64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
#include "MainGUI.h"
|
|
#include "modules/ImguiModule/src/ImguiModule.h"
|
|
|
|
|
|
MainGUI::MainGUI(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {
|
|
|
|
name = "MainGUI";
|
|
|
|
ImguiModule* im = new ImguiModule(a, h);
|
|
deps[*im] = im;
|
|
}
|
|
|
|
MainGUI::~MainGUI() {
|
|
|
|
if(app) {
|
|
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
|
|
im->releaseContext(ImGui::GetCurrentContext());
|
|
}
|
|
}
|
|
|
|
void MainGUI::onLoad() {
|
|
|
|
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
|
|
|
|
if(!im) {
|
|
std::cout << "No ImguiModule for MainGUI!\n";
|
|
std::abort();
|
|
}
|
|
|
|
ImGui::SetCurrentContext(im->aquireContext());
|
|
|
|
}
|
|
|
|
void MainGUI::run() {
|
|
|
|
if(open) {
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
static std::string s;
|
|
|
|
ImGui::Begin("MainGUI Module", &open);
|
|
|
|
ImGui::Text("Active Modules:");
|
|
for(auto m : app->getModuleNames())
|
|
ImGui::Text("%s", m.c_str());
|
|
|
|
ImGui::Text("\nEnter a module to un/load:");
|
|
ImGui::InputText("module: ", &s);
|
|
|
|
if(ImGui::Button("load"))
|
|
app->emitEvent(new Archimedes::DoLoadModuleEvent(s));
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(ImGui::Button("unload"))
|
|
app->emitEvent(new Archimedes::DoUnloadModuleEvent(s));
|
|
|
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
|
ImGui::End();
|
|
} else {
|
|
app->end();
|
|
}
|
|
|
|
}
|