Re: [Super-tux-commit] supertux/lib/gui menu.cpp,1.9,1.10
Brought to you by:
wkendrick
From: Ricardo C. <ri...@ae...> - 2004-08-05 14:14:58
|
I haven't (and will not) look much to the menu code, so I don't know how=20 sucky it is, but just look at this piece of code: =AB MenuItem& new_item =3D item[active_item]; if(new_item.kind =3D=3D MN_DEACTIVE || new_item.kind =3D=3D MN_LABEL || new_item.kind =3D=3D MN_HL) { // Skip the horzontal line item if (menuaction !=3D MENU_ACTION_UP && menuaction !=3D MENU_ACTION_DOWN) menuaction =3D MENU_ACTION_DOWN; if (item.size() > 1) action(); } menuaction =3D MENU_ACTION_NONE; if (active_item >=3D int(item.size())) active_item =3D int(item.size()) - 1; =BB What's the point in having this? if (menuaction !=3D MENU_ACTION_UP && menuaction !=3D MENU_ACTION_DOWN) menuaction =3D MENU_ACTION_DOWN; If right after, it is done this: menuaction =3D MENU_ACTION_NONE; lol! And how is the checking of active_item in the end, if there can be a overf= low=20 before? Cheers, Ricardo Em Quinta, 5 de Agosto de 2004 15:09, o Ricardo Cruz escreveu: > Update of /cvsroot/super-tux/supertux/lib/gui > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30962/lib/gui > > Modified Files: > menu.cpp > Log Message: > When there is no entries in a menu, there is a crash. This delays the cra= sh > until an event is triggered. Select a level from Contrib Levels for > testing. I dunno what changes Tobias made to menu, but I don't think that > ugly checking for horizontal lines was in there. > > Index: menu.cpp > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvsroot/super-tux/supertux/lib/gui/menu.cpp,v > retrieving revision 1.9 > retrieving revision 1.10 > diff -u -d -r1.9 -r1.10 > --- menu.cpp 28 Jul 2004 23:33:23 -0000 1.9 > +++ menu.cpp 5 Aug 2004 14:09:12 -0000 1.10 > @@ -457,17 +457,23 @@ > } > } > > - MenuItem& new_item =3D item[active_item]; > - if(new_item.kind =3D=3D MN_DEACTIVE > - || new_item.kind =3D=3D MN_LABEL > - || new_item.kind =3D=3D 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 =3D item[active_item]; > + if(new_item.kind =3D=3D MN_DEACTIVE || > + new_item.kind =3D=3D MN_LABEL || > + new_item.kind =3D=3D MN_HL) > + { > // Skip the horzontal line item > if (menuaction !=3D MENU_ACTION_UP && menuaction !=3D MENU_ACTION_= DOWN) > menuaction =3D MENU_ACTION_DOWN; > > if (item.size() > 1) > action(); > + } > } > > menuaction =3D MENU_ACTION_NONE; > > > > ------------------------------------------------------- > This SF.Net email is sponsored by OSTG. Have you noticed the changes on > Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, > one more big change to announce. We are now OSTG- Open Source Technology > Group. Come see the changes on the new OSTG site. www.ostg.com > _______________________________________________ > Super-tux-commit mailing list > Sup...@li... > https://lists.sourceforge.net/lists/listinfo/super-tux-commit =2D-=20 You are a fluke of the universe; you have no right to be here. |