aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-10 21:16:05 +0100
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:55 +0200
commit4c6fa6bfd37862acfbe377bb95561da4b4ce8cc9 (patch)
tree2e73b109c50f4ebedc89a8c2eb881fa654cc2a37 /src
parent19f5d93dba74dda1fd1a9211707d98b6dd9b19ba (diff)
feat: make status bar visible from game start
Diffstat (limited to 'src')
-rw-r--r--src/engine/engine.cpp6
-rw-r--r--src/input_actions.cpp7
-rw-r--r--src/strings.hpp5
3 files changed, 16 insertions, 2 deletions
diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp
index 6050348..d793c65 100644
--- a/src/engine/engine.cpp
+++ b/src/engine/engine.cpp
@@ -1,10 +1,12 @@
#include "engine.hpp"
#include "input_actions.hpp"
+#include "strings.hpp"
#include "util/function.hpp"
#include <cstdlib>
+#include <fmt/core.h>
#include <utility>
CLIGameEngine::CLIGameEngine(IGameFactory game_factory, ISceneFactory scene_factory,
@@ -34,6 +36,10 @@ void CLIGameEngine::start() noexcept
_cursor_controller->move_to(center_position);
+ scene->write_status(fmt::format(STATUS_BAR_COORDINATES,
+ fmt::arg("x", center_position.get_x()),
+ fmt::arg("y", center_position.get_y())));
+
std::atexit(normalize_lambda(
[scene, this]()
{
diff --git a/src/input_actions.cpp b/src/input_actions.cpp
index 5df6e5f..7a6976d 100644
--- a/src/input_actions.cpp
+++ b/src/input_actions.cpp
@@ -1,5 +1,7 @@
#include "input_actions.hpp"
+#include "strings.hpp"
+
#include <fmt/core.h>
namespace InputActions
@@ -31,8 +33,9 @@ Callback move_cursor(const Vector2 &direction,
cursor_controller->move_to(new_position);
- scene->write_status(
- fmt::format("X: {} Y {}", new_position.get_x(), new_position.get_y()));
+ scene->write_status(fmt::format(STATUS_BAR_COORDINATES,
+ fmt::arg("x", new_position.get_x()),
+ fmt::arg("y", new_position.get_y())));
};
}
diff --git a/src/strings.hpp b/src/strings.hpp
new file mode 100644
index 0000000..3678c57
--- /dev/null
+++ b/src/strings.hpp
@@ -0,0 +1,5 @@
+#pragma once
+
+#include <fmt/core.h>
+
+constexpr fmt::string_view STATUS_BAR_COORDINATES = "X: {x} Y {y}";