diff options
author | Aki <please@ignore.pl> | 2022-12-25 22:13:16 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-12-25 22:13:16 +0100 |
commit | 5a1731154259909b5ba6168ecec080ec6e32d15a (patch) | |
tree | ec21188122c27b90be877e8e6c72d2146975fe6c | |
parent | 1ae32d48ebf409f0ee75f777624b5d96fc3cdfac (diff) | |
download | kurator-5a1731154259909b5ba6168ecec080ec6e32d15a.zip kurator-5a1731154259909b5ba6168ecec080ec6e32d15a.tar.gz kurator-5a1731154259909b5ba6168ecec080ec6e32d15a.tar.bz2 |
Title scene now uses SceneBuilder for switching
-rw-r--r-- | kurator/src/SceneBuilder.cpp | 25 | ||||
-rw-r--r-- | kurator/src/SceneBuilder.h | 3 | ||||
-rw-r--r-- | kurator/src/Title.cpp | 17 | ||||
-rw-r--r-- | kurator/src/Title.h | 1 |
4 files changed, 31 insertions, 15 deletions
diff --git a/kurator/src/SceneBuilder.cpp b/kurator/src/SceneBuilder.cpp index 4fee62e..108b9e4 100644 --- a/kurator/src/SceneBuilder.cpp +++ b/kurator/src/SceneBuilder.cpp @@ -24,9 +24,30 @@ std::shared_ptr<Scene> SceneBuilder::build(std::string_view name) const { if (name == "Battle") - return std::make_shared<Battle>(session); + return battle(); if (name == "ScenarioEditor") - return std::make_shared<ScenarioEditor>(session); + return scenario_editor(); + return title(); +} + + +std::shared_ptr<Scene> +SceneBuilder::battle() const +{ + return std::make_shared<Battle>(session); +} + + +std::shared_ptr<Scene> +SceneBuilder::scenario_editor() const +{ + return std::make_shared<ScenarioEditor>(session); +} + + +std::shared_ptr<Scene> +SceneBuilder::title() const +{ return std::make_shared<Title>(session); } diff --git a/kurator/src/SceneBuilder.h b/kurator/src/SceneBuilder.h index a567593..ea39a94 100644 --- a/kurator/src/SceneBuilder.h +++ b/kurator/src/SceneBuilder.h @@ -16,6 +16,9 @@ class SceneBuilder public: explicit SceneBuilder(std::shared_ptr<Session> _session); std::shared_ptr<Scene> build(std::string_view name) const; + std::shared_ptr<Scene> battle() const; + std::shared_ptr<Scene> scenario_editor() const; + std::shared_ptr<Scene> title() const; private: std::shared_ptr<Session> session; }; diff --git a/kurator/src/Title.cpp b/kurator/src/Title.cpp index 3ada1d5..ffd1b83 100644 --- a/kurator/src/Title.cpp +++ b/kurator/src/Title.cpp @@ -6,8 +6,8 @@ #include <raylib.h> #include <imgui.h> +#include "SceneBuilder.h" #include "Session.h" -#include "Battle.h" namespace kurator @@ -26,14 +26,14 @@ Title::update(const float) ImGui::SetNextWindowSize({GetScreenWidth()/3.0f, 0.0f}, ImGuiCond_Once); 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("Start", {-1.0f, 0.0f})) - start_battle(); + if (ImGui::Button("Quick Battle", {-1.0f, 0.0f})) + session->set(SceneBuilder(session).battle()); + if (ImGui::Button("Scenario Editor", {-1.0f, 0.0f})) + session->set(SceneBuilder(session).scenario_editor()); if (ImGui::Button("Exit", {-1.0f, 0.0f})) session->quit(); } ImGui::End(); - if (IsKeyPressed(KEY_SPACE)) - start_battle(); } @@ -48,11 +48,4 @@ Title::draw() const } -void -Title::start_battle() -{ - session->set(std::make_shared<Battle>(session)); -} - - } // namespace kurator diff --git a/kurator/src/Title.h b/kurator/src/Title.h index b350196..c29dc99 100644 --- a/kurator/src/Title.h +++ b/kurator/src/Title.h @@ -18,7 +18,6 @@ public: void draw() const override; private: std::shared_ptr<Session> session; - void start_battle(); }; |