diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-25 16:19:21 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-25 16:19:21 +0200 |
| commit | a00ac8b5fed9d03cb2b3eafb4cd7d04546e341b1 (patch) | |
| tree | 18bfeda1abd43a2a0b81f2ad4b909c30b9bfb419 /main | |
| parent | 45f2533113a0dfe4cf8a7723a1c76099d0a6d091 (diff) | |
move some headers around
Diffstat (limited to 'main')
| -rw-r--r-- | main/app.cpp (renamed from main/floormat-app.cpp) | 4 | ||||
| -rw-r--r-- | main/debug.cpp | 2 | ||||
| -rw-r--r-- | main/events.cpp (renamed from main/floormat-events.cpp) | 6 | ||||
| -rw-r--r-- | main/floormat-app.hpp | 49 | ||||
| -rw-r--r-- | main/floormat-events.hpp | 56 | ||||
| -rw-r--r-- | main/floormat-main.hpp | 48 | ||||
| -rw-r--r-- | main/floormat.hpp | 36 | ||||
| -rw-r--r-- | main/main-impl.cpp (renamed from main/floormat-main-impl.cpp) | 5 | ||||
| -rw-r--r-- | main/main-impl.hpp (renamed from main/floormat-main-impl.hpp) | 4 |
9 files changed, 10 insertions, 200 deletions
diff --git a/main/floormat-app.cpp b/main/app.cpp index 2f69c0da..91b4ccaf 100644 --- a/main/floormat-app.cpp +++ b/main/app.cpp @@ -1,5 +1,5 @@ -#include "floormat-app.hpp" -#include "floormat.hpp" +#include "floormat/app.hpp" +#include "floormat/settings.hpp" namespace floormat { diff --git a/main/debug.cpp b/main/debug.cpp index f46c63d5..a8483cd0 100644 --- a/main/debug.cpp +++ b/main/debug.cpp @@ -1,4 +1,4 @@ -#include "floormat-main-impl.hpp" +#include "main-impl.hpp" #include <chrono> namespace floormat { diff --git a/main/floormat-events.cpp b/main/events.cpp index 0ef380fb..ac8f0766 100644 --- a/main/floormat-events.cpp +++ b/main/events.cpp @@ -1,6 +1,6 @@ -#include "floormat-main-impl.hpp" -#include "floormat-app.hpp" -#include "floormat-events.hpp" +#include "main-impl.hpp" +#include "floormat/app.hpp" +#include "floormat/events.hpp" #include "compat/assert.hpp" #include <SDL_events.h> #include <SDL_video.h> diff --git a/main/floormat-app.hpp b/main/floormat-app.hpp deleted file mode 100644 index 60ecc52c..00000000 --- a/main/floormat-app.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -namespace Magnum::Math { template<typename T> class Vector2; } - -namespace floormat { - -struct mouse_move_event; -struct mouse_button_event; -struct mouse_scroll_event; -struct key_event; -struct text_input_event; -struct text_editing_event; -struct any_event; - -struct chunk_coords; -struct chunk; - -struct floormat_app -{ - explicit floormat_app() noexcept; - virtual ~floormat_app() noexcept; - - floormat_app(const floormat_app&) = delete; - floormat_app& operator=(const floormat_app&) = delete; - [[deprecated]] floormat_app(floormat_app&&) = default; - [[deprecated]] floormat_app& operator=(floormat_app&&) = default; - - virtual void update(float dt) = 0; - virtual void maybe_initialize_chunk(const chunk_coords& pos, chunk& c) = 0; - virtual void draw_msaa(); - virtual void draw() = 0; - - virtual void on_mouse_move(const mouse_move_event& event) noexcept = 0; - virtual void on_mouse_up_down(const mouse_button_event& event, bool is_down) noexcept = 0; - virtual void on_mouse_scroll(const mouse_scroll_event& event) noexcept = 0; - virtual void on_key_up_down(const key_event& event, bool is_down) noexcept = 0; - virtual void on_text_input_event(const text_input_event& event) noexcept = 0; - //virtual bool on_text_editing_event(const text_editing_event& event) noexcept = 0; - virtual void on_viewport_event(const Magnum::Math::Vector2<int>& size) noexcept = 0; - virtual void on_any_event(const any_event& event) noexcept = 0; - virtual void on_focus_in() noexcept = 0; - virtual void on_focus_out() noexcept = 0; - virtual void on_mouse_leave() noexcept = 0; - virtual void on_mouse_enter() noexcept = 0; -}; - -inline void floormat_app::draw_msaa() {} - -} // namespace floormat diff --git a/main/floormat-events.hpp b/main/floormat-events.hpp deleted file mode 100644 index 97c5f171..00000000 --- a/main/floormat-events.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once -#include <Magnum/Math/Vector2.h> -#include <SDL_keycode.h> -#include <SDL_mouse.h> -#include <SDL_events.h> - -namespace floormat { - -enum mouse_button : std::uint8_t { - mouse_button_none = 0, - mouse_button_left = SDL_BUTTON_LMASK, - mouse_button_middle = SDL_BUTTON_MMASK, - mouse_button_right = SDL_BUTTON_RMASK, - mouse_button_x1 = SDL_BUTTON_X1MASK, - mouse_button_x2 = SDL_BUTTON_X2MASK, -}; - -struct mouse_button_event final { - Vector2i position; - SDL_Keymod mods = KMOD_NONE; - mouse_button button = mouse_button_none; - std::uint8_t click_count = 0; -}; - -struct mouse_move_event final { - Vector2i position, relative_position; - mouse_button buttons = mouse_button_none; - SDL_Keymod mods = KMOD_NONE; -}; - -struct mouse_scroll_event final { - Magnum::Vector2 offset; - Vector2i position; - SDL_Keymod mods = KMOD_NONE; -}; - -struct text_input_event final { - Containers::StringView text; -}; - -struct text_editing_event final { - Containers::StringView text; - std::int32_t start = 0, length = 0; -}; - -struct key_event final { - SDL_Keycode key = SDLK_UNKNOWN; - SDL_Keymod mods = KMOD_NONE; - std::uint8_t is_repeated = false; -}; - -struct any_event final { - SDL_Event event = {}; -}; - -} // namespace floormat diff --git a/main/floormat-main.hpp b/main/floormat-main.hpp deleted file mode 100644 index 6ba3b4c8..00000000 --- a/main/floormat-main.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#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_time; } - 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; - - [[nodiscard]] static floormat_main* create(floormat_app& app, fm_settings&& options); - -protected: - float _frame_time = 0; -}; - -} // namespace floormat diff --git a/main/floormat.hpp b/main/floormat.hpp deleted file mode 100644 index 3bf4b492..00000000 --- a/main/floormat.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "compat/defs.hpp" -#include <cstdint> -#include <Corrade/Containers/String.h> -#include <Magnum/Math/Vector2.h> - -namespace floormat { - -enum class fm_gpu_debug : char { no_error = 1, off, on, robust, }; -enum class fm_tristate : char { maybe = -1, on, off }; -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"}; - Corrade::Containers::String disabled_extensions; // TODO - std::uint8_t msaa_samples = 16; - fm_tristate vsync = fm_tristate::maybe; - fm_gpu_debug gpu_debug = fm_gpu_debug::on; - fm_log_level log_level = fm_log_level::normal; - std::uint8_t resizable : 1 = true, - fullscreen : 1 = false, - fullscreen_desktop : 1 = false, - borderless : 1 = false, - maximized : 1 = false, - msaa : 1 = true; -}; - -} // namespace floormat - diff --git a/main/floormat-main-impl.cpp b/main/main-impl.cpp index 1f35024e..856635d2 100644 --- a/main/floormat-main-impl.cpp +++ b/main/main-impl.cpp @@ -1,6 +1,5 @@ -#include "floormat-main-impl.hpp" -#include "floormat.hpp" -#include "floormat-app.hpp" +#include "main-impl.hpp" +#include "floormat/app.hpp" #include "compat/assert.hpp" #include "compat/fpu.hpp" #include "src/chunk.hpp" diff --git a/main/floormat-main-impl.hpp b/main/main-impl.hpp index e0a7f1e1..39a877fe 100644 --- a/main/floormat-main-impl.hpp +++ b/main/main-impl.hpp @@ -1,6 +1,6 @@ #pragma once -#include "floormat.hpp" -#include "floormat-main.hpp" +#include "floormat/main.hpp" +#include "floormat/settings.hpp" #include "src/world.hpp" #include "draw/floor-mesh.hpp" #include "draw/wall-mesh.hpp" |
