From: Tobias Gläßer Date: Wed, 5 May 2004 16:59:41 +0000 (+0000) Subject: LevelEditor tilegroup/object select by wheelup/wheeldown on buttons. Support for... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=201fd5966f080d26bc8256a89b4156811e92dc6c;p=supertux.git LevelEditor tilegroup/object select by wheelup/wheeldown on buttons. Support for WheelUp and WheelDown in Buttons. SVN-Revision: 998 --- diff --git a/src/button.cpp b/src/button.cpp index ff0c8d22a..b58e63ef4 100644 --- a/src/button.cpp +++ b/src/button.cpp @@ -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; diff --git a/src/button.h b/src/button.h index 0ef22311a..b97f9d61e 100644 --- a/src/button.h +++ b/src/button.h @@ -28,7 +28,9 @@ enum ButtonState { BUTTON_NONE = -1, BUTTON_CLICKED, BUTTON_PRESSED, - BUTTON_HOVER + BUTTON_HOVER, + BUTTON_WHEELUP, + BUTTON_WHEELDOWN }; class ButtonPanel; diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index c87aeacd9..c413505bb 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -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; } } }