aboutsummaryrefslogtreecommitdiff
path: root/src/input_actions.cpp
blob: 5df6e5f7ef3bf6d808f9031e1cd0bd4a3cef801c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "input_actions.hpp"

#include <fmt/core.h>

namespace InputActions
{

void exit_success()
{
	exit(EXIT_SUCCESS);
}

Callback move_cursor(const Vector2 &direction,
					 const std::shared_ptr<ICursorController> &cursor_controller,
					 const std::shared_ptr<IScene> &scene,
					 const std::shared_ptr<IWindow> &window)
{
	return [direction, cursor_controller, scene, window]()
	{
		constexpr int32_t amount = 1;

		const auto new_position =
			cursor_controller->where().to_direction(direction, amount);

		const auto window_size = window->size();

		if (window_size.validate_coords(new_position) != CoordsValidation::VALID)
		{
			return;
		}

		cursor_controller->move_to(new_position);

		scene->write_status(
			fmt::format("X: {}    Y {}", new_position.get_x(), new_position.get_y()));
	};
}

} // namespace InputActions