summaryrefslogtreecommitdiffhomepage
path: root/floormat/main.hpp
blob: 9347ad4072b66ce80b514ecc224e6fd15e5b8152 (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
40
41
42
43
44
45
46
47
48
#pragma once

#include "src/global-coords.hpp"
#include <Magnum/Math/Vector2.h>

struct SDL_Window;

namespace floormat {

struct fm_settings;
struct floormat_app;
struct tile_shader;
struct world;

struct floormat_main
{
    floormat_main() noexcept;
    virtual ~floormat_main() noexcept;

    fm_DECLARE_DELETED_COPY_ASSIGNMENT(floormat_main);
    fm_DECLARE_DEPRECATED_MOVE_ASSIGNMENT(floormat_main);

    virtual int exec() = 0;
    virtual void quit(int status) = 0;

    virtual Magnum::Math::Vector2<int> window_size() const noexcept = 0;
    virtual tile_shader& shader() noexcept = 0;
    virtual const tile_shader& shader() const noexcept = 0;
    constexpr float smoothed_dt() const noexcept { return _frame_time1; }
    virtual fm_settings& settings() noexcept = 0;
    virtual const fm_settings& settings() const noexcept = 0;

    virtual bool is_text_input_active() const noexcept = 0;
    virtual void start_text_input() noexcept = 0;
    virtual void stop_text_input() noexcept = 0;

    virtual global_coords pixel_to_tile(Vector2d position) const noexcept = 0;

    virtual struct world& world() noexcept = 0;
    virtual SDL_Window* window() noexcept = 0;

    [[nodiscard]] static floormat_main* create(floormat_app& app, fm_settings&& options);

protected:
    float _frame_time1 = 0, _frame_time2 = 0;
};

} // namespace floormat