fix start pos menu crash

This commit is contained in:
camila314 2022-12-14 12:35:26 -06:00
parent b3c88d349e
commit 47cce30351

View file

@ -6,71 +6,75 @@
USE_GEODE_NAMESPACE();
$register_ids(LevelSettingsLayer) {
bool startPos = m_mainLayer->getChildrenCount() < 10;
if (startPos) {
setIDSafe(m_mainLayer, 0, "back-button");
}
if (auto menu = getChildOfType<CCMenu>(m_mainLayer, 0)) {
menu->setID("song-select-menu");
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,
"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")
);
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,
@ -85,14 +89,6 @@ $register_ids(LevelSettingsLayer) {
menu->getChildByID("spider-button")
);
detachAndCreateMenu(
this,
"scenery-selection-menu",
ColumnLayout::create(),
menu->getChildByID("background-select-button"),
menu->getChildByID("ground-select-button")
);
detachAndCreateMenu(
this,
"right-toggle-menu",
@ -101,21 +97,6 @@ $register_ids(LevelSettingsLayer) {
menu->getChildByID("dual-toggle")
);
detachAndCreateMenu(
this,
"font-button-menu",
RowLayout::create()->setAlignment(Alignment::End),
menu->getChildByID("font-button")
);
detachAndCreateMenu(
this,
"2-player-menu",
ColumnLayout::create(),
menu->getChildByID("2-player-help-button"),
menu->getChildByID("2-player-toggle")
);
detachAndCreateMenu(
this,
"speed-selection-menu",
@ -126,6 +107,61 @@ $register_ids(LevelSettingsLayer) {
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")
);
detachAndCreateMenu(
this,
"font-button-menu",
RowLayout::create()->setAlignment(Alignment::End),
menu->getChildByID("font-button")
);
}
}
setIDs(m_mainLayer, 2,
@ -156,7 +192,7 @@ class $modify(LevelSettingsLayer) {
if (!LevelSettingsLayer::init(levelSettings, editor))
return false;
NodeIDs::get()->provide(this);
//NodeIDs::get()->provide(this);
return true;
}