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
GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const float h) : ModalDialog(w, h) { doInit(); m_curr_time = 0.0f; const int y1 = m_area.getHeight()/7; const int y2 = m_area.getHeight()*6/7; m_gp_ident = gpIdent; const GrandPrixData* gp = grand_prix_manager->getGrandPrix(gpIdent); if (gp == NULL) { assert(false); std::cerr << "ERROR at " << __FILE__ << " : " << __LINE__ << "; trying to continue\n"; ModalDialog::dismiss(); return; } // ---- GP Name core::rect< s32 > area_top(0, 0, m_area.getWidth(), y1); IGUIStaticText* title = GUIEngine::getGUIEnv()->addStaticText( translations->fribidize(gp->getName()), area_top, false, true, // border, word wrap m_irrlicht_window); title->setTabStop(false); title->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER); // ---- Track listings const std::vector<std::string>& tracks = gp->getTrackNames(); const int trackAmount = tracks.size(); int height_of_one_line = (y2 - y1)/(trackAmount+1); const int textHeight = GUIEngine::getFontHeight(); if (height_of_one_line > (int)(textHeight*1.5f)) height_of_one_line = (int)(textHeight*1.5f); bool gp_ok = true; for (int t=0; t<trackAmount; t++) { const int from_y = y1 + height_of_one_line*(t+1); Track* track = track_manager->getTrack(tracks[t]); stringw lineText; if (track == NULL) { lineText = L"MISSING : "; lineText.append( stringw(tracks[t].c_str()) ); gp_ok = false; } else { lineText = track->getName(); } LabelWidget* widget = new LabelWidget(); widget->setText(translations->fribidize(lineText), false); widget->m_x = 20; widget->m_y = from_y; widget->m_w = m_area.getWidth()/2 - 20; widget->m_h = height_of_one_line; widget->setParent(m_irrlicht_window); m_widgets.push_back(widget); widget->add(); // IGUIStaticText* line = GUIEngine::getGUIEnv()->addStaticText( lineText.c_str(), // entry_area, false , true , // border, word wrap // m_irrlicht_window); } // ---- Track screenshot m_screenshot_widget = new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO, false /* tab stop */, false /* focusable */, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE /* Track gives us absolute paths */); // images are saved squared, but must be stretched to 4:3 m_screenshot_widget->setCustomAspectRatio(4.0f / 3.0f); m_screenshot_widget->m_x = m_area.getWidth()/2; m_screenshot_widget->m_y = y1; m_screenshot_widget->m_w = m_area.getWidth()/2; m_screenshot_widget->m_h = y2 - y1 - 10; Track* track = track_manager->getTrack(tracks[0]); m_screenshot_widget->m_properties[PROP_ICON] = (track != NULL ? track->getScreenshotFile().c_str() : file_manager->getAsset(FileManager::GUI,"main_help.png")); m_screenshot_widget->setParent(m_irrlicht_window); m_screenshot_widget->add(); m_widgets.push_back(m_screenshot_widget); // ---- Start button ButtonWidget* okBtn = new ButtonWidget(); ButtonWidget* continueBtn = new ButtonWidget(); SavedGrandPrix* saved_gp = SavedGrandPrix::getSavedGP( StateManager::get() ->getActivePlayerProfile(0) ->getUniqueID(), gpIdent, race_manager->getDifficulty(), race_manager->getNumberOfKarts(), race_manager->getNumLocalPlayers()); if (gp_ok) { okBtn->m_properties[PROP_ID] = "start"; okBtn->setText(_("Start Grand Prix")); continueBtn->m_properties[PROP_ID] = "continue"; continueBtn->setText(_("Continue")); } else { okBtn->m_properties[PROP_ID] = "cannot_start"; okBtn->setText(_("This Grand Prix is broken!")); okBtn->setBadge(BAD_BADGE); } if (saved_gp && gp_ok) { continueBtn->m_x = m_area.getWidth()/2 + 110; continueBtn->m_y = y2; continueBtn->m_w = 200; continueBtn->m_h = m_area.getHeight() - y2 - 15; continueBtn->setParent(m_irrlicht_window); m_widgets.push_back(continueBtn); continueBtn->add(); continueBtn->getIrrlichtElement()->setTabStop(true); continueBtn->getIrrlichtElement()->setTabGroup(false); okBtn->m_x = m_area.getWidth()/2 - 310; } else { okBtn->m_x = m_area.getWidth()/2 - 200; } okBtn->m_y = y2; okBtn->m_w = 400; okBtn->m_h = m_area.getHeight() - y2 - 15; okBtn->setParent(m_irrlicht_window); m_widgets.push_back(okBtn); okBtn->add(); okBtn->getIrrlichtElement()->setTabStop(true); okBtn->getIrrlichtElement()->setTabGroup(false); okBtn->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); }
// ----------------------------------------------------------------------------- void ListWidget::add() { const int header_height = GUIEngine::getFontHeight() + 15; rect<s32> widget_size = (m_header.size() > 0 ? rect<s32>(m_x, m_y + header_height, m_x + m_w, m_y + m_h) : rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h) ); IGUISkin * current_skin = GUIEngine::getGUIEnv()->getSkin(); IGUIFont * current_font = GUIEngine::getGUIEnv()->getBuiltInFont(); CGUISTKListBox * list_box = new CGUISTKListBox( GUIEngine::getGUIEnv(), m_parent ? m_parent : GUIEngine::getGUIEnv()->getRootGUIElement(), getNewID(), widget_size, true, true, false); if (current_skin && current_skin->getSpriteBank()) { list_box->setSpriteBank(current_skin->getSpriteBank()); } else if (current_font && current_font->getType() == EGFT_BITMAP) { list_box->setSpriteBank( ((IGUIFontBitmap*)current_font)->getSpriteBank()); } list_box->drop(); list_box->setAutoScrollEnabled(false); m_element = list_box; m_element->setTabOrder( list_box->getID() ); if (m_header.size() > 0) { //const int col_size = m_w / m_header.size(); int proportion_total = 0; for (unsigned int n=0; n<m_header.size(); n++) { proportion_total += m_header[n].m_proportion; } int x = m_x; for (unsigned int n=0; n<m_header.size(); n++) { std::ostringstream name; name << m_properties[PROP_ID]; name << "_column_"; name << n; ButtonWidget* header = new ButtonWidget(); header->m_reserved_id = getNewNoFocusID(); header->m_y = m_y; header->m_h = header_height; header->m_x = x; header->m_w = (int)(m_w * float(m_header[n].m_proportion) /float(proportion_total)); x += header->m_w; header->setText( m_header[n].m_text ); header->m_properties[PROP_ID] = name.str(); header->add(); header->m_event_handler = this; header->getIrrlichtElement()->setTabStop(false); m_children.push_back(header); m_header_elements.push_back(header); } m_check_inside_me = true; } }