summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kurator/src/Log.cpp3
-rw-r--r--kurator/src/ScenarioEditor.cpp26
-rw-r--r--kurator/src/ScenarioEditor.h5
-rw-r--r--kurator/src/Session.cpp2
-rw-r--r--kurator/src/Title.cpp4
5 files changed, 26 insertions, 14 deletions
diff --git a/kurator/src/Log.cpp b/kurator/src/Log.cpp
index 162e309..0689176 100644
--- a/kurator/src/Log.cpp
+++ b/kurator/src/Log.cpp
@@ -9,7 +9,6 @@
#include <kurator/stats/events.h>
#include "EventLog.h"
-#include "ScenarioEditor.h"
#include "Session.h"
@@ -36,7 +35,7 @@ void
Log::update(const float)
{
if (IsKeyPressed(KEY_SPACE))
- session->set(std::make_shared<ScenarioEditor>(session));
+ session->pop();
}
diff --git a/kurator/src/ScenarioEditor.cpp b/kurator/src/ScenarioEditor.cpp
index 0b00b02..7025b49 100644
--- a/kurator/src/ScenarioEditor.cpp
+++ b/kurator/src/ScenarioEditor.cpp
@@ -25,7 +25,7 @@ ScenarioEditor::ScenarioEditor(std::shared_ptr<Session> _session) :
warbringers {2},
eclipses {3},
distance {12000},
- battle {std::make_shared<Battle>(session, scenario())}
+ battle {generate()}
{
}
@@ -51,13 +51,16 @@ ScenarioEditor::update(float)
update |= ImGui::SliderInt("Eclipses", &eclipses, 0, 20);
update |= ImGui::SliderFloat("Distance", &distance, 10000, 20000);
if (update)
- battle = std::make_shared<Battle>(session, scenario());
+ battle = generate();
if (ImGui::Button("Start"))
- session->set(std::move(battle));
+ start_battle();
+ ImGui::SameLine();
+ if (ImGui::Button("Back"))
+ session->pop();
}
ImGui::End();
if (IsKeyPressed(KEY_SPACE))
- session->set(std::move(battle));
+ start_battle();
}
@@ -83,10 +86,19 @@ ScenarioEditor::draw() const
}
-campaign::Scenario
-ScenarioEditor::scenario() const
+void
+ScenarioEditor::start_battle()
+{
+ session->push(std::move(battle));
+ battle = generate();
+}
+
+
+std::shared_ptr<Scene>
+ScenarioEditor::generate() const
{
- return campaign::scenarios::example(teams, anvils, warbringers, eclipses, distance);
+ auto scenario = campaign::scenarios::example(teams, anvils, warbringers, eclipses, distance);
+ return std::make_shared<Battle>(session, std::move(scenario));
}
diff --git a/kurator/src/ScenarioEditor.h b/kurator/src/ScenarioEditor.h
index 70ce3a2..ec83965 100644
--- a/kurator/src/ScenarioEditor.h
+++ b/kurator/src/ScenarioEditor.h
@@ -4,8 +4,6 @@
#include <raylib.h>
-#include <kurator/campaign/Scenario.h>
-
#include "Scene.h"
#include "Session.h"
@@ -21,8 +19,9 @@ public:
~ScenarioEditor();
void update(float dt) override;
void draw() const override;
+ void start_battle();
private:
- campaign::Scenario scenario() const;
+ std::shared_ptr<Scene> generate() const;
std::shared_ptr<Session> session;
RenderTexture2D buffer;
int teams;
diff --git a/kurator/src/Session.cpp b/kurator/src/Session.cpp
index 9d39d59..59adcae 100644
--- a/kurator/src/Session.cpp
+++ b/kurator/src/Session.cpp
@@ -45,6 +45,8 @@ Session::run()
auto scene = scenes.back();
rlImGuiBegin();
scene->update(GetFrameTime());
+ if (!scenes.empty())
+ scene = scenes.back();
BeginDrawing();
scene->draw();
rlImGuiEnd();
diff --git a/kurator/src/Title.cpp b/kurator/src/Title.cpp
index ffd1b83..30fb209 100644
--- a/kurator/src/Title.cpp
+++ b/kurator/src/Title.cpp
@@ -27,9 +27,9 @@ Title::update(const float)
ImGui::SetNextWindowPos({GetScreenWidth()/2.0f, GetScreenHeight()/2.0f}, ImGuiCond_Once, {0.5f, 0.4f});
if (ImGui::Begin("Main Menu", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Button("Quick Battle", {-1.0f, 0.0f}))
- session->set(SceneBuilder(session).battle());
+ session->push(SceneBuilder(session).battle());
if (ImGui::Button("Scenario Editor", {-1.0f, 0.0f}))
- session->set(SceneBuilder(session).scenario_editor());
+ session->push(SceneBuilder(session).scenario_editor());
if (ImGui::Button("Exit", {-1.0f, 0.0f}))
session->quit();
}