X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=lib%2Fgui%2Fmenu.cpp;h=d35f6d902244c49804c83ef6f441e3617081b6ff;hb=9ea50023ee514dfd2ba0cdb53cef91d6b842bafc;hp=b23ff784bfc95447c1000273ec4f7a594625babb;hpb=ef0d2a4018e5496fbb81645b928044bae4fb47db;p=supertux.git diff --git a/lib/gui/menu.cpp b/lib/gui/menu.cpp index b23ff784b..d35f6d902 100644 --- a/lib/gui/menu.cpp +++ b/lib/gui/menu.cpp @@ -457,17 +457,23 @@ Menu::action() } } - MenuItem& new_item = item[active_item]; - if(new_item.kind == MN_DEACTIVE - || new_item.kind == MN_LABEL - || new_item.kind == MN_HL) + if(active_item > 0 && active_item < (int)item.size()) { + // FIXME: wtf?! having a hack to avoid horizontal lines... + // Elegant solution would be to check for horizontal lines, right + // when it was asked to move menu up and down + MenuItem& new_item = item[active_item]; + if(new_item.kind == MN_DEACTIVE || + new_item.kind == MN_LABEL || + new_item.kind == MN_HL) + { // Skip the horzontal line item if (menuaction != MENU_ACTION_UP && menuaction != MENU_ACTION_DOWN) menuaction = MENU_ACTION_DOWN; if (item.size() > 1) action(); + } } menuaction = MENU_ACTION_NONE; @@ -764,7 +770,7 @@ Menu::event(SDL_Event& event) /* An International Character. */ } - if(item[active_item].kind == MN_CONTROLFIELD_KB) + if(item.size() > 0 && item[active_item].kind == MN_CONTROLFIELD_KB) { if(key == SDLK_ESCAPE) { @@ -792,7 +798,7 @@ Menu::event(SDL_Event& event) menuaction = MENU_ACTION_RIGHT; break; case SDLK_SPACE: - if(item[active_item].kind == MN_TEXTFIELD) + if(item.size() > 0 && item[active_item].kind == MN_TEXTFIELD) { menuaction = MENU_ACTION_INPUT; mn_input_char = ' '; @@ -842,7 +848,7 @@ Menu::event(SDL_Event& event) } break; case SDL_JOYBUTTONDOWN: - if (item[active_item].kind == MN_CONTROLFIELD_JS) + if (item.size() > 0 && item[active_item].kind == MN_CONTROLFIELD_JS) { // FIXME: This next line does nothing useable, right? // *item[active_item].int_p = key;