diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 44102bff..e0e4ae1b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -145,7 +145,7 @@ jobs: dest: geode-nightly-win.zip - name: Update release - uses: IsaacShelton/update-existing-release@v1.3.1 + uses: IsaacShelton/update-existing-release@v1.3.2 with: token: ${{ secrets.GITHUB_TOKEN }} files: ./geode-nightly-mac.zip ./geode-nightly-win.zip diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ebc5b74..fed7a527 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,6 +122,10 @@ file(GLOB CODEGEN_DEPENDS CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/codegen/src/*.hpp ) +if (NOT GEODE_BINDINGS_PATH) + set(GEODE_BINDINGS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bindings) +endif() + file(GLOB CODEGEN_OUTPUTS CONFIGURE_DEPENDS ${GEODE_CODEGEN_PATH}/Geode/binding/*.hpp ) @@ -129,7 +133,7 @@ file(GLOB CODEGEN_OUTPUTS CONFIGURE_DEPENDS add_custom_command( DEPENDS ${CODEGEN_DEPENDS} DEPENDS CodegenProject - COMMAND ${GEODE_CODEGEN_BINARY_OUT}/Codegen ${GEODE_TARGET_PLATFORM} bindings ${GEODE_CODEGEN_PATH} + COMMAND ${GEODE_CODEGEN_BINARY_OUT}/Codegen ${GEODE_TARGET_PLATFORM} ${GEODE_BINDINGS_PATH} ${GEODE_CODEGEN_PATH} COMMAND echo codegen > ${GEODE_CODEGEN_PATH}/.stamp WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Run Codegen" diff --git a/bindings/GeometryDash.bro b/bindings/GeometryDash.bro index 4978f33d..c876ae9e 100644 --- a/bindings/GeometryDash.bro +++ b/bindings/GeometryDash.bro @@ -2256,7 +2256,7 @@ class GJGameLevel : cocos2d::CCNode { void getNormalPercent() = mac 0x2b8b20; void levelWasAltered() = mac 0x2db530, win 0xbd550; void savePercentage(int, bool, int, int, bool) = mac 0x2db700; - void dataLoaded(DS_Dictionary* dict) = mac 0x2922f0, win 0xbded0, ios 0x6fca4; + void dataLoaded(DS_Dictionary* dict) = mac 0x2dc0e0, win 0xbded0, ios 0x6fca4; GJDifficulty getAverageDifficulty() = win 0xbd9b0; gd::string getUnpackedLevelDescription() = win 0xbf890; gd::string lengthKeyToString(int key) = win 0xbd910; @@ -2310,7 +2310,7 @@ class GJGameLevel : cocos2d::CCNode { int m_chk; bool m_isChkValid; bool m_isCompletionLegitimate; - geode::SeedValueVSR m_normalPercent; + geode::SeedValueVRS m_normalPercent; geode::SeedValueRSV m_orbCompletion; geode::SeedValueRSV m_newNormalPercent2; int m_practicePercent; @@ -2576,8 +2576,8 @@ class GJSearchObject : cocos2d::CCNode { return m_searchType; } - static GJSearchObject* create(SearchType nID) = win 0xc2b90; - static GJSearchObject* create(SearchType nID, gd::string str) = win 0xc2c80; + static GJSearchObject* create(SearchType nID) = win 0xc2b90, mac 0x2df120; + static GJSearchObject* create(SearchType nID, gd::string str) = win 0xc2c80, mac 0x2df310; SearchType m_searchType; gd::string m_searchQuery; @@ -3670,13 +3670,13 @@ class LevelBrowserLayer : cocos2d::CCLayer { void updateLevelsLabel() = win 0x15c350; static LevelBrowserLayer* create(GJSearchObject* search) = mac 0x251210, win 0x159fa0, ios 0x2d0a00; - PAD = win 0x18; + PAD = win 0x18, mac 0x30; GJListLayer* m_list; CCMenuItemSpriteExtra* m_leftArrow; CCMenuItemSpriteExtra* m_rightArrow; - PAD = win 0x10; + PAD = win 0x10, mac 0x20; GJSearchObject* m_searchObject; - PAD = win 0x14; + PAD = win 0x14, mac 0x28; int m_itemCount; int m_pageStartIdx; int m_pageEndIdx; @@ -3923,14 +3923,14 @@ class LevelInfoLayer : cocos2d::CCLayer, LevelDownloadDelegate, LevelUpdateDeleg void setupProgressBars() = win 0x177fc0; void downloadLevel() = win 0x177d90; - PAD = win 0x4; + PAD = win 0x4, mac 0x8; cocos2d::CCMenu* m_playBtnMenu; GJGameLevel* m_level; cocos2d::CCArray* m_unknown; CCMenuItemSpriteExtra* m_likeBtn; CCMenuItemSpriteExtra* m_starRateBtn; CCMenuItemSpriteExtra* m_demonRateBtn; - PAD = win 0x4; + PAD = win 0x4, mac 0x8; CCMenuItemToggler* m_toggler; cocos2d::CCLabelBMFont* m_label0; cocos2d::CCLabelBMFont* m_label1; @@ -3939,7 +3939,7 @@ class LevelInfoLayer : cocos2d::CCLayer, LevelDownloadDelegate, LevelUpdateDeleg cocos2d::CCLabelBMFont* m_label4; cocos2d::CCLabelBMFont* m_label5; CCMenuItemSpriteExtra* m_cloneBtn; - PAD = win 0x4; + PAD = win 0x4, mac 0x8; } class LevelLeaderboard : FLAlertLayer { @@ -4148,7 +4148,7 @@ class LocalLevelManager : GManager { cocos2d::CCDictionary* getAllLevelsInDict() = mac 0x35e3d0, win 0x18d7c0; - PAD = mac 0x10, win 0x1C; + PAD = mac 0x4, win 0x1C; cocos2d::CCDictionary* m_loadData; cocos2d::CCDictionary* m_levelData; cocos2d::CCArray* m_localLevels; diff --git a/flash.toml b/flash.toml index 8ecd8e62..dc749c85 100644 --- a/flash.toml +++ b/flash.toml @@ -4,7 +4,7 @@ [project] name = "Geode" -version = "v1.0.0-beta" +version = "v1.0.0" repository = "https://github.com/geode-sdk/geode" tree = "https://github.com/geode-sdk/geode/tree/main" icon = "loader/resources/logos/geode-circle.png" @@ -60,4 +60,4 @@ build-args = [ ] # The file we use to get all the include paths and such -infer-args-from = "loader/src/main.cpp" +infer-args-from = "loader/src/load.cpp" diff --git a/loader/include/Geode/ui/EnterLayerEvent.hpp b/loader/include/Geode/ui/EnterLayerEvent.hpp index 91c22835..acab4980 100644 --- a/loader/include/Geode/ui/EnterLayerEvent.hpp +++ b/loader/include/Geode/ui/EnterLayerEvent.hpp @@ -53,7 +53,7 @@ namespace geode { template concept InheritsEnterLayer = std::is_base_of_v, T>; - template T> + template T = EnterLayerEvent> class EnterLayerFilter : public EventFilter> { public: using Callback = void(T*); diff --git a/loader/src/platform/mac/util.mm b/loader/src/platform/mac/util.mm index 5e21154c..192494f9 100644 --- a/loader/src/platform/mac/util.mm +++ b/loader/src/platform/mac/util.mm @@ -75,25 +75,14 @@ void utils::web::openLinkInBrowser(std::string const& url) { @implementation FileDialog +(Result>) filePickerWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options multiple:(bool)mult { - NSOpenPanel* panel = [NSOpenPanel openPanel]; + NSSavePanel* panel; + if (mode == file::PickMode::SaveFile) + panel = [NSSavePanel savePanel]; + else + panel = [NSOpenPanel openPanel]; - // allowed files - NSMutableArray* allowed = [NSMutableArray array]; + [panel setCanCreateDirectories: TRUE]; - for (auto& f : options.filters) { - for (auto& i : f.files) { - auto nsstr = [NSString stringWithUTF8String: i.c_str()]; - - if (![allowed containsObject: nsstr]) - [allowed addObject: nsstr]; - } - } - - if (options.filters.size()) - [panel setAllowedFileTypes: allowed]; - - // multiple - [panel setAllowsMultipleSelection: mult]; // default path if (options.defaultPath) { @@ -102,8 +91,36 @@ void utils::web::openLinkInBrowser(std::string const& url) { } // other - [panel setCanChooseDirectories: NO]; - [panel setCanChooseFiles: YES]; + if (mode != file::PickMode::SaveFile) { + auto openPanel = (NSOpenPanel*)panel; + + if (mode == file::PickMode::OpenFile){ + [openPanel setCanChooseDirectories: NO]; + [openPanel setCanChooseFiles: YES]; + } + else { + [openPanel setCanChooseDirectories: YES]; + [openPanel setCanChooseFiles: NO]; + } + + [openPanel setAllowsMultipleSelection: mult]; + + // allowed files + // TODO: allowed files using the NSOpenSavePanelDelegate xd + // NSMutableArray* allowed = [NSMutableArray array]; + + // for (auto& f : options.filters) { + // for (auto& i : f.files) { + // auto nsstr = [NSString stringWithUTF8String: i.c_str()]; + + // if (![allowed containsObject: nsstr]) + // [allowed addObject: nsstr]; + // } + // } + + // if (options.filters.size()) + // [panel setAllowedFileTypes: allowed]; + } // run thing @@ -111,11 +128,16 @@ void utils::web::openLinkInBrowser(std::string const& url) { if (result == NSModalResponseOK) { std::vector fileURLs; - - for (NSURL* i in panel.URLs) { - fileURLs.push_back(std::string(i.path.UTF8String)); + if (mode == file::PickMode::SaveFile) { + fileURLs.push_back(std::string([[[panel URL] path] UTF8String])); } + else { + auto openPanel = (NSOpenPanel*)panel; + for (NSURL* i in openPanel.URLs) { + fileURLs.push_back(std::string(i.path.UTF8String)); + } + } return Ok(fileURLs); } else { return Err("File picker cancelled"); @@ -143,10 +165,11 @@ Result> utils::file::pickFiles( } CCPoint cocos::getMousePos() { - auto frame = NSApp.mainWindow.frame; - auto scaleFactor = CCPoint(CCDirector::get()->getWinSize()) / ccp(frame.size.width, frame.size.height); + auto windowFrame = NSApp.mainWindow.frame; + auto viewFrame = NSApp.mainWindow.contentView.frame; + auto scaleFactor = CCPoint(CCDirector::get()->getWinSize()) / ccp(viewFrame.size.width, viewFrame.size.height); auto mouse = [NSEvent mouseLocation]; - return ccp(mouse.x - frame.origin.x, mouse.y - frame.origin.y) * scaleFactor; + return ccp(mouse.x - windowFrame.origin.x, mouse.y - windowFrame.origin.y) * scaleFactor; } ghc::filesystem::path dirs::getGameDir() { diff --git a/loader/test/members/MacOS.cpp b/loader/test/members/MacOS.cpp index aa30d238..42eb843b 100644 --- a/loader/test/members/MacOS.cpp +++ b/loader/test/members/MacOS.cpp @@ -64,4 +64,15 @@ GEODE_MEMBER_CHECK(SetupPulsePopup, m_pulseMode, 0x38c); // ColorSelectPopup GEODE_MEMBER_CHECK(ColorSelectPopup, m_copyColor, 0x372); +// LevelInfoLayer +GEODE_MEMBER_CHECK(LevelInfoLayer, m_level, 0x1c0); + +// LevelBrowserLayer +GEODE_MEMBER_CHECK(LevelBrowserLayer, m_leftArrow, 0x1a8); +GEODE_MEMBER_CHECK(LevelBrowserLayer, m_searchObject, 0x1d8); +GEODE_MEMBER_CHECK(LevelBrowserLayer, m_itemCount, 0x208); + +// LocalLevelManager +GEODE_MEMBER_CHECK(LocalLevelManager, m_localLevels, 0x140); + #endif \ No newline at end of file