From d770e9b92ace99daa3bfd769c4d6fc35b3f93c45 Mon Sep 17 00:00:00 2001 From: alk <45172705+altalk23@users.noreply.github.com> Date: Thu, 15 Jun 2023 10:20:04 +0300 Subject: [PATCH 1/9] Update flash.toml version --- flash.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flash.toml b/flash.toml index 8ecd8e625..380b671d0 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" From 9cd0327766386a6c2b347d483bb6556cae6f7f48 Mon Sep 17 00:00:00 2001 From: alk <45172705+altalk23@users.noreply.github.com> Date: Thu, 15 Jun 2023 10:35:37 +0300 Subject: [PATCH 2/9] Update flash.toml infer-args-from --- flash.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flash.toml b/flash.toml index 380b671d0..dc749c850 100644 --- a/flash.toml +++ b/flash.toml @@ -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" From 17eb0e5aa01384998ac4b1469687839a5888fe27 Mon Sep 17 00:00:00 2001 From: alk <45172705+altalk23@users.noreply.github.com> Date: Fri, 23 Jun 2023 23:48:41 +0300 Subject: [PATCH 3/9] Add EnterLayerEvent as default template param to the filter --- loader/include/Geode/ui/EnterLayerEvent.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loader/include/Geode/ui/EnterLayerEvent.hpp b/loader/include/Geode/ui/EnterLayerEvent.hpp index 91c22835a..acab49809 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*); From 7e70daf5a0f95cd03c5344caa7f3164e48990564 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Sat, 24 Jun 2023 00:45:13 +0300 Subject: [PATCH 4/9] fix getMousePos for macchew --- loader/src/platform/mac/util.mm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/loader/src/platform/mac/util.mm b/loader/src/platform/mac/util.mm index 5e21154cb..b5bf11c19 100644 --- a/loader/src/platform/mac/util.mm +++ b/loader/src/platform/mac/util.mm @@ -143,10 +143,11 @@ @implementation FileDialog } 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() { From 5b9e8a74674b5cb8404286933e3acaf04c02def3 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Sun, 25 Jun 2023 18:47:16 +0300 Subject: [PATCH 5/9] fix infolayer and browserlayer structs --- CMakeLists.txt | 6 +++++- bindings/GeometryDash.bro | 16 ++++++++-------- loader/test/members/MacOS.cpp | 8 ++++++++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ebc5b741..fed7a5275 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 27545eb4f..664b784e1 100644 --- a/bindings/GeometryDash.bro +++ b/bindings/GeometryDash.bro @@ -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; @@ -3666,13 +3666,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; @@ -3919,14 +3919,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; @@ -3935,7 +3935,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 { diff --git a/loader/test/members/MacOS.cpp b/loader/test/members/MacOS.cpp index aa30d2385..fbb3f0724 100644 --- a/loader/test/members/MacOS.cpp +++ b/loader/test/members/MacOS.cpp @@ -64,4 +64,12 @@ 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); + #endif \ No newline at end of file From de672b0133b423a14a435a884f8db5f1ebf360eb Mon Sep 17 00:00:00 2001 From: mat <26722564+matcool@users.noreply.github.com> Date: Sun, 25 Jun 2023 13:20:15 -0300 Subject: [PATCH 6/9] Update build.yml update "update-existing-release", maybe this will fix it --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 44102bffd..e0e4ae1b7 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 From 4ad8b486ff9f6ab315276fa8736f6f6c92f4a543 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Sun, 25 Jun 2023 19:52:01 +0300 Subject: [PATCH 7/9] implement save and open panel --- bindings/GeometryDash.bro | 2 +- loader/src/platform/mac/util.mm | 66 ++++++++++++++++++++++----------- loader/test/members/MacOS.cpp | 3 ++ 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/bindings/GeometryDash.bro b/bindings/GeometryDash.bro index 664b784e1..561bfa309 100644 --- a/bindings/GeometryDash.bro +++ b/bindings/GeometryDash.bro @@ -4144,7 +4144,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/loader/src/platform/mac/util.mm b/loader/src/platform/mac/util.mm index b5bf11c19..192494f9f 100644 --- a/loader/src/platform/mac/util.mm +++ b/loader/src/platform/mac/util.mm @@ -75,25 +75,14 @@ @interface FileDialog : NSObject @implementation FileDialog +(Result>) filePickerWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options multiple:(bool)mult { - NSOpenPanel* panel = [NSOpenPanel openPanel]; - - // allowed files - NSMutableArray* allowed = [NSMutableArray array]; - - for (auto& f : options.filters) { - for (auto& i : f.files) { - auto nsstr = [NSString stringWithUTF8String: i.c_str()]; + NSSavePanel* panel; + if (mode == file::PickMode::SaveFile) + panel = [NSSavePanel savePanel]; + else + panel = [NSOpenPanel openPanel]; - if (![allowed containsObject: nsstr]) - [allowed addObject: nsstr]; - } - } + [panel setCanCreateDirectories: TRUE]; - if (options.filters.size()) - [panel setAllowedFileTypes: allowed]; - - // multiple - [panel setAllowsMultipleSelection: mult]; // default path if (options.defaultPath) { @@ -102,8 +91,36 @@ @implementation FileDialog } // 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 @@ @implementation FileDialog 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"); diff --git a/loader/test/members/MacOS.cpp b/loader/test/members/MacOS.cpp index fbb3f0724..42eb843b7 100644 --- a/loader/test/members/MacOS.cpp +++ b/loader/test/members/MacOS.cpp @@ -72,4 +72,7 @@ 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 From 3c3f7aacf33f7d706bc46ca77d34858ad4048823 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Sun, 25 Jun 2023 20:17:34 +0300 Subject: [PATCH 8/9] fix gjgamelevel dataloaded macchew --- bindings/GeometryDash.bro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/GeometryDash.bro b/bindings/GeometryDash.bro index 561bfa309..d905ff04b 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; From 0cb4300a4a77a39685a1ecde8e10f085dcb04068 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Sun, 25 Jun 2023 21:04:59 +0300 Subject: [PATCH 9/9] the most important gjgamelevel fix --- bindings/GeometryDash.bro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/GeometryDash.bro b/bindings/GeometryDash.bro index d905ff04b..5f86b0f8d 100644 --- a/bindings/GeometryDash.bro +++ b/bindings/GeometryDash.bro @@ -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;