Next step is to save them to config file and to make joystick also configurable.
SVN-Revision: 611
/* Return a pointer to a new menu item */
MenuItem*
-MenuItem::create(MenuItemKind kind_, const char *text_, int init_toggle_, Menu* target_menu_)
+MenuItem::create(MenuItemKind kind_, const char *text_, int init_toggle_, Menu* target_menu_, int* int_p_)
{
MenuItem *pnew_item = new MenuItem;
}
else
pnew_item->list = NULL;
+
+ pnew_item->int_p = int_p_;
+
return pnew_item;
}
}
void
-Menu::additem(MenuItemKind kind_, const std::string& text_, int toggle_, Menu* menu_)
+Menu::additem(MenuItemKind kind_, const std::string& text_, int toggle_, Menu* menu_, int* int_p)
{
if(kind_ == MN_BACK)
has_backitem = true;
- additem(MenuItem::create(kind_, text_.c_str(), toggle_, menu_));
+ additem(MenuItem::create(kind_, text_.c_str(), toggle_, menu_, int_p));
}
/* Add an item to a menu */
case MN_ACTION:
case MN_TEXTFIELD:
case MN_NUMFIELD:
- case MN_CONTROLFIELD:
Menu::set_current(0);
item[active_item].toggled = true;
break;
+ case MN_CONTROLFIELD:
+ break;
case MN_BACK:
Menu::pop_current();
item[active_item].input[1] = '\0';
}
}
- break;
case MENU_ACTION_NONE:
break;
/* An International Character. */
}
+ if(item[active_item].kind == MN_CONTROLFIELD)
+ {
+ *item[active_item].int_p = event.key.keysym.unicode;
+ menuaction = MENU_ACTION_DOWN;
+ return;
+ }
+
+
switch(key)
{
case SDLK_UP: /* Menu Up */
int toggled;
char *text;
char *input;
+ int *int_p; // used for setting keys (can be used for more stuff...)
string_list_type* list;
Menu* target_menu;
void change_text (const char *text);
void change_input(const char *text);
- static MenuItem* create(MenuItemKind kind, const char *text, int init_toggle, Menu* target_menu);
+ static MenuItem* create(MenuItemKind kind, const char *text, int init_toggle, Menu* target_menu, int* int_p);
};
class Menu
~Menu();
void additem(MenuItem* pmenu_item);
- void additem(MenuItemKind kind, const std::string& text, int init_toggle, Menu* target_menu);
+ void additem(MenuItemKind kind, const std::string& text, int init_toggle, Menu* target_menu, int *int_p = NULL);
void action ();
PlayerKeymap();
};
+extern PlayerKeymap keymap;
+
struct player_input_type
{
int right;
#include "scene.h"
#include "worldmap.h"
+#include "player.h"
+
#ifdef WIN32
#define mkdir(dir, mode) mkdir(dir)
// on win32 we typically don't want LFS paths
options_controls_menu->additem(MN_LABEL,"Controls",0,0);
options_controls_menu->additem(MN_HL,"",0,0);
- //FIXME:options_controls_menu->additem(MN_CONTROLFIELD,"Move Right", tux.keymap.right,0);
+ options_controls_menu->additem(MN_CONTROLFIELD,"Right move", 0,0, &keymap.right);
+ options_controls_menu->additem(MN_CONTROLFIELD,"Left move", 0,0, &keymap.left);
+ options_controls_menu->additem(MN_CONTROLFIELD,"Jump", 0,0, &keymap.jump);
+ options_controls_menu->additem(MN_CONTROLFIELD,"Duck", 0,0, &keymap.duck);
+ options_controls_menu->additem(MN_CONTROLFIELD,"Power", 0,0, &keymap.fire);
options_controls_menu->additem(MN_HL,"",0,0);
options_controls_menu->additem(MN_BACK,"Back",0,0);