// ----------------------------------------------------------------------------- void OptionsScreenInput::init() { Screen::init(); RibbonWidget* tabBar = this->getWidget<RibbonWidget>("options_choice"); if (tabBar != NULL) tabBar->select( "tab_controls", PLAYER_ID_GAME_MASTER ); tabBar->getRibbonChildren()[0].setTooltip( _("Graphics") ); tabBar->getRibbonChildren()[1].setTooltip( _("Audio") ); tabBar->getRibbonChildren()[2].setTooltip( _("User Interface") ); tabBar->getRibbonChildren()[3].setTooltip( _("Players") ); /* DynamicRibbonWidget* devices = this->getWidget<DynamicRibbonWidget>("devices"); assert( devices != NULL ); */ buildDeviceList(); //devices->updateItemDisplay(); /* // trigger displaying bindings for default selected device const std::string name2("devices"); eventCallback(devices, name2, PLAYER_ID_GAME_MASTER); */ } // init
void OptionsScreenAudio::init() { Screen::init(); RibbonWidget* ribbon = this->getWidget<RibbonWidget>("options_choice"); if (ribbon != NULL) ribbon->select( "tab_audio", PLAYER_ID_GAME_MASTER ); ribbon->getRibbonChildren()[0].setTooltip( _("Graphics") ); ribbon->getRibbonChildren()[2].setTooltip( _("User Interface") ); ribbon->getRibbonChildren()[3].setTooltip( _("Players") ); ribbon->getRibbonChildren()[4].setTooltip( _("Controls") ); // ---- sfx volume SpinnerWidget* gauge = this->getWidget<SpinnerWidget>("sfx_volume"); assert(gauge != NULL); gauge->setValue( (int)(sfx_manager->getMasterSFXVolume()*10.0f) ); gauge = this->getWidget<SpinnerWidget>("music_volume"); assert(gauge != NULL); gauge->setValue( (int)(music_manager->getMasterMusicVolume()*10.f) ); // ---- music volume CheckBoxWidget* sfx = this->getWidget<CheckBoxWidget>("sfx_enabled"); CheckBoxWidget* music = this->getWidget<CheckBoxWidget>("music_enabled"); // ---- audio enables/disables sfx->setState( UserConfigParams::m_sfx ); music->setState( UserConfigParams::m_music ); } // init
void HelpScreen3::init() { Screen::init(); RibbonWidget* w = this->getWidget<RibbonWidget>("category"); if (w != NULL) w->select( "page3", PLAYER_ID_GAME_MASTER ); } // init
// ----------------------------------------------------------------------------- void GrandPrixEditorScreen::init() { RibbonWidget* tabs = getWidget<RibbonWidget>("gpgroups"); assert (tabs != NULL); tabs->select (StringUtils::toString(m_gpgroup), PLAYER_ID_GAME_MASTER); loadGPList(); setSelection(m_selection); }
void HelpScreen5::init() { Screen::init(); RibbonWidget* w = this->getWidget<RibbonWidget>("category"); if (w != NULL) { w->setFocusForPlayer(PLAYER_ID_GAME_MASTER); w->select( "page5", PLAYER_ID_GAME_MASTER ); } } // init
void HelpScreen1::init() { Screen::init(); RibbonWidget* w = this->getWidget<RibbonWidget>("category"); ButtonWidget* tutorial = getWidget<ButtonWidget>("startTutorial"); tutorial->setActive(StateManager::get()->getGameState() != GUIEngine::INGAME_MENU); if (w != NULL) w->select( "page1", PLAYER_ID_GAME_MASTER ); } //init
// ----------------------------------------------------------------------------- void EditTrackScreen::init() { RibbonWidget* tabs = getWidget<RibbonWidget>("trackgroups"); assert (tabs != NULL); SpinnerWidget* laps = getWidget<SpinnerWidget>("laps"); assert(laps != NULL); CheckBoxWidget* reverse = getWidget<CheckBoxWidget>("reverse"); assert(reverse != NULL); if (m_track_group.empty()) tabs->select (ALL_TRACKS_GROUP_ID, PLAYER_ID_GAME_MASTER); else tabs->select (m_track_group, PLAYER_ID_GAME_MASTER); laps->setValue(m_laps); reverse->setState(m_reverse); loadTrackList(); if (m_track == NULL) selectTrack(""); else selectTrack(m_track->getIdent()); }
// ----------------------------------------------------------------------------- void LoginScreen::init() { Screen::init(); // Make sure this tab is actually focused. RibbonWidget* tabs = this->getWidget<RibbonWidget>("login_tabs"); if (tabs) tabs->select( "tab_login", PLAYER_ID_GAME_MASTER ); TextBoxWidget *password_widget = getWidget<TextBoxWidget>("password"); password_widget->setPasswordBox(true,L'*'); m_options_widget = getWidget<RibbonWidget>("options"); assert(m_options_widget); m_options_widget->setActivated(); m_info_widget = getWidget<LabelWidget>("info"); assert(m_info_widget != NULL); m_success = false; // As default don't select 'remember' getWidget<CheckBoxWidget>("remember")->setState(false); } // init
void OptionsScreenPlayers::init() { Screen::init(); RibbonWidget* tabBar = this->getWidget<RibbonWidget>("options_choice"); if (tabBar != NULL) tabBar->select( "tab_players", PLAYER_ID_GAME_MASTER ); tabBar->getRibbonChildren()[0].setTooltip( _("Graphics") ); tabBar->getRibbonChildren()[1].setTooltip( _("Audio") ); tabBar->getRibbonChildren()[2].setTooltip( _("User Interface") ); tabBar->getRibbonChildren()[4].setTooltip( _("Controls") ); ListWidget* players = this->getWidget<ListWidget>("players"); assert(players != NULL); refreshPlayerList(); ButtonWidget* you = getWidget<ButtonWidget>("playername"); unsigned int playerID = PlayerManager::get()->getCurrentPlayer()->getUniqueID(); core::stringw player_name = L"-"; const PlayerProfile* curr = PlayerManager::get()->getPlayerById(playerID); if(curr) player_name = curr->getName(); you->setText( player_name ); ((gui::IGUIButton*)you->getIrrlichtElement())->setOverrideFont( GUIEngine::getSmallFont() ); if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) { players->setDeactivated(); you->setDeactivated(); } else { players->setActivated(); you->setActivated(); } } // init
void EasterEggScreen::init() { DynamicRibbonWidget* tracks_widget = this->getWidget<DynamicRibbonWidget>("tracks"); assert( tracks_widget != NULL ); RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups"); assert( tabs != NULL ); tabs->select(UserConfigParams::m_last_used_track_group, PLAYER_ID_GAME_MASTER); buildTrackList(); // select old track for the game master (if found) irr_driver->setTextureErrorMessage( "While loading screenshot in track screen for last track '%s':", UserConfigParams::m_last_track); if (!tracks_widget->setSelection(UserConfigParams::m_last_track, PLAYER_ID_GAME_MASTER, true)) { tracks_widget->setSelection(0, PLAYER_ID_GAME_MASTER, true); } irr_driver->unsetTextureErrorMessage(); }
void TracksScreen::init() { DynamicRibbonWidget* gps_widget = getWidget<DynamicRibbonWidget>("gps"); DynamicRibbonWidget* tracks_widget = getWidget<DynamicRibbonWidget>("tracks"); assert(tracks_widget != NULL); // Reset GP list everytime (accounts for locking changes, etc.) gps_widget->clearItems(); gps_widget->setMaxLabelLength(30); // Ensure that no GP and no track is NULL grand_prix_manager->checkConsistency(); // Build GP list const int gpAmount = grand_prix_manager->getNumberOfGrandPrix(); for (int n=0; n<gpAmount; n++) { const GrandPrixData* gp = grand_prix_manager->getGrandPrix(n); const std::vector<std::string> tracks = gp->getTrackNames(true); //Skip epmpty GPs if (gp->getNumberOfTracks()==0) continue; std::vector<std::string> screenshots; for (unsigned int t=0; t<tracks.size(); t++) { const Track* curr = track_manager->getTrack(tracks[t]); screenshots.push_back(curr->getScreenshotFile()); } assert(screenshots.size() > 0); if (PlayerManager::getCurrentPlayer()->isLocked(gp->getId())) { gps_widget->addAnimatedItem(_("Locked!"), "locked", screenshots, 1.5f, LOCKED_BADGE | TROPHY_BADGE, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE); } else { gps_widget->addAnimatedItem(translations->fribidize(gp->getName()), gp->getId(), screenshots, 1.5f, TROPHY_BADGE, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE); } } // Random GP std::vector<std::string> screenshots; screenshots.push_back(file_manager->getAsset(FileManager::GUI, "main_help.png")); gps_widget->addAnimatedItem(translations->fribidize("Random Grand Prix"), "Random Grand Prix", screenshots, 1.5f, 0, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE); gps_widget->updateItemDisplay(); RibbonWidget* tabs = getWidget<RibbonWidget>("trackgroups"); tabs->select(UserConfigParams::m_last_used_track_group, PLAYER_ID_GAME_MASTER); buildTrackList(); // select old track for the game master (if found) irr_driver->setTextureErrorMessage( "While loading screenshot in track screen for last track '%s':", UserConfigParams::m_last_track); if (!tracks_widget->setSelection(UserConfigParams::m_last_track, PLAYER_ID_GAME_MASTER, true)) { tracks_widget->setSelection(0, PLAYER_ID_GAME_MASTER, true); } irr_driver->unsetTextureErrorMessage(); } // init
// ----------------------------------------------------------------------------- void TracksScreen::init() { if (m_network_tracks) updateProgressBarText(); // change the back button image (because it makes the game quit) if (m_quit_server) { IconButtonWidget* back_button = getWidget<IconButtonWidget>("back"); back_button->setImage("gui/icons/main_quit.png"); } else { IconButtonWidget* back_button = getWidget<IconButtonWidget>("back"); back_button->setImage("gui/icons/back.png"); } DynamicRibbonWidget* tracks_widget = getWidget<DynamicRibbonWidget>("tracks"); assert(tracks_widget != NULL); RibbonWidget* tabs = getWidget<RibbonWidget>("trackgroups"); tabs->select(UserConfigParams::m_last_used_track_group, PLAYER_ID_GAME_MASTER); buildTrackList(); // select old track for the game master (if found) STKTexManager::getInstance()->setTextureErrorMessage( "While loading screenshot in track screen for last track '%s':", UserConfigParams::m_last_track); if (!tracks_widget->setSelection(UserConfigParams::m_last_track, PLAYER_ID_GAME_MASTER, true)) { tracks_widget->setSelection(0, PLAYER_ID_GAME_MASTER, true); } STKTexManager::getInstance()->unsetTextureErrorMessage(); if (m_network_tracks) { // Notice: for arena (battle / soccer) lap and reverse will be mapped to // goals / time limit and random item location auto cl = LobbyProtocol::get<ClientLobby>(); assert(cl); for (const std::string& track : cl->getAvailableTracks()) { Track* t = track_manager->getTrack(track); if (!t) { Log::fatal("TracksScreen", "Missing network track %s", track.c_str()); } video::ITexture* tex = irr_driver->getTexture(t->getScreenshotFile()); if (!tex) { tex = irr_driver->getTexture(file_manager ->getAsset(FileManager::GUI_ICON, "main_help.png")); } assert(tex); m_track_icons->addTextureAsSprite(tex); } int icon_height = getHeight() / 13; m_track_icons->setScale(icon_height / 256.0f); m_track_icons->setTargetIconSize(256, 256); m_vote_list->setIcons(m_track_icons, (int)icon_height); const PeerVote* vote = cl->getVote(STKHost::get()->getMyHostId()); if (vote) { DynamicRibbonWidget* w2 = getWidget<DynamicRibbonWidget>("tracks"); m_selected_track = track_manager->getTrack(vote->m_track_name); w2->setBadge(vote->m_track_name, OK_BADGE); } if (UserConfigParams::m_num_laps == 0 || UserConfigParams::m_num_laps > 20) UserConfigParams::m_num_laps = 1; if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL) { getWidget("lap-text")->setVisible(false); m_laps->setValue(0); m_laps->setVisible(false); getWidget("reverse-text")->setVisible(true); //I18N: In track screen getWidget<LabelWidget>("reverse-text")->setText(_("Random item location"), false); m_reversed->setVisible(true); m_reversed->setState(UserConfigParams::m_random_arena_item); if (vote) m_reversed->setState(vote->m_reverse); } else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG) { getWidget("lap-text")->setVisible(false); m_laps->setValue(0); m_laps->setVisible(false); getWidget("reverse-text")->setVisible(false); m_reversed->setState(false); m_reversed->setVisible(false); } else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER) { if (cl->isServerAutoGameTime()) { getWidget("lap-text")->setVisible(false); m_laps->setVisible(false); m_laps->setValue(0); } else { m_laps->setVisible(true); getWidget("lap-text")->setVisible(true); if (cl->getGameSetup()->isSoccerGoalTarget()) { //I18N: In track screen getWidget<LabelWidget>("lap-text")->setText(_("Number of goals to win"), false); m_laps->setValue(UserConfigParams::m_num_goals); m_laps->setMin(1); m_laps->setMax(10); } else { //I18N: In track screen getWidget<LabelWidget>("lap-text")->setText(_("Maximum time (min.)"), false); m_laps->setValue(UserConfigParams::m_soccer_time_limit); m_laps->setMin(1); m_laps->setMax(15); } if (vote) m_laps->setValue(vote->m_num_laps); } getWidget("reverse-text")->setVisible(true); //I18N: In track screen getWidget<LabelWidget>("reverse-text")->setText(_("Random item location"), false); m_reversed->setVisible(true); m_reversed->setState(UserConfigParams::m_random_arena_item); if (vote) m_reversed->setState(vote->m_reverse); } else { if (cl->isServerAutoGameTime()) { getWidget("lap-text")->setVisible(false); m_laps->setVisible(false); m_laps->setValue(0); } else { getWidget("lap-text")->setVisible(true); //I18N: In track screen getWidget<LabelWidget>("lap-text") ->setText(_("Number of laps"), false); m_laps->setVisible(true); m_laps->setMin(1); m_laps->setMax(20); m_laps->setValue(UserConfigParams::m_num_laps); if (vote) m_laps->setValue(vote->m_num_laps); } getWidget("reverse-text")->setVisible(true); //I18N: In track screen getWidget<LabelWidget>("reverse-text") ->setText(_("Drive in reverse"), false); m_reversed->setVisible(true); m_reversed->setState(false); if (vote) m_reversed->setState(vote->m_reverse); } } updatePlayerVotes(); } // init
void OptionsScreenUI::init() { Screen::init(); RibbonWidget* ribbon = getWidget<RibbonWidget>("options_choice"); assert(ribbon != NULL); ribbon->select( "tab_ui", PLAYER_ID_GAME_MASTER ); ribbon->getRibbonChildren()[0].setTooltip( _("Graphics") ); ribbon->getRibbonChildren()[1].setTooltip( _("Audio") ); ribbon->getRibbonChildren()[3].setTooltip( _("Players") ); ribbon->getRibbonChildren()[4].setTooltip( _("Controls") ); GUIEngine::SpinnerWidget* skinSelector = getWidget<GUIEngine::SpinnerWidget>("skinchoice"); assert( skinSelector != NULL ); // ---- video modes CheckBoxWidget* fps = getWidget<CheckBoxWidget>("showfps"); assert( fps != NULL ); fps->setState( UserConfigParams::m_display_fps ); CheckBoxWidget* news = getWidget<CheckBoxWidget>("enable-internet"); assert( news != NULL ); news->setState( UserConfigParams::m_internet_status ==RequestManager::IPERM_ALLOWED ); CheckBoxWidget* stats = getWidget<CheckBoxWidget>("enable-hw-report"); assert( stats != NULL ); LabelWidget *stats_label = getWidget<LabelWidget>("label-hw-report"); assert( stats_label ); stats->setState(UserConfigParams::m_hw_report_enable); if(news->getState()) { stats_label->setVisible(true); stats->setVisible(true); stats->setState(UserConfigParams::m_hw_report_enable); } else { stats_label->setVisible(false); stats->setVisible(false); } CheckBoxWidget* difficulty = getWidget<CheckBoxWidget>("perPlayerDifficulty"); assert( difficulty != NULL ); difficulty->setState( UserConfigParams::m_per_player_difficulty ); difficulty->setTooltip(_("In multiplayer mode, players can select handicapped (more difficult) profiles on the kart selection screen")); CheckBoxWidget* show_login = getWidget<CheckBoxWidget>("show-login"); assert( show_login!= NULL ); show_login->setState( UserConfigParams::m_always_show_login_screen); // --- select the right skin in the spinner bool currSkinFound = false; const int skinCount = (int) m_skins.size(); for (int n=0; n<skinCount; n++) { const std::string skinFileName = StringUtils::getBasename(m_skins[n]); if (UserConfigParams::m_skin_file.c_str() == skinFileName) { skinSelector->setValue(n); currSkinFound = true; break; } } if (!currSkinFound) { Log::warn("OptionsScreenUI", "Couldn't find current skin in the list of skins!"); skinSelector->setValue(0); GUIEngine::reloadSkin(); } // --- language ListWidget* list_widget = getWidget<ListWidget>("language"); // I18N: in the language choice, to select the same language as the OS list_widget->addItem("system", _("System Language")); const std::vector<std::string>* lang_list = translations->getLanguageList(); const int amount = (int)lang_list->size(); // The names need to be sorted alphabetically. Store the 2-letter // language names in a mapping, to be able to get them from the // user visible full name. std::vector<core::stringw> nice_lang_list; std::map<core::stringw, std::string> nice_name_2_id; for (int n=0; n<amount; n++) { std::string code_name = (*lang_list)[n]; std::string s_name = translations->getLocalizedName(code_name) + " (" + tinygettext::Language::from_name(code_name).get_language() + ")"; core::stringw nice_name = translations->fribidize(StringUtils::utf8ToWide(s_name)); nice_lang_list.push_back(nice_name); nice_name_2_id[nice_name] = code_name; } std::sort(nice_lang_list.begin(), nice_lang_list.end()); for(unsigned int i=0; i<nice_lang_list.size(); i++) { list_widget->addItem(nice_name_2_id[nice_lang_list[i]], nice_lang_list[i]); } list_widget->setSelectionID( list_widget->getItemID(UserConfigParams::m_language) ); // Forbid changing language while in-game, since this crashes (changing the language involves // tearing down and rebuilding the menu stack. not good when in-game) list_widget->setActive(StateManager::get()->getGameState() != GUIEngine::INGAME_MENU); } // init
void OptionsScreenVideo::init() { Screen::init(); RibbonWidget* ribbon = getWidget<RibbonWidget>("options_choice"); if (ribbon != NULL) ribbon->select( "tab_video", PLAYER_ID_GAME_MASTER ); ribbon->getRibbonChildren()[1].setTooltip( _("Audio") ); ribbon->getRibbonChildren()[2].setTooltip( _("User Interface") ); ribbon->getRibbonChildren()[3].setTooltip( _("Players") ); ribbon->getRibbonChildren()[4].setTooltip( _("Controls") ); GUIEngine::ButtonWidget* applyBtn = getWidget<GUIEngine::ButtonWidget>("apply_resolution"); assert( applyBtn != NULL ); GUIEngine::SpinnerWidget* gfx = getWidget<GUIEngine::SpinnerWidget>("gfx_level"); assert( gfx != NULL ); GUIEngine::CheckBoxWidget* vsync = getWidget<GUIEngine::CheckBoxWidget>("vsync"); assert( vsync != NULL ); vsync->setState( UserConfigParams::m_vsync ); // ---- video modes DynamicRibbonWidget* res = getWidget<DynamicRibbonWidget>("resolutions"); assert( res != NULL ); CheckBoxWidget* full = getWidget<CheckBoxWidget>("fullscreen"); assert( full != NULL ); full->setState( UserConfigParams::m_fullscreen ); CheckBoxWidget* rememberWinpos = getWidget<CheckBoxWidget>("rememberWinpos"); rememberWinpos->setState(UserConfigParams::m_remember_window_location); if (UserConfigParams::m_fullscreen) rememberWinpos->setDeactivated(); else rememberWinpos->setActivated(); // --- get resolution list from irrlicht the first time if (!m_inited) { res->clearItems(); const std::vector<IrrDriver::VideoMode>& modes = irr_driver->getVideoModes(); const int amount = (int)modes.size(); bool found_config_res = false; // for some odd reason, irrlicht sometimes fails to report the good // old standard resolutions // those are always useful for windowed mode // allow 800x600 only for debug mode #ifdef DEBUG bool found_800_600 = false; #endif bool found_1024_640 = false; bool found_1024_768 = false; for (int n=0; n<amount; n++) { const int w = modes[n].getWidth(); const int h = modes[n].getHeight(); const float ratio = (float)w / h; if (w == UserConfigParams::m_width && h == UserConfigParams::m_height) { found_config_res = true; } if (w == 800 && h == 600) { #ifdef DEBUG found_800_600 = true; #else continue; #endif } else if (w == 1024 && h == 640) { found_1024_640 = true; } else if (w == 1024 && h == 768) { found_1024_768 = true; } char name[32]; sprintf( name, "%ix%i", w, h ); core::stringw label; label += w; label += L"\u00D7"; label += h; #define ABOUT_EQUAL(a , b) (fabsf( a - b ) < 0.01) if (ABOUT_EQUAL( ratio, (5.0f/4.0f) )) res->addItem(label, name, "/gui/screen54.png"); else if (ABOUT_EQUAL( ratio, (4.0f/3.0f) )) res->addItem(label, name, "/gui/screen43.png"); else if (ABOUT_EQUAL( ratio, (16.0f/10.0f))) res->addItem(label, name, "/gui/screen1610.png"); else if (ABOUT_EQUAL( ratio, (5.0f/3.0f) )) res->addItem(label, name, "/gui/screen53.png"); else if (ABOUT_EQUAL( ratio, (3.0f/2.0f) )) res->addItem(label, name, "/gui/screen32.png"); else if (ABOUT_EQUAL( ratio, (16.0f/9.0f) )) res->addItem(label, name, "/gui/screen169.png"); else res->addItem(label, name, "/gui/screen_other.png"); #undef ABOUT_EQUAL } // next resolution if (!found_config_res) { const int w = UserConfigParams::m_width; const int h = UserConfigParams::m_height; const float ratio = (float)w / h; if (w == 800 && h == 600) { #ifdef DEBUG found_800_600 = true; #endif } else if (w == 1024 && h == 640) { found_1024_640 = true; } else if (w == 1024 && h == 768) { found_1024_768 = true; } char name[32]; sprintf( name, "%ix%i", w, h ); core::stringw label; label += w; label += L"\u00D7"; label += h; #define ABOUT_EQUAL(a , b) (fabsf( a - b ) < 0.01) if (ABOUT_EQUAL( ratio, (5.0f/4.0f) )) res->addItem(label, name, "/gui/screen54.png"); else if (ABOUT_EQUAL( ratio, (4.0f/3.0f) )) res->addItem(label, name, "/gui/screen43.png"); else if (ABOUT_EQUAL( ratio, (16.0f/10.0f) )) res->addItem(label, name, "/gui/screen1610.png"); else if (ABOUT_EQUAL( ratio, (5.0f/3.0f) )) res->addItem(label, name, "/gui/screen53.png"); else if (ABOUT_EQUAL( ratio, (3.0f/2.0f) )) res->addItem(label, name, "/gui/screen32.png"); else if (ABOUT_EQUAL( ratio, (16.0f/9.0f) )) res->addItem(label, name, "/gui/screen169.png"); else res->addItem(label, name, "/gui/screen_other.png"); #undef ABOUT_EQUAL } #ifdef DEBUG if (!found_800_600) { res->addItem(L"800\u00D7600", "800x600", "/gui/screen43.png"); } #endif if (!found_1024_640) { res->addItem(L"1024\u00D7640", "1024x640", "/gui/screen1610.png"); } if (!found_1024_768) { res->addItem(L"1024\u00D7768", "1024x768", "/gui/screen43.png"); } } // end if not inited res->updateItemDisplay(); // ---- select current resolution every time char searching_for[32]; snprintf(searching_for, 32, "%ix%i", (int)UserConfigParams::m_width, (int)UserConfigParams::m_height); if (!res->setSelection(searching_for, PLAYER_ID_GAME_MASTER, false /* focus it */, true /* even if deactivated*/)) { Log::error("OptionsScreenVideo", "Cannot find resolution %s", searching_for); } // --- set gfx settings values updateGfxSlider(); // ---- forbid changing resolution or animation settings from in-game // (we need to disable them last because some items can't be edited when // disabled) if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) { res->setDeactivated(); full->setDeactivated(); applyBtn->setDeactivated(); gfx->setDeactivated(); getWidget<ButtonWidget>("custom")->setDeactivated(); } else { // Enable back widgets if they were visited in-game previously res->setActivated(); full->setActivated(); applyBtn->setActivated(); gfx->setActivated(); getWidget<ButtonWidget>("custom")->setActivated(); } } // init
void KartSelectionScreen::init() { m_instance_ptr = this; Screen::init(); m_must_delete_on_back = false; RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups"); assert( tabs != NULL ); tabs->select(UserConfigParams::m_last_used_kart_group, PLAYER_ID_GAME_MASTER); Widget* placeholder = getWidget("playerskarts"); assert(placeholder != NULL); // FIXME : The reserved id value is -1 when we switch from KSS to NKSS and vice-versa m_dispatcher->setRootID(placeholder->m_reserved_id); g_root_id = placeholder->m_reserved_id; if (!m_widgets.contains(m_dispatcher)) { m_widgets.push_back(m_dispatcher); // this is only needed if the dispatcher wasn't already in // the list of widgets. If it already was, it was added along // other widgets. m_dispatcher->add(); } m_game_master_confirmed = false; tabs->setActive(true); m_kart_widgets.clearAndDeleteAll(); StateManager::get()->resetActivePlayers(); input_manager->getDeviceManager()->setAssignMode(DETECT_NEW); DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("karts"); assert( w != NULL ); KartHoverListener* karthoverListener = new KartHoverListener(this); w->registerHoverListener(karthoverListener); // Build kart list (it is built everytime, to account for .g. locking) setKartsFromCurrentGroup(); /* TODO: Ultimately, it'd be nice to *not* clear m_kart_widgets so that when players return to the kart selection screen, it will appear as it did when they left (at least when returning from the track menu). Rebuilding the screen is a little tricky. */ /* if (m_kart_widgets.size() > 0) { // trying to rebuild the screen for (int n = 0; n < m_kart_widgets.size(); n++) { PlayerKartWidget *pkw; pkw = m_kart_widgets.get(n); manualAddWidget(pkw); pkw->add(); } } else */ // For now this is what will happen if (!m_multiplayer) { joinPlayer(input_manager->getDeviceManager()->getLatestUsedDevice()); w->updateItemDisplay(); // Player 0 select default kart if (!w->setSelection(UserConfigParams::m_default_kart, 0, true)) { // if kart from config not found, select the first instead w->setSelection(0, 0, true); } } else // Add multiplayer message addMultiplayerMessage(); // This flag will cause that a 'fire' event will be mapped to 'select' (if // 'fire' is not assigned to a GUI event). This is done to support the old // way of player joining by pressing 'fire' instead of 'select'. input_manager->getDeviceManager()->mapFireToSelect(true); } // init
void OptionsScreenUI::init() { Screen::init(); RibbonWidget* ribbon = getWidget<RibbonWidget>("options_choice"); if (ribbon != NULL) ribbon->select( "tab_ui", PLAYER_ID_GAME_MASTER ); ribbon->getRibbonChildren()[0].setTooltip( _("Graphics") ); ribbon->getRibbonChildren()[1].setTooltip( _("Audio") ); ribbon->getRibbonChildren()[3].setTooltip( _("Players") ); ribbon->getRibbonChildren()[4].setTooltip( _("Controls") ); GUIEngine::SpinnerWidget* skinSelector = getWidget<GUIEngine::SpinnerWidget>("skinchoice"); assert( skinSelector != NULL ); // ---- video modes CheckBoxWidget* fps = getWidget<CheckBoxWidget>("showfps"); assert( fps != NULL ); fps->setState( UserConfigParams::m_display_fps ); CheckBoxWidget* news = getWidget<CheckBoxWidget>("enable-internet"); assert( news != NULL ); news->setState( UserConfigParams::m_internet_status ==INetworkHttp::IPERM_ALLOWED ); CheckBoxWidget* min_gui = getWidget<CheckBoxWidget>("minimal-racegui"); assert( min_gui != NULL ); min_gui->setState( UserConfigParams::m_minimal_race_gui); if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) min_gui->setDeactivated(); else min_gui->setActivated(); // --- select the right skin in the spinner bool currSkinFound = false; const int skinCount = m_skins.size(); for (int n=0; n<skinCount; n++) { const std::string skinFileName = StringUtils::getBasename(m_skins[n]); if (UserConfigParams::m_skin_file.c_str() == skinFileName) { skinSelector->setValue(n); currSkinFound = true; break; } } if (!currSkinFound) { std::cerr << "WARNING: couldn't find current skin in the list of skins!!\n"; skinSelector->setValue(0); GUIEngine::reloadSkin(); } // --- language ListWidget* list_widget = getWidget<ListWidget>("language"); // I18N: in the language choice, to select the same language as the OS list_widget->addItem("system", _("System Language")); const std::vector<std::string>* lang_list = translations->getLanguageList(); const int amount = lang_list->size(); for (int n=0; n<amount; n++) { std::string code_name = (*lang_list)[n]; std::string nice_name = tinygettext::Language::from_name(code_name.c_str()).get_name(); list_widget->addItem(code_name, core::stringw(code_name.c_str()) + " (" + nice_name.c_str() + ")"); } list_widget->setSelectionID( list_widget->getItemID(UserConfigParams::m_language) ); // Forbid changing language while in-game, since this crashes (changing the language involves // tearing down and rebuilding the menu stack. not good when in-game) if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) { list_widget->setDeactivated(); } else { list_widget->setActivated(); } } // init
void OptionsScreenVideo::init() { Screen::init(); RibbonWidget* ribbon = getWidget<RibbonWidget>("options_choice"); assert(ribbon != NULL); ribbon->select( "tab_video", PLAYER_ID_GAME_MASTER ); ribbon->getRibbonChildren()[1].setTooltip( _("Audio") ); ribbon->getRibbonChildren()[2].setTooltip( _("User Interface") ); ribbon->getRibbonChildren()[3].setTooltip( _("Players") ); ribbon->getRibbonChildren()[4].setTooltip( _("Controls") ); GUIEngine::ButtonWidget* applyBtn = getWidget<GUIEngine::ButtonWidget>("apply_resolution"); assert( applyBtn != NULL ); GUIEngine::SpinnerWidget* gfx = getWidget<GUIEngine::SpinnerWidget>("gfx_level"); assert( gfx != NULL ); GUIEngine::CheckBoxWidget* vsync = getWidget<GUIEngine::CheckBoxWidget>("vsync"); assert( vsync != NULL ); vsync->setState( UserConfigParams::m_vsync ); // ---- video modes DynamicRibbonWidget* res = getWidget<DynamicRibbonWidget>("resolutions"); assert( res != NULL ); CheckBoxWidget* full = getWidget<CheckBoxWidget>("fullscreen"); assert( full != NULL ); full->setState( UserConfigParams::m_fullscreen ); CheckBoxWidget* rememberWinpos = getWidget<CheckBoxWidget>("rememberWinpos"); rememberWinpos->setState(UserConfigParams::m_remember_window_location); rememberWinpos->setActive(UserConfigParams::m_fullscreen); // --- get resolution list from irrlicht the first time if (!m_inited) { res->clearItems(); const std::vector<IrrDriver::VideoMode>& modes = irr_driver->getVideoModes(); const int amount = (int)modes.size(); std::vector<Resolution> resolutions; Resolution r; bool found_config_res = false; // for some odd reason, irrlicht sometimes fails to report the good // old standard resolutions // those are always useful for windowed mode bool found_1024_768 = false; for (int n=0; n<amount; n++) { r.width = modes[n].getWidth(); r.height = modes[n].getHeight(); resolutions.push_back(r); if (r.width == UserConfigParams::m_width && r.height == UserConfigParams::m_height) { found_config_res = true; } if (r.width == 1024 && r.height == 768) { found_1024_768 = true; } } if (!found_config_res) { r.width = UserConfigParams::m_width; r.height = UserConfigParams::m_height; resolutions.push_back(r); if (r.width == 1024 && r.height == 768) { found_1024_768 = true; } } // next found resolution // Add default resolutions that were not found by irrlicht if (!found_1024_768) { r.width = 1024; r.height = 768; resolutions.push_back(r); } // Sort resolutions by size std::sort(resolutions.begin(), resolutions.end()); // Add resolutions list for(std::vector<Resolution>::iterator it = resolutions.begin(); it != resolutions.end(); it++) { const float ratio = it->getRatio(); char name[32]; sprintf(name, "%ix%i", it->width, it->height); core::stringw label; label += it->width; label += L"\u00D7"; label += it->height; #define ABOUT_EQUAL(a , b) (fabsf( a - b ) < 0.01) if (ABOUT_EQUAL( ratio, (5.0f/4.0f) )) res->addItem(label, name, "/gui/screen54.png"); else if (ABOUT_EQUAL( ratio, (4.0f/3.0f) )) res->addItem(label, name, "/gui/screen43.png"); else if (ABOUT_EQUAL( ratio, (16.0f/10.0f))) res->addItem(label, name, "/gui/screen1610.png"); else if (ABOUT_EQUAL( ratio, (5.0f/3.0f) )) res->addItem(label, name, "/gui/screen53.png"); else if (ABOUT_EQUAL( ratio, (3.0f/2.0f) )) res->addItem(label, name, "/gui/screen32.png"); else if (ABOUT_EQUAL( ratio, (16.0f/9.0f) )) res->addItem(label, name, "/gui/screen169.png"); else res->addItem(label, name, "/gui/screen_other.png"); #undef ABOUT_EQUAL } // add next resolution } // end if not inited res->updateItemDisplay(); // ---- select current resolution every time char searching_for[32]; snprintf(searching_for, 32, "%ix%i", (int)UserConfigParams::m_width, (int)UserConfigParams::m_height); if (!res->setSelection(searching_for, PLAYER_ID_GAME_MASTER, false /* focus it */, true /* even if deactivated*/)) { Log::error("OptionsScreenVideo", "Cannot find resolution %s", searching_for); } // --- set gfx settings values updateGfxSlider(); // ---- forbid changing resolution or animation settings from in-game // (we need to disable them last because some items can't be edited when // disabled) bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU; res->setActive(!in_game); full->setActive(!in_game); applyBtn->setActive(!in_game); gfx->setActive(!in_game); getWidget<ButtonWidget>("custom")->setActive(!in_game); } // init
void TracksScreen::init() { DynamicRibbonWidget* gps_widget = this->getWidget<DynamicRibbonWidget>("gps"); assert( gps_widget != NULL ); DynamicRibbonWidget* tracks_widget = this->getWidget<DynamicRibbonWidget>("tracks"); assert( tracks_widget != NULL ); // Reset GP list everytime (accounts for locking changes, etc.) gps_widget->clearItems(); // Build GP list const int gpAmount = grand_prix_manager->getNumberOfGrandPrix(); for (int n=0; n<gpAmount; n++) { const GrandPrixData* gp = grand_prix_manager->getGrandPrix(n); std::vector<std::string> tracks = gp->getTracks(); std::vector<std::string> sshot_files; for (unsigned int t=0; t<tracks.size(); t++) { Track* curr = track_manager->getTrack(tracks[t]); if (curr == NULL) { std::cerr << "/!\\ WARNING: Grand Prix '" << gp->getId() << "' refers to track '" << tracks[t] << "', which does not exist.\n"; } else { sshot_files.push_back(curr->getScreenshotFile()); } } if (sshot_files.size() == 0) { std::cerr << "/!\\ WARNING: Grand Prix '" << gp->getId() << "' does not contain any valid track.\n"; sshot_files.push_back("gui/main_help.png"); } if (unlock_manager->getCurrentSlot()->isLocked(gp->getId())) { gps_widget->addAnimatedItem(_("Locked!"), "locked", sshot_files, 1.5f, LOCKED_BADGE | TROPHY_BADGE, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE); } else { gps_widget->addAnimatedItem(translations->fribidize(gp->getName()), gp->getId(), sshot_files, 1.5f, TROPHY_BADGE, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE ); } } gps_widget->updateItemDisplay(); RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups"); assert( tabs != NULL ); tabs->select(UserConfigParams::m_last_used_track_group, PLAYER_ID_GAME_MASTER); buildTrackList(); // select something for the game master // FIXME: 'setSelection' will not scroll up to the passed track, so if given track // is not visible with current scrolling this fails if (!tracks_widget->setSelection(UserConfigParams::m_last_track, PLAYER_ID_GAME_MASTER, true)) { tracks_widget->setSelection(0, PLAYER_ID_GAME_MASTER, true); } }
/** Make sure this tab is actually selected. */ void GuestLoginScreen::init() { Screen::init(); RibbonWidget* tabs = this->getWidget<RibbonWidget>("login_tabs"); if (tabs) tabs->select( "tab_guest_login", PLAYER_ID_GAME_MASTER ); } // init
void OptionsScreenInput2::init() { Screen::init(); RibbonWidget* tabBar = getWidget<RibbonWidget>("options_choice"); if (tabBar != NULL) tabBar->select( "tab_controls", PLAYER_ID_GAME_MASTER ); tabBar->getRibbonChildren()[0].setTooltip( _("Graphics") ); tabBar->getRibbonChildren()[1].setTooltip( _("Audio") ); tabBar->getRibbonChildren()[2].setTooltip( _("User Interface") ); tabBar->getRibbonChildren()[3].setTooltip( _("Players") ); ButtonWidget* deleteBtn = getWidget<ButtonWidget>("delete"); if (m_config->getType() != DEVICE_CONFIG_TYPE_KEYBOARD) { core::stringw label = (m_config->isEnabled() ? //I18N: button to disable a gamepad configuration _("Disable Device") : //I18N: button to enable a gamepad configuration _("Enable Device")); // Make sure button is wide enough as the text is being changed away // from the original value core::dimension2d<u32> size = GUIEngine::getFont()->getDimension(label.c_str()); const int needed = size.Width + deleteBtn->getWidthNeededAroundLabel(); if (deleteBtn->m_w < needed) deleteBtn->m_w = needed; deleteBtn->setLabel(label); } else { deleteBtn->setLabel(_("Delete Configuration")); if (input_manager->getDeviceList()->getKeyboardAmount() < 2) { // don't allow deleting the last config deleteBtn->setDeactivated(); } else { deleteBtn->setActivated(); } } // Make the two buttons the same length, not strictly needed but will // look nicer... ButtonWidget* backBtn = getWidget<ButtonWidget>("back_to_device_list"); if (backBtn->m_w < deleteBtn->m_w) backBtn->m_w = deleteBtn->m_w; else deleteBtn->m_w = backBtn->m_w; backBtn->moveIrrlichtElement(); deleteBtn->moveIrrlichtElement(); LabelWidget* label = getWidget<LabelWidget>("title"); label->setText( m_config->getName().c_str(), false ); GUIEngine::ListWidget* actions = getWidget<GUIEngine::ListWidget>("actions"); assert( actions != NULL ); // ---- create list skeleton (right number of items, right internal names) // their actualy contents will be adapted as needed after //I18N: Key binding section addListItemSubheader(actions, "game_keys_section", _("Game Keys")); addListItem(actions, PA_STEER_LEFT); addListItem(actions, PA_STEER_RIGHT); addListItem(actions, PA_ACCEL); addListItem(actions, PA_BRAKE); addListItem(actions, PA_FIRE); addListItem(actions, PA_NITRO); addListItem(actions, PA_DRIFT); addListItem(actions, PA_LOOK_BACK); addListItem(actions, PA_RESCUE); addListItem(actions, PA_PAUSE_RACE); //I18N: Key binding section addListItemSubheader(actions, "menu_keys_section", _("Menu Keys")); addListItem(actions, PA_MENU_UP); addListItem(actions, PA_MENU_DOWN); addListItem(actions, PA_MENU_LEFT); addListItem(actions, PA_MENU_RIGHT); addListItem(actions, PA_MENU_SELECT); addListItem(actions, PA_MENU_CANCEL); updateInputButtons(); // Disable deletion keyboard configurations if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) { getWidget<ButtonWidget>("delete")->setDeactivated(); } else { getWidget<ButtonWidget>("delete")->setActivated(); } } // init
void NetworkKartSelectionScreen::init() { m_multiplayer = false; KartSelectionScreen::init(); RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups"); assert( tabs != NULL ); tabs->select( "standard", PLAYER_ID_GAME_MASTER); // select standard kart group tabs->setDeactivated(); tabs->setVisible(false); // change the back button image (because it makes the game quit) IconButtonWidget* back_button = getWidget<IconButtonWidget>("back"); back_button->setImage("gui/main_quit.png"); m_multiplayer = false; // add a widget for each player except self (already exists): GameSetup* setup = NetworkManager::getInstance()->getGameSetup(); if (!setup) { Log::error("NetworkKartSelectionScreen", "No network game setup registered."); return; } std::vector<NetworkPlayerProfile*> players = setup->getPlayers(); Log::info("NKSS", "There are %d players", players.size()); // ---- Get available area for karts // make a copy of the area, ands move it to be outside the screen Widget* kartsAreaWidget = getWidget("playerskarts"); // start at the rightmost of the screen const int shift = irr_driver->getFrameSize().Width; core::recti kartsArea(kartsAreaWidget->m_x + shift, kartsAreaWidget->m_y, kartsAreaWidget->m_x + shift + kartsAreaWidget->m_w, kartsAreaWidget->m_y + kartsAreaWidget->m_h); for (unsigned int i = 0; i < players.size(); i++) { if (players[i]->user_profile == PlayerManager::getCurrentOnlineProfile()) { m_id_mapping.insert(m_id_mapping.begin(),players[i]->race_id); //!< first kart widget always me Log::info("NKSS", "Insert %d at pos 0", players[i]->race_id); continue; // it is me, don't add again } Log::info("NKSS", "Adding %d at pos %d", players[i]->race_id, i); m_id_mapping.push_back(players[i]->race_id); StateManager::ActivePlayer* aplayer = NULL; // player is remote std::string selected_kart_group = "standard"; // standard group PlayerKartWidget* newPlayerWidget = new PlayerKartWidget(this, aplayer, players[i]->user_profile, kartsArea, m_kart_widgets.size(), selected_kart_group); manualAddWidget(newPlayerWidget); m_kart_widgets.push_back(newPlayerWidget); newPlayerWidget->add(); } const int amount = m_kart_widgets.size(); Widget* fullarea = getWidget("playerskarts"); const int splitWidth = fullarea->m_w / amount; for (int n=0; n<amount; n++) { m_kart_widgets[n].move( fullarea->m_x + splitWidth*n, fullarea->m_y, splitWidth, fullarea->m_h); } }