diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-13 04:36:09 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-13 04:36:09 +0100 |
commit | e75f99e22197008bd8a2e6df70c5b7554698300e (patch) | |
tree | d233b819a862fa482a663bb3b60c1a5b6d5474c9 /editor | |
parent | 860189e34fb24cc908c306489bf2d62e6c13f5a8 (diff) |
dw
Diffstat (limited to 'editor')
-rw-r--r-- | editor/app.cpp | 11 | ||||
-rw-r--r-- | editor/app.hpp | 39 | ||||
-rw-r--r-- | editor/imgui.cpp | 6 |
3 files changed, 31 insertions, 25 deletions
diff --git a/editor/app.cpp b/editor/app.cpp index 7505ff84..c6c298b3 100644 --- a/editor/app.cpp +++ b/editor/app.cpp @@ -1,19 +1,20 @@ #include "app.hpp" #include "compat/assert.hpp" #include "compat/sysexits.hpp" -#include "floormat/main.hpp" -#include "floormat/settings.hpp" -#include "loader/loader.hpp" #include "src/world.hpp" #include "src/anim-atlas.hpp" #include "src/critter.hpp" -#include <cerrno> +#include "floormat/main.hpp" +#include "floormat/settings.hpp" +#include "loader/loader.hpp" +#include "draw/wireframe-meshes.hpp" #include <cstdlib> #include <cstring> #include <algorithm> #include <Corrade/Containers/StringIterable.h> #include <Corrade/Utility/Arguments.h> #include <Corrade/Utility/Move.h> +#include <Magnum/ImGuiIntegration/Context.h> namespace floormat { @@ -30,6 +31,7 @@ const cursor_state& app::cursor_state() { return cursor; } app::app(fm_settings&& opts) : M{floormat_main::create(*this, Utility::move(opts))}, + _wireframe{InPlaceInit}, _tests{tests_data_::make()} { reset_world(); @@ -43,7 +45,6 @@ app::app(fm_settings&& opts) : app::~app() { - } void app::reset_world() diff --git a/editor/app.hpp b/editor/app.hpp index 09198c36..e0dc36e0 100644 --- a/editor/app.hpp +++ b/editor/app.hpp @@ -2,20 +2,26 @@ #include "compat/defs.hpp" #include "compat/enum-bitset.hpp" #include "editor.hpp" -#include "draw/wireframe.hpp" -#include "draw/quad-floor.hpp" -#include "draw/quad-wall-n.hpp" -#include "draw/quad-wall-w.hpp" -#include "draw/quad.hpp" -#include "draw/box.hpp" #include "floormat/app.hpp" #include "keys.hpp" #include "src/object-id.hpp" #include "tests.hpp" #include <memory> +#include <array> #include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Optional.h> -#include <Magnum/ImGuiIntegration/Context.h> + +namespace Magnum::GL { +template<UnsignedInt dimensions> class Texture; +typedef Texture<2> Texture2D; +} // namespace Magnum::GL + +namespace Magnum::ImGuiIntegration { class Context; } + +namespace floormat::wireframe { +GL::Texture2D make_constant_texture(); +struct meshes; +} // namespace floormat::wireframe namespace floormat { @@ -69,8 +75,6 @@ struct app final : floormat_app std::shared_ptr<critter> ensure_player_character(world& w); private: - using key_set = enum_bitset<key, key_COUNT>; - app(fm_settings&& opts); fm_DECLARE_DELETED_COPY_ASSIGNMENT(app); @@ -109,9 +113,6 @@ private: void do_mouse_up_down(uint8_t button, bool is_down, int modifiers); void do_mouse_scroll(int offset); - void do_camera(float dt, const key_set& cmds, int mods); - void reset_camera_offset(); - void do_quicksave(); void do_quickload(); void do_new_file(); @@ -139,6 +140,7 @@ private: void kill_popups(bool hard); void render_menu(); + using key_set = enum_bitset<key, key_COUNT>; void do_key(key k, int mods); void do_key(key k); void do_set_mode(editor_mode mode); @@ -150,6 +152,9 @@ private: void clear_non_global_keys(); void clear_non_repeated_keys(); + void do_camera(float dt, const key_set& cmds, int mods); + void reset_camera_offset(); + [[nodiscard]] bool tests_handle_key(const key_event& e, bool is_down); [[nodiscard]] bool tests_handle_mouse_click(const mouse_button_event& e, bool is_down); [[nodiscard]] bool tests_handle_mouse_move(const mouse_move_event& e); @@ -161,14 +166,10 @@ private: tests_data& tests(); Pointer<floormat_main> M; + Pointer<floormat::wireframe::meshes> _wireframe; + Pointer<ImGuiIntegration::Context> _imgui; Pointer<tests_data_> _tests; - ImGuiIntegration::Context _imgui{NoCreate}; - GL::Texture2D _wireframe_texture = wireframe::make_constant_texture(); - wireframe_mesh<wireframe::quad_floor> _wireframe_quad {_wireframe_texture}; - wireframe_mesh<wireframe::quad_wall_n> _wireframe_wall_n {_wireframe_texture}; - wireframe_mesh<wireframe::quad_wall_w> _wireframe_wall_w {_wireframe_texture}; - wireframe_mesh<wireframe::box> _wireframe_box {_wireframe_texture}; - wireframe_mesh<wireframe::quad> _wireframe_rect {_wireframe_texture}; + editor _editor{this}; key_set keys; std::array<int, key_set::COUNT> key_modifiers = {}; diff --git a/editor/imgui.cpp b/editor/imgui.cpp index 440c9928..1e9dfc89 100644 --- a/editor/imgui.cpp +++ b/editor/imgui.cpp @@ -9,6 +9,7 @@ #include "imgui-raii.hpp" #include "src/light.hpp" #include <Magnum/GL/Renderer.h> +#include <Magnum/ImGuiIntegration/Context.h> #include <imgui.h> namespace floormat { @@ -19,8 +20,11 @@ bool popup_target::operator==(const popup_target&) const = default; void app::init_imgui(Vector2i size) { - if (!_imgui.context()) + if (!_imgui) [[unlikely]] + { _imgui = ImGuiIntegration::Context(Vector2{size}, size, size); + fm_assert(_imgui.context()); + } else _imgui.relayout(Vector2{size}, size, size); } |