sequencer: switch to *-scene events isntead of *-pattern, drop the concept of next/previous scene

This commit is contained in:
Torrie Fischer 2023-12-20 09:20:34 +01:00
parent 8c4e0e402c
commit 436950eef2

View File

@ -63,34 +63,27 @@ Sequencer::handleEvent(const InputEvent& evt)
Log.verbose("Starting pattern task %s", pattern);
MainLoop::instance()->dispatch(InputEvent{InputEvent::StartThing, pattern});
}
} else if (evt.intent == InputEvent::SetPattern && evt.asString() == m_scenes[m_idx].name) {
} else if (evt.intent == InputEvent::SetScene && evt.asString() == m_scenes[m_idx].name) {
return;
} else if (evt.intent == InputEvent::SetPattern || evt.intent == InputEvent::NextPattern || evt.intent == InputEvent::PreviousPattern) {
Log.notice("Switching pattern!");
} else if (evt.intent == InputEvent::SetScene) {
Log.notice("Switching scene to %s!", evt.asString());
m_scenes[m_idx].stop();
if (evt.intent == InputEvent::NextPattern) {
m_idx++;
} else if (evt.intent == InputEvent::PreviousPattern) {
m_idx--;
} else {
for(m_idx = 0; m_idx < m_scenes.size(); m_idx++) {
if (!strcmp(evt.asString(), m_scenes[m_idx].name)) {
int newIdx = 0;
bool found = false;
for(newIdx = 0; newIdx < m_scenes.size(); newIdx++) {
if (!strcmp(evt.asString(), m_scenes[newIdx].name)) {
found = true;
break;
}
}
}
if (m_idx < 0) {
m_idx = m_scenes.size() - 1;
}
if (m_idx >= m_scenes.size()) {
m_idx = 0;
}
if (found) {
m_scenes[m_idx].stop();
m_idx = newIdx;
m_scenes[m_idx].start();
} else {
Log.notice("Scene not found!");
}
}
}