summaryrefslogtreecommitdiffhomepage
path: root/main/app.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-16 21:51:07 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-16 21:51:07 +0200
commit7ab99aabe8509e84b9b5b04aafa1e1ae20b40512 (patch)
treee86c02ccaa195b0dc239ff04e50f9efa8cb54a34 /main/app.cpp
parent0db5306c483c718076b14349f223840cce2862bd (diff)
a
Diffstat (limited to 'main/app.cpp')
-rw-r--r--main/app.cpp23
1 files changed, 15 insertions, 8 deletions
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