aspect_ratio = -1; // autodetect
enable_script_debugger = false;
+
+ locale = ""; // autodetect
}
Config::~Config()
config_lisp->get("show_fps", show_fps);
config_lisp->get("console", console_enabled);
+ config_lisp->get("locale", locale);
config_lisp->get("random_seed", random_seed);
const lisp::Lisp* config_video_lisp = config_lisp->get_lisp("video");
writer.write_bool("show_fps", show_fps);
writer.write_bool("console", console_enabled);
+ writer.write_string("locale", locale);
writer.start_list("video");
writer.write_bool("fullscreen", use_fullscreen);
bool enable_script_debugger;
std::string start_demo;
std::string record_demo;
+
+ std::string locale; /**< force SuperTux language to this locale, e.g. "de". A file "data/locale/xx.po" must exist for this to work. An empty string means autodetect. */
};
extern Config* config;
#include "lisp.hpp"
#include "obstack/obstackpp.hpp"
+#include "gameconfig.hpp"
+
namespace lisp
{
if(translate) {
dictionary_manager = new TinyGetText::DictionaryManager();
dictionary_manager->set_charset("UTF-8");
+ if (config && (config->locale != "")) dictionary_manager->set_language(config->locale);
}
obstack_init(&obst);
{
dictionary_manager.add_directory("locale");
dictionary_manager.set_charset("UTF-8");
+
+ // Config setting "locale" overrides language detection
+ if (config->locale != "") {
+ dictionary_manager.set_language( config->locale );
+ }
}
static void init_physfs(const char* argv0)
for(int i = 1; i < argc; ++i) {
std::string arg = argv[i];
- if(arg == "--help") {
- print_usage(argv[0]);
- return true;
- } else if(arg == "--version") {
+ if(arg == "--version") {
std::cout << PACKAGE_NAME << " " << PACKAGE_VERSION << std::endl;
return true;
}
for(int i = 1; i < argc; ++i) {
std::string arg = argv[i];
- if(arg == "--fullscreen" || arg == "-f") {
+ if(arg == "--help") {
+ print_usage(argv[0]);
+ return true;
+ } else if(arg == "--fullscreen" || arg == "-f") {
config->use_fullscreen = true;
} else if(arg == "--window" || arg == "-w") {
config->use_fullscreen = false;
MNID_MUSIC
};
+class LanguageMenu : public Menu
+{
+public:
+ LanguageMenu() {
+ add_label(_("Language"));
+ add_hl();
+ add_entry(0, std::string("(")+_("auto-detect language")+")");
+
+ int mnid = 10;
+ std::set<std::string> languages = dictionary_manager.get_languages();
+ for (std::set<std::string>::iterator i = languages.begin(); i != languages.end(); i++) {
+ std::string locale_name = *i;
+ TinyGetText::LanguageDef ldef = TinyGetText::get_language_def(locale_name);
+ std::string locale_fullname = locale_name;
+ if (std::string(ldef.code) == locale_name) {
+ locale_fullname = ldef.name;
+ }
+ add_entry(mnid++, locale_fullname);
+ }
+
+ add_hl();
+ add_back(_("Back"));
+ }
+
+ virtual void menu_action(MenuItem* item) {
+ if (item->id == 0) {
+ config->locale = "";
+ dictionary_manager.set_language(config->locale);
+ config->save();
+ Menu::set_current(0);
+ }
+ int mnid = 10;
+ std::set<std::string> languages = dictionary_manager.get_languages();
+ for (std::set<std::string>::iterator i = languages.begin(); i != languages.end(); i++) {
+ std::string locale_name = *i;
+ if (item->id == mnid++) {
+ config->locale = locale_name;
+ dictionary_manager.set_language(config->locale);
+ config->save();
+ Menu::set_current(0);
+ }
+ }
+ }
+};
+
+
class OptionsMenu : public Menu
{
public:
virtual ~OptionsMenu();
virtual void menu_action(MenuItem* item);
+
+protected:
+ std::auto_ptr<LanguageMenu> language_menu;
+
};
OptionsMenu::OptionsMenu()
{
+ language_menu.reset(new LanguageMenu());
+
add_label(_("Options"));
add_hl();
add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen);
+ add_submenu(_("Language"), language_menu.get());
if (sound_manager->is_audio_enabled()) {
add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled);
add_toggle(MNID_MUSIC, _("Music"), config->music_enabled);
Menu* get_options_menu()
{
- if(options_menu == NULL)
- options_menu = new OptionsMenu();
+ //if(options_menu == NULL)
+ options_menu = new OptionsMenu();
return options_menu;
}
if (!addon.isInstalled) {
try {
addon.install();
- generate_addons_menu();
- Menu::set_current(addons_menu.get());
- addons_menu->set_active_item(index);
+ //generate_addons_menu();
+ //Menu::set_current(addons_menu.get());
+ //addons_menu->set_active_item(index);
+ Menu::set_current(0);
}
catch (std::runtime_error e) {
log_warning << "Installation of Add-on failed: " << e.what() << std::endl;
} else {
try {
addon.remove();
- generate_addons_menu();
- Menu::set_current(addons_menu.get());
- addons_menu->set_active_item(index);
+ //generate_addons_menu();
+ //Menu::set_current(addons_menu.get());
+ //addons_menu->set_active_item(index);
+ Menu::set_current(0);
}
catch (std::runtime_error e) {
log_warning << "Removal of Add-on failed: " << e.what() << std::endl;
player->set_controller(controller.get());
player->set_speedlimit(230); //MAX_WALK_XM
+ generate_main_menu();
+}
+
+void
+TitleScreen::generate_main_menu()
+{
main_menu.reset(new Menu());
main_menu->set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2 + 35);
main_menu->add_entry(MNID_STARTGAME, _("Start Game"));
// reopen menu of user closed it (so that the app doesn't close when user
// accidently hit ESC)
if(Menu::current() == 0) {
+ generate_main_menu();
Menu::set_current(main_menu.get());
}
}
bool process_load_game_menu();
void make_tux_jump();
void update_load_game_menu();
+ void generate_main_menu();
void generate_contrib_menu();
void check_levels_contrib_menu();
void check_contrib_world_menu();