diff --git a/CMakeLists.txt b/CMakeLists.txt index c248fff..d6fe5bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,17 +4,35 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) project(Template VERSION 1.0.0) -add_library(${PROJECT_NAME} SHARED main.cpp) +# Use GLOB_RECURSE instead of GLOB +# to recursively add all source files +# under src/ +file(GLOB SOURCES + src/*.cpp +) + +# Set up the mod binary +add_library(${PROJECT_NAME} SHARED ${SOURCES}) set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") +# Find Geode. If you've installed +# the Geode developer tools using +# the official installer, this should +# work out-of-the-box; otherwise, you +# will have to add the GEODE_SUITE +# environment variable yourself. find_path(GEODE_SDK_PATH - NAMES Geode.cmake - PATHS $ENV{GEODE_SUITE}/sdk /Users/Shared/Geode/suite/sdk /usr/local/geode/sdk - DOC "Geode SDK path." - REQUIRED + NAMES Geode.cmake + PATHS $ENV{GEODE_SUITE}/sdk /Users/Shared/Geode/suite/sdk /usr/local/geode/sdk + DOC "Geode SDK path." + REQUIRED ) include(${GEODE_SDK_PATH}/Geode.cmake) +# Set up this project as a Geode mod. +# This will include all the required +# directories and link the necessary +# libraries, as well as create & +# install the .geode package after +# builds. setup_geode_mod() - -create_geode_file(${PROJECT_NAME}) \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 7f4a72c..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 Geode SDK - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/main.cpp b/main.cpp deleted file mode 100644 index 83b776c..0000000 --- a/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -class $modify(MenuLayer) { - void onMoreGames(cocos2d::CCObject*) { - FLAlertLayer::create("Geode", "Hello from custom mod!", "OK")->show(); - } -}; diff --git a/mod.json b/mod.json index 46b7576..9506cfd 100644 --- a/mod.json +++ b/mod.json @@ -1,15 +1,15 @@ { - "geode": 1, + "geode": 1, "version": "v1.0.0", "id": "com.you.template", - "name": "Template", - "developer": "You", - "description": "template mod", - "binary": "Template", - "dependencies": [ - { - "id": "com.geode.api", - "required": true - } - ] + "name": "Template", + "developer": "You", + "description": "template mod", + "binary": "Template", + "dependencies": [ + { + "id": "com.geode.api", + "required": true + } + ] } diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..73b55fb --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,32 @@ +/** + * Include the Geode headers. + */ +#include + +/** + * Brings cocos2d and all Geode namespaces + * to the current scope. + */ +USE_GEODE_NAMESPACE(); + +/** + * `$modify` lets you extend and modify GD's + * classes; to hook a function in Geode, + * simply $modify the class and write a new + * function definition with the signature of + * the one you want to hook. + */ +class $modify(MenuLayer) { + /** + * MenuLayer::onMoreGames is a GD function, + * so we hook it by simply writing its name + * inside a $modified MenuLayer class. + * + * Note that for all hooks, your signature + * has to match exactly - `bool onMoreGames` + * would not place a hook! + */ + void onMoreGames(CCObject*) { + FLAlertLayer::create("Geode", "Hello from my custom mod!", "OK")->show(); + } +};