## Build list of sources for supertux binary
-FILE(GLOB SUPERTUX_SOURCES RELATIVE ${SUPERTUX_SOURCE_DIR} src/*.cpp src/*/*.cpp src/video/sdl/*.cpp external/obstack/*.c external/tinygettext/*.cpp external/findlocale/findlocale.c)
+FILE(GLOB SUPERTUX_SOURCES RELATIVE ${SUPERTUX_SOURCE_DIR} src/*.cpp src/*/*.cpp src/supertux/menu/*.cpp src/video/sdl/*.cpp external/obstack/*.c external/tinygettext/*.cpp external/findlocale/findlocale.c)
IF(HAVE_OPENGL)
FILE(GLOB SUPERTUX_OPENGL_SOURCES RELATIVE ${SUPERTUX_SOURCE_DIR} src/video/gl/*.cpp)
version_h.close()
# base source
- supertux_sources = Glob("src/*.cpp") + Glob("src/*/*.cpp")
+ supertux_sources = Glob("src/*.cpp") + Glob("src/*/*.cpp") + Glob("src/supertux/menu/*.cpp")
# optional video drivers
supertux_sources += Glob("src/video/gl/*.cpp")
+++ /dev/null
-// SuperTux
-// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include "control/joystick_menu.hpp"
-
-#include <sstream>
-
-#include "util/gettext.hpp"
-#include "supertux/gameconfig.hpp"
-
-namespace{
- const int SCAN_JOYSTICKS = Controller::CONTROLCOUNT + 1;
-}
-
-JoystickMenu::JoystickMenu(JoystickKeyboardController* _controller) :
- controller(_controller)
-{
- recreateMenu();
-}
-
-JoystickMenu::~JoystickMenu()
-{}
-
-void
-JoystickMenu::recreateMenu()
-{
- clear();
- add_label(_("Setup Joystick"));
- add_hl();
- if(controller->joysticks.size() > 0) {
- add_controlfield(Controller::UP, _("Up"));
- add_controlfield(Controller::DOWN, _("Down"));
- add_controlfield(Controller::LEFT, _("Left"));
- add_controlfield(Controller::RIGHT, _("Right"));
- add_controlfield(Controller::JUMP, _("Jump"));
- add_controlfield(Controller::ACTION, _("Action"));
- add_controlfield(Controller::PAUSE_MENU, _("Pause/Menu"));
- add_controlfield(Controller::PEEK_LEFT, _("Peek Left"));
- add_controlfield(Controller::PEEK_RIGHT, _("Peek Right"));
- add_controlfield(Controller::PEEK_UP, _("Peek Up"));
- add_controlfield(Controller::PEEK_DOWN, _("Peek Down"));
-
- add_toggle(Controller::CONTROLCOUNT, _("Jump with Up"), controller->jump_with_up_joy);
- } else {
- add_inactive(-1, _("No Joysticks found"));
- }
- add_inactive(-1,"");
- add_entry(SCAN_JOYSTICKS, _("Scan for Joysticks"));
-
- //Show Joysticks currently activated:
- for(std::vector<SDL_Joystick*>::iterator i = controller->joysticks.begin();
- i != controller->joysticks.end(); ++i) {
- if(*i != 0)
- add_inactive(-1, SDL_JoystickName(SDL_JoystickIndex(*i)) );
- }
-
- add_hl();
- add_back(_("Back"));
- update();
-}
-
-std::string
-JoystickMenu::get_button_name(int button)
-{
- if(button < 0)
- return _("None");
-
- std::ostringstream name;
- name << "Button " << button;
- return name.str();
-}
-
-void
-JoystickMenu::menu_action(MenuItem* item)
-{
- if (item->id >= 0 && item->id < Controller::CONTROLCOUNT) {
- item->change_input(_("Press Button"));
- controller->wait_for_joystick = item->id;
- } else if (item->id == Controller::CONTROLCOUNT) {
- controller->jump_with_up_joy = item->toggled;
- } else if( item->id == SCAN_JOYSTICKS) {
- controller->updateAvailableJoysticks();
- recreateMenu();
- }
-}
-
-void
-JoystickMenu::update_menu_item(Controller::Control id)
-{
- int button = controller->reversemap_joybutton(id);
- int axis = controller->reversemap_joyaxis(id);
- int hat_dir = controller->reversemap_joyhat(id);
-
- if (button != -1) {
- get_item_by_id((int)id).change_input(get_button_name(button));
- } else if (axis != 0) {
- std::ostringstream name;
-
- name << "Axis ";
-
- if (axis < 0)
- name << "-";
- else
- name << "+";
-
- if (abs(axis) == 1)
- name << "X";
- else if (abs(axis) == 2)
- name << "Y";
- else if (abs(axis) == 2)
- name << "X2";
- else if (abs(axis) == 3)
- name << "Y2";
- else
- name << abs(axis);
-
- get_item_by_id((int)id).change_input(name.str());
- } else if (hat_dir != -1) {
- std::string name;
-
- switch (hat_dir)
- {
- case SDL_HAT_UP:
- name = "Hat Up";
- break;
-
- case SDL_HAT_DOWN:
- name = "Hat Down";
- break;
-
- case SDL_HAT_LEFT:
- name = "Hat Left";
- break;
-
- case SDL_HAT_RIGHT:
- name = "Hat Right";
- break;
-
- default:
- name = "Unknown hat_dir";
- break;
- }
-
- get_item_by_id((int)id).change_input(name);
- } else {
- get_item_by_id((int)id).change_input("None");
- }
-}
-
-void
-JoystickMenu::update()
-{
- if(controller->joysticks.size() == 0)
- return;
-
- update_menu_item(Controller::UP);
- update_menu_item(Controller::DOWN);
- update_menu_item(Controller::LEFT);
- update_menu_item(Controller::RIGHT);
-
- update_menu_item(Controller::JUMP);
- update_menu_item(Controller::ACTION);
- update_menu_item(Controller::PAUSE_MENU);
- update_menu_item(Controller::PEEK_LEFT);
- update_menu_item(Controller::PEEK_RIGHT);
- update_menu_item(Controller::PEEK_UP);
- update_menu_item(Controller::PEEK_DOWN);
-
- get_item_by_id(Controller::CONTROLCOUNT).toggled = controller->jump_with_up_joy;
-}
-
-/* EOF */
+++ /dev/null
-// SuperTux
-// Copyright (C) 2006 Matthias Braun <matze@braunis.de>,
-// 2007 Ingo Ruhnke <grumbel@gmx.de>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_SUPERTUX_CONTROL_JOYSTICK_MENU_HPP
-#define HEADER_SUPERTUX_CONTROL_JOYSTICK_MENU_HPP
-
-#include "control/joystickkeyboardcontroller.hpp"
-#include "control/controller.hpp"
-#include "gui/menu.hpp"
-#include "gui/menu_item.hpp"
-
-class JoystickMenu : public Menu
-{
-public:
- JoystickMenu(JoystickKeyboardController* controller);
- virtual ~JoystickMenu();
-
- void update();
- std::string get_button_name(int button);
- void update_menu_item(Controller::Control id);
- virtual void menu_action(MenuItem* item);
- JoystickKeyboardController* controller;
-
-private:
- void recreateMenu();
-
-private:
- JoystickMenu(const JoystickMenu&);
- JoystickMenu& operator=(const JoystickMenu&);
-};
-
-#endif
-
-/* EOF */
#include <iostream>
-#include "control/joystick_menu.hpp"
-#include "control/keyboard_menu.hpp"
-#include "util/writer.hpp"
#include "lisp/list_iterator.hpp"
-#include "supertux/gameconfig.hpp"
#include "supertux/console.hpp"
+#include "supertux/gameconfig.hpp"
+#include "supertux/menu/joystick_menu.hpp"
+#include "supertux/menu/keyboard_menu.hpp"
#include "util/gettext.hpp"
+#include "util/writer.hpp"
JoystickKeyboardController::JoystickKeyboardController() :
keymap(),
+++ /dev/null
-// SuperTux
-// Copyright (C) 2006 Matthias Braun <matze@braunis.de>,
-// 2007 Ingo Ruhnke <grumbel@gmx.de>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include "control/keyboard_menu.hpp"
-
-#include "util/gettext.hpp"
-#include "supertux/gameconfig.hpp"
-
-KeyboardMenu::KeyboardMenu(JoystickKeyboardController* _controller) :
- controller(_controller)
-{
- add_label(_("Setup Keyboard"));
- add_hl();
- add_controlfield(Controller::UP, _("Up"));
- add_controlfield(Controller::DOWN, _("Down"));
- add_controlfield(Controller::LEFT, _("Left"));
- add_controlfield(Controller::RIGHT, _("Right"));
- add_controlfield(Controller::JUMP, _("Jump"));
- add_controlfield(Controller::ACTION, _("Action"));
- add_controlfield(Controller::PEEK_LEFT, _("Peek Left"));
- add_controlfield(Controller::PEEK_RIGHT, _("Peek Right"));
- add_controlfield(Controller::PEEK_UP, _("Peek Up"));
- add_controlfield(Controller::PEEK_DOWN, _("Peek Down"));
- if (g_config->console_enabled) {
- add_controlfield(Controller::CONSOLE, _("Console"));
- }
- add_toggle(Controller::CONTROLCOUNT, _("Jump with Up"), controller->jump_with_up_kbd);
- add_hl();
- add_back(_("Back"));
- update();
-}
-
-KeyboardMenu::~KeyboardMenu()
-{}
-
-std::string
-KeyboardMenu::get_key_name(SDLKey key)
-{
- switch(key) {
- case SDLK_UNKNOWN:
- return _("None");
- case SDLK_UP:
- return _("Up cursor");
- case SDLK_DOWN:
- return _("Down cursor");
- case SDLK_LEFT:
- return _("Left cursor");
- case SDLK_RIGHT:
- return _("Right cursor");
- case SDLK_RETURN:
- return _("Return");
- case SDLK_SPACE:
- return _("Space");
- case SDLK_RSHIFT:
- return _("Right Shift");
- case SDLK_LSHIFT:
- return _("Left Shift");
- case SDLK_RCTRL:
- return _("Right Control");
- case SDLK_LCTRL:
- return _("Left Control");
- case SDLK_RALT:
- return _("Right Alt");
- case SDLK_LALT:
- return _("Left Alt");
- default:
- return SDL_GetKeyName((SDLKey) key);
- }
-}
-
-void
-KeyboardMenu::menu_action(MenuItem* item)
-{
- if(item->id >= 0 && item->id < Controller::CONTROLCOUNT){
- item->change_input(_("Press Key"));
- controller->wait_for_key = item->id;
- } else if( item->id == Controller::CONTROLCOUNT) {
- controller->jump_with_up_kbd = item->toggled;
- }
-}
-
-void
-KeyboardMenu::update()
-{
- // update menu
- get_item_by_id((int) Controller::UP).change_input(get_key_name(
- controller->reversemap_key(Controller::UP)));
- get_item_by_id((int) Controller::DOWN).change_input(get_key_name(
- controller->reversemap_key(Controller::DOWN)));
- get_item_by_id((int) Controller::LEFT).change_input(get_key_name(
- controller->reversemap_key(Controller::LEFT)));
- get_item_by_id((int) Controller::RIGHT).change_input(get_key_name(
- controller->reversemap_key(Controller::RIGHT)));
- get_item_by_id((int) Controller::JUMP).change_input(get_key_name(
- controller->reversemap_key(Controller::JUMP)));
- get_item_by_id((int) Controller::ACTION).change_input(get_key_name(
- controller->reversemap_key(Controller::ACTION)));
- get_item_by_id((int) Controller::PEEK_LEFT).change_input(get_key_name(
- controller->reversemap_key(Controller::PEEK_LEFT)));
- get_item_by_id((int) Controller::PEEK_RIGHT).change_input(get_key_name(
- controller->reversemap_key(Controller::PEEK_RIGHT)));
- get_item_by_id((int) Controller::PEEK_UP).change_input(get_key_name(
- controller->reversemap_key(Controller::PEEK_UP)));
- get_item_by_id((int) Controller::PEEK_DOWN).change_input(get_key_name(
- controller->reversemap_key(Controller::PEEK_DOWN)));
- if (g_config->console_enabled) {
- get_item_by_id((int) Controller::CONSOLE).change_input(get_key_name(
- controller->reversemap_key(Controller::CONSOLE)));
- }
- get_item_by_id(Controller::CONTROLCOUNT).toggled = controller->jump_with_up_kbd;
-}
-
-/* EOF */
+++ /dev/null
-// SuperTux
-// Copyright (C) 2006 Matthias Braun <matze@braunis.de>,
-// 2007 Ingo Ruhnke <grumbel@gmx.de>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_SUPERTUX_CONTROL_KEYBOARD_MENU_HPP
-#define HEADER_SUPERTUX_CONTROL_KEYBOARD_MENU_HPP
-
-#include "control/joystickkeyboardcontroller.hpp"
-#include "gui/menu.hpp"
-#include "gui/menu_item.hpp"
-
-class KeyboardMenu : public Menu
-{
-public:
- KeyboardMenu(JoystickKeyboardController* controller);
- ~KeyboardMenu();
-
- void update();
- std::string get_key_name(SDLKey key);
- virtual void menu_action(MenuItem* item);
- JoystickKeyboardController* controller;
-
-private:
- KeyboardMenu(const KeyboardMenu&);
- KeyboardMenu& operator=(const KeyboardMenu&);
-};
-
-#endif
-
-/* EOF */
#include "supertux/levelintro.hpp"
#include "supertux/globals.hpp"
#include "supertux/mainloop.hpp"
-#include "supertux/options_menu.hpp"
+#include "supertux/menu/options_menu.hpp"
#include "supertux/sector.hpp"
#include "util/file_system.hpp"
#include "util/gettext.hpp"
+++ /dev/null
-// SuperTux
-// Copyright (C) 2004 Tobas Glaesser <tobi.web@gmx.de>
-// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include "supertux/language_menu.hpp"
-
-extern "C" {
-#include "findlocale.h"
-}
-#include "gui/menu_item.hpp"
-#include "supertux/gameconfig.hpp"
-
-enum {
- MNID_LANGUAGE_AUTO_DETECT = 0,
- MNID_LANGUAGE_ENGLISH = 1,
- MNID_LANGUAGE_NEXT = 10
-};
-
-LanguageMenu::LanguageMenu()
-{
- add_label(_("Language"));
- add_hl();
- add_entry(MNID_LANGUAGE_AUTO_DETECT, _("<auto-detect>"));
- add_entry(MNID_LANGUAGE_ENGLISH, "English");
-
- int mnid = MNID_LANGUAGE_NEXT;
- std::set<tinygettext::Language> languages = dictionary_manager.get_languages();
- for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++)
- {
- add_entry(mnid++, i->get_name());
- }
-
- add_hl();
- add_back(_("Back"));
-}
-
-void
-LanguageMenu::menu_action(MenuItem* item)
-{
- if (item->id == MNID_LANGUAGE_AUTO_DETECT) // auto detect
- {
- FL_Locale *locale;
- FL_FindLocale(&locale, FL_MESSAGES);
- tinygettext::Language language = tinygettext::Language::from_spec(locale->lang, locale->country, locale->variant);
- FL_FreeLocale(&locale);
-
- dictionary_manager.set_language(language);
- g_config->locale = language.str();
- g_config->save();
- Menu::pop_current();
- }
- else if (item->id == MNID_LANGUAGE_ENGLISH) // english
- {
- g_config->locale = "en";
- dictionary_manager.set_language(tinygettext::Language::from_name(g_config->locale));
- g_config->save();
- Menu::pop_current();
- }
- else
- {
- int mnid = MNID_LANGUAGE_NEXT;
- std::set<tinygettext::Language> languages = dictionary_manager.get_languages();
-
- for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++)
- {
- if (item->id == mnid++)
- {
- g_config->locale = i->str();
- dictionary_manager.set_language(*i);
- g_config->save();
- Menu::pop_current();
- break;
- }
- }
- }
-}
-
-/* EOF */
+++ /dev/null
-// SuperTux
-// Copyright (C) 2004 Tobas Glaesser <tobi.web@gmx.de>
-// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_SUPERTUX_SUPERTUX_LANGUAGE_MENU_HPP
-#define HEADER_SUPERTUX_SUPERTUX_LANGUAGE_MENU_HPP
-
-#include <set>
-
-#include "util/gettext.hpp"
-#include "gui/menu.hpp"
-
-class LanguageMenu : public Menu
-{
-public:
- LanguageMenu();
-
- virtual void menu_action(MenuItem* item);
-};
-
-#endif
-
-/* EOF */
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "supertux/menu/joystick_menu.hpp"
+
+#include <sstream>
+
+#include "util/gettext.hpp"
+#include "supertux/gameconfig.hpp"
+
+namespace{
+ const int SCAN_JOYSTICKS = Controller::CONTROLCOUNT + 1;
+}
+
+JoystickMenu::JoystickMenu(JoystickKeyboardController* _controller) :
+ controller(_controller)
+{
+ recreateMenu();
+}
+
+JoystickMenu::~JoystickMenu()
+{}
+
+void
+JoystickMenu::recreateMenu()
+{
+ clear();
+ add_label(_("Setup Joystick"));
+ add_hl();
+ if(controller->joysticks.size() > 0) {
+ add_controlfield(Controller::UP, _("Up"));
+ add_controlfield(Controller::DOWN, _("Down"));
+ add_controlfield(Controller::LEFT, _("Left"));
+ add_controlfield(Controller::RIGHT, _("Right"));
+ add_controlfield(Controller::JUMP, _("Jump"));
+ add_controlfield(Controller::ACTION, _("Action"));
+ add_controlfield(Controller::PAUSE_MENU, _("Pause/Menu"));
+ add_controlfield(Controller::PEEK_LEFT, _("Peek Left"));
+ add_controlfield(Controller::PEEK_RIGHT, _("Peek Right"));
+ add_controlfield(Controller::PEEK_UP, _("Peek Up"));
+ add_controlfield(Controller::PEEK_DOWN, _("Peek Down"));
+
+ add_toggle(Controller::CONTROLCOUNT, _("Jump with Up"), controller->jump_with_up_joy);
+ } else {
+ add_inactive(-1, _("No Joysticks found"));
+ }
+ add_inactive(-1,"");
+ add_entry(SCAN_JOYSTICKS, _("Scan for Joysticks"));
+
+ //Show Joysticks currently activated:
+ for(std::vector<SDL_Joystick*>::iterator i = controller->joysticks.begin();
+ i != controller->joysticks.end(); ++i) {
+ if(*i != 0)
+ add_inactive(-1, SDL_JoystickName(SDL_JoystickIndex(*i)) );
+ }
+
+ add_hl();
+ add_back(_("Back"));
+ update();
+}
+
+std::string
+JoystickMenu::get_button_name(int button)
+{
+ if(button < 0)
+ return _("None");
+
+ std::ostringstream name;
+ name << "Button " << button;
+ return name.str();
+}
+
+void
+JoystickMenu::menu_action(MenuItem* item)
+{
+ if (item->id >= 0 && item->id < Controller::CONTROLCOUNT) {
+ item->change_input(_("Press Button"));
+ controller->wait_for_joystick = item->id;
+ } else if (item->id == Controller::CONTROLCOUNT) {
+ controller->jump_with_up_joy = item->toggled;
+ } else if( item->id == SCAN_JOYSTICKS) {
+ controller->updateAvailableJoysticks();
+ recreateMenu();
+ }
+}
+
+void
+JoystickMenu::update_menu_item(Controller::Control id)
+{
+ int button = controller->reversemap_joybutton(id);
+ int axis = controller->reversemap_joyaxis(id);
+ int hat_dir = controller->reversemap_joyhat(id);
+
+ if (button != -1) {
+ get_item_by_id((int)id).change_input(get_button_name(button));
+ } else if (axis != 0) {
+ std::ostringstream name;
+
+ name << "Axis ";
+
+ if (axis < 0)
+ name << "-";
+ else
+ name << "+";
+
+ if (abs(axis) == 1)
+ name << "X";
+ else if (abs(axis) == 2)
+ name << "Y";
+ else if (abs(axis) == 2)
+ name << "X2";
+ else if (abs(axis) == 3)
+ name << "Y2";
+ else
+ name << abs(axis);
+
+ get_item_by_id((int)id).change_input(name.str());
+ } else if (hat_dir != -1) {
+ std::string name;
+
+ switch (hat_dir)
+ {
+ case SDL_HAT_UP:
+ name = "Hat Up";
+ break;
+
+ case SDL_HAT_DOWN:
+ name = "Hat Down";
+ break;
+
+ case SDL_HAT_LEFT:
+ name = "Hat Left";
+ break;
+
+ case SDL_HAT_RIGHT:
+ name = "Hat Right";
+ break;
+
+ default:
+ name = "Unknown hat_dir";
+ break;
+ }
+
+ get_item_by_id((int)id).change_input(name);
+ } else {
+ get_item_by_id((int)id).change_input("None");
+ }
+}
+
+void
+JoystickMenu::update()
+{
+ if(controller->joysticks.size() == 0)
+ return;
+
+ update_menu_item(Controller::UP);
+ update_menu_item(Controller::DOWN);
+ update_menu_item(Controller::LEFT);
+ update_menu_item(Controller::RIGHT);
+
+ update_menu_item(Controller::JUMP);
+ update_menu_item(Controller::ACTION);
+ update_menu_item(Controller::PAUSE_MENU);
+ update_menu_item(Controller::PEEK_LEFT);
+ update_menu_item(Controller::PEEK_RIGHT);
+ update_menu_item(Controller::PEEK_UP);
+ update_menu_item(Controller::PEEK_DOWN);
+
+ get_item_by_id(Controller::CONTROLCOUNT).toggled = controller->jump_with_up_joy;
+}
+
+/* EOF */
--- /dev/null
+// SuperTux
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>,
+// 2007 Ingo Ruhnke <grumbel@gmx.de>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_CONTROL_JOYSTICK_MENU_HPP
+#define HEADER_SUPERTUX_CONTROL_JOYSTICK_MENU_HPP
+
+#include "control/joystickkeyboardcontroller.hpp"
+#include "control/controller.hpp"
+#include "gui/menu.hpp"
+#include "gui/menu_item.hpp"
+
+class JoystickMenu : public Menu
+{
+public:
+ JoystickMenu(JoystickKeyboardController* controller);
+ virtual ~JoystickMenu();
+
+ void update();
+ std::string get_button_name(int button);
+ void update_menu_item(Controller::Control id);
+ virtual void menu_action(MenuItem* item);
+ JoystickKeyboardController* controller;
+
+private:
+ void recreateMenu();
+
+private:
+ JoystickMenu(const JoystickMenu&);
+ JoystickMenu& operator=(const JoystickMenu&);
+};
+
+#endif
+
+/* EOF */
--- /dev/null
+// SuperTux
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>,
+// 2007 Ingo Ruhnke <grumbel@gmx.de>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "supertux/menu/keyboard_menu.hpp"
+
+#include "util/gettext.hpp"
+#include "supertux/gameconfig.hpp"
+
+KeyboardMenu::KeyboardMenu(JoystickKeyboardController* _controller) :
+ controller(_controller)
+{
+ add_label(_("Setup Keyboard"));
+ add_hl();
+ add_controlfield(Controller::UP, _("Up"));
+ add_controlfield(Controller::DOWN, _("Down"));
+ add_controlfield(Controller::LEFT, _("Left"));
+ add_controlfield(Controller::RIGHT, _("Right"));
+ add_controlfield(Controller::JUMP, _("Jump"));
+ add_controlfield(Controller::ACTION, _("Action"));
+ add_controlfield(Controller::PEEK_LEFT, _("Peek Left"));
+ add_controlfield(Controller::PEEK_RIGHT, _("Peek Right"));
+ add_controlfield(Controller::PEEK_UP, _("Peek Up"));
+ add_controlfield(Controller::PEEK_DOWN, _("Peek Down"));
+ if (g_config->console_enabled) {
+ add_controlfield(Controller::CONSOLE, _("Console"));
+ }
+ add_toggle(Controller::CONTROLCOUNT, _("Jump with Up"), controller->jump_with_up_kbd);
+ add_hl();
+ add_back(_("Back"));
+ update();
+}
+
+KeyboardMenu::~KeyboardMenu()
+{}
+
+std::string
+KeyboardMenu::get_key_name(SDLKey key)
+{
+ switch(key) {
+ case SDLK_UNKNOWN:
+ return _("None");
+ case SDLK_UP:
+ return _("Up cursor");
+ case SDLK_DOWN:
+ return _("Down cursor");
+ case SDLK_LEFT:
+ return _("Left cursor");
+ case SDLK_RIGHT:
+ return _("Right cursor");
+ case SDLK_RETURN:
+ return _("Return");
+ case SDLK_SPACE:
+ return _("Space");
+ case SDLK_RSHIFT:
+ return _("Right Shift");
+ case SDLK_LSHIFT:
+ return _("Left Shift");
+ case SDLK_RCTRL:
+ return _("Right Control");
+ case SDLK_LCTRL:
+ return _("Left Control");
+ case SDLK_RALT:
+ return _("Right Alt");
+ case SDLK_LALT:
+ return _("Left Alt");
+ default:
+ return SDL_GetKeyName((SDLKey) key);
+ }
+}
+
+void
+KeyboardMenu::menu_action(MenuItem* item)
+{
+ if(item->id >= 0 && item->id < Controller::CONTROLCOUNT){
+ item->change_input(_("Press Key"));
+ controller->wait_for_key = item->id;
+ } else if( item->id == Controller::CONTROLCOUNT) {
+ controller->jump_with_up_kbd = item->toggled;
+ }
+}
+
+void
+KeyboardMenu::update()
+{
+ // update menu
+ get_item_by_id((int) Controller::UP).change_input(get_key_name(
+ controller->reversemap_key(Controller::UP)));
+ get_item_by_id((int) Controller::DOWN).change_input(get_key_name(
+ controller->reversemap_key(Controller::DOWN)));
+ get_item_by_id((int) Controller::LEFT).change_input(get_key_name(
+ controller->reversemap_key(Controller::LEFT)));
+ get_item_by_id((int) Controller::RIGHT).change_input(get_key_name(
+ controller->reversemap_key(Controller::RIGHT)));
+ get_item_by_id((int) Controller::JUMP).change_input(get_key_name(
+ controller->reversemap_key(Controller::JUMP)));
+ get_item_by_id((int) Controller::ACTION).change_input(get_key_name(
+ controller->reversemap_key(Controller::ACTION)));
+ get_item_by_id((int) Controller::PEEK_LEFT).change_input(get_key_name(
+ controller->reversemap_key(Controller::PEEK_LEFT)));
+ get_item_by_id((int) Controller::PEEK_RIGHT).change_input(get_key_name(
+ controller->reversemap_key(Controller::PEEK_RIGHT)));
+ get_item_by_id((int) Controller::PEEK_UP).change_input(get_key_name(
+ controller->reversemap_key(Controller::PEEK_UP)));
+ get_item_by_id((int) Controller::PEEK_DOWN).change_input(get_key_name(
+ controller->reversemap_key(Controller::PEEK_DOWN)));
+ if (g_config->console_enabled) {
+ get_item_by_id((int) Controller::CONSOLE).change_input(get_key_name(
+ controller->reversemap_key(Controller::CONSOLE)));
+ }
+ get_item_by_id(Controller::CONTROLCOUNT).toggled = controller->jump_with_up_kbd;
+}
+
+/* EOF */
--- /dev/null
+// SuperTux
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>,
+// 2007 Ingo Ruhnke <grumbel@gmx.de>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_CONTROL_KEYBOARD_MENU_HPP
+#define HEADER_SUPERTUX_CONTROL_KEYBOARD_MENU_HPP
+
+#include "control/joystickkeyboardcontroller.hpp"
+#include "gui/menu.hpp"
+#include "gui/menu_item.hpp"
+
+class KeyboardMenu : public Menu
+{
+public:
+ KeyboardMenu(JoystickKeyboardController* controller);
+ ~KeyboardMenu();
+
+ void update();
+ std::string get_key_name(SDLKey key);
+ virtual void menu_action(MenuItem* item);
+ JoystickKeyboardController* controller;
+
+private:
+ KeyboardMenu(const KeyboardMenu&);
+ KeyboardMenu& operator=(const KeyboardMenu&);
+};
+
+#endif
+
+/* EOF */
--- /dev/null
+// SuperTux
+// Copyright (C) 2004 Tobas Glaesser <tobi.web@gmx.de>
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "supertux/menu/language_menu.hpp"
+
+extern "C" {
+#include "findlocale.h"
+}
+#include "gui/menu_item.hpp"
+#include "supertux/gameconfig.hpp"
+
+enum {
+ MNID_LANGUAGE_AUTO_DETECT = 0,
+ MNID_LANGUAGE_ENGLISH = 1,
+ MNID_LANGUAGE_NEXT = 10
+};
+
+LanguageMenu::LanguageMenu()
+{
+ add_label(_("Language"));
+ add_hl();
+ add_entry(MNID_LANGUAGE_AUTO_DETECT, _("<auto-detect>"));
+ add_entry(MNID_LANGUAGE_ENGLISH, "English");
+
+ int mnid = MNID_LANGUAGE_NEXT;
+ std::set<tinygettext::Language> languages = dictionary_manager.get_languages();
+ for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++)
+ {
+ add_entry(mnid++, i->get_name());
+ }
+
+ add_hl();
+ add_back(_("Back"));
+}
+
+void
+LanguageMenu::menu_action(MenuItem* item)
+{
+ if (item->id == MNID_LANGUAGE_AUTO_DETECT) // auto detect
+ {
+ FL_Locale *locale;
+ FL_FindLocale(&locale, FL_MESSAGES);
+ tinygettext::Language language = tinygettext::Language::from_spec(locale->lang, locale->country, locale->variant);
+ FL_FreeLocale(&locale);
+
+ dictionary_manager.set_language(language);
+ g_config->locale = language.str();
+ g_config->save();
+ Menu::pop_current();
+ }
+ else if (item->id == MNID_LANGUAGE_ENGLISH) // english
+ {
+ g_config->locale = "en";
+ dictionary_manager.set_language(tinygettext::Language::from_name(g_config->locale));
+ g_config->save();
+ Menu::pop_current();
+ }
+ else
+ {
+ int mnid = MNID_LANGUAGE_NEXT;
+ std::set<tinygettext::Language> languages = dictionary_manager.get_languages();
+
+ for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++)
+ {
+ if (item->id == mnid++)
+ {
+ g_config->locale = i->str();
+ dictionary_manager.set_language(*i);
+ g_config->save();
+ Menu::pop_current();
+ break;
+ }
+ }
+ }
+}
+
+/* EOF */
--- /dev/null
+// SuperTux
+// Copyright (C) 2004 Tobas Glaesser <tobi.web@gmx.de>
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_SUPERTUX_LANGUAGE_MENU_HPP
+#define HEADER_SUPERTUX_SUPERTUX_LANGUAGE_MENU_HPP
+
+#include <set>
+
+#include "util/gettext.hpp"
+#include "gui/menu.hpp"
+
+class LanguageMenu : public Menu
+{
+public:
+ LanguageMenu();
+
+ virtual void menu_action(MenuItem* item);
+};
+
+#endif
+
+/* EOF */
--- /dev/null
+// SuperTux
+// Copyright (C) 2004 Tobas Glaesser <tobi.web@gmx.de>
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "supertux/menu/options_menu.hpp"
+
+#include "audio/sound_manager.hpp"
+#include "control/joystickkeyboardcontroller.hpp"
+#include "gui/menu.hpp"
+#include "gui/menu_item.hpp"
+#include "supertux/gameconfig.hpp"
+#include "supertux/globals.hpp"
+#include "supertux/main.hpp"
+#include "supertux/menu/profile_menu.hpp"
+#include "supertux/menu/language_menu.hpp"
+#include "util/gettext.hpp"
+#include "video/renderer.hpp"
+
+Menu* options_menu = 0;
+
+enum OptionsMenuIDs {
+ MNID_FULLSCREEN,
+ MNID_FULLSCREEN_RESOLUTION,
+ MNID_MAGNIFICATION,
+ MNID_ASPECTRATIO,
+ MNID_PROFILES,
+ MNID_SOUND,
+ MNID_MUSIC
+};
+
+OptionsMenu::OptionsMenu() :
+ language_menu()
+{
+ language_menu.reset(new LanguageMenu());
+
+ add_label(_("Options"));
+ add_hl();
+
+ // Language change should only be possible in the main menu, since elsewhere it might not always work fully
+ // FIXME: Implement me: if (get_parent() == main_menu)
+ add_submenu(_("Select Language"), language_menu.get())
+ ->set_help(_("Select a different language to display text in"));
+
+ add_submenu(_("Select Profile"), get_profile_menu())
+ ->set_help(_("Select a profile to play with"));
+
+ add_toggle(MNID_PROFILES, _("Profile on Startup"), g_config->sound_enabled)
+ ->set_help(_("Select your profile immediately after start-up"));
+
+ add_toggle(MNID_FULLSCREEN,_("Fullscreen"), g_config->use_fullscreen)
+ ->set_help(_("Fill the entire screen"));
+
+ MenuItem* fullscreen_res = add_string_select(MNID_FULLSCREEN_RESOLUTION, _("Resolution"));
+ fullscreen_res->set_help(_("Determine the resolution used in fullscreen mode (you must toggle fullscreen to complete the change)"));
+
+ MenuItem* magnification = add_string_select(MNID_MAGNIFICATION, _("Magnification"));
+ magnification->set_help(_("Change the magnification of the game area"));
+
+ // These values go from screen:640/projection:1600 to
+ // screen:1600/projection:640 (i.e. 640, 800, 1024, 1280, 1600)
+ magnification->list.push_back("auto");
+ magnification->list.push_back("40%");
+ magnification->list.push_back("50%");
+ magnification->list.push_back("62.5%");
+ magnification->list.push_back("80%");
+ magnification->list.push_back("100%");
+ magnification->list.push_back("125%");
+ magnification->list.push_back("160%");
+ magnification->list.push_back("200%");
+ magnification->list.push_back("250%");
+
+ SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL);
+
+ if (modes == (SDL_Rect **)0)
+ { // No resolutions at all available, bad
+
+ }
+ else if(modes == (SDL_Rect **)-1)
+ { // All resolutions should work, so we fall back to hardcoded defaults
+ fullscreen_res->list.push_back("640x480");
+ fullscreen_res->list.push_back("800x600");
+ fullscreen_res->list.push_back("1024x768");
+ fullscreen_res->list.push_back("1152x864");
+ fullscreen_res->list.push_back("1280x960");
+ fullscreen_res->list.push_back("1280x1024");
+ fullscreen_res->list.push_back("1440x900");
+ fullscreen_res->list.push_back("1680x1050");
+ fullscreen_res->list.push_back("1600x1200");
+ fullscreen_res->list.push_back("1920x1080");
+ fullscreen_res->list.push_back("1920x1200");
+ }
+ else
+ {
+ for(int i = 0; modes[i]; ++i)
+ {
+ std::ostringstream out;
+ out << modes[i]->w << "x" << modes[i]->h;
+ fullscreen_res->list.push_back(out.str());
+ }
+ }
+
+ MenuItem* aspect = add_string_select(MNID_ASPECTRATIO, _("Aspect Ratio"));
+ aspect->set_help(_("Adjust the aspect ratio"));
+
+ aspect->list.push_back("auto");
+ aspect->list.push_back("5:4");
+ aspect->list.push_back("4:3");
+ aspect->list.push_back("16:10");
+ aspect->list.push_back("16:9");
+ aspect->list.push_back("1368:768");
+
+ if (g_config->aspect_width != 0 && g_config->aspect_height != 0)
+ {
+ std::ostringstream out;
+ out << g_config->aspect_width << ":" << g_config->aspect_height;
+ std::string aspect_ratio = out.str();
+ for(std::vector<std::string>::iterator i = aspect->list.begin(); i != aspect->list.end(); ++i)
+ {
+ if(*i == aspect_ratio)
+ {
+ aspect_ratio.clear();
+ break;
+ }
+ }
+
+ if (!aspect_ratio.empty())
+ {
+ aspect->selected = aspect->list.size();
+ aspect->list.push_back(aspect_ratio);
+ }
+ }
+
+ if (sound_manager->is_audio_enabled()) {
+ add_toggle(MNID_SOUND, _("Sound"), g_config->sound_enabled)
+ ->set_help(_("Disable all sound effects"));
+ add_toggle(MNID_MUSIC, _("Music"), g_config->music_enabled)
+ ->set_help(_("Disable all music"));
+ } else {
+ add_inactive(MNID_SOUND, _("Sound (disabled)"));
+ add_inactive(MNID_MUSIC, _("Music (disabled)"));
+ }
+
+ add_submenu(_("Setup Keyboard"), g_main_controller->get_key_options_menu())
+ ->set_help(_("Configure key-action mappings"));
+
+ add_submenu(_("Setup Joystick") ,g_main_controller->get_joystick_options_menu())
+ ->set_help(_("Configure joystick control-action mappings"));
+ add_hl();
+ add_back(_("Back"));
+}
+
+OptionsMenu::~OptionsMenu()
+{
+}
+
+void
+OptionsMenu::menu_action(MenuItem* item)
+{
+ switch (item->id) {
+ case MNID_ASPECTRATIO:
+ {
+ if (item->list[item->selected] == "auto")
+ {
+ g_config->aspect_width = 0; // Magic values
+ g_config->aspect_height = 0;
+ Renderer::instance()->apply_config();
+ Menu::recalc_pos();
+ }
+ else if(sscanf(item->list[item->selected].c_str(), "%d:%d", &g_config->aspect_width, &g_config->aspect_height) == 2)
+ {
+ Renderer::instance()->apply_config();
+ Menu::recalc_pos();
+ }
+ else
+ {
+ assert(!"This must not be reached");
+ }
+ }
+ break;
+
+ case MNID_MAGNIFICATION:
+ if (item->list[item->selected] == "auto")
+ {
+ g_config->magnification = 0.0f; // Magic value
+ }
+ else if(sscanf(item->list[item->selected].c_str(), "%f", &g_config->magnification) == 1)
+ {
+ g_config->magnification /= 100.0f;
+ }
+ Renderer::instance()->apply_config();
+ Menu::recalc_pos();
+ break;
+
+ case MNID_FULLSCREEN_RESOLUTION:
+ if(sscanf(item->list[item->selected].c_str(), "%dx%d", &g_config->fullscreen_width, &g_config->fullscreen_height) == 2)
+ {
+ // do nothing, changes are only applied when toggling fullscreen mode
+ }
+ break;
+
+ case MNID_FULLSCREEN:
+ if(g_config->use_fullscreen != options_menu->is_toggled(MNID_FULLSCREEN)) {
+ g_config->use_fullscreen = !g_config->use_fullscreen;
+ init_video(); // FIXME: Should call apply_config instead
+ Menu::recalc_pos();
+ g_config->save();
+ }
+ break;
+
+ case MNID_SOUND:
+ if(g_config->sound_enabled != options_menu->is_toggled(MNID_SOUND)) {
+ g_config->sound_enabled = !g_config->sound_enabled;
+ sound_manager->enable_sound(g_config->sound_enabled);
+ g_config->save();
+ }
+ break;
+
+ case MNID_MUSIC:
+ if(g_config->music_enabled != options_menu->is_toggled(MNID_MUSIC)) {
+ g_config->music_enabled = !g_config->music_enabled;
+ sound_manager->enable_music(g_config->music_enabled);
+ g_config->save();
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+Menu* get_options_menu()
+{
+ //static OptionsMenu menu;
+ options_menu = new OptionsMenu();
+ return options_menu;
+}
+
+void free_options_menu()
+{
+ delete options_menu;
+ options_menu = 0;
+}
+
+/* EOF */
--- /dev/null
+// SuperTux
+// Copyright (C) 2004 Tobas Glaesser <tobi.web@gmx.de>
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_SUPERTUX_OPTIONS_MENU_HPP
+#define HEADER_SUPERTUX_SUPERTUX_OPTIONS_MENU_HPP
+
+#include <memory>
+
+#include "gui/menu.hpp"
+
+class LanguageMenu;
+
+Menu* get_options_menu();
+void free_options_menu();
+
+class OptionsMenu : public Menu
+{
+public:
+ OptionsMenu();
+ virtual ~OptionsMenu();
+
+ virtual void menu_action(MenuItem* item);
+
+protected:
+ std::auto_ptr<LanguageMenu> language_menu;
+
+};
+
+#endif
+
+/* EOF */
--- /dev/null
+// SuperTux
+// Copyright (C) 2008 Ingo Ruhnke <grumbel@gmx.de>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include <sstream>
+
+#include "gui/menu.hpp"
+#include "gui/menu_item.hpp"
+#include "supertux/gameconfig.hpp"
+#include "util/gettext.hpp"
+
+enum ProfileMenuIDs {
+
+};
+
+class ProfileMenu : public Menu
+{
+public:
+ ProfileMenu() {
+ add_label(_("Select Profile"));
+ add_hl();
+ for(int i = 0; i < 5; ++i)
+ {
+ std::ostringstream out;
+ out << "Profile " << i+1;
+ add_entry(i+1, out.str());
+ }
+
+ add_hl();
+ add_back(_("Back"));
+ }
+
+ void menu_action(MenuItem* item) {
+ g_config->profile = item->id;
+ Menu::set_current(0);
+ }
+};
+
+Menu* profile_menu = 0;
+
+Menu* get_profile_menu()
+{
+ //static ProfileMenu menu;
+ profile_menu = new ProfileMenu();
+ return profile_menu;
+}
+
+void free_profile_menu()
+{
+ delete profile_menu;
+ profile_menu = 0;
+}
+
+/*
+ std::string
+ TitleScreen::get_slotinfo(int slot)
+ {
+ std::string tmp;
+ std::string title;
+
+ std::string basename = current_world->get_basedir();
+ basename = basename.substr(0, basename.length()-1);
+ std::string worlddirname = FileSystem::basename(basename);
+ std::ostringstream stream;
+ stream << "profile" << config->profile << "/" << worlddirname << "_" << slot << ".stsg";
+ std::string slotfile = stream.str();
+
+ try {
+ lisp::Parser parser;
+ const lisp::Lisp* root = parser.parse(slotfile);
+
+ const lisp::Lisp* savegame = root->get_lisp("supertux-savegame");
+ if(!savegame)
+ throw std::runtime_error("file is not a supertux-savegame.");
+
+ savegame->get("title", title);
+ } catch(std::exception& ) {
+ std::ostringstream slottitle;
+ slottitle << _("Slot") << " " << slot << " - " << _("Free");
+ return slottitle.str();
+ }
+
+ std::ostringstream slottitle;
+ slottitle << _("Slot") << " " << slot << " - " << title;
+ return slottitle.str();
+ }
+*/
+
+/* EOF */
--- /dev/null
+// SuperTux
+// Copyright (C) 2008 Ingo Ruhnke <grumbel@gmx.de>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_SUPERTUX_PROFILE_MENU_HPP
+#define HEADER_SUPERTUX_SUPERTUX_PROFILE_MENU_HPP
+
+class Menu;
+Menu* get_profile_menu();
+void free_profile_menu();
+
+#endif
+
+/* EOF */
+++ /dev/null
-// SuperTux
-// Copyright (C) 2004 Tobas Glaesser <tobi.web@gmx.de>
-// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include "supertux/options_menu.hpp"
-
-#include "audio/sound_manager.hpp"
-#include "control/joystickkeyboardcontroller.hpp"
-#include "gui/menu.hpp"
-#include "gui/menu_item.hpp"
-#include "supertux/gameconfig.hpp"
-#include "supertux/globals.hpp"
-#include "supertux/main.hpp"
-#include "supertux/profile_menu.hpp"
-#include "supertux/language_menu.hpp"
-#include "util/gettext.hpp"
-#include "video/renderer.hpp"
-
-Menu* options_menu = 0;
-
-enum OptionsMenuIDs {
- MNID_FULLSCREEN,
- MNID_FULLSCREEN_RESOLUTION,
- MNID_MAGNIFICATION,
- MNID_ASPECTRATIO,
- MNID_PROFILES,
- MNID_SOUND,
- MNID_MUSIC
-};
-
-OptionsMenu::OptionsMenu() :
- language_menu()
-{
- language_menu.reset(new LanguageMenu());
-
- add_label(_("Options"));
- add_hl();
-
- // Language change should only be possible in the main menu, since elsewhere it might not always work fully
- // FIXME: Implement me: if (get_parent() == main_menu)
- add_submenu(_("Select Language"), language_menu.get())
- ->set_help(_("Select a different language to display text in"));
-
- add_submenu(_("Select Profile"), get_profile_menu())
- ->set_help(_("Select a profile to play with"));
-
- add_toggle(MNID_PROFILES, _("Profile on Startup"), g_config->sound_enabled)
- ->set_help(_("Select your profile immediately after start-up"));
-
- add_toggle(MNID_FULLSCREEN,_("Fullscreen"), g_config->use_fullscreen)
- ->set_help(_("Fill the entire screen"));
-
- MenuItem* fullscreen_res = add_string_select(MNID_FULLSCREEN_RESOLUTION, _("Resolution"));
- fullscreen_res->set_help(_("Determine the resolution used in fullscreen mode (you must toggle fullscreen to complete the change)"));
-
- MenuItem* magnification = add_string_select(MNID_MAGNIFICATION, _("Magnification"));
- magnification->set_help(_("Change the magnification of the game area"));
-
- // These values go from screen:640/projection:1600 to
- // screen:1600/projection:640 (i.e. 640, 800, 1024, 1280, 1600)
- magnification->list.push_back("auto");
- magnification->list.push_back("40%");
- magnification->list.push_back("50%");
- magnification->list.push_back("62.5%");
- magnification->list.push_back("80%");
- magnification->list.push_back("100%");
- magnification->list.push_back("125%");
- magnification->list.push_back("160%");
- magnification->list.push_back("200%");
- magnification->list.push_back("250%");
-
- SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL);
-
- if (modes == (SDL_Rect **)0)
- { // No resolutions at all available, bad
-
- }
- else if(modes == (SDL_Rect **)-1)
- { // All resolutions should work, so we fall back to hardcoded defaults
- fullscreen_res->list.push_back("640x480");
- fullscreen_res->list.push_back("800x600");
- fullscreen_res->list.push_back("1024x768");
- fullscreen_res->list.push_back("1152x864");
- fullscreen_res->list.push_back("1280x960");
- fullscreen_res->list.push_back("1280x1024");
- fullscreen_res->list.push_back("1440x900");
- fullscreen_res->list.push_back("1680x1050");
- fullscreen_res->list.push_back("1600x1200");
- fullscreen_res->list.push_back("1920x1080");
- fullscreen_res->list.push_back("1920x1200");
- }
- else
- {
- for(int i = 0; modes[i]; ++i)
- {
- std::ostringstream out;
- out << modes[i]->w << "x" << modes[i]->h;
- fullscreen_res->list.push_back(out.str());
- }
- }
-
- MenuItem* aspect = add_string_select(MNID_ASPECTRATIO, _("Aspect Ratio"));
- aspect->set_help(_("Adjust the aspect ratio"));
-
- aspect->list.push_back("auto");
- aspect->list.push_back("5:4");
- aspect->list.push_back("4:3");
- aspect->list.push_back("16:10");
- aspect->list.push_back("16:9");
- aspect->list.push_back("1368:768");
-
- if (g_config->aspect_width != 0 && g_config->aspect_height != 0)
- {
- std::ostringstream out;
- out << g_config->aspect_width << ":" << g_config->aspect_height;
- std::string aspect_ratio = out.str();
- for(std::vector<std::string>::iterator i = aspect->list.begin(); i != aspect->list.end(); ++i)
- {
- if(*i == aspect_ratio)
- {
- aspect_ratio.clear();
- break;
- }
- }
-
- if (!aspect_ratio.empty())
- {
- aspect->selected = aspect->list.size();
- aspect->list.push_back(aspect_ratio);
- }
- }
-
- if (sound_manager->is_audio_enabled()) {
- add_toggle(MNID_SOUND, _("Sound"), g_config->sound_enabled)
- ->set_help(_("Disable all sound effects"));
- add_toggle(MNID_MUSIC, _("Music"), g_config->music_enabled)
- ->set_help(_("Disable all music"));
- } else {
- add_inactive(MNID_SOUND, _("Sound (disabled)"));
- add_inactive(MNID_MUSIC, _("Music (disabled)"));
- }
-
- add_submenu(_("Setup Keyboard"), g_main_controller->get_key_options_menu())
- ->set_help(_("Configure key-action mappings"));
-
- add_submenu(_("Setup Joystick") ,g_main_controller->get_joystick_options_menu())
- ->set_help(_("Configure joystick control-action mappings"));
- add_hl();
- add_back(_("Back"));
-}
-
-OptionsMenu::~OptionsMenu()
-{
-}
-
-void
-OptionsMenu::menu_action(MenuItem* item)
-{
- switch (item->id) {
- case MNID_ASPECTRATIO:
- {
- if (item->list[item->selected] == "auto")
- {
- g_config->aspect_width = 0; // Magic values
- g_config->aspect_height = 0;
- Renderer::instance()->apply_config();
- Menu::recalc_pos();
- }
- else if(sscanf(item->list[item->selected].c_str(), "%d:%d", &g_config->aspect_width, &g_config->aspect_height) == 2)
- {
- Renderer::instance()->apply_config();
- Menu::recalc_pos();
- }
- else
- {
- assert(!"This must not be reached");
- }
- }
- break;
-
- case MNID_MAGNIFICATION:
- if (item->list[item->selected] == "auto")
- {
- g_config->magnification = 0.0f; // Magic value
- }
- else if(sscanf(item->list[item->selected].c_str(), "%f", &g_config->magnification) == 1)
- {
- g_config->magnification /= 100.0f;
- }
- Renderer::instance()->apply_config();
- Menu::recalc_pos();
- break;
-
- case MNID_FULLSCREEN_RESOLUTION:
- if(sscanf(item->list[item->selected].c_str(), "%dx%d", &g_config->fullscreen_width, &g_config->fullscreen_height) == 2)
- {
- // do nothing, changes are only applied when toggling fullscreen mode
- }
- break;
-
- case MNID_FULLSCREEN:
- if(g_config->use_fullscreen != options_menu->is_toggled(MNID_FULLSCREEN)) {
- g_config->use_fullscreen = !g_config->use_fullscreen;
- init_video(); // FIXME: Should call apply_config instead
- Menu::recalc_pos();
- g_config->save();
- }
- break;
-
- case MNID_SOUND:
- if(g_config->sound_enabled != options_menu->is_toggled(MNID_SOUND)) {
- g_config->sound_enabled = !g_config->sound_enabled;
- sound_manager->enable_sound(g_config->sound_enabled);
- g_config->save();
- }
- break;
-
- case MNID_MUSIC:
- if(g_config->music_enabled != options_menu->is_toggled(MNID_MUSIC)) {
- g_config->music_enabled = !g_config->music_enabled;
- sound_manager->enable_music(g_config->music_enabled);
- g_config->save();
- }
- break;
-
- default:
- break;
- }
-}
-
-Menu* get_options_menu()
-{
- //static OptionsMenu menu;
- options_menu = new OptionsMenu();
- return options_menu;
-}
-
-void free_options_menu()
-{
- delete options_menu;
- options_menu = 0;
-}
-
-/* EOF */
+++ /dev/null
-// SuperTux
-// Copyright (C) 2004 Tobas Glaesser <tobi.web@gmx.de>
-// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_SUPERTUX_SUPERTUX_OPTIONS_MENU_HPP
-#define HEADER_SUPERTUX_SUPERTUX_OPTIONS_MENU_HPP
-
-#include <memory>
-
-#include "gui/menu.hpp"
-
-class LanguageMenu;
-
-Menu* get_options_menu();
-void free_options_menu();
-
-class OptionsMenu : public Menu
-{
-public:
- OptionsMenu();
- virtual ~OptionsMenu();
-
- virtual void menu_action(MenuItem* item);
-
-protected:
- std::auto_ptr<LanguageMenu> language_menu;
-
-};
-
-#endif
-
-/* EOF */
+++ /dev/null
-// SuperTux
-// Copyright (C) 2008 Ingo Ruhnke <grumbel@gmx.de>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include <sstream>
-
-#include "gui/menu.hpp"
-#include "gui/menu_item.hpp"
-#include "supertux/gameconfig.hpp"
-#include "util/gettext.hpp"
-
-enum ProfileMenuIDs {
-
-};
-
-class ProfileMenu : public Menu
-{
-public:
- ProfileMenu() {
- add_label(_("Select Profile"));
- add_hl();
- for(int i = 0; i < 5; ++i)
- {
- std::ostringstream out;
- out << "Profile " << i+1;
- add_entry(i+1, out.str());
- }
-
- add_hl();
- add_back(_("Back"));
- }
-
- void menu_action(MenuItem* item) {
- g_config->profile = item->id;
- Menu::set_current(0);
- }
-};
-
-Menu* profile_menu = 0;
-
-Menu* get_profile_menu()
-{
- //static ProfileMenu menu;
- profile_menu = new ProfileMenu();
- return profile_menu;
-}
-
-void free_profile_menu()
-{
- delete profile_menu;
- profile_menu = 0;
-}
-
-/*
- std::string
- TitleScreen::get_slotinfo(int slot)
- {
- std::string tmp;
- std::string title;
-
- std::string basename = current_world->get_basedir();
- basename = basename.substr(0, basename.length()-1);
- std::string worlddirname = FileSystem::basename(basename);
- std::ostringstream stream;
- stream << "profile" << config->profile << "/" << worlddirname << "_" << slot << ".stsg";
- std::string slotfile = stream.str();
-
- try {
- lisp::Parser parser;
- const lisp::Lisp* root = parser.parse(slotfile);
-
- const lisp::Lisp* savegame = root->get_lisp("supertux-savegame");
- if(!savegame)
- throw std::runtime_error("file is not a supertux-savegame.");
-
- savegame->get("title", title);
- } catch(std::exception& ) {
- std::ostringstream slottitle;
- slottitle << _("Slot") << " " << slot << " - " << _("Free");
- return slottitle.str();
- }
-
- std::ostringstream slottitle;
- slottitle << _("Slot") << " " << slot << " - " << title;
- return slottitle.str();
- }
-*/
-
-/* EOF */
+++ /dev/null
-// SuperTux
-// Copyright (C) 2008 Ingo Ruhnke <grumbel@gmx.de>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_SUPERTUX_SUPERTUX_PROFILE_MENU_HPP
-#define HEADER_SUPERTUX_SUPERTUX_PROFILE_MENU_HPP
-
-class Menu;
-Menu* get_profile_menu();
-void free_profile_menu();
-
-#endif
-
-/* EOF */
#include "supertux/gameconfig.hpp"
#include "supertux/globals.hpp"
#include "supertux/mainloop.hpp"
-#include "supertux/options_menu.hpp"
+#include "supertux/menu/options_menu.hpp"
#include "supertux/resources.hpp"
#include "supertux/sector.hpp"
#include "supertux/textscroller.hpp"
#include "supertux/game_session.hpp"
#include "supertux/globals.hpp"
#include "supertux/mainloop.hpp"
-#include "supertux/options_menu.hpp"
+#include "supertux/menu/options_menu.hpp"
#include "supertux/player_status.hpp"
#include "supertux/resources.hpp"
#include "supertux/sector.hpp"