Пример #1
0
void GuiPowerDamageIndicator::onDraw(sf::RenderTarget& window)
{
    if (!my_spaceship)
        return;
    
    sf::Color color;
    string display_text;

    float power = my_spaceship->systems[system].power_level;
    float health = my_spaceship->systems[system].health;
    float heat = my_spaceship->systems[system].heat_level;
    int alpha = 128;
    if (system == SYS_FrontShield)
    {
        power = std::max(power, my_spaceship->systems[SYS_RearShield].power_level);
        health = std::max(health, my_spaceship->systems[SYS_RearShield].health);
        heat = std::max(heat, my_spaceship->systems[SYS_RearShield].heat_level);
    }
    if (health <= 0.0)
    {
        color = sf::Color::Red;
        display_text = "DAMAGED";
    }else if ((system == SYS_Warp || system == SYS_JumpDrive) && WarpJammer::isWarpJammed(my_spaceship->getPosition()))
    {
        color = sf::Color::Red;
        display_text = "JAMMED";
    }else if (power == 0.0)
    {
        color = sf::Color::Red;
        display_text = "NO POWER";
    }else if (my_spaceship->energy_level < 10)
    {
        color = sf::Color(255, 128, 0);
        alpha = 64;
        display_text = "LOW ENERGY";
    }else if (power < 0.3)
    {
        color = sf::Color(255, 128, 0);
        alpha = 64;
        display_text = "LOW POWER";
    }else if (heat > 0.90)
    {
        color = sf::Color(255, 128, 0);
        alpha = 64;
        display_text = "OVERHEATING";
    }else{
        return;
    }
    draw9Cut(window, rect, "button_background", sf::Color(0, 0, 0, alpha));
    draw9Cut(window, rect, "border_background", color);
    
    if (rect.height > rect.width)
        drawVerticalText(window, rect, display_text, ACenter, text_size, main_font, color);
    else
        drawText(window, rect, display_text, ACenter, text_size, main_font, color);
}
Пример #2
0
void  Font::Draw3DText(FLOAT baseX, FLOAT baseY, LPCSTR lpchText, int cchText, FLOAT cchSpace)
{
	if ((NULL == lpchText)
		|| (-1 >  cchText)
		|| (0  == cchText))
	{
		return ;
	}


	if (!m_fontVertical)
	{
		m_fontSpaceX = cchSpace * m_fontScalingX;
		m_fontSpaceY = 0.0f;
		drawStandardText(baseX, baseY, lpchText, cchText, &Font::DrawChar);
	}
	else
	{
		m_fontSpaceX = 0.0f;
		m_fontSpaceY = cchSpace * m_fontScalingY;
		drawVerticalText(baseX, baseY, lpchText, cchText, &Font::DrawChar);
	}

}