diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/floormat-app.hpp | 2 | ||||
-rw-r--r-- | main/floormat-main-impl.cpp | 10 | ||||
-rw-r--r-- | main/floormat-main-impl.hpp | 7 | ||||
-rw-r--r-- | main/floormat-main.hpp | 6 | ||||
-rw-r--r-- | main/floormat.hpp | 4 |
5 files changed, 23 insertions, 6 deletions
diff --git a/main/floormat-app.hpp b/main/floormat-app.hpp index c74ea461..6474b66a 100644 --- a/main/floormat-app.hpp +++ b/main/floormat-app.hpp @@ -18,7 +18,7 @@ struct chunk; struct floormat_app { - floormat_app() noexcept; + explicit floormat_app() noexcept; virtual ~floormat_app() noexcept; fm_DECLARE_DELETED_COPY_ASSIGNMENT(floormat_app); diff --git a/main/floormat-main-impl.cpp b/main/floormat-main-impl.cpp index 7f2821d2..92f1c7ce 100644 --- a/main/floormat-main-impl.cpp +++ b/main/floormat-main-impl.cpp @@ -65,6 +65,7 @@ auto main_impl::make_gl_conf(const fm_settings& s) -> GLConfiguration flags |= f::RobustAccess; else if (s.gpu_debug == fm_gpu_debug::no_error) flags |= f::NoError; + return GLConfiguration{}.setFlags(flags); } void main_impl::recalc_viewport(Vector2i size) noexcept @@ -82,7 +83,7 @@ void main_impl::recalc_viewport(Vector2i size) noexcept } // NOLINTNEXTLINE(performance-unnecessary-value-param) -main_impl::main_impl(floormat_app& app, fm_settings s) noexcept : +main_impl::main_impl(floormat_app& app, fm_settings&& s) noexcept : Platform::Sdl2Application{Arguments{fake_argc, fm_fake_argv}, make_conf(s), make_gl_conf(s)}, app{app}, s{std::move(s)} @@ -209,10 +210,13 @@ const fm_settings& main_impl::settings() const noexcept { return s; } Vector2i main_impl::window_size() const noexcept { return windowSize(); } tile_shader& main_impl::shader() noexcept { return _shader; } const tile_shader& main_impl::shader() const noexcept { return _shader; } +bool main_impl::is_text_input_active() const noexcept { return const_cast<main_impl&>(*this).isTextInputActive(); } +void main_impl::start_text_input() noexcept { startTextInput(); } +void main_impl::stop_text_input() noexcept { stopTextInput(); } -floormat_main* floormat_main::create(floormat_app& app, const fm_settings& options) +floormat_main* floormat_main::create(floormat_app& app, fm_settings&& options) { - auto* ret = new main_impl(app, options); + auto* ret = new main_impl(app, std::move(options)); fm_assert(ret); return ret; } diff --git a/main/floormat-main-impl.hpp b/main/floormat-main-impl.hpp index 0406760a..9bcdc6de 100644 --- a/main/floormat-main-impl.hpp +++ b/main/floormat-main-impl.hpp @@ -17,7 +17,7 @@ struct floormat_app; struct main_impl final : Platform::Sdl2Application, floormat_main { - main_impl(floormat_app& app, fm_settings opts) noexcept; + explicit main_impl(floormat_app& app, fm_settings&& opts) noexcept; ~main_impl() noexcept override; int exec() override; @@ -46,8 +46,13 @@ struct main_impl final : Platform::Sdl2Application, floormat_main [[maybe_unused]] void keyPressEvent(KeyEvent& event) override; [[maybe_unused]] void keyReleaseEvent(KeyEvent& event) override; [[maybe_unused]] void anyEvent(SDL_Event& event) override; + void drawEvent() override; + bool is_text_input_active() const noexcept override; + void start_text_input() noexcept override; + void stop_text_input() noexcept override; + private: floormat_app& app; tile_shader _shader; diff --git a/main/floormat-main.hpp b/main/floormat-main.hpp index 3a4ed20e..66efeeec 100644 --- a/main/floormat-main.hpp +++ b/main/floormat-main.hpp @@ -31,12 +31,16 @@ struct floormat_main 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 world& world() noexcept = 0; virtual SDL_Window* window() noexcept = 0; - static floormat_main* create(floormat_app& app, const fm_settings& options); + static floormat_main* create(floormat_app& app, fm_settings&& options); protected: float _frame_time = 0; diff --git a/main/floormat.hpp b/main/floormat.hpp index d596c21b..9696cfbd 100644 --- a/main/floormat.hpp +++ b/main/floormat.hpp @@ -1,4 +1,5 @@ #pragma once +#include "compat/defs.hpp" #include <cstdint> #include <Corrade/Containers/String.h> #include <Magnum/Math/Vector2.h> @@ -11,7 +12,10 @@ enum class fm_log_level : unsigned char { quiet, normal, verbose, }; struct fm_settings { + inline fm_settings() noexcept = default; virtual ~fm_settings() noexcept; + fm_DECLARE_DEPRECATED_COPY_ASSIGNMENT(fm_settings); + fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT_(fm_settings); Magnum::Math::Vector2<int> resolution{1024, 768}; Corrade::Containers::String title{"Test"}; |