diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-05 08:17:00 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-05 08:17:00 +0100 |
commit | 2679d49a53a3f9825ce855f6ed25b3b045ec5aa1 (patch) | |
tree | 9767e933c25aa6a9a0b5b692890d655ea5029e24 | |
parent | 38b4c1864fddb4ed552f2f4217395bd02e21c5fe (diff) |
editor, main: use less sdl includes
-rw-r--r-- | editor/CMakeLists.txt | 11 | ||||
-rw-r--r-- | editor/app.hpp | 2 | ||||
-rw-r--r-- | editor/events.cpp | 5 | ||||
-rw-r--r-- | editor/precomp.hpp | 2 | ||||
-rw-r--r-- | floormat/main.hpp | 1 | ||||
-rw-r--r-- | main/CMakeLists.txt | 9 | ||||
-rw-r--r-- | main/events.cpp | 7 |
7 files changed, 25 insertions, 12 deletions
diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 2119ee9e..f94c21e1 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -12,6 +12,10 @@ endif() add_library(${self}_o OBJECT "${res}" "${sources}") target_link_libraries(${self}_o PUBLIC MagnumIntegration::ImGui fmt::fmt nlohmann_json::nlohmann_json) +if(WIN32) + target_sources(${self}_o PRIVATE "../main/floormat.rc") +endif() + if(NOT SDL2_INCLUDE_DIRS) if(NOT TARGET SDL2::SDL2) find_package(SDL2 QUIET REQUIRED) @@ -19,11 +23,10 @@ if(NOT SDL2_INCLUDE_DIRS) get_target_property(SDL2_INCLUDE_DIRS SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES) endif() endif() -target_include_directories(${self}_o SYSTEM PRIVATE "${SDL2_INCLUDE_DIRS}") - -if(WIN32) - target_sources(${self}_o PRIVATE "../main/floormat.rc") +if(FLOORMAT_PRECOMPILED-HEADERS) + include_directories("${SDL2_INCLUDE_DIRS}") endif() +set_property(SOURCE "events.cpp" APPEND PROPERTY INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}") add_executable(${self} dummy.cc) target_link_libraries(${self} PRIVATE ${self}_o floormat-main floormat-serialize floormat-draw floormat) diff --git a/editor/app.hpp b/editor/app.hpp index 776b0fcf..c34b7ebd 100644 --- a/editor/app.hpp +++ b/editor/app.hpp @@ -107,7 +107,7 @@ private: void do_key(key k, int mods); void do_key(key k); void apply_commands(const key_set& k); - static int get_key_modifiers(); + int get_key_modifiers(); void clear_keys(key min_inclusive, key max_exclusive); void clear_keys(); void clear_non_global_keys(); diff --git a/editor/events.cpp b/editor/events.cpp index 426acac4..6bf4b3e7 100644 --- a/editor/events.cpp +++ b/editor/events.cpp @@ -10,9 +10,6 @@ #include <Magnum/Platform/Sdl2Application.h> #include <Magnum/ImGuiIntegration/Context.hpp> -#include <SDL_keycode.h> -#include <SDL_events.h> - namespace floormat { void app::on_focus_in() noexcept {} @@ -198,7 +195,7 @@ void app::do_key(floormat::key k) int app::get_key_modifiers() { - return fixup_mods(SDL_GetModState()); + return fixup_mods(M->get_mods()); } } // namespace floormat diff --git a/editor/precomp.hpp b/editor/precomp.hpp index 775f59e7..8949f3ed 100644 --- a/editor/precomp.hpp +++ b/editor/precomp.hpp @@ -13,6 +13,4 @@ #if __has_include(<SDL.h>) #include <Magnum/Platform/Sdl2Application.h> -#include <SDL_keycode.h> -#include <SDL_events.h> #endif diff --git a/floormat/main.hpp b/floormat/main.hpp index 6c933037..7803cd3c 100644 --- a/floormat/main.hpp +++ b/floormat/main.hpp @@ -61,6 +61,7 @@ struct floormat_main virtual struct world& world() noexcept = 0; virtual SDL_Window* window() noexcept = 0; Vector2 dpi_scale() const noexcept { return _dpi_scale; } + static int get_mods() noexcept; [[nodiscard]] static floormat_main* create(floormat_app& app, fm_settings&& options); diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index b40015e8..50e1bc91 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -10,6 +10,15 @@ target_link_libraries(${self} PUBLIC fmt::fmt ) +if(NOT SDL2_INCLUDE_DIRS) + if(NOT TARGET SDL2::SDL2) + find_package(SDL2 QUIET REQUIRED) + else() + get_target_property(SDL2_INCLUDE_DIRS SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES) + endif() +endif() +include_directories("${SDL2_INCLUDE_DIRS}") + if(FLOORMAT_PRECOMPILED-HEADERS) target_precompile_headers(${self} PRIVATE precomp.hpp) endif() diff --git a/main/events.cpp b/main/events.cpp index 11076b54..17db862f 100644 --- a/main/events.cpp +++ b/main/events.cpp @@ -3,7 +3,7 @@ #include "floormat/events.hpp" #include <cstring> #include <SDL_events.h> -//#include <SDL_video.h> +#include <SDL_keyboard.h> namespace floormat { @@ -104,4 +104,9 @@ void main_impl::anyEvent(SDL_Event& event) return app.on_any_event(make_any_event(event)); } +int floormat_main::get_mods() noexcept +{ + return (int)SDL_GetModState(); +} + } // namespace floormat |