LevelEditor tilegroup/object select by wheelup/wheeldown on buttons. Support for...
authorTobias Gläßer <tobi.web@gmx.de>
Wed, 5 May 2004 16:59:41 +0000 (16:59 +0000)
committerTobias Gläßer <tobi.web@gmx.de>
Wed, 5 May 2004 16:59:41 +0000 (16:59 +0000)
SVN-Revision: 998

src/button.cpp
src/button.h
src/leveleditor.cpp

index ff0c8d2..b58e63e 100644 (file)
@@ -126,11 +126,21 @@ void Button::event(SDL_Event &event)
         event.button.y < rect.y || event.button.y >= rect.y + rect.h)
       return;
 
-    if(event.button.button != SDL_BUTTON_LEFT)
+    if(event.button.button == SDL_BUTTON_RIGHT)
     {
       show_info = true;
       return;
     }
+    else if(event.button.button == 4) /* Mouse wheel up. */
+    {
+      state = BUTTON_WHEELUP;
+      return;
+    }
+    else if(event.button.button == 5) /* Mouse wheel down. */
+    {
+      state = BUTTON_WHEELDOWN;
+      return;
+    }
 
     if(event.type == SDL_MOUSEBUTTONDOWN)
       state = BUTTON_PRESSED;
index 0ef2231..b97f9d6 100644 (file)
@@ -28,7 +28,9 @@ enum ButtonState {
   BUTTON_NONE = -1,
   BUTTON_CLICKED,
   BUTTON_PRESSED,
-  BUTTON_HOVER
+  BUTTON_HOVER,
+  BUTTON_WHEELUP,
+  BUTTON_WHEELDOWN
 };
 
 class ButtonPanel;
index c87aeac..c413505 100644 (file)
@@ -1184,21 +1184,90 @@ void le_checkevents()
             if(le_select_mode_two_bt->get_state() == BUTTON_CLICKED)
               le_selection_mode = SQUARE;
           }
-
+          ButtonPanelMap::iterator it;
           le_tilegroup_bt->event(event);
-          if(le_tilegroup_bt->get_state() == BUTTON_CLICKED)
+         switch (le_tilegroup_bt->get_state())
           {
+          case BUTTON_CLICKED:
             Menu::set_current(select_tilegroup_menu);
             select_tilegroup_menu_effect.start(200);
             select_tilegroup_menu->set_pos(screen->w - 64,100,-0.5,0.5);
+           break;
+          case BUTTON_WHEELUP:
+           it = tilegroups_map.find(cur_tilegroup);
+           if(it == tilegroups_map.end())
+           {
+           cur_tilegroup = tilegroups_map.begin()->first;
+            cur_objects.clear();           
+           break;
+           }
+           if(++it != tilegroups_map.end())
+           cur_tilegroup = (*it).first;
+           else
+           cur_tilegroup = tilegroups_map.begin()->first;
+           
+            cur_objects.clear();
+            break;
+          case BUTTON_WHEELDOWN:
+           it = tilegroups_map.find(cur_tilegroup);
+           if(it == tilegroups_map.begin())
+           {
+           cur_tilegroup = tilegroups_map.rbegin()->first;
+            cur_objects.clear();           
+           break;
+           }
+           if(--it != --tilegroups_map.begin())
+           cur_tilegroup = (*it).first;
+           else
+           cur_tilegroup = tilegroups_map.rbegin()->first;
+           
+            cur_objects.clear();
+            break;
+          default:
+            break;
           }
 
           le_objects_bt->event(event);
-          if(le_objects_bt->get_state() == BUTTON_CLICKED)
+          switch (le_objects_bt->get_state())
           {
+          case BUTTON_CLICKED:
             Menu::set_current(select_objects_menu);
             select_objects_menu_effect.start(200);
             select_objects_menu->set_pos(screen->w - 64,100,-0.5,0.5);
+            break;
+          case BUTTON_WHEELUP:
+           it = objects_map.find(cur_objects);
+           if(it == objects_map.end())
+           {
+           cur_objects = objects_map.begin()->first;
+            cur_tilegroup.clear();         
+           break;
+           }       
+           if(++it != objects_map.end())
+           cur_objects = (*it).first;
+           else
+           cur_objects = objects_map.begin()->first;
+           
+            cur_tilegroup.clear();
+            break;
+          case BUTTON_WHEELDOWN:
+           it = objects_map.find(cur_objects);
+           if(it == objects_map.begin())
+           {
+           cur_objects = objects_map.rbegin()->first;
+            cur_tilegroup.clear();         
+           break;
+           }
+           if(--it != --objects_map.begin())
+           cur_objects = (*it).first;
+           else
+           cur_objects = objects_map.rbegin()->first;
+           
+            cur_tilegroup.clear();
+            break;       
+            break;
+          default:
+            break;
           }
 
           le_settings_bt->event(event);
@@ -1278,7 +1347,7 @@ void le_checkevents()
               le_current_level->badguy_data.push_back(&le_world.bad_guys.back());
             }
           }
-         le_mouse_clicked[LEFT] = false;
+          le_mouse_clicked[LEFT] = false;
         }
       }
     }