diff options
author | Aki <please@ignore.pl> | 2023-02-10 23:10:39 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-02-10 23:10:39 +0100 |
commit | fbeac799986d4d70d3937418218d01d39372bb00 (patch) | |
tree | 730819402e39402d31d95e081ef0127f4ff9de50 | |
parent | 1c93b1bbcf9ea0435490d2e16cc1a02a7b9afc68 (diff) | |
download | kurator-fbeac799986d4d70d3937418218d01d39372bb00.zip kurator-fbeac799986d4d70d3937418218d01d39372bb00.tar.gz kurator-fbeac799986d4d70d3937418218d01d39372bb00.tar.bz2 |
Extracted time factor controls
-rw-r--r-- | kurator/src/Battle.cpp | 24 |
1 files 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<float>::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<float>::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) |