diff --git a/VortexEngine/src/Menus/Menu.cpp b/VortexEngine/src/Menus/Menu.cpp index 2f4af21db8..463c050cbd 100644 --- a/VortexEngine/src/Menus/Menu.cpp +++ b/VortexEngine/src/Menus/Menu.cpp @@ -125,14 +125,14 @@ Menu::MenuAction Menu::run() // every time a button is clicked, change the led selection if (g_pButton->onShortClick()) { - m_ledSelection = (m_ledSelection + 1) % NUM_PERMUTATIONS; + do { + m_ledSelection = (m_ledSelection + 1) % NUM_PERMUTATIONS; + } while (!isValidLedSelection(ledPermutations[m_ledSelection])); } if (g_pButton2->onShortClick()) { - if (m_ledSelection > 0) { - m_ledSelection--; - } else { - m_ledSelection = NUM_PERMUTATIONS - 1; - } + do { + m_ledSelection = (m_ledSelection > 0) ? (m_ledSelection - 1) : (NUM_PERMUTATIONS - 1); + } while (!isValidLedSelection(ledPermutations[m_ledSelection])); } // on a long press of the button, lock in the target led if (g_pButton->onLongClick()) { diff --git a/VortexEngine/src/Menus/Menu.h b/VortexEngine/src/Menus/Menu.h index fca138d4e2..aefcf0d363 100644 --- a/VortexEngine/src/Menus/Menu.h +++ b/VortexEngine/src/Menus/Menu.h @@ -43,9 +43,9 @@ class Menu void showBulbSelection(); void showExit(); - // iterate to next bulb selection - void nextBulbSelection(); - void prevBulbSelection(); + // an overridable api that allows derived menus to decide which led selections + // should be available before they have actually opened + virtual bool isValidLedSelection(LedMap selection) const { return true; } // blink the selected finger virtual void blinkSelection(uint32_t offMs = 250, uint32_t onMs = 500); diff --git a/VortexEngine/src/Menus/MenuList/ColorSelect.cpp b/VortexEngine/src/Menus/MenuList/ColorSelect.cpp index c5e42f0cfe..e25717fed1 100644 --- a/VortexEngine/src/Menus/MenuList/ColorSelect.cpp +++ b/VortexEngine/src/Menus/MenuList/ColorSelect.cpp @@ -405,3 +405,11 @@ void ColorSelect::blinkSelection(uint32_t offMs, uint32_t onMs) // otherwise run the default blink logic Menu::blinkSelection(offMs, onMs); } + +bool ColorSelect::isValidLedSelection(LedMap selection) const +{ + // if we have a multi-led pattern then we can only select LED_MULTI otherwise + // if we don't have a multi-led pattern then we can't select multi + bool selectedMulti = (selection == MAP_LED(LED_MULTI)); + return selectedMulti == m_previewMode.isMultiLed(); +} diff --git a/VortexEngine/src/Menus/MenuList/ColorSelect.h b/VortexEngine/src/Menus/MenuList/ColorSelect.h index 34a235a6ee..aed7d038ce 100644 --- a/VortexEngine/src/Menus/MenuList/ColorSelect.h +++ b/VortexEngine/src/Menus/MenuList/ColorSelect.h @@ -24,6 +24,9 @@ class ColorSelect : public Menu // overridden blink logic for the colorselect menu (Controls how m_curSelection blinks) void blinkSelection(uint32_t offMs = 350, uint32_t onMs = 500) override; + // override the led selection api to choose which led maps can be selected + bool isValidLedSelection(LedMap selection) const override; + // private enumeration for internal state of color selection enum ColorSelectState : uint32_t {