Merge branch 'main' into tulip-hook

This commit is contained in:
altalk23 2023-01-06 22:09:53 +03:00
commit b97bb0cc98
49 changed files with 1273 additions and 868 deletions

3
.gitattributes vendored Normal file
View file

@ -0,0 +1,3 @@
loader/include/Geode/cocos/** linguist-vendored
loader/include/Geode/external/** linguist-vendored
loader/include/Geode/fmod/** linguist-vendored

View file

@ -71,7 +71,6 @@ jobs:
${{ matrix.config.prefixes }} cmake -B
${{ github.workspace }}/build
${{ matrix.config.extra_flags }}
-DGEODE_DISABLE_CLI_CALLS=ON
-DCLI_PATH="${{ github.workspace }}/cli"
-D CMAKE_C_COMPILER_LAUNCHER=ccache
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache

58
.github/workflows/test-offsets.yml vendored Normal file
View file

@ -0,0 +1,58 @@
name: Test Offsets
on:
workflow_dispatch:
push:
branches:
- '**' # every branch
- '!no-build-**' # unless marked as no-build
jobs:
build:
strategy:
fail-fast: false
matrix:
config:
- name: Windows
os_identifier: win
os: windows-2019
prefixes: ''
extra_flags: -A win32 -DGEODE_DEBUG=On
- name: macOS
os_identifier: mac
os: macos-latest
prefixes: PATH="/usr/local/opt/ccache/libexec:$PATH"
extra_flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DGEODE_DEBUG=On
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: x86
if: matrix.config.os_identifier == 'win'
- name: Configure ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ matrix.config.os }}
- name: Configure CMake
run: >
${{ matrix.config.prefixes }} cmake -B
${{ github.workspace }}/build
${{ matrix.config.extra_flags }}
-D GEODE_DISABLE_CLI_CALLS=ON
-D CMAKE_C_COMPILER_LAUNCHER=ccache
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Build member test
run: |
cd build
cmake --build . --config RelWithDebInfo --parallel --target TestMembers

1
.gitignore vendored
View file

@ -40,6 +40,7 @@
# Ignore build folders
**/build
build
build-docs/
bin
loader/src/internal/about.hpp

View file

