From 7ab99aabe8509e84b9b5b04aafa1e1ae20b40512 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 16 Oct 2022 21:51:07 +0200 Subject: a --- main/app.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'main/app.cpp') diff --git a/main/app.cpp b/main/app.cpp index 9537bf58..b412c81b 100644 --- a/main/app.cpp +++ b/main/app.cpp @@ -32,6 +32,7 @@ app::app(const Arguments& arguments): SDL_MaximizeWindow(window()); timeline.start(); } + void app::viewportEvent(Platform::Sdl2Application::ViewportEvent& event) { update_window_scale(event.windowSize()); @@ -44,6 +45,20 @@ void app::mousePressEvent(Platform::Sdl2Application::MouseEvent& event) { if (_imgui.handleMousePressEvent(event)) return event.setAccepted(); + { + const auto tile = pixel_to_tile(Vector2(*_cursor_pos)); + int button; + switch (event.button()) + { + case MouseEvent::Button::Left: button = 0; break; + case MouseEvent::Button::Right: button = 1; break; + case MouseEvent::Button::Middle: button = 2; break; + case MouseEvent::Button::X1: button = 5; break; + case MouseEvent::Button::X2: button = 6; break; + default: button = -1; break; + } + do_mouse_click(tile, button); + } } void app::mouseReleaseEvent(Platform::Sdl2Application::MouseEvent& event) @@ -114,12 +129,4 @@ void app::event_mouse_enter() { } -void app::update(float dt) -{ - do_camera(dt); - do_menu(); - if (keys[key::quit]) - Platform::Sdl2Application::exit(0); -} - } // namespace floormat -- cgit v1.2.3