summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-12-30 01:37:36 +0100
committerAki <please@ignore.pl>2022-12-30 01:50:56 +0100
commitaa8fd24f6058307c97c010fe5ea1d66da3e0b23a (patch)
treedc462c5e6e26a240b581d586f055eedebd5cb49c
parentbc05dbcb04dbce5e88921d318fc3094e3bcddf2f (diff)
downloadkurator-aa8fd24f6058307c97c010fe5ea1d66da3e0b23a.zip
kurator-aa8fd24f6058307c97c010fe5ea1d66da3e0b23a.tar.gz
kurator-aa8fd24f6058307c97c010fe5ea1d66da3e0b23a.tar.bz2
SceneBuilder can now list the scenes
Still, information is duplicated between the list_scenes and other methods.
-rw-r--r--kurator/completions/kurator.bash16
-rw-r--r--kurator/src/SceneBuilder.cpp8
-rw-r--r--kurator/src/SceneBuilder.h2
-rw-r--r--kurator/src/args.cpp5
-rw-r--r--kurator/src/args.h1
-rw-r--r--kurator/src/main.cpp5
6 files changed, 36 insertions, 1 deletions
diff --git a/kurator/completions/kurator.bash b/kurator/completions/kurator.bash
new file mode 100644
index 0000000..1891791
--- /dev/null
+++ b/kurator/completions/kurator.bash
@@ -0,0 +1,16 @@
+# kurator completion
+# for use with bash-completions
+
+_kurator()
+{
+ local cur prev words cword
+ _init_completion || return
+ case $prev in
+ -s)
+ COMPREPLY=($(compgen -W "$($1 -l)" -- "$cur"))
+ return
+ ;;
+ esac
+ COMPREPLY=($(compgen -W '-s -l' -- "$cur")) # no usage or help implemented
+} &&
+ complete -F _kurator kurator kurator/kurator
diff --git a/kurator/src/SceneBuilder.cpp b/kurator/src/SceneBuilder.cpp
index b9f13ab..f3c05a5 100644
--- a/kurator/src/SceneBuilder.cpp
+++ b/kurator/src/SceneBuilder.cpp
@@ -1,6 +1,7 @@
#include "SceneBuilder.h"
#include <memory>
+#include <ostream>
#include <string_view>
#include <utility>
@@ -21,6 +22,13 @@ SceneBuilder::SceneBuilder(std::shared_ptr<Session> _session) :
}
+void
+SceneBuilder::list_scenes(std::ostream& out)
+{
+ out << "Battle\n" "Campaign\n" "ScenarioEditor\n" "Title\n";
+}
+
+
std::shared_ptr<Scene>
SceneBuilder::build(std::string_view name) const
{
diff --git a/kurator/src/SceneBuilder.h b/kurator/src/SceneBuilder.h
index 631a6e9..2b8014d 100644
--- a/kurator/src/SceneBuilder.h
+++ b/kurator/src/SceneBuilder.h
@@ -1,6 +1,7 @@
#pragma once
#include <memory>
+#include <ostream>
#include <string_view>
#include "Scene.h"
@@ -15,6 +16,7 @@ class SceneBuilder
{
public:
explicit SceneBuilder(std::shared_ptr<Session> _session);
+ static void list_scenes(std::ostream& out);
std::shared_ptr<Scene> build(std::string_view name) const;
std::shared_ptr<Scene> battle() const;
std::shared_ptr<Scene> campaign() const;
diff --git a/kurator/src/args.cpp b/kurator/src/args.cpp
index cff094e..91925a7 100644
--- a/kurator/src/args.cpp
+++ b/kurator/src/args.cpp
@@ -14,11 +14,14 @@ parse_args(int argc, char* argv[])
{
Args args {};
int opt;
- while (-1 != (opt = getopt(argc, argv, "s:"))) {
+ while (-1 != (opt = getopt(argc, argv, "s:l"))) {
switch (opt) {
case 's':
args.scene = optarg;
break;
+ case 'l':
+ args.show_scenes = true;
+ break;
default:
break; // Ignore any problems and proceed with what you can parse properly.
}
diff --git a/kurator/src/args.h b/kurator/src/args.h
index 9418550..55ac058 100644
--- a/kurator/src/args.h
+++ b/kurator/src/args.h
@@ -10,6 +10,7 @@ namespace kurator
struct Args
{
std::string_view scene;
+ bool show_scenes = false;
};
diff --git a/kurator/src/main.cpp b/kurator/src/main.cpp
index b9ef6a3..631c938 100644
--- a/kurator/src/main.cpp
+++ b/kurator/src/main.cpp
@@ -1,3 +1,4 @@
+#include <iostream>
#include <memory>
#include "args.h"
@@ -9,6 +10,10 @@ int
main(int argc, char* argv[])
{
const auto args = kurator::parse_args(argc, argv);
+ if (args.show_scenes) {
+ kurator::SceneBuilder::list_scenes(std::cout);
+ return 0;
+ }
auto session = std::make_shared<kurator::Session>();
session->set(kurator::SceneBuilder(session).build(args.scene));
session->run();