Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

feat(gameclient): put the superweapon countdowns on a plate and shrink them

Olcay Seygan5f2ed93795a5
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index a80db22ae..67219c98e 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -199,6 +199,7 @@ public:
const SpecialPowerTemplate* getSpecialPowerTemplate() const { return m_powerTemplate; }
void setFont(const AsciiString& superweaponNormalFont, Int superweaponNormalPointSize, Bool superweaponNormalBold);
void setText(const UnicodeString& name, const UnicodeString& time);
+ void drawBackdrop(Int x, Int y); ///< plate behind the name and time, so they stay readable over terrain
void drawName(Int x, Int y, Color color, Color dropColor);
void drawTime(Int x, Int y, Color color, Color dropColor);
Real getHeight() const;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index 079bd10ad..419e01774 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -322,6 +322,25 @@ void SuperweaponInfo::setText(const UnicodeString& name, const UnicodeString& ti
m_timeDisplayString->setText(time);
}
+// ------------------------------------------------------------------------------------------------
+/** The countdowns sit straight on the battlefield, where light terrain swallows them. Put a
+ * translucent plate under the whole line - the name is right-aligned to x, the time starts at
+ * it - before either half is drawn. */
+// ------------------------------------------------------------------------------------------------
+void SuperweaponInfo::drawBackdrop(Int x, Int y)
+{
+ if( m_nameDisplayString == NULL || m_timeDisplayString == NULL )
+ return;
+
+ Int nameW = m_nameDisplayString->getWidth();
+ Int timeW = m_timeDisplayString->getWidth();
+ Int h = (Int)getHeight();
+
+ const Int pad = 3;
+ TheDisplay->drawFillRect( x - nameW - pad, y - 1, nameW + timeW + pad*2, h + 2,
+ GameMakeColor( 0, 0, 0, 130 ) );
+}
+
// ------------------------------------------------------------------------------------------------
void SuperweaponInfo::drawName(Int x, Int y, Color color, Color dropColor)
{
@@ -1141,6 +1160,8 @@ void InGameUI::init( void )
if (TheGlobalLanguageData->m_superweaponCountdownNormalFont.name.isNotEmpty())
{ m_superweaponNormalFont = TheGlobalLanguageData->m_superweaponCountdownNormalFont.name;
m_superweaponNormalPointSize = TheGlobalLanguageData->m_superweaponCountdownNormalFont.size;
+ // these are overlay text on the battlefield, not panel text - take them down a notch
+ m_superweaponNormalPointSize = max( 8, (m_superweaponNormalPointSize * 4) / 5 );
m_superweaponNormalBold = TheGlobalLanguageData->m_superweaponCountdownNormalFont.bold;
}
@@ -3793,6 +3814,8 @@ void InGameUI::postDraw( void )
info->setText(name, time);
}
+ info->drawBackdrop( startX, startY );
+
if (isReady)
{
if ( m_superweaponFlashDuration != 0.0f )