a ButtonPanel is able to highlight the last clicked/activated item now. A double...
authorTobias Gläßer <tobi.web@gmx.de>
Wed, 5 May 2004 12:59:18 +0000 (12:59 +0000)
committerTobias Gläßer <tobi.web@gmx.de>
Wed, 5 May 2004 12:59:18 +0000 (12:59 +0000)
SVN-Revision: 993

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

index d83ad5e..e8a6368 100644 (file)
@@ -187,6 +187,8 @@ ButtonPanel::ButtonPanel(int x, int y, int w, int h)
   rect.w = w;
   rect.h = h;
   hidden = false;
+  hlast = false;
+  //last_clicked(NULL);
 }
 
 Button* ButtonPanel::event(SDL_Event& event)
@@ -197,7 +199,11 @@ Button* ButtonPanel::event(SDL_Event& event)
     {
       (*it)->event(event);
       if((*it)->state != BUTTON_NONE)
+      {
+        if(hlast && (*it)->state == BUTTON_CLICKED)
+       last_clicked = it;
         return (*it);
+       }
     }
     return NULL;
   }
@@ -225,6 +231,10 @@ void ButtonPanel::draw()
     for(std::vector<Button*>::iterator it = item.begin(); it != item.end(); ++it)
     {
       (*it)->draw();
+      if(hlast && it == last_clicked)
+      {
+      fillrect((*it)->get_pos().x,(*it)->get_pos().y,(*it)->get_pos().w,(*it)->get_pos().h,100,100,100,128);
+      }
     }
   }
 }
@@ -261,3 +271,10 @@ Button* ButtonPanel::manipulate_button(int i)
   else
     return item[i];
 }
+
+void ButtonPanel::highlight_last(bool b)
+{
+hlast = b;
+}
+
+
index 213fe71..0ef2231 100644 (file)
@@ -72,12 +72,15 @@ public:
   Button* button_panel_event(SDL_Event& event);
   void set_button_size(int w, int h);
   Button* manipulate_button(int i);
+  void highlight_last(bool b);
 
 private:
   int bw, bh;
+  bool hlast;
   bool hidden;
   SDL_Rect rect;
   std::vector<Button*> item;
+  std::vector<Button*>::iterator last_clicked;
 };
 
 #endif /*SUPERTUX_BUTTON_H*/
index d9b6283..0a8f5f3 100644 (file)
@@ -485,7 +485,7 @@ void le_init_menus()
   level_settings_menu->additem(MN_ACTION,"Apply Changes",0,0,MNID_APPLY);
 
   select_tilegroup_menu->arrange_left = true;
-  select_tilegroup_menu->additem(MN_LABEL,"Select Tilegroup",0,0);
+  select_tilegroup_menu->additem(MN_LABEL,"Tilegroup",0,0);
   select_tilegroup_menu->additem(MN_HL,"",0,0);
   std::vector<TileGroup>* tilegroups = TileManager::tilegroups();
   int tileid = 1;
@@ -529,7 +529,7 @@ void le_init_menus()
   select_tilegroup_menu->additem(MN_HL,"",0,0);
 
   select_objects_menu->arrange_left = true;
-  select_objects_menu->additem(MN_LABEL,"Select Objects",0,0);
+  select_objects_menu->additem(MN_LABEL,"Objects",0,0);
   select_objects_menu->additem(MN_HL,"",0,0);
   select_objects_menu->additem(MN_ACTION,"BadGuys",0,0,1);
   objects_map["BadGuys"] = new ButtonPanel(screen->w - 64,96, 64, 318);
@@ -585,9 +585,10 @@ int le_init()
 
   le_tilemap_panel = new ButtonPanel(screen->w-64,screen->h-32,32,32);
   le_tilemap_panel->set_button_size(32,10);
-  le_tilemap_panel->additem(new Button("/images/icons/bkgrd.png","Background",SDLK_F4,0,0),TM_BG);
-  le_tilemap_panel->additem(new Button("/images/icons/intact.png","Interactive",SDLK_F4,0,0),TM_IA);
-  le_tilemap_panel->additem(new Button("/images/icons/frgrd.png","Foreground",SDLK_F4,0,0),TM_FG);
+  le_tilemap_panel->additem(new Button("/images/icons/bkgrd.png","Background",SDLK_b,0,0),TM_BG);
+  le_tilemap_panel->additem(new Button("/images/icons/intact.png","Interactive",SDLK_i,0,0),TM_IA);
+  le_tilemap_panel->additem(new Button("/images/icons/frgrd.png","Foreground",SDLK_f,0,0),TM_FG);
+  le_tilemap_panel->highlight_last(true);
     
   le_current.Init();