73 lines
1.6 KiB
C++
73 lines
1.6 KiB
C++
#include "MinimalApp.h"
|
|
|
|
void MinimalApp::run() {
|
|
|
|
for(std::string m : runOrder) {
|
|
modules[m]->onLoad();
|
|
}
|
|
|
|
|
|
// Main loop
|
|
while (!done && !runOrder.empty()) {
|
|
|
|
for(std::string m : runOrder) {
|
|
modules[m]->run();
|
|
}
|
|
|
|
handleEvents();
|
|
|
|
for(std::string m : toClose) {
|
|
unload(m);
|
|
}
|
|
toClose.clear();
|
|
|
|
for(auto m : toOpen) {
|
|
static Archimedes::Module* n;
|
|
if(std::holds_alternative<std::string>(m)) {
|
|
n = load(std::get<std::string>(m));
|
|
} else {
|
|
n = load(std::get<Archimedes::Module*>(m));
|
|
}
|
|
if(n) {
|
|
n->onLoad();
|
|
n = nullptr;
|
|
}
|
|
}
|
|
toOpen.clear();
|
|
}
|
|
|
|
}
|
|
|
|
bool MinimalApp::onEvent(const Archimedes::Event& event) {
|
|
|
|
unsigned int type = getEventType(event);
|
|
|
|
if(type == getEventType(Archimedes::DoLoadModuleEvent())) {
|
|
|
|
Archimedes::DoLoadModuleEvent& e = (Archimedes::DoLoadModuleEvent&) event;
|
|
|
|
startModule(e.module);
|
|
|
|
return true;
|
|
|
|
} else if(type == getEventType(Archimedes::DoUnloadModuleEvent())) {
|
|
|
|
Archimedes::DoUnloadModuleEvent& e = (Archimedes::DoUnloadModuleEvent&) event;
|
|
|
|
stopModule(e.module);
|
|
|
|
return true;
|
|
|
|
} else if(type == getEventType(Archimedes::LoadModuleEvent())) {
|
|
|
|
return true;
|
|
} else if(type == getEventType(Archimedes::UnloadModuleEvent())) {
|
|
|
|
return true;
|
|
} else if(type == getEventType(Archimedes::AnonymousEvent())) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|