Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
211 changes: 108 additions & 103 deletions src/EditorPauseLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ class GuidelinesButtonDummy {
}
};

CCMenu* createToggleContainer(EditorPauseLayer* self, CCMenu* menu, CCNode* addTo, ZStringView ID) {
return detachAndCreateMenu(
addTo,
fmt::format("{}-container", ID).c_str(),
SimpleRowLayout::create()
->setGap(5.f)
->setMainAxisScaling(AxisScaling::Fit)
->setCrossAxisScaling(AxisScaling::Fit),
menu->getChildByID(fmt::format("{}-toggle", ID)),
self->getChildByID(fmt::format("{}-label", ID))
);
}

$register_ids(EditorPauseLayer) {
auto winSize = CCDirector::get()->getWinSize();

Expand All @@ -39,9 +52,10 @@ class GuidelinesButtonDummy {

menu->setContentSize({ 100.f, 220.f });
menu->setLayout(
ColumnLayout::create()
SimpleColumnLayout::create()
->setGap(12.5f)
->setAxisReverse(true)
->setCrossAxisScaling(AxisScaling::Fit)
->setMainAxisDirection(AxisDirection::TopToBottom)
);
}

Expand Down Expand Up @@ -114,9 +128,12 @@ class GuidelinesButtonDummy {
auto smallActionsMenu = detachAndCreateMenu(
this,
"small-actions-menu",
ColumnLayout::create()
->setAxisAlignment(AxisAlignment::Start)
->setAxisReverse(true),
SimpleColumnLayout::create()
->setGap(5.f)
->setMainAxisScaling(AxisScaling::ScaleDownGaps)
->setCrossAxisScaling(AxisScaling::Fit)
->setMainAxisAlignment(MainAxisAlignment::End)
->setMainAxisDirection(AxisDirection::TopToBottom),
menu->getChildByID("regroup-button"),
menu->getChildByID("create-loop-button"),
menu->getChildByID("align-x-button"),
Expand All @@ -128,15 +145,19 @@ class GuidelinesButtonDummy {
menu->getChildByID("new-groupy-button")
);
smallActionsMenu->setContentSize({ 100.f, 290.f });
smallActionsMenu->setPositionY(155.f);
smallActionsMenu->setAnchorPoint({0.5f, 0.f});
smallActionsMenu->setPositionY(10.f);
smallActionsMenu->updateLayout();

auto actionsMenu = detachAndCreateMenu(
this,
"actions-menu",
ColumnLayout::create()
->setAxisAlignment(AxisAlignment::Start)
->setAxisReverse(true),
SimpleColumnLayout::create()
->setGap(5.f)
->setMainAxisScaling(AxisScaling::ScaleDownGaps)
->setCrossAxisScaling(AxisScaling::Fit)
->setMainAxisAlignment(MainAxisAlignment::End)
->setMainAxisDirection(AxisDirection::TopToBottom),
#ifdef GEODE_IS_DESKTOP
menu->getChildByID("keys-button"),
#endif
Expand All @@ -148,94 +169,78 @@ class GuidelinesButtonDummy {
menu->getChildByID("reset-unused-button"),
menu->getChildByID("uncheck-portals-button")
);
actionsMenu->setContentSize({ 100.f, 290.f });
actionsMenu->setPositionY(155.f);
actionsMenu->setContentSize({ 100.f, 230.f });
actionsMenu->setAnchorPoint({0.5f, 0.f});
actionsMenu->setPositionY(10.f);
actionsMenu->updateLayout();

for(CCNode* node : CCArrayExt<CCNode*>(menu->getChildren())) {
if(CCMenuItemToggler* toggler = typeinfo_cast<CCMenuItemToggler*>(node)) {
for (auto node : menu->getChildrenExt()) {
auto toggler = typeinfo_cast<CCMenuItemToggler*>(node);
if (!toggler) continue;

auto off = toggler->m_offButton;
auto on = toggler->m_onButton;
float maxWidth = std::max(toggler->m_offButton->getContentWidth(), toggler->m_onButton->getContentWidth());
float maxHeight = std::max(toggler->m_offButton->getContentHeight(), toggler->m_onButton->getContentHeight());

float maxWidth = (std::max)(off->getContentSize().width, on->getContentSize().width);
float maxHeight = (std::max)(off->getContentSize().height, on->getContentSize().height);
auto maxSize = CCSize{maxWidth, maxHeight};
auto halfSize = maxSize / 2;

toggler->setContentSize({maxWidth, maxHeight});
off->setContentSize({maxWidth, maxHeight});
on->setContentSize({maxWidth, maxHeight});
toggler->setContentSize(maxSize);
toggler->m_offButton->setContentSize(maxSize);
toggler->m_onButton->setContentSize(maxSize);

off->setPosition({maxWidth/2, maxHeight/2});
on->setPosition({maxWidth/2, maxHeight/2});
auto offSpr = toggler->m_offButton->getNormalImage();
auto onSpr = toggler->m_onButton->getNormalImage();

CCSprite* offSpr = off->getChildByType<CCSprite>(0);
CCSprite* onSpr = off->getChildByType<CCSprite>(0);
toggler->m_offButton->setPosition(halfSize);
toggler->m_onButton->setPosition(halfSize);

off->setPosition({maxWidth/2, maxHeight/2});
on->setPosition({maxWidth/2, maxHeight/2});

offSpr->setPosition({maxWidth/2, maxHeight/2});
onSpr->setPosition({maxWidth/2, maxHeight/2});
}
offSpr->setPosition(halfSize);
onSpr->setPosition(halfSize);
}

auto optionsMenu = detachAndCreateMenu(
this,
"options-menu",
RowLayout::create()
->setGap(5.f)
->setAxisAlignment(AxisAlignment::Start)
->setGrowCrossAxis(true)
->setCrossAxisAlignment(AxisAlignment::Start)
->setCrossAxisOverflow(false),
menu->getChildByID("show-hitboxes-toggle"),
this->getChildByID("show-hitboxes-label"),
menu->getChildByID("hide-invisible-toggle"),
this->getChildByID("hide-invisible-label"),
menu->getChildByID("preview-mode-toggle"),
this->getChildByID("preview-mode-label"),
menu->getChildByID("preview-animations-toggle"),
this->getChildByID("preview-animations-label"),
menu->getChildByID("preview-particles-toggle"),
this->getChildByID("preview-particles-label"),
menu->getChildByID("preview-shaders-toggle"),
this->getChildByID("preview-shaders-label"),
menu->getChildByID("show-ground-toggle"),
this->getChildByID("show-ground-label"),
menu->getChildByID("show-object-info-toggle"),
this->getChildByID("show-object-info-label"),
menu->getChildByID("show-grid-toggle"),
this->getChildByID("show-grid-label"),
menu->getChildByID("select-filter-toggle"),
this->getChildByID("select-filter-label"),
menu->getChildByID("ignore-damage-toggle"),
this->getChildByID("ignore-damage-label")
// kept as a CCMenu in case anyone relies on that
auto optionsMenu = CCMenu::create();
optionsMenu->setID("options-menu");
optionsMenu->setLayout(SimpleColumnLayout::create()
->setGap(5.f)
->setMainAxisDirection(AxisDirection::TopToBottom)
->setCrossAxisAlignment(CrossAxisAlignment::Start)
->setMainAxisScaling(AxisScaling::ScaleDownGaps)
->setCrossAxisScaling(AxisScaling::Fit)
);
for (auto node : CCArrayExt<CCNode*>(optionsMenu->getChildren())) {
if (auto label = typeinfo_cast<CCLabelBMFont*>(node)) {
label->setLayoutOptions(
AxisLayoutOptions::create()
->setSameLine(true)
->setBreakLine(true)
->setPrevGap(5.f)
->setScaleLimits(.1f, .35f)
->setScalePriority(1)
);
}
}
optionsMenu->setContentSize({ 120.f, winSize.height - 60.f });
optionsMenu->setPosition(75.f, winSize.height / 2 - 25.f + 10.f);
createToggleContainer(this, menu, optionsMenu, "show-hitboxes");
createToggleContainer(this, menu, optionsMenu, "hide-invisible");
createToggleContainer(this, menu, optionsMenu, "preview-mode");
createToggleContainer(this, menu, optionsMenu, "preview-animations");
createToggleContainer(this, menu, optionsMenu, "preview-particles");
createToggleContainer(this, menu, optionsMenu, "preview-shaders");
createToggleContainer(this, menu, optionsMenu, "show-ground");
createToggleContainer(this, menu, optionsMenu, "show-object-info");
createToggleContainer(this, menu, optionsMenu, "show-grid");
createToggleContainer(this, menu, optionsMenu, "select-filter");
createToggleContainer(this, menu, optionsMenu, "ignore-damage");

optionsMenu->setContentSize({ 120.f, winSize.height - 62.f });
optionsMenu->setAnchorPoint({0.f, 0.f});
optionsMenu->setPosition(15.5f, 14.5f);
optionsMenu->updateLayout();

addChild(optionsMenu);

auto settingsMenu = detachAndCreateMenu(
this,
"settings-menu",
RowLayout::create()
->setAxisReverse(true),
ColumnLayout::create()
->setCrossAxisReverse(true)
->setGrowCrossAxis(true)
->setCrossAxisOverflow(false)
->setAxisAlignment(AxisAlignment::Start),
menu->getChildByID("settings-button")
);
settingsMenu->setContentSize({ 95.f, 50.f });
settingsMenu->setContentSize({ 54.f, 62.f });
settingsMenu->updateLayout();
settingsMenu->setAnchorPoint({0.5f, 1.f});
settingsMenu->setPosition({actionsMenu->getPositionX(), winSize.height - 5.f});

auto guidelinesMenu = menu;

Expand All @@ -253,44 +258,44 @@ class GuidelinesButtonDummy {
glToggle->setID("guidelines-enable-toggle");
guidelinesMenu->insertBefore(glToggle, nullptr);
m_guidelinesOffButton = m_guidelinesOnButton = nullptr;
// this->updateSongButton();

guidelinesMenu->setID("guidelines-menu");
guidelinesMenu->setContentSize({ winSize.width / 2, 50.f });
guidelinesMenu->setLayout(RowLayout::create());
guidelinesMenu->setLayout(SimpleRowLayout::create()
->setGap(5.f)
);

auto topMenu = CCMenu::create();
topMenu->setContentSize({ winSize.width / 2, 50.f });
topMenu->setContentSize({ winSize.width / 2 - 20, 50.f });
topMenu->setPosition(winSize.width / 2, winSize.height - 30.f);
topMenu->setID("top-menu");
topMenu->setLayout(RowLayout::create());
topMenu->setLayout(SimpleRowLayout::create()
->setGap(5.f)
);
this->addChild(topMenu);
}

if (auto menu = detachAndCreateMenu(
auto infoMenu = detachAndCreateMenu(
this, "info-menu",
ColumnLayout::create()
->setGap(10.f)
->setAxisAlignment(AxisAlignment::End)
->setAxisReverse(true)
->setCrossAxisOverflow(false)
->setCrossAxisAlignment(AxisAlignment::Start)
->setCrossAxisLineAlignment(AxisAlignment::Start),
SimpleColumnLayout::create()
->setGap(16.f)
->setMainAxisAlignment(MainAxisAlignment::Start)
->setMainAxisScaling(AxisScaling::ScaleDownGaps)
->setCrossAxisScaling(AxisScaling::Fit)
->setCrossAxisAlignment(CrossAxisAlignment::Start)
->setMainAxisDirection(AxisDirection::TopToBottom),
this->getChildByID("object-count-label"),
this->getChildByID("length-label"),
this->getChildByID("length-name-label")
)) {
for (auto child : CCArrayExt<CCNode*>(menu->getChildren())) {
child->setLayoutOptions(
AxisLayoutOptions::create()
->setScaleLimits(.1f, .5f)
->setBreakLine(true)
);
}
menu->setContentSize({ 180.f, 100.f });
menu->setPosition(100.f, winSize.height - 55.f);
menu->updateLayout();
}
this->getChildByID("length-name-label"));

infoMenu->addOnEnterCallback([infoMenu] {
infoMenu->updateLayout();
});

infoMenu->setContentSize({ 180.f, 34.f });
infoMenu->setScale(0.927f);
infoMenu->setAnchorPoint({0.f, 1.f});
infoMenu->setPosition(10.f, winSize.height - 6.f);
}

struct EditorPauseLayerIDs : Modify<EditorPauseLayerIDs, EditorPauseLayer> {
Expand Down
64 changes: 56 additions & 8 deletions src/SetGroupIDLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ static void replaceInput(
m_mainLayer->getChildByID("add-group-id-input"),
menu->getChildByID("add-group-id-prev-button"),
menu->getChildByID("add-group-id-next-button"),
menu->getChildByID("settings-button"),
m_mainLayer->getChildByID("add-group-id-label")
);
addGroupIDMenu->setPosition(winSize.width / 2, winSize.height / 2 + 50);
Expand Down Expand Up @@ -348,19 +349,47 @@ static void replaceInput(
ColumnLayout::create()
->setAxisReverse(true)
->setAxisAlignment(AxisAlignment::End),
menu->getChildByID("copy-button") ? menu->getChildByID("copy-button") : menu->getChildByID("extra-button"),
menu->getChildByID("paste-button"),
menu->getChildByID("extra-button"),
menu->getChildByID("extra2-button"),
menu->getChildByID("anim-button"),
menu->getChildByID("copy-button") ? menu->getChildByID("copy-button") : EmptySpace::create(menu, "copy-button-spacer"),
menu->getChildByID("paste-button") ? menu->getChildByID("paste-button") : EmptySpace::create(menu, "paste-button-spacer"),
menu->getChildByID("extra-button") ? menu->getChildByID("extra-button") : EmptySpace::create(menu, "extra-button-spacer"),
menu->getChildByID("extra2-button") ? menu->getChildByID("extra2-button") : EmptySpace::create(menu, "extra2-button-spacer"),
menu->getChildByID("anim-button") ? menu->getChildByID("anim-button") : EmptySpace::create(menu, "anim-button-spacer")
);
actionsMenu->setAnchorPoint({0.5f, 1.f});
actionsMenu->setPosition(winSize.width / 2 + 220, winSize.height / 2 + 155);
actionsMenu->setContentSize({ 90, 145 });
actionsMenu->updateLayout();

auto previewMenu = detachAndCreateMenu(
m_mainLayer,
"preview-menu",
ColumnLayout::create()
->setGap(0.f)
->setAxisReverse(true)
->setAxisAlignment(AxisAlignment::Start),
m_mainLayer->getChildByID("preview-menu"),
m_mainLayer->getChildByID("playback-menu"),
m_mainLayer->getChildByID("trace-out-menu"),
m_mainLayer->getChildByID("trace-in-menu")
);
actionsMenu->setPosition(winSize.width / 2 + 220, winSize.height / 2);
actionsMenu->setContentSize({ 90, 300 });
actionsMenu->updateLayout();

previewMenu->setAnchorPoint({0.5f, 0.f});
previewMenu->setPosition(winSize.width / 2 + 220, winSize.height / 2 - 155);
previewMenu->setContentSize({ 90, 165 });
previewMenu->updateLayout();

auto zLayerOffsetMenu = detachAndCreateMenu(
m_mainLayer,
"z-layer-offset-menu",
SimpleRowLayout::create()
->setGap(68)
->setMainAxisScaling(AxisScaling::Fit)
->setCrossAxisScaling(AxisScaling::Fit),
menu->getChildByID("z-layer-decrement-button"),
menu->getChildByID("z-layer-increment-button")
);
zLayerOffsetMenu->setPosition(winSize.width / 2, winSize.height / 2 - 66);
zLayerOffsetMenu->updateLayout();

auto orderMenu = detachAndCreateMenu(
m_mainLayer,
Expand Down Expand Up @@ -388,6 +417,25 @@ static void replaceInput(
channelMenu->setContentSize({ 120, 60 });
channelMenu->updateLayout();
offsetChildren(channelMenu, ccp(0, -10));

auto dummyMenu = CCMenu::create();
dummyMenu->ignoreAnchorPointForPosition(false);
dummyMenu->setContentSize({350, 60});
dummyMenu->setPosition({winSize.width / 2, winSize.height / 2 - 17.f});

auto children = menu->getChildren()->shallowCopy();
for (auto child : children->asExt<CCNode>()) {
switchToMenu(child, dummyMenu);
}

menu->ignoreAnchorPointForPosition(false);
menu->setContentSize({350, 60});
menu->setPosition({winSize.width / 2, winSize.height / 2 - 17.f});

children = dummyMenu->getChildren()->shallowCopy();
for (auto child : children->asExt<CCNode>()) {
switchToMenu(child, menu);
}
}
};

Expand Down