#include "gui/menu_manager.hpp"
#include "supertux/console.hpp"
#include "supertux/gameconfig.hpp"
+#include "supertux/menu/menu_storage.hpp"
#include "supertux/menu/joystick_menu.hpp"
#include "supertux/menu/keyboard_menu.hpp"
#include "util/gettext.hpp"
jump_with_up_joy(),
jump_with_up_kbd(),
wait_for_key(-1),
- wait_for_joystick(-1),
- key_options_menu(0),
- joystick_options_menu(0)
+ wait_for_joystick(-1)
{
// initialize default keyboard map
keymap[SDLK_LEFT] = LEFT;
if(*i != 0)
SDL_JoystickClose(*i);
}
-
- delete key_options_menu;
- delete joystick_options_menu;
}
void
if(jbutton.state == SDL_PRESSED)
{
bind_joybutton(jbutton.button, (Control)wait_for_joystick);
- joystick_options_menu->update();
+ MenuStorage::get_joystick_options_menu()->update();
reset();
wait_for_joystick = -1;
}
else
bind_joyaxis(jaxis.axis + 1, Control(wait_for_joystick));
- joystick_options_menu->update();
+ MenuStorage::get_joystick_options_menu()->update();
wait_for_joystick = -1;
}
}
if (changed & SDL_HAT_RIGHT && jhat.value & SDL_HAT_RIGHT)
bind_joyhat(SDL_HAT_RIGHT, (Control)wait_for_joystick);
- joystick_options_menu->update();
+ MenuStorage::get_joystick_options_menu()->update();
wait_for_joystick = -1;
}
else
bind_key(event.key.keysym.sym, (Control) wait_for_key);
}
reset();
- key_options_menu->update();
+ MenuStorage::get_key_options_menu()->update();
wait_for_key = -1;
return;
}
if(wait_for_joystick >= 0) {
if(event.key.keysym.sym == SDLK_ESCAPE) {
reset();
- joystick_options_menu->update();
+ MenuStorage::get_joystick_options_menu()->update();
wait_for_joystick = -1;
}
return;
return -1;
}
-Menu*
-JoystickKeyboardController::get_key_options_menu()
-{
- if(key_options_menu == 0) {
- key_options_menu = new KeyboardMenu(this);
- }
-
- return key_options_menu;
-}
-
-Menu*
-JoystickKeyboardController::get_joystick_options_menu()
-{
- if(joystick_options_menu == 0) {
- joystick_options_menu = new JoystickMenu(this);
- }
-
- return joystick_options_menu;
-}
-
/* EOF */
int wait_for_key;
int wait_for_joystick;
- KeyboardMenu* key_options_menu;
- JoystickMenu* joystick_options_menu;
-
private:
JoystickKeyboardController(const JoystickKeyboardController&);
JoystickKeyboardController& operator=(const JoystickKeyboardController&);
#include "supertux/menu/options_menu.hpp"
#include "supertux/menu/profile_menu.hpp"
+#include "supertux/menu/joystick_menu.hpp"
+#include "supertux/menu/keyboard_menu.hpp"
+#include "supertux/globals.hpp"
Menu* MenuStorage::options_menu = 0;
Menu* MenuStorage::profile_menu = 0;
+KeyboardMenu* MenuStorage::key_options_menu = 0;
+JoystickMenu* MenuStorage::joystick_options_menu = 0;
Menu*
MenuStorage::get_options_menu()
profile_menu = 0;
}
+
+KeyboardMenu*
+MenuStorage::get_key_options_menu()
+{
+ if (!key_options_menu)
+ { // FIXME: this in never freed
+ key_options_menu = new KeyboardMenu(g_main_controller);
+ }
+
+ return key_options_menu;
+}
+
+JoystickMenu*
+MenuStorage::get_joystick_options_menu()
+{
+ if (!joystick_options_menu)
+ { // FIXME: this in never freed
+ joystick_options_menu = new JoystickMenu(g_main_controller);
+ }
+
+ return joystick_options_menu;
+}
+
/* EOF */
#define HEADER_SUPERTUX_SUPERTUX_MENU_MENU_STORAGE_HPP
class Menu;
+class JoystickMenu;
+class KeyboardMenu;
class MenuStorage
{
MenuStorage();
static Menu* get_options_menu();
- static void free_options_menu();
+ static void free_options_menu();
static Menu* get_profile_menu();
- static void free_profile_menu();
+ static void free_profile_menu();
+
+ static KeyboardMenu* get_key_options_menu();
+ static JoystickMenu* get_joystick_options_menu();
private:
static Menu* options_menu;
static Menu* profile_menu;
+ static KeyboardMenu* key_options_menu;
+ static JoystickMenu* joystick_options_menu;
private:
MenuStorage(const MenuStorage&);
#include "audio/sound_manager.hpp"
#include "control/joystickkeyboardcontroller.hpp"
#include "gui/menu.hpp"
-#include "gui/menu_manager.hpp"
#include "gui/menu_item.hpp"
+#include "gui/menu_manager.hpp"
#include "supertux/gameconfig.hpp"
#include "supertux/globals.hpp"
#include "supertux/main.hpp"
-#include "supertux/menu/profile_menu.hpp"
+#include "supertux/menu/joystick_menu.hpp"
+#include "supertux/menu/keyboard_menu.hpp"
#include "supertux/menu/language_menu.hpp"
#include "supertux/menu/menu_storage.hpp"
+#include "supertux/menu/profile_menu.hpp"
#include "util/gettext.hpp"
#include "video/renderer.hpp"
add_inactive(MNID_MUSIC, _("Music (disabled)"));
}
- add_submenu(_("Setup Keyboard"), g_main_controller->get_key_options_menu())
+ add_submenu(_("Setup Keyboard"), MenuStorage::get_key_options_menu())
->set_help(_("Configure key-action mappings"));
- add_submenu(_("Setup Joystick") ,g_main_controller->get_joystick_options_menu())
+ add_submenu(_("Setup Joystick"), MenuStorage::get_joystick_options_menu())
->set_help(_("Configure joystick control-action mappings"));
add_hl();
add_back(_("Back"));