@ -49,20 +49,24 @@ include(cmake/CPM.cmake)
target_sources(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/entry.cpp)
include(ExternalProject)
set(GEODE_CODEGEN_BINARY_OUT ${CMAKE_CURRENT_BINARY_DIR}/codegen)
ExternalProject_Add(CodegenProject
BUILD_ALWAYS ON
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/codegen
CMAKE_CACHE_ARGS "-DCMAKE_INSTALL_PREFIX:STRING=${GEODE_CODEGEN_BINARY_OUT}"
BUILD_ALWAYS ${GEODE_ALWAYS_BUILD_CODEGEN}
CMAKE_ARGS ${GEODE_CODEGEN_CMAKE_ARGS}
)
file(GLOB CODEGEN_DEPENDS CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/bindings/*.bro
${CMAKE_CURRENT_SOURCE_DIR}/codegen/src/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/codegen/src/*.hpp
)
add_custom_command(
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bindings/GeometryDash.bro
${CMAKE_CURRENT_SOURCE_DIR}/bindings/Cocos2d.bro
${CMAKE_CURRENT_SOURCE_DIR}/bindings/Entry.bro
DEPENDS ${CODEGEN_DEPENDS}
DEPENDS CodegenProject
COMMAND ${GEODE_CODEGEN_BINARY_OUT}/Codegen ${GEODE_TARGET_PLATFORM} bindings ${GEODE_CODEGEN_PATH}
COMMAND echo codegen > ${GEODE_CODEGEN_PATH}/.stamp
@ -95,7 +99,6 @@ target_include_directories(${PROJECT_NAME} INTERFACE
)
target_link_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/loader/include/link)
add_definitions(-DFMT_CONSTEVAL=)
CPMAddPackage("gh:fmtlib/fmt#9.1.0")
CPMAddPackage("gh:gulrak/filesystem#3e5b930")

View file

@ -74,9 +74,11 @@ class AnimatedShopKeeper : CCAnimatedSprite {
bool m_unknown;
}
class AnimatedSpriteDelegate {}
class AnimatedSpriteDelegate {
virtual void animationFinished(const char*) {}
}
class AppDelegate : cocos2d::CCApplication {
class AppDelegate : cocos2d::CCApplication, cocos2d::CCSceneDelegate {
void bgScale() = mac 0x3aaab0;
virtual bool applicationDidFinishLaunching() = mac 0x3aa900, win 0x3cbb0;
virtual void applicationDidEnterBackground() = mac 0x3aabe0, win 0x3cf40;
@ -324,18 +326,18 @@ class CCLightFlash {
class CCMenuItemSpriteExtra : cocos2d::CCMenuItemSprite {
void useAnimationType(MenuAnimationType type) {
this->m_startPosition = this->getNormalImage()->getPosition();
this->m_animationType = type;
m_startPosition = this->getNormalImage()->getPosition();
m_animationType = type;
}
void setDestination(cocos2d::CCPoint const& pos) {
this->m_destPosition = pos;
m_destPosition = pos;
}
void setOffset(cocos2d::CCPoint const& pos) {
this->m_offset = pos;
m_offset = pos;
}
void setScale(float scale) {
this->CCMenuItemSprite::setScale(scale);
this->m_baseScale = scale;
m_baseScale = scale;
}
static CCMenuItemSpriteExtra* create(cocos2d::CCNode*, cocos2d::CCNode*, cocos2d::CCObject*, cocos2d::SEL_MenuHandler) = mac 0x1253c0, win 0x18ee0, ios 0xe0740;
@ -461,11 +463,11 @@ class CCScrollLayerExt : cocos2d::CCLayer {
}
float getMinY() {
return this->getContentSize().height -
this->m_contentLayer->getContentSize().height -
this->m_scrollLimitTop;
m_contentLayer->getContentSize().height -
m_scrollLimitTop;
}
float getMaxY() {
return this->m_scrollLimitBottom;
return m_scrollLimitBottom;
}
// todo: add this back when CCDestructor works and
@ -1046,12 +1048,12 @@ class DrawGridLayer : cocos2d::CCLayer {
class EditButtonBar : cocos2d::CCNode {
void removeAllItems() {
this->m_buttonArray->removeAllObjects();
m_buttonArray->removeAllObjects();
this->reloadItemsInNormalSize();
}
void reloadItems(int rowCount, int columnCount) {
if (this->m_buttonArray)
this->loadFromItems(this->m_buttonArray, rowCount, columnCount, this->m_unknown);
if (m_buttonArray)
this->loadFromItems(m_buttonArray, rowCount, columnCount, m_unknown);
}
void reloadItemsInNormalSize() {
// TODO: fix this
@ -1061,8 +1063,8 @@ class EditButtonBar : cocos2d::CCNode {
// );
}
void addButton(CCMenuItemSpriteExtra* btn, bool reload) {
if (this->m_buttonArray)
this->m_buttonArray->addObject(btn);
if (m_buttonArray)
m_buttonArray->addObject(btn);
if (reload)
this->reloadItemsInNormalSize();
}
@ -1258,10 +1260,10 @@ class EditorUI : cocos2d::CCLayer, FLAlertLayerProtocol, ColorSelectDelegate, GJ
virtual void scrollWheel(float vertical, float horizontal) = win 0x921d0, mac 0x31370, ios 0x2c4884;
void createMoveMenu() = mac 0x275e0, win 0x8c0d0;
bool m_isPlayingMusic;
EditButtonBar* m_buttonBar;
PAD = mac 0x8, win 0x4;
cocos2d::CCArray* m_hideableUIElementArray;
PAD = mac 0x8, win 0x4;
float m_gridSize;
PAD = mac 0x18, win 0x14;
bool m_moveModifier;
@ -1359,19 +1361,19 @@ class EffectGameObject : GameObject {
void updateLabel() {
auto label = static_cast<cocos2d::CCLabelBMFont*>(this->getChildByTag(999));
if (label) {
switch (this->m_objectID) {
switch (m_objectID) {
// instant count, collision block, pickup
case 0x713: [[fallthrough]];
case 0x718: [[fallthrough]];
case 0x716:
label->setString(
cocos2d::CCString::createWithFormat("%i", this->m_itemBlockAID)->getCString()
cocos2d::CCString::createWithFormat("%i", m_itemBlockAID)->getCString()
);
break;
// color, pulse
case 899: [[fallthrough]];
case 1006: {
int target = this->m_objectID == 1006 ? m_targetGroupID : m_targetColorID;
int target = m_objectID == 1006 ? m_targetGroupID : m_targetColorID;
if (target > 999) {
label->setString(GJSpecialColorSelect::textForColorIdx(target));
} else {
@ -1383,7 +1385,7 @@ class EffectGameObject : GameObject {
} break;
default:
label->setString(
cocos2d::CCString::createWithFormat("%i", this->m_targetGroupID)->getCString()
cocos2d::CCString::createWithFormat("%i", m_targetGroupID)->getCString()
);
}
}
@ -1630,7 +1632,7 @@ class GJBaseGameLayer : cocos2d::CCLayer, TriggerEffectDelegate {
return m_objectLayer;
}
cocos2d::CCArray* getAllObjects() {
return this->m_objects;
return m_objects;
}
static GJBaseGameLayer* get() {
@ -1714,14 +1716,6 @@ class GJBaseGameLayer : cocos2d::CCLayer, TriggerEffectDelegate {
void updateQueuedLabels() = mac 0xb9f30, win 0x111b00;
virtual ~GJBaseGameLayer() = mac 0xaf990, win 0x10add0;
// GJEffectManager* effectManager = mac 0x180;
// cocos2d::CCLayer* objectLayer = mac 0x188;
// cocos2d::CCArray* objects = mac 0x3a0;
// cocos2d::CCArray* sections = mac 0x3a8;
// PlayerObject* player1 = mac 0x380;
// PlayerObject* player2 = mac 0x388;
// LevelSettingsObject* levelSettings = mac 0x390;
// cocos2d::CCDictionary* unknownDict = mac 0x398;
OBB2D* m_boundingBox;
GJEffectManager* m_effectManager;
cocos2d::CCLayer* m_objectLayer;
@ -1827,15 +1821,9 @@ class GJChallengeDelegate {}
class GJChallengeItem : cocos2d::CCObject {
GJChallengeType m_challengeType;
int m_countSeed;
int m_countRand;
int m_count;
int m_rewardSeed;
int m_rewardRand;
int m_reward;
int m_goalSeed;
int m_goalRand;
int m_goal;
geode::SeedValueSRV m_count;
geode::SeedValueSRV m_reward;
geode::SeedValueSRV m_goal;
int m_timeLeft;
bool m_canClaim;
int m_position;
@ -2126,9 +2114,7 @@ class GJGameLevel : cocos2d::CCNode {
}
cocos2d::CCDictionary* m_lastBuildSave;
int m_levelIDRand;
int m_levelIDSeed;
int m_levelID;
geode::SeedValueRSV m_levelID;
gd::string m_levelName;
gd::string m_levelDesc;
gd::string m_levelString;
@ -2136,20 +2122,14 @@ class GJGameLevel : cocos2d::CCNode {
gd::string m_recordString;
gd::string m_uploadDate;
gd::string m_updateDate;
int m_userIDRand;
int m_userIDSeed;
int m_userID;
int m_accountIDRand;
int m_accountIDSeed;
int m_accountID;
geode::SeedValueRSV m_userID;
geode::SeedValueRSV m_accountID;
GJDifficulty m_difficulty;
int m_audioTrack;
int m_songID;
int m_levelRev;
bool m_unlisted;
int m_objectCountRand;
int m_objectCountSeed;
int m_objectCount;
geode::SeedValueRSV m_objectCount;
int m_levelIndex;
int m_ratings;
int m_ratingsSum;
@ -2161,37 +2141,22 @@ class GJGameLevel : cocos2d::CCNode {
int m_workingTime2;
bool m_lowDetailMode;
bool m_lowDetailModeToggled;
int m_isVerifiedRand;
int m_isVerifiedSeed;
bool m_isVerified;
geode::SeedValueRS m_isVerified;
bool m_isVerifiedRaw; // honestly i dont think this is need to be used
bool m_isUploaded;
bool m_hasBeenModified;
int m_levelVersion;
int m_gameVersion;
int m_attemptsRand;
int m_attemptsSeed;
int m_attempts;
int m_jumpsRand;
int m_jumpsSeed;
int m_jumps;
int m_clicksRand;
int m_clicksSeed;
int m_clicks;
int m_attemptTimeRand;
int m_attemptTimeSeed;
int m_attemptTime;
geode::SeedValueRSV m_attempts;
geode::SeedValueRSV m_jumps;
geode::SeedValueRSV m_clicks;
geode::SeedValueRSV m_attemptTime;
int m_chk;
bool m_isChkValid;
bool m_isCompletionLegitimate;
int m_normalPercent;
int m_normalPercentSeed;
int m_normalPercentRand;
int m_orbCompletionRand;
int m_orbCompletionSeed;
int m_orbCompletion;
int m_newNormalPercent2Rand;
int m_newNormalPercent2Seed;
int m_newNormalPercent2;
geode::SeedValueVSR m_normalPercent;
geode::SeedValueRSV m_orbCompletion;
geode::SeedValueRSV m_newNormalPercent2;
int m_practicePercent;
int m_likes;
int m_dislikes;
@ -2200,37 +2165,20 @@ class GJGameLevel : cocos2d::CCNode {
bool m_isEpic;
bool m_levelFavorited;
int m_levelFolder;
int m_dailyIDRand;
int m_dailyIDSeed;
int m_dailyID;
int m_demonRand;
int m_demonSeed;
int m_demon;
geode::SeedValueRSV m_dailyID;
geode::SeedValueRSV m_demon;
int m_demonDifficulty;
int m_starsRand;
int m_starsSeed;
int m_stars;
geode::SeedValueRSV m_stars;
bool m_autoLevel;
int m_coins;
int m_coinsVerifiedRand;
int m_coinsVerifiedSeed;
int m_coinsVerified;
int m_passwordRand;
int m_passwordSeed;
int m_originalLevelRand;
int m_originalLevelSeed;
int m_originalLevel;
geode::SeedValueRSV m_coinsVerified;
geode::SeedValueRS m_password;
geode::SeedValueRSV m_originalLevel;
bool m_twoPlayerMode;
int m_failedPasswordAttempts;
int m_firstCoinVerifiedRand;
int m_firstCoinVerifiedSeed;
int m_firstCoinVerified;
int m_secondCoinVerifiedRand;
int m_secondCoinVerifiedSeed;
int m_secondCoinVerified;
int m_thirdCoinVerifiedRand;
int m_thirdCoinVerifiedSeed;
int m_thirdCoinVerified;
geode::SeedValueRSV m_firstCoinVerified;
geode::SeedValueRSV m_secondCoinVerified;
geode::SeedValueRSV m_thirdCoinVerified;
int m_starsRequested;
bool m_showedSongWarning;
int m_starRatings;
@ -2397,10 +2345,10 @@ class GJRobotSprite : CCAnimatedSprite {
class GJRotationControl : cocos2d::CCLayer {
void setAngle(float angle) {
this->m_sliderPosition = cocos2d::CCPointMake(sinf(angle) * 60.0f, cosf(angle) * 60.0f);
this->m_angle = angle;
m_sliderPosition = cocos2d::CCPointMake(sinf(angle) * 60.0f, cosf(angle) * 60.0f);
m_angle = angle;
this->m_sliderThumb->setPosition(this->m_sliderPosition);
m_sliderThumb->setPosition(m_sliderPosition);
}
void updateSliderPosition(cocos2d::CCPoint const& pos) = win 0x94020;
@ -2452,7 +2400,7 @@ class GJScoreCell : TableViewCell {
class GJSearchObject : cocos2d::CCNode {
SearchType getType() {
return this->m_searchType;
return m_searchType;
}
static GJSearchObject* create(SearchType nID) = win 0xc2b90;
@ -2512,46 +2460,46 @@ class GJUserCell : TableViewCell {
class GJUserScore : cocos2d::CCNode {
IconType getIconType() const {
return this->m_iconType;
return m_iconType;
}
int getPlayerCube() const {
return this->m_playerCube;
return m_playerCube;
}
int getPlayerShip() const {
return this->m_playerShip;
return m_playerShip;
}
int getPlayerBall() const {
return this->m_playerBall;
return m_playerBall;
}
int getPlayerUfo() const {
return this->m_playerUfo;
return m_playerUfo;
}
int getPlayerWave() const {
return this->m_playerWave;
return m_playerWave;
}
int getPlayerRobot() const {
return this->m_playerRobot;
return m_playerRobot;
}
int getPlayerSpider() const {
return this->m_playerSpider;
return m_playerSpider;
}
int getPlayerStreak() const {
return this->m_playerStreak;
return m_playerStreak;
}
bool getGlowEnabled() const {
return this->m_glowEnabled;
return m_glowEnabled;
}
int getPlayerExplosion() const {
return this->m_playerExplosion;
return m_playerExplosion;
}
int getPlayerColor1() const {
return this->m_color1;
return m_color1;
}
int getPlayerColor2() const {
return this->m_color2;
return m_color2;
}
gd::string getPlayerName() const {
return this->m_userName;
return m_userName;
}
static GJUserScore* create() = win 0xc1660;
static GJUserScore* create(cocos2d::CCDictionary*) = win 0xc0750;
@ -2753,47 +2701,36 @@ class GameManager : GManager {
}
void setPlayerFrame(int id) {
m_playerFrame = id;
m_playerFrameRand1 = id + m_playerFrameRand2;
}
void setPlayerShip(int id) {
m_playerShip = id;
m_playerShipRand1 = id + m_playerShipRand2;
}
void setPlayerBall(int id) {
m_playerBall = id;
m_playerBallRand1 = id + m_playerBallRand2;
}
void setPlayerBird(int id) {
m_playerBird = id;
m_playerBirdRand1 = id + m_playerBirdRand2;
}
void setPlayerDart(int id) {
m_playerDart = id;
m_playerDartRand1 = id + m_playerDartRand2;
}
void setPlayerRobot(int id) {
m_playerRobot = id;
m_playerRobotRand1 = id + m_playerRobotRand2;
}
void setPlayerSpider(int id) {
m_playerSpider = id;
m_playerSpiderRand1 = id + m_playerSpiderRand2;
}
void setPlayerStreak(int id) {
m_playerStreak = id;
m_playerStreakRand1 = id + m_playerStreakRand2;
}
void setPlayerDeathEffect(int id) {
m_playerDeathEffect = id;
m_playerDeathEffectRand1 = id + m_playerDeathEffectRand2;
}
void setPlayerColor(int id) {
m_playerColor = id;
m_playerColorRand1 = id + m_playerColorRand2;
}
void setPlayerColor2(int id) {
m_playerColor2 = id;
m_playerColor2Rand1 = id + m_playerColor2Rand2;
}
void setPlayerGlow(bool v) {
m_playerGlow = v;
@ -2890,9 +2827,7 @@ class GameManager : GManager {
gd::string m_playerUDID;
gd::string m_playerName;
bool m_commentsEnabled;
int m_playerUserIDRand1;
int m_playerUserIDRand2;
int m_playerUserID;
geode::SeedValueRSV m_playerUserID;
float m_backgroundMusicVolume;
float m_effectsVolume;
float m_timeOffset;
@ -2910,43 +2845,19 @@ class GameManager : GManager {
int m_sceneEnum;
int m_searchObjectType;
bool m_unknownBool6;
int m_playerFrameRand1;
int m_playerFrameRand2;
int m_playerFrame;
int m_playerShipRand1;
int m_playerShipRand2;
int m_playerShip;
int m_playerBallRand1;
int m_playerBallRand2;
int m_playerBall;
int m_playerBirdRand1;
int m_playerBirdRand2;
int m_playerBird;
int m_playerDartRand1;
int m_playerDartRand2;
int m_playerDart;
int m_playerRobotRand1;
int m_playerRobotRand2;
int m_playerRobot;
int m_playerSpiderRand1;
int m_playerSpiderRand2;
int m_playerSpider;
int m_playerColorRand1;
int m_playerColorRand2;
int m_playerColor;
int m_playerColor2Rand1;
int m_playerColor2Rand2;
int m_playerColor2;
int m_playerStreakRand1;
int m_playerStreakRand2;
int m_playerStreak;
int m_playerDeathEffectRand1;
int m_playerDeathEffectRand2;
int m_playerDeathEffect;
int m_chkSeed;
int m_chkRand;
int m_secretNumberSeed;
int m_secretNumberRand;
geode::SeedValueRSV m_playerFrame;
geode::SeedValueRSV m_playerShip;
geode::SeedValueRSV m_playerBall;
geode::SeedValueRSV m_playerBird;
geode::SeedValueRSV m_playerDart;
geode::SeedValueRSV m_playerRobot;
geode::SeedValueRSV m_playerSpider;
geode::SeedValueRSV m_playerColor;
geode::SeedValueRSV m_playerColor2;
geode::SeedValueRSV m_playerStreak;
geode::SeedValueRSV m_playerDeathEffect;
geode::SeedValueSR m_chk;
geode::SeedValueSR m_secretNumber;
bool m_playerGlow;
IconType m_playerIconType;
bool m_everyPlaySetup;
@ -2971,9 +2882,7 @@ class GameManager : GManager {
bool m_unk2;
bool m_gameCenterEnabled;
bool m_smoothFix;
int m_ratePowerSeed;
int m_ratePowerRand;
int m_ratePower;
geode::SeedValueSRV m_ratePower;
bool m_canGetLevelSaveData;
int m_resolution;
cocos2d::TextureQuality m_quality;
@ -3386,9 +3295,7 @@ class GameStatsManager : cocos2d::CCNode {
cocos2d::CCDictionary* m_completedMappacks;
cocos2d::CCDictionary* m_weeklyChest;
cocos2d::CCDictionary* m_treasureRoomChests;
int m_bonusKeySeed;
int m_bonusKeyRand;
int m_bonusKey;
geode::SeedValueSRV m_bonusKey;
cocos2d::CCDictionary* m_miscChests;
}
@ -3723,9 +3630,7 @@ class LevelEditorLayer : GJBaseGameLayer, LevelSettingsDelegate {
cocos2d::CCArray* m_unkArray12;
bool field_14;
bool field_31D;
int m_coinCountRand1;
int m_coinCountRand2;
int m_coinCount;
geode::SeedValueRSV m_coinCount;
bool m_moveTrigger;
bool m_colorTrigger;
bool m_pulseTrigger;
@ -3756,9 +3661,7 @@ class LevelEditorLayer : GJBaseGameLayer, LevelSettingsDelegate {
cocos2d::CCArray* m_undoObjects;
cocos2d::CCArray* m_redoObjects;
cocos2d::CCPoint m_unkPoint1;
int m_objectCountRand1;
int m_objectCountRand2;
int m_objectCount;
geode::SeedValueRSV m_objectCount;
DrawGridLayer* m_drawGridLayer;
GJGameLevel* m_level;
PlaybackMode m_playbackMode;
@ -4373,8 +4276,7 @@ class PlayLayer : GJBaseGameLayer, CCCircleWaveDelegate, CurrencyRewardDelegate,
float unused4c8;
bool unused4cc;
bool m_hasCheated;
int m_dontSaveRand;
int m_dontSaveSeed;
geode::SeedValueRS m_dontSave;
int unknown4d8;
bool m_debugPauseOff;
bool m_shouldSmoothCamera;
@ -4426,7 +4328,7 @@ class PlayLayer : GJBaseGameLayer, CCCircleWaveDelegate, CurrencyRewardDelegate,
float unknown5c4;
GJGroundLayer* m_bottomGround;
GJGroundLayer* m_topGround;
double m_completelyUninitializedData;
PAD = mac 0x8, win 0x8;
bool m_isDead;
bool m_startCameraAtCorner;
bool m_cameraYLocked;
@ -4457,9 +4359,10 @@ class PlayLayer : GJBaseGameLayer, CCCircleWaveDelegate, CurrencyRewardDelegate,
cocos2d::CCSprite* m_sliderGrooveSprite;
cocos2d::CCSprite* m_sliderBarSprite;
cocos2d::CCSize m_sliderSize;
void* unknown680;
int unknown680;
int m_activeGravityEffects;
int m_gravityEffectStatus; // ??
PAD = mac 0x4, win 0x4;
cocos2d::CCArray* m_gravitySprites;
bool unk428;
bool m_shouldRecordActions;
@ -4702,35 +4605,7 @@ class PlayerObject : GameObject, AnimatedSpriteDelegate {
void runRotateAction() = win 0x1e9bf0;
void runBallRotation() = win 0x1e9d10;
// HardStreak* waveStreak = mac 0x600;
// double speed = mac 0x608;
// double gravity = mac 0x618;
// bool inPlayLayer = mac 0x62c;
// GJRobotSprite* robotSprite = mac 0x6a8;
// GJSpiderSprite* spiderSprite = mac 0x6b0;
// bool isHolding = mac 0x745;
// bool hasJustHeld = mac 0x746;
// double yAccel = mac 0x760;
// bool isShip = mac 0x770;
// bool isBird = mac 0x771;
// bool isBall = mac 0x772;
// bool isDart = mac 0x773;
// bool isRobot = mac 0x774;
// bool isSpider = mac 0x775;
// bool upsideDown = mac 0x776;
// bool dead = mac 0x777;
// bool onGround = mac 0x778;
// float vehicleSize = mac 0x77c;
// cocos2d::CCPoint lastPortalLocation = mac 0x78c;
// bool isSliding = mac 0x7a0;
// bool isRising = mac 0x7a1;
// cocos2d::CCPoint lastHitGround = mac 0x7a4;
// GameObject* lastPortal = mac 0x7b8;
// cocos2d::_ccColor3B col1 = mac 0x7c2;
// cocos2d::_ccColor3B col2 = mac 0x7c5;
// float xPos = mac 0x7c8;
// float yPos = mac 0x7cc;
PAD = mac 0x18, win 0x14;
PAD = mac 0x14, win 0x14;
bool m_unk480;
cocos2d::CCNode* m_unk484;
cocos2d::CCDictionary* m_collisionLog;
@ -4755,7 +4630,6 @@ class PlayerObject : GameObject, AnimatedSpriteDelegate {
cocos2d::CCSprite* m_unk500;
cocos2d::CCSprite* m_vehicleSpriteWhitener;
cocos2d::CCSprite* m_vehicleGlow;
PAD = mac 0x8; // idk about windows
cocos2d::CCMotionStreak* m_regularTrail;
HardStreak* m_waveTrail;
double m_xAccel;
@ -4776,7 +4650,7 @@ class PlayerObject : GameObject, AnimatedSpriteDelegate {
PAD = mac 0x24, win 0x24;
float m_decelerationRate;
PAD = mac 0x14, win 0x14;
GameObject* m_snappedObject;
GameObject* m_lastCollidedSolid;
PAD = mac 0x10, win 0x8;
GJRobotSprite* m_robotSprite;
GJSpiderSprite* m_spiderSprite;
@ -5110,10 +4984,10 @@ class SimplePlayer : cocos2d::CCSprite {
class Slider : cocos2d::CCLayer {
void setValue(float val) {
this->m_touchLogic->getThumb()->setValue(val);
m_touchLogic->getThumb()->setValue(val);
}
void setBarVisibility(bool v) {
this->m_sliderBar->setVisible(v);
m_sliderBar->setVisible(v);
}
static Slider* create(cocos2d::CCNode* target, cocos2d::SEL_MenuHandler click, float scale) {
return create(target, click, "sliderBar.png", "slidergroove.png", "sliderthumb.png", "sliderthumbsel.png", scale);
@ -5133,11 +5007,11 @@ class Slider : cocos2d::CCLayer {
class SliderThumb : cocos2d::CCMenuItemImage {
void setValue(float val) = mac 0x18ce80, win 0x2e1b0, ios 0x210db4;
float getValue() {
return (m_fScaleX * this->m_length * .5f +
return (m_fScaleX * m_length * .5f +
(m_vertical ?
this->getPositionY() :
this->getPositionX())
) / (m_fScaleX * this->m_length);
) / (m_fScaleX * m_length);
}
float m_length;

View file

@ -132,9 +132,18 @@ function(package_geode_resources_now proname src dest header_dest)
if (GEODE_DISABLE_CLI_CALLS)
message(WARNING
"package_geode_resources_now called, but GEODE_DISABLE_CLI_CALLS
is set to true - Ignoring it as this function requires CLI calls
in order to work"
is set to true - Faking output result in case you only wish to
analyze the project statically, do not expect built project to
function properly"
)
set(HEADER_FILE
"#include <unordered_map>\n\n"
"static const std::unordered_map<std::string, std::string> "
"LOADER_RESOURCE_HASHES {}\;\n"
)
file(WRITE ${header_dest} ${HEADER_FILE})
message(STATUS "Wrote fake resource hashes to ${header_dest}")
return()
endif()
if(GEODE_CLI STREQUAL "GEODE_CLI-NOTFOUND")

View file

@ -23,8 +23,6 @@ if (GEODE_TARGET_PLATFORM STREQUAL "iOS")
OSX_ARCHITECTURES arm64
)
target_compile_definitions(${PROJECT_NAME} -DCC_TARGET_OS_IPHONE)
set(GEODE_PLATFORM_BINARY "GeodeIOS.dylib")
elseif (GEODE_TARGET_PLATFORM STREQUAL "MacOS")
set_target_properties(${PROJECT_NAME} PROPERTIES
@ -33,15 +31,8 @@ elseif (GEODE_TARGET_PLATFORM STREQUAL "MacOS")
APPLE_SILICON_PROCESSOR x86_64
)
target_include_directories(${PROJECT_NAME} INTERFACE
${GEODE_LOADER_PATH}/include/Geode/cocos/cocos2dx/platform/mac
${GEODE_LOADER_PATH}/include/Geode/cocos/cocos2dx/platform/third_party/mac
${GEODE_LOADER_PATH}/include/Geode/cocos/cocos2dx/platform/third_party/mac/OGLES
)
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_definitions(${PROJECT_NAME} INTERFACE -DCC_TARGET_OS_MAC)
set(GEODE_PLATFORM_BINARY "Geode.dylib")
@ -51,14 +42,7 @@ elseif (GEODE_TARGET_PLATFORM STREQUAL "Win32")
GENERATOR_PLATFORM x86
)
target_include_directories(${PROJECT_NAME} INTERFACE
${GEODE_LOADER_PATH}/include/Geode/cocos/cocos2dx/platform/win32
${GEODE_LOADER_PATH}/include/Geode/cocos/cocos2dx/platform/third_party/win32
${GEODE_LOADER_PATH}/include/Geode/cocos/cocos2dx/platform/third_party/win32/zlib
${GEODE_LOADER_PATH}/include/Geode/cocos/cocos2dx/platform/third_party/win32/OGLES
)
target_compile_definitions(${PROJECT_NAME} INTERFACE -DCC_TARGET_OS_WIN32 NOMINMAX)
target_compile_definitions(${PROJECT_NAME} INTERFACE NOMINMAX)
target_link_libraries(${PROJECT_NAME} INTERFACE
${GEODE_LOADER_PATH}/include/link/libcocos2d.lib

View file

@ -14,6 +14,7 @@ namespace { namespace format_strings {
#include <cocos-ext.h>
#include <Geode/GeneratedPredeclare.hpp>
#include <Geode/Enums.hpp>
#include <Geode/utils/SeedValue.hpp>
)GEN";
@ -46,7 +47,10 @@ public:
}}
)GEN";
char const* error_definition_virtual = R"GEN( [[deprecated("Use of undefined virtual function - will crash at runtime!!!")]]
char const* error_definition_virtual = R"GEN(
#ifndef GEODE_DONT_WARN_INCORRECT_MEMBERS
[[deprecated("Use of undefined virtual function - will crash at runtime!!!")]]
#endif
{virtual}{return_type} {function_name}({parameters}){const}{{
#ifdef GEODE_NO_UNDEFINED_VIRTUALS
static_assert(false, "Undefined virtual function - implement in GeometryDash.bro");
@ -55,6 +59,12 @@ public:
}}
)GEN";
char const* warn_offset_member = R"GEN(
#ifndef GEODE_DONT_WARN_INCORRECT_MEMBERS
[[deprecated("Member placed incorrectly - will crash at runtime!!!")]]
#endif
)GEN";
char const* structor_definition = R"GEN(
{function_name}({parameters});)GEN";
@ -126,7 +136,7 @@ std::string generateBindingHeader(Root& root, ghc::filesystem::path const& singl
single_output += "\t" + i->inner + "\n";
continue;
} else if (auto m = field.get_as<MemberField>()) {
if (unimplementedField) single_output += "\t[[deprecated(\"Member placed incorrectly - will crash at runtime!!!\")]]\n";
if (unimplementedField) single_output += format_strings::warn_offset_member;
single_output += fmt::format(format_strings::member_definition,
fmt::arg("type", m->type.name),
fmt::arg("member_name", m->name + str_if(fmt::format("[{}]", m->count), m->count))

View file

@ -6,7 +6,8 @@ namespace { namespace format_strings {
#include <Geode/Bindings.hpp>
#include <Geode/utils/addresser.hpp>
#include <Geode/utils/casts.hpp>
#include <Geode/modify/Addresses.hpp>
#include <Geode/meta/meta.hpp>
#include <Geode/modify/Addresses.hpp>
#include <Geode/modify/Types.hpp>
using namespace geode;
using namespace geode::cast;

62
flash.toml Normal file
View file

@ -0,0 +1,62 @@
# Configuration file for the Flash C++ documentation generator.
# https://github.com/hjfod/flash
[project]
name = "Geode"
version = "v1.0.0-beta"
repository = "https://github.com/geode-sdk/geode"
tree = "https://github.com/geode-sdk/geode/tree/main"
[[sources]]
name = "Geode"
dir = "loader/include/Geode"
# todo: Make flash infer this from cmake
strip-include-prefix = "loader/include"
include = [
"**/*.hpp",
"**/*.h",
]
exclude = [
"modify/Comparer.hpp",
"platform/*.hpp",
"c++stl/*.hpp",
# All of the relevant cocos headers are included through Geode headers
"cocos/**/*.h"
]
[[sources]]
name = "Bindings"
dir = "build-docs/codegenned/Geode/binding"
strip-include-prefix = "build-docs/codegenned"
include = [
"*.hpp"
]
# Bindings are generated at compile time
exists-online = false
# CMake options
[cmake]
config-args = [
"-G", "Ninja",
"-DCMAKE_CXX_COMPILER=Clang",
"-DCMAKE_C_COMPILER=Clang",
"-DGEODE_DISABLE_CLI_CALLS=On",
"-DGEODE_PLATFORM_NAME=Win32",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=On",
"-DGEODE_DISABLE_PRECOMPILED_HEADERS=On",
"-DGEODE_CODEGEN_CMAKE_ARGS=-DCMAKE_CXX_COMPILER=Clang;-DCMAKE_C_COMPILER=Clang",
"-DCMAKE_C_FLAGS=-m32",
"-DCMAKE_CXX_FLAGS=-m32",
"-DWIN32=On"
]
# We want to build codegen in order to get the bindings
build = true
build-dir = "build-docs"
build-args = [
"--target", "CodegenRun"
]
# The file we use to get all the include paths and such
infer-args-from = "loader/src/main.cpp"

