void FleetPlacementButton::Render( int realX, int realY, bool highlighted, bool clicked ) { SidePanel *parent = (SidePanel *)m_parent; g_renderer->SetClip( realX, realY, m_w, m_h ); Team *myTeam = g_app->GetWorld()->GetTeam( g_app->GetWorld()->m_myTeamId ); int currentFleetId = parent->m_currentFleetId; m_disabled = false; if( currentFleetId == -1 || !myTeam->m_fleets.ValidIndex(currentFleetId) ) { m_disabled = true; } else { if( myTeam->m_fleets[ currentFleetId ]->m_memberType.Size() == 0 || myTeam->m_fleets[ currentFleetId ]->m_active ) { m_disabled = true; } } if( !m_disabled ) { Colour col = myTeam->GetTeamColour(); if( EclMouseInButton( m_parent, this ) ) { col += Colour(60,60,60,0); } if( clicked ) { col += Colour(60,60,60,0); } Image *img = g_resource->GetImage( "graphics/cursor_target.bmp" ); g_renderer->SetBlendMode( Renderer::BlendModeAdditive ); g_renderer->Blit( img, realX, realY, m_w, m_h, col ); g_renderer->SetBlendMode( Renderer::BlendModeNormal ); } g_renderer->ResetClip(); }
void Silo::Render() { WorldObject::Render(); // // Render nuke count under the silo if( m_teamId == g_app->GetWorld()->m_myTeamId || g_app->GetWorld()->m_myTeamId == -1 || g_app->GetGame()->m_winner != -1 ) { int numNukesInStore = m_states[0]->m_numTimesPermitted; int numNukesInQueue = m_actionQueue.Size(); Team *team = g_app->GetWorld()->GetTeam(m_teamId); Colour colour = team->GetTeamColour(); colour.m_a = 150; Image *bmpImage = g_resource->GetImage("graphics/smallnuke.bmp"); if( bmpImage ) { float x = m_longitude.DoubleValue(); float y = m_latitude.DoubleValue() - GetSize().DoubleValue() * 0.9f; float nukeSize = GetSize().DoubleValue() * 0.35f; x -= GetSize().DoubleValue()*0.95f; for( int i = 0; i < numNukesInStore; ++i ) { if( i >= (numNukesInStore-numNukesInQueue) ) { colour.Set( 128,128,128,100 ); } g_renderer->Blit( bmpImage, x+i*nukeSize*0.5f, y, nukeSize, -nukeSize, colour ); } } } }
void Render( int realX, int realY, bool highlighted, bool clicked ) { AlliancesWindow *parent = (AlliancesWindow *)m_parent; int teamId = parent->m_teamOrder[m_teamIndex]; int myTeamId = g_app->GetWorld()->m_myTeamId; Team *team = g_app->GetWorld()->GetTeam(teamId); if( team ) { Colour teamCol = team->GetTeamColour(); teamCol.m_a = 178; if( highlighted || clicked ) teamCol.m_a = 255; Colour teamColDark = teamCol; teamColDark.m_r *= 0.2f; teamColDark.m_g *= 0.2f; teamColDark.m_b *= 0.2f; g_renderer->RectFill( realX, realY, m_w, m_h, teamCol, teamColDark, teamColDark, teamCol ); g_renderer->Rect( realX, realY, m_w, m_h, Colour(255,255,255,100) ); g_renderer->RectFill( realX + m_w-180, realY, 60, m_h, Colour(0,0,0,50) ); g_renderer->RectFill( realX + m_w-60, realY, 60, m_h, Colour(0,0,0,50) ); if( teamId == g_app->GetWorld()->m_myTeamId ) { g_renderer->Rect( realX, realY, m_w, m_h, Colour(255,255,255,255) ); g_renderer->TextCentreSimple( realX+180, realY+10, White, 15, "-" ); g_renderer->TextCentreSimple( realX+240, realY+10, White, 15, "-" ); g_renderer->TextCentreSimple( realX+305, realY+10, White, 15, "-" ); } else { Image *img = g_resource->GetImage( "gui/tick.bmp" ); g_renderer->SetBlendMode( Renderer::BlendModeAdditive ); if( myTeamId != -1 && team->m_sharingRadar[myTeamId] ) { g_renderer->Blit( img, realX+175, realY+8, 15, 15, White ); } int sharingRadar = g_app->GetGame()->GetOptionValue("RadarSharing"); if( sharingRadar != 2 && g_app->GetWorld()->GetMyTeam() && g_app->GetWorld()->GetMyTeam()->m_sharingRadar[teamId] ) { g_renderer->Blit( img, realX+235, realY+8, 15, 15, White ); } int permitDefection = g_app->GetGame()->GetOptionValue("PermitDefection"); if( permitDefection == 0 && g_app->GetWorld()->GetMyTeam() && g_app->GetWorld()->GetMyTeam()->m_ceaseFire[teamId] ) { g_renderer->Blit( img, realX+320, realY+8, 15, 15, White ); } g_renderer->SetBlendMode( Renderer::BlendModeNormal ); } if( teamId == parent->m_selectionTeamId ) { g_renderer->Rect( realX-2, realY-2, m_w+4, m_h+4, Colour(255,255,255,255) ); } g_renderer->TextSimple( realX+10, realY+6, White, 20, team->m_name ); } }
void AddToFleetButton::Render( int realX, int realY, bool highlighted, bool clicked ) { #ifndef NON_PLAYABLE SidePanel *parent = (SidePanel *)m_parent; Team *team = g_app->GetWorld()->GetTeam(g_app->GetWorld()->m_myTeamId); if( parent->m_mode == SidePanel::ModeFleetPlacement ) { m_disabled = false; Image *bmpImage = g_resource->GetImage( g_app->GetMapRenderer()->m_imageFiles[m_unitType] ); g_renderer->SetBlendMode( Renderer::BlendModeSubtractive ); Colour col(30,30,30,0); for( int x = -1; x <= 1; ++x ) { for( int y = -1; y <= 1; ++y ) { g_renderer->Blit( bmpImage, realX+x, realY+y, m_w, m_h, col ); } } g_renderer->SetBlendMode( Renderer::BlendModeAdditive ); Colour colour = team->GetTeamColour(); if( highlighted ) { colour.m_b += 40; colour.m_g += 40; colour.m_r += 40; } if( clicked ) { colour.m_b += 80; colour.m_g += 80; colour.m_r += 80; } if( team->m_unitsAvailable[m_unitType] <= 0 || team->m_unitCredits < g_app->GetWorld()->GetUnitValue(m_unitType)) { m_disabled = true; } else { m_disabled = false; } if( m_disabled ) { colour = Colour(50, 50, 50, 255); } //float size = 32.0f; if( bmpImage ) { g_renderer->Blit( bmpImage, realX, realY, m_w, m_h, colour ); g_renderer->SetBlendMode( Renderer::BlendModeNormal ); } char languageString[64]; switch( m_unitType ) { case WorldObject::TypeBattleShip : sprintf( languageString, "unit_battleship" ); break; case WorldObject::TypeCarrier : sprintf( languageString, "unit_carrier" ); break; case WorldObject::TypeSub : sprintf( languageString, "unit_sub" ); break; } char caption[256]; sprintf(caption, "%s(%u)", LANGUAGEPHRASE(languageString), team->m_unitsAvailable[m_unitType]); Colour textCol = White; if( m_disabled ) { textCol = Colour(50,50,50,255); } g_renderer->TextCentreSimple( realX + m_w/2, realY+m_h, textCol, parent->m_fontsize, caption ); int variableTeamUnits = g_app->GetGame()->GetOptionValue("VariableUnitCounts"); if( variableTeamUnits == 1 ) { char caption[8]; sprintf( caption, "%d", g_app->GetWorld()->GetUnitValue( m_unitType )); Colour col = Colour(255,255,0,255); g_renderer->TextCentreSimple( realX + m_w/2, realY+m_h+14, col, parent->m_fontsize, caption ); } if( highlighted || clicked ) { InfoWindow *info = (InfoWindow *)EclGetWindow("Info"); if( info ) { info->SwitchInfoDisplay( m_unitType, -1 ); } } } else { m_disabled = true; } #endif }
void PanelModeButton::Render(int realX, int realY, bool highlighted, bool clicked) { #ifndef NON_PLAYABLE SidePanel *parent = (SidePanel *)m_parent; if( m_imageButton ) { Team *team = g_app->GetWorld()->GetTeam(g_app->GetWorld()->m_myTeamId); if( !team ) return; Image *bmpImage = g_resource->GetImage( bmpImageFilename ); g_renderer->SetBlendMode( Renderer::BlendModeSubtractive ); Colour col(30,30,30,0); for( int x = -1; x <= 1; ++x ) { for( int y = -1; y <= 1; ++y ) { g_renderer->Blit( bmpImage, realX+x, realY+y, m_w, m_h, col ); } } g_renderer->SetBlendMode( Renderer::BlendModeAdditive ); Colour colour = team->GetTeamColour(); if( highlighted ) { colour.m_b += 40; colour.m_g += 40; colour.m_r += 40; } if( clicked ) { colour.m_b += 80; colour.m_g += 80; colour.m_r += 80; } colour.m_a = 255; if( m_disabled ) { colour = Colour(50, 50, 50, 255); } float size = 32.0f; if( bmpImage ) { g_renderer->Blit( bmpImage, realX, realY, m_w, m_h, colour ); g_renderer->SetBlendMode( Renderer::BlendModeNormal ); } Colour textCol = White; if( m_disabled ) { textCol = Colour(50,50,50,255); } if( m_captionIsLanguagePhrase ) { g_renderer->TextCentreSimple( realX + m_w/2, realY+m_h, textCol, parent->m_fontsize, LANGUAGEPHRASE(m_caption) ); } else { g_renderer->TextCentreSimple( realX + m_w/2, realY+m_h, textCol, parent->m_fontsize, m_caption ); } } else { InterfaceButton::Render( realX, realY, highlighted, clicked ); } #endif }
void SidePanel::Render( bool hasFocus ) { int currentSelectionId = g_app->GetMapRenderer()->GetCurrentSelectionId(); if( currentSelectionId == -1 ) { if( m_mode != ModeUnitPlacement && m_mode != ModeFleetPlacement ) { ChangeMode( ModeUnitPlacement ); m_currentFleetId = -1; } } Team *myTeam = g_app->GetWorld()->GetMyTeam(); if( m_mode == ModeUnitPlacement ) { PanelModeButton *button = (PanelModeButton *)GetButton("FleetMode"); //if( !button->m_disabled ) { int shipsRemaining = 0; if( myTeam ) { shipsRemaining += myTeam->m_unitsAvailable[WorldObject::TypeBattleShip]; shipsRemaining += myTeam->m_unitsAvailable[WorldObject::TypeCarrier]; shipsRemaining += myTeam->m_unitsAvailable[WorldObject::TypeSub]; bool unplacedFleets = false; bool outOfCredits = myTeam->m_unitCredits <= 0; if( !g_app->GetGame()->GetOptionValue("VariableUnitCounts") ) outOfCredits = false; if( myTeam->m_fleets.Size() > 0 && myTeam->GetFleet( myTeam->m_fleets.Size() - 1 )->m_active == false ) { unplacedFleets = true; } if( (shipsRemaining <= 0 || myTeam->m_unitCredits <= 0 )&& !unplacedFleets ) { button->m_disabled = true; } else { button->m_disabled = false; } } } } int w = m_w; m_w = 100; FadingWindow::Render( hasFocus, true ); m_w = w; char text[128]; switch(m_mode) { case ModeUnitPlacement: sprintf(text, LANGUAGEPHRASE("dialog_placeunit")); break; case ModeFleetPlacement: sprintf(text, LANGUAGEPHRASE("dialog_createfleet")); break; } g_renderer->TextCentreSimple(m_x+50, m_y+10, White, m_fontsize, text ); if( m_mode == ModeFleetPlacement ) { if( m_currentFleetId != -1 ) { int x = 0; int y = 0; int yMod = 0; Team *myTeam = g_app->GetWorld()->GetTeam( g_app->GetWorld()->m_myTeamId ); if( myTeam && myTeam->m_fleets.ValidIndex(m_currentFleetId) ) { if( m_mode == ModeFleetPlacement ) { x = m_x + 120; y = m_y + 20; yMod = 50; for( int i = 0; i < 6; ++i ) { g_renderer->RectFill( x, y, 40, 40, Colour(90,90,170,200) ); g_renderer->Rect(x, y, 40, 40, White ); y += yMod; } y = m_y+20; } else { x = m_x + 10; y = m_y + 40; yMod = 60; } for( int i = 0; i < myTeam->m_fleets[ m_currentFleetId ]->m_memberType.Size(); ++i ) { int type = myTeam->m_fleets[ m_currentFleetId ]->m_memberType[i]; Image *bmpImage = g_resource->GetImage( g_app->GetMapRenderer()->m_imageFiles[type] ); g_renderer->SetBlendMode( Renderer::BlendModeAdditive ); g_renderer->Blit( bmpImage, x+3, y, 35, 35, myTeam->GetTeamColour() ); g_renderer->SetBlendMode( Renderer::BlendModeNormal ); y += yMod; } } } } int variableTeamUnits = g_app->GetGame()->GetOptionValue("VariableUnitCounts"); if( myTeam ) { if( variableTeamUnits == 1 ) { Colour col = Colour(255,255,0,255); char msg[128]; sprintf( msg, LANGUAGEPHRASE("dialog_credits_1") ); LPREPLACEINTEGERFLAG( 'C', myTeam->m_unitCredits, msg ); g_renderer->TextCentreSimple( m_x+50, m_y+m_h-28, col, m_fontsize, msg ); sprintf( msg, LANGUAGEPHRASE("dialog_credits_2")); g_renderer->TextCentreSimple( m_x+50, m_y+m_h-15, col, m_fontsize, msg ); } int totalUnits = 0; for( int i = 0; i < WorldObject::NumObjectTypes; ++i ) { totalUnits += myTeam->m_unitsAvailable[i]; } if( totalUnits == 0 && m_previousUnitCount > 0 && m_currentFleetId == -1 && !g_app->GetTutorial() ) { EclRemoveWindow("Side Panel" ); return; } m_previousUnitCount = totalUnits; } }