no src
This commit is contained in:
63
modules/MainGUI/MainGUI.cpp
Normal file
63
modules/MainGUI/MainGUI.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#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();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user