Better splashscreen scaling on widescreen resolutions
parent
0a85fae9b5
commit
36d08e852c
|
@ -2745,7 +2745,7 @@ float CEngine::GetFogStart(int rank)
|
|||
}
|
||||
|
||||
void CEngine::SetBackground(const std::string& name, Color up, Color down,
|
||||
Color cloudUp, Color cloudDown, bool full)
|
||||
Color cloudUp, Color cloudDown, bool full, bool scale)
|
||||
{
|
||||
if (m_backgroundTex.Valid())
|
||||
{
|
||||
|
@ -2759,6 +2759,7 @@ void CEngine::SetBackground(const std::string& name, Color up, Color down,
|
|||
m_backgroundCloudUp = cloudUp;
|
||||
m_backgroundCloudDown = cloudDown;
|
||||
m_backgroundFull = full;
|
||||
m_backgroundScale = scale;
|
||||
|
||||
if (! m_backgroundName.empty())
|
||||
{
|
||||
|
@ -2769,7 +2770,7 @@ void CEngine::SetBackground(const std::string& name, Color up, Color down,
|
|||
}
|
||||
|
||||
void CEngine::GetBackground(std::string& name, Color& up, Color& down,
|
||||
Color& cloudUp, Color& cloudDown, bool &full)
|
||||
Color& cloudUp, Color& cloudDown, bool &full, bool &scale)
|
||||
{
|
||||
name = m_backgroundName;
|
||||
up = m_backgroundColorUp;
|
||||
|
@ -2777,6 +2778,7 @@ void CEngine::GetBackground(std::string& name, Color& up, Color& down,
|
|||
cloudUp = m_backgroundCloudUp;
|
||||
cloudDown = m_backgroundCloudDown;
|
||||
full = m_backgroundFull;
|
||||
scale = m_backgroundScale;
|
||||
}
|
||||
|
||||
void CEngine::SetForegroundName(const std::string& name)
|
||||
|
@ -4493,6 +4495,30 @@ void CEngine::DrawBackgroundImage()
|
|||
u2 *= backgroundScale.x;
|
||||
v2 *= backgroundScale.y;
|
||||
|
||||
if (m_backgroundScale)
|
||||
{
|
||||
Math::Point scale;
|
||||
scale.x = static_cast<float>(m_size.x) / static_cast<float>(m_backgroundTex.originalSize.x);
|
||||
scale.y = static_cast<float>(m_size.y) / static_cast<float>(m_backgroundTex.originalSize.y);
|
||||
if (scale.x > scale.y) {
|
||||
scale.y /= scale.x;
|
||||
scale.x = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale.x /= scale.y;
|
||||
scale.y = 1;
|
||||
}
|
||||
float margin_u = (1-scale.x)/2;
|
||||
float margin_v = (1-scale.y)/2;
|
||||
margin_u *= backgroundScale.x;
|
||||
margin_v *= backgroundScale.y;
|
||||
u1 += margin_u;
|
||||
v1 += margin_v;
|
||||
u2 -= margin_u;
|
||||
v2 -= margin_v;
|
||||
}
|
||||
|
||||
SetTexture(m_backgroundTex);
|
||||
SetState(ENG_RSTATE_OPAQUE_TEXTURE | ENG_RSTATE_WRAP);
|
||||
|
||||
|
|
|
@ -1057,10 +1057,10 @@ public:
|
|||
//! Management of the background image to use
|
||||
void SetBackground(const std::string& name, Color up = Color(), Color down = Color(),
|
||||
Color cloudUp = Color(), Color cloudDown = Color(),
|
||||
bool full = false);
|
||||
bool full = false, bool scale = false);
|
||||
void GetBackground(std::string& name, Color& up, Color& down,
|
||||
Color& cloudUp, Color& cloudDown,
|
||||
bool& full);
|
||||
bool& full, bool& scale);
|
||||
//@}
|
||||
|
||||
//! Specifies the name of foreground texture
|
||||
|
@ -1408,6 +1408,7 @@ protected:
|
|||
bool m_firstGroundSpot;
|
||||
std::string m_secondTex;
|
||||
bool m_backgroundFull;
|
||||
bool m_backgroundScale;
|
||||
std::string m_backgroundName;
|
||||
Texture m_backgroundTex;
|
||||
Color m_backgroundColorUp;
|
||||
|
|
|
@ -1342,8 +1342,8 @@ void CAutoBase::BeginTransit()
|
|||
m_engine->SetDeepView(2000.0f); // we see very far
|
||||
m_engine->ApplyChange();
|
||||
|
||||
bool full;
|
||||
m_engine->GetBackground(m_bgName, m_bgUp, m_bgDown, m_bgCloudUp, m_bgCloudDown, full);
|
||||
bool full, scale;
|
||||
m_engine->GetBackground(m_bgName, m_bgUp, m_bgDown, m_bgCloudUp, m_bgCloudDown, full, scale);
|
||||
m_engine->DeleteTexture(m_bgName);
|
||||
|
||||
m_engine->SetBackground(m_bgBack, Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
|
|
|
@ -1628,7 +1628,7 @@ void CMainDialog::ChangePhase(Phase phase)
|
|||
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
true);
|
||||
true, true);
|
||||
m_engine->SetBackForce(true);
|
||||
}
|
||||
if ( m_phase == PHASE_WELCOME2 )
|
||||
|
@ -1647,7 +1647,7 @@ void CMainDialog::ChangePhase(Phase phase)
|
|||
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
true);
|
||||
true, true);
|
||||
m_engine->SetBackForce(true);
|
||||
}
|
||||
if ( m_phase == PHASE_WELCOME3 )
|
||||
|
@ -1666,7 +1666,7 @@ void CMainDialog::ChangePhase(Phase phase)
|
|||
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
true);
|
||||
true, true);
|
||||
m_engine->SetBackForce(true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue