You can say that it is a bad approuch, but it is not a bug!
Besides, I don't think it's a bad approuch. Your code is maybe a better approuch. But in the other hand is buggy, so please let my code be there.
Buggy, why, you may ask...
Imagine this simple and fictional code:
�
#define MNID_START 1
menu->additem("Start Game", MNID_START);
menu->additem("Options");
if(menu->check() == MNID_START)
startgame();
�
With your code, when you pressed Options, the game would also start. Have a look at it again and guess why ;-)
SVN-Revision: 685
pos_x = screen->w/2;
pos_y = screen->h/2;
has_backitem = false;
+ last_id = 0;
arrange_left = 0;
active_item = 0;
effect.init(false);
{
if(kind_ == MN_BACK)
has_backitem = true;
-
- if(id == -1)
- id = int(item.size());
+ if(id == -1 && item.size() == (unsigned)last_id)
+ {
+ id = last_id;
+ last_id++;
+ }
+
additem(MenuItem::create(kind_, text_.c_str(), toggle_, menu_, id, int_p));
}
int pos_x;
int pos_y;
bool has_backitem;
+ int last_id;
/** input event for the menu (up, down, left, right, etc.) */
MenuAction menuaction;