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); Log.verbose("Starting pattern task %s", pattern);
MainLoop::instance()->dispatch(InputEvent{InputEvent::StartThing, 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; return;
} else if (evt.intent == InputEvent::SetPattern || evt.intent == InputEvent::NextPattern || evt.intent == InputEvent::PreviousPattern) { } else if (evt.intent == InputEvent::SetScene) {
Log.notice("Switching pattern!"); Log.notice("Switching scene to %s!", evt.asString());
m_scenes[m_idx].stop(); 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 (evt.intent == InputEvent::NextPattern) { if (found) {
m_idx++; m_scenes[m_idx].stop();
} else if (evt.intent == InputEvent::PreviousPattern) { m_idx = newIdx;
m_idx--; m_scenes[m_idx].start();
} else { } else {
for(m_idx = 0; m_idx < m_scenes.size(); m_idx++) { Log.notice("Scene not found!");
if (!strcmp(evt.asString(), m_scenes[m_idx].name)) {
break;
}
}
} }
if (m_idx < 0) {
m_idx = m_scenes.size() - 1;
}
if (m_idx >= m_scenes.size()) {
m_idx = 0;
}
m_scenes[m_idx].start();
} }
} }