diff --git a/CMakeLists.txt b/CMakeLists.txt index 15ddde33..3e16c50e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,9 @@ project(geode-sdk VERSION ${GEODE_VERSION} LANGUAGES CXX C) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) +if (APPLE) + set(CMAKE_BUILD_TYPE Debug) +endif() add_library(${PROJECT_NAME} INTERFACE) diff --git a/bindings/Cocos2d.bro b/bindings/Cocos2d.bro index 00e2c55c..9d9b04c1 100644 --- a/bindings/Cocos2d.bro +++ b/bindings/Cocos2d.bro @@ -21,8 +21,8 @@ class cocos2d::CCApplication { virtual auto setAnimationInterval(double) = mac 0x1a3ee0, ios 0x10e494; static auto sharedApplication() = mac 0x1a3f30; // ~CCApplication() = mac 0x1a3d10, ios 0x10e384; - inline cocos2d::CCApplication::CCApplication() {} - inline cocos2d::CCApplication::~CCApplication() {} + CCApplication() {} + ~CCApplication() {} } class cocos2d::CCArray { @@ -96,8 +96,8 @@ class cocos2d::CCDictionary { } class cocos2d::CCDirector { - inline cocos2d::CCDirector::CCDirector() {} - inline cocos2d::CCDirector::~CCDirector() {} + CCDirector() {} + ~CCDirector() {} // virtual ~CCDirector() = mac 0x2493a0; virtual auto init() = mac 0x248df0; virtual auto getScheduler() = mac 0x24af00; @@ -148,6 +148,10 @@ class cocos2d::CCDrawNode { virtual ~CCDrawNode() = mac 0x378cc0; } +class cocos2d::CCEaseBackIn { + static cocos2d::CCEaseBackIn* create(cocos2d::CCActionInterval*) = mac 0x2a41b0; +} + class cocos2d::CCEaseElasticOut { static cocos2d::CCEaseElasticOut* create(cocos2d::CCActionInterval*, float) = mac 0x2a3080; } @@ -209,12 +213,12 @@ class cocos2d::CCHide { } class cocos2d::CCIMEDelegate { - inline cocos2d::CCIMEDelegate::~CCIMEDelegate() { + ~CCIMEDelegate() { CCIMEDispatcher::sharedDispatcher()->removeDelegate(this); } virtual auto attachWithIME() = mac 0x2776a0, ios 0x12d3d4; virtual auto detachWithIME() = mac 0x277880, ios 0x12d4e8; - inline cocos2d::CCIMEDelegate::CCIMEDelegate() { + CCIMEDelegate() { CCIMEDispatcher::sharedDispatcher()->addDelegate(this); } } @@ -308,6 +312,7 @@ class cocos2d::CCLayer { class cocos2d::CCLayerColor { CCLayerColor() = mac 0x274320, ios 0xc8aec; static cocos2d::CCLayerColor* create(cocos2d::_ccColor4B const&, float, float) = mac 0x2745e0; + static cocos2d::CCLayerColor* create(cocos2d::_ccColor4B const&) = mac 0x2744c0; auto draw() = mac 0x274b50, ios 0xc8fe0; auto getBlendFunc() = mac 0x274480, ios 0xc8bcc; auto init() = mac 0x274800, ios 0xc8de8; @@ -365,6 +370,7 @@ class cocos2d::CCMenu { } class cocos2d::CCMenuItem { + auto initWithTarget(cocos2d::CCObject*, cocos2d::SEL_MenuHandler) = mac 0x1fb7f0; virtual ~CCMenuItem() = mac 0x1fb8e0, ios 0x2cdf4; virtual auto activate() = mac 0x1fba70, ios 0x2ceb0; virtual auto selected() = mac 0x1fb9e0, ios 0x2ce2e; @@ -442,6 +448,7 @@ class cocos2d::CCMoveTo { class cocos2d::CCNode { CCNode() = mac 0x122550; + auto boundingBox() = mac 0x123030; virtual auto _setZOrder(int) = mac 0x122990, ios 0x15dd7c; virtual auto addChild(cocos2d::CCNode*) = mac 0x1233d0, ios 0x15e5d4; virtual auto addChild(cocos2d::CCNode*, int) = mac 0x1233b0, ios 0x15e5c4; @@ -616,6 +623,10 @@ class cocos2d::CCRenderTexture { auto newCCImage(bool) = mac 0x35d7d0; } +class cocos2d::CCRepeat { + static cocos2d::CCRepeat* create(cocos2d::CCFiniteTimeAction*, unsigned int) = mac 0x1f3230; +} + class cocos2d::CCRepeatForever { static cocos2d::CCRepeatForever* create(cocos2d::CCActionInterval*) = mac 0x1f3920; } @@ -823,6 +834,7 @@ class cocos2d::CCTouch { auto getLocationInView() const = mac 0x38250; auto getPreviousLocationInView() const = mac 0x38270; auto getLocation() const = mac 0x382b0, ios 0x21ce78; + auto getStartLocation() const = mac 0x382e0; } class cocos2d::CCTouchDispatcher { @@ -852,7 +864,7 @@ class cocos2d::ZipUtils { } class cocos2d::extension::CCControl { - inline cocos2d::extension::CCControl::CCControl() {} + CCControl() {} virtual bool init() = mac 0x1a71c0; virtual ~CCControl() = mac 0x1a7380; auto sendActionsForControlEvents(cocos2d::extension::CCControlEvent) = mac 0x1a7490; @@ -875,7 +887,7 @@ class cocos2d::extension::CCControl { } class cocos2d::extension::CCControlColourPicker { - inline cocos2d::extension::CCControlColourPicker::CCControlColourPicker() {} + CCControlColourPicker() {} ~CCControlColourPicker() = mac 0x1aae30; auto setColorValue(cocos2d::_ccColor3B const&) = mac 0x1aac10; auto ccTouchBegan(cocos2d::CCTouch*, cocos2d::CCEvent*) = mac 0x1aae10; @@ -893,6 +905,8 @@ class cocos2d::extension::CCScale9Sprite { CCScale9Sprite() = mac 0x211330; static cocos2d::extension::CCScale9Sprite* create(char const*) = mac 0x2130d0; static cocos2d::extension::CCScale9Sprite* create(char const*, cocos2d::CCRect) = mac 0x212ef0; + static cocos2d::extension::CCScale9Sprite* createWithSpriteFrameName(char const*, cocos2d::CCRect) = mac 0x213380; + static cocos2d::extension::CCScale9Sprite* createWithSpriteFrameName(char const*) = mac 0x213460; virtual ~CCScale9Sprite() = mac 0x211590; virtual auto init() = mac 0x2115d0; virtual auto setContentSize(cocos2d::CCSize const&) = mac 0x2127c0, ios 0x13e400; diff --git a/bindings/GeometryDash.bro b/bindings/GeometryDash.bro index 678bbfa9..adef0a3a 100644 --- a/bindings/GeometryDash.bro +++ b/bindings/GeometryDash.bro @@ -4907,7 +4907,7 @@ class Slider : cocos2d::CCLayer { this->m_sliderBar->setVisible(v); } static Slider* create(cocos2d::CCNode* target, cocos2d::SEL_MenuHandler click, float scale) { - return create(target, click, nullptr, "slidergroove.png", "sliderthumb.png", "sliderthumbsel.png", scale); + return create(target, click, "sliderBar.png", "slidergroove.png", "sliderthumb.png", "sliderthumbsel.png", scale); } float getValue() = mac 0x18e0c0, win 0x2e970, ios 0x0; diff --git a/cmake/Platform.cmake b/cmake/Platform.cmake index b2c3a78a..d7ea4cd0 100644 --- a/cmake/Platform.cmake +++ b/cmake/Platform.cmake @@ -40,7 +40,7 @@ elseif (GEODE_TARGET_PLATFORM STREQUAL "MacOS") ) target_link_libraries(${PROJECT_NAME} INTERFACE curl "-framework Cocoa") - target_compile_options(${PROJECT_NAME} INTERFACE -fms-extensions -Wno-deprecated -Wno-ignored-attributes -Os -flto -fvisibility=internal) + target_compile_options(${PROJECT_NAME} INTERFACE -fms-extensions -Wno-deprecated -Wno-ignored-attributes -Os #[[-flto]] -fvisibility=internal) target_compile_definitions(${PROJECT_NAME} INTERFACE -DCC_TARGET_OS_MAC) set(GEODE_PLATFORM_BINARY "Geode.dylib") diff --git a/codegen/src/SourceGen.cpp b/codegen/src/SourceGen.cpp index 338ec027..fa0d0a37 100644 --- a/codegen/src/SourceGen.cpp +++ b/codegen/src/SourceGen.cpp @@ -63,9 +63,12 @@ types::ret{index} {class_name}::{function_name}({parameters}){const} {{ }} )GEN"; - // requires: static, return_type, function_name, raw_parameters, const, class_name, definition char const* ool_function_definition = R"GEN( {return} {class_name}::{function_name}({parameters}){const} {definition} +)GEN"; + + char const* ool_structor_function_definition = R"GEN( +{class_name}::{function_name}({parameters}){const} {definition} )GEN"; }} @@ -81,15 +84,34 @@ std::string generateGDSource(Root& root) { output += i->inner + "\n"; } } else if (auto fn = f.get_as<OutOfLineField>()) { - output += fmt::format(format_strings::ool_function_definition, - fmt::arg("function_name", fn->beginning.name), - fmt::arg("const", str_if(" const ", fn->beginning.is_const)), - fmt::arg("class_name", c.name), - fmt::arg("parameters", codegen::getParameters(fn->beginning)), - fmt::arg("index", f.field_id), - fmt::arg("definition", fn->inner), - fmt::arg("return", fn->beginning.ret.name) - ); + if (codegen::getStatus(f) != BindStatus::Unbindable) + continue; + + switch (fn->beginning.type) { + case FunctionType::Ctor: + case FunctionType::Dtor: + output += fmt::format(format_strings::ool_structor_function_definition, + fmt::arg("function_name", fn->beginning.name), + fmt::arg("const", str_if(" const ", fn->beginning.is_const)), + fmt::arg("class_name", c.name), + fmt::arg("parameters", codegen::getParameters(fn->beginning)), + fmt::arg("index", f.field_id), + fmt::arg("definition", fn->inner) + ); + break; + default: + output += fmt::format(format_strings::ool_function_definition, + fmt::arg("function_name", fn->beginning.name), + fmt::arg("const", str_if(" const ", fn->beginning.is_const)), + fmt::arg("class_name", c.name), + fmt::arg("parameters", codegen::getParameters(fn->beginning)), + fmt::arg("index", f.field_id), + fmt::arg("definition", fn->inner), + fmt::arg("return", fn->beginning.ret.name) + ); + break; + } + } else if (auto fn = f.get_as<FunctionBindField>()) { if (codegen::getStatus(f) != BindStatus::NeedsBinding) continue; diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 00a13695..4855994d 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -62,30 +62,11 @@ make_directory("${GEODE_BIN_PATH}/nightly") set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME "Geode" - LIBRARY_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}" - RUNTIME_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}" - ARCHIVE_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}" + LIBRARY_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}/nightly" + RUNTIME_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}/nightly" + ARCHIVE_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}/nightly" ) -# Move compiled binary into `bin/nightly` directory -if (APPLE) - add_custom_command( - COMMAND - ${CMAKE_COMMAND} -E rename "$<TARGET_FILE:${PROJECT_NAME}>" "${GEODE_BIN_PATH}/nightly/$<TARGET_FILE_NAME:${PROJECT_NAME}>" - DEPENDS $<TARGET_FILE:${PROJECT_NAME}> - VERBATIM - TARGET ${PROJECT_NAME} - ) -elseif(WIN32) - add_custom_command( - COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:${PROJECT_NAME}>" "${GEODE_BIN_PATH}/nightly/$<TARGET_FILE_NAME:${PROJECT_NAME}>" - COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_LINKER_FILE:${PROJECT_NAME}>" "${GEODE_BIN_PATH}/nightly/$<TARGET_LINKER_FILE_NAME:${PROJECT_NAME}>" - DEPENDS $<TARGET_FILE:${PROJECT_NAME}> - VERBATIM - TARGET ${PROJECT_NAME} - ) -endif() - if (NOT GEODE_DISABLE_CLI_CALLS) # Package resources for UI package_geode_resources( diff --git a/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControlColourPicker.h b/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControlColourPicker.h index 001175ad..d1c6fa25 100644 --- a/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControlColourPicker.h +++ b/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControlColourPicker.h @@ -63,6 +63,9 @@ public: virtual ~CCControlColourPicker(); protected: + RT_ADD( + ccColor3B m_rgb; + ) HSV m_hsv; CC_SYNTHESIZE_RETAIN(CCControlSaturationBrightnessPicker*, m_colourPicker, colourPicker) diff --git a/loader/include/Geode/modify/Field.hpp b/loader/include/Geode/modify/Field.hpp index b7e75ebe..566f4231 100644 --- a/loader/include/Geode/modify/Field.hpp +++ b/loader/include/Geode/modify/Field.hpp @@ -73,7 +73,8 @@ namespace geode::modifier { template <class=std::enable_if_t<true>> Parent* operator->() { // get the this pointer of the base - auto node = reinterpret_cast<Parent*>(reinterpret_cast<std::byte*>(this) - offsetof(Parent, m_fields)); + auto node = reinterpret_cast<Parent*>(reinterpret_cast<std::byte*>(this) - sizeof(Base)); + static_assert(sizeof(Base) == offsetof(Parent, m_fields), "offsetof not correct"); auto container = reinterpret_cast<FieldContainer*>(node->getUserObject()); if (!container) { container = FieldContainer::create(); diff --git a/loader/resources/about.md b/loader/resources/about.md index 677dbd8e..a5c317fa 100644 --- a/loader/resources/about.md +++ b/loader/resources/about.md @@ -38,4 +38,8 @@ Using * [fmt](https://fmt.dev/latest/index.html) + * [PEGTL](https://github.com/taocpp/PEGTL) + + * [md4c](https://github.com/mity/md4c) + Special thanks to [RobTop Games](https://twitter.com/RobTopGames/) for making this amazing game and providing us and so many others with hours of entertainment <3 diff --git a/loader/src/ui/internal/settings/GeodeSettingNode.hpp b/loader/src/ui/internal/settings/GeodeSettingNode.hpp index 1afbc9d3..ed3efb5d 100644 --- a/loader/src/ui/internal/settings/GeodeSettingNode.hpp +++ b/loader/src/ui/internal/settings/GeodeSettingNode.hpp @@ -293,7 +293,9 @@ namespace { m_decArrow = CCMenuItemSpriteExtra::create( decArrowSpr, self(), - menu_selector(ImplArrows::onDecrement) + makeMenuSelector([this](CCObject*){ + onDecrement(self()); + }) ); m_decArrow->setPosition(-width / 2 + 80.f, yPos); self()->m_menu->addChild(m_decArrow); @@ -303,7 +305,9 @@ namespace { m_incArrow = CCMenuItemSpriteExtra::create( incArrowSpr, self(), - menu_selector(ImplArrows::onIncrement) + makeMenuSelector([this](CCObject*){ + onIncrement(self()); + }) ); m_incArrow->setPosition(-10.f, yPos); self()->m_menu->addChild(m_incArrow); @@ -316,7 +320,9 @@ namespace { m_bigDecArrow = CCMenuItemSpriteExtra::create( decArrowSpr, self(), - (SEL_MenuHandler)(&ImplArrows<C, T>::onBigDecrement) + makeMenuSelector([this](CCObject*){ + onBigDecrement(self()); + }) ); m_bigDecArrow->setPosition(-width / 2 + 65.f, yPos); self()->m_menu->addChild(m_bigDecArrow); @@ -326,39 +332,37 @@ namespace { m_bigIncArrow = CCMenuItemSpriteExtra::create( incArrowSpr, self(), - (SEL_MenuHandler)(&ImplArrows<C, T>::onBigIncrement) + makeMenuSelector([this](CCObject*){ + onBigIncrement(self()); + }) ); m_bigIncArrow->setPosition(5.f, yPos); self()->m_menu->addChild(m_bigIncArrow); } } - void onIncrement(CCObject*) { - auto self = reinterpret_cast<C*>(this); + static void onIncrement(C* self) { self->m_uncommittedValue += std::static_pointer_cast<T>( self->m_setting )->getArrowStepSize(); self->valueChanged(true); } - void onDecrement(CCObject*) { - auto self = reinterpret_cast<C*>(this); + static void onDecrement(C* self) { self->m_uncommittedValue -= std::static_pointer_cast<T>( self->m_setting )->getArrowStepSize(); self->valueChanged(true); } - void onBigIncrement(CCObject*) { - auto self = reinterpret_cast<C*>(this); + static void onBigIncrement(C* self) { self->m_uncommittedValue += std::static_pointer_cast<T>( self->m_setting )->getBigArrowStepSize(); self->valueChanged(true); } - void onBigDecrement(CCObject*) { - auto self = reinterpret_cast<C*>(this); + static void onBigDecrement(C* self) { self->m_uncommittedValue -= std::static_pointer_cast<T>( self->m_setting )->getBigArrowStepSize(); @@ -375,7 +379,7 @@ namespace { return static_cast<C*>(this); } - float valueToSlider( + static float valueToSlider( std::shared_ptr<T> setting, typename T::value_t num ) { @@ -387,7 +391,7 @@ namespace { )); } - typename T::value_t valueFromSlider( + static typename T::value_t valueFromSlider( std::shared_ptr<T> setting, float num ) { @@ -406,7 +410,9 @@ namespace { void setupSlider(std::shared_ptr<T> setting, float width) { if (setting->hasSlider()) { m_slider = Slider::create( - self(), menu_selector(ImplSlider::onSlider), .5f + self(), makeMenuSelector([this](CCObject* slider){ + onSlider(self(), slider); + }), .5f ); m_slider->setPosition(-50.f, -15.f); self()->m_menu->addChild(m_slider); @@ -423,8 +429,7 @@ namespace { m_slider->updateBar(); } - void onSlider(CCObject* slider) { - auto self = reinterpret_cast<C*>(this); + static void onSlider(C* self, CCObject* slider) { auto setting = std::static_pointer_cast<T>(self->m_setting); self->m_uncommittedValue = valueFromSlider( diff --git a/loader/src/utils/mac/util.mm b/loader/src/utils/mac/util.mm index 1cfd875c..8a1e2fc3 100644 --- a/loader/src/utils/mac/util.mm +++ b/loader/src/utils/mac/util.mm @@ -7,6 +7,7 @@ USE_GEODE_NAMESPACE(); #include <iostream> #include <sstream> #include <Cocoa/Cocoa.h> +#include <functional> bool utils::clipboard::write(std::string const& data) { [[NSPasteboard generalPasteboard] clearContents]; @@ -40,4 +41,46 @@ void utils::web::openLinkInBrowser(std::string const& url) { [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[NSString stringWithUTF8String: url.c_str()]]]; } +// @interface FileDialog : NSObject +// + (Result<ghc::filesystem::path>)importDocumentWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options; +// + (Result<std::vector<ghc::filesystem::path>>)importDocumentsWithOptions:(file::FilePickOptions const&)options +// @end + +// @implementation FileDialog + +// + (Result<ghc::filesystem::path>)importDocumentWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options { +// NSOpenPanel* panel = [NSOpenPanel openPanel]; +// // TODO: [panel setAllowedFileTypes:@[]]; + +// auto defaultPath = [NSString stringWithCString:options.defaultPath.c_str() encoding:NSUTF8StringEncoding]; +// [panel setDirectoryURL: [NSURL fileURLWithPath: defaultPath]]; +// [panel beginWithCompletionHandler:^(NSInteger result){ +// if (result == NSFileHandlingPanelOKButton) { +// auto fileUrl = [[panel URLs] objectAtIndex:0]; +// auto path = std::string([[fileUrl path] UTF8String], [[fileUrl path] lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); +// return Ok(path); +// } +// else { +// return Err(result); +// } +// }]; +// } + +// @end + +Result<ghc::filesystem::path> utils::file::pickFile( + file::PickMode mode, + file::FilePickOptions const& options +) { + return Err("utils::file::pickFile is not implemented"); + // return [FileDialog importDocumentWithMode:mode options:options]; +} + +Result<std::vector<ghc::filesystem::path>> utils::file::pickFiles( + file::FilePickOptions const& options +) { + return Err("utils::file::pickFiles is not implemented"); + // return [FileDialog importDocumentWithOptions:options]; +} + #endif diff --git a/loader/test/dependency/CMakeLists.txt b/loader/test/dependency/CMakeLists.txt index 2919f79e..b6230d14 100644 --- a/loader/test/dependency/CMakeLists.txt +++ b/loader/test/dependency/CMakeLists.txt @@ -10,11 +10,11 @@ add_library(${PROJECT_NAME} SHARED main.cpp) add_compile_definitions(EXPORTING_MOD) +set(GEODE_LINK_SOURCE ON) set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") target_link_libraries( ${PROJECT_NAME} - geode-loader geode-sdk ) diff --git a/loader/test/main/CMakeLists.txt b/loader/test/main/CMakeLists.txt index 0ca12732..9a11d192 100644 --- a/loader/test/main/CMakeLists.txt +++ b/loader/test/main/CMakeLists.txt @@ -8,11 +8,11 @@ project(${PROJECT_NAME} VERSION 1.0.0) add_library(${PROJECT_NAME} SHARED main.cpp) +set(GEODE_LINK_SOURCE ON) set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") target_link_libraries( ${PROJECT_NAME} - geode-loader geode-sdk )