diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-23 22:38:54 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-23 22:38:54 +0200 |
commit | 0efe01d0e7286e9eb60c4739ae748c0cb6e7a51f (patch) | |
tree | 09121d7fcbb17151ea10331bfb3de0474fe6a661 /editor/app.hpp | |
parent | b6a067678ab9e225647b256595d54dde2ce6f2f5 (diff) |
a
Diffstat (limited to 'editor/app.hpp')
-rw-r--r-- | editor/app.hpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/editor/app.hpp b/editor/app.hpp index 0b369936..856d8a64 100644 --- a/editor/app.hpp +++ b/editor/app.hpp @@ -1,19 +1,97 @@ #pragma once +#include "compat/defs.hpp" +#include "compat/enum-bitset.hpp" +#include "editor.hpp" +#include "src/global-coords.hpp" #include "draw/wireframe-mesh.hpp" #include "draw/wireframe-quad.hpp" #include "draw/wireframe-box.hpp" #include "main/floormat-app.hpp" +#include <memory> +#include <optional> + +#include <Magnum/ImGuiIntegration/Context.h> +#include <Corrade/Containers/Pointer.h> + namespace floormat { +struct chunk; +struct floormat_main; +struct tile_atlas; +struct tile_editor; + +struct cursor_state final { + std::optional<Vector2i> pixel; + std::optional<global_coords> coord; + bool in_imgui = false; +}; + struct app final : floormat_app { app(); ~app() override; + fm_DECLARE_DELETED_COPY_ASSIGNMENT(app); + fm_DECLARE_DEPRECATED_MOVE_ASSIGNMENT(app); + + void update(float dt) override; + void draw_msaa() override; + void draw() override; + + bool on_mouse_move(const mouse_move_event& event) noexcept override; + bool on_mouse_down(const mouse_button_event& event) noexcept override; + bool on_mouse_up(const mouse_button_event& event) noexcept override; + bool on_mouse_scroll(const mouse_scroll_event& event) noexcept override; + bool on_key_down(const key_event& event) noexcept override; + bool on_key_up(const key_event& event) noexcept override; + bool on_text_input_event(const text_input_event& event) noexcept override; + bool on_text_editing_event(const text_editing_event& event) noexcept override; + void on_viewport_event(const Magnum::Math::Vector2<int>& size) noexcept override; + void on_any_event(const any_event& event) noexcept override; + void on_focus_in() noexcept override; + void on_focus_out() noexcept override; + void on_mouse_leave() noexcept override; + void on_mouse_enter() noexcept override; + private: + using tile_atlas_ = std::shared_ptr<tile_atlas>; + + enum class key : int { + camera_up, camera_left, camera_right, camera_down, camera_reset, + rotate_tile, quicksave, quickload, + quit, + MAX = quit, COUNT + }; + + void make_test_chunk(chunk& c); + + void do_mouse_click(global_coords pos, int button); + void do_mouse_release(int button); + void do_mouse_move(global_coords pos); + + void do_camera(double dt); + void reset_camera_offset(); + void recalc_cursor_tile(); + void init_imgui(Vector2i size); + + void draw_cursor_tile(); + void draw_wireframe_quad(global_coords pt); + void draw_wireframe_box(global_coords pt); + void draw_ui(); + float draw_main_menu(); + void draw_editor_pane(tile_editor& type, float main_menu_height); + void draw_fps(); + void draw_cursor_coord(); + + std::shared_ptr<tile_atlas> _floor1, _floor2, _wall1, _wall2; + Containers::Pointer<floormat_main> _fmain; + ImGuiIntegration::Context _imgui{NoCreate}; wireframe_mesh<wireframe::quad> _wireframe_quad; wireframe_mesh<wireframe::box> _wireframe_box; + editor _editor; + enum_bitset<key> _keys; + cursor_state _cursor; }; } // namespace floormat |