From: Tobias Gläßer Date: Mon, 10 May 2004 16:44:37 +0000 (+0000) Subject: fixed visual button bugs. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=bef877f5870361766432e379a0336fc290bf3c08;p=supertux.git fixed visual button bugs. SVN-Revision: 1077 --- diff --git a/src/button.cpp b/src/button.cpp index b46b8e512..8bb8e502d 100644 --- a/src/button.cpp +++ b/src/button.cpp @@ -69,7 +69,7 @@ void Button::add_icon(std::string icon_file, int mw, int mh) } else icon.push_back(new Surface(filename,USE_ALPHA)); - + } void Button::draw() @@ -82,8 +82,8 @@ void Button::draw() fillrect(rect.x+1,rect.y+1,rect.w-2,rect.h-2,175,175,175,200); for(std::vector::iterator it = icon.begin(); it != icon.end(); ++it) - (*it)->draw(rect.x,rect.y); - + (*it)->draw(rect.x,rect.y); + if(game_object != NULL) { game_object->draw_on_screen(rect.x,rect.y); @@ -111,15 +111,15 @@ void Button::draw() Button::~Button() { for(std::vector::iterator it = icon.begin(); it != icon.end(); ++it) - delete (*it); + delete (*it); icon.clear(); delete game_object; } void Button::event(SDL_Event &event) { -if(state == BUTTON_DEACTIVE) -return; + if(state == BUTTON_DEACTIVE) + return; SDLKey key = event.key.keysym.sym; @@ -146,20 +146,24 @@ return; } if(event.button.button == SDL_BUTTON_LEFT) - if(event.type == SDL_MOUSEBUTTONDOWN) - state = BUTTON_PRESSED; - else - state = BUTTON_CLICKED; + if(event.type == SDL_MOUSEBUTTONDOWN) + state = BUTTON_PRESSED; + else + state = BUTTON_CLICKED; } else if(event.type == SDL_MOUSEMOTION) { if(event.motion.x < rect.x || event.motion.x >= rect.x + rect.w || event.motion.y < rect.y || event.motion.y >= rect.y + rect.h) + { state = BUTTON_NONE; + } else + { state = BUTTON_HOVER; + popup_timer.start(1500); + } - popup_timer.start(1500); if(show_info) { show_info = false; @@ -209,17 +213,18 @@ Button* ButtonPanel::event(SDL_Event& event) { if(!hidden) { + Button* ret = NULL; for(std::vector::iterator it = item.begin(); it != item.end(); ++it) { (*it)->event(event); if((*it)->state != BUTTON_NONE) { if(hlast && (*it)->state == BUTTON_CLICKED) - last_clicked = it; - return (*it); - } + last_clicked = it; + ret = (*it); + } } - return NULL; + return ret; } else { @@ -247,7 +252,7 @@ void ButtonPanel::draw() (*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); + fillrect((*it)->get_pos().x,(*it)->get_pos().y,(*it)->get_pos().w,(*it)->get_pos().h,100,100,100,128); } } } @@ -288,7 +293,7 @@ Button* ButtonPanel::manipulate_button(int i) void ButtonPanel::highlight_last(bool b) { -hlast = b; + hlast = b; } diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index 29dd721ad..37446b9a6 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -561,7 +561,7 @@ int le_init() le_tilegroup_bt = new Button("/images/icons/tilegroup.png","Select Tilegroup", SDLK_F7,screen->w-64,64); le_objects_bt = new Button("/images/icons/objects.png","Select Objects", SDLK_F8,screen->w-64,80); le_object_select_bt = new Button("/images/icons/select-one.png","Select an Object", SDLK_s, screen->w - 64, screen->h-98); - le_object_properties_bt = new Button("/images/icons/properties.png","Select an Object", SDLK_p, screen->w - 32, screen->h-98); + le_object_properties_bt = new Button("/images/icons/properties.png","Edit object properties", SDLK_p, screen->w - 32, screen->h-98); le_object_properties_bt->set_active(false); mouse_select_object = new MouseCursor(datadir + "/images/status/select-cursor.png",1);