move main.cpp to src + other small fixes and comments

This commit is contained in:
HJfod 2022-05-14 12:48:38 +03:00
parent 9833970547
commit 48515856f0
5 changed files with 68 additions and 46 deletions

View file

@ -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})

21
LICENSE
View file

@ -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.

View file

@ -1,7 +0,0 @@
#include <Geode.hpp>
class $modify(MenuLayer) {
void onMoreGames(cocos2d::CCObject*) {
FLAlertLayer::create("Geode", "Hello from custom mod!", "OK")->show();
}
};

View file

@ -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
}
]
}

32
src/main.cpp Normal file
View file

@ -0,0 +1,32 @@
/**
* Include the Geode headers.
*/
#include <Geode.hpp>
/**
* 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();
}
};