]> git.localhorst.tv Git - blank.git/commitdiff
some more user interaction
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 12 Mar 2015 21:22:00 +0000 (22:22 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 12 Mar 2015 21:22:00 +0000 (22:22 +0100)
* mousewheel for selecting block type
* release mouse on focus loss

src/app.cpp

index 716fb3caa4ee7530ddddcaa47975de228efd58a6..0005443abe23ee64fe7a081085533ed9ae6a5c94 100644 (file)
@@ -108,11 +108,32 @@ void Application::HandleEvents() {
                        case SDL_MOUSEMOTION:
                                controller.HandleMouse(event.motion);
                                break;
+                       case SDL_MOUSEWHEEL:
+                               if (event.wheel.y < 0) {
+                                       ++place_id;
+                                       if (size_t(place_id) >= world.BlockTypes().Size()) {
+                                               place_id = 1;
+                                       }
+                                       hud.Display(*world.BlockTypes()[place_id]);
+                               } else if (event.wheel.y > 0) {
+                                       --place_id;
+                                       if (place_id <= 0) {
+                                               place_id = world.BlockTypes().Size() - 1;
+                                       }
+                                       hud.Display(*world.BlockTypes()[place_id]);
+                               }
+                               break;
                        case SDL_QUIT:
                                running = false;
                                break;
                        case SDL_WINDOWEVENT:
                                switch (event.window.event) {
+                                       case SDL_WINDOWEVENT_FOCUS_GAINED:
+                                               window.GrabMouse();
+                                               break;
+                                       case SDL_WINDOWEVENT_FOCUS_LOST:
+                                               window.ReleaseMouse();
+                                               break;
                                        case SDL_WINDOWEVENT_RESIZED:
                                                cam.Viewport(event.window.data1, event.window.data2);
                                                hud.Viewport(event.window.data1, event.window.data2);