void PingusMain::print_greeting_message() { std::string greeting = "Welcome to Pingus 0.7.6"/*VERSION*/; greeting += "!"; std::cout << greeting << std::endl; for (unsigned int i = 0; i < greeting.length(); ++i) std::cout.put('='); std::cout << std::endl; std::cout << "userdir: " << System::get_userdir() << std::endl; std::cout << "datadir: " << g_path_manager.get_path() << std::endl; std::cout << "language: " << dictionary_manager.get_language().get_name() << " (" << dictionary_manager.get_language().str() << ")" << std::endl; if (globals::sound_enabled) std::cout << "sound support: enabled" << std::endl; else std::cout << "sound support: disabled" << std::endl; if (globals::music_enabled) std::cout << "music support: enabled" << std::endl; else std::cout << "music support: disabled" << std::endl; std::cout << "fullscreen: "; if (cmd_options.fullscreen.is_set() && cmd_options.fullscreen.get()) { std::cout << cmd_options.fullscreen_resolution.get().width << "x" << cmd_options.fullscreen_resolution.get().height << std::endl; } else { std::cout << "disabled" << std::endl; } std::cout << std::endl; }
/** * @brief Loads a localization file * @param[in] language */ void I18N_SetLanguage(const char *language) { // TODO: check if there is a localization file available for the selected language dictionary.set_language(tinygettext::Language::from_env(std::string(language))); dictionary_mod.set_language(tinygettext::Language::from_env(std::string(language))); Com_Printf("Language set to %s\n", dictionary.get_language().get_name().c_str()); Com_sprintf(cl_lang_last, sizeof(cl_lang_last), "%s", language); if (!Q_stricmp(cl_lang->string, "en")) { doTranslate = qfalse; } else { doTranslate = qtrue; } strings.clear(); }
tinygettext::Language ConfigManager::get_language() const { return dictionary_manager.get_language(); }
OptionMenu::OptionMenu() : background(), ok_button(), x_pos(), y_pos(), options(), fullscreen_box(), swcursor_box(), autoscroll_box(), mousegrab_box(), printfps_box(), master_volume_box(), sound_volume_box(), music_volume_box(), defaults_label(), defaults_box(), connections(), language(), language_map() { background = Sprite("core/menu/optionmenu"); gui_manager->add(ok_button = new OptionMenuCloseButton(this, Display::get_width()/2 + 225, Display::get_height()/2 + 125)); x_pos = 0; y_pos = 0; int resolutions[][2] = { { 640, 480 }, // 4:3, VGA { 768, 576 }, // 4:3, PAL { 800, 480 }, // Nokia N770, N800 { 800, 600 }, // 4:3, SVGA { 1024, 768 }, // 4:3, XGA { 1152, 864 }, // 4:3 { 1280, 720 }, // 16:9, HD-TV, 720p { 1280, 960 }, // 4:3 { 1280, 1024 }, // 5:4 { 1366, 768 }, // ~16:9, Wide XGA { 1440, 900, }, // 16:10 { 1600, 1200 }, // 4:3, UXGA { 1680, 1050 }, // 16:10, WSXGA { 1920, 1080 }, // 16:9, HD-TV, 1080p { 1920, 1200 }, // 16:10 { -1, -1 } }; int current_choice = -1; int n; ChoiceBox* resolution_box = new ChoiceBox(Rect()); for (n = 0; resolutions[n][0] != -1; ++n) { std::ostringstream ostr; ostr << resolutions[n][0] << "x" << resolutions[n][1]; resolution_box->add_choice(ostr.str()); if (Display::get_width() == resolutions[n][0] && Display::get_height() == resolutions[n][1]) { current_choice = n; } } resolution_box->add_choice("Custom"); if (current_choice == -1) current_choice = n; resolution_box->set_current_choice(current_choice); tinygettext::Language current_language = dictionary_manager.get_language(); language = current_language; n = 0; ChoiceBox* language_box = new ChoiceBox(Rect()); std::set<tinygettext::Language> languages = dictionary_manager.get_languages(); for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); ++i) { language_box->add_choice(i->str()); if (current_language == *i) language_box->set_current_choice(current_choice); } ChoiceBox* scroll_box = new ChoiceBox(Rect()); scroll_box->add_choice("Drag&Drop"); scroll_box->add_choice("Rubberband"); swcursor_box = new CheckBox(Rect()); fullscreen_box = new CheckBox(Rect()); autoscroll_box = new CheckBox(Rect()); mousegrab_box = new CheckBox(Rect()); printfps_box = new CheckBox(Rect()); master_volume_box = new SliderBox(Rect()); sound_volume_box = new SliderBox(Rect()); music_volume_box = new SliderBox(Rect()); C(swcursor_box->on_change.connect(std::bind(&OptionMenu::on_swcursor_change, this, std::placeholders::_1))); C(fullscreen_box->on_change.connect(std::bind(&OptionMenu::on_fullscreen_change, this, std::placeholders::_1))); C(autoscroll_box->on_change.connect(std::bind(&OptionMenu::on_autoscroll_change, this, std::placeholders::_1))); C(mousegrab_box->on_change.connect(std::bind(&OptionMenu::on_mousegrab_change, this, std::placeholders::_1))); C(printfps_box->on_change.connect(std::bind(&OptionMenu::on_printfps_change, this, std::placeholders::_1))); C(master_volume_box->on_change.connect(std::bind(&OptionMenu::on_master_volume_change, this, std::placeholders::_1))); C(sound_volume_box->on_change.connect(std::bind(&OptionMenu::on_sound_volume_change, this, std::placeholders::_1))); C(music_volume_box->on_change.connect(std::bind(&OptionMenu::on_music_volume_change, this, std::placeholders::_1))); C(language_box->on_change.connect(std::bind(&OptionMenu::on_language_change, this, std::placeholders::_1))); C(resolution_box->on_change.connect(std::bind(&OptionMenu::on_resolution_change, this, std::placeholders::_1))); add_item(_("Language:"), language_box); // add_item(_("Scroll Mode:"), scroll_box); add_item(_("Resolution:"), resolution_box); add_item(_("Fullscreen:"), fullscreen_box); add_item(_("Master Volume:"), master_volume_box); add_item(_("Sound Volume:"), sound_volume_box); add_item(_("Music Volume:"), music_volume_box); add_item(_("Autoscrolling:"), autoscroll_box); add_item(_("Print FPS:"), printfps_box); add_item(_("Mouse Grab:"), mousegrab_box); add_item(_("Software Cursor:"), swcursor_box); // Connect with ConfigManager mousegrab_box->set_state(config_manager.get_mouse_grab(), false); C(config_manager.on_mouse_grab_change.connect(std::bind(&CheckBox::set_state, mousegrab_box, std::placeholders::_1, false))); printfps_box->set_state(config_manager.get_print_fps(), false); C(config_manager.on_print_fps_change.connect(std::bind(&CheckBox::set_state, printfps_box, std::placeholders::_1, false))); fullscreen_box->set_state(config_manager.get_fullscreen(), false); C(config_manager.on_fullscreen_change.connect(std::bind(&CheckBox::set_state, fullscreen_box, std::placeholders::_1, false))); swcursor_box->set_state(config_manager.get_swcursor(), false); C(config_manager.on_swcursor_change.connect(std::bind(&CheckBox::set_state, swcursor_box, std::placeholders::_1, false))); autoscroll_box->set_state(config_manager.get_autoscroll(), false); C(config_manager.on_autoscroll_change.connect(std::bind(&CheckBox::set_state, autoscroll_box, std::placeholders::_1, false))); defaults_label = new Label(_("Reset to Defaults:"), Rect(Vector2i(Display::get_width()/2 - 100, Display::get_height()/2 + 160), Size(170, 32))); gui_manager->add(defaults_label); defaults_box = new CheckBox(Rect(Vector2i(Display::get_width()/2 - 100 + 170, Display::get_height()/2 + 160), Size(32, 32))); gui_manager->add(defaults_box); }
OptionMenu::OptionMenu() : m_background("core/menu/wood"), m_blackboard("core/menu/blackboard"), ok_button(), x_pos(), y_pos(), options(), fullscreen_box(), software_cursor_box(), autoscroll_box(), dragdrop_scroll_box(), mousegrab_box(), printfps_box(), master_volume_box(), sound_volume_box(), music_volume_box(), //defaults_label(), //defaults_box(), connections(), m_language(), m_language_map() { gui_manager->add(ok_button = new OptionMenuCloseButton(this, Display::get_width()/2 + 245, Display::get_height()/2 + 150)); x_pos = 0; y_pos = 0; ChoiceBox* resolution_box = new ChoiceBox(Rect()); { std::vector<SDL_DisplayMode> resolutions = Display::get_fullscreen_video_modes(); Size fullscreen = config_manager.get_fullscreen_resolution(); int choice = static_cast<int>(resolutions.size()) - 1; for (auto it = resolutions.begin(); it != resolutions.end(); ++it) { // add resolution to the box std::ostringstream ostr; ostr << it->w << "x" << it->h << "@" << it->refresh_rate; resolution_box->add_choice(ostr.str()); // FIXME: ignoring refresh_rate if (fullscreen.width == it->w && fullscreen.height == it->h) { choice = static_cast<int>(it - resolutions.begin()); } } resolution_box->set_current_choice(choice); } ChoiceBox* renderer_box = new ChoiceBox(Rect()); renderer_box->add_choice("sdl"); renderer_box->add_choice("delta"); renderer_box->add_choice("opengl"); switch(config_manager.get_renderer()) { case SDL_FRAMEBUFFER: renderer_box->set_current_choice(0); break; case DELTA_FRAMEBUFFER: renderer_box->set_current_choice(1); break; case OPENGL_FRAMEBUFFER: renderer_box->set_current_choice(2); break; default: assert(!"unknown renderer type"); } m_language = dictionary_manager.get_language(); ChoiceBox* language_box = new ChoiceBox(Rect()); { std::set<tinygettext::Language> languages = dictionary_manager.get_languages(); // English is the default language, thus it's not in the list of // languages returned by tinygettext and we have to add it manually languages.insert(tinygettext::Language::from_name("en")); std::vector<tinygettext::Language> langs(languages.begin(), languages.end()); std::sort(langs.begin(), langs.end(), LanguageSorter()); for (auto i = langs.begin(); i != langs.end(); ++i) { m_language_map[i->get_name()] = *i; language_box->add_choice(i->get_name()); if (m_language == *i) { language_box->set_current_choice(static_cast<int>(i - langs.begin())); } } } ChoiceBox* scroll_box = new ChoiceBox(Rect()); scroll_box->add_choice("Drag&Drop"); scroll_box->add_choice("Rubberband"); software_cursor_box = new CheckBox(Rect()); fullscreen_box = new CheckBox(Rect()); autoscroll_box = new CheckBox(Rect()); dragdrop_scroll_box = new CheckBox(Rect()); mousegrab_box = new CheckBox(Rect()); printfps_box = new CheckBox(Rect()); master_volume_box = new SliderBox(Rect(), 25); sound_volume_box = new SliderBox(Rect(), 25); music_volume_box = new SliderBox(Rect(), 25); master_volume_box->set_value(config_manager.get_master_volume()); sound_volume_box->set_value(config_manager.get_sound_volume()); music_volume_box->set_value(config_manager.get_music_volume()); C(software_cursor_box->on_change.connect(std::bind(&OptionMenu::on_software_cursor_change, this, std::placeholders::_1))); C(fullscreen_box->on_change.connect(std::bind(&OptionMenu::on_fullscreen_change, this, std::placeholders::_1))); C(autoscroll_box->on_change.connect(std::bind(&OptionMenu::on_autoscroll_change, this, std::placeholders::_1))); C(dragdrop_scroll_box->on_change.connect(std::bind(&OptionMenu::on_drag_drop_scrolling_change, this, std::placeholders::_1))); C(mousegrab_box->on_change.connect(std::bind(&OptionMenu::on_mousegrab_change, this, std::placeholders::_1))); C(printfps_box->on_change.connect(std::bind(&OptionMenu::on_printfps_change, this, std::placeholders::_1))); C(master_volume_box->on_change.connect(std::bind(&OptionMenu::on_master_volume_change, this, std::placeholders::_1))); C(sound_volume_box->on_change.connect(std::bind(&OptionMenu::on_sound_volume_change, this, std::placeholders::_1))); C(music_volume_box->on_change.connect(std::bind(&OptionMenu::on_music_volume_change, this, std::placeholders::_1))); C(language_box->on_change.connect(std::bind(&OptionMenu::on_language_change, this, std::placeholders::_1))); C(resolution_box->on_change.connect(std::bind(&OptionMenu::on_resolution_change, this, std::placeholders::_1))); C(renderer_box->on_change.connect(std::bind(&OptionMenu::on_renderer_change, this, std::placeholders::_1))); x_pos = 0; y_pos = 0; add_item(_("Fullscreen"), fullscreen_box); add_item(_("Mouse Grab"), mousegrab_box); y_pos += 1; add_item(_("Software Cursor"), software_cursor_box); add_item(_("Autoscrolling"), autoscroll_box); add_item(_("Drag&Drop Scrolling"), dragdrop_scroll_box); y_pos += 1; add_item(_("Print FPS"), printfps_box); x_pos = 1; y_pos = 0; add_item(_("Resolution:"), resolution_box); add_item(_("Renderer:"), renderer_box); y_pos += 1; add_item(_("Language:"), language_box); y_pos += 1; add_item(_("Master Volume:"), master_volume_box); add_item(_("Sound Volume:"), sound_volume_box); add_item(_("Music Volume:"), music_volume_box); // Connect with ConfigManager mousegrab_box->set_state(config_manager.get_mouse_grab(), false); C(config_manager.on_mouse_grab_change.connect(std::bind(&CheckBox::set_state, mousegrab_box, std::placeholders::_1, false))); printfps_box->set_state(config_manager.get_print_fps(), false); C(config_manager.on_print_fps_change.connect(std::bind(&CheckBox::set_state, printfps_box, std::placeholders::_1, false))); fullscreen_box->set_state(config_manager.get_fullscreen(), false); C(config_manager.on_fullscreen_change.connect(std::bind(&CheckBox::set_state, fullscreen_box, std::placeholders::_1, false))); software_cursor_box->set_state(config_manager.get_software_cursor(), false); C(config_manager.on_software_cursor_change.connect(std::bind(&CheckBox::set_state, software_cursor_box, std::placeholders::_1, false))); autoscroll_box->set_state(config_manager.get_auto_scrolling(), false); C(config_manager.on_auto_scrolling_change.connect(std::bind(&CheckBox::set_state, autoscroll_box, std::placeholders::_1, false))); dragdrop_scroll_box->set_state(config_manager.get_drag_drop_scrolling(), false); C(config_manager.on_drag_drop_scrolling_change.connect(std::bind(&CheckBox::set_state, dragdrop_scroll_box, std::placeholders::_1, false))); /* defaults_label = new Label(_("Reset to Defaults:"), Rect(Vector2i(Display::get_width()/2 - 100, Display::get_height()/2 + 160), Size(170, 32))); gui_manager->add(defaults_label); defaults_box = new CheckBox(Rect(Vector2i(Display::get_width()/2 - 100 + 170, Display::get_height()/2 + 160), Size(32, 32))); gui_manager->add(defaults_box); */ }