From 3000644adb68568724aabe3cc5139bbd0b8d41c6 Mon Sep 17 00:00:00 2001 From: flaks45 Date: Mon, 15 Jun 2026 18:49:52 +0200 Subject: [PATCH 1/2] Added IDs to LevelSettingsLayer --- src/LevelSettingsLayer.cpp | 340 ++++++++++++++----------------------- 1 file changed, 126 insertions(+), 214 deletions(-) diff --git a/src/LevelSettingsLayer.cpp b/src/LevelSettingsLayer.cpp index 481b710..39acd60 100644 --- a/src/LevelSettingsLayer.cpp +++ b/src/LevelSettingsLayer.cpp @@ -1,216 +1,128 @@ -// #include "AddIDs.hpp" - -#include -// #include -#include +#include +#include +#include using namespace geode::prelude; - -// $register_ids(LevelSettingsLayer) { -// bool startPos = m_mainLayer->getChildrenCount() < 10; - -// if (startPos) { -// setIDSafe(m_mainLayer, 0, "back-button"); -// } - -// if (auto menu = m_mainLayer->getChildByType(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" -// ); -// } - -// 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, -// "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") -// ); - -// 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, -// "2-player-menu", -// ColumnLayout::create(), -// menu->getChildByID("2-player-help-button"), -// menu->getChildByID("2-player-toggle") -// ); - -// auto fontButtonMenu = detachAndCreateMenu( -// this, -// "font-button-menu", -// RowLayout::create() -// ->setAxisAlignment(AxisAlignment::End), -// menu->getChildByID("font-button") -// ); -// fontButtonMenu->setPositionY(fontButtonMenu->getPositionY() - 100.f / 2); -// fontButtonMenu->setContentSize({ 50.f, 100.f }); -// } -// } - -// 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" -// ); -// } - -// struct LevelSettingsLayerIDs : Modify { -// static void onModify(auto& self) { -// if (!self.setHookPriority("LevelSettingsLayer::init", GEODE_ID_PRIORITY)) { -// log::warn("Failed to set LevelSettingsLayer::init hook priority, node IDs may not work properly"); -// } -// } - -// bool init(LevelSettingsObject* levelSettings, LevelEditorLayer* editor) { -// if (!LevelSettingsLayer::init(levelSettings, editor)) return false; - -// // NodeIDs::get()->provide(this); - -// return true; -// } -// }; +using namespace geode::node_ids; + +$register_ids(LevelSettingsLayer) { + /* + This layer is used in two places: + 1. Start Pos menu, which has fewer buttons and labels because you can't set colors or music. + 2. Level settings from the Editor UI button, which has song selection too. + */ + bool isStartPos = m_mainLayer->getChildrenCount() < 15; // Startpos has 13, level settings normally has 22 + + if (isStartPos) { + m_mainLayer->getChildByType(0)->setID("background"); + m_mainLayer->getChildByType(1)->setID("order-background"); + m_mainLayer->getChildByType(2)->setID("channel-background"); + + m_mainLayer->getChildByType(0)->setID("disable-label"); + m_mainLayer->getChildByType(1)->setID("reset-camera-label"); + m_mainLayer->getChildByType(2)->setID("target-order-label"); + m_mainLayer->getChildByType(3)->setID("target-channel-label"); + m_mainLayer->getChildByType(4)->setID("speed-label"); + m_mainLayer->getChildByType(5)->setID("mode-label"); + m_mainLayer->getChildByType(6)->setID("options-label"); + + m_mainLayer->getChildByType(0)->setID("order-input"); + m_mainLayer->getChildByType(1)->setID("channel-input"); + + if (auto menu = m_mainLayer->getChildByType(0)) { + menu->setID("menu"); + + menu->getChildByType(0)->setID("back-button"); + menu->getChildByType(1)->setID("speed-button"); + menu->getChildByType(2)->setID("mode-button"); + menu->getChildByType(3)->setID("options-button"); + + menu->getChildByType(0)->setID("disable-toggle"); + menu->getChildByType(1)->setID("reset-camera-toggle"); + } + } + else { + m_mainLayer->getChildByType(0)->setID("background"); + m_mainLayer->getChildByType(1)->setID("song-background"); + + m_mainLayer->getChildByType(0)->setID("select-color-label"); + m_mainLayer->getChildByType(1)->setID("bg-color-label"); + m_mainLayer->getChildByType(2)->setID("g-color-label"); + m_mainLayer->getChildByType(3)->setID("g2-color-label"); + m_mainLayer->getChildByType(4)->setID("line-color-label"); + m_mainLayer->getChildByType(5)->setID("mg-color-label"); + m_mainLayer->getChildByType(6)->setID("mg2-color-label"); + m_mainLayer->getChildByType(7)->setID("more-color-label"); + m_mainLayer->getChildByType(8)->setID("game-type-label"); // Be careful! This one is called here despite future ordering + m_mainLayer->getChildByType(9)->setID("bg-label"); + m_mainLayer->getChildByType(10)->setID("g-label"); + m_mainLayer->getChildByType(11)->setID("mg-label"); + m_mainLayer->getChildByType(12)->setID("select-song-label"); + m_mainLayer->getChildByType(13)->setID("song-label"); + m_mainLayer->getChildByType(14)->setID("speed-label"); + m_mainLayer->getChildByType(15)->setID("mode-label"); + m_mainLayer->getChildByType(16)->setID("options-label"); + + if (auto menu = m_mainLayer->getChildByType(0)) { + menu->setID("menu"); + + menu->getChildByType(0)->setID("bg-color-button"); + menu->getChildByType(1)->setID("g-color-button"); + menu->getChildByType(2)->setID("g2-color-button"); + menu->getChildByType(3)->setID("line-color-button"); + menu->getChildByType(4)->setID("mg-color-button"); + menu->getChildByType(5)->setID("mg2-color-button"); + menu->getChildByType(6)->setID("more-color-button"); + + menu->getChildByType(7)->setID("bg-color-select-button"); + menu->getChildByType(8)->setID("g-color-select-button"); + menu->getChildByType(9)->setID("g2-color-select-button"); + menu->getChildByType(10)->setID("line-color-select-button"); + menu->getChildByType(11)->setID("mg-color-select-button"); + menu->getChildByType(12)->setID("mg2-color-select-button"); + + menu->getChildByType(13)->setID("classic-button"); + menu->getChildByType(14)->setID("platformer-button"); + + menu->getChildByType(15)->setID("bg-button"); + menu->getChildByType(16)->setID("g-button"); + menu->getChildByType(17)->setID("mg-button"); + menu->getChildByType(18)->setID("font-button"); + + menu->getChildByType(19)->setID("back-button"); + + menu->getChildByType(20)->setID("previous-song-button"); + menu->getChildByType(21)->setID("next-song-button"); + menu->getChildByType(22)->setID("normal-song-button"); + menu->getChildByType(23)->setID("custom-song-button"); + menu->getChildByType(24)->setID("select-custom-song-button"); + menu->getChildByType(25)->setID("new-song-button"); + + menu->getChildByType(26)->setID("speed-button"); + menu->getChildByType(27)->setID("mode-button"); + menu->getChildByType(28)->setID("options-button"); + } + + /* + Unset because they are unique: + - CustomSongWidget + - SongSelectNode + */ + } +} + +struct LevelSettingsLayerIDs : Modify { + static void onModify(auto& self) { + if (!self.setHookPriority("LevelSettingsLayer::init", GEODE_ID_PRIORITY)) { + log::warn("Failed to set LevelSettingsLayer::init hook priority, node IDs may not work properly"); + } + } + + bool init(LevelSettingsObject* levelSettings, LevelEditorLayer* editor) { + if (!LevelSettingsLayer::init(levelSettings, editor)) return false; + + NodeIDs::get()->provide(this); + + return true; + } +}; From 9163f8692ced551aab282e91efd7547eec76a846 Mon Sep 17 00:00:00 2001 From: flaks45 Date: Wed, 17 Jun 2026 18:35:59 +0200 Subject: [PATCH 2/2] Made IDs more consistent with the 2.1 version and other IDs from the mod, common element separated as well --- src/LevelSettingsLayer.cpp | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/LevelSettingsLayer.cpp b/src/LevelSettingsLayer.cpp index 39acd60..d9a8eea 100644 --- a/src/LevelSettingsLayer.cpp +++ b/src/LevelSettingsLayer.cpp @@ -11,10 +11,11 @@ using namespace geode::node_ids; 1. Start Pos menu, which has fewer buttons and labels because you can't set colors or music. 2. Level settings from the Editor UI button, which has song selection too. */ - bool isStartPos = m_mainLayer->getChildrenCount() < 15; // Startpos has 13, level settings normally has 22 + // Common elements with the same indexes + m_mainLayer->getChildByType(0)->setID("background"); + bool isStartPos = m_mainLayer->getChildrenCount() < 15; // Startpos has 13, level settings has 22 by default if (isStartPos) { - m_mainLayer->getChildByType(0)->setID("background"); m_mainLayer->getChildByType(1)->setID("order-background"); m_mainLayer->getChildByType(2)->setID("channel-background"); @@ -22,6 +23,7 @@ using namespace geode::node_ids; m_mainLayer->getChildByType(1)->setID("reset-camera-label"); m_mainLayer->getChildByType(2)->setID("target-order-label"); m_mainLayer->getChildByType(3)->setID("target-channel-label"); + m_mainLayer->getChildByType(4)->setID("speed-label"); m_mainLayer->getChildByType(5)->setID("mode-label"); m_mainLayer->getChildByType(6)->setID("options-label"); @@ -30,9 +32,10 @@ using namespace geode::node_ids; m_mainLayer->getChildByType(1)->setID("channel-input"); if (auto menu = m_mainLayer->getChildByType(0)) { - menu->setID("menu"); + menu->setID("main-menu"); + + menu->getChildByType(0)->setID("ok-button"); - menu->getChildByType(0)->setID("back-button"); menu->getChildByType(1)->setID("speed-button"); menu->getChildByType(2)->setID("mode-button"); menu->getChildByType(3)->setID("options-button"); @@ -42,7 +45,6 @@ using namespace geode::node_ids; } } else { - m_mainLayer->getChildByType(0)->setID("background"); m_mainLayer->getChildByType(1)->setID("song-background"); m_mainLayer->getChildByType(0)->setID("select-color-label"); @@ -53,18 +55,22 @@ using namespace geode::node_ids; m_mainLayer->getChildByType(5)->setID("mg-color-label"); m_mainLayer->getChildByType(6)->setID("mg2-color-label"); m_mainLayer->getChildByType(7)->setID("more-color-label"); - m_mainLayer->getChildByType(8)->setID("game-type-label"); // Be careful! This one is called here despite future ordering + + m_mainLayer->getChildByType(8)->setID("game-type-label"); // Only one that doesn't follow the order after z ordering + m_mainLayer->getChildByType(9)->setID("bg-label"); m_mainLayer->getChildByType(10)->setID("g-label"); m_mainLayer->getChildByType(11)->setID("mg-label"); + m_mainLayer->getChildByType(12)->setID("select-song-label"); m_mainLayer->getChildByType(13)->setID("song-label"); + m_mainLayer->getChildByType(14)->setID("speed-label"); m_mainLayer->getChildByType(15)->setID("mode-label"); m_mainLayer->getChildByType(16)->setID("options-label"); if (auto menu = m_mainLayer->getChildByType(0)) { - menu->setID("menu"); + menu->setID("main-menu"); menu->getChildByType(0)->setID("bg-color-button"); menu->getChildByType(1)->setID("g-color-button"); @@ -74,12 +80,12 @@ using namespace geode::node_ids; menu->getChildByType(5)->setID("mg2-color-button"); menu->getChildByType(6)->setID("more-color-button"); - menu->getChildByType(7)->setID("bg-color-select-button"); - menu->getChildByType(8)->setID("g-color-select-button"); - menu->getChildByType(9)->setID("g2-color-select-button"); - menu->getChildByType(10)->setID("line-color-select-button"); - menu->getChildByType(11)->setID("mg-color-select-button"); - menu->getChildByType(12)->setID("mg2-color-select-button"); + menu->getChildByType(7)->setID("bg-color-quick-edit-button"); + menu->getChildByType(8)->setID("g-color-quick-edit-button"); + menu->getChildByType(9)->setID("g2-color-quick-edit-button"); + menu->getChildByType(10)->setID("line-color-quick-edit-button"); + menu->getChildByType(11)->setID("mg-color-quick-edit-button"); + menu->getChildByType(12)->setID("mg2-color-quick-edit-button"); menu->getChildByType(13)->setID("classic-button"); menu->getChildByType(14)->setID("platformer-button"); @@ -89,9 +95,9 @@ using namespace geode::node_ids; menu->getChildByType(17)->setID("mg-button"); menu->getChildByType(18)->setID("font-button"); - menu->getChildByType(19)->setID("back-button"); + menu->getChildByType(19)->setID("ok-button"); - menu->getChildByType(20)->setID("previous-song-button"); + menu->getChildByType(20)->setID("prev-song-button"); menu->getChildByType(21)->setID("next-song-button"); menu->getChildByType(22)->setID("normal-song-button"); menu->getChildByType(23)->setID("custom-song-button");