View file

@ -141,15 +141,18 @@ CPMAddPackage("gh:altalk23/TulipHook#2347311")
target_link_libraries(${PROJECT_NAME} md4c z TulipHook geode-sdk re2)
# Use precompiled headers for faster builds
target_precompile_headers(${PROJECT_NAME} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/DefaultInclude.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Utils.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Loader.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/UI.hpp"
# "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Bindings.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/cocos/include/cocos2d.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/cocos/extensions/cocos-ext.h"
)
if (NOT GEODE_DISABLE_PRECOMPILED_HEADERS)
target_precompile_headers(${PROJECT_NAME} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/DefaultInclude.hpp"
# "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Utils.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Loader.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/UI.hpp"
# "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Bindings.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Modify.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/cocos/include/cocos2d.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/cocos/extensions/cocos-ext.h"
)
endif()
# Create launcher
if (APPLE)

View file

@ -36,6 +36,15 @@ NS_CC_BEGIN
* @{
*/
// geode should use the cocos2d-x-gd imo
class CCScene;
class CC_DLL CCSceneDelegate {
public:
virtual void willSwitchToScene(CCScene* scene) {}
};
/** @brief CCScene is a subclass of CCNode that is used only as an abstract concept.
CCScene an CCNode are almost identical with the difference that CCScene has it's
@ -71,8 +80,7 @@ public:
int getHighestChildZ(void);
protected:
void* m_pIDK;
CCSceneDelegate* m_pDelegate;
)
};

View file

@ -285,7 +285,7 @@ enum {
# endif
#endif
#include <../pthread/sched.h>
#include "sched.h"
/*
* To avoid including windows.h we define only those things that we

View file

@ -9,40 +9,42 @@
namespace geode {
// Mod interoperability
template <typename... Args>
class DispatchEvent : public Event {
std::string m_selector;
std::tuple<Args...> m_args;
// todo: update to new event system
public:
DispatchEvent(std::string const& name, Args... args) :
m_selector(name), m_args(std::make_tuple(args...)) {}
// template <typename... Args>
// class DispatchEvent : public Event {
// std::string m_selector;
// std::tuple<Args...> m_args;
std::string const& selector() {
return m_selector;
}
};
// public:
// DispatchEvent(std::string const& name, Args... args) :
// m_selector(name), m_args(std::make_tuple(args...)) {}
template <typename... Args>
class DispatchHandler : public EventHandler<DispatchEvent<Args...>> {
std::string m_selector;
std::function<void(Args...)> m_callback;
// std::string const& selector() {
// return m_selector;
// }
// };
DispatchHandler(std::string const& name, std::function<void(Args...)> callback) :
m_selector(name), m_callback(callback) {}
// template <typename... Args>
// class DispatchHandler : public EventHandler<DispatchEvent<Args...>> {
// std::string m_selector;
// std::function<void(Args...)> m_callback;
public:
bool handle(DispatchEvent<Args...>* ev) {
if (ev->name() == m_selector) {
std::apply(m_callback, ev->m_args);
}
return true;
}
// DispatchHandler(std::string const& name, std::function<void(Args...)> callback) :
// m_selector(name), m_callback(callback) {}
static DispatchHandler* create(
std::string const& name, std::function<void(Args...)> callback
) {
return new DispatchHandler(name, callback);
}
};
// public:
// bool handle(DispatchEvent<Args...>* ev) {
// if (ev->name() == m_selector) {
// std::apply(m_callback, ev->m_args);
// }
// return true;
// }
// static DispatchHandler* create(
// std::string const& name, std::function<void(Args...)> callback
// ) {
// return new DispatchHandler(name, callback);
// }
// };
}

View file

@ -4,6 +4,7 @@
#include "../external/json/json.hpp"
#include "../utils/VersionInfo.hpp"
#include "../utils/Result.hpp"
#include "Setting.hpp"
namespace geode {
namespace utils::file {

View file

@ -199,10 +199,10 @@ namespace geode::core::meta::x86 {
using Sequences = typename Membercall<Ret*, Class, Ret*, Args...>::Sequences;
// Where all the logic is actually implemented.
template <class Class, class>
template <class ImplClass, class>
class Impl {
static_assert(
always_false<Class>,
always_false<ImplClass>,
"Please report a bug to the Geode developers! This should never be reached.\n"
"SFINAE didn't reach the right overload!"
);

View file

@ -17,6 +17,7 @@
#define GEODE_CALL __stdcall
#define GEODE_PLATFORM_EXTENSION ".dll"
#define GEODE_PLATFORM_SHORT_IDENTIFIER "win"
#define CC_TARGET_OS_WIN32
#else
#define GEODE_WINDOWS(...)
#endif
@ -31,6 +32,7 @@
#define GEODE_PLATFORM_NAME "iOS"
#define GEODE_PLATFORM_EXTENSION ".ios.dylib"
#define GEODE_PLATFORM_SHORT_IDENTIFIER "ios"
#define CC_TARGET_OS_IPHONE
#else
#define GEODE_IOS(...)
#define GEODE_MACOS(...) __VA_ARGS__
@ -39,6 +41,7 @@
#define GEODE_PLATFORM_NAME "MacOS"
#define GEODE_PLATFORM_EXTENSION ".dylib"
#define GEODE_PLATFORM_SHORT_IDENTIFIER "mac"
#define CC_TARGET_OS_MAC
#endif
#define GEODE_CALL
#else
@ -55,6 +58,7 @@
#define GEODE_CALL
#define GEODE_PLATFORM_EXTENSION ".so"
#define GEODE_PLATFORM_SHORT_IDENTIFIER "android"
#define CC_TARGET_OS_ANDROID
#else
#define GEODE_ANDROID(...)
#endif

View file

@ -0,0 +1,243 @@
#pragma once
#include <array>
namespace geode {
class BaseSeedValue {
public:
BaseSeedValue() = default;
BaseSeedValue(BaseSeedValue const& other) = default;
BaseSeedValue(BaseSeedValue&& other) = default;
BaseSeedValue& operator=(BaseSeedValue const& other) = default;
BaseSeedValue& operator=(BaseSeedValue&& other) = default;
};
#define GEODE_SEED_VALUE_COMMON_OPS() \
SeedValue& operator=(int value) { \
internalValue() = value; \
internalRandom() = value + internalSeed(); \
return *this; \
} \
int value() { \
internalValue() = internalRandom() - internalSeed(); \
return internalValue(); \
} \
operator int() { return this->value(); }
class SeedValueSR : public BaseSeedValue {
private:
using SeedValue = SeedValueSR;
std::array<int, 2> m_values;
int& internalSeed() {
return m_values[0];
}
int& internalRandom() {
return m_values[1];
}
public:
using BaseSeedValue::BaseSeedValue;
SeedValueSR(int value, int seed) : m_values({seed, value + seed}) {}
SeedValue& operator=(int value) {
internalRandom() = value + internalSeed();
return *this;
}
int value() {
return internalRandom() - internalSeed();
}
operator int() {
return this->value();
}
};
class SeedValueRS : public BaseSeedValue {
private:
using SeedValue = SeedValueRS;
std::array<int, 2> m_values;
int& internalRandom() {
return m_values[0];
}
int& internalSeed() {
return m_values[1];
}
public:
using BaseSeedValue::BaseSeedValue;
SeedValueRS(int value, int seed) : m_values({value + seed, seed}) {}
SeedValue& operator=(int value) {
internalRandom() = value + internalSeed();
return *this;
}
int value() {
return internalRandom() - internalSeed();
}
operator int() {
return this->value();
}
};
class SeedValueVRS : public BaseSeedValue {
private:
using SeedValue = SeedValueVRS;
std::array<int, 3> m_values;
int& internalValue() {
return m_values[0];
}
int& internalRandom() {
return m_values[1];
}
int& internalSeed() {
return m_values[2];
}
public:
using BaseSeedValue::BaseSeedValue;
SeedValueVRS(int value, int seed) : m_values({value, value + seed, seed}) {}
GEODE_SEED_VALUE_COMMON_OPS();
};
class SeedValueVSR : public BaseSeedValue {
private:
using SeedValue = SeedValueVSR;
std::array<int, 3> m_values;
int& internalValue() {
return m_values[0];
}
int& internalSeed() {
return m_values[1];
}
int& internalRandom() {
return m_values[2];
}
public:
using BaseSeedValue::BaseSeedValue;
SeedValueVSR(int value, int seed) : m_values({value, seed, value + seed}) {}
GEODE_SEED_VALUE_COMMON_OPS();
};
class SeedValueRVS : public BaseSeedValue {
private:
using SeedValue = SeedValueRVS;
std::array<int, 3> m_values;
int& internalRandom() {
return m_values[0];
}
int& internalValue() {
return m_values[1];
}
int& internalSeed() {
return m_values[2];
}
public:
using BaseSeedValue::BaseSeedValue;
SeedValueRVS(int value, int seed) : m_values({value + seed, value, seed}) {}
GEODE_SEED_VALUE_COMMON_OPS();
};
class SeedValueRSV : public BaseSeedValue {
private:
using SeedValue = SeedValueRSV;
std::array<int, 3> m_values;
int& internalRandom() {
return m_values[0];
}
int& internalSeed() {
return m_values[1];
}
int& internalValue() {
return m_values[2];
}
public:
using BaseSeedValue::BaseSeedValue;
SeedValueRSV(int value, int seed) : m_values({value + seed, seed, value}) {}
GEODE_SEED_VALUE_COMMON_OPS();
};
class SeedValueSVR : public BaseSeedValue {
private:
using SeedValue = SeedValueSVR;
std::array<int, 3> m_values;
int& internalSeed() {
return m_values[0];
}
int& internalValue() {
return m_values[1];
}
int& internalRandom() {
return m_values[2];
}
public:
using BaseSeedValue::BaseSeedValue;
SeedValueSVR(int value, int seed) : m_values({seed, value, value + seed}) {}
GEODE_SEED_VALUE_COMMON_OPS();
};
class SeedValueSRV : public BaseSeedValue {
private:
using SeedValue = SeedValueSRV;
std::array<int, 3> m_values;
int& internalSeed() {
return m_values[0];
}
int& internalRandom() {
return m_values[1];
}
int& internalValue() {
return m_values[2];
}
public:
using BaseSeedValue::BaseSeedValue;
SeedValueSRV(int value, int seed) : m_values({seed, value + seed, value}) {}
GEODE_SEED_VALUE_COMMON_OPS();
};
#undef GEODE_SEED_VALUE_COMMON_OPS
} // namespace geode

View file

@ -4,10 +4,7 @@
* Adapted from https://gist.github.com/altalk23/29b97969e9f0624f783b673f6c1cd279
*/
#include "../loader/Log.hpp"
#include "../loader/Mod.hpp"
#include "casts.hpp"
#include "general.hpp"
#include <Geode/DefaultInclude.hpp>
#include <cstdlib>
@ -89,10 +86,10 @@ namespace geode::addresser {
// log::debug("[[" + utils::intToHex((void*)ins) + " + " + utils::intToHex(thunk) + "] +
// " + utils::intToHex(index) + "]");
log::debug(
"[[{} + {}] + {}]", utils::intToHex((void*)ins), utils::intToHex(thunk),
utils::intToHex(index)
);
// log::debug(
// "[[{} + {}] + {}]", utils::intToHex((void*)ins), utils::intToHex(thunk),
// utils::intToHex(index)
// );
// [[this + thunk] + offset] is the f we want
auto address =
@ -179,23 +176,23 @@ namespace geode::addresser {
#else
template <typename T>
inline intptr_t getVirtual(T func) {
log::debug(
"Get virtual function address from {}",
utils::intToHex(geode::cast::reference_cast<intptr_t>(func))
);
// log::debug(
// "Get virtual function address from {}",
// utils::intToHex(geode::cast::reference_cast<intptr_t>(func))
// );
auto addr = Addresser::addressOfVirtual(func);
log::debug("The address is: {}", utils::intToHex(addr));
// log::debug("The address is: {}", utils::intToHex(addr));
return addr;
}
template <typename T>
inline intptr_t getNonVirtual(T func) {
log::debug(
"Get non-virtual function address from {}",
utils::intToHex(geode::cast::reference_cast<intptr_t>(func))
);
// log::debug(
// "Get non-virtual function address from {}",
// utils::intToHex(geode::cast::reference_cast<intptr_t>(func))
// );
auto addr = Addresser::addressOfNonVirtual(func);
log::debug("The address is: {}", utils::intToHex(addr));
// log::debug("The address is: {}", utils::intToHex(addr));
return addr;
}

View file

@ -1,7 +1,7 @@
#include <cocos2d.h>
#include <Geode/modify/CCFileUtils.hpp>
#include <Geode/utils/ranges.hpp>
#include <cocos2d.h>
USE_GEODE_NAMESPACE();
@ -29,7 +29,7 @@ void CCFileUtils::removeTexturePack(std::string const& id) {
this->updatePaths();
}
void CCFileUtils::addPriorityPath(const char* path) {
void CCFileUtils::addPriorityPath(char const* path) {
PATHS.insert(PATHS.begin(), path);
this->updatePaths();
}
@ -78,12 +78,11 @@ void CCFileUtils::updatePaths() {
this->addSearchPath(path.c_str());
}
DONT_ADD_PATHS = false;
}
#pragma warning(pop)
class $modify(CCFileUtils) {
struct FileUtilsUpdatePaths : Modify<FileUtilsUpdatePaths, CCFileUtils> {
static CCFileUtils* sharedFileUtils() {
static bool doAddPaths = true;
auto ret = CCFileUtils::sharedFileUtils();

View file

@ -1,8 +1,9 @@
#include <Geode/Modify.hpp>
#include <Geode/Bindings.hpp>
#include <Geode/utils/cocos.hpp>
#include "AddIDs.hpp"
#include <Geode/Bindings.hpp>
#include <Geode/Modify.hpp>
#include <Geode/utils/cocos.hpp>
USE_GEODE_NAMESPACE();
$register_ids(CreatorLayer) {
@ -21,11 +22,13 @@ $register_ids(CreatorLayer) {
setIDSafe(menu, 7, "hall-of-fame-button");
setIDSafe(menu, 8, "map-packs-button");
setIDSafe(menu, 9, "search-button");
setIDSafe(menu, 10,"gauntlets-button");
setIDSafe(menu, 10, "gauntlets-button");
// move vault button to its own menu
if (auto lockBtn = setIDSafe(menu, -2, "vault-button")) {
detachAndCreateMenu(this, "top-right-menu",
detachAndCreateMenu(
this,
"top-right-menu",
ColumnLayout::create(5.f, 0.f)->setAlignment(Alignment::Begin),
lockBtn
);
@ -33,7 +36,9 @@ $register_ids(CreatorLayer) {
// move treasure room button to its own menu
if (auto roomBtn = setIDSafe(menu, -1, "treasure-room-button")) {
detachAndCreateMenu(this, "bottom-right-menu",
detachAndCreateMenu(
this,
"bottom-right-menu",
ColumnLayout::create(5.f, 0.f)->setAlignment(Alignment::End),
roomBtn
);
@ -46,11 +51,10 @@ $register_ids(CreatorLayer) {
}
}
class $modify(CreatorLayer) {
struct CreatorLayerIDs : Modify<CreatorLayerIDs, CreatorLayer> {
bool init() {
if (!CreatorLayer::init())
return false;
if (!CreatorLayer::init()) return false;
NodeIDs::get()->provide(this);
return true;

View file

@ -1,12 +1,15 @@
#include <Geode/modify/EditLevelLayer.hpp>
#include <Geode/Bindings.hpp>
#include <Geode/utils/cocos.hpp>
#include "AddIDs.hpp"
#include <Geode/Bindings.hpp>
#include <Geode/modify/EditLevelLayer.hpp>
#include <Geode/utils/cocos.hpp>
USE_GEODE_NAMESPACE();
$register_ids(EditLevelLayer) {
setIDs(this, 0,
setIDs(
this,
0,
"background",
"bottom-left-art",
"bottom-right-art",
@ -27,15 +30,13 @@ $register_ids(EditLevelLayer) {
);
if (auto menu = this->getChildByID("level-action-menu")) {
setIDs(menu, 0,
"edit-button",
"play-button",
"share-button"
);
setIDs(menu, 0, "edit-button", "play-button", "share-button");
}
if (auto menu = this->getChildByID("right-side-menu")) {
setIDs(menu, 0,
setIDs(
menu,
0,
"delete-button",
"help-button",
"duplicate-button",
@ -43,25 +44,20 @@ $register_ids(EditLevelLayer) {
"folder-button"
);
detachAndCreateMenu(menu,
"folder-menu",
ColumnLayout::create(),
menu->getChildByID("folder-button")
detachAndCreateMenu(
menu, "folder-menu", ColumnLayout::create(), menu->getChildByID("folder-button")
);
}
if (auto menu = this->getChildByID("back-button-menu"))
setIDSafe(menu, 0, "back-button");
if (auto menu = this->getChildByID("back-button-menu")) setIDSafe(menu, 0, "back-button");
if (auto menu = this->getChildByID("info-button-menu"))
setIDSafe(menu, 0, "info-button");
if (auto menu = this->getChildByID("info-button-menu")) setIDSafe(menu, 0, "info-button");
}
class $modify(EditLevelLayer) {
struct EditLevelLayerIDs : Modify<EditLevelLayerIDs, EditLevelLayer> {
bool init(GJGameLevel* l) {
if (!EditLevelLayer::init(l))
return false;
if (!EditLevelLayer::init(l)) return false;
NodeIDs::get()->provide(this);
return true;

View file

@ -1,12 +1,12 @@
#include <Geode/modify/EditorUI.hpp>
#include <Geode/Bindings.hpp>
#include <Geode/utils/cocos.hpp>
#include "AddIDs.hpp"
#include <Geode/Bindings.hpp>
#include <Geode/modify/EditorUI.hpp>
#include <Geode/utils/cocos.hpp>
USE_GEODE_NAMESPACE();
$register_ids(EditorUI) {
setIDSafe(this, 0, "position-slider");
setIDSafe(this, this->getChildrenCount() - 2, "layer-index-label");
setIDSafe(this, this->getChildrenCount() - 1, "object-info-label");
@ -14,7 +14,9 @@ $register_ids(EditorUI) {
if (auto menu = getChildOfType<CCMenu>(this, 0)) {
menu->setID("toolbar-categories-menu");
setIDs(menu, 0,
setIDs(
menu,
0,
"build-button",
"edit-button",
"delete-button",
@ -42,7 +44,7 @@ $register_ids(EditorUI) {
detachAndCreateMenu(
this,
"toolbar-toggles-menu",
"toolbar-toggles-menu",
GridLayout::create(2, GridAlignment::Begin, GridDirection::Column),
menu->getChildByID("swipe-button"),
menu->getChildByID("free-move-button"),
@ -60,10 +62,7 @@ $register_ids(EditorUI) {
);
detachAndCreateMenu(
this,
"playback-menu",
RowLayout::create(),
menu->getChildByID("music-playback-button")
this, "playback-menu", RowLayout::create(), menu->getChildByID("music-playback-button")
);
detachAndCreateMenu(
@ -94,7 +93,9 @@ $register_ids(EditorUI) {
if (auto menu = getChildOfType<CCMenu>(this, 1)) {
menu->setID("delete-category-menu");
setIDs(menu, 0,
setIDs(
menu,
0,
"delete-button",
"delete-startpos-button",
"delete-all-of-button",
@ -130,7 +131,9 @@ $register_ids(EditorUI) {
if (auto menu = getChildOfType<CCMenu>(this, 2)) {
menu->setID("build-tabs-menu");
setIDs(menu, 0,
setIDs(
menu,
0,
"static-tab-1",
"static-tab-2",
"static-tab-3",
@ -148,7 +151,9 @@ $register_ids(EditorUI) {
}
if (auto menu = getChildOfType<CCMenu>(this, 3)) {
setIDs(menu, 0,
setIDs(
menu,
0,
"pause-button",
"settings-button",
"copy-paste-button",
@ -194,7 +199,7 @@ $register_ids(EditorUI) {
menu->getChildByID("copy-values-button"),
menu->getChildByID("hsv-button")
);
detachAndCreateMenu(
this,
"layer-menu",
@ -207,11 +212,10 @@ $register_ids(EditorUI) {
}
}
class $modify(EditorUI) {
struct EditorUIIDs : Modify<EditorUIIDs, EditorUI> {
bool init(LevelEditorLayer* lel) {
if (!EditorUI::init(lel))
return false;
if (!EditorUI::init(lel)) return false;
NodeIDs::get()->provide(this);
return true;

View file

@ -1,18 +1,21 @@
#include <Geode/modify/GJGarageLayer.hpp>
#include <Geode/Bindings.hpp>
#include <Geode/utils/cocos.hpp>
#include "AddIDs.hpp"
#include <Geode/Bindings.hpp>
#include <Geode/modify/GJGarageLayer.hpp>
#include <Geode/utils/cocos.hpp>
USE_GEODE_NAMESPACE();
$register_ids(GJGarageLayer) {
setIDSafe(this, 2, "username-label");
setIDSafe(this, 2, "username-label");
setIDSafe(this, 6, "player-icon");
if (auto menu = getChildOfType<CCMenu>(this, 0)) {
menu->setID("icon-select-menu");
setIDs(menu, 0,
setIDs(
menu,
0,
"cube-button",
"ship-button",
"ball-button",
@ -25,7 +28,9 @@ $register_ids(GJGarageLayer) {
);
}
setIDs(this, 10,
setIDs(
this,
10,
"cube-selection-menu",
"ship-selection-menu",
"ball-selection-menu",
@ -45,26 +50,18 @@ $register_ids(GJGarageLayer) {
if (auto menu = getChildOfType<CCMenu>(this, 11)) {
menu->setID("top-left-menu");
setIDs(menu, 0,
"back-button",
"shop-button",
"shards-button"
);
setIDs(menu, 0, "back-button", "shop-button", "shards-button");
detachAndCreateMenu(
menu,
"shards-button-menu",
ColumnLayout::create(),
menu->getChildByID("shards-button")
menu, "shards-button-menu", ColumnLayout::create(), menu->getChildByID("shards-button")
);
}
}
class $modify(GJGarageLayer) {
struct GJGarageLayerIDs : Modify<GJGarageLayerIDs, GJGarageLayer> {
bool init() {
if (!GJGarageLayer::init())
return false;
if (!GJGarageLayer::init()) return false;
NodeIDs::get()->provide(this);
return true;

View file

@ -1,8 +1,9 @@
#include <Geode/Modify.hpp>
#include <Geode/Bindings.hpp>
#include <Geode/utils/cocos.hpp>
#include "AddIDs.hpp"
#include <Geode/Bindings.hpp>
#include <Geode/Modify.hpp>
#include <Geode/utils/cocos.hpp>
USE_GEODE_NAMESPACE();
$register_ids(LevelBrowserLayer) {
@ -17,24 +18,23 @@ $register_ids(LevelBrowserLayer) {
setIDSafe(menu, 0, "new-level-button");
if (auto myLevelsBtn = setIDSafe(menu, 1, "my-levels-button")) {
detachAndCreateMenu(this, "my-levels-menu",
detachAndCreateMenu(
this,
"my-levels-menu",
ColumnLayout::create(5.f, 0.f)->setAlignment(Alignment::End),
myLevelsBtn
);
}
menu->setLayout(
ColumnLayout::create(5.f, 0.f)->setAlignment(Alignment::End)
);
menu->setLayout(ColumnLayout::create(5.f, 0.f)->setAlignment(Alignment::End));
}
}
}
class $modify(LevelBrowserLayer) {
struct LevelBrowserLayerIDs : Modify<LevelBrowserLayerIDs, LevelBrowserLayer> {
bool init(GJSearchObject* obj) {
if (!LevelBrowserLayer::init(obj))
return false;
if (!LevelBrowserLayer::init(obj)) return false;
NodeIDs::get()->provide(this);
return true;

View file

@ -1,4 +1,5 @@
#include "AddIDs.hpp"
#include <Geode/binding/LevelInfoLayer.hpp>
#include <Geode/modify/LevelInfoLayer.hpp>
@ -35,7 +36,7 @@ $register_ids(LevelInfoLayer) {
if (auto menu = getChildOfType<CCMenu>(this, 0)) {
menu->setID("exit-menu");
setIDSafe(menu, 0, "exit-button");
setIDSafe(menu, 0, "exit-button");
}
if (auto menu = getChildOfType<CCMenu>(this, 1)) {
@ -43,9 +44,7 @@ $register_ids(LevelInfoLayer) {
if (auto name = setIDSafe(menu, 0, "creator-name")) {
detachAndCreateMenu(
this, "creator-info-menu",
ColumnLayout::create()->setAlignment(Alignment::Begin),
name
this, "creator-info-menu", ColumnLayout::create()->setAlignment(Alignment::Begin), name
);
}
@ -56,7 +55,7 @@ $register_ids(LevelInfoLayer) {
this->addChild(leftSideMenu);
menu->setPosition(winSize / 2 + ccp(254.f, 0.f));
for (auto child : CCArrayExt<CCNode>(menu->getChildren())) {
if (child->getPositionX() < 0.f) {
child->retain();
@ -81,11 +80,10 @@ $register_ids(LevelInfoLayer) {
}
}
class $modify(LevelInfoLayer) {
struct LevelInfoLayerIDs : Modify<LevelInfoLayerIDs, LevelInfoLayer> {
bool init(GJGameLevel* level) {
if (!LevelInfoLayer::init(level))
return false;
if (!LevelInfoLayer::init(level)) return false;
NodeIDs::get()->provide(this);
return true;

View file

@ -1,78 +1,76 @@
#include "AddIDs.hpp"
#include <Geode/modify/LevelSearchLayer.hpp>
$register_ids(LevelSearchLayer) {
// set the funny ids
setIDSafe(this, 0, "background");
getChildOfType<CCTextInputNode>(this, 0)->setID("search-bar");
getChildOfType<CCScale9Sprite>(this, 0)->setID("level-search-bg");
getChildOfType<CCScale9Sprite>(this, 1)->setID("level-search-bar-bg");
getChildOfType<CCScale9Sprite>(this, 2)->setID("quick-search-bg");
getChildOfType<CCScale9Sprite>(this, 3)->setID("difficulty-filters-bg");
getChildOfType<CCScale9Sprite>(this, 4)->setID("length-filters-bg");
getChildOfType<CCLabelBMFont>(this, 0)->setID("quick-search-title");
getChildOfType<CCLabelBMFont>(this, 1)->setID("filters-title");
getChildOfType<CCSprite>(this, 1)->setID("left-corner");
getChildOfType<CCSprite>(this, 2)->setID("right-corner");
if (auto filtermenu = getChildOfType<CCMenu>(this, 0)) {
filtermenu->setID("other-filter-menu");
setIDSafe(filtermenu, 0, "clear-filters-button");
setIDSafe(filtermenu, 1, "advanced-filters-button");
}
if (auto searchmenu = getChildOfType<CCMenu>(this, 1)) {
searchmenu->setID("search-button-menu");
setIDSafe(searchmenu, 0, "search-level-button");
setIDSafe(searchmenu, 1, "search-user-button");
// set the funny ids
setIDSafe(this, 0, "background");
getChildOfType<CCTextInputNode>(this, 0)->setID("search-bar");
getChildOfType<CCScale9Sprite>(this, 0)->setID("level-search-bg");
getChildOfType<CCScale9Sprite>(this, 1)->setID("level-search-bar-bg");
getChildOfType<CCScale9Sprite>(this, 2)->setID("quick-search-bg");
getChildOfType<CCScale9Sprite>(this, 3)->setID("difficulty-filters-bg");
getChildOfType<CCScale9Sprite>(this, 4)->setID("length-filters-bg");
getChildOfType<CCLabelBMFont>(this, 0)->setID("quick-search-title");
getChildOfType<CCLabelBMFont>(this, 1)->setID("filters-title");
getChildOfType<CCSprite>(this, 1)->setID("left-corner");
getChildOfType<CCSprite>(this, 2)->setID("right-corner");
}
if (auto quickmenu = getChildOfType<CCMenu>(this, 2)) {
quickmenu->setID("quick-search-menu");
setIDSafe(quickmenu, 0, "most-downloaded-button");
setIDSafe(quickmenu, 1, "most-liked-button");
setIDSafe(quickmenu, 2, "trending-button");
setIDSafe(quickmenu, 3, "recent-button");
setIDSafe(quickmenu, 4, "magic-button");
setIDSafe(quickmenu, 5, "awarded-button");
setIDSafe(quickmenu, 6, "followed-button");
setIDSafe(quickmenu, 7, "friends-button");
}
if (auto filtersmenu = getChildOfType<CCMenu>(this, 3)) {
filtersmenu->setID("difficulty-filter-menu");
setIDSafe(filtersmenu, 0, "na-filter-button");
setIDSafe(filtersmenu, 1, "easy-filter-button");
setIDSafe(filtersmenu, 2, "normal-filter-button");
setIDSafe(filtersmenu, 3, "hard-filter-button");
setIDSafe(filtersmenu, 4, "harder-filter-button");
setIDSafe(filtersmenu, 5, "insane-filter-button");
setIDSafe(filtersmenu, 6, "demon-filter-button");
setIDSafe(filtersmenu, 7, "auto-filter-button");
setIDSafe(filtersmenu, 8, "demon-type-filter-button");
}
if (auto filtersmenu = getChildOfType<CCMenu>(this, 4)) {
filtersmenu->setID("length-filter-menu");
setIDSafe(filtersmenu, 0, "clock-icon");
setIDSafe(filtersmenu, 1, "tiny-filter-button");
setIDSafe(filtersmenu, 2, "short-filter-button");
setIDSafe(filtersmenu, 3, "medium-filter-button");
setIDSafe(filtersmenu, 4, "long-filter-button");
setIDSafe(filtersmenu, 5, "xl-filter-button");
setIDSafe(filtersmenu, 6, "star-filter-button");
}
if (auto backmenu = getChildOfType<CCMenu>(this, 5)) {
backmenu->setID("exit-menu");
setIDSafe(backmenu, 0, "exit-button");
}
if (auto filtermenu = getChildOfType<CCMenu>(this, 0)) {
filtermenu->setID("other-filter-menu");
setIDSafe(filtermenu, 0, "clear-filters-button");
setIDSafe(filtermenu, 1, "advanced-filters-button");
}
if (auto searchmenu = getChildOfType<CCMenu>(this, 1)) {
searchmenu->setID("search-button-menu");
setIDSafe(searchmenu, 0, "search-level-button");
setIDSafe(searchmenu, 1, "search-user-button");
}
if (auto quickmenu = getChildOfType<CCMenu>(this, 2)) {
quickmenu->setID("quick-search-menu");
setIDSafe(quickmenu, 0, "most-downloaded-button");
setIDSafe(quickmenu, 1, "most-liked-button");
setIDSafe(quickmenu, 2, "trending-button");
setIDSafe(quickmenu, 3, "recent-button");
setIDSafe(quickmenu, 4, "magic-button");
setIDSafe(quickmenu, 5, "awarded-button");
setIDSafe(quickmenu, 6, "followed-button");
setIDSafe(quickmenu, 7, "friends-button");
}
if (auto filtersmenu = getChildOfType<CCMenu>(this, 3)) {
filtersmenu->setID("difficulty-filter-menu");
setIDSafe(filtersmenu, 0, "na-filter-button");
setIDSafe(filtersmenu, 1, "easy-filter-button");
setIDSafe(filtersmenu, 2, "normal-filter-button");
setIDSafe(filtersmenu, 3, "hard-filter-button");
setIDSafe(filtersmenu, 4, "harder-filter-button");
setIDSafe(filtersmenu, 5, "insane-filter-button");
setIDSafe(filtersmenu, 6, "demon-filter-button");
setIDSafe(filtersmenu, 7, "auto-filter-button");
setIDSafe(filtersmenu, 8, "demon-type-filter-button");
}
if (auto filtersmenu = getChildOfType<CCMenu>(this, 4)) {
filtersmenu->setID("length-filter-menu");
setIDSafe(filtersmenu, 0, "clock-icon");
setIDSafe(filtersmenu, 1, "tiny-filter-button");
setIDSafe(filtersmenu, 2, "short-filter-button");
setIDSafe(filtersmenu, 3, "medium-filter-button");
setIDSafe(filtersmenu, 4, "long-filter-button");
setIDSafe(filtersmenu, 5, "xl-filter-button");
setIDSafe(filtersmenu, 6, "star-filter-button");
}
if (auto backmenu = getChildOfType<CCMenu>(this, 5)) {
backmenu->setID("exit-menu");
setIDSafe(backmenu, 0, "exit-button");
}
}
class $modify(LevelSearchLayer) {
struct LevelSearchLayerIDs : Modify<LevelSearchLayerIDs, LevelSearchLayer> {
bool init() {
if (!LevelSearchLayer::init())
return false;
if (!LevelSearchLayer::init()) return false;
NodeIDs::get()->provide(this);
return true;
}
};

View file

@ -1,198 +1,206 @@
#include <Geode/Modify.hpp>
#include <Geode/Bindings.hpp>
#include <Geode/utils/cocos.hpp>
#include "AddIDs.hpp"
#include <Geode/Bindings.hpp>
#include <Geode/Modify.hpp>
#include <Geode/utils/cocos.hpp>
USE_GEODE_NAMESPACE();
$register_ids(LevelSettingsLayer) {
bool startPos = m_mainLayer->getChildrenCount() < 10;
bool startPos = m_mainLayer->getChildrenCount() < 10;
if (startPos) {
setIDSafe(m_mainLayer, 0, "back-button");
}
if (startPos) {
setIDSafe(m_mainLayer, 0, "back-button");
}
if (auto menu = getChildOfType<CCMenu>(m_mainLayer, 0)) {
menu->setID("song-select-menu");
if (auto menu = getChildOfType<CCMenu>(m_mainLayer, 0)) {
menu->setID("song-select-menu");
if (startPos) {
setIDs(menu, 0,
"cube-button",
"ship-button",
"ball-button",
"ufo-button",
"wave-button",
"robot-button",
"spider-button",
"mini-toggle",
"dual-toggle",
"ok-button",
"flip-gravity-toggle",
"half-speed-button",
"normal-speed-button",
"2x-speed-button",
"3x-speed-button",
"4x-speed-button"
);
} else {
setIDs(menu, 0,
"bg-color-button",
"g-color-button",
"g2-color-button",
"line-color-button",
"obj-color-button",
"more-color-button",
"3dl-color-button",
"bg-quick-edit-button",
"g-quick-edit-button",
"g2-quick-edit-button",
"line-quick-edit-button",
"cube-button",
"ship-button",
"ball-button",
"ufo-button",
"wave-button",
"robot-button",
"spider-button",
"background-select-button",
"ground-select-button",
"mini-toggle",
"dual-toggle",
"font-button",
"ok-button",
"2-player-toggle",
"2-player-help-button",
"prev-song-button",
"next-song-button",
"normal-song-button",
"custom-song-button",
"select-custom-song-button",
"new-song-button",
"half-speed-button",
"normal-speed-button",
"2x-speed-button",
"3x-speed-button",
"4x-speed-button"
);
}
if (startPos) {
setIDs(
menu,
0,
"cube-button",
"ship-button",
"ball-button",
"ufo-button",
"wave-button",
"robot-button",
"spider-button",
"mini-toggle",
"dual-toggle",
"ok-button",
"flip-gravity-toggle",
"half-speed-button",
"normal-speed-button",
"2x-speed-button",
"3x-speed-button",
"4x-speed-button"
);
}
else {
setIDs(
menu,
0,
"bg-color-button",
"g-color-button",
"g2-color-button",
"line-color-button",
"obj-color-button",
"more-color-button",
"3dl-color-button",
"bg-quick-edit-button",
"g-quick-edit-button",
"g2-quick-edit-button",
"line-quick-edit-button",
"cube-button",
"ship-button",
"ball-button",
"ufo-button",
"wave-button",
"robot-button",
"spider-button",
"background-select-button",
"ground-select-button",
"mini-toggle",
"dual-toggle",
"font-button",
"ok-button",
"2-player-toggle",
"2-player-help-button",
"prev-song-button",
"next-song-button",
"normal-song-button",
"custom-song-button",
"select-custom-song-button",
"new-song-button",
"half-speed-button",
"normal-speed-button",
"2x-speed-button",
"3x-speed-button",
"4x-speed-button"
);
}
detachAndCreateMenu(
this,
"vehicle-selection-menu",
RowLayout::create(),
menu->getChildByID("cube-button"),
menu->getChildByID("ship-button"),
menu->getChildByID("ball-button"),
menu->getChildByID("ufo-button"),
menu->getChildByID("wave-button"),
menu->getChildByID("robot-button"),
menu->getChildByID("spider-button")
);
detachAndCreateMenu(
this,
"vehicle-selection-menu",
RowLayout::create(),
menu->getChildByID("cube-button"),
menu->getChildByID("ship-button"),
menu->getChildByID("ball-button"),
menu->getChildByID("ufo-button"),
menu->getChildByID("wave-button"),
menu->getChildByID("robot-button"),
menu->getChildByID("spider-button")
);
detachAndCreateMenu(
this,
"right-toggle-menu",
ColumnLayout::create(),
menu->getChildByID("mini-toggle"),
menu->getChildByID("dual-toggle")
);
detachAndCreateMenu(
this,
"right-toggle-menu",
ColumnLayout::create(),
menu->getChildByID("mini-toggle"),
menu->getChildByID("dual-toggle")
);
detachAndCreateMenu(
this,
"speed-selection-menu",
ColumnLayout::create(),
menu->getChildByID("half-speed-button"),
menu->getChildByID("normal-song-button"),
menu->getChildByID("2x-speed-button"),
menu->getChildByID("3x-speed-button"),
menu->getChildByID("4x-speed-button")
);
detachAndCreateMenu(
this,
"speed-selection-menu",
ColumnLayout::create(),
menu->getChildByID("half-speed-button"),
menu->getChildByID("normal-song-button"),
menu->getChildByID("2x-speed-button"),
menu->getChildByID("3x-speed-button"),
menu->getChildByID("4x-speed-button")
);
if (startPos) {
detachAndCreateMenu(
this,
"flip-gravity-menu",
ColumnLayout::create(),
menu->getChildByID("flip-gravity-toggle")
);
} else {
detachAndCreateMenu(
this,
"color-button-menu",
RowLayout::create(),
menu->getChildByID("bg-color-button"),
menu->getChildByID("g-color-button"),
menu->getChildByID("g2-color-button"),
menu->getChildByID("line-color-button"),
menu->getChildByID("obj-color-button"),
menu->getChildByID("3dl-color-button"),
menu->getChildByID("more-color-button")
);
if (startPos) {
detachAndCreateMenu(
this,
"flip-gravity-menu",
ColumnLayout::create(),
menu->getChildByID("flip-gravity-toggle")
);
}
else {
detachAndCreateMenu(
this,
"color-button-menu",
RowLayout::create(),
menu->getChildByID("bg-color-button"),
menu->getChildByID("g-color-button"),
menu->getChildByID("g2-color-button"),
menu->getChildByID("line-color-button"),
menu->getChildByID("obj-color-button"),
menu->getChildByID("3dl-color-button"),
menu->getChildByID("more-color-button")
);
detachAndCreateMenu(
this,
"color-quick-edit-menu",
RowLayout::create(),
menu->getChildByID("bg-quick-edit-button"),
menu->getChildByID("g-quick-edit-button"),
menu->getChildByID("g2-quick-edit-button"),
menu->getChildByID("line-quick-edit-button")
);
detachAndCreateMenu(
this,
"color-quick-edit-menu",
RowLayout::create(),
menu->getChildByID("bg-quick-edit-button"),
menu->getChildByID("g-quick-edit-button"),
menu->getChildByID("g2-quick-edit-button"),
menu->getChildByID("line-quick-edit-button")
);
detachAndCreateMenu(
this,
"scenery-selection-menu",
ColumnLayout::create(),
menu->getChildByID("background-select-button"),
menu->getChildByID("ground-select-button")
);
detachAndCreateMenu(
this,
"scenery-selection-menu",
ColumnLayout::create(),
menu->getChildByID("background-select-button"),
menu->getChildByID("ground-select-button")
);
detachAndCreateMenu(
this,
"2-player-menu",
ColumnLayout::create(),
menu->getChildByID("2-player-help-button"),
menu->getChildByID("2-player-toggle")
);
detachAndCreateMenu(
this,
"2-player-menu",
ColumnLayout::create(),
menu->getChildByID("2-player-help-button"),
menu->getChildByID("2-player-toggle")
);
detachAndCreateMenu(
this,
"font-button-menu",
RowLayout::create()->setAlignment(Alignment::End),
menu->getChildByID("font-button")
);
}
}
detachAndCreateMenu(
this,
"font-button-menu",
RowLayout::create()->setAlignment(Alignment::End),
menu->getChildByID("font-button")
);
}
}
setIDs(m_mainLayer, 2,
"select-color-label",
"bg-color-label",
"g-color-label",
"g2-color-label",
"3dl-color-label",
"line-color-label",
"obj-color-label",
"more-color-label",
"select-mode-label",
"bg-selection-label",
"g-selection-label",
"mini-label",
"dual-label",
"2-player-label-1",
"2-player-label-2",
"select-song-label",
"default-song-label",
"custom-song-widget",
"speed-label"
);
setIDs(
m_mainLayer,
2,
"select-color-label",
"bg-color-label",
"g-color-label",
"g2-color-label",
"3dl-color-label",
"line-color-label",
"obj-color-label",
"more-color-label",
"select-mode-label",
"bg-selection-label",
"g-selection-label",
"mini-label",
"dual-label",
"2-player-label-1",
"2-player-label-2",
"select-song-label",
"default-song-label",
"custom-song-widget",
"speed-label"
);
}
class $modify(LevelSettingsLayer) {
struct LevelSettingsLayerIDs : Modify<LevelSettingsLayerIDs, LevelSettingsLayer> {
bool init(LevelSettingsObject* levelSettings, LevelEditorLayer* editor) {
if (!LevelSettingsLayer::init(levelSettings, editor))
return false;
//NodeIDs::get()->provide(this);
if (!LevelSettingsLayer::init(levelSettings, editor)) return false;
// NodeIDs::get()->provide(this);
return true;
}

View file

@ -1,90 +1,88 @@
#include "AddIDs.hpp"
#include <Geode/modify/MenuLayer.hpp>
#include <Geode/utils/cocos.hpp>
#include "AddIDs.hpp"
USE_GEODE_NAMESPACE();
$register_ids(MenuLayer) {
// set IDs to everything
setIDSafe(this, 0, "main-menu-bg");
setIDSafe<CCSprite>(this, 0, "main-title");
// set IDs to everything
setIDSafe(this, 0, "main-menu-bg");
setIDSafe<CCSprite>(this, 0, "main-title");
// controller
if (PlatformToolbox::isControllerConnected()) {
setIDSafe<CCSprite>(this, 1, "play-gamepad-icon");
setIDSafe<CCSprite>(this, 2, "editor-gamepad-icon");
setIDSafe<CCSprite>(this, 3, "icon-kit-gamepad-icon");
// controller
if (PlatformToolbox::isControllerConnected()) {
setIDSafe<CCSprite>(this, 1, "play-gamepad-icon");
setIDSafe<CCSprite>(this, 2, "editor-gamepad-icon");
setIDSafe<CCSprite>(this, 3, "icon-kit-gamepad-icon");
setIDSafe<CCSprite>(this, 4, "settings-gamepad-icon");
setIDSafe<CCSprite>(this, 5, "mouse-gamepad-icon");
setIDSafe<CCSprite>(this, 6, "click-gamepad-icon");
setIDSafe<CCSprite>(this, 4, "settings-gamepad-icon");
setIDSafe<CCSprite>(this, 5, "mouse-gamepad-icon");
setIDSafe<CCSprite>(this, 6, "click-gamepad-icon");
setIDSafe<CCLabelBMFont>(this, 0, "mouse-gamepad-label");
setIDSafe<CCLabelBMFont>(this, 1, "click-gamepad-label");
setIDSafe<CCLabelBMFont>(this, 0, "mouse-gamepad-label");
setIDSafe<CCLabelBMFont>(this, 1, "click-gamepad-label");
setIDSafe<CCLabelBMFont>(this, 2, "player-username");
} else {
setIDSafe<CCLabelBMFont>(this, 0, "player-username");
}
// main menu
if (auto menu = getChildOfType<CCMenu>(this, 0)) {
menu->setID("main-menu");
auto playBtn = setIDSafe(menu, 0, "play-button");
auto iconBtn = setIDSafe(menu, 1, "icon-kit-button");
setIDSafe<CCLabelBMFont>(this, 2, "player-username");
}
else {
setIDSafe<CCLabelBMFont>(this, 0, "player-username");
}
// main menu
if (auto menu = getChildOfType<CCMenu>(this, 0)) {
menu->setID("main-menu");
auto playBtn = setIDSafe(menu, 0, "play-button");
auto iconBtn = setIDSafe(menu, 1, "icon-kit-button");
// the buttons are added in order play, icon, editor which doesn't work
// well with setLayout that deals with children in order
menu->swapChildIndices(playBtn, iconBtn);
// the buttons are added in order play, icon, editor which doesn't work
// well with setLayout that deals with children in order
menu->swapChildIndices(playBtn, iconBtn);
setIDSafe(menu, 2, "editor-button");
if (auto pfp = setIDSafe(menu, 3, "profile-button")) {
pfp->setPositionHint(PositionHint::Absolute);
}
setIDSafe(menu, 2, "editor-button");
menu->setLayout(RowLayout::create(18.f, 0.f));
}
// bottom menu
if (auto menu = getChildOfType<CCMenu>(this, 1)) {
menu->setID("bottom-menu");
auto ach = setIDSafe(menu, 0, "achievements-button");
setIDSafe(menu, 1, "settings-button");
setIDSafe(menu, 2, "stats-button");
setIDSafe(menu, 3, "newgrounds-button");
if (auto pfp = setIDSafe(menu, 3, "profile-button")) {
pfp->setPositionHint(PositionHint::Absolute);
}
// move daily chest to its own menu
menu->setLayout(RowLayout::create(18.f, 0.f));
}
// bottom menu
if (auto menu = getChildOfType<CCMenu>(this, 1)) {
menu->setID("bottom-menu");
auto ach = setIDSafe(menu, 0, "achievements-button");
setIDSafe(menu, 1, "settings-button");
setIDSafe(menu, 2, "stats-button");
setIDSafe(menu, 3, "newgrounds-button");
if (auto dailyChest = setIDSafe(menu, -1, "daily-chest-button")) {
detachAndCreateMenu(this, "right-side-menu",
ColumnLayout::create(0.f, 0.f),
dailyChest
);
}
// move daily chest to its own menu
menu->setLayout(RowLayout::create(5.f, ach->getPositionY()));
}
// social media menu
if (auto menu = getChildOfType<CCMenu>(this, 2)) {
menu->setID("social-media-menu");
setIDSafe(menu, 0, "robtop-logo-button");
setIDSafe(menu, 1, "facebook-button");
setIDSafe(menu, 2, "twitter-button");
setIDSafe(menu, 3, "youtube-button");
}
// more games menu
if (auto menu = getChildOfType<CCMenu>(this, 3)) {
menu->setID("more-games-menu");
setIDSafe(menu, 0, "more-games-button");
if (auto dailyChest = setIDSafe(menu, -1, "daily-chest-button")) {
detachAndCreateMenu(this, "right-side-menu", ColumnLayout::create(0.f, 0.f), dailyChest);
}
// move close button to its own menu
menu->setLayout(RowLayout::create(5.f, ach->getPositionY()));
}
// social media menu
if (auto menu = getChildOfType<CCMenu>(this, 2)) {
menu->setID("social-media-menu");
setIDSafe(menu, 0, "robtop-logo-button");
setIDSafe(menu, 1, "facebook-button");
setIDSafe(menu, 2, "twitter-button");
setIDSafe(menu, 3, "youtube-button");
}
// more games menu
if (auto menu = getChildOfType<CCMenu>(this, 3)) {
menu->setID("more-games-menu");
setIDSafe(menu, 0, "more-games-button");
if (auto closeBtn = setIDSafe(menu, 1, "close-button")) {
detachAndCreateMenu(this, "close-menu",
RowLayout::create(5.f, 0.f)->setAlignment(Alignment::Begin),
closeBtn
);
}
}
// move close button to its own menu
if (auto closeBtn = setIDSafe(menu, 1, "close-button")) {
detachAndCreateMenu(
this, "close-menu", RowLayout::create(5.f, 0.f)->setAlignment(Alignment::Begin), closeBtn
);
}
}
}
// MenuLayer::init is hooked in ../hooks/MenuLayer.cpp

View file

@ -1,78 +1,67 @@
#include <Geode/modify/PauseLayer.hpp>
#include <Geode/Bindings.hpp>
#include <Geode/utils/cocos.hpp>
#include "AddIDs.hpp"
#include <Geode/Bindings.hpp>
#include <Geode/modify/PauseLayer.hpp>
#include <Geode/utils/cocos.hpp>
USE_GEODE_NAMESPACE();
$register_ids(PauseLayer) {
setIDs(this, 0,
"background",
"level-name",
setIDs(
this,
0,
"background",
"level-name",
"normal-progress-bar",
"practice-progress-bar",
"normal-progress-label",
"practice-progress-label",
"normal-mode-label",
"practice-mode-label",
"normal-progress-bar",
"practice-progress-bar",
"normal-progress-label",
"practice-progress-label",
"normal-mode-label",
"practice-mode-label",
"center-button-menu",
"center-button-menu",
"auto-retry-label",
"auto-checkpoints-label",
"show-progress-bar-label"
);
"auto-retry-label",
"auto-checkpoints-label",
"show-progress-bar-label"
);
if (auto menu = this->getChildByID("center-button-menu")) {
int start_idx = 0;
if (auto menu = this->getChildByID("center-button-menu")) {
int start_idx = 0;
if (menu->getChildrenCount() == 5) {
setIDSafe(menu, 0, "edit-button");
start_idx = 1;
}
if (menu->getChildrenCount() == 5) {
setIDSafe(menu, 0, "edit-button");
start_idx = 1;
}
setIDs(menu, start_idx,
"practice-button",
"play-button",
"exit-button"
);
setIDs(menu, start_idx, "practice-button", "play-button", "exit-button");
if (menu->getChildrenCount() == 4)
setIDSafe(menu, start_idx + 3, "retry-button");
}
if (menu->getChildrenCount() == 4) setIDSafe(menu, start_idx + 3, "retry-button");
}
// Record toggle on mobile
if (auto label = typeinfo_cast<CCLabelBMFont*>(getChild(this, 12))) {
setIDSafe(this, 12, "record-label");
}
// Record toggle on mobile
if (auto label = typeinfo_cast<CCLabelBMFont*>(getChild(this, 12))) {
setIDSafe(this, 12, "record-label");
}
if (auto menu = getChildOfType<CCMenu>(this, 1)) {
menu->setID("toggle-menu");
if (auto menu = getChildOfType<CCMenu>(this, 1)) {
menu->setID("toggle-menu");
setIDs(menu, 0,
"auto-retry-toggle",
"auto-checkpoints-toggle",
"show-progress-bar-toggle"
);
setIDs(menu, 0, "auto-retry-toggle", "auto-checkpoints-toggle", "show-progress-bar-toggle");
if (menu->getChildrenCount() == 4)
setIDSafe(menu, 3, "record-toggle");
}
if (menu->getChildrenCount() == 4) setIDSafe(menu, 3, "record-toggle");
}
setIDs(this, this->getChildrenCount() - 4,
"music-slider",
"sfx-slider",
"music-label",
"sfx-label"
);
setIDs(
this, this->getChildrenCount() - 4, "music-slider", "sfx-slider", "music-label", "sfx-label"
);
}
class $modify(PauseLayer) {
struct PauseLayerIDs : Modify<PauseLayerIDs, PauseLayer> {
void customSetup() {
PauseLayer::customSetup();
NodeIDs::get()->provide(this);
}
};

View file

@ -1,32 +1,29 @@
#include <Geode/modify/UILayer.hpp>
#include <Geode/Bindings.hpp>
#include <Geode/utils/cocos.hpp>
#include "AddIDs.hpp"
#include <Geode/Bindings.hpp>
#include <Geode/modify/UILayer.hpp>
#include <Geode/utils/cocos.hpp>
USE_GEODE_NAMESPACE();
$register_ids(UILayer) {
if (auto menu = getChildOfType<CCMenu>(this, 0)) {
menu->setID("pause-button-menu");
if (auto menu = getChildOfType<CCMenu>(this, 0)) {
menu->setID("pause-button-menu");
setIDs(menu, 0, "pause-button");
}
setIDs(menu, 0, "pause-button");
}
if (auto menu = getChildOfType<CCMenu>(this, 1)) {
menu->setID("checkpoint-menu");
if (auto menu = getChildOfType<CCMenu>(this, 1)) {
menu->setID("checkpoint-menu");
setIDs(menu, 0,
"add-checkpoint-button",
"remove-checkpoint-button"
);
}
setIDs(menu, 0, "add-checkpoint-button", "remove-checkpoint-button");
}
}
class $modify(UILayer) {
struct UILayerIDs : Modify<UILayerIDs, UILayer> {
bool init() {
if (!UILayer::init())
return false;
if (!UILayer::init()) return false;
NodeIDs::get()->provide(this);
return true;

View file

@ -17,7 +17,7 @@ protected:
ErrorCallback m_error;
bool m_filemode = false;
void* m_platform_handle;
void* m_platformHandle;
bool m_exiting = false;
void watch();

View file

@ -113,7 +113,7 @@ std::vector<Hook*> Mod::Impl::getHooks() const {
// Settings and saved values
Result<> Mod::Impl::loadData() {
ModStateEvent(this->m_self, ModEventType::DataLoaded).post();
ModStateEvent(m_self, ModEventType::DataLoaded).post();
// Settings
// Check if settings exist
@ -135,7 +135,7 @@ Result<> Mod::Impl::loadData() {
if (!setting->load(value.json())) {
log::internalLog(
Severity::Error,
this->m_self,
m_self,
"{}: Unable to load value for setting \"{}\"",
m_info.id,
key
@ -145,7 +145,7 @@ Result<> Mod::Impl::loadData() {
else {
log::internalLog(
Severity::Warning,
this->m_self,
m_self,
"Encountered unknown setting \"{}\" while loading "
"settings",
key
@ -174,7 +174,7 @@ Result<> Mod::Impl::loadData() {
}
Result<> Mod::Impl::saveData() {
ModStateEvent(this->m_self, ModEventType::DataSaved).post();
ModStateEvent(m_self, ModEventType::DataSaved).post();
// Data saving should be fully fail-safe
@ -285,14 +285,14 @@ Result<> Mod::Impl::loadBinary() {
return Err("Mod has unresolved dependencies");
}
LoaderImpl::get()->provideNextMod(this->m_self);
LoaderImpl::get()->provideNextMod(m_self);
GEODE_UNWRAP(this->loadPlatformBinary());
m_binaryLoaded = true;
LoaderImpl::get()->releaseNextMod();
ModStateEvent(this->m_self, ModEventType::Loaded).post();
ModStateEvent(m_self, ModEventType::Loaded).post();
Loader::get()->updateAllDependencies();
@ -313,7 +313,7 @@ Result<> Mod::Impl::unloadBinary() {
GEODE_UNWRAP(this->saveData());
GEODE_UNWRAP(this->disable());
ModStateEvent(this->m_self, ModEventType::Unloaded).post();
ModStateEvent(m_self, ModEventType::Unloaded).post();
// Disabling unhooks and unpatches already
for (auto const& hook : m_hooks) {
@ -349,7 +349,7 @@ Result<> Mod::Impl::enable() {
}
}
ModStateEvent(this->m_self, ModEventType::Enabled).post();
ModStateEvent(m_self, ModEventType::Enabled).post();
m_enabled = true;
return Ok();
@ -363,7 +363,7 @@ Result<> Mod::Impl::disable() {
return Err("Mod does not support disabling");
}
ModStateEvent(this->m_self, ModEventType::Disabled).post();
ModStateEvent(m_self, ModEventType::Disabled).post();
for (auto const& hook : m_hooks) {
GEODE_UNWRAP(this->disableHook(hook));
@ -402,7 +402,7 @@ Result<> Mod::Impl::uninstall() {
}
bool Mod::Impl::isUninstalled() const {
return this->m_self != Mod::get() && !ghc::filesystem::exists(m_info.path);
return m_self != Mod::get() && !ghc::filesystem::exists(m_info.path);
}
// Dependencies
@ -503,7 +503,7 @@ Result<Hook*> Mod::Impl::addHook(Hook* hook) {
}
}
else {
LoaderImpl::get()->addInternalHook(hook, this->m_self);
LoaderImpl::get()->addInternalHook(hook, m_self);
}
return Ok(hook);
@ -533,7 +533,7 @@ Result<Patch*> Mod::Impl::patch(void* address, ByteVector const& data) {
auto p = new Patch;
p->m_address = address;
p->m_original = readMemory(address, data.size());
p->m_owner = this->m_self;
p->m_owner = m_self;
p->m_patch = data;
if (!p->apply()) {
delete p;

View file

@ -12,23 +12,23 @@
FileWatcher::FileWatcher(
ghc::filesystem::path const& file, FileWatchCallback callback, ErrorCallback error
) {
this->m_filemode = ghc::filesystem::is_regular_file(file);
m_filemode = ghc::filesystem::is_regular_file(file);
this->m_platform_handle = NULL;
this->m_file = file;
this->m_callback = callback;
this->m_error = error;
m_platformHandle = NULL;
m_file = file;
m_callback = callback;
m_error = error;
this->watch();
}
FileWatcher::~FileWatcher() {
dispatch_source_cancel(reinterpret_cast<dispatch_source_t>(this->m_platform_handle));
this->m_platform_handle = NULL;
dispatch_source_cancel(reinterpret_cast<dispatch_source_t>(m_platformHandle));
m_platformHandle = NULL;
}
void FileWatcher::watch() {
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
int fildes = open(this->m_file.string().c_str(), O_EVTONLY);
int fildes = open(m_file.string().c_str(), O_EVTONLY);
__block dispatch_source_t source = dispatch_source_create(
DISPATCH_SOURCE_TYPE_VNODE, fildes,
@ -38,11 +38,11 @@ void FileWatcher::watch() {
queue
);
this->m_platform_handle = static_cast<void*>(source);
m_platformHandle = static_cast<void*>(source);
dispatch_source_set_event_handler(source, ^{
if (this->m_callback) {
this->m_callback(this->m_file);
if (m_callback) {
m_callback(m_file);
}
});
dispatch_source_set_cancel_handler(source, ^(void) { close(fildes); });
@ -50,7 +50,7 @@ void FileWatcher::watch() {
}
bool FileWatcher::watching() const {
return this->m_platform_handle != NULL;
return m_platformHandle != NULL;
}
#endif

View file

@ -19,12 +19,12 @@ T findSymbolOrMangled(void* dylib, char const* name, char const* mangled) {
Result<> Mod::Impl::loadPlatformBinary() {
auto dylib =
dlopen((this->m_tempDirName / this->m_info.binaryName).string().c_str(), RTLD_LAZY);
dlopen((m_tempDirName / m_info.binaryName).string().c_str(), RTLD_LAZY);
if (dylib) {
if (this->m_platformInfo) {
delete this->m_platformInfo;
if (m_platformInfo) {
delete m_platformInfo;
}
this->m_platformInfo = new PlatformInfo { dylib };
m_platformInfo = new PlatformInfo { dylib };
return Ok();
}
@ -33,9 +33,9 @@ Result<> Mod::Impl::loadPlatformBinary() {
}
Result<> Mod::Impl::unloadPlatformBinary() {
auto dylib = this->m_platformInfo->m_dylib;
delete this->m_platformInfo;
this->m_platformInfo = nullptr;
auto dylib = m_platformInfo->m_dylib;
delete m_platformInfo;
m_platformInfo = nullptr;
if (dlclose(dylib) == 0) {
return Ok();
}

View file

@ -12,23 +12,23 @@
FileWatcher::FileWatcher(
ghc::filesystem::path const& file, FileWatchCallback callback, ErrorCallback error
) {
this->m_filemode = ghc::filesystem::is_regular_file(file);
m_filemode = ghc::filesystem::is_regular_file(file);
this->m_platform_handle = NULL;
this->m_file = file;
this->m_callback = callback;
this->m_error = error;
m_platformHandle = NULL;
m_file = file;
m_callback = callback;
m_error = error;
this->watch();
}
FileWatcher::~FileWatcher() {
dispatch_source_cancel(reinterpret_cast<dispatch_source_t>(this->m_platform_handle));
this->m_platform_handle = NULL;
dispatch_source_cancel(reinterpret_cast<dispatch_source_t>(m_platformHandle));
m_platformHandle = NULL;
}
void FileWatcher::watch() {
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
int fildes = open(this->m_file.string().c_str(), O_EVTONLY);
int fildes = open(m_file.string().c_str(), O_EVTONLY);
__block dispatch_source_t source = dispatch_source_create(
DISPATCH_SOURCE_TYPE_VNODE, fildes,
@ -38,11 +38,11 @@ void FileWatcher::watch() {
queue
);
this->m_platform_handle = static_cast<void*>(source);
m_platformHandle = static_cast<void*>(source);
dispatch_source_set_event_handler(source, ^{
if (this->m_callback) {
this->m_callback(this->m_file);
if (m_callback) {
m_callback(m_file);
}
});
dispatch_source_set_cancel_handler(source, ^(void) { close(fildes); });
@ -50,7 +50,7 @@ void FileWatcher::watch() {
}
bool FileWatcher::watching() const {
return this->m_platform_handle != NULL;
return m_platformHandle != NULL;
}
#endif

View file

@ -19,12 +19,12 @@ T findSymbolOrMangled(void* dylib, char const* name, char const* mangled) {
Result<> Mod::Impl::loadPlatformBinary() {
auto dylib =
dlopen((this->m_tempDirName / this->m_info.binaryName).string().c_str(), RTLD_LAZY);
dlopen((m_tempDirName / m_info.binaryName).string().c_str(), RTLD_LAZY);
if (dylib) {
if (this->m_platformInfo) {
delete this->m_platformInfo;
if (m_platformInfo) {
delete m_platformInfo;
}
this->m_platformInfo = new PlatformInfo { dylib };
m_platformInfo = new PlatformInfo { dylib };
return Ok();
}
@ -33,9 +33,9 @@ Result<> Mod::Impl::loadPlatformBinary() {
}
Result<> Mod::Impl::unloadPlatformBinary() {
auto dylib = this->m_platformInfo->m_dylib;
delete this->m_platformInfo;
this->m_platformInfo = nullptr;
auto dylib = m_platformInfo->m_dylib;
delete m_platformInfo;
m_platformInfo = nullptr;
if (dlclose(dylib) == 0) {
return Ok();
}

View file

@ -2,6 +2,7 @@
#ifdef GEODE_IS_MACOS
#include <array>
#include <ghc/filesystem.hpp>
#include <Foundation/Foundation.h>

View file

@ -10,43 +10,43 @@ static constexpr auto const notifyAttributes =
FileWatcher::FileWatcher(
ghc::filesystem::path const& file, FileWatchCallback callback, ErrorCallback error
) {
this->m_filemode = ghc::filesystem::is_regular_file(file);
m_filemode = ghc::filesystem::is_regular_file(file);
auto handle = FindFirstChangeNotificationW(
(this->m_filemode ? file.parent_path() : file).wstring().c_str(), false, notifyAttributes
(m_filemode ? file.parent_path() : file).wstring().c_str(), false, notifyAttributes
);
this->m_platform_handle = (void*)handle;
m_platformHandle = (void*)handle;
this->m_file = file;
this->m_callback = callback;
this->m_error = error;
m_file = file;
m_callback = callback;
m_error = error;
if (handle != INVALID_HANDLE_VALUE) {
std::thread(&FileWatcher::watch, this).detach();
}
else {
if (this->m_error) this->m_error("Invalid handle");
if (m_error) m_error("Invalid handle");
}
}
FileWatcher::~FileWatcher() {
HANDLE handle = (HANDLE)this->m_platform_handle;
HANDLE handle = (HANDLE)m_platformHandle;
FindCloseChangeNotification(handle);
this->m_exiting = true;
m_exiting = true;
}
void FileWatcher::watch() {
HANDLE handle = (HANDLE)this->m_platform_handle;
HANDLE handle = (HANDLE)m_platformHandle;
while (WaitForSingleObject(handle, 10000) == WAIT_OBJECT_0) {
if (this->m_exiting) return;
if (this->m_callback) {
if (this->m_filemode) {
if (m_exiting) return;
if (m_callback) {
if (m_filemode) {
auto file = CreateFileW(
this->m_file.parent_path().wstring().c_str(), FILE_LIST_DIRECTORY,
m_file.parent_path().wstring().c_str(), FILE_LIST_DIRECTORY,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, nullptr
);
if (file == INVALID_HANDLE_VALUE) {
handle = nullptr;
if (this->m_error) this->m_error("Reading dir failed");
if (m_error) m_error("Reading dir failed");
return;
}
OVERLAPPED overlapped;
@ -58,13 +58,13 @@ void FileWatcher::watch() {
&overlapped, nullptr
)) {
handle = nullptr;
if (this->m_error) this->m_error("Reading dir changes failed");
if (m_error) m_error("Reading dir changes failed");
return;
}
DWORD result = WaitForSingleObject(overlapped.hEvent, 500);
if (result != WAIT_OBJECT_0 && result != WAIT_TIMEOUT) {
handle = nullptr;
if (this->m_error) this->m_error("Overlap hEvent was not WAIT_OBJECT_0");
if (m_error) m_error("Overlap hEvent was not WAIT_OBJECT_0");
return;
}
DWORD bytes_transferred;
@ -74,30 +74,30 @@ void FileWatcher::watch() {
auto filename = std::wstring(
info->FileName, info->FileName + info->FileNameLength / sizeof(wchar_t)
);
if (ghc::filesystem::exists(this->m_file) &&
ghc::filesystem::file_size(this->m_file) > 1000 &&
if (ghc::filesystem::exists(m_file) &&
ghc::filesystem::file_size(m_file) > 1000 &&
info->Action == FILE_ACTION_MODIFIED &&
this->m_file.filename().wstring() == filename) {
this->m_callback(this->m_file);
m_file.filename().wstring() == filename) {
m_callback(m_file);
}
} while (info->NextEntryOffset && (info = info + info->NextEntryOffset));
}
else {
this->m_callback(this->m_file);
m_callback(m_file);
}
}
if (!FindNextChangeNotification(handle)) {
handle = nullptr;
if (this->m_error) this->m_error("FindNextChangeNotification failed");
if (m_error) m_error("FindNextChangeNotification failed");
return;
}
}
handle = nullptr;
if (this->m_error) this->m_error("WaitForSingleObject failed");
if (m_error) m_error("WaitForSingleObject failed");
}
bool FileWatcher::watching() const {
HANDLE handle = (HANDLE)this->m_platform_handle;
HANDLE handle = (HANDLE)m_platformHandle;
return handle != INVALID_HANDLE_VALUE && handle != nullptr;
}

View file

@ -10,8 +10,8 @@ bool HookListLayer::init(Mod* mod) {
for (auto const& hook : mod->getHooks()) {
hooks->addObject(new HookItem(hook));
}
this->m_listLayer->m_listView = HookListView::create(hooks, mod, 356.f, 220.f);
this->m_listLayer->addChild(this->m_listLayer->m_listView);
m_listLayer->m_listView = HookListView::create(hooks, mod, 356.f, 220.f);
m_listLayer->addChild(m_listLayer->m_listView);
return true;
}

View file

@ -49,7 +49,7 @@ void ListView::setupList() {
}
TableViewCell* ListView::getListCell(char const* key) {
return GenericListCell::create(key, { this->m_width, this->m_itemSeparation });
return GenericListCell::create(key, { m_width, m_itemSeparation });
}
void ListView::loadCell(TableViewCell* cell, unsigned int index) {

View file

@ -689,12 +689,12 @@ CCScrollLayerExt* MDTextArea::getScrollLayer() const {
}
void MDTextArea::setString(char const* text) {
this->m_text = text;
m_text = text;
this->updateLabel();
}
char const* MDTextArea::getString() {
return this->m_text.c_str();
return m_text.c_str();
}
MDTextArea* MDTextArea::create(std::string const& str, CCSize const& size) {

View file

@ -292,7 +292,7 @@ SentAsyncWebRequest::Impl::Impl(SentAsyncWebRequest* self, AsyncWebRequest const
Loader::get()->queueInGDThread([this, ret]() {
std::lock_guard _(m_mutex);
for (auto& then : m_thens) {
then(*this->m_self, ret);
then(*m_self, ret);
}
std::lock_guard __(RUNNING_REQUESTS_MUTEX);
RUNNING_REQUESTS.erase(m_id);
@ -319,7 +319,7 @@ void SentAsyncWebRequest::Impl::doCancel() {
Loader::get()->queueInGDThread([this]() {
std::lock_guard _(m_mutex);
for (auto& canc : m_cancelleds) {
canc(*this->m_self);
canc(*m_self);
}
});

View file

@ -1,2 +1,3 @@
add_subdirectory(main)
add_subdirectory(dependency)
add_subdirectory(members)

View file

@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.3.0)
set(PROJECT_NAME TestMembers)
project(${PROJECT_NAME} VERSION 1.0.0)
add_library(${PROJECT_NAME} SHARED MacOS.cpp Windows.cpp)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)
target_include_directories(${PROJECT_NAME} PRIVATE
${GEODE_CODEGEN_PATH}
${GEODE_LOADER_PATH}/include
${GEODE_LOADER_PATH}/include/Geode/cocos/include
${GEODE_LOADER_PATH}/include/Geode/cocos/extensions
${GEODE_LOADER_PATH}/include/Geode/fmod
)
target_compile_definitions(${PROJECT_NAME} PRIVATE -DGEODE_DONT_WARN_INCORRECT_MEMBERS)
target_link_libraries(${PROJECT_NAME} PRIVATE ghc_filesystem)
add_dependencies(${PROJECT_NAME} CodegenRun)

View file

@ -0,0 +1,24 @@
#pragma once
#include <Geode/Bindings.hpp>
template <auto... Values>
struct False {
static constexpr auto value = false;
};
template<int Difference, class Class, class Member, bool Predicate>
struct MemberIsOffsetBy {
static_assert(False<Difference>::value, "Member is offset by this value");
};
template<int Difference, class Class, class Member>
struct MemberIsOffsetBy<Difference, Class, Member, true> {
};
template <class Member, class Class, int Offset, int Expected>
struct SingleChecker {
using IsOffsetBy = MemberIsOffsetBy<Offset - Expected, Class, Member, Expected == Offset>;
};
#define GEODE_MEMBER_CHECK(Class_, Member_, Offset_) class Member_; SingleChecker<Member_, Class_, offsetof(Class_, Member_), Offset_>::IsOffsetBy GEODE_CONCAT(OffsetBy, __LINE__)

View file

@ -0,0 +1,56 @@
#include "Common.hpp"
#ifdef GEODE_IS_MACOS
// PlayerObject
GEODE_MEMBER_CHECK(PlayerObject, m_collisionLog, 0x518);
GEODE_MEMBER_CHECK(PlayerObject, m_particleSystems, 0x590);
GEODE_MEMBER_CHECK(PlayerObject, m_waveTrail, 0x600);
GEODE_MEMBER_CHECK(PlayerObject, m_lastCollidedSolid, 0x690);
GEODE_MEMBER_CHECK(PlayerObject, m_playerColor1, 0x7c2);
// EditorUI
GEODE_MEMBER_CHECK(EditorUI, m_buttonBar, 0x1a0);
GEODE_MEMBER_CHECK(EditorUI, m_selectedObject, 0x440);
// LevelEditorLayer
GEODE_MEMBER_CHECK(LevelEditorLayer, m_editorUI, 0x5d8);
GEODE_MEMBER_CHECK(LevelEditorLayer, m_level, 0x618);
// PlayLayer
GEODE_MEMBER_CHECK(PlayLayer, unknown518, 0x518);
GEODE_MEMBER_CHECK(PlayLayer, unknown5f4, 0x5f4);
GEODE_MEMBER_CHECK(PlayLayer, unknown680, 0x680);
GEODE_MEMBER_CHECK(PlayLayer, unknown6a8, 0x6a8);
GEODE_MEMBER_CHECK(PlayLayer, m_level, 0x728);
GEODE_MEMBER_CHECK(PlayLayer, m_shouldTryToKick, 0x7a8);
// GameManager
GEODE_MEMBER_CHECK(GameManager, m_playLayer, 0x180);
GEODE_MEMBER_CHECK(GameManager, m_levelEditorLayer, 0x188);
// GEODE_MEMBER_CHECK(GameManager, m_clickedGarage, 0x2a2); // todo: find why this is not 0x2a2
// GameObject
GEODE_MEMBER_CHECK(GameObject, m_baseColorID, 0x27c);
GEODE_MEMBER_CHECK(GameObject, m_detailColorID, 0x280);
GEODE_MEMBER_CHECK(GameObject, m_active, 0x2e5);
GEODE_MEMBER_CHECK(GameObject, m_baseSprite, 0x348);
GEODE_MEMBER_CHECK(GameObject, m_startPosition, 0x37c);
GEODE_MEMBER_CHECK(GameObject, m_baseColor, 0x410);
GEODE_MEMBER_CHECK(GameObject, m_groups, 0x458);
GEODE_MEMBER_CHECK(GameObject, m_effectManager, 0x4d8);
// EffectGameObject
GEODE_MEMBER_CHECK(EffectGameObject, m_duration, 0x4f0);
GEODE_MEMBER_CHECK(EffectGameObject, m_followMod, 0x530);
GEODE_MEMBER_CHECK(EffectGameObject, m_hsvValue, 0x560);
GEODE_MEMBER_CHECK(EffectGameObject, m_spawnDelay, 0x588);
GEODE_MEMBER_CHECK(EffectGameObject, m_itemBlockAID, 0x5b0);
// TeleportPortalObject
GEODE_MEMBER_CHECK(TeleportPortalObject, m_orangePortal, 0x4f8);
// StartPosObject
GEODE_MEMBER_CHECK(StartPosObject, m_levelSettings, 0x5e0);
#endif

View file

@ -0,0 +1,51 @@
#include "Common.hpp"
#ifdef GEODE_IS_WINDOWS
GEODE_MEMBER_CHECK(GameObject, m_effectPlistName, 0x278);
GEODE_MEMBER_CHECK(GameObject, m_effectManager, 0x454);
GEODE_MEMBER_CHECK(PlayerObject, m_unk484, 0x484);
GEODE_MEMBER_CHECK(PlayerObject, m_ghostTrail, 0x4E4);
GEODE_MEMBER_CHECK(PlayerObject, m_waveTrail, 0x514);
GEODE_MEMBER_CHECK(EditorUI, m_buttonBar, 0x134);
GEODE_MEMBER_CHECK(EditorUI, m_hideableUIElementArray, 0x13c);
GEODE_MEMBER_CHECK(EditorUI, m_gridSize, 0x140);
GEODE_MEMBER_CHECK(EditorUI, m_objectInfoLabel, 0x168);
GEODE_MEMBER_CHECK(EditorUI, m_scaleControl, 0x17c);
GEODE_MEMBER_CHECK(EditorUI, m_selectedObject, 0x2c4);
GEODE_MEMBER_CHECK(LevelEditorLayer, m_editorUI, 0x380);
GEODE_MEMBER_CHECK(LevelEditorLayer, m_level, 0x3a8);
GEODE_MEMBER_CHECK(GameManager, m_valueKeeper, 0x110);
GEODE_MEMBER_CHECK(GameManager, m_loaded, 0x148);
GEODE_MEMBER_CHECK(GameManager, m_playLayer, 0x164);
GEODE_MEMBER_CHECK(GameManager, m_levelEditorLayer, 0x168);
GEODE_MEMBER_CHECK(GameManager, m_playerUDID, 0x180);
GEODE_MEMBER_CHECK(GameManager, m_backgroundMusicVolume, 0x1c0);
GEODE_MEMBER_CHECK(GameManager, m_sceneEnum, 0x1dc);
GEODE_MEMBER_CHECK(GameManager, m_ratePower, 0x2d0);
GEODE_MEMBER_CHECK(PlayLayer, m_startPos, 0x32c);
GEODE_MEMBER_CHECK(PlayLayer, m_screenRingObjects, 0x36c);
GEODE_MEMBER_CHECK(PlayLayer, m_bottomGround, 0x38c);
GEODE_MEMBER_CHECK(PlayLayer, m_topGround, 0x390);
GEODE_MEMBER_CHECK(PlayLayer, m_isDead, 0x39c);
GEODE_MEMBER_CHECK(PlayLayer, m_levelLength, 0x3b4);
GEODE_MEMBER_CHECK(PlayLayer, m_attemptLabel, 0x3bc);
GEODE_MEMBER_CHECK(PlayLayer, m_sliderGrooveSprite, 0x404);
GEODE_MEMBER_CHECK(PlayLayer, m_gravitySprites, 0x424);
GEODE_MEMBER_CHECK(PlayLayer, m_level, 0x488);
GEODE_MEMBER_CHECK(PlayLayer, m_isTestMode, 0x494);
GEODE_MEMBER_CHECK(PlayLayer, m_antiCheatObject, 0x530);
GEODE_MEMBER_CHECK(PlayLayer, m_disableGravityEffect, 0x536);
GEODE_MEMBER_CHECK(GJBaseGameLayer, m_boundingBox, 0x120);
GEODE_MEMBER_CHECK(GJBaseGameLayer, m_player1, 0x224);
GEODE_MEMBER_CHECK(GJBaseGameLayer, m_groups, 0x274);
GEODE_MEMBER_CHECK(GJBaseGameLayer, m_attemptClickCount, 0x2b4);
static_assert(sizeof(GJBaseGameLayer) == 0x2cc);
#endif