Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/geode-sdk/geode
Browse files Browse the repository at this point in the history
  • Loading branch information
cgytrus committed Jun 26, 2023
2 parents 4668fd5 + 0cb4300 commit 887f448
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,18 @@ 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
)

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"
Expand Down
22 changes: 11 additions & 11 deletions bindings/GeometryDash.bro
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions flash.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
2 changes: 1 addition & 1 deletion loader/include/Geode/ui/EnterLayerEvent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace geode {
template<class T, class N>
concept InheritsEnterLayer = std::is_base_of_v<EnterLayerEvent<N>, T>;

template<class N, InheritsEnterLayer<N> T>
template<class N, InheritsEnterLayer<N> T = EnterLayerEvent<N>>
class EnterLayerFilter : public EventFilter<EnterLayerEvent<N>> {
public:
using Callback = void(T*);
Expand Down
73 changes: 48 additions & 25 deletions loader/src/platform/mac/util.mm
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,14 @@ @interface FileDialog : NSObject

@implementation FileDialog
+(Result<std::vector<ghc::filesystem::path>>) 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) {
Expand All @@ -102,20 +91,53 @@ @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

int result = [panel runModal];

if (result == NSModalResponseOK) {
std::vector<ghc::filesystem::path> 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");
Expand Down Expand Up @@ -143,10 +165,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() {
Expand Down
11 changes: 11 additions & 0 deletions loader/test/members/MacOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 887f448

Please sign in to comment.