void GrandPrixWin::init() { std::vector<std::string> parts; parts.push_back("gpwin"); ((CutsceneWorld*)World::getWorld())->setParts(parts); CutsceneWorld::setUseDuration(false); Screen::init(); World::getWorld()->setPhase(WorldStatus::RACE_PHASE); saveGPButton(); if (PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges().size() > 0) { const core::dimension2d<u32>& frame_size = GUIEngine::getDriver()->getCurrentRenderTargetSize(); core::stringw message = _("You completed a challenge!"); const int message_width = GUIEngine::getFont()->getDimension(message.c_str()).Width + 30; const int label_height = GUIEngine::getFontHeight() + 15; const int y_from = frame_size.Height - label_height*2; const int y_to = frame_size.Height - label_height; const int label_x_from = frame_size.Width/2 - message_width/2; const int label_x_to = frame_size.Width/2 + message_width/2; // button_h is used in the x coordinates not by mistake, but because the icon is square and // scaled according to the available height. core::rect< s32 > iconarea(label_x_from - label_height, y_from, label_x_from, y_to); IGUIImage* img = GUIEngine::getGUIEnv()->addImage( iconarea ); img->setImage( irr_driver->getTexture( FileManager::GUI, "cup_gold.png") ); img->setScaleImage(true); img->setTabStop(false); img->setUseAlphaChannel(true); core::rect< s32 > icon2area(label_x_to, y_from, label_x_to + label_height, y_to); img = GUIEngine::getGUIEnv()->addImage( icon2area ); img->setImage( irr_driver->getTexture( FileManager::GUI,"cup_gold.png") ); img->setScaleImage(true); img->setTabStop(false); img->setUseAlphaChannel(true); m_unlocked_label = new GUIEngine::LabelWidget(); m_unlocked_label->m_properties[GUIEngine::PROP_ID] = "label"; m_unlocked_label->m_properties[GUIEngine::PROP_TEXT_ALIGN] = "center"; m_unlocked_label->m_x = label_x_from; m_unlocked_label->m_y = y_from; m_unlocked_label->m_w = message_width; m_unlocked_label->m_h = label_height; m_unlocked_label->setText(message, false); m_unlocked_label->add(); manualAddWidget(m_unlocked_label); } else { m_unlocked_label = NULL; } m_global_time = 0.0f; m_phase = 1; SFXManager::get()->quickSound("gp_end"); getWidget<ButtonWidget>("continue")->setFocusForPlayer(PLAYER_ID_GAME_MASTER); } // init
void GrandPrixWin::init() { Screen::init(); if (unlock_manager->getRecentlyUnlockedFeatures().size() > 0) { const core::dimension2d<u32>& frame_size = GUIEngine::getDriver()->getCurrentRenderTargetSize(); core::stringw message = _("You unlocked a new feature!"); const int message_width = GUIEngine::getFont()->getDimension(message.c_str()).Width + 30; const int label_height = GUIEngine::getFontHeight() + 15; const int y_from = frame_size.Height - label_height*2; const int y_to = frame_size.Height - label_height; const int label_x_from = frame_size.Width/2 - message_width/2; const int label_x_to = frame_size.Width/2 + message_width/2; // button_h is used in the x coordinates not by mistake, but because the icon is square and // scaled according to the available height. core::rect< s32 > iconarea(label_x_from - label_height, y_from, label_x_from, y_to); IGUIImage* img = GUIEngine::getGUIEnv()->addImage( iconarea ); img->setImage( irr_driver->getTexture( file_manager->getTextureFile("cup_gold.png") ) ); img->setScaleImage(true); img->setTabStop(false); img->setUseAlphaChannel(true); core::rect< s32 > icon2area(label_x_to, y_from, label_x_to + label_height, y_to); img = GUIEngine::getGUIEnv()->addImage( icon2area ); img->setImage( irr_driver->getTexture( file_manager->getTextureFile("cup_gold.png") ) ); img->setScaleImage(true); img->setTabStop(false); img->setUseAlphaChannel(true); m_unlocked_label = new GUIEngine::LabelWidget(); m_unlocked_label->m_properties[GUIEngine::PROP_ID] = "label"; m_unlocked_label->m_properties[GUIEngine::PROP_TEXT_ALIGN] = "center"; m_unlocked_label->m_x = label_x_from; m_unlocked_label->m_y = y_from; m_unlocked_label->m_w = message_width; m_unlocked_label->m_h = label_height; m_unlocked_label->setText(message, false); //const irr::video::SColor orange(255, 255, 126, 21); //unlocked_label->setColor(orange); m_unlocked_label->add(); manualAddWidget(m_unlocked_label); } else { m_unlocked_label = NULL; } m_phase = 1; m_sky_angle = 0.0f; m_global_time = 0.0f; video::ITexture *t = irr_driver->getTexture( file_manager->getTextureFile("clouds.png")); m_sky = irr_driver->addSkyDome(t, 16 /* hori_res */, 16 /* vert_res */, 1.0f /* texture_percent */, 2.0f /* sphere_percent */); m_camera = irr_driver->addCameraSceneNode(); m_camera_x = 3.0f; m_camera_y = 0.0f; m_camera_z = -5.0f; m_camera->setPosition( core::vector3df(m_camera_x, m_camera_y, m_camera_z) ); m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) ); irr_driver->getSceneManager()->setActiveCamera(m_camera); m_camera_target_x = 1.5f; m_camera_target_z = 0.0f; m_camera->setTarget( core::vector3df(m_camera_target_x, -2.0f, m_camera_target_z) ); m_camera->setFOV( DEGREE_TO_RAD*50.0f ); m_camera->updateAbsolutePosition(); scene::IMesh* model_village = irr_driver->getMesh( file_manager->getModelFile("village.b3d") ); assert(model_village != NULL); m_village = irr_driver->addMesh(model_village); #ifdef DEBUG m_village->setName("village"); #endif m_village->setPosition( core::vector3df(2, INITIAL_Y, 0) ); scene::IMesh* podium_model = irr_driver->getMesh( file_manager->getModelFile("wood_podium.b3d") ); assert(podium_model != NULL); m_podium_step[0] = irr_driver->addMesh(podium_model); #ifdef DEBUG m_podium_step[0]->setName("Podium 0"); #endif m_podium_step[0]->setPosition( core::vector3df(m_podium_x[0], INITIAL_PODIUM_Y, m_podium_z[0]) ); m_podium_step[1] = irr_driver->addMesh(podium_model); #ifdef DEBUG m_podium_step[1]->setName("Podium 1"); #endif m_podium_step[1]->setPosition( core::vector3df(m_podium_x[1], INITIAL_PODIUM_Y, m_podium_z[1]) ); m_podium_step[2] = irr_driver->addMesh(podium_model); #ifdef DEBUG m_podium_step[2]->setName("Podium 2"); #endif m_podium_step[2]->setPosition( core::vector3df(m_podium_x[2], INITIAL_PODIUM_Y, m_podium_z[2]) ); scene::ISceneManager* sceneManager = irr_driver->getSceneManager(); sceneManager->setAmbientLight(video::SColor(255, 95, 95, 95)); const core::vector3df &sun_pos = core::vector3df( 0, 200, 100.0f ); m_light = irr_driver->getSceneManager()->addLightSceneNode(NULL, sun_pos, video::SColorf(0.25f,0.25f,0.25f), 300.0f /* radius */); m_light->getLightData().DiffuseColor = irr::video::SColorf(0.25f, 0.25f, 0.25f, 1.0f); m_light->getLightData().AmbientColor = irr::video::SColorf(0.25f, 0.25f, 0.25f, 1.0f); m_light->getLightData().SpecularColor = irr::video::SColorf(0.0f, 0.0f, 0.0f, 1.0f); sfx_manager->quickSound("gp_end"); } // init