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;
|
||||||
|
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user