summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kurator/CMakeLists.txt2
-rw-r--r--kurator/src/SceneBuilder.cpp34
-rw-r--r--kurator/src/SceneBuilder.h24
-rw-r--r--kurator/src/args.cpp30
-rw-r--r--kurator/src/args.h19
-rw-r--r--kurator/src/main.cpp8
6 files changed, 114 insertions, 3 deletions
diff --git a/kurator/CMakeLists.txt b/kurator/CMakeLists.txt
index 65f55eb..44b6be9 100644
--- a/kurator/CMakeLists.txt
+++ b/kurator/CMakeLists.txt
@@ -1,12 +1,14 @@
project(kurator)
add_executable(
${PROJECT_NAME}
+ src/args.cpp
src/Battle.cpp
src/colors.cpp
src/ForceBalance.cpp
src/Log.cpp
src/main.cpp
src/ScenarioEditor.cpp
+ src/SceneBuilder.cpp
src/Session.cpp
src/Skybox.cpp
src/Title.cpp
diff --git a/kurator/src/SceneBuilder.cpp b/kurator/src/SceneBuilder.cpp
new file mode 100644
index 0000000..4fee62e
--- /dev/null
+++ b/kurator/src/SceneBuilder.cpp
@@ -0,0 +1,34 @@
+#include "SceneBuilder.h"
+
+#include <memory>
+#include <string_view>
+#include <utility>
+
+#include "Battle.h"
+#include "ScenarioEditor.h"
+#include "Scene.h"
+#include "Title.h"
+
+
+namespace kurator
+{
+
+
+SceneBuilder::SceneBuilder(std::shared_ptr<Session> _session) :
+ session {std::move(_session)}
+{
+}
+
+
+std::shared_ptr<Scene>
+SceneBuilder::build(std::string_view name) const
+{
+ if (name == "Battle")
+ return std::make_shared<Battle>(session);
+ if (name == "ScenarioEditor")
+ return std::make_shared<ScenarioEditor>(session);
+ return std::make_shared<Title>(session);
+}
+
+
+} // namespace kurator
diff --git a/kurator/src/SceneBuilder.h b/kurator/src/SceneBuilder.h
new file mode 100644
index 0000000..a567593
--- /dev/null
+++ b/kurator/src/SceneBuilder.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <memory>
+#include <string_view>
+
+#include "Scene.h"
+#include "Session.h"
+
+
+namespace kurator
+{
+
+
+class SceneBuilder
+{
+public:
+ explicit SceneBuilder(std::shared_ptr<Session> _session);
+ std::shared_ptr<Scene> build(std::string_view name) const;
+private:
+ std::shared_ptr<Session> session;
+};
+
+
+} // namespace kurator
diff --git a/kurator/src/args.cpp b/kurator/src/args.cpp
new file mode 100644
index 0000000..cff094e
--- /dev/null
+++ b/kurator/src/args.cpp
@@ -0,0 +1,30 @@
+#include "args.h"
+
+#include <unistd.h>
+
+#include <string_view>
+
+
+namespace kurator
+{
+
+
+Args
+parse_args(int argc, char* argv[])
+{
+ Args args {};
+ int opt;
+ while (-1 != (opt = getopt(argc, argv, "s:"))) {
+ switch (opt) {
+ case 's':
+ args.scene = optarg;
+ break;
+ default:
+ break; // Ignore any problems and proceed with what you can parse properly.
+ }
+ }
+ return args;
+}
+
+
+} // namespace kurator
diff --git a/kurator/src/args.h b/kurator/src/args.h
new file mode 100644
index 0000000..9418550
--- /dev/null
+++ b/kurator/src/args.h
@@ -0,0 +1,19 @@
+#pragma once
+
+#include <string_view>
+
+
+namespace kurator
+{
+
+
+struct Args
+{
+ std::string_view scene;
+};
+
+
+auto parse_args(int argc, char* argv[]) -> Args;
+
+
+} // namespace kurator
diff --git a/kurator/src/main.cpp b/kurator/src/main.cpp
index 5cda6d0..b9ef6a3 100644
--- a/kurator/src/main.cpp
+++ b/kurator/src/main.cpp
@@ -1,13 +1,15 @@
#include <memory>
+#include "args.h"
+#include "SceneBuilder.h"
#include "Session.h"
-#include "ScenarioEditor.h"
int
-main(int, char*[])
+main(int argc, char* argv[])
{
+ const auto args = kurator::parse_args(argc, argv);
auto session = std::make_shared<kurator::Session>();
- session->set(std::make_shared<kurator::ScenarioEditor>(session));
+ session->set(kurator::SceneBuilder(session).build(args.scene));
session->run();
}