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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(gameclient): the promotion screen drawn by a page, compact, in grids
Olcay Seygan4956ab1c612c
diff --git a/GeneralsMD/Code/Data/Window/Html/Promotion.html b/GeneralsMD/Code/Data/Window/Html/Promotion.htmlnew file mode 100644index 000000000..82d49b548--- /dev/null+++ b/GeneralsMD/Code/Data/Window/Html/Promotion.html@@ -0,0 +1,114 @@+<!DOCTYPE html>+<!--+ The general's promotion screen, drawn in the place of the side's painting, in the command bar's+ steel. The promotions are the screen's own buttons and paint over this page, each on its cell; the+ close button, the title, the points and the experience bar are the screen's windows too, drawing+ nothing now and still taking their clicks, and the page draws them. Same materials as+ Window/Html/ControlBar.html.++ The game fills in, every frame the screen is up (InGameUI::drawPromotionPage):+ {{side}} "america", "china" or "gla"+ {{held}} "held" while the left mouse button is down+ {{panel.x}} .y .w .h the screen's plate+ {{well.x}} ... the well the promotions stand in, under the bar and the points+ {{Name.x}} .y .w .h StaticTextTitle, ProgressBarExperience, StaticTextRankPointsAvailable and+ ButtonExit, each with {{Name.shown}} and {{Name.state}} ("disabled",+ "hilite", "pushed")+ {{title}} the rank's name, {{points}} the promotions left to spend+ data-each="exprungs" the experience bar's twenty rungs, each {{lit}} "lit" up to the way from+ this rank to the next, at {{x}} and {{w}} inside the bar+ data-each="headings" a heading over each row of promotions, {{heading.x}} .y .w .h and {{label}}+ data-each="cells" every place of every row's grid, {{cell.x}} .y .w .h, and {{state}}+ "owned" once bought, "ready" while it can be, "locked" while it cannot,+ "empty" where no promotion stands+ All in the page's pixels, a pixel of an 800x600 screen. Without this page the painting draws.+-->+<html>+<head>+<meta charset="utf-8">+<title>Promotion</title>+<style>+ html, body { margin: 0; padding: 0; }+ body { background-color: #3b4a36; font-size: 8px; color: #dfe5ea; }+ .hidden { display: none; }+ .piece { position: absolute; }++ /* the plate: steel lit from above, a light line along its top and down its left, dark along its+ right and bottom */+ .plate { background: linear-gradient(to bottom, #9aa3ad, #5a626c 18%, #353c45); border: 1px solid #0c1114;+ border-top-color: #dde4ea; border-left-color: #b3bbc4; }+ .china .plate { background: linear-gradient(to bottom, #c06a52, #7a3120 18%, #3f160f); border-top-color: #f0b8a4; border-left-color: #d58a70; }+ .gla .plate { background: linear-gradient(to bottom, #b8ab6e, #766a3a 18%, #3c3519); border-top-color: #ebe2b4; border-left-color: #cabe86; }++ /* a well sunk two pixels, dark along the top and left and lit along the bottom and right */+ .well { margin: -2px 0 0 -2px; border: 2px solid #06090b; border-bottom-color: #b4bec8; border-right-color: #b4bec8;+ background-color: #3a414a; }+ .china .well { border-bottom-color: #d98a72; border-right-color: #d98a72; background-color: #45190f; }+ .gla .well { border-bottom-color: #cbbf82; border-right-color: #cbbf82; background-color: #423a1c; }++ .title { text-align: left; font-size: 10px; font-weight: bold; color: #f2cf4a; }++ /* the experience bar: twenty rungs in a groove, gold from the left up to the way to the next rank */+ .groove { margin: -3px 0 0 -3px; border: 2px solid #06090b; border-bottom-color: #b4bec8; border-right-color: #b4bec8;+ background-color: #020405; }+ .china .groove { border-bottom-color: #d98a72; border-right-color: #d98a72; }+ .gla .groove { border-bottom-color: #cbbf82; border-right-color: #cbbf82; }+ .groove .lip { position: absolute; left: 0; top: 0; right: 0; bottom: 0; border: 1px solid #000000; }+ .rung { position: absolute; top: 1px; bottom: 1px; }+ .rung .seg { position: absolute; left: 0; right: 1px; top: 0; bottom: 0; background-color: #15130c; }+ .rung.lit .seg { background: linear-gradient(to bottom, #f6d860, #8a6a14); }++ /* the promotions left to spend: a gold figure in a small dark window */+ .points { margin: -2px 0 0 -2px; border: 2px solid #06090b; border-bottom-color: #b4bec8; border-right-color: #b4bec8;+ background-color: #020405; text-align: center; font-size: 11px; font-weight: bold; color: #f2cf4a; }+ .china .points { border-bottom-color: #d98a72; border-right-color: #d98a72; }+ .gla .points { border-bottom-color: #cbbf82; border-right-color: #cbbf82; }++ /* a row's heading, over a lit rule the width of the well */+ .heading { padding-left: 4px; font-size: 8px; font-weight: bold; color: #c9d2d9; text-align: left; line-height: 11px; }+ .heading .rule { position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background-color: #5a626c; }+ .china .heading .rule { background-color: #7a3120; }+ .gla .heading .rule { background-color: #766a3a; }++ /* the grid, as the command bar's: every place a dark cell exactly a button's size, steel between+ them, an empty place a hole with its bevel. A promotion's cell carries a rim a pixel outside+ the button that says where it stands - gold once bought, light steel while it can be bought */+ .cell { background-color: #020405; }+ .cell .bevel { position: absolute; left: 0; top: 0; right: 0; bottom: 0; border: 1px solid #06090b;+ border-bottom-color: #9aa4ae; border-right-color: #9aa4ae; }+ .china .cell .bevel { border-bottom-color: #d98a72; border-right-color: #d98a72; }+ .gla .cell .bevel { border-bottom-color: #cbbf82; border-right-color: #cbbf82; }+ .cell .rim { display: none; position: absolute; left: -1px; top: -1px; right: -1px; bottom: -1px; border: 1px solid #e8c24a; }+ .cell.owned .rim { display: block; }+ .cell.ready .rim { display: block; border-color: #eef3f7; }++ /* the close button: a key sunk in the steel, lit steel with a gold rim under the pointer, pressed in+ while held */+ .close { border: 1px solid #06090b; border-bottom-color: #9aa4ae; border-right-color: #9aa4ae; background-color: rgba(4, 8, 10, 0.9);+ text-align: center; font-size: 8px; font-weight: bold; color: #e8eef2; }+ .close.hilite { background: linear-gradient(to bottom, #b3bbc4, #5a626c); border-color: #e8d27a; color: #ffffff; }+ .china .close.hilite { background: linear-gradient(to bottom, #d58a70, #7a3120); }+ .gla .close.hilite { background: linear-gradient(to bottom, #cabe86, #766a3a); }+ .held .close.hilite, .close.pushed { background: linear-gradient(to bottom, #151a1f, #3a414a); border-color: #e8d27a; }+ .close .label { position: absolute; left: 0; right: 0; top: 50%; margin-top: -6px; line-height: 12px; }+</style>+</head>+<body>+<div class="{{side}} {{held}}">+ <div class="piece plate" style="left: {{panel.x}}px; top: {{panel.y}}px; width: {{panel.w}}px; height: {{panel.h}}px"></div>+ <div class="piece well" style="left: {{well.x}}px; top: {{well.y}}px; width: {{well.w}}px; height: {{well.h}}px"></div>++ <div class="piece title {{StaticTextTitle.shown}}" style="left: {{StaticTextTitle.x}}px; top: {{StaticTextTitle.y}}px; width: {{StaticTextTitle.w}}px; height: {{StaticTextTitle.h}}px; line-height: {{StaticTextTitle.h}}px">{{title}}</div>+ <div class="piece groove {{ProgressBarExperience.shown}}" style="left: {{ProgressBarExperience.x}}px; top: {{ProgressBarExperience.y}}px; width: {{ProgressBarExperience.w}}px; height: {{ProgressBarExperience.h}}px">+ <div class="rung {{lit}}" data-each="exprungs" style="left: {{x}}px; width: {{w}}px"><div class="seg"></div></div>+ <div class="lip"></div>+ </div>+ <div class="piece points {{StaticTextRankPointsAvailable.shown}}" style="left: {{StaticTextRankPointsAvailable.x}}px; top: {{StaticTextRankPointsAvailable.y}}px; width: {{StaticTextRankPointsAvailable.w}}px; height: {{StaticTextRankPointsAvailable.h}}px; line-height: {{StaticTextRankPointsAvailable.h}}px">{{points}}</div>++ <div class="piece heading" data-each="headings" style="left: {{heading.x}}px; top: {{heading.y}}px; width: {{heading.w}}px; height: {{heading.h}}px">{{label}}<div class="rule"></div></div>+ <div class="piece cell {{state}}" data-each="cells" style="left: {{cell.x}}px; top: {{cell.y}}px; width: {{cell.w}}px; height: {{cell.h}}px"><div class="bevel"></div><div class="rim"></div></div>++ <div class="piece close {{ButtonExit.shown}} {{ButtonExit.state}}" style="left: {{ButtonExit.x}}px; top: {{ButtonExit.y}}px; width: {{ButtonExit.w}}px; height: {{ButtonExit.h}}px"><div class="label">{{text:GUI:CloseExpScreen}}</div></div>+</div>+</body>+</html>diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex 2c7872629..3c56ee085 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -407,6 +407,9 @@ public: // ********************************************************************/** A click that reached the world, on one of that page's own buttons: TRUE when it was one, and* when `act` is set the button it names is pressed. */Bool handleControlBarPageClick( const ICoord2D *mouse, Bool act );+ /** The general's promotion screen, Window/Html/Promotion.html, drawn as `parent`'s picture: the+ * screen's windows keep their clicks and the promotions' own cameos paint over it. */+ void drawPromotionPage( GameWindow *parent );void drawScoreboard( void ); ///< that scoreboard, over everything/** Window/Html/Tooltip.html is there to draw with, in a match. */Bool isTooltipPageReady( void );@@ -1222,6 +1225,9 @@ protected:Bool m_tooltipPageLoaded;std::string m_tooltipPage;ICoord2D m_tooltipSize; ///< the box as last laid out, in screen pixels, to place the next one by+ HtmlOverlay * m_promotionOverlay;+ Bool m_promotionPageLoaded;+ std::string m_promotionPage;Bool m_signalsWereShown; ///< the smoke signal column was up last frameUnsignedInt m_signalsRiseStartMs; ///< when it last came up, the start of its buttons' risediff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex f165bc199..e55edc5d4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -1203,6 +1203,8 @@ InGameUI::InGameUI()m_scoreboardPageLoaded = FALSE;m_controlBarOverlay = NULL;m_controlBarPageLoaded = FALSE;+ m_promotionOverlay = NULL;+ m_promotionPageLoaded = FALSE;m_controlBarPageShown = FALSE;m_tooltipOverlay = NULL;m_tooltipPageLoaded = FALSE;@@ -1331,6 +1333,8 @@ InGameUI::~InGameUI()m_scoreboardOverlay = NULL;delete m_controlBarOverlay;m_controlBarOverlay = NULL;+ delete m_promotionOverlay;+ m_promotionOverlay = NULL;delete m_tooltipOverlay;m_tooltipOverlay = NULL;}@@ -3882,6 +3886,7 @@ void InGameUI::reset( void )m_scoreboardPageLoaded = FALSE;m_controlBarPageLoaded = FALSE;m_tooltipPageLoaded = FALSE;+ m_promotionPageLoaded = FALSE;m_signalsWereShown = FALSE;m_spectatorPageLoaded = FALSE;m_spectatorFlipped.clear();@@ -10172,6 +10177,8 @@ void InGameUI::drawScoreboard( void )}static const char *const CONTROL_BAR_PAGE = "Window\\Html\\ControlBar.html";+static const char *const PROMOTION_PAGE = "Window\\Html\\Promotion.html";+static void standDownPromotionScreen( void );/** The command bar's windows the page is told the place of, by their name in ControlBar.wnd. */static const char *const CONTROL_BAR_WINDOWS[] =@@ -10251,6 +10258,17 @@ static void putPowerBar( HtmlValues &values, std::vector< HtmlValues > &cells )values[ "power.state" ] = "green";}+/** How far `player` is from this rank to the next, 0 to 100. A script can disable a level, which+ * leaves its points required at -1: a rank with no way on counts as full, where the bar's own+ * drawing divided by it. */+static Int experiencePercent( const Player *player )+{+ enum { FULL = 100 };+ const Int span = player->getSkillPointsLevelUp() - player->getSkillPointsLevelDown();+ const Int progress = span > 0 ? ( player->getSkillPoints() - player->getSkillPointsLevelDown() ) * FULL / span : FULL;+ return min( (Int)FULL, max( 0, progress ) );+}+//-------------------------------------------------------------------------------------------------/** The general's experience as the page draws it, in the groove {{expframe.x}} ... puts down the* right panel: `cells` from the bottom up, each {{lit}} "lit" up to the way from this rank to the@@ -10275,11 +10293,7 @@ static void putExperienceBar( HtmlValues &values, std::vector< HtmlValues > &celif( player == NULL )return;- // a script can disable a level, which leaves its points required at -1: a rank with no way on- // counts as full, where the bar's own drawing divided by it- const Int span = player->getSkillPointsLevelUp() - player->getSkillPointsLevelDown();- const Int progress = span > 0 ? ( player->getSkillPoints() - player->getSkillPointsLevelDown() ) * FULL / span : FULL;- const Int lit = min( (Int)EXPERIENCE_CELLS, max( 0, progress ) * EXPERIENCE_CELLS / FULL );+ const Int lit = experiencePercent( player ) * EXPERIENCE_CELLS / FULL;const Int column = height - 2 * FRAME_LIP;for( Int cell = 0; cell < EXPERIENCE_CELLS && column > 0; cell++ ){@@ -10895,6 +10909,15 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, Iwindow->winHide( TRUE );}+ // the promotion screen is its own layout, drawn over the bar; its page goes with this one+ if( !m_promotionPageLoaded )+ {+ m_promotionPageLoaded = TRUE;+ readHtmlPage( PROMOTION_PAGE, m_promotionPage );+ }+ if( !m_promotionPage.empty() )+ standDownPromotionScreen();+m_controlBarOverlay->setPage( HtmlTemplate_expand( m_controlBarPage, values, lists, lookupGameText ) );m_controlBarOverlay->hover( TheMouse->getMouseStatus()->pos );m_controlBarOverlay->draw();@@ -10941,6 +10964,281 @@ Bool InGameUI::handleControlBarPageClick( const ICoord2D *mouse, Bool act )return TRUE;}+static const char *const PROMOTION_PREFIX = "GeneralsExpPoints.wnd:";+static const char *const PROMOTION_BUTTON_PREFIX = "ButtonRank";++/** The promotion screen's three rows, each a run of ButtonRankNNumberM buttons under a heading. */+static const struct PromotionRow+{+ const char *buttons; ///< the buttons' name, before their number+ Int count;+ Int depth; ///< buttons to a column: the layout numbers the middle row's down each column+ const char *heading; ///< the string table label over the row+} PROMOTION_ROWS[] =+{+ { "ButtonRank1Number", 4, 1, "GUI:Rank1Required" },+ { "ButtonRank3Number", 15, 3, "GUI:Rank3Required" },+ { "ButtonRank8Number", 4, 1, "GUI:Rank8Required" }+};++/** The compact screen's measures, 800x600 pixels; a cell is a command button's size. */+enum+{+ PROMOTION_COLUMNS = 5, ///< the widest row, the middle one+ PROMOTION_MARGIN = 6, ///< the plate round the well, and the well's gap under the bar+ PROMOTION_INSET = 4, ///< the well round the cells+ PROMOTION_CELL_GAP = 2,+ PROMOTION_TITLE = 14, ///< the rank's name's line, the points beside it+ PROMOTION_BAR = 7, ///< the experience bar under it+ PROMOTION_BAR_GAP = 3,+ PROMOTION_HEADING = 14, ///< a row's heading over its first button+ PROMOTION_SECTION = 8 ///< between one row's last cells and the next row's heading+};++/** One place in the screen's grids, screen pixels, and the promotion's button standing in it: NULL+ * for a place no promotion fills, which shows as a hole, and the close button in its own place. */+struct PromotionPlace+{+ IRegion2D rect;+ GameWindow *button;+};++/** Where layoutPromotionScreen put everything the page draws round the windows. */+struct PromotionLayout+{+ std::vector< PromotionPlace > places;+ std::vector< IRegion2D > headings; ///< one over each row, in PROMOTION_ROWS' order+ IRegion2D well;+};++static GameWindow *promotionWindow( const std::string &name )+{+ return TheWindowManager->winGetWindowFromId( NULL, NAMEKEY( ( PROMOTION_PREFIX + name ).c_str() ) );+}++/** Puts one of the screen's windows at `x`, `y` in its parent, `width` by `height`, screen pixels. */+static void placePromotionWindow( const std::string &name, Int x, Int y, Int width, Int height )+{+ GameWindow *window = promotionWindow( name );+ window->winSetPosition( x, y );+ window->winSetSize( width, height );+}++//-------------------------------------------------------------------------------------------------+/** The promotion screen laid out compact, every frame it draws, over the layout's own places: each+ * row a grid five places wide in command button cells with a hair of steel between them, the way+ * the command bar's grid is, a heading over it and a gap before the next; the rank's name and the+ * points on one line with the bar under them, and the close button in the last row's fifth place,+ * which no side fills. Centred at the top of the screen where the layout hung it. `layout` gets+ * every place, filled or not, the headings and the well, in screen pixels. */+//-------------------------------------------------------------------------------------------------+static void layoutPromotionScreen( GameWindow *parent, PromotionLayout &layout )+{+ const Real scale = ControlBarUniformScale();+ struct Page { static Int px( Int pagePixels, Real scale ) { return REAL_TO_INT( pagePixels * scale ); } };+ const IRegion2D button = commandButtonRect( 1 );+ const Int cellWidth = button.hi.x - button.lo.x;+ const Int cellHeight = button.hi.y - button.lo.y;+ const Int gap = Page::px( PROMOTION_CELL_GAP, scale );+ const Int margin = Page::px( PROMOTION_MARGIN, scale );+ const Int inset = Page::px( PROMOTION_INSET, scale );+ const Int heading = Page::px( PROMOTION_HEADING, scale );++ const Int gridWidth = PROMOTION_COLUMNS * cellWidth + ( PROMOTION_COLUMNS - 1 ) * gap;+ const Int width = gridWidth + 2 * ( margin + inset );+ const Int titleHeight = Page::px( PROMOTION_TITLE, scale );+ const Int pointsWidth = Page::px( PROMOTION_TITLE + PROMOTION_BAR, scale );+ placePromotionWindow( "StaticTextTitle", margin, margin, width - 2 * margin - pointsWidth, titleHeight );+ placePromotionWindow( "StaticTextRankPointsAvailable", width - margin - pointsWidth, margin, pointsWidth,+ titleHeight + Page::px( PROMOTION_BAR + PROMOTION_BAR_GAP, scale ) );+ placePromotionWindow( "ProgressBarExperience", margin, margin + titleHeight + Page::px( PROMOTION_BAR_GAP, scale ),+ width - 3 * margin - pointsWidth, Page::px( PROMOTION_BAR, scale ) );++ // the parent goes first, so the places can be handed out in screen pixels+ Int parentX = 0, parentY = 0;+ parent->winGetPosition( &parentX, &parentY );+ parentX = ( TheDisplay->getWidth() - width ) / 2;+ parent->winSetPosition( parentX, parentY );++ // the well stands a margin under the bar and the points, and the cells an inset inside it+ const Int wellTop = margin + titleHeight + Page::px( PROMOTION_BAR_GAP + PROMOTION_BAR, scale ) + margin;+ Int y = wellTop + inset;+ const Int left = margin + inset;+ layout.places.clear();+ layout.headings.clear();+ for( Int row = 0; row < (Int)ARRAY_SIZE( PROMOTION_ROWS ); row++ )+ {+ if( row > 0 )+ y += Page::px( PROMOTION_SECTION, scale );+ IRegion2D title;+ title.lo.x = parentX + left;+ title.hi.x = title.lo.x + gridWidth;+ title.lo.y = parentY + y;+ title.hi.y = title.lo.y + heading - gap;+ layout.headings.push_back( title );+ y += heading;++ const Int depth = PROMOTION_ROWS[ row ].depth;+ const Bool lastRow = row == (Int)ARRAY_SIZE( PROMOTION_ROWS ) - 1;+ for( Int column = 0; column < PROMOTION_COLUMNS; column++ )+ {+ for( Int line = 0; line < depth; line++ )+ {+ const Int x = left + column * ( cellWidth + gap );+ const Int top = y + line * ( cellHeight + gap );+ const Int number = column * depth + line;+ PromotionPlace place;+ place.rect.lo.x = parentX + x;+ place.rect.lo.y = parentY + top;+ place.rect.hi.x = place.rect.lo.x + cellWidth;+ place.rect.hi.y = place.rect.lo.y + cellHeight;+ place.button = NULL;+ if( lastRow && column == PROMOTION_COLUMNS - 1 )+ {+ placePromotionWindow( "ButtonExit", x, top, cellWidth, cellHeight );+ place.button = promotionWindow( "ButtonExit" );+ }+ else if( number < PROMOTION_ROWS[ row ].count )+ {+ const std::string name = PROMOTION_ROWS[ row ].buttons + std::to_string( number );+ placePromotionWindow( name, x, top, cellWidth, cellHeight );+ place.button = promotionWindow( name );+ }+ layout.places.push_back( place );+ }+ }+ y += depth * ( cellHeight + gap ) - gap;+ }++ const Int height = y + inset + margin;+ parent->winSetSize( width, height );+ layout.well.lo.x = parentX + margin;+ layout.well.hi.x = parentX + width - margin;+ layout.well.lo.y = parentY + wellTop;+ layout.well.hi.y = parentY + height - margin;+}++/** The screen's picture, drawn by the page while it is there. */+static void drawPromotionScreen( GameWindow *window, WinInstanceData *instData )+{+ TheInGameUI->drawPromotionPage( window );+}++/** The promotion screen hands its look to the page: the parent draws the page, and every child but+ * the promotions' own buttons draws nothing - the side's painting, the titles, the bar and its frame+ * and the close button are the page's. They all keep their clicks. */+static void standDownPromotionScreen( void )+{+ GameWindow *parent = promotionWindow( "GenExpParent" );+ if( parent == NULL )+ return;++ parent->winSetDrawFunc( drawPromotionScreen );+ const std::string buttonName = std::string( PROMOTION_PREFIX ) + PROMOTION_BUTTON_PREFIX;+ for( GameWindow *child = parent->winGetChild(); child; child = child->winGetNext() )+ {+ if( !child->winGetInstanceData()->m_decoratedNameString.startsWith( buttonName.c_str() ) )+ child->winSetDrawFunc( drawNothing );+ }+}++/** "owned", "ready" or "locked" for one promotion's button, by the state the bar left it in: enabled+ * when it can be bought, disabled in colour when it was, disabled in grey otherwise. */+static const char *promotionState( GameWindow *button )+{+ if( BitTest( button->winGetStatus(), WIN_STATUS_ENABLED ) )+ return "ready";+ return BitTest( button->winGetStatus(), WIN_STATUS_ALWAYS_COLOR ) ? "owned" : "locked";+}++//-------------------------------------------------------------------------------------------------+/** The general's promotion screen from Window/Html/Promotion.html, in the place of the side's+ * painting. Everything is placed from the screen's own windows, so it goes where the layout and+ * the scheme put them; the promotions are the bar's buttons and paint over it. */+//-------------------------------------------------------------------------------------------------+void InGameUI::drawPromotionPage( GameWindow *parent )+{+ enum+ {+ EXPERIENCE_RUNGS = 20,+ FULL = 100+ };++ if( m_promotionOverlay == NULL )+ m_promotionOverlay = new HtmlOverlay( m_superweaponNormalFont );++ // laid out here, the parent's own draw, so every child is in its place before it draws+ PromotionLayout layout;+ layoutPromotionScreen( parent, layout );++ HtmlValues values;+ HtmlLists lists;+ values[ "side" ] = spectatorSide();+ values[ "held" ] = TheMouse->getMouseStatus()->leftState != MBS_Up ? "held" : "";++ IRegion2D panel;+ controlBarWindowRect( parent, panel );+ putPageRect( values, "panel", panel, TRUE );++ static const char *const PLACED[] = { "StaticTextTitle", "ProgressBarExperience", "StaticTextRankPointsAvailable", "ButtonExit" };+ for( Int each = 0; each < (Int)ARRAY_SIZE( PLACED ); each++ )+ {+ GameWindow *window = promotionWindow( PLACED[ each ] );+ IRegion2D rect;+ putPageRect( values, PLACED[ each ], rect, controlBarWindowRect( window, rect ) );+ values[ std::string( PLACED[ each ] ) + ".state" ] = controlBarWindowState( window );+ }+ values[ "title" ] = WideCharStringToMultiByte( GadgetStaticTextGetText( promotionWindow( "StaticTextTitle" ) ).str() );+ values[ "points" ] = WideCharStringToMultiByte( GadgetStaticTextGetText( promotionWindow( "StaticTextRankPointsAvailable" ) ).str() );++ // the bar goes by the player the screen was opened for, the watched one while watching+ const Player *player = TheControlBar->isObserverControlBarOn() ? TheControlBar->getObserverLookAtPlayer()+ : ThePlayerList->getLocalPlayer();+ // its rungs cut from the bar's width in page pixels so they add up to it exactly, as the power+ // bar's cells are+ const Int lit = player ? experiencePercent( player ) * EXPERIENCE_RUNGS / FULL : 0;+ const Int barWidth = atoi( values[ "ProgressBarExperience.w" ].c_str() );+ std::vector< HtmlValues > &rungs = lists[ "exprungs" ];+ for( Int rung = 0; rung < EXPERIENCE_RUNGS && barWidth > 0; rung++ )+ {+ const Int left = rung * barWidth / EXPERIENCE_RUNGS;+ HtmlValues entry;+ entry[ "lit" ] = rung < lit ? "lit" : "";+ entry[ "x" ] = std::to_string( left );+ entry[ "w" ] = std::to_string( ( rung + 1 ) * barWidth / EXPERIENCE_RUNGS - left );+ rungs.push_back( entry );+ }++ // the promotions stand in a well of steel, a dark cell for every place of every row, filled or+ // not, as the command grid's are, and each row's heading over it+ putPageRect( values, "well", layout.well, TRUE );+ GameWindow *exit = promotionWindow( "ButtonExit" );+ std::vector< HtmlValues > &cells = lists[ "cells" ];+ for( size_t each = 0; each < layout.places.size(); each++ )+ {+ const PromotionPlace &place = layout.places[ each ];+ if( place.button == exit )+ continue;++ HtmlValues entry;+ putPageRect( entry, "cell", place.rect, TRUE );+ entry[ "state" ] = place.button && !place.button->winIsHidden() ? promotionState( place.button ) : "empty";+ cells.push_back( entry );+ }+ std::vector< HtmlValues > &headings = lists[ "headings" ];+ for( size_t row = 0; row < layout.headings.size(); row++ )+ {+ HtmlValues entry;+ putPageRect( entry, "heading", layout.headings[ row ], TRUE );+ entry[ "label" ] = WideCharStringToMultiByte( TheGameText->fetch( PROMOTION_ROWS[ row ].heading ).str() );+ headings.push_back( entry );+ }++ m_promotionOverlay->setPage( HtmlTemplate_expand( m_promotionPage, values, lists, lookupGameText ) );+ m_promotionOverlay->hover( TheMouse->getMouseStatus()->pos );+ m_promotionOverlay->draw();+}+//-------------------------------------------------------------------------------------------------/** Lay out and draw one run of cells, its left edge at left and the first cameo's top edge at* bottomY.