-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Cvolton/sapphire-ids
7 new layers
- Loading branch information
Showing
15 changed files
with
1,140 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
# Node IDs | ||
|
||
Adds node IDs to layers for other mods to base their UI on, for preserving mod compatibility. See the [Github repository](https://github.com/geode-sdk/NodeIDs) for contributing. | ||
Adds node ids to layers for other mods to base their UI on, for preserving mod compatibility. See the [Github repository](https://github.com/geode-sdk/NodeIDs) for contributing. | ||
|
||
Has ids for: | ||
|
||
- CommentCell | ||
- CreatorLayer | ||
- DailyLevelNode | ||
- DailyLevelPage | ||
- EditLevelLayer | ||
- InfoLayer | ||
- LeaderboardsLayer | ||
- LevelBrowserLayer | ||
- LevelCell | ||
- LevelInfoLayer | ||
- LevelLeaderboard | ||
- LevelSearchLayer | ||
- ProfilePage | ||
- RewardsPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// #include "AddIDs.hpp" | ||
|
||
#include <Geode/modify/GJScoreCell.hpp> | ||
#include <Geode/utils/NodeIDs.hpp> | ||
|
||
using namespace geode::prelude; | ||
using namespace geode::node_ids; | ||
|
||
$register_ids(GJScoreCell) { | ||
setIDs( | ||
m_mainLayer, | ||
0, | ||
"player-icon", | ||
"main-menu" | ||
); | ||
|
||
if(m_score->m_scoreType != 2) { | ||
setIDs( | ||
m_mainLayer, | ||
2, | ||
"rank-label" | ||
); | ||
} | ||
|
||
setIDs( | ||
m_mainLayer, | ||
m_score->m_scoreType == 2 ? 2 : 3, | ||
"stars-label", | ||
"stars-icon", | ||
"moons-label", | ||
"moons-icon", | ||
"diamonds-label", | ||
"diamonds-icon", | ||
"coins-label", | ||
"coins-icon", | ||
"user-coins-label", | ||
"user-coins-icon", | ||
"demons-label", | ||
"demons-icon", | ||
"creator-points-label", | ||
"creator-points-icon" | ||
); | ||
|
||
if(auto menu = m_mainLayer->getChildByID("main-menu")) { | ||
if(menu->getChildrenCount() > 0) { | ||
static_cast<CCNode*>(menu->getChildren()->objectAtIndex(0))->setID("player-name"); | ||
} | ||
} | ||
} | ||
|
||
struct GJScoreCellIDs : Modify<GJScoreCellIDs, GJScoreCell> { | ||
static void onModify(auto& self) { | ||
if (!self.setHookPriority("GJScoreCell::loadFromScore", GEODE_ID_PRIORITY)) { | ||
log::warn("Failed to set GJScoreCell::loadFromScore hook priority, node IDs may not work properly"); | ||
} | ||
} | ||
|
||
void loadFromScore(GJUserScore* score) { | ||
GJScoreCell::loadFromScore(score); | ||
|
||
NodeIDs::get()->provide(this); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#define verifyIDSafe(Member_, ID_) \ | ||
if(Member_ && Member_->getID() != ID_) { \ | ||
log::warn("{} has an invalid ID - {} (expected {})", #Member_, Member_->getID(), ID_); \ | ||
} | ||
|
||
#define verifyParentIDSafe(Member_, ID_) \ | ||
if(Member_ && Member_->getParent() && Member_->getParent()->getID() != ID_) { \ | ||
log::warn("{}'s parent has an invalid ID - {} (expected {})", #Member_, m_rightArrow->getParent()->getID(), ID_); \ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
#include <Geode/Bindings.hpp> | ||
#include <Geode/modify/InfoLayer.hpp> | ||
#include <Geode/utils/cocos.hpp> | ||
#include <Geode/ui/BasedButtonSprite.hpp> | ||
#include <Geode/utils/NodeIDs.hpp> | ||
|
||
#include "IDCheck.hpp" | ||
|
||
using namespace geode::prelude; | ||
using namespace geode::node_ids; | ||
|
||
$register_ids(InfoLayer) { | ||
bool descNotVisible = GameManager::sharedState()->getGameVariable("0089") || m_score; | ||
|
||
size_t buttonOffset = 0; | ||
size_t labelOffset = 0; | ||
size_t menuOffset = 0; | ||
|
||
auto winSize = CCDirector::get()->getWinSize(); | ||
|
||
getChildOfType<CCScale9Sprite>(m_mainLayer, 0)->setID("background"); | ||
|
||
//this label is created at a different points in init for m_score and !m_score but the index happens to match, since they're right after each other | ||
getChildOfType<CCLabelBMFont>(m_mainLayer, 0)->setID("title-label"); | ||
labelOffset++; | ||
|
||
getChildOfType<CCMenu>(m_mainLayer, 0)->setID("main-menu"); | ||
menuOffset++; | ||
|
||
if(!m_score) { | ||
getChildOfType<CCMenuItemSpriteExtra>(m_buttonMenu, buttonOffset)->setID("creator-button"); | ||
buttonOffset++; | ||
|
||
if(!descNotVisible) { | ||
getChildOfType<CCScale9Sprite>(m_mainLayer, 1)->setID("desc-background"); | ||
getChildOfType<TextArea>(m_mainLayer, 0)->setID("description-area"); | ||
} | ||
|
||
//InfoLayer::setupLevelInfo stuff | ||
if(m_level || m_levelList) { | ||
getChildOfType<CCMenu>(m_mainLayer, menuOffset)->setID("id-menu"); | ||
menuOffset++; | ||
|
||
getChildOfType<CCLabelBMFont>(m_mainLayer, labelOffset)->setID("version-label"); | ||
labelOffset++; | ||
} | ||
//end of InfoLayer::setupLevelInfo stuff | ||
|
||
if(m_level && m_level->m_originalLevel != 0 && m_level->m_originalLevel != m_level->m_levelID && !GameManager::sharedState()->getGameVariable("0077")) { | ||
getChildOfType<CCMenuItemSpriteExtra>(m_buttonMenu, buttonOffset)->setID("original-level-button"); | ||
buttonOffset++; | ||
} | ||
|
||
getChildOfType<CCMenuItemSpriteExtra>(m_buttonMenu, buttonOffset)->setID("comment-button"); | ||
buttonOffset++; | ||
|
||
getChildOfType<CCMenuItemSpriteExtra>(m_buttonMenu, buttonOffset)->setID("report-button"); | ||
buttonOffset++; | ||
|
||
} | ||
|
||
getChildOfType<CCMenuItemSpriteExtra>(m_buttonMenu, buttonOffset)->setID("close-button"); | ||
buttonOffset++; | ||
|
||
getChildOfType<LoadingCircle>(m_mainLayer, 0)->setID("loading-circle"); | ||
|
||
|
||
if(auto menu = getChildOfType<CCMenu>(m_mainLayer, menuOffset)){ | ||
menu->setID("switch-page-menu"); | ||
menuOffset++; | ||
|
||
getChildOfType<CCMenuItemSpriteExtra>(menu, 0)->setID("prev-page-button"); | ||
getChildOfType<CCMenuItemSpriteExtra>(menu, 1)->setID("next-page-button"); | ||
} | ||
|
||
getChildOfType<CCLabelBMFont>(m_mainLayer, labelOffset)->setID("comment-count-label"); | ||
labelOffset++; | ||
|
||
if(auto menu = getChildOfType<CCMenu>(m_mainLayer, menuOffset)){ | ||
menu->setID("left-side-menu"); | ||
menuOffset++; | ||
|
||
getChildOfType<CCMenuItemSpriteExtra>(menu, 0)->setID("sort-likes-button"); | ||
getChildOfType<CCMenuItemSpriteExtra>(menu, 1)->setID("sort-recent-button"); | ||
getChildOfType<CCMenuItemSpriteExtra>(menu, 2)->setID("small-mode-button"); | ||
if(!m_score) { | ||
getChildOfType<CCMenuItemSpriteExtra>(menu, 3)->setID("extend-button"); | ||
} | ||
|
||
menu->setContentSize({10, 140}); | ||
menu->setLayout( | ||
ColumnLayout::create() | ||
->setGap(6.f) | ||
->setAxisAlignment(AxisAlignment::Center) | ||
->setAxisReverse(true) | ||
); | ||
|
||
//the default autoscale options make the buttons too big | ||
for(auto& child : CCArrayExt<CCNode*>(menu->getChildren())) { | ||
child->setLayoutOptions( | ||
AxisLayoutOptions::create() | ||
->setMinScale(.1f) | ||
->setMaxScale(.7f) | ||
); | ||
} | ||
|
||
} | ||
|
||
//now it calls InfoLayer::updateCommentModeButtons but that doesn't do anything important | ||
|
||
getChildOfType<CCMenuItemSpriteExtra>(m_buttonMenu, buttonOffset)->setID("load-comments-button"); | ||
buttonOffset++; | ||
|
||
getChildOfType<CCLabelBMFont>(m_mainLayer, labelOffset)->setID("no-comments"); | ||
labelOffset++; | ||
|
||
if(!m_score) { | ||
getChildOfType<CCMenuItemSpriteExtra>(m_buttonMenu, buttonOffset)->setID("info-button"); | ||
buttonOffset++; | ||
} | ||
|
||
getChildOfType<CCMenuItemSpriteExtra>(m_buttonMenu, buttonOffset)->setID("refresh-button"); | ||
buttonOffset++; | ||
|
||
auto refreshMenu = detachAndCreateMenu( | ||
m_mainLayer, "refresh-menu", | ||
ColumnLayout::create()->setAxisAlignment(AxisAlignment::Start), | ||
m_buttonMenu->getChildByID("refresh-button") | ||
); | ||
refreshMenu->setContentSize({refreshMenu->getContentSize().width, 100.f}); | ||
refreshMenu->setPositionY(refreshMenu->getPositionY() + 35); | ||
|
||
/** | ||
* Sanity checks | ||
*/ | ||
verifyIDSafe(m_loadingCircle, "loading-circle"); | ||
verifyIDSafe(m_pageLabel, "comment-count-label"); | ||
verifyIDSafe(m_noComments, "no-comments"); | ||
verifyIDSafe(m_rightArrow, "next-page-button"); | ||
verifyIDSafe(m_leftArrow, "prev-page-button"); | ||
verifyIDSafe(m_likeBtn, "sort-likes-button"); | ||
verifyIDSafe(m_timeBtn, "sort-recent-button"); | ||
//verifyIDSafe(m_reportBtn, "report-button"); //not necessarily nullptr | ||
verifyIDSafe(m_commentsBtn, "load-comments-button"); | ||
verifyIDSafe(m_refreshCommentsBtn, "refresh-button"); | ||
|
||
verifyParentIDSafe(m_rightArrow, "switch-page-menu"); | ||
verifyParentIDSafe(m_leftArrow, "switch-page-menu"); | ||
verifyParentIDSafe(m_likeBtn, "left-side-menu"); | ||
verifyParentIDSafe(m_timeBtn, "left-side-menu"); | ||
//verifyParentIDSafe(m_reportBtn, "main-menu"); | ||
verifyParentIDSafe(m_commentsBtn, "main-menu"); | ||
verifyParentIDSafe(m_refreshCommentsBtn, "refresh-menu"); | ||
} | ||
|
||
struct InfoLayerIDs : Modify<InfoLayerIDs, InfoLayer> { | ||
static void onModify(auto& self) { | ||
if (!self.setHookPriority("InfoLayer::init", GEODE_ID_PRIORITY)) { | ||
log::warn("Failed to set InfoLayer::init hook priority, node IDs may not work properly"); | ||
} | ||
} | ||
|
||
bool init(GJGameLevel* level, GJUserScore* score, GJLevelList* list) { | ||
if (!InfoLayer::init(level, score, list)) return false; | ||
|
||
NodeIDs::get()->provide(this); | ||
|
||
return true; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include <Geode/Bindings.hpp> | ||
#include <Geode/modify/LeaderboardsLayer.hpp> | ||
#include <Geode/utils/cocos.hpp> | ||
#include <Geode/utils/NodeIDs.hpp> | ||
|
||
using namespace geode::prelude; | ||
using namespace geode::node_ids; | ||
|
||
$register_ids(LeaderboardsLayer) { | ||
setIDs( | ||
this, | ||
0, | ||
"background", | ||
"bottom-left-art", | ||
"bottom-right-art", | ||
"loading-circle", | ||
"no-internet-label", | ||
"info-menu", | ||
"top-100-menu", | ||
"friends-menu", | ||
"global-menu", | ||
"creators-menu", | ||
"list-layer", | ||
"back-menu" | ||
); | ||
|
||
auto winSize = CCDirector::get()->getWinSize(); | ||
|
||
auto bottomRightMenu = CCMenu::create(); | ||
bottomRightMenu->setID("bottom-right-menu"); | ||
bottomRightMenu->setContentSize({ 26.75f*2, winSize.height - 10.f }); | ||
bottomRightMenu->setPosition(winSize.width - 26.75f, winSize.height / 2); | ||
bottomRightMenu->setZOrder(2); | ||
bottomRightMenu->setLayout( | ||
ColumnLayout::create() | ||
->setGap(7.f) | ||
->setAxisAlignment(AxisAlignment::Start) | ||
->setAxisReverse(true) | ||
); | ||
this->addChild(bottomRightMenu); | ||
|
||
if(auto infoMenu = getChildByID("info-menu")) { | ||
setIDSafe(infoMenu, 0, "info-button"); | ||
|
||
infoMenu->setContentSize({ 26.75f*2, winSize.height - 37.f }); | ||
infoMenu->setPositionY(winSize.height / 2); | ||
infoMenu->setLayout( | ||
ColumnLayout::create() | ||
->setGap(7.f) | ||
->setAxisAlignment(AxisAlignment::Start) | ||
->setAxisReverse(true) | ||
); | ||
} | ||
} | ||
|
||
struct LeaderboardsLayerIDs : Modify<LeaderboardsLayerIDs, LeaderboardsLayer> { | ||
static void onModify(auto& self) { | ||
if (!self.setHookPriority("LeaderboardsLayer::init", GEODE_ID_PRIORITY)) { | ||
log::warn("Failed to set LeaderboardsLayer::init hook priority, node IDs may not work properly"); | ||
} | ||
} | ||
|
||
bool init(LeaderboardState state) { | ||
if (!LeaderboardsLayer::init(state)) return false; | ||
|
||
NodeIDs::get()->provide(this); | ||
|
||
return true; | ||
} | ||
}; |
Oops, something went wrong.