From: Tobias Gläßer Date: Wed, 5 May 2004 12:59:18 +0000 (+0000) Subject: a ButtonPanel is able to highlight the last clicked/activated item now. A double... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=6a0699dd6245ffdac2898b80afc0b6fa612e1f58;p=supertux.git a ButtonPanel is able to highlight the last clicked/activated item now. A double/tripple shortcut was replaced in the leveleditor. SVN-Revision: 993 --- diff --git a/src/button.cpp b/src/button.cpp index d83ad5e45..e8a636892 100644 --- a/src/button.cpp +++ b/src/button.cpp @@ -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::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; +} + + diff --git a/src/button.h b/src/button.h index 213fe7124..0ef22311a 100644 --- a/src/button.h +++ b/src/button.h @@ -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 item; + std::vector::iterator last_clicked; }; #endif /*SUPERTUX_BUTTON_H*/ diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index d9b6283da..0a8f5f365 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -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* 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();