summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kurator/src/Battle.cpp24
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)