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): load and score screens in the front end's look

Olcay Seygan05e0df2b4baf
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c7ef84c6d..ea4b10a6e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ found and fixed — EA's own, not port damage.**
- The map's name, the kind of game, the team sizes and the starting cash head the screen. Along the bottom a tip changes every eight seconds over the load's bar and percentage.
- Enemies who picked a random side, colour or start stay hidden as they were in the lobby. Observers and replays see every side as it is.
- A campaign mission keeps its own picture and briefing movie. Once the movie ends, the mission number, campaign and difficulty sit above it and the same tip and bar sit below it. Generals' Challenge is unchanged.
+- It wears the menus' own lettering and blue frames, so the load looks like the lobby it came from.
## A summary and graphs on the score screen
@@ -22,6 +23,7 @@ found and fixed — EA's own, not port damage.**
- The tabs beside Summary give a chart the whole screen, one line per player over the whole match: money earned, army size or buildings standing, with each player's colour named along the top. Army size counts infantry, vehicles and aircraft; workers and supply trucks are left out.
- A single row of small pictures above the chart marks superweapons built and fired, general's powers and promotions, framed in the player's colour. Moments that fall close together share one picture with a count on it. Hover over it for the list, each line with its time, and a faint line down to where each one falls on the chart.
- The Build order tab puts the first of each structure and unit each player made on a timeline whose first five minutes take over half the width, so an opening reads at a glance. Show every build adds the rest; hover over a picture for its name and time. With the whole page to itself a 4v4 keeps two strips of pictures per player, even at 1280x720.
+- The map's name heads the page, the pages sit in boxed tabs like the options screen's, and the open one is lettered green. Dark blue and purple player names are lifted so they stay readable on the panel.
- The game records all of this as the match plays, a sample every five seconds, and it changes nothing in the match itself. A game loaded from a save only graphs what happened after the load.
## Computer players have personalities
diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifest
index 9e61e8d81..d488e3dd8 100644
--- a/GeneralsMD/Code/BuildFingerprint.manifest
+++ b/GeneralsMD/Code/BuildFingerprint.manifest
@@ -641,6 +641,7 @@ GameEngine/Include/GameClient/Snow.h
GameEngine/Include/GameClient/Statistics.h
GameEngine/Include/GameClient/TerrainRoads.h
GameEngine/Include/GameClient/TerrainVisual.h
+GameEngine/Include/GameClient/UIStyle.h
GameEngine/Include/GameClient/UiAnimClock.h
GameEngine/Include/GameClient/VideoPlayer.h
GameEngine/Include/GameClient/View.h
@@ -1241,6 +1242,7 @@ GameEngine/Source/GameClient/GUI/LoadScreen.cpp
GameEngine/Source/GameClient/GUI/ProcessAnimateWindow.cpp
GameEngine/Source/GameClient/GUI/Shell/Shell.cpp
GameEngine/Source/GameClient/GUI/Shell/ShellMenuScheme.cpp
+GameEngine/Source/GameClient/GUI/UIStyle.cpp
GameEngine/Source/GameClient/GUI/WinInstanceData.cpp
GameEngine/Source/GameClient/GUI/WindowLayout.cpp
GameEngine/Source/GameClient/GUI/WindowVideoManager.cpp
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/UIStyle.h b/GeneralsMD/Code/GameEngine/Include/GameClient/UIStyle.h
new file mode 100644
index 000000000..f15ade6aa
--- /dev/null
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/UIStyle.h
@@ -0,0 +1,93 @@
+/*
+** Command & Conquer Generals Zero Hour(tm)
+** Copyright 2025 Electronic Arts Inc.
+**
+** This program is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// FILE: UIStyle.h ////////////////////////////////////////////////////////////////////////////////
+//
+// The front end's one look, for the screens drawn in code (the load screen's board, the score
+// screen's pages) so they match the ones built from .wnd layouts (main menu, options, the staging
+// rooms, the in-game menu). The colours were read off those layouts at 1920x1080; the type is the
+// layouts' own, Arial and the "Generals" face at a layout's point size, sized the way the layouts'
+// text is. The rules for using them are in UI-STYLE.md in the wrapper's docs/reference.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#ifndef _UISTYLE_H_
+#define _UISTYLE_H_
+
+#include "Lib/BaseType.h"
+#include "GameClient/Color.h"
+
+class GameFont;
+class DisplayString;
+
+namespace UIStyle
+{
+ /// type sizes in a layout's points (authored at 800x600), the sizes the .wnd files use
+ enum TextSize
+ {
+ TEXT_SMALL = 8, ///< chips, axis labels, a card's third line
+ TEXT_BODY = 10, ///< lists, subtitles, a card's second line, a tab
+ TEXT_STRONG = 12, ///< player names, table numbers, the wordmark
+ TEXT_HEADING = 14, ///< column and group headings, a room's labels
+ TEXT_TITLE = 18, ///< the screen's title, in the "Generals" face
+ TEXT_DISPLAY = 30 ///< one big word: VS
+ };
+
+ extern const Color GROUND; ///< behind a screen with no picture behind it
+ extern const Color PANEL; ///< a panel over a picture: the layouts' see-through black
+ extern const Color CARD; ///< a card or a row on a panel
+ extern const Color FRAME; ///< a panel's and a card's edge, the header rule
+ extern const Color GRID; ///< faint rules: a chart's grid, between rows, a bar's track
+ extern const Color EDGE; ///< a button's edge, a progress bar, a selection
+ extern const Color EDGE_LIT; ///< the bright middle line of a button's edge, a hover
+ extern const Color TAB_EDGE; ///< a tab's box
+ extern const Color INK; ///< words and numbers
+ extern const Color MUTED; ///< what is secondary
+ extern const Color ACTIVE; ///< the layouts' green: section headings, the open tab, chip labels
+ extern const Color GOLD; ///< results only: the winner, a column's best
+ extern const Color WORDMARK_BLUE; ///< "Reforged" in the wordmark, nowhere else
+ extern const Color SHADOW;
+
+ /// a length given for 1920x1080, on this screen (the smaller axis, as the layouts stretch)
+ Int px( Real at1080 );
+ /// Arial at a layout's point size, grown for the screen the way a layout's text is
+ GameFont *font( Int points, Bool bold = FALSE );
+ /// the "Generals" face the layouts' titles and buttons are set in
+ GameFont *titleFont( Int points );
+
+ /// a filled box with a FRAME edge
+ void panel( Int x, Int y, Int width, Int height, Color fill );
+ /// the two-pixel rule under a header and over a foot
+ void rule( Int x, Int y, Int width );
+ /// a layout button's box: the panel's black under a blue, cyan, blue edge
+ void button( Int x, Int y, Int width, Int height );
+ /// a tab's box; the label in it is ACTIVE when the tab is open, INK when not
+ void tab( Int x, Int y, Int width, Int height );
+ /// the player's colour down the edge of his row or card, stripeWidth() wide
+ void stripe( Int x, Int y, Int height, Color player );
+ Int stripeWidth( void );
+ /// "Zero Hour Reforged" with its right edge at right; words are "Zero Hour" and " Reforged"
+ void wordmark( DisplayString *words[ 2 ], Int right, Int y );
+
+ /// a house colour lifted toward white where it is too dark to read as words on a panel
+ Color readable( Color player );
+ Color withAlpha( Color color, Int alpha );
+}
+
+#endif // _UISTYLE_H_
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreenGraphs.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreenGraphs.cpp
index 5539475be..63fd01ee2 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreenGraphs.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreenGraphs.cpp
@@ -26,7 +26,9 @@
// promoted; markers that fall close together share one picture and list all of theirs on hover. The
// build order shows the first of each structure and unit until asked for every build. Everything is
// drawn here from TheMatchHistory and the score keepers; the panel is made in code over the layout,
-// whose own score table ScoreScreen.cpp hides, so no layout file changes.
+// whose own score table ScoreScreen.cpp hides, so no layout file changes. It is drawn in the front
+// end's look (UIStyle.h): the map's name and the wordmark over a rule, the tabs boxed as the options
+// screen's are.
////////////////////////////////////////////////////////////////////////////////////////////////////
#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
@@ -46,7 +48,11 @@
#include "GameClient/GameWindow.h"
#include "GameClient/GameWindowManager.h"
#include "GameClient/Image.h"
+#include "GameClient/MapUtil.h"
#include "GameClient/Mouse.h"
+#include "GameClient/UIStyle.h"
+#include "Common/GameState.h"
+#include "Common/GlobalData.h"
#include "GameLogic/VictoryConditions.h"
#include <algorithm>
@@ -115,22 +121,13 @@ static const Int theEventRank[ MATCH_EVENT_TYPE_COUNT ] = { 1, 0, 2, 3 };
static const Real EARLY_SHARE = 0.55f;
static const UnsignedInt EARLY_FRAMES = 5 * 60 * LOGICFRAMES_PER_SECOND;
-static const Color PANEL_FILL = GameMakeColor( 8, 12, 20, 255 );
-static const Color PANEL_EDGE = GameMakeColor( 110, 130, 160, 255 );
-static const Color TAB_FILL = GameMakeColor( 24, 32, 46, 255 );
-static const Color TEXT = GameMakeColor( 220, 225, 235, 255 );
-static const Color TEXT_DIM = GameMakeColor( 150, 160, 175, 255 );
-static const Color GRID = GameMakeColor( 255, 255, 255, 22 );
-static const Color AXIS = GameMakeColor( 255, 255, 255, 70 );
-static const Color GOLD = GameMakeColor( 235, 190, 60, 255 );
-static const Color SHADOW = GameMakeColor( 0, 0, 0, 255 );
-
struct GraphPlayer
{
Int index; ///< the player's index, or -1 for a campaign's side, which only has a summary row
UnicodeString name;
UnicodeString side;
Color color;
+ Color nameColor; ///< the colour lifted where it is too dark to read as words
Bool winner;
Int stats[ SUMMARY_COLUMN_COUNT ];
};
@@ -194,6 +191,9 @@ static IRegion2D s_tabBox[ GRAPH_TAB_COUNT ];
static DisplayString *s_tabText[ GRAPH_TAB_COUNT ];
static IRegion2D s_toggleBox;
static DisplayString *s_toggleText = NULL;
+static DisplayString *s_title = NULL; ///< the map's name, over the tabs
+static DisplayString *s_wordmark[ 2 ] = { NULL, NULL };
+static Int s_ruleY = 0; ///< the header's rule, from the panel's top
static std::vector< DisplayString * > s_tipText;
static Int s_tipMark = -1;
@@ -460,13 +460,13 @@ static void layoutSummary( Int top, Int width, Int bottom, Int pad )
}
}
const Int groupLeft = columnRight[ first ] - column + pad;
- addText( TheGameText->fetch( theGroupLabels[ group ] ), s_font, ( groupLeft + columnRight[ last ] ) / 2, top, TEXT, 1 );
- addRule( groupLeft, subTop - pad / 4, columnRight[ last ], subTop - pad / 4, AXIS );
+ addText( TheGameText->fetch( theGroupLabels[ group ] ), s_font, ( groupLeft + columnRight[ last ] ) / 2, top, UIStyle::INK, 1 );
+ addRule( groupLeft, subTop - pad / 4, columnRight[ last ], subTop - pad / 4, UIStyle::FRAME );
}
for( Int each = 0; each < SUMMARY_COLUMN_COUNT; each++ )
- addText( TheGameText->fetch( theColumnLabels[ each ] ), s_smallFont, columnRight[ each ], subTop, TEXT_DIM, 2 );
+ addText( TheGameText->fetch( theColumnLabels[ each ] ), s_smallFont, columnRight[ each ], subTop, UIStyle::MUTED, 2 );
Int y = subTop + smallLine + pad / 2;
- addRule( left, y, right, y, AXIS );
+ addRule( left, y, right, y, UIStyle::FRAME );
// the row a column's best stands in, or -1 where two rows share it
Int bestRow[ SUMMARY_COLUMN_COUNT ];
@@ -497,32 +497,33 @@ static void layoutSummary( Int top, Int width, Int bottom, Int pad )
{
const GraphPlayer &player = s_players[ each ];
const Int nameY = y + ( rowHeight - ( sideUnder && !player.side.isEmpty() ? line + sideLine : line ) ) / 2;
- s_marks.push_back( newMark( left, y + pad / 2, 4, rowHeight - pad, player.color, player.color ) );
- const Int x = left + 4 + pad;
- const Int nameWidth = addText( player.name, s_bigFont, x, nameY, player.color );
+ const Int stripe = UIStyle::stripeWidth();
+ s_marks.push_back( newMark( left, y + pad / 2, stripe, rowHeight - pad, player.color, player.color ) );
+ const Int x = left + stripe + pad;
+ const Int nameWidth = addText( player.name, s_bigFont, x, nameY, player.nameColor );
if( !player.side.isEmpty() )
{
if( sideUnder )
- addText( player.side, s_font, x, nameY + line, TEXT_DIM );
+ addText( player.side, s_font, x, nameY + line, UIStyle::MUTED );
else
- addText( player.side, s_smallFont, x + nameWidth + pad, nameY + line - smallLine - 1, TEXT_DIM );
+ addText( player.side, s_smallFont, x + nameWidth + pad, nameY + line - smallLine - 1, UIStyle::MUTED );
}
if( player.winner )
{
const Int tagY = y + ( rowHeight - sideLine ) / 2;
- const Int tagWidth = addText( TheGameText->fetch( "GUI:SummaryWinner" ), s_font, namesRight - pad, tagY, GOLD, 2 );
- s_marks.push_back( newMark( namesRight - pad * 2 - tagWidth, tagY - 3, tagWidth + pad * 2, sideLine + 6, 0, GOLD ) );
+ const Int tagWidth = addText( TheGameText->fetch( "GUI:SummaryWinner" ), s_font, namesRight - pad, tagY, UIStyle::GOLD, 2 );
+ s_marks.push_back( newMark( namesRight - pad * 2 - tagWidth, tagY - 3, tagWidth + pad * 2, sideLine + 6, 0, UIStyle::GOLD ) );
}
const Int textY = y + ( rowHeight - line ) / 2;
for( Int stat = 0; stat < SUMMARY_COLUMN_COUNT; stat++ )
{
UnicodeString value;
value.format( u"%d", player.stats[ stat ] );
- addText( value, s_bigFont, columnRight[ stat ], textY, bestRow[ stat ] == (Int)each ? GOLD : TEXT, 2 );
+ addText( value, s_bigFont, columnRight[ stat ], textY, bestRow[ stat ] == (Int)each ? UIStyle::GOLD : UIStyle::INK, 2 );
}
y += rowHeight;
if( each + 1 < s_players.size() )
- addRule( left, y, right, y, GRID );
+ addRule( left, y, right, y, UIStyle::GRID );
}
}
@@ -532,7 +533,7 @@ static void dressMark( GraphMark &mark, const MatchEvent &event, const GraphPlay
{
mark.rank = theEventRank[ event.type ];
mark.edge = player.color;
- mark.fill = TAB_FILL;
+ mark.fill = UIStyle::CARD;
if( mark.label )
TheDisplayStringManager->freeDisplayString( mark.label );
mark.label = NULL;
@@ -571,7 +572,7 @@ static void layoutChart( MatchSeries series, Int top, Int width, Int bottom, Int
if( count == 0 )
{
- addText( TheGameText->fetch( "GUI:GraphNoData" ), s_font, pad * 2, plotTop, TEXT_DIM );
+ addText( TheGameText->fetch( "GUI:GraphNoData" ), s_font, pad * 2, plotTop, UIStyle::MUTED );
return;
}
@@ -597,15 +598,15 @@ static void layoutChart( MatchSeries series, Int top, Int width, Int bottom, Int
for( Int value = 0; value <= ceiling; value += step )
{
const Int y = plotBottom - (Int)( (Real)value / ceiling * plotHeight );
- addRule( plotLeft, y, plotRight, y, value == 0 ? AXIS : GRID );
- addText( valueText( value ), s_smallFont, plotLeft - pad, y - smallLine / 2, TEXT_DIM, 2 );
+ addRule( plotLeft, y, plotRight, y, value == 0 ? UIStyle::FRAME : UIStyle::GRID );
+ addText( valueText( value ), s_smallFont, plotLeft - pad, y - smallLine / 2, UIStyle::MUTED, 2 );
}
const Int minutes = minuteStep( end, 8 );
for( UnsignedInt frame = 0; frame <= end; frame += minutes * 60 * LOGICFRAMES_PER_SECOND )
{
const Int x = plotLeft + (Int)( (Real)frame / end * plotWidth );
- addText( clockText( frame ), s_smallFont, x, plotBottom + pad / 2, TEXT_DIM, frame == 0 ? 0 : 1 );
+ addText( clockText( frame ), s_smallFont, x, plotBottom + pad / 2, UIStyle::MUTED, frame == 0 ? 0 : 1 );
}
for( size_t each = 0; each < players.size(); each++ )
@@ -640,7 +641,7 @@ static void layoutChart( MatchSeries series, Int top, Int width, Int bottom, Int
if( s_marks.size() == firstMarker || x >= anchor + iconWidth + pad / 2 )
{
anchor = x;
- GraphMark mark = newMark( x - iconWidth / 2, stripTop, iconWidth, icon, TAB_FILL, player->color );
+ GraphMark mark = newMark( x - iconWidth / 2, stripTop, iconWidth, icon, UIStyle::CARD, player->color );
mark.dropBottom = plotBottom;
s_marks.push_back( mark );
}
@@ -751,8 +752,8 @@ static void layoutBuildOrder( Int top, Int width, Int bottom, Int pad )
for( UnsignedInt frame = 0; frame <= end; frame += ( split && frame < EARLY_FRAMES ) ? minute : lateStep )
{
const Int x = buildX( frame, end, left, span );
- addRule( x, rowsTop, x, rowsTop + (Int)players.size() * rowHeight, frame == EARLY_FRAMES && split ? AXIS : GRID );
- addText( clockText( frame ), s_smallFont, x, top, TEXT_DIM, 1 );
+ addRule( x, rowsTop, x, rowsTop + (Int)players.size() * rowHeight, frame == EARLY_FRAMES && split ? UIStyle::FRAME : UIStyle::GRID );
+ addText( clockText( frame ), s_smallFont, x, top, UIStyle::MUTED, 1 );
if( split && frame < EARLY_FRAMES && frame + minute > EARLY_FRAMES )
frame = EARLY_FRAMES - minute;
}
@@ -762,11 +763,11 @@ static void layoutBuildOrder( Int top, Int width, Int bottom, Int pad )
const GraphPlayer &player = *players[ each ];
const Int rowTop = rowsTop + (Int)each * rowHeight;
if( each > 0 )
- addRule( pad * 2, rowTop, right + iconWidth / 2, rowTop, GRID );
+ addRule( pad * 2, rowTop, right + iconWidth / 2, rowTop, UIStyle::GRID );
const Int nameTop = rowTop + ( rowHeight - ( twoLines ? 2 : 1 ) * smallLine ) / 2;
- addText( labels[ each ], s_smallFont, pad * 2, nameTop, player.color );
+ addText( labels[ each ], s_smallFont, pad * 2, nameTop, player.nameColor );
if( twoLines )
- addText( player.side, s_smallFont, pad * 2, nameTop + smallLine, TEXT_DIM );
+ addText( player.side, s_smallFont, pad * 2, nameTop + smallLine, UIStyle::MUTED );
std::vector< Int > laneRight( lanes, -iconWidth );
std::vector< const ThingTemplate * > seen;
@@ -788,12 +789,12 @@ static void layoutBuildOrder( Int top, Int width, Int bottom, Int pad )
Int x = buildX( build.frame, end, left, span ) - iconWidth / 2;
const Int lane = pickLane( laneRight, x, iconWidth, 3 );
x = min( x, right - iconWidth / 2 ); // a push never carries a picture off the timeline's end
- GraphMark mark = newMark( x, lanesTop + lane * ( icon + 3 ), iconWidth, icon, TAB_FILL,
- build.thing->isKindOf( KINDOF_STRUCTURE ) ? TEXT_DIM : player.color );
+ GraphMark mark = newMark( x, lanesTop + lane * ( icon + 3 ), iconWidth, icon, UIStyle::CARD,
+ build.thing->isKindOf( KINDOF_STRUCTURE ) ? UIStyle::MUTED : player.color );
mark.image = image;
UnicodeString tip;
tip.format( u"%s %s", clockText( build.frame ).str(), build.thing->getDisplayName().str() );
- addTip( mark, tip, TEXT );
+ addTip( mark, tip, UIStyle::INK );
s_marks.push_back( mark );
}
}
@@ -820,7 +821,7 @@ static Int layoutLegend( Int top, Int width, Int pad )
y += smallLine + pad / 3;
}
s_marks.push_back( newMark( x, y + 3, 4, smallLine - 6, players[ each ]->color, players[ each ]->color ) );
- addText( label, s_smallFont, x + 4 + pad / 2, y, players[ each ]->color );
+ addText( label, s_smallFont, x + 4 + pad / 2, y, players[ each ]->nameColor );
x += entryWidth + pad * 2;
}
return y + smallLine;
@@ -835,18 +836,23 @@ static void layoutPanel( void )
const Int pad = max( s_font->height / 2, 4 );
const Int smallLine = s_smallFont->height;
- const Int tabsTop = pad * 2;
+ // the header, as a staging room's: the map's name, the wordmark across from it, a rule under both
+ Int titleWidth, titleHeight;
+ s_title->getSize( &titleWidth, &titleHeight );
+ s_ruleY = pad * 2 + titleHeight + pad;
+
+ // the pages as the options screen's tabs, boxed, the open one lettered green
+ const Int tabsTop = s_ruleY + pad * 2;
Int x = pad * 2;
for( Int tab = 0; tab < GRAPH_TAB_COUNT; tab++ )
{
- s_tabBox[ tab ].lo.x = x - pad / 2;
+ s_tabBox[ tab ].lo.x = x;
s_tabBox[ tab ].lo.y = tabsTop;
- s_tabBox[ tab ].hi.x = x + textWidth( s_tabText[ tab ] ) + pad / 2;
- s_tabBox[ tab ].hi.y = tabsTop + smallLine + pad / 2;
- x += textWidth( s_tabText[ tab ] ) + pad * 2;
+ s_tabBox[ tab ].hi.x = x + textWidth( s_tabText[ tab ] ) + pad * 3;
+ s_tabBox[ tab ].hi.y = tabsTop + smallLine + pad;
+ x = s_tabBox[ tab ].hi.x + pad / 2;
}
const Int tabsBottom = s_tabBox[ 0 ].hi.y;
- addRule( pad * 2, tabsBottom, width - pad * 2, tabsBottom, GRID );
s_toggleBox.lo.x = s_toggleBox.hi.x = 0;
s_toggleBox.lo.y = s_toggleBox.hi.y = 0;
@@ -856,9 +862,9 @@ static void layoutPanel( void )
{
s_toggleText->setText( TheGameText->fetch( s_everyBuild ? "GUI:BuildOrderFirsts" : "GUI:BuildOrderEvery" ) );
s_toggleBox.hi.x = width - pad * 2;
- s_toggleBox.lo.x = s_toggleBox.hi.x - textWidth( s_toggleText ) - pad * 2;
- s_toggleBox.lo.y = tabsTop - pad / 2;
- s_toggleBox.hi.y = tabsBottom - 2;
+ s_toggleBox.lo.x = s_toggleBox.hi.x - textWidth( s_toggleText ) - pad * 3;
+ s_toggleBox.lo.y = tabsTop;
+ s_toggleBox.hi.y = tabsBottom;
layoutBuildOrder( tabsBottom + pad, width, height - pad, pad );
}
else
@@ -884,21 +890,28 @@ static void drawPanel( GameWindow *window, WinInstanceData *instData )
Int ox, oy, width, height;
window->winGetScreenPosition( &ox, &oy );
window->winGetSize( &width, &height );
- TheDisplay->drawFillRect( ox, oy, width, height, PANEL_FILL );
- TheDisplay->drawOpenRect( ox, oy, width, height, 2.0f, PANEL_EDGE );
+ UIStyle::panel( ox, oy, width, height, UIStyle::PANEL );
const Int pad = max( s_font->height / 2, 4 );
+ s_title->draw( ox + pad * 2, oy + pad * 2, UIStyle::INK, UIStyle::SHADOW );
+ Int titleWidth, titleHeight, markWidth, markHeight;
+ s_title->getSize( &titleWidth, &titleHeight );
+ s_wordmark[ 0 ]->getSize( &markWidth, &markHeight );
+ UIStyle::wordmark( s_wordmark, ox + width - pad * 2, oy + pad * 2 + ( titleHeight - markHeight ) / 2 );
+ UIStyle::rule( ox + pad * 2, oy + s_ruleY, width - pad * 4 );
+
for( Int tab = 0; tab < GRAPH_TAB_COUNT; tab++ )
{
const IRegion2D &box = s_tabBox[ tab ];
- s_tabText[ tab ]->draw( ox + box.lo.x + pad / 2, oy + box.lo.y, tab == s_tab ? TEXT : TEXT_DIM, SHADOW );
- if( tab == s_tab )
- TheDisplay->drawFillRect( ox + box.lo.x, oy + box.hi.y - 2, box.hi.x - box.lo.x, 3, GOLD );
+ UIStyle::tab( ox + box.lo.x, oy + box.lo.y, box.hi.x - box.lo.x, box.hi.y - box.lo.y );
+ s_tabText[ tab ]->draw( ox + ( box.lo.x + box.hi.x - textWidth( s_tabText[ tab ] ) ) / 2,
+ oy + ( box.lo.y + box.hi.y - s_smallFont->height ) / 2, tab == s_tab ? UIStyle::ACTIVE : UIStyle::INK, UIStyle::SHADOW );
}
if( s_toggleBox.hi.x > s_toggleBox.lo.x )
{
- drawBox( s_toggleBox, ox, oy, TAB_FILL, PANEL_EDGE );
- s_toggleText->draw( ox + s_toggleBox.lo.x + pad, oy + s_toggleBox.lo.y + ( s_toggleBox.hi.y - s_toggleBox.lo.y - s_smallFont->height ) / 2, TEXT, SHADOW );
+ UIStyle::button( ox + s_toggleBox.lo.x, oy + s_toggleBox.lo.y, s_toggleBox.hi.x - s_toggleBox.lo.x, s_toggleBox.hi.y - s_toggleBox.lo.y );
+ s_toggleText->draw( ox + ( s_toggleBox.lo.x + s_toggleBox.hi.x - textWidth( s_toggleText ) ) / 2,
+ oy + s_toggleBox.lo.y + ( s_toggleBox.hi.y - s_toggleBox.lo.y - s_smallFont->height ) / 2, UIStyle::INK, UIStyle::SHADOW );
}
for( size_t each = 0; each < s_rules.size(); each++ )
@@ -907,7 +920,7 @@ static void drawPanel( GameWindow *window, WinInstanceData *instData )
TheDisplay->drawLine( ox + rule.lo.x, oy + rule.lo.y, ox + rule.hi.x, oy + rule.hi.y, 1.0f, s_ruleColors[ each ] );
}
for( size_t each = 0; each < s_texts.size(); each++ )
- s_texts[ each ].text->draw( ox + s_texts[ each ].x, oy + s_texts[ each ].y, s_texts[ each ].color, SHADOW );
+ s_texts[ each ].text->draw( ox + s_texts[ each ].x, oy + s_texts[ each ].y, s_texts[ each ].color, UIStyle::SHADOW );
const ICoord2D mouse = TheMouse->getMouseStatus()->pos;
Int hovered = -1;
@@ -941,7 +954,7 @@ static void drawPanel( GameWindow *window, WinInstanceData *instData )
{
Int w, h;
mark.label->getSize( &w, &h );
- mark.label->draw( ox + ( mark.box.lo.x + mark.box.hi.x - w ) / 2, oy + ( mark.box.lo.y + mark.box.hi.y - h ) / 2, mark.edge, SHADOW );
+ mark.label->draw( ox + ( mark.box.lo.x + mark.box.hi.x - w ) / 2, oy + ( mark.box.lo.y + mark.box.hi.y - h ) / 2, mark.edge, UIStyle::SHADOW );
}
if( mark.count )
{
@@ -950,7 +963,7 @@ static void drawPanel( GameWindow *window, WinInstanceData *instData )
const Int x = ox + mark.box.hi.x - w - 2;
const Int y = oy + mark.box.hi.y - h;
TheDisplay->drawFillRect( x - 2, y, w + 3, h - 1, GameMakeColor( 0, 0, 0, 200 ) );
- mark.count->draw( x, y - 1, TEXT, SHADOW );
+ mark.count->draw( x, y - 1, UIStyle::INK, UIStyle::SHADOW );
}
}
@@ -964,7 +977,7 @@ static void drawPanel( GameWindow *window, WinInstanceData *instData )
s_tipText.push_back( newText( mark.tip[ line ].text, s_smallFont ) );
s_tipMark = hovered;
}
- drawBox( mark.box, ox, oy, 0, GOLD );
+ drawBox( mark.box, ox, oy, 0, UIStyle::EDGE_LIT );
Int w = 0;
const Int lineHeight = s_smallFont->height + 2;
for( size_t line = 0; line < s_tipText.size(); line++ )
@@ -972,10 +985,9 @@ static void drawPanel( GameWindow *window, WinInstanceData *instData )
const Int h = (Int)s_tipText.size() * lineHeight;
const Int x = max( min( ox + mark.box.lo.x, ox + width - w - 12 ), ox + 4 );
const Int y = oy + mark.box.hi.y + 4 + h + 6 < oy + height ? oy + mark.box.hi.y + 4 : oy + mark.box.lo.y - h - 10;
- TheDisplay->drawFillRect( x, y, w + 8, h + 6, GameMakeColor( 0, 0, 0, 230 ) );
- TheDisplay->drawOpenRect( x, y, w + 8, h + 6, 1.0f, GOLD );
+ UIStyle::panel( x, y, w + 8, h + 6, UIStyle::CARD );
for( size_t line = 0; line < s_tipText.size(); line++ )
- s_tipText[ line ]->draw( x + 4, y + 3 + (Int)line * lineHeight, mark.tip[ line ].color, SHADOW );
+ s_tipText[ line ]->draw( x + 4, y + 3 + (Int)line * lineHeight, mark.tip[ line ].color, UIStyle::SHADOW );
}
}
@@ -1008,17 +1020,29 @@ static WindowMsgHandledType panelInput( GameWindow *window, UnsignedInt msg, Win
}
//-------------------------------------------------------------------------------------------------
-/** Makes the panel, hidden until ScoreScreenGraphsShow; anchor is the layout's OK button, whose font
- * the panel takes and above which it stops. */
+/** Makes the panel, hidden until ScoreScreenGraphsShow; anchor is the layout's OK button, above which
+ * it stops. */
void ScoreScreenGraphsInit( GameWindow *parent, GameWindow *anchor )
{
s_players.clear();
s_tab = GRAPH_TAB_SUMMARY;
s_everyBuild = FALSE;
- s_font = anchor->winGetFont();
- s_bigFont = TheFontLibrary->getFont( s_font->nameString, s_font->pointSize + 3, FALSE );
- s_smallFont = TheFontLibrary->getFont( s_font->nameString, max( s_font->pointSize - 2, 8 ), FALSE );
- s_tinyFont = TheFontLibrary->getFont( s_font->nameString, max( s_font->pointSize * 2 / 3, 7 ), TRUE );
+ s_font = UIStyle::font( UIStyle::TEXT_STRONG );
+ s_bigFont = UIStyle::font( UIStyle::TEXT_HEADING );
+ s_smallFont = UIStyle::font( UIStyle::TEXT_BODY );
+ s_tinyFont = UIStyle::font( UIStyle::TEXT_SMALL, TRUE );
+
+ // the match's map names the page, as it named the load screen
+ const MapMetaData *map = TheMapCache->findMap( TheGlobalData->m_mapName );
+ UnicodeString mapName;
+ if( map )
+ mapName = map->m_displayName;
+ else
+ mapName.translate( TheGameState->getMapLeafName( TheGlobalData->m_mapName ) );
+ s_title = newText( mapName, UIStyle::titleFont( UIStyle::TEXT_TITLE ) );
+ GameFont *wordmarkFont = UIStyle::font( UIStyle::TEXT_STRONG, TRUE );
+ s_wordmark[ 0 ] = newText( UnicodeString( u"Zero Hour" ), wordmarkFont );
+ s_wordmark[ 1 ] = newText( UnicodeString( u" Reforged" ), wordmarkFont );
Int parentX, parentY, parentW, parentH, anchorX, anchorY, anchorW, anchorH;
parent->winGetScreenPosition( &parentX, &parentY );
@@ -1048,6 +1072,7 @@ void ScoreScreenGraphsAddPlayer( Player *player, const UnicodeString &name, Colo
entry.name = name;
entry.side = side ? side->getDisplayName() : UnicodeString::TheEmptyString;
entry.color = color;
+ entry.nameColor = UIStyle::readable( color );
entry.winner = TheVictoryConditions->hasAchievedVictory( player );
entry.stats[ SUMMARY_UNITS_BUILT ] = score->getTotalUnitsBuilt();
entry.stats[ SUMMARY_UNITS_LOST ] = score->getTotalUnitsLost();
@@ -1067,6 +1092,7 @@ void ScoreScreenGraphsAddSide( const UnicodeString &name, Color color, Int units
entry.index = -1;
entry.name = name;
entry.color = color;
+ entry.nameColor = UIStyle::readable( color );
entry.winner = FALSE;
entry.stats[ SUMMARY_UNITS_BUILT ] = unitsBuilt;
entry.stats[ SUMMARY_UNITS_LOST ] = unitsLost;
@@ -1101,6 +1127,9 @@ void ScoreScreenGraphsShutdown( void )
for( Int tab = 0; tab < GRAPH_TAB_COUNT; tab++ )
TheDisplayStringManager->freeDisplayString( s_tabText[ tab ] );
TheDisplayStringManager->freeDisplayString( s_toggleText );
+ TheDisplayStringManager->freeDisplayString( s_title );
+ TheDisplayStringManager->freeDisplayString( s_wordmark[ 0 ] );
+ TheDisplayStringManager->freeDisplayString( s_wordmark[ 1 ] );
TheWindowManager->winDestroy( s_panel );
s_panel = NULL;
s_players.clear();
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp
index 785202b39..ebaaec27a 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp
@@ -88,6 +88,7 @@
#include "GameClient/WindowLayout.h"
#include "GameClient/WindowVideoManager.h"
#include "GameClient/ChallengeGenerals.h"
+#include "GameClient/UIStyle.h"
#include "GameLogic/AI.h" // aiPersonalityName, for a computer seat's card
#include "GameLogic/FPUControl.h"
#include "GameLogic/GameLogic.h"
@@ -194,26 +195,14 @@ void LoadScreen::update( Int percent )
Everything is laid out once, when the board is made, against a 1920x1080 picture scaled to the
screen; a pass draws flat fills, the images the lobby and the challenge menu already load (the
portraits share one 512 page, the crests another) and display strings made up front. The
- colours are zerohour.gg's, as the -directorrecord broadcast's are, and so are its fonts' Windows
- stand-ins. */
-
-static const Color BOARD_GROUND = GameMakeColor( 0x0c, 0x12, 0x20, 255 );
-static const Color BOARD_PANEL = GameMakeColor( 0x12, 0x1a, 0x2b, 255 );
-static const Color BOARD_LINE = GameMakeColor( 0x1f, 0x29, 0x40, 255 );
-static const Color BOARD_EDGE = GameMakeColor( 0x2f, 0x3b, 0x57, 255 );
-static const Color BOARD_INK = GameMakeColor( 0xe8, 0xea, 0xf0, 255 );
-static const Color BOARD_MUTED = GameMakeColor( 0x8e, 0x97, 0xad, 255 );
-static const Color BOARD_BLUE = GameMakeColor( 0x80, 0x95, 0xea, 255 );
-static const Color BOARD_SHADOW = GameMakeColor( 0, 0, 0, 255 );
-static const char *const BOARD_WORDS = "Segoe UI";
-static const char *const BOARD_NUMBERS = "Consolas";
-/// the picture the sizes below are given for; a smaller screen scales them down, 12 pixels the floor
+ colours, the type and the boxes are the front end's (UIStyle.h), so the board reads as the
+ staging room it came from. */
+
+/// the picture the boxes below are given for; another screen scales them by its smaller axis
static const Real BOARD_WIDTH = 1920.0f;
static const Real BOARD_HEIGHT = 1080.0f;
-static const Int BOARD_SMALLEST_TEXT = 12;
static const Int BOARD_TIP_COUNT = 10;
static const UnsignedInt BOARD_TIP_MILLISECONDS = 8000;
-static const Int BOARD_WASH_STRIPS = 48;
/// a middle dot between spaces, spelled out: the source is read in the machine's code page
static const WideChar BOARD_SEPARATOR[] = { ' ', ' ', ' ', 0x00B7, ' ', ' ', ' ', 0 };
@@ -268,7 +257,6 @@ private:
void drawBriefing( void );
void drawCard( const BoardCard &card );
Int scaled( Real pixels ) const { return REAL_TO_INT( pixels * m_scale + 0.5f ); }
- GameFont *font( const char *name, Real pixels, Bool bold ) const;
DisplayString *text( const UnicodeString &words, GameFont *font );
BoardCard *cardFor( Int slot );
void layoutColumn( std::vector< Int > &column, Int left, Int top, Int bottom, Bool mirrored );
@@ -338,13 +326,6 @@ LoadScreenBoard::~LoadScreenBoard( void )
TheDisplayStringManager->freeDisplayString( m_strings[ each ] );
}
-GameFont *LoadScreenBoard::font( const char *name, Real pixels, Bool bold ) const
-{
- // a point is 4/3 of a pixel at the 96 dots an inch the glyphs are drawn at
- const Int height = max( BOARD_SMALLEST_TEXT, scaled( pixels ) );
- return TheFontLibrary->getFont( AsciiString( name ), max( 1, height * 3 / 4 ), bold );
-}
-
DisplayString *LoadScreenBoard::text( const UnicodeString &words, GameFont *font )
{
DisplayString *string = TheDisplayStringManager->newDisplayString();
@@ -378,26 +359,6 @@ static Int stringHeight( DisplayString *string )
return height;
}
-static Color withAlpha( Color color, Int alpha )
-{
- UnsignedByte r, g, b, a;
- GameGetColorComponents( color, &r, &g, &b, &a );
- return GameMakeColor( r, g, b, alpha );
-}
-
-/** Blue and purple house colours are too dark for words on the panel; they are lifted part of the
- * way to white, the bar and the map spot keep the colour itself. */
-static Color readableColor( Color color )
-{
- UnsignedByte r, g, b, a;
- GameGetColorComponents( color, &r, &g, &b, &a );
- const Int luma = ( 54 * r + 183 * g + 19 * b ) / 256;
- if( luma >= 120 )
- return color;
- const Int lift = 110; // of 256
- return GameMakeColor( r + ( 255 - r ) * lift / 256, g + ( 255 - g ) * lift / 256, b + ( 255 - b ) * lift / 256, 255 );
-}
-
/** The side's crest from the lobby: the three 144 pixel logos on one page. A mod's side brings its
* own lobby glyph or nothing. */
static const Image *sideCrest( const PlayerTemplate *side )
@@ -433,13 +394,13 @@ static UnicodeString tipText( Int index )
GameWindow *LoadScreenBoard::create( GameInfo *game, const char *modeLabel, Bool cardBars )
{
m_network = cardBars;
- GameFont *labelFont = font( BOARD_NUMBERS, 16, TRUE );
- GameFont *centerFont = font( BOARD_WORDS, 64, TRUE );
- GameFont *centerSmallFont = font( BOARD_WORDS, 24, TRUE );
- GameFont *observerFont = font( BOARD_WORDS, 16, FALSE );
- GameFont *nameFont = font( BOARD_WORDS, 26, TRUE );
- GameFont *armyFont = font( BOARD_WORDS, 18, FALSE );
- GameFont *detailFont = font( BOARD_WORDS, 16, FALSE );
+ GameFont *labelFont = UIStyle::font( UIStyle::TEXT_SMALL, TRUE );
+ GameFont *centerFont = UIStyle::titleFont( UIStyle::TEXT_DISPLAY );
+ GameFont *centerSmallFont = UIStyle::font( UIStyle::TEXT_HEADING, TRUE );
+ GameFont *observerFont = UIStyle::font( UIStyle::TEXT_SMALL );
+ GameFont *nameFont = UIStyle::font( UIStyle::TEXT_STRONG, TRUE );
+ GameFont *armyFont = UIStyle::font( UIStyle::TEXT_BODY );
+ GameFont *detailFont = UIStyle::font( UIStyle::TEXT_SMALL );
// a watcher, a replay's viewer among them, sees every side as it is; a player sees what the
// lobby let him see of his enemies
@@ -468,7 +429,7 @@ GameWindow *LoadScreenBoard::create( GameInfo *game, const char *modeLabel, Bool
card.slot = i;
const Int colorIndex = seeAll ? slot->getColor() : slot->getApparentColor();
card.color = TheMultiplayerSettings->getColor( colorIndex )->getColor();
- card.nameColor = readableColor( card.color );
+ card.nameColor = UIStyle::readable( card.color );
card.team = slot->getTeamNumber();
card.startSpot = seeAll ? slot->getStartPos() : slot->getApparentStartPos();
card.percent = cardBars && slot->isHuman() ? 0 : -1;
@@ -684,19 +645,19 @@ GameWindow *LoadScreenBoard::create( GameInfo *game, const char *modeLabel, Bool
/** The header's and the foot's words, the same on every board. */
void LoadScreenBoard::prepare( const UnicodeString &title, const UnicodeString &subtitle )
{
- GameFont *wordmarkFont = font( BOARD_WORDS, 24, TRUE );
- GameFont *tipFont = font( BOARD_WORDS, 18, FALSE );
- m_title = text( title, font( BOARD_WORDS, 40, TRUE ) );
- m_subtitle = text( subtitle, font( BOARD_WORDS, 18, FALSE ) );
+ GameFont *wordmarkFont = UIStyle::font( UIStyle::TEXT_STRONG, TRUE );
+ GameFont *tipFont = UIStyle::font( UIStyle::TEXT_BODY );
+ m_title = text( title, UIStyle::titleFont( UIStyle::TEXT_TITLE ) );
+ m_subtitle = text( subtitle, tipFont );
m_wordmark[ 0 ] = text( UnicodeString( u"Zero Hour" ), wordmarkFont );
m_wordmark[ 1 ] = text( UnicodeString( u" Reforged" ), wordmarkFont );
// the foot: a tip, the load's percentage and its bar
- m_tipLabel = text( TheGameText->fetch( "GUI:LoadTip" ), font( BOARD_NUMBERS, 16, TRUE ) );
+ m_tipLabel = text( TheGameText->fetch( "GUI:LoadTip" ), UIStyle::font( UIStyle::TEXT_SMALL, TRUE ) );
m_tipIndex = (Int)( Clock_Milliseconds() % BOARD_TIP_COUNT );
m_tipSince = Clock_Milliseconds();
m_tip = text( tipText( m_tipIndex ), tipFont );
- m_percent = text( UnicodeString( u"0%" ), font( BOARD_NUMBERS, 20, TRUE ) );
+ m_percent = text( UnicodeString( u"0%" ), UIStyle::font( UIStyle::TEXT_STRONG, TRUE ) );
m_waiting = text( TheGameText->fetch( "GUI:LoadWaiting" ), tipFont );
m_localPercent = 0;
}
@@ -723,9 +684,9 @@ GameWindow *LoadScreenBoard::createMission( GameWindow *parent, const UnicodeStr
m_briefingBox.lo.x = m_left + scaled( 64 );
m_briefingBox.lo.y = m_top + scaled( 216 );
m_briefingBox.hi.x = m_briefingBox.lo.x + width;
- m_briefingHead = text( TheGameText->fetch( "GUI:LoadBriefing" ), font( BOARD_NUMBERS, 16, TRUE ) );
+ m_briefingHead = text( TheGameText->fetch( "GUI:LoadBriefing" ), UIStyle::font( UIStyle::TEXT_SMALL, TRUE ) );
Int bottom = m_briefingBox.lo.y + pad + stringHeight( m_briefingHead ) + scaled( 8 );
- GameFont *lineFont = font( BOARD_WORDS, 22, FALSE );
+ GameFont *lineFont = UIStyle::font( UIStyle::TEXT_STRONG );
for( Int line = 0; line < briefingLines; line++ )
{
if( briefing[ line ].isEmpty() )
@@ -797,19 +758,7 @@ void LoadScreenBoard::drawCard( const BoardCard &card )
const Int y0 = card.box.lo.y;
const Int width = card.box.hi.x - x0;
const Int height = card.box.hi.y - y0;
- TheDisplay->drawFillRect( x0, y0, width, height, BOARD_PANEL );
-
- // the player's colour washes in from the outer edge, under a solid stripe of it
- const Int stripe = max( 3, scaled( 6 ) );
- const Int wash = width * 9 / 20;
- for( Int strip = 0; strip < BOARD_WASH_STRIPS; strip++ )
- {
- const Int from = wash * strip / BOARD_WASH_STRIPS;
- const Int to = wash * ( strip + 1 ) / BOARD_WASH_STRIPS;
- const Int alpha = 64 * ( BOARD_WASH_STRIPS - strip ) / BOARD_WASH_STRIPS;
- const Int x = card.mirrored ? x0 + width - to : x0 + from;
- TheDisplay->drawFillRect( x, y0, to - from, height, withAlpha( card.color, alpha ) );
- }
+ UIStyle::panel( x0, y0, width, height, UIStyle::CARD );
// the side's crest, faint, at the inner end
if( card.watermark )
@@ -818,20 +767,21 @@ void LoadScreenBoard::drawCard( const BoardCard &card )
const Int x = card.mirrored ? x0 + scaled( 24 ) : x0 + width - scaled( 24 ) - size;
TheDisplay->drawImage( card.watermark, x, y0 + ( height - size ) / 2, x + size, y0 + ( height + size ) / 2, GameMakeColor( 255, 255, 255, 30 ) );
}
- TheDisplay->drawFillRect( card.mirrored ? x0 + width - stripe : x0, y0, stripe, height, card.color );
- TheDisplay->drawOpenRect( x0, y0, width, height, 1.0f, BOARD_EDGE );
+ // the player's colour down the outer edge
+ const Int stripe = UIStyle::stripeWidth();
+ UIStyle::stripe( card.mirrored ? x0 + width - stripe : x0, y0, height, card.color );
// the portrait, in a frame of the player's colour
const Int pad = scaled( 16 );
const Int emblem = min( height - 2 * pad, scaled( 168 ) );
const Int emblemX = card.mirrored ? x0 + width - stripe - pad - emblem : x0 + stripe + pad;
const Int emblemY = y0 + ( height - emblem ) / 2;
- TheDisplay->drawFillRect( emblemX, emblemY, emblem, emblem, BOARD_GROUND );
+ TheDisplay->drawFillRect( emblemX, emblemY, emblem, emblem, UIStyle::GROUND );
if( card.emblem )
TheDisplay->drawImage( card.emblem, emblemX + 2, emblemY + 2, emblemX + emblem - 2, emblemY + emblem - 2 );
else
- m_unknown->draw( emblemX + ( emblem - stringWidth( m_unknown ) ) / 2, emblemY + ( emblem - stringHeight( m_unknown ) ) / 2, BOARD_MUTED, BOARD_SHADOW );
- TheDisplay->drawOpenRect( emblemX, emblemY, emblem, emblem, 1.0f, withAlpha( card.color, 200 ) );
+ m_unknown->draw( emblemX + ( emblem - stringWidth( m_unknown ) ) / 2, emblemY + ( emblem - stringHeight( m_unknown ) ) / 2, UIStyle::MUTED, UIStyle::SHADOW );
+ TheDisplay->drawOpenRect( emblemX, emblemY, emblem, emblem, 1.0f, UIStyle::withAlpha( card.color, 200 ) );
// the words, on the portrait's far side, aligned away from it
const Int textGap = scaled( 24 );
@@ -849,11 +799,11 @@ void LoadScreenBoard::drawCard( const BoardCard &card )
if( card.percent >= 0 )
y -= scaled( 8 );
DisplayString *lines[ 3 ] = { card.name, card.army, card.detail };
- const Color colors[ 3 ] = { card.nameColor, BOARD_INK, BOARD_MUTED };
+ const Color colors[ 3 ] = { card.nameColor, UIStyle::INK, UIStyle::MUTED };
for( Int line = 0; line < ( hasDetail ? 3 : 2 ); line++ )
{
const Int w = stringWidth( lines[ line ] );
- lines[ line ]->draw( card.mirrored ? textRight - w : textLeft, y, colors[ line ], BOARD_SHADOW );
+ lines[ line ]->draw( card.mirrored ? textRight - w : textLeft, y, colors[ line ], UIStyle::SHADOW );
if( line == 0 && card.badge )
{
const Int size = stringHeight( card.name ) * 3 / 4;
@@ -872,8 +822,8 @@ void LoadScreenBoard::drawCard( const BoardCard &card )
const Int tx = card.mirrored ? x0 + scaled( 14 ) : x0 + width - scaled( 14 ) - w;
const Int sx = card.mirrored ? tx + w + scaled( 8 ) : tx - scaled( 8 ) - swatch;
TheDisplay->drawFillRect( sx, ty + scaled( 2 ), swatch, swatch, LobbyTeamColor( card.team ) );
- TheDisplay->drawOpenRect( sx, ty + scaled( 2 ), swatch, swatch, 1.0f, BOARD_EDGE );
- card.teamText->draw( tx, ty, BOARD_MUTED, BOARD_SHADOW );
+ TheDisplay->drawOpenRect( sx, ty + scaled( 2 ), swatch, swatch, 1.0f, UIStyle::FRAME );
+ card.teamText->draw( tx, ty, UIStyle::MUTED, UIStyle::SHADOW );
}
// a network player's own load
@@ -884,12 +834,12 @@ void LoadScreenBoard::drawCard( const BoardCard &card )
const Int label = stringWidth( card.percentText ) + scaled( 12 );
const Int barLeft = card.mirrored ? textLeft + label : textLeft;
const Int barRight = card.mirrored ? textRight : textRight - label;
- TheDisplay->drawFillRect( barLeft, barY, barRight - barLeft, barHeight, BOARD_LINE );
+ TheDisplay->drawFillRect( barLeft, barY, barRight - barLeft, barHeight, UIStyle::GRID );
const Int filled = ( barRight - barLeft ) * card.percent / 100;
TheDisplay->drawFillRect( card.mirrored ? barRight - filled : barLeft, barY, filled, barHeight, card.color );
const Int labelY = barY + barHeight / 2 - stringHeight( card.percentText ) / 2;
card.percentText->draw( card.mirrored ? textLeft : textRight - stringWidth( card.percentText ), labelY,
- card.percent >= 100 ? BOARD_INK : BOARD_MUTED, BOARD_SHADOW );
+ card.percent >= 100 ? UIStyle::INK : UIStyle::MUTED, UIStyle::SHADOW );
}
}
@@ -909,44 +859,41 @@ void LoadScreenBoard::draw( void )
const Int footTop = m_top + scaled( 952 );
if( m_mission )
{
- const Color band = withAlpha( BOARD_GROUND, 224 );
+ const Color band = UIStyle::withAlpha( UIStyle::GROUND, 224 );
TheDisplay->drawFillRect( 0, 0, m_width, headerBottom, band );
TheDisplay->drawFillRect( 0, footTop, m_width, m_height - footTop, band );
drawBriefing();
}
else
{
- TheDisplay->drawFillRect( 0, 0, m_width, m_height, BOARD_GROUND );
+ TheDisplay->drawFillRect( 0, 0, m_width, m_height, UIStyle::GROUND );
drawMatch();
}
// the header
const Int titleY = m_top + scaled( 52 );
- m_title->draw( left, titleY, BOARD_INK, BOARD_SHADOW );
- m_subtitle->draw( left, titleY + stringHeight( m_title ) + scaled( 4 ), BOARD_MUTED, BOARD_SHADOW );
- const Int markWidth = stringWidth( m_wordmark[ 0 ] ) + stringWidth( m_wordmark[ 1 ] );
- const Int markY = titleY + ( stringHeight( m_title ) - stringHeight( m_wordmark[ 0 ] ) ) / 2;
- m_wordmark[ 0 ]->draw( right - markWidth, markY, BOARD_INK, BOARD_SHADOW );
- m_wordmark[ 1 ]->draw( right - stringWidth( m_wordmark[ 1 ] ), markY, BOARD_BLUE, BOARD_SHADOW );
- TheDisplay->drawFillRect( left, headerBottom, right - left, 1, BOARD_LINE );
+ m_title->draw( left, titleY, UIStyle::INK, UIStyle::SHADOW );
+ m_subtitle->draw( left, titleY + stringHeight( m_title ) + scaled( 4 ), UIStyle::MUTED, UIStyle::SHADOW );
+ UIStyle::wordmark( m_wordmark, right, titleY + ( stringHeight( m_title ) - stringHeight( m_wordmark[ 0 ] ) ) / 2 );
+ UIStyle::rule( left, headerBottom, right - left );
// the foot
const Int barHeight = max( 4, scaled( 8 ) );
const Int barY = m_top + scaled( 1016 );
const Int rowY = barY - scaled( 18 ) - stringHeight( m_tip );
- TheDisplay->drawFillRect( left, footTop, right - left, 1, BOARD_LINE );
+ UIStyle::rule( left, footTop, right - left );
const Int chipPad = scaled( 8 );
const Int chipHeight = stringHeight( m_tipLabel ) + scaled( 4 );
const Int chipY = rowY + ( stringHeight( m_tip ) - chipHeight ) / 2;
- TheDisplay->drawOpenRect( left, chipY, stringWidth( m_tipLabel ) + 2 * chipPad, chipHeight, 1.0f, BOARD_BLUE );
- m_tipLabel->draw( left + chipPad, chipY + scaled( 2 ), BOARD_BLUE, BOARD_SHADOW );
- m_tip->draw( left + stringWidth( m_tipLabel ) + 2 * chipPad + scaled( 16 ), rowY, BOARD_INK, BOARD_SHADOW );
+ TheDisplay->drawOpenRect( left, chipY, stringWidth( m_tipLabel ) + 2 * chipPad, chipHeight, 1.0f, UIStyle::FRAME );
+ m_tipLabel->draw( left + chipPad, chipY + scaled( 2 ), UIStyle::ACTIVE, UIStyle::SHADOW );
+ m_tip->draw( left + stringWidth( m_tipLabel ) + 2 * chipPad + scaled( 16 ), rowY, UIStyle::INK, UIStyle::SHADOW );
if( m_network && m_localPercent > 100 )
- m_waiting->draw( right - stringWidth( m_waiting ), rowY, BOARD_MUTED, BOARD_SHADOW );
+ m_waiting->draw( right - stringWidth( m_waiting ), rowY, UIStyle::MUTED, UIStyle::SHADOW );
else
- m_percent->draw( right - stringWidth( m_percent ), rowY + stringHeight( m_tip ) - stringHeight( m_percent ), BOARD_INK, BOARD_SHADOW );
- TheDisplay->drawFillRect( left, barY, right - left, barHeight, BOARD_LINE );
- TheDisplay->drawFillRect( left, barY, ( right - left ) * min( m_localPercent, 100 ) / 100, barHeight, BOARD_BLUE );
+ m_percent->draw( right - stringWidth( m_percent ), rowY + stringHeight( m_tip ) - stringHeight( m_percent ), UIStyle::INK, UIStyle::SHADOW );
+ TheDisplay->drawFillRect( left, barY, right - left, barHeight, UIStyle::GRID );
+ TheDisplay->drawFillRect( left, barY, ( right - left ) * min( m_localPercent, 100 ) / 100, barHeight, UIStyle::EDGE );
}
void LoadScreenBoard::drawBriefing( void )
@@ -957,16 +904,14 @@ void LoadScreenBoard::drawBriefing( void )
const Int width = box.hi.x - box.lo.x;
const Int height = box.hi.y - box.lo.y;
const Int pad = scaled( 28 );
- TheDisplay->drawFillRect( box.lo.x, box.lo.y, width, height, withAlpha( BOARD_GROUND, 216 ) );
- TheDisplay->drawFillRect( box.lo.x, box.lo.y, max( 3, scaled( 6 ) ), height, BOARD_BLUE );
- TheDisplay->drawOpenRect( box.lo.x, box.lo.y, width, height, 1.0f, BOARD_EDGE );
+ UIStyle::panel( box.lo.x, box.lo.y, width, height, UIStyle::PANEL );
Int y = box.lo.y + pad;
- m_briefingHead->draw( box.lo.x + pad, y, BOARD_BLUE, BOARD_SHADOW );
+ m_briefingHead->draw( box.lo.x + pad, y, UIStyle::ACTIVE, UIStyle::SHADOW );
y += stringHeight( m_briefingHead ) + scaled( 8 );
for( size_t each = 0; each < m_briefing.size(); each++ )
{
y += scaled( 10 );
- m_briefing[ each ]->draw( box.lo.x + pad, y, BOARD_INK, BOARD_SHADOW );
+ m_briefing[ each ]->draw( box.lo.x + pad, y, UIStyle::INK, UIStyle::SHADOW );
y += stringHeight( m_briefing[ each ] );
}
}
@@ -987,8 +932,8 @@ void LoadScreenBoard::drawMatch( void )
const Int swatch = stringHeight( m_columnHead[ side ] ) - scaled( 4 );
const Int sx = side == 0 ? m_columnHeadPos[ side ].x - scaled( 10 ) - swatch : m_columnHeadPos[ side ].x + stringWidth( m_columnHead[ side ] ) + scaled( 10 );
TheDisplay->drawFillRect( sx, m_columnHeadPos[ side ].y + scaled( 2 ), swatch, swatch, m_columnTeam[ side ] );
- TheDisplay->drawOpenRect( sx, m_columnHeadPos[ side ].y + scaled( 2 ), swatch, swatch, 1.0f, BOARD_EDGE );
- m_columnHead[ side ]->draw( m_columnHeadPos[ side ].x, m_columnHeadPos[ side ].y, BOARD_MUTED, BOARD_SHADOW );
+ TheDisplay->drawOpenRect( sx, m_columnHeadPos[ side ].y + scaled( 2 ), swatch, swatch, 1.0f, UIStyle::FRAME );
+ m_columnHead[ side ]->draw( m_columnHeadPos[ side ].x, m_columnHeadPos[ side ].y, UIStyle::ACTIVE, UIStyle::SHADOW );
}
for( size_t each = 0; each < m_cards.size(); each++ )
@@ -996,22 +941,22 @@ void LoadScreenBoard::drawMatch( void )
// the middle
if( m_centerLabel )
- m_centerLabel->draw( m_centerLabelPos.x, m_centerLabelPos.y, BOARD_INK, BOARD_SHADOW );
+ m_centerLabel->draw( m_centerLabelPos.x, m_centerLabelPos.y, UIStyle::INK, UIStyle::SHADOW );
const Int mapSize = m_mapBox.hi.x - m_mapBox.lo.x;
- TheDisplay->drawFillRect( m_mapBox.lo.x, m_mapBox.lo.y, mapSize, mapSize, BOARD_PANEL );
+ TheDisplay->drawFillRect( m_mapBox.lo.x, m_mapBox.lo.y, mapSize, mapSize, UIStyle::CARD );
if( m_mapImage )
TheDisplay->drawImage( m_mapImage, m_mapDrawn.lo.x, m_mapDrawn.lo.y, m_mapDrawn.hi.x, m_mapDrawn.hi.y );
- TheDisplay->drawOpenRect( m_mapBox.lo.x - 1, m_mapBox.lo.y - 1, mapSize + 2, mapSize + 2, 1.0f, BOARD_EDGE );
+ TheDisplay->drawOpenRect( m_mapBox.lo.x - 1, m_mapBox.lo.y - 1, mapSize + 2, mapSize + 2, 1.0f, UIStyle::FRAME );
const Int spot = max( 8, scaled( 18 ) );
const Int ring = max( 2, scaled( 3 ) );
for( size_t each = 0; each < m_spots.size(); each++ )
{
const BoardSpot &mark = m_spots[ each ];
- TheDisplay->drawFillRect( mark.pos.x - spot / 2 - ring, mark.pos.y - spot / 2 - ring, spot + 2 * ring, spot + 2 * ring, BOARD_GROUND );
+ TheDisplay->drawFillRect( mark.pos.x - spot / 2 - ring, mark.pos.y - spot / 2 - ring, spot + 2 * ring, spot + 2 * ring, UIStyle::GROUND );
TheDisplay->drawFillRect( mark.pos.x - spot / 2, mark.pos.y - spot / 2, spot, spot, mark.color );
}
if( m_observers )
- m_observers->draw( m_observersPos.x, m_observersPos.y, BOARD_MUTED, BOARD_SHADOW );
+ m_observers->draw( m_observersPos.x, m_observersPos.y, UIStyle::MUTED, UIStyle::SHADOW );
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/UIStyle.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/UIStyle.cpp
new file mode 100644
index 000000000..9a603793b
--- /dev/null
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/UIStyle.cpp
@@ -0,0 +1,132 @@
+/*
+** Command & Conquer Generals Zero Hour(tm)
+** Copyright 2025 Electronic Arts Inc.
+**
+** This program is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// FILE: UIStyle.cpp //////////////////////////////////////////////////////////////////////////////
+//
+// The colours, type and boxes of the front end's code-drawn screens. See UIStyle.h.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
+
+#include "GameClient/UIStyle.h"
+#include "GameClient/Display.h"
+#include "GameClient/DisplayString.h"
+#include "GameClient/GameFont.h"
+#include "GameClient/GlobalLanguage.h"
+
+namespace UIStyle
+{
+
+// read off MainMenu.wnd, OptionsMenu.wnd and the staging rooms at 1920x1080 on 2026-10-20
+const Color GROUND = GameMakeColor( 0x05, 0x07, 0x0c, 255 );
+const Color PANEL = GameMakeColor( 0, 0, 0, 200 );
+const Color CARD = GameMakeColor( 0x0a, 0x0c, 0x16, 255 );
+const Color FRAME = GameMakeColor( 0x2f, 0x37, 0xa8, 255 );
+const Color GRID = GameMakeColor( 0x2f, 0x37, 0xa8, 90 );
+const Color EDGE = GameMakeColor( 0x25, 0x34, 0xff, 255 );
+const Color EDGE_LIT = GameMakeColor( 0x00, 0xe3, 0xff, 255 );
+const Color TAB_EDGE = GameMakeColor( 0x85, 0x88, 0xb9, 255 );
+const Color INK = GameMakeColor( 0xff, 0xff, 0xff, 255 );
+const Color MUTED = GameMakeColor( 0xa4, 0xaa, 0xbe, 255 );
+const Color ACTIVE = GameMakeColor( 0xba, 0xff, 0x0c, 255 );
+// BRAND.md's gold and text blue
+const Color GOLD = GameMakeColor( 0xf2, 0xc2, 0x30, 255 );
+const Color WORDMARK_BLUE = GameMakeColor( 0x80, 0x95, 0xea, 255 );
+const Color SHADOW = GameMakeColor( 0, 0, 0, 255 );
+
+Int px( Real at1080 )
+{
+ const Real scale = min( TheDisplay->getWidth() / 1920.0f, TheDisplay->getHeight() / 1080.0f );
+ return REAL_TO_INT( at1080 * scale + 0.5f );
+}
+
+GameFont *font( Int points, Bool bold )
+{
+ return TheFontLibrary->getFont( AsciiString( "Arial" ), TheGlobalLanguageData->adjustFontSize( points ), bold );
+}
+
+GameFont *titleFont( Int points )
+{
+ return TheFontLibrary->getFont( AsciiString( "Generals" ), TheGlobalLanguageData->adjustFontSize( points ), FALSE );
+}
+
+void panel( Int x, Int y, Int width, Int height, Color fill )
+{
+ TheDisplay->drawFillRect( x, y, width, height, fill );
+ TheDisplay->drawOpenRect( x, y, width, height, 1.0f, FRAME );
+}
+
+void rule( Int x, Int y, Int width )
+{
+ TheDisplay->drawFillRect( x, y, width, max( 1, px( 2 ) ), FRAME );
+}
+
+void button( Int x, Int y, Int width, Int height )
+{
+ TheDisplay->drawFillRect( x, y, width, height, PANEL );
+ TheDisplay->drawOpenRect( x, y, width, height, 1.0f, EDGE );
+ TheDisplay->drawOpenRect( x + 1, y + 1, width - 2, height - 2, 1.0f, EDGE_LIT );
+ TheDisplay->drawOpenRect( x + 2, y + 2, width - 4, height - 4, 1.0f, EDGE );
+}
+
+void tab( Int x, Int y, Int width, Int height )
+{
+ TheDisplay->drawFillRect( x, y, width, height, PANEL );
+ TheDisplay->drawOpenRect( x, y, width, height, 1.0f, TAB_EDGE );
+}
+
+void stripe( Int x, Int y, Int height, Color player )
+{
+ TheDisplay->drawFillRect( x, y, stripeWidth(), height, player );
+}
+
+Int stripeWidth( void )
+{
+ return max( 3, px( 6 ) );
+}
+
+void wordmark( DisplayString *words[ 2 ], Int right, Int y )
+{
+ Int first, second, height;
+ words[ 0 ]->getSize( &first, &height );
+ words[ 1 ]->getSize( &second, &height );
+ words[ 0 ]->draw( right - first - second, y, INK, SHADOW );
+ words[ 1 ]->draw( right - second, y, WORDMARK_BLUE, SHADOW );
+}
+
+/** Blue and purple house colours are too dark for words on a panel; they are lifted part of the way
+ * to white, while a stripe, a line or a map spot keeps the colour itself. */
+Color readable( Color player )
+{
+ UnsignedByte r, g, b, a;
+ GameGetColorComponents( player, &r, &g, &b, &a );
+ const Int luma = ( 54 * r + 183 * g + 19 * b ) / 256;
+ if( luma >= 120 )
+ return player;
+ const Int lift = 110; // of 256
+ return GameMakeColor( r + ( 255 - r ) * lift / 256, g + ( 255 - g ) * lift / 256, b + ( 255 - b ) * lift / 256, 255 );
+}
+
+Color withAlpha( Color color, Int alpha )
+{
+ UnsignedByte r, g, b, a;
+ GameGetColorComponents( color, &r, &g, &b, &a );
+ return GameMakeColor( r, g, b, alpha );
+}
+
+}