diff --git a/changelog.md b/changelog.md index 36b7625..b8a8ac7 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ ## v6.10.0-alpha.3 * Add Create Loop keybind + * Fix Next Free not working for Editor Layers * Fix Build Helper keybind actually creating a loop * Fix 32-bit Android crashing upon entering the editor diff --git a/src/features/EditMixedValues.cpp b/src/features/EditMixedValues.cpp index e14fdaa..c04adc3 100644 --- a/src/features/EditMixedValues.cpp +++ b/src/features/EditMixedValues.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,7 @@ struct MixedValuesConfig final { Type (*getDefault)(GameObject*); Type (*get)(GameObject*); Type (*set)(GameObject*, Type, Direction); + void (*useNextFreeValues)(GameObject*, std::set&) = nullptr; }; template @@ -58,7 +60,7 @@ class MixedValuesInput : public CCMenu { protected: bool init( GameObject* obj, CCArray* objs, MixedValuesConfig const& config, - const char* title, const char* arrowSpr, bool showNextFree + const char* title, const char* arrowSpr ) { if (!CCMenu::init()) return false; @@ -112,7 +114,7 @@ class MixedValuesInput : public CCMenu { m_arrowRightBtn->setID("arrow-right-button"_spr); this->addChildAtPosition(m_arrowRightBtn, Anchor::Right, ccp(-15, -10)); - if (showNextFree) { + if (m_config.useNextFreeValues) { auto nextFreeSpr = CCSprite::createWithSpriteFrameName("GJ_plus2Btn_001.png"); nextFreeSpr->setScale(.8f); m_nextFreeBtn = CCMenuItemSpriteExtra::create( @@ -151,8 +153,8 @@ class MixedValuesInput : public CCMenu { } void onNextFree(CCObject*) { std::set usedLayers; - for (auto obj : m_targets) { - usedLayers.insert(m_config.get(obj)); + for (auto obj : CCArrayExt(LevelEditorLayer::get()->m_objects)) { + m_config.useNextFreeValues(obj, usedLayers); } T nextFree; for (nextFree = m_config.limits.min; nextFree < m_config.limits.max; nextFree += 1) { @@ -198,10 +200,10 @@ class MixedValuesInput : public CCMenu { static MixedValuesInput* create( GameObject* obj, CCArray* objs, MixedValuesConfig const& config, - const char* title, const char* arrowSpr, bool showNextFree + const char* title, const char* arrowSpr ) { auto ret = new MixedValuesInput(); - if (ret && ret->init(obj, objs, config, title, arrowSpr, showNextFree)) { + if (ret && ret->init(obj, objs, config, title, arrowSpr)) { ret->autorelease(); return ret; } @@ -283,8 +285,12 @@ class $modify(SetGroupIDLayer) { obj->m_editorLayer = value; return value; }, + .useNextFreeValues = +[](GameObject* obj, std::set& values) { + values.insert(obj->m_editorLayer); + values.insert(obj->m_editorLayer2); + }, }, - "Editor L", "GJ_arrow_02_001.png", true + "Editor L", "GJ_arrow_02_001.png" )->replace(m_editorLayerInput, m_mainLayer->querySelector("editor-layer-menu")); MixedValuesInput::create( @@ -300,8 +306,12 @@ class $modify(SetGroupIDLayer) { obj->m_editorLayer2 = value; return value; }, + .useNextFreeValues = +[](GameObject* obj, std::set& values) { + values.insert(obj->m_editorLayer); + values.insert(obj->m_editorLayer2); + }, }, - "Editor L2", "GJ_arrow_03_001.png", true + "Editor L2", "GJ_arrow_03_001.png" )->replace(m_editorLayer2Input, m_mainLayer->querySelector("editor-layer-2-menu")); MixedValuesInput::create( @@ -332,7 +342,7 @@ class $modify(SetGroupIDLayer) { return obj->m_zOrder; }, }, - "Z Order", "GJ_arrow_02_001.png", false + "Z Order", "GJ_arrow_02_001.png" )->replace(m_zOrderInput, m_mainLayer->querySelector("z-order-menu")); if (m_orderInput) { @@ -353,7 +363,7 @@ class $modify(SetGroupIDLayer) { return value; } }, - nullptr, "GJ_arrow_02_001.png", false + nullptr, "GJ_arrow_02_001.png" )->replace(m_orderInput, m_mainLayer->querySelector("channel-order-menu")); } if (m_channelInput) { @@ -374,7 +384,7 @@ class $modify(SetGroupIDLayer) { return value; } }, - nullptr, "GJ_arrow_02_001.png", false + nullptr, "GJ_arrow_02_001.png" )->replace(m_channelInput, m_mainLayer->querySelector("channel-menu")); }