This commit is contained in:
HJfod 2022-10-22 23:11:02 +03:00
parent b62de213a7
commit 6501fcc665
7 changed files with 39 additions and 5 deletions

View file

@ -859,7 +859,8 @@ public:
* Set the string ID of this node. String IDs are a Geode addition
* that are much safer to use to get nodes than absolute indexes
* @param id The ID of the node, recommended to be in kebab case
* without any spaces or uppercase letters
* without any spaces or uppercase letters. If the node is added
* by a mod, use the _spr literal to append the mod ID to it
*/
void setID(std::string const& id);

View file

@ -102,7 +102,7 @@ class $modify(CustomMenuLayer, MenuLayer) {
auto btn = CCMenuItemSpriteExtra::create(
g_geodeButton.data(), this, menu_selector(CustomMenuLayer::onGeode)
);
btn->setID("geode-button");
btn->setID("geode-button"_spr);
bottomMenu->addChild(btn);
bottomMenu->updateLayout();

View file

@ -30,7 +30,7 @@ static CCMenu* detachIntoOwnMenu(CCNode* parent, CCNode* node, const char* menuI
auto newMenu = CCMenu::create();
newMenu->setPosition(oldMenu->convertToWorldSpace(node->getPosition()));
newMenu->setID("top-right-menu");
newMenu->setID(menuID);
node->setPosition(0, 0);
newMenu->addChild(node);
newMenu->setLayout(layout);

View file

@ -22,7 +22,6 @@ $register_ids(CreatorLayer) {
setIDSafe(menu, 10,"gauntlets-button");
// move vault button to its own menu
if (auto lockBtn = setIDSafe(menu, -2, "vault-button")) {
detachIntoOwnMenu(this, lockBtn, "top-right-menu",
ColumnLayout::create(5.f, 0.f)->setAlignment(Alignment::Begin)
@ -30,7 +29,6 @@ $register_ids(CreatorLayer) {
}
// move treasure room button to its own menu
if (auto roomBtn = setIDSafe(menu, -1, "treasure-room-button")) {
detachIntoOwnMenu(this, roomBtn, "bottom-right-menu",
ColumnLayout::create(5.f, 0.f)->setAlignment(Alignment::End)
@ -43,3 +41,14 @@ $register_ids(CreatorLayer) {
setIDSafe(menu, 0, "back-button");
}
}
class $modify(CreatorLayer) {
bool init() {
if (!CreatorLayer::init())
return false;
NodeStringIDManager::get()->provide(this);
return true;
}
};

View file

@ -28,3 +28,14 @@ $register_ids(LevelBrowserLayer) {
}
}
}
class $modify(LevelBrowserLayer) {
bool init(GJSearchObject* obj) {
if (!LevelBrowserLayer::init(obj))
return false;
NodeStringIDManager::get()->provide(this);
return true;
}
};

View file

@ -65,3 +65,14 @@ $register_ids(LevelSearchLayer) {
}
}
class $modify(LevelSearchLayer) {
bool init() {
if (!LevelSearchLayer::init())
return false;
NodeStringIDManager::get()->provide(this);
return true;
}
};

View file

@ -84,3 +84,5 @@ $register_ids(MenuLayer) {
}
}
}
// MenuLayer::init is hooked in ../hooks/MenuLayer.cpp