Skip to content

Commit 79ec8a1

Browse files
committed
evil modules
1 parent 6f4b4c3 commit 79ec8a1

14 files changed

Lines changed: 79 additions & 42 deletions

CMakeLists.txt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
cmake_minimum_required(VERSION 3.21)
1+
cmake_minimum_required(VERSION 3.26)
2+
23
set(CMAKE_CXX_STANDARD 23)
34
set(CMAKE_CXX_STANDARD_REQUIRED ON)
5+
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
6+
47
if("${CMAKE_SYSTEM_NAME}" STREQUAL "iOS" OR IOS)
58
set(CMAKE_OSX_ARCHITECTURES "arm64")
69
else()
710
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
811
endif()
9-
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
1012

1113
project(HorribleIdeas VERSION 1.0.0)
1214

15+
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
16+
1317
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.cpp)
14-
add_library(${PROJECT_NAME} SHARED ${SOURCES})
18+
file(GLOB_RECURSE MODULES CONFIGURE_DEPENDS src/*.cppm)
19+
20+
add_library(${PROJECT_NAME} SHARED)
21+
22+
target_sources(${PROJECT_NAME}
23+
PRIVATE ${SOURCES}
24+
PUBLIC FILE_SET cxx_modules TYPE CXX_MODULES FILES ${MODULES}
25+
)
1526

1627
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/include)
1728

@@ -25,6 +36,8 @@ else()
2536
message(STATUS "Found Geode: $ENV{GEODE_SDK}")
2637
endif()
2738

39+
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
2840
add_subdirectory($ENV{GEODE_SDK} ${CMAKE_CURRENT_BINARY_DIR}/geode)
41+
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
2942

3043
setup_geode_mod(${PROJECT_NAME})

include/Option.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace horrible {
2828
Option() = default; // Default constructor
2929

3030
// Constructor
31-
Option(
31+
inline Option(
3232
std::string id,
3333
std::string name,
3434
std::string description,

src/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#include <Utils.hpp>
22

3-
#include <menu/OptionMenuButton.hpp>
4-
#include <menu/SettingV3.hpp>
5-
63
#include <ranges>
74

85
#include <Geode/modify/PlayLayer.hpp>
@@ -11,6 +8,9 @@
118

129
using namespace horrible::prelude;
1310

11+
import OptionMenuButton;
12+
import SettingV3;
13+
1414
inline static std::vector<Hook*> safeModeHooks;
1515
inline static std::vector<Hook*> floatingBtnHooks;
1616

@@ -41,7 +41,7 @@ inline static std::vector<Hook*> floatingBtnHooks;
4141
}; \
4242
}
4343

44-
$on_game(Loaded) {
44+
$on_mod(Loaded) {
4545
(void)horribleMod->registerCustomSettingType("menu", &HorribleSettingV3::parse);
4646

4747
if (auto fb = OptionMenuButton::get()) OverlayManager::get()->addChild(fb);
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
#pragma once
1+
module;
22

33
#include <Geode/Geode.hpp>
44

55
using namespace geode::prelude;
66

7+
export module OptionCategoryItem;
8+
79
// Event for option toggles
8-
struct CategoryEvent final : Event<CategoryEvent, bool(std::string_view, bool)> {
10+
export struct CategoryEvent final : Event<CategoryEvent, bool(std::string_view, bool)> {
911
using Event::Event;
1012
};
1113

12-
class OptionCategoryItem final : public CCMenu {
14+
export class OptionCategoryItem final : public CCMenu {
1315
private:
1416
class Impl;
1517
std::unique_ptr<Impl> m_impl;
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
module;
22

33
#include <Utils.hpp>
44

@@ -7,12 +7,14 @@
77
using namespace geode::prelude;
88
using namespace horrible;
99

10+
export module OptionItem;
11+
1012
// Event for pin toggles
11-
struct PinEvent final : Event<PinEvent, bool()> {
13+
export struct PinEvent final : Event<PinEvent, bool()> {
1214
using Event::Event;
1315
};
1416

15-
class OptionItem final : public CCMenu {
17+
export class OptionItem final : public CCMenu {
1618
private:
1719
class Impl;
1820
std::unique_ptr<Impl> m_impl;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#pragma once
2-
3-
#include "OptionCategoryItem.hpp"
1+
module;
42

53
#include <Utils.hpp>
64

@@ -9,7 +7,9 @@
97
using namespace geode::prelude;
108
using namespace horrible;
119

12-
class OptionMenu final : public Popup {
10+
export module OptionMenu;
11+
12+
export class OptionMenu final : public Popup {
1313
private:
1414
class Impl;
1515
std::unique_ptr<Impl> m_impl;
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
#pragma once
1+
module;
22

33
#include <Geode/Geode.hpp>
44

55
using namespace geode::prelude;
66

7-
class OptionMenuButton final : public CCLayer {
7+
export module OptionMenuButton;
8+
9+
export class OptionMenuButton final : public CCLayer {
810
private:
911
class Impl;
1012
std::unique_ptr<Impl> m_impl;
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
#pragma once
1+
module;
22

33
#include <Geode/Geode.hpp>
44

55
#include <Geode/loader/SettingV3.hpp>
66

77
using namespace geode::prelude;
88

9-
class HorribleSettingV3 final : public SettingV3 {
9+
export module SettingV3;
10+
11+
export class HorribleSettingV3 final : public SettingV3 {
1012
public:
1113
static Result<std::shared_ptr<SettingV3>> parse(
1214
std::string key,
@@ -23,7 +25,7 @@ class HorribleSettingV3 final : public SettingV3 {
2325
SettingNodeV3* createNode(float width) override;
2426
};
2527

26-
class HorribleSettingNodeV3 final : public SettingNodeV3 {
28+
export class HorribleSettingNodeV3 final : public SettingNodeV3 {
2729
private:
2830
class Impl;
2931
std::unique_ptr<Impl> m_impl;

src/menu/src/OptionCategoryItem.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
#include "../OptionCategoryItem.hpp"
1+
module;
22

3-
#include <Geode/Geode.hpp>
43
#include <Utils.hpp>
54

5+
#include <Geode/Geode.hpp>
6+
67
using namespace geode::prelude;
78
using namespace horrible::prelude;
89

10+
module OptionCategoryItem;
11+
912
class OptionCategoryItem::Impl final {
1013
public:
1114
std::string category = ""; // The category name

src/menu/src/OptionItem.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "../OptionItem.hpp"
1+
module;
22

33
#include <Utils.hpp>
44

@@ -7,6 +7,8 @@
77
using namespace geode::prelude;
88
using namespace horrible::prelude;
99

10+
module OptionItem;
11+
1012
class OptionItem::Impl final {
1113
public:
1214
bool compatible = false; // If this option is compatible with the current platform

0 commit comments

Comments
 (0)