Use red/blue billboard text above karts in soccer world as Arthur suggested

This commit is contained in:
Benau 2016-01-17 12:13:20 +08:00
parent ab61e55a6d
commit 51ce4c5cbd
2 changed files with 31 additions and 20 deletions

View File

@ -2807,13 +2807,32 @@ void Kart::setOnScreenText(const wchar_t *text)
// is started without splash screen (since "Loading" is shown even in this
// case). A smaller font would be better
irr::video::SColor top;
irr::video::SColor bottom;
SoccerTeam team = SOCCER_TEAM_BLUE;
SoccerWorld* sw = dynamic_cast<SoccerWorld*>(World::getWorld());
if (sw)
{
// Override color of text by kart team in soccer world
team = sw->getKartTeam(this->getWorldKartId());
top = (team == SOCCER_TEAM_RED ?
video::SColor(255, 255, 30, 200) : video::SColor(255, 100, 200, 220));
bottom = (team == SOCCER_TEAM_RED ?
video::SColor(255, 255, 100, 100) : video::SColor(255, 80, 80, 220));
}
else
{
top = GUIEngine::getSkin()->getColor("font::top");
bottom = GUIEngine::getSkin()->getColor("font::bottom");
}
if (CVS->isGLSL())
{
gui::ScalableFont* font = GUIEngine::getFont() ? GUIEngine::getFont()
: GUIEngine::getTitleFont();
new STKTextBillboard(text, font,
GUIEngine::getSkin()->getColor("font::bottom"),
GUIEngine::getSkin()->getColor("font::top"),
bottom,
top,
getNode(), irr_driver->getSceneManager(), -1,
core::vector3df(0.0f, 1.5f, 0.0f),
core::vector3df(1.0f, 1.0f, 1.0f));
@ -2829,8 +2848,8 @@ void Kart::setOnScreenText(const wchar_t *text)
textsize.Height/55.0f),
core::vector3df(0.0f, 1.5f, 0.0f),
-1, // id
GUIEngine::getSkin()->getColor("font::bottom"),
GUIEngine::getSkin()->getColor("font::top"));
bottom,
top);
}
// No need to store the reference to the billboard scene node:

View File

@ -81,7 +81,7 @@ void SoccerWorld::init()
} // init
//-----------------------------------------------------------------------------
/** Called when a battle is restarted.
/** Called when a soccer game is restarted.
*/
void SoccerWorld::reset()
{
@ -230,7 +230,7 @@ void SoccerWorld::setLastKartTohitBall(unsigned int kart_id)
} // setLastKartTohitBall
//-----------------------------------------------------------------------------
/** The battle is over if only one kart is left, or no player kart.
/** The soccer game is over if time up or either team wins.
*/
bool SoccerWorld::isRaceOver()
{
@ -272,23 +272,15 @@ void SoccerWorld::initKartList()
{
const unsigned int kart_amount = (unsigned int)m_karts.size();
//Loading the indicator textures
irr::video::ITexture *red =
irr_driver->getTexture(FileManager::GUI, "soccer_player_red.png");
irr::video::ITexture *blue =
irr_driver->getTexture(FileManager::GUI, "soccer_player_blue.png");
//Assigning indicators
// Assigning billboard text on the karts
for(unsigned int i=0; i<kart_amount; i++)
{
scene::ISceneNode *arrowNode;
float arrow_pos_height = m_karts[i]->getKartModel()->getHeight()+0.5f;
SoccerTeam team = getKartTeam(i);
int human_player_id = i - (kart_amount - race_manager->getNumPlayers());
stringw name = (human_player_id >= 0 ? race_manager
->getKartInfo(human_player_id).getPlayerName() :
translations->fribidize(m_karts[i]->getName()));
arrowNode = irr_driver->addBillboard(core::dimension2d<irr::f32>(0.3f,0.3f),
team == SOCCER_TEAM_BLUE ? blue : red, m_karts[i]->getNode(), true);
arrowNode->setPosition(core::vector3df(0, arrow_pos_height, 0));
m_karts[i]->setOnScreenText(name.c_str());
}
} // initKartList