sequencer: switch to *-scene events isntead of *-pattern, drop the concept of next/previous scene
This commit is contained in:
parent
8c4e0e402c
commit
436950eef2
@ -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;
|
||||||
if (evt.intent == InputEvent::NextPattern) {
|
for(newIdx = 0; newIdx < m_scenes.size(); newIdx++) {
|
||||||
m_idx++;
|
if (!strcmp(evt.asString(), m_scenes[newIdx].name)) {
|
||||||
} else if (evt.intent == InputEvent::PreviousPattern) {
|
found = true;
|
||||||
m_idx--;
|
|
||||||
} else {
|
|
||||||
for(m_idx = 0; m_idx < m_scenes.size(); m_idx++) {
|
|
||||||
if (!strcmp(evt.asString(), m_scenes[m_idx].name)) {
|
|
||||||
break;
|
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();
|
m_scenes[m_idx].start();
|
||||||
|
} else {
|
||||||
|
Log.notice("Scene not found!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user