summaryrefslogtreecommitdiffhomepage
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/debug.cpp4
-rw-r--r--main/floormat-app.hpp6
-rw-r--r--main/floormat-events.cpp32
-rw-r--r--main/floormat-events.hpp3
-rw-r--r--main/floormat-main-impl.cpp1
-rw-r--r--main/floormat-main-impl.hpp3
-rw-r--r--main/floormat-main.hpp3
7 files changed, 29 insertions, 23 deletions
diff --git a/main/debug.cpp b/main/debug.cpp
index 7e012b9d..efc47a6c 100644
--- a/main/debug.cpp
+++ b/main/debug.cpp
@@ -58,7 +58,7 @@ void main_impl::_debug_callback(GL::DebugOutput::Source src, GL::DebugOutput::Ty
static_cast<const main_impl*>(self)->debug_callback(src, type, id, severity, str);
}
-void main_impl::register_debug_callback() noexcept
+void* main_impl::register_debug_callback() noexcept
{
GL::DebugOutput::setCallback(_debug_callback, this);
@@ -66,6 +66,8 @@ void main_impl::register_debug_callback() noexcept
/* Disable rather spammy "Buffer detailed info" debug messages on NVidia drivers */
GL::DebugOutput::setEnabled(GL::DebugOutput::Source::Api, GL::DebugOutput::Type::Other, {131185}, false);
#endif
+
+ return nullptr;
}
} // namespace floormat
diff --git a/main/floormat-app.hpp b/main/floormat-app.hpp
index 805718a0..f4f7cc25 100644
--- a/main/floormat-app.hpp
+++ b/main/floormat-app.hpp
@@ -26,11 +26,9 @@ struct floormat_app
virtual void draw() = 0;
virtual bool on_mouse_move(const mouse_move_event& event) noexcept = 0;
- virtual bool on_mouse_down(const mouse_button_event& event) noexcept = 0;
- virtual bool on_mouse_up(const mouse_button_event& event) noexcept = 0;
+ virtual bool on_mouse_up_down(const mouse_button_event& event, bool is_down) noexcept = 0;
virtual bool on_mouse_scroll(const mouse_scroll_event& event) noexcept = 0;
- virtual bool on_key_down(const key_event& event) noexcept = 0;
- virtual bool on_key_up(const key_event& event) noexcept = 0;
+ virtual bool on_key_up_down(const key_event& event, bool is_down) noexcept = 0;
virtual bool 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;
diff --git a/main/floormat-events.cpp b/main/floormat-events.cpp
index d0ed797b..9091e663 100644
--- a/main/floormat-events.cpp
+++ b/main/floormat-events.cpp
@@ -17,19 +17,21 @@ void main_impl::viewportEvent(Platform::Sdl2Application::ViewportEvent& event)
void main_impl::mousePressEvent(Platform::Sdl2Application::MouseEvent& event)
{
- if (app.on_mouse_down(mouse_button_event{event.position(),
- (SDL_Keymod)(std::uint16_t)event.modifiers(),
- mouse_button(event.button()),
- std::uint8_t(std::min(255, event.clickCount()))}))
+ if (app.on_mouse_up_down({event.position(),
+ (SDL_Keymod)(std::uint16_t)event.modifiers(),
+ mouse_button(event.button()),
+ std::uint8_t(std::min(255, event.clickCount()))},
+ true))
return event.setAccepted();
}
void main_impl::mouseReleaseEvent(Platform::Sdl2Application::MouseEvent& event)
{
- if (app.on_mouse_up({event.position(),
- (SDL_Keymod)(std::uint16_t)event.modifiers(),
- mouse_button(event.button()),
- std::uint8_t(std::min(255, event.clickCount()))}))
+ if (app.on_mouse_up_down({event.position(),
+ (SDL_Keymod)(std::uint16_t)event.modifiers(),
+ mouse_button(event.button()),
+ std::uint8_t(std::min(255, event.clickCount()))},
+ false))
return event.setAccepted();
}
@@ -62,17 +64,19 @@ void main_impl::textEditingEvent(Platform::Sdl2Application::TextEditingEvent& ev
void main_impl::keyPressEvent(Platform::Sdl2Application::KeyEvent& event)
{
- if (app.on_key_down({(SDL_Keycode)(std::uint32_t)event.key(),
- (SDL_Keymod)(std::uint16_t)event.modifiers(),
- true, event.isRepeated()}))
+ if (app.on_key_up_down({(SDL_Keycode)(std::uint32_t)event.key(),
+ (SDL_Keymod)(std::uint16_t)event.modifiers(),
+ event.isRepeated()},
+ true))
return event.setAccepted();
}
void main_impl::keyReleaseEvent(Platform::Sdl2Application::KeyEvent& event)
{
- if (app.on_key_up({(SDL_Keycode)(std::uint32_t)event.key(),
- (SDL_Keymod)(std::uint16_t)event.modifiers(),
- false, event.isRepeated()}))
+ if (app.on_key_up_down({(SDL_Keycode)(std::uint32_t)event.key(),
+ (SDL_Keymod)(std::uint16_t)event.modifiers(),
+ event.isRepeated()},
+ false))
return event.setAccepted();
}
diff --git a/main/floormat-events.hpp b/main/floormat-events.hpp
index 64f41efd..97c5f171 100644
--- a/main/floormat-events.hpp
+++ b/main/floormat-events.hpp
@@ -46,8 +46,7 @@ struct text_editing_event final {
struct key_event final {
SDL_Keycode key = SDLK_UNKNOWN;
SDL_Keymod mods = KMOD_NONE;
- std::uint8_t is_down : 1 = false;
- std::uint8_t is_repeated : 1 = false;
+ std::uint8_t is_repeated = false;
};
struct any_event final {
diff --git a/main/floormat-main-impl.cpp b/main/floormat-main-impl.cpp
index 0945daf4..7ba31490 100644
--- a/main/floormat-main-impl.cpp
+++ b/main/floormat-main-impl.cpp
@@ -219,6 +219,7 @@ SDL_Window* main_impl::window() noexcept
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; }
floormat_main* floormat_main::create(floormat_app& app, const fm_options& options)
{
diff --git a/main/floormat-main-impl.hpp b/main/floormat-main-impl.hpp
index e84a0527..4ab6ef27 100644
--- a/main/floormat-main-impl.hpp
+++ b/main/floormat-main-impl.hpp
@@ -24,7 +24,8 @@ struct main_impl final : Platform::Sdl2Application, floormat_main
Magnum::Math::Vector2<int> window_size() const noexcept override;
tile_shader& shader() noexcept override;
- void register_debug_callback() noexcept override;
+ const tile_shader& shader() const noexcept override;
+ void* register_debug_callback() noexcept override;
struct world& world() noexcept override;
SDL_Window* window() noexcept override;
diff --git a/main/floormat-main.hpp b/main/floormat-main.hpp
index ae08744e..b569c5d7 100644
--- a/main/floormat-main.hpp
+++ b/main/floormat-main.hpp
@@ -24,7 +24,8 @@ struct floormat_main
virtual Magnum::Math::Vector2<int> window_size() const noexcept = 0;
virtual tile_shader& shader() noexcept = 0;
- virtual void register_debug_callback() noexcept = 0;
+ virtual const tile_shader& shader() const noexcept = 0;
+ virtual void* register_debug_callback() noexcept = 0;
constexpr float smoothed_dt() const noexcept { return _frame_time; }
virtual global_coords pixel_to_tile(Vector2d position) const noexcept = 0;