From fbeac799986d4d70d3937418218d01d39372bb00 Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 10 Feb 2023 23:10:39 +0100 Subject: Extracted time factor controls --- kurator/src/Battle.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp index ce14365..37dda67 100644 --- a/kurator/src/Battle.cpp +++ b/kurator/src/Battle.cpp @@ -70,6 +70,20 @@ Battle::~Battle() void +time_controls(const char* id, float& time_factor) +{ + ImGui::PushID(id); + ImGui::PushItemWidth(-std::numeric_limits::min()); + if (ImGui::Button("1x")) + time_factor = 1.0f; + ImGui::SameLine(); + ImGui::SliderFloat("##time_factor", &time_factor, 0.1f, 10.0f); + ImGui::PopItemWidth(); + ImGui::PopID(); +} + + +void Battle::update(const float dt) { if (IsKeyPressed(KEY_ESCAPE)) @@ -111,14 +125,8 @@ Battle::update(const float dt) balance.update(registry); ImGui::SetNextWindowPos({GetScreenWidth()/2.0f, GetScreenHeight()-100.0f}, ImGuiCond_Once, {0.5f, 0.5f}); ImGui::SetNextWindowSize({240.0f, 0.0f}, ImGuiCond_Once); - if (ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_NoFocusOnAppearing)) { - ImGui::PushItemWidth(-std::numeric_limits::min()); - if (ImGui::Button("1x")) - time_factor = 1.0f; - ImGui::SameLine(); - ImGui::SliderFloat("##time_factor", &time_factor, 0.1f, 10.0f); - ImGui::PopItemWidth(); - } + if (ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_NoFocusOnAppearing)) + time_controls("TimeControls", time_factor); ImGui::End(); if (IsKeyPressed(KEY_SPACE)) { if (report) -- cgit v1.1