Skip to content

Commit

Permalink
Lua: improvement to UI layout
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Mar 6, 2024
1 parent f5f0771 commit 7cf045f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/mods/LuaLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ void LuaLoader::on_frame() {
}
}

void LuaLoader::on_draw_ui() {
ImGui::SetNextItemOpen(false, ImGuiCond_::ImGuiCond_Once);

if (ImGui::CollapsingHeader(get_name().data())) {
void LuaLoader::on_draw_sidebar_entry(std::string_view in_entry) {
if (in_entry == "Main") {
if (ImGui::Button("Run script")) {
OPENFILENAME ofn{};
char file[260]{};
Expand Down Expand Up @@ -201,9 +199,12 @@ void LuaLoader::on_draw_ui() {
} else {
ImGui::Text("No scripts loaded.");
}

ImGui::TreePop();
}

if (ImGui::CollapsingHeader("Script Generated UI")) {

if (in_entry == "Script UI") {
std::scoped_lock _{m_access_mutex};

if (m_states.empty()) {
Expand All @@ -213,6 +214,8 @@ void LuaLoader::on_draw_ui() {
for (auto& state : m_states) {
state->on_draw_ui();
}

ImGui::TreePop();
}
}

Expand Down
10 changes: 9 additions & 1 deletion src/mods/LuaLoader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ class LuaLoader : public Mod {
std::string_view get_name() const override { return "LuaLoader"; }
bool is_advanced_mod() const override { return true; }
std::optional<std::string> on_initialize_d3d_thread() override;
void on_draw_ui() override;

std::vector<SidebarEntryInfo> get_sidebar_entries() override {
return {
{"Main", true},
{"Script UI", true}
};
}

void on_draw_sidebar_entry(std::string_view in_entry);
void on_frame() override;

void on_config_load(const utility::Config& cfg, bool set_defaults) override;
Expand Down

0 comments on commit 7cf045f

Please sign in to comment.