summaryrefslogtreecommitdiffhomepage
path: root/floormat/main.hpp
blob: 6c93303745b4f0cdf096ea0da83c65e2a1dd71a6 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once

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

struct SDL_Window;
namespace Corrade::Containers { template<typename T> class ArrayView; }

namespace floormat {

struct fm_settings;
struct floormat_app;
struct tile_shader;
struct world;
struct scenery;
struct anim_atlas;
template<typename Atlas, typename T> struct clickable;
struct floor_mesh;
struct wall_mesh;
struct anim_mesh;

struct floormat_main
{
    struct draw_bounds final { std::int16_t minx, maxx, miny, maxy; };
    struct meshes final {
        floor_mesh& floor;
        wall_mesh& wall;
        anim_mesh& anim;
    };

    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 ArrayView<const clickable<anim_atlas, scenery>> clickable_scenery() const noexcept = 0;
    virtual ArrayView<clickable<anim_atlas, scenery>> clickable_scenery() noexcept = 0;
    virtual void set_cursor(std::uint32_t cursor) noexcept = 0;
    virtual std::uint32_t cursor() const noexcept = 0;

    virtual global_coords pixel_to_tile(Vector2d position) const noexcept = 0;
    virtual draw_bounds get_draw_bounds() const noexcept = 0;
    virtual struct meshes meshes() noexcept = 0;

    virtual struct world& world() noexcept = 0;
    virtual SDL_Window* window() noexcept = 0;
    Vector2 dpi_scale() const noexcept { return _dpi_scale; }

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

protected:
    float _frame_time1 = 0, _frame_time2 = 0;
    Vector2 _dpi_scale{1, 1}, _virtual_scale{1, 1};
};

} // namespace floormat