toOpen is a list

This commit is contained in:
2025-04-10 14:18:42 -05:00
parent 178d1b9ec0
commit ce89c18293
4 changed files with 17 additions and 22 deletions

View File

@@ -39,7 +39,7 @@ namespace Archimedes {
virtual void stopModule(std::string lib) { toClose.push_back(lib); } virtual void stopModule(std::string lib) { toClose.push_back(lib); }
virtual void startModule(std::string lib, std::variant<std::string, Module*> m) { toOpen[lib] = m; } virtual void startModule(std::variant<std::string, Module*> m) { toOpen.push_back(m); }
void end() { done = true; } void end() { done = true; }
@@ -57,7 +57,7 @@ namespace Archimedes {
std::list<std::string> runOrder; std::list<std::string> runOrder;
std::list<std::string> toClose; std::list<std::string> toClose;
std::unordered_map<std::string, std::variant<std::string, Module*>> toOpen; std::list<std::variant<std::string, Module*>> toOpen;
virtual Module* dynamicLoad(std::string lib) { virtual Module* dynamicLoad(std::string lib) {

View File

@@ -27,23 +27,18 @@ void MainGUI::onLoad() {
} }
void MainGUI::run() { void MainGUI::run() {
{
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
static float f = 0.0f; static std::string path;
static int counter = 0;
ImGui::Begin("MainGUI Module"); // Create a window called "Hello, world!" and append into it. ImGui::Begin("MainGUI Module");
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) ImGui::Text("Enter a module to load:");
ImGui::InputText("path: ", path.data(), path.size());
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f if (ImGui::Button("Button"))
app->startModule(path);
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
counter++;
ImGui::SameLine();
ImGui::Text("counter = %d", counter);
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
ImGui::End(); ImGui::End();
}
} }

View File

@@ -18,10 +18,10 @@ void ImguiEmbed::run() {
toClose.clear(); toClose.clear();
for(auto m : toOpen) { for(auto m : toOpen) {
if(std::holds_alternative<std::string>(m.second)) { if(std::holds_alternative<std::string>(m)) {
load(std::get<std::string>(m.second))->onLoad(); load(std::get<std::string>(m))->onLoad();
} else { } else {
load(std::get<Archimedes::Module*>(m.second))->onLoad(); load(std::get<Archimedes::Module*>(m))->onLoad();
} }
} }
toOpen.clear(); toOpen.clear();

View File

@@ -19,10 +19,10 @@ void MinimalApp::run() {
toClose.clear(); toClose.clear();
for(auto m : toOpen) { for(auto m : toOpen) {
if(std::holds_alternative<std::string>(m.second)) { if(std::holds_alternative<std::string>(m)) {
load(std::get<std::string>(m.second))->onLoad(); load(std::get<std::string>(m))->onLoad();
} else { } else {
load(std::get<Archimedes::Module*>(m.second))->onLoad(); load(std::get<Archimedes::Module*>(m))->onLoad();
} }
} }
toOpen.clear(); toOpen.clear();