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(gameengine): dress the strips in the bar's own metal and fold repeats into xN
Olcay Seygana1e0fea836ca
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 70fef0bab..cd3a0873d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -282,7 +282,7 @@ found and fixed — EA's own, not port damage.**- A superweapon's wait is written in plain seconds - 200, not 3:20 - so it compares with every other countdown on the screen at a glance. Once it is charged the number goes away entirely and the picture itself breathes in your colour, which is the one thing you want to catch out of the corner of your eye.- The countdown inside a strip picture lost its black backing plate. On a picture that small the plate was most of the picture; the number now sits straight on the sweeping clock.- Every picture in the row stands in a tray - the same tray your general's powers stand in down in the corner, your own side's copy of it, so the American, Chinese and GLA strips each carry their own metal. The tray is turned back to front, because that bar grows out of the right hand corner and the strip grows out of the left, so its heavy rail leads the row instead of standing between every pair of pictures. It is never stretched to fit, and the trays close up behind each other by exactly what that bar closes its own up by, so the row reads as one run of metal rather than a line of loose boxes. The strip is flush against the left edge, and a black rectangle laid over the battlefield is gone.-- A slot in it is a slot of that bar to the pixel, at every resolution - the size is measured off the bar itself rather than guessed - so the queue is read at a glance instead of squinted at: these were postage stamps a third of that size. Six of them is the most the row shows, and everything past them is counted at the end of it.+- A slot in it is a slot of that bar to the pixel, at every resolution - the size is measured off the bar itself rather than guessed - so the queue is read at a glance instead of squinted at: these were postage stamps a third of that size. Six of them is the most the row shows, and everything past them is counted at the end of it. Ten tanks ordered back to back are one picture with an x10 in its corner rather than ten copies of the same tank eating the row, so what is left of the row still says what else is coming.- Above the queue is a row of what is actually going up on the ground: every building your workers are raising, each with its own sweep and the seconds it still needs, soonest first. Click one and the camera goes to the site - a half-finished building under fire on the far side of the map is one click away instead of a hunt across the minimap. Nothing in that row can be cancelled by mistake: a building already standing is sold or lost, never cancelled, so Ctrl over it does nothing.- The superweapon strip in the top right stands in the same metal, the right way round this time: it is anchored to the right hand edge and grows leftwards, which is the way that bar in the corner grows, so its rail closes the row against the edge of the screen. The black rectangle behind those pictures is gone with it, and the countdowns are the size of the ones down in the corner rather than half of it.- A game opens with nothing selected, so your first click is not a rally point.@@ -297,7 +297,8 @@ found and fixed — EA's own, not port damage.**- Aircraft always show how many attack runs they have left.- The corner readout separates game time from real time, and sim rate from fps.- Pausing stops both clocks.-- Watching a match, the strip becomes every player's queue at once: one row each, bordered in that player's colour, showing the five that land soonest and a count of the rest.+- Watching a match, the strip becomes every player's queue at once: one row each, bordered in that player's colour, showing the three that land soonest and a count of the rest. Buildings going up on the ground are in those rows too, so a player answering an attack with three war factories is visible while the concrete is still wet, and eight players fit on one screen because a row is three pictures wide.+- Every row and every countdown stands in real metal, cut from the same tray the general's powers sit in down in the corner - the side your command bar is showing. Watching a match there is no bar of your own, so both strips used to fall back to a flat black box for the whole match; now they wear the metal of the player you are watching, and follow it when you switch seats.- Watching, the bars over the buildings are everyone's too - what each factory is turning out, and how long the superweapons have left. An observer used to see none of it.- Watching, you see the fog the player you are watching sees. The game only ever remembered one player's fog, so switching seats handed you the first player's idea of the map.- An ally, and anyone watching, now sees a stealthed unit's muzzle flash, its promotion and the cash it earns - if they can see the unit at all. Those three asked 'is it mine' instead of 'can I see it', so allies and observers got nothing.diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.hindex 8141be3bd..88d5bf8db 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h@@ -828,16 +828,24 @@ public:Color getUpgradeBorderColor( void ){return m_commandButtonBorderUpgradeColor;}void updateBorderColor( Color color) {m_commandBarBorderColor = color; }- /** The tray one of the general's power shortcuts stands in, down in the corner - this side's own- * copy of it, taken off the bar itself rather than named, so a mod's bar brings its own. */+ /** The tray one of the general's power shortcuts stands in, down in the corner - the tray of+ * whichever side this bar is showing, taken off the bar itself rather than named, so a mod's+ * bar brings its own. Watching a match the bar has no side of its own to read, and the tray+ * comes out of the layout of the player the bar is looking at instead. */const Image *getSpecialPowerTrayImage( void );/** That tray at the size the bar draws it, the hole in it the cameo fills, and the step a row of- * them runs at - measured off the loaded bar, so a borrowed tray is the size of the powers'- * own at any resolution. Any out-parameter may be NULL; FALSE when there is no bar. */+ * them runs at - measured off the same layout the tray came out of, so it is the size of the+ * powers' own at any resolution. Any out-parameter may be NULL; FALSE when there is no bar+ * and no layout to borrow one from. */Bool getSpecialPowerTrayLayout( ICoord2D *traySize, ICoord2D *cameoSize,ICoord2D *cameoOffset, Int *columnStep );+ /** The tray geometry from one slot's size. Public because it is the single home of the artwork's+ * proportions: the bar itself, anything borrowing the look, and the tests all read it here. */+ static Bool trayLayoutFromSlot( Int slotWidth, Int slotHeight, ICoord2D *traySize,+ ICoord2D *cameoSize, ICoord2D *cameoOffset, Int *columnStep );+/// set the command data into the buttonvoid setControlCommand( GameWindow *button, const CommandButton *commandButton );@@ -1037,6 +1045,27 @@ protected:Int m_specialPowerShortcutRow; ///< row a first key press picked, -1 when none is pendingUnsignedInt m_specialPowerShortcutRowMs; ///< millisecond that row was picked on, for CHORD_TIMEOUT_MS+ /** A tray taken out of a side's shortcut layout without standing that side's bar up: what the+ * HUD needs while watching somebody else play. The layout is created, measured and destroyed+ * on the spot - the image itself belongs to the mapped image collection and outlives it - and+ * the answer is kept, since a spectator's bar asks for the same side every frame. */+ struct BorrowedTray+ {+ AsciiString layout; ///< the .wnd it came out of, and the key this is found by+ const Image *image; ///< that layout's slot background, NULL when it has none+ ICoord2D size; ///< the size the loader gave that slot+ };+ enum { MAX_BORROWED_TRAYS = 8 };+ BorrowedTray m_borrowedTrays[ MAX_BORROWED_TRAYS ];+ Int m_borrowedTrayCount;+ const BorrowedTray *borrowTray( const PlayerTemplate *pt );++ /// whose tray this bar shows when it has no bar of its own: the side the bar itself is wearing+ const PlayerTemplate *specialPowerTraySide( void );++ /// a template of this side that ships a general's power bar, so its tray can be read off it+ const PlayerTemplate *templateForSide( AsciiString side );+Int m_purchaseScienceColumn; ///< promotion screen column a first key press marked, -1 when noneUnsignedInt m_purchaseScienceColumnMs; ///< millisecond it was marked on, for CHORD_TIMEOUT_MSdiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBarScheme.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBarScheme.hindex 2712cbdf7..6a5d57554 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBarScheme.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBarScheme.h@@ -260,7 +260,20 @@ public:void setControlBarSchemeByPlayer(Player *p); ///< Based off the playerTemplate, pick the right scheme for the control barvoid setControlBarSchemeByPlayerTemplate( const PlayerTemplate *pt, Bool useSmall = FALSE);void setControlBarScheme(AsciiString schemeName); ///< SchemeName must be a valid INI entry-++ /** The side whose bar is on screen right now - the artwork actually being drawn, not whoever the+ * seat belongs to. Empty when no scheme is up; "Observer" while watching from no seat at all,+ * and the side with "Small" on the end for the shell's small bar. */+ AsciiString getCurrentSide( void ) const+ { return m_currentScheme ? m_currentScheme->m_side : AsciiString::TheEmptyString; }++ /** The side another scheme is dressed in, when the one on screen has no artwork of its own. The+ * observer bar is a side called "Observer" and every plate on it is American - EA built it out+ * of that side's art - so the scheme wearing the same right hand plate names the side the bar+ * is really showing. Empty when nothing else shares it. */+ AsciiString getCurrentArtTwinSide( void ) const;++// parse Functions for the INI fileconst FieldParse *getFieldParse() const { return m_controlBarSchemeFieldParseTable; } ///< returns the parsing fieldsstatic const FieldParse m_controlBarSchemeFieldParseTable[]; ///< the parse tablediff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex cea057faf..b809caf54 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -587,7 +587,9 @@ public: // ********************************************************************// producer's queue it is, and where it was drawn this frame.//enum { PRODUCTION_STRIP_ROW_MAX = 6 }; ///< cameos one row will draw; the rest become a "+N"- enum { PRODUCTION_STRIP_WATCH_MAX = 5 }; ///< and while watching, where eight rows share the screen+ enum { PRODUCTION_STRIP_WATCH_MAX = 3 }; ///< and while watching, where eight rows share the screen+ /// and a row is a whole player: three cameos and a "+N",+ /// since a run of the same unit is one of them nowenum { PRODUCTION_STRIP_ROWS = 8 }; ///< playing: the global row and the selected producer's row./// watching: one row per player, so eight of them@@ -636,11 +638,17 @@ public: // ********************************************************************Int id; ///< a unit's ProductionID, or an upgrade's name key/// (kept as an Int so this header stays clear of GameLogic)Bool isUpgrade; ///< which of those two the id means+ Int typeKey; ///< what the item is rather than which order it is - a unit's template+ /// id, an upgrade's name key - so a run of the same thing queued+ /// back to back becomes one cameoBool isStructure; ///< the slot is a building going up on the map, not an item in/// a queue: 'producer' is that building and there is no idBool leads; ///< it belongs to the building you have selected, so it stands at the/// head of the row whatever the rest of the base is finishingInt remaining; ///< logic frames until this item pops, waiting time ahead of it included+ Int quantity; ///< how many of the same thing this cameo stands for: a queue of five+ /// Red Guards is one cameo wearing an "x5", not five cameos of+ /// the same picture pushing everything else off the rowICoord2D pos; ///< top left corner of the cameo on screen};@@ -964,9 +972,10 @@ protected:void updateIncomeEstimate( Player *player ); ///< income per minute, shown beside the moneyvoid drawProductionStrip( void ); ///< the production queue rows above the control barvoid drawProductionStripRow( Int row, Int y ); ///< one of those rows, at that top edge- const Image *productionStripTray( void ); ///< the power bar's tray, mirrored, kept until that bar changes side+ const Image *productionStripTray( void ); ///< the bar's tray, mirrored, kept until the bar changes sidevoid stripTrayMetrics( ICoord2D *tray, ICoord2D *cameo, ICoord2D *hole, Int *step ); ///< that tray's size, its cameo hole, and the column step- void drawStripSeconds( Int x, Int y, Int w, Int h, Int seconds, Bool plainSeconds = FALSE ); ///< countdown written inside a cameo+ void drawStripSeconds( Int which, Int x, Int y, Int w, Int h, Int seconds, Bool plainSeconds = FALSE ); ///< countdown written inside a cameo+ void drawStripQuantity( Int which, Int x, Int y, Int w, Int quantity ); ///< the "xN" in a cameo's top right cornervoid addSuperweaponIcon( const Image *image, Int seconds, Int percent, Bool ready, Color color );void drawSuperweaponStrip( void ); ///< those icons, top right, soonest at the right hand end@@ -1013,10 +1022,31 @@ protected:Bool m_productionStripWatching; ///< the rows are every player's, not oursInt m_productionStripCameoW; ///< cameo size this frame, in the control bar's aspectInt m_productionStripCameoH;- Image * m_productionStripTray; ///< our mirrored copy of the power bar's tray++ //+ // The strip's cameos face the other way from the power bar's, so the tray behind them is a+ // mirrored copy of it. The whole strip wears one side's metal - the side the bar underneath it+ // is showing - so one is kept at a time and remade when the bar changes side, which watching a+ // match it does every time the observer picks a different player out of the list.+ //+ Image * m_productionStripTray; ///< our mirrored copy of the bar's trayconst Image * m_productionStripTraySource; ///< the tray it was made from, so a side change remakes it- DisplayString * m_productionStripOverflow; ///< the "+N" that stands for the rest of a row- DisplayString * m_stripSecondsString; ///< the countdown written inside a cameo, either strip's+ //+ // One kept string per cameo, not one string walked across all of them. A DisplayString+ // rebuilds its sentence whenever the text it holds changes, and a rebuild is a fresh font+ // surface, a fresh texture and a surface copy - so a single shared string paid that once per+ // cameo per frame, and watching a match the strips cost more to draw than the terrain under+ // them. Kept per cameo, a countdown rebuilds when its own second changes: once a second.+ //+ enum { STRIP_SECONDS_STRINGS = PRODUCTION_STRIP_ROWS * PRODUCTION_STRIP_ROW_MAX+ + SUPERWEAPON_STRIP_MAX };+ enum { STRIP_OVERFLOW_STRINGS = PRODUCTION_STRIP_ROWS + 1 }; ///< one per production row, plus the superweapon strip's++ enum { STRIP_QUANTITY_STRINGS = PRODUCTION_STRIP_ROWS * PRODUCTION_STRIP_ROW_MAX };++ DisplayString * m_productionStripOverflow[ STRIP_OVERFLOW_STRINGS ]; ///< the "+N" that stands for the rest of a row+ DisplayString * m_stripSecondsString[ STRIP_SECONDS_STRINGS ]; ///< the countdown written inside a cameo, either strip's+ DisplayString * m_stripQuantityString[ STRIP_QUANTITY_STRINGS ]; ///< the "xN" a run of the same item wears//// The superweapon strip: the same cameos the command bar fires them from, in the top rightdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 6c84af3bc..3bce628f9 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -1090,6 +1090,7 @@ ControlBar::ControlBar( void )m_specialPowerShortcutParent = NULL;m_specialPowerShortcutRow = -1;m_specialPowerShortcutRowMs = 0;+ m_borrowedTrayCount = 0;m_purchaseScienceColumn = -1;m_purchaseScienceColumnMs = 0;m_specialPowerLayout = NULL;@@ -1517,7 +1518,10 @@ void ControlBar::reset( void )m_isObserverCommandBar = FALSE; // reset us to use a normal command barm_observerLookAtPlayer = NULL;-++ // the next match has its own sides, and a mod switch reloads the artwork these point at+ m_borrowedTrayCount = 0;+if(m_buildToolTipLayout)m_buildToolTipLayout->hide(TRUE);m_showBuildToolTipLayout = FALSE;@@ -2661,36 +2665,196 @@ Bool ControlBar::clearSpecialPowerShortcutRow( void )//-------------------------------------------------------------------------------------------------/** The tray a general's power shortcut stands in: the background of one of that bar's slots, taken* off the slot itself. Each side ships its own bar and its own tray art, so reading it here is- * what keeps anything that borrows the look - the production strip does - on the right side's- * metal without naming a single image.+ * what keeps anything that borrows the look - both HUD strips do - on the same side's metal as+ * the bar underneath them, without naming a single image.*- * NULL until that bar exists, and it never exists for a side whose template has no shortcuts. */+ * Watching a match there is no such bar: FactionObserver ships neither a shortcut layout nor a+ * button count, so both strips used to fall back to a flat black plate for the whole match. The+ * side the observer bar is looking at answers for it instead - one side for the whole HUD, the+ * one the bar itself is showing. *///-------------------------------------------------------------------------------------------------const Image *ControlBar::getSpecialPowerTrayImage( void ){- if( m_specialPowerShortcutParent == NULL || m_specialPowerShortcutButtonParents[ 0 ] == NULL )- return NULL;+ if( m_specialPowerShortcutParent && m_specialPowerShortcutButtonParents[ 0 ] )+ return m_specialPowerShortcutButtonParents[ 0 ]->winGetEnabledImage( 0 );- return m_specialPowerShortcutButtonParents[ 0 ]->winGetEnabledImage( 0 );+ const BorrowedTray *borrowed = borrowTray( specialPowerTraySide() );+ return borrowed ? borrowed->image : NULL;} // end getSpecialPowerTrayImage+//-------------------------------------------------------------------------------------------------+/** Any template of this side that ships a general's power bar - the generals of one side share that+ * layout, so which one comes back does not matter, only that it carries the side's tray. The+ * shell's bar names its side with "Small" on the end; that is the same art at another size. */+//-------------------------------------------------------------------------------------------------+const PlayerTemplate *ControlBar::templateForSide( AsciiString side )+{+ if( side.isEmpty() || ThePlayerTemplateStore == NULL )+ return NULL;++ if( side.endsWithNoCase( "Small" ) )+ for( Int c = 0; c < 5; c++ )+ side.removeLastChar();++ for( Int t = 0; t < ThePlayerTemplateStore->getPlayerTemplateCount(); t++ )+ {+ const PlayerTemplate *pt = ThePlayerTemplateStore->getNthPlayerTemplate( t );+ if( pt && pt->getSide().compareNoCase( side ) == 0+ && !pt->getSpecialPowerShortcutWinName().isEmpty() )+ return pt;+ }++ return NULL;++} // end templateForSide++//-------------------------------------------------------------------------------------------------+/** Whose metal the HUD wears when this bar has none of its own. The answer is the bar on screen and+ * nothing else: the scheme manager knows which side's artwork it is drawing, so the strips wear+ * that side even while watching, where the seat at the keyboard has no side at all.+ *+ * The scheme names a side, not a general, and the generals of one side share a shortcut layout, so+ * any template of that side hands over the same tray. The observer bar's own side is "Observer",+ * which no template carries, but every plate on that bar is another side's - so the scheme sharing+ * its right hand plate names the side it is really wearing, and the strips follow the bar rather+ * than the seat. Only if even that finds nothing does whoever is being watched, and then the first+ * side still in the match, answer: a plate of plain black is worse than somebody else's metal, and+ * it was what the strips wore for whole matches. */+//-------------------------------------------------------------------------------------------------+const PlayerTemplate *ControlBar::specialPowerTraySide( void )+{+ if( m_controlBarSchemeManager )+ {+ const PlayerTemplate *own = templateForSide( m_controlBarSchemeManager->getCurrentSide() );+ if( own )+ return own;++ const PlayerTemplate *worn = templateForSide( m_controlBarSchemeManager->getCurrentArtTwinSide() );+ if( worn )+ return worn;+ }++ // the bar wears artwork no side owns; the seat it is showing is the next best answer+ if( m_observerLookAtPlayer && m_observerLookAtPlayer->getPlayerTemplate()+ && !m_observerLookAtPlayer->getPlayerTemplate()->getSpecialPowerShortcutWinName().isEmpty() )+ return m_observerLookAtPlayer->getPlayerTemplate();++ if( ThePlayerList == NULL )+ return NULL;++ for( Int i = 0; i < ThePlayerList->getPlayerCount(); i++ )+ {+ Player *p = ThePlayerList->getNthPlayer( i );+ if( p == NULL || !p->isPlayerActive() || !p->isPlayableSide() )+ continue;++ const PlayerTemplate *pt = p->getPlayerTemplate();+ if( pt && !pt->getSpecialPowerShortcutWinName().isEmpty() )+ return pt;+ }++ return NULL;++} // end specialPowerTraySide++//-------------------------------------------------------------------------------------------------+/** Read a side's tray out of its own shortcut layout, once. Nothing of the layout survives the+ * call: the Image belongs to the mapped image collection and the size is two integers, so the+ * windows go straight back. The lookup is by layout name rather than by template, since the+ * generals of one side share a bar. */+//-------------------------------------------------------------------------------------------------+const ControlBar::BorrowedTray *ControlBar::borrowTray( const PlayerTemplate *pt )+{+ if( pt == NULL || pt->getSpecialPowerShortcutWinName().isEmpty() )+ return NULL;++ const AsciiString layoutName = pt->getSpecialPowerShortcutWinName();++ //+ // the side at the keyboard is read off the bar it is already showing. Not an optimization: the+ // generals of one side share a layout, and a second copy of it would put a second window under+ // every one of its names for as long as this call runs+ //+ if( m_specialPowerLayout && m_specialPowerShortcutButtonParents[ 0 ]+ && m_specialPowerLayout->getFilename().compareNoCase( layoutName ) == 0 )+ return NULL;++ for( Int i = 0; i < m_borrowedTrayCount; i++ )+ if( m_borrowedTrays[ i ].layout.compareNoCase( layoutName ) == 0 )+ return m_borrowedTrays[ i ].image ? &m_borrowedTrays[ i ] : NULL;++ if( m_borrowedTrayCount >= MAX_BORROWED_TRAYS )+ return NULL; // more sides on one screen than any game ships: they keep the plain plate++ BorrowedTray *slot = &m_borrowedTrays[ m_borrowedTrayCount++ ];+ slot->layout = layoutName;+ slot->image = NULL;+ slot->size.x = 0;+ slot->size.y = 0;++ WindowLayout *layout = TheWindowManager->winCreateLayout( layoutName );+ if( layout == NULL )+ return NULL; // a mod naming a layout it does not ship: remembered as having no tray+ layout->hide( TRUE );++ AsciiString parentName = layoutName;+ parentName.concat( ":ButtonParent1" );++ //+ // looked up inside our own copy of the bar rather than across every window on screen: a player+ // who was knocked out still has his own bar loaded, and it carries these very names+ //+ GameWindow *slotWindow = TheWindowManager->winGetWindowFromId( layout->getFirstWindow(),+ TheNameKeyGenerator->nameToKey( parentName ) );+ if( slotWindow )+ {+ slot->image = slotWindow->winGetEnabledImage( 0 );+ slotWindow->winGetSize( &slot->size.x, &slot->size.y );+ }++ layout->destroyWindows();+ layout->deleteInstance();++ return slot->image ? slot : NULL;++} // end borrowTray+//-------------------------------------------------------------------------------------------------/** That tray at the size the bar itself draws it, the hole in its artwork the cameo fills, and the* step a row of them runs at. All of it read back off the loaded bar, which the loader has* already scaled to the running resolution - so nothing here is in 800x600 pixels, and anything* borrowing the look comes out the size of the powers themselves at every resolution.*- * Any of the four out-parameters may be NULL. FALSE when there is no bar to measure. */+ * Any of the four out-parameters may be NULL. FALSE when there is no bar and no layout to+ * borrow one from - the strips then keep the plain plate they had before any of this. *///-------------------------------------------------------------------------------------------------Bool ControlBar::getSpecialPowerTrayLayout( ICoord2D *traySize, ICoord2D *cameoSize,ICoord2D *cameoOffset, Int *columnStep ){- if( m_specialPowerShortcutParent == NULL || m_specialPowerShortcutButtonParents[ 0 ] == NULL )+ if( m_specialPowerShortcutParent && m_specialPowerShortcutButtonParents[ 0 ] )+ {+ Int slotWidth, slotHeight;+ m_specialPowerShortcutButtonParents[ 0 ]->winGetSize( &slotWidth, &slotHeight );+ return trayLayoutFromSlot( slotWidth, slotHeight, traySize, cameoSize, cameoOffset, columnStep );+ }++ // measured off the very layout the tray came out of, so the two always agree+ const BorrowedTray *borrowed = borrowTray( specialPowerTraySide() );+ if( borrowed == NULL )return FALSE;- Int slotWidth, slotHeight;- m_specialPowerShortcutButtonParents[ 0 ]->winGetSize( &slotWidth, &slotHeight );+ return trayLayoutFromSlot( borrowed->size.x, borrowed->size.y,+ traySize, cameoSize, cameoOffset, columnStep );++} // end getSpecialPowerTrayLayout++//-------------------------------------------------------------------------------------------------+/** The artwork's proportions, applied to whatever size a slot came out at. */+//-------------------------------------------------------------------------------------------------+Bool ControlBar::trayLayoutFromSlot( Int slotWidth, Int slotHeight, ICoord2D *traySize,+ ICoord2D *cameoSize, ICoord2D *cameoOffset, Int *columnStep )+{if( slotWidth <= 0 || slotHeight <= 0 )return FALSE;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cppindex 6f0014dbc..ab1b0f92e 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp@@ -1115,6 +1115,33 @@ void ControlBarSchemeManager::drawBackground( ICoord2D offset )m_currentScheme->drawBackground( m_multiplyer, offset );}+//-----------------------------------------------------------------------------+/** Which side's artwork the bar on screen is wearing, when the scheme's own name is not a side+ * anything else knows - "Observer". ControlBar.ini builds that bar entirely out of one faction's+ * plates (the American ones, down to the logo in the right hand corner), so the scheme that shares+ * its right hand plate is the side a watcher is really looking at, and anything dressing itself to+ * match the bar - the HUD strips do - has a side to ask for. */+//-----------------------------------------------------------------------------+AsciiString ControlBarSchemeManager::getCurrentArtTwinSide( void ) const+{+ if( m_currentScheme == NULL || m_currentScheme->m_rightHUDImage == NULL )+ return AsciiString::TheEmptyString;++ for( ControlBarSchemeList::const_iterator it = m_schemeList.begin(); it != m_schemeList.end(); ++it )+ {+ const ControlBarScheme *scheme = *it;+ if( scheme == NULL || scheme->m_rightHUDImage != m_currentScheme->m_rightHUDImage )+ continue;+ if( scheme->m_side.isEmpty() || scheme->m_side.compareNoCase( m_currentScheme->m_side ) == 0 )+ continue;++ return scheme->m_side;+ }++ return AsciiString::TheEmptyString;++}+//-----------------------------------------------------------------------------void ControlBarSchemeManager::setControlBarSchemeByPlayerTemplate( const PlayerTemplate *pt, Bool useSmall){diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex e403494f8..8e3ddf182 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -1152,8 +1152,12 @@ InGameUI::InGameUI()m_productionStripCameoH = PRODUCTION_STRIP_CAMEO;m_productionStripTray = NULL;m_productionStripTraySource = NULL;- m_productionStripOverflow = NULL;- m_stripSecondsString = NULL;+ for( Int stripString = 0; stripString < STRIP_OVERFLOW_STRINGS; stripString++ )+ m_productionStripOverflow[ stripString ] = NULL;+ for( Int stripSeconds = 0; stripSeconds < STRIP_SECONDS_STRINGS; stripSeconds++ )+ m_stripSecondsString[ stripSeconds ] = NULL;+ for( Int stripQuantity = 0; stripQuantity < STRIP_QUANTITY_STRINGS; stripQuantity++ )+ m_stripQuantityString[ stripQuantity ] = NULL;m_superweaponIconCount = 0;m_superweaponIconTotal = 0;@@ -5959,10 +5963,12 @@ static void appendProducerQueue( Object *obj, InGameUI::ProductionStripSlot *sloPlayer *owner = obj->getControllingPlayer();Int ahead = 0; ///< frames the queue in front of the current entry still needs+ Int runAt = -1; ///< where this producer's last item went, so a run of the same thing folds into itfor( const ProductionEntry *p = pu->firstProduction(); p; p = pu->nextProduction( p ) ){Int id = 0;+ Int typeKey = 0;Bool isUpgrade = FALSE;Int buildFrames = 0;@@ -5970,12 +5976,16 @@ static void appendProducerQueue( Object *obj, InGameUI::ProductionStripSlot *slo{id = (Int)p->getProductionID();if( p->getProductionObject() )+ {buildFrames = p->getProductionObject()->calcTimeToBuild( owner );+ typeKey = (Int)p->getProductionObject()->getTemplateID();+ }}else if( p->getProductionType() == PRODUCTION_UPGRADE && p->getProductionUpgrade() ){isUpgrade = TRUE;id = (Int)p->getProductionUpgrade()->getUpgradeNameKey();+ typeKey = id;buildFrames = p->getProductionUpgrade()->calcTimeToBuild( owner );}else@@ -5997,6 +6007,21 @@ static void appendProducerQueue( Object *obj, InGameUI::ProductionStripSlot *slo//(*total)++;+ //+ // Ten Red Guards queued back to back are one order repeated, not ten things to read: they+ // fold into the cameo the run started, which wears an "xN". Only a run does - the same unit+ // queued again after something else is a second cameo, because that is what the queue looks+ // like - and only within one producer's queue, so the cameo still stands for a place you can+ // jump to and an item you can cancel. The countdown stays the one the run's first item+ // carries: what the cameo says is when the next of these arrives.+ //+ if( runAt >= 0 && runAt < *count && slots[ runAt ].typeKey == typeKey+ && slots[ runAt ].isUpgrade == isUpgrade && slots[ runAt ].producer == obj->getID() )+ {+ slots[ runAt ].quantity++;+ continue;+ }+//// walk back over the items that finish later than this one and drop it in front of them.// Ties keep the order they were met in, so a base full of identical barracks stays put@@ -6010,6 +6035,9 @@ static void appendProducerQueue( Object *obj, InGameUI::ProductionStripSlot *sloslots[ at - 1 ].remaining ) )at--;+ // something else has come between: whatever this producer queues next starts a new run+ runAt = -1;+if( at >= max )continue; // everything already kept finishes sooner: counted, but not drawn@@ -6019,13 +6047,17 @@ static void appendProducerQueue( Object *obj, InGameUI::ProductionStripSlot *slofor( Int j = *count - 1; j > at; j-- )slots[ j ] = slots[ j - 1 ];+ runAt = at;+InGameUI::ProductionStripSlot *slot = &slots[ at ];slot->producer = obj->getID();slot->id = id;+ slot->typeKey = typeKey;slot->isUpgrade = isUpgrade;slot->isStructure = FALSE;slot->leads = leads;slot->remaining = remaining;+ slot->quantity = 1;slot->pos.x = 0;slot->pos.y = 0;}@@ -6082,10 +6114,13 @@ static void appendStructureUnderConstruction( Object *obj, InGameUI::ProductionSInGameUI::ProductionStripSlot *slot = &slots[ at ];slot->producer = obj->getID();slot->id = 0;+ slot->typeKey = 0;slot->isUpgrade = FALSE;slot->isStructure = TRUE;slot->leads = FALSE;slot->remaining = remaining;+ // each site is its own place on the map, so two of the same building stay two cameos+ slot->quantity = 1;slot->pos.x = 0;slot->pos.y = 0;}@@ -6120,6 +6155,20 @@ static void gatherStripStructures( Object *obj, void *userData )appendStructureUnderConstruction( obj, g->slot, g->count, g->max, g->total );}+//-------------------------------------------------------------------------------------------------+/** Player::iterateObjects callback for a watched player's row: everything that player has coming,+ * queued in a factory or going up on the ground, in the one line. Playing, those are two rows+ * because you act on them differently; watching, a row is a whole player and what is being built+ * is the same question either way. Nothing is counted twice - a building under construction+ * produces nothing until it is finished. */+//-------------------------------------------------------------------------------------------------+static void gatherStripEverything( Object *obj, void *userData )+{+ ProductionStripGather *g = (ProductionStripGather *)userData;+ appendProducerQueue( obj, g->slot, g->count, g->max, g->total, FALSE );+ appendStructureUnderConstruction( obj, g->slot, g->count, g->max, g->total );+}+//-------------------------------------------------------------------------------------------------/** Find the queue entry a slot stands for. Re-read every frame rather than cached: production runs* on the logic clock and this draws on the render clock, so anything held is stale. */@@ -6152,8 +6201,9 @@ static const ProductionEntry *findStripEntry( ProductionUpdateInterface *pu,* between every pair of cameos; mirrored, the rail leads the row and the trays close up behind* it.*- * Kept until the bar hands back a different tray - a side change, a mod's own bar - rather than- * rebuilt per cameo per frame. NULL for a side whose template ships no shortcut bar. */+ * Kept until the bar hands back a different tray - a side change, an observer picking a different+ * player out of the list, a mod's own bar - rather than rebuilt per cameo per frame. NULL when+ * there is no bar and nothing to borrow one from. *///-------------------------------------------------------------------------------------------------const Image *InGameUI::productionStripTray( void ){@@ -6231,22 +6281,25 @@ Int InGameUI::stripRowStep( Int trayHeight )* is a shape rather than a number: it answers "nearly" and never "eleven seconds". Both strips* put the number in the middle of the box, over the sweep. *///--------------------------------------------------------------------------------------------------void InGameUI::drawStripSeconds( Int x, Int y, Int w, Int h, Int seconds, Bool plainSeconds )+void InGameUI::drawStripSeconds( Int which, Int x, Int y, Int w, Int h, Int seconds, Bool plainSeconds ){- if( m_stripSecondsString == NULL )+ // its own string, kept between frames - see m_stripSecondsString+ DisplayString *&secondsString = m_stripSecondsString[ which ];++ if( secondsString == NULL ){- m_stripSecondsString = TheDisplayStringManager->newDisplayString();- m_stripSecondsString->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,+ secondsString = TheDisplayStringManager->newDisplayString();+ secondsString->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,TheGlobalLanguageData->adjustFontSize( PRODUCTION_STRIP_SECS ),TRUE ) );}UnicodeString text;formatStripSeconds( &text, seconds, plainSeconds );- m_stripSecondsString->setText( text );+ secondsString->setText( text );Int textWidth = 0, textHeight = 0;- m_stripSecondsString->getSize( &textWidth, &textHeight );+ secondsString->getSize( &textWidth, &textHeight );const Int textX = x + ( w - textWidth ) / 2;const Int textY = y + ( h - textHeight ) / 2;@@ -6254,8 +6307,38 @@ void InGameUI::drawStripSeconds( Int x, Int y, Int w, Int h, Int seconds, Bool p// no plate under it: the cameo is already under the sweep's scrim, and a second black box// inside a sixteen pixel box was most of the cameo - the number read as a label stuck over// the picture instead of a countdown running on it. The drop shadow carries it.- m_stripSecondsString->draw( textX, textY, GameMakeColor( 245, 245, 245, 255 ),- GameMakeColor( 0, 0, 0, 255 ) );+ secondsString->draw( textX, textY, GameMakeColor( 245, 245, 245, 255 ),+ GameMakeColor( 0, 0, 0, 255 ) );+}++//-------------------------------------------------------------------------------------------------+/** The "xN" a folded run of the same item wears, in the cameo's top right corner - the corner the+ * command bar puts its own count badge in, and the corner the countdown in the middle leaves free.+ * Kept per cameo for the reason the countdowns are: a DisplayString rebuilds a font surface every+ * time its text changes, and this one changes only when the run does. */+//-------------------------------------------------------------------------------------------------+void InGameUI::drawStripQuantity( Int which, Int x, Int y, Int w, Int quantity )+{+ DisplayString *&quantityString = m_stripQuantityString[ which ];++ if( quantityString == NULL )+ {+ quantityString = TheDisplayStringManager->newDisplayString();+ quantityString->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,+ TheGlobalLanguageData->adjustFontSize( PRODUCTION_STRIP_SECS ),+ TRUE ) );+ }++ UnicodeString text;+ text.format( L"x%d", quantity );+ quantityString->setText( text );++ Int textWidth = 0, textHeight = 0;+ quantityString->getSize( &textWidth, &textHeight );++ quantityString->draw( x + w - textWidth - 1, y + 1,+ GameMakeColor( 255, 255, 255, 255 ),+ GameMakeColor( 0, 0, 0, 255 ) );}//-------------------------------------------------------------------------------------------------@@ -6322,7 +6405,6 @@ void InGameUI::drawSuperweaponStrip( void )const Image *tray = TheControlBar ? TheControlBar->getSpecialPowerTrayImage() : NULL;const Int gap = stripPixels( PRODUCTION_STRIP_GAP );- const Int edge = stripPixels( PRODUCTION_STRIP_LEFT );const Int more = stripPixels( PRODUCTION_STRIP_MORE );const Int plate = stripPixels( 3 );@@ -6347,9 +6429,15 @@ void InGameUI::drawSuperweaponStrip( void )pulse = 0.5f - 0.5f * (Real)cos( 2.0 * PI * phase );}- const Int right = TheDisplay->getWidth() - edge;+ // flush against the right hand edge: the tray's heavy rail is the edge of the strip, and an inset+ // leaves it hanging in the middle of nothing. The production rows keep their inset because their+ // rail faces the other way, into the screen+ const Int right = TheDisplay->getWidth();const Int hidden = m_superweaponIconTotal - m_superweaponIconCount;+ // drawn as a batch, for the reason drawProductionStrip() gives - see Display::beginBatch2D+ TheDisplay->beginBatch2D();+for( Int row = 0; row < SUPERWEAPON_STRIP_ROWS; row++ ){const Int first = row * SUPERWEAPON_STRIP_COLS;@@ -6383,32 +6471,33 @@ void InGameUI::drawSuperweaponStrip( void )TheDisplay->drawFillRect( backX, trayY, trayW, trayH, GameMakeColor( 0, 0, 0, 130 ) );}- for( Int i = 0; i < inRow; i++ )+ //+ // The row goes down a piece at a time - every picture, then every sweep, then every border -+ // rather than an icon at a time, for the reason drawProductionStripRow() gives: pieces that+ // want the same thing of the renderer are one draw call when they follow each other and one+ // draw call each when they do not. The icons do not overlap, so nothing changes on screen.+ //+ for( Int cameoSlot = 0; cameoSlot < inRow; cameoSlot++ ){- const SuperweaponIconSlot *slot = &m_superweaponIcons[ first + i ];- const Int x = right - trayW + trayHole.x - i * trayStep;+ const SuperweaponIconSlot *slot = &m_superweaponIcons[ first + cameoSlot ];+ const Int x = right - trayW + trayHole.x - cameoSlot * trayStep;if( slot->image )TheDisplay->drawImage( slot->image, x, y, x + cameoW, y + cameoH );+ }- //- // the same sweep the production cameos wear, and the same way round as the command- // bar's own clock: the scrim covers what is still to be charged and is swept off as- // the charge runs.- //- UnsignedByte r, g, b, a;- GameGetColorComponents( slot->color, &r, &g, &b, &a );+ //+ // the same sweep the production cameos wear, and the same way round as the command bar's own+ // clock: the scrim covers what is still to be charged and is swept off as the charge runs+ //+ for( Int clockSlot = 0; clockSlot < inRow; clockSlot++ )+ {+ const SuperweaponIconSlot *slot = &m_superweaponIcons[ first + clockSlot ];+ const Int x = right - trayW + trayHole.x - clockSlot * trayStep;if( !slot->ready )- {TheDisplay->drawRemainingRectClock( x, y, cameoW, cameoH, slot->percent,GameMakeColor( 0, 0, 0, 130 ) );- //- // bare seconds, however many there are: this strip is read against the other- // countdowns on the screen, and m:ss is a number you have to convert first- //- drawStripSeconds( x, y, cameoW, cameoH, slot->seconds, TRUE );- }else{//@@ -6417,11 +6506,35 @@ void InGameUI::drawSuperweaponStrip( void )// thing on this strip that wants to be noticed rather than looked up, and a// translucent wash over the picture says whose it is in the same stroke.//+ UnsignedByte r, g, b, a;+ GameGetColorComponents( slot->color, &r, &g, &b, &a );const UnsignedByte washAlpha = (UnsignedByte)( 30.0f + 90.0f * pulse );TheDisplay->drawFillRect( x, y, cameoW, cameoH, GameMakeColor( r, g, b, washAlpha ) );}+ }++ //+ // bare seconds, however many there are: this strip is read against the other countdowns on+ // the screen, and m:ss is a number you have to convert first+ //+ for( Int secondsSlot = 0; secondsSlot < inRow; secondsSlot++ )+ {+ const SuperweaponIconSlot *slot = &m_superweaponIcons[ first + secondsSlot ];+ const Int x = right - trayW + trayHole.x - secondsSlot * trayStep;- // the border is whose weapon it is - the colour the timer was registered with+ if( !slot->ready )+ drawStripSeconds( PRODUCTION_STRIP_ROWS * PRODUCTION_STRIP_ROW_MAX + first + secondsSlot,+ x, y, cameoW, cameoH, slot->seconds, TRUE );+ }++ // the border is whose weapon it is - the colour the timer was registered with+ for( Int borderSlot = 0; borderSlot < inRow; borderSlot++ )+ {+ const SuperweaponIconSlot *slot = &m_superweaponIcons[ first + borderSlot ];+ const Int x = right - trayW + trayHole.x - borderSlot * trayStep;++ UnsignedByte r, g, b, a;+ GameGetColorComponents( slot->color, &r, &g, &b, &a );TheDisplay->drawOpenRect( x, y, cameoW, cameoH, 2.0f, GameMakeColor( r, g, b, 255 ) );}@@ -6431,27 +6544,32 @@ void InGameUI::drawSuperweaponStrip( void )//if( hidden > 0 && lastRow ){- if( m_productionStripOverflow == NULL )+ // this strip's own "+N", kept apart from the production rows' - see m_stripSecondsString+ DisplayString *&overflow = m_productionStripOverflow[ PRODUCTION_STRIP_ROWS ];++ if( overflow == NULL ){- m_productionStripOverflow = TheDisplayStringManager->newDisplayString();- m_productionStripOverflow->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,+ overflow = TheDisplayStringManager->newDisplayString();+ overflow->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,TheGlobalLanguageData->adjustFontSize( HUD_OVERLAY_POINT_SIZE ),TRUE ) );}UnicodeString text;text.format( L"+%d", hidden );- m_productionStripOverflow->setText( text );+ overflow->setText( text );Int textWidth = 0, textHeight = 0;- m_productionStripOverflow->getSize( &textWidth, &textHeight );+ overflow->getSize( &textWidth, &textHeight );- m_productionStripOverflow->draw( right - rowWidth + ( more - textWidth ) / 2,- y + ( cameoH - textHeight ) / 2,- GameMakeColor( 235, 235, 235, 255 ),- GameMakeColor( 0, 0, 0, 255 ) );+ overflow->draw( right - rowWidth + ( more - textWidth ) / 2,+ y + ( cameoH - textHeight ) / 2,+ GameMakeColor( 235, 235, 235, 255 ),+ GameMakeColor( 0, 0, 0, 255 ) );}}++ TheDisplay->endBatch2D();}//-------------------------------------------------------------------------------------------------@@ -6510,17 +6628,53 @@ void InGameUI::drawProductionStripRow( Int row, Int y )TheDisplay->drawFillRect( backX, trayY, trayW, trayH, GameMakeColor( 0, 0, 0, 130 ) );}- const Int hidden = m_productionStripTotal[ row ] - count;+ //+ // what the "+N" stands for is everything the row does not already show - and a cameo wearing an+ // "x5" shows five of them, so the run counts as five here or the same items are reported twice+ //+ Int shown = 0;+ for( Int shownSlot = 0; shownSlot < count; shownSlot++ )+ shown += m_productionStrip[ row ][ shownSlot ].quantity;++ const Int hidden = m_productionStripTotal[ row ] - shown;++ //+ // What every cameo in the row is to be drawn with, worked out before any of it is drawn. The+ // row then goes down a piece at a time - every picture, then every scrim, then every border -+ // rather than a cameo at a time, because a run of pieces that ask the renderer for the same+ // thing is one draw call and the same pieces shuffled together are one draw call each. The+ // cameos do not overlap, so what lands on the screen is exactly what always did.+ //+ struct StripSlotDraw+ {+ Int x; ///< left edge of this cameo+ const Image *cameo; ///< its picture, NULL when the template carries none+ Int percent; ///< how much of the scrim has been swept off, -1 for no scrim+ Int seconds; ///< the countdown written across it, -1 for none+ Int quantity; ///< how many of the same item it stands for, 1 for a lone one+ Color border;+ Bool cancelHover; ///< the cursor is on it with ctrl held: this is the one a click cancels+ };+ StripSlotDraw slots[ PRODUCTION_STRIP_ROW_MAX ];Int trayX = 0;Int x = trayX + trayInsetX;for( Int i = 0; i < count; i++ ){ProductionStripSlot *slot = &m_productionStrip[ row ][ i ];+ StripSlotDraw *draw = &slots[ i ];+x = trayX + trayInsetX;slot->pos.x = x;slot->pos.y = y;+ draw->x = x;+ draw->cameo = NULL;+ draw->percent = -1;+ draw->seconds = -1;+ draw->quantity = slot->quantity;+ draw->cancelHover = FALSE;+Object *producer = TheGameLogic->findObjectByID( slot->producer );ProductionUpdateInterface *pu = producer ? producer->getProductionUpdateInterface() : NULL;const ProductionEntry *entry = slot->isStructure ? NULL : findStripEntry( pu, slot );@@ -6531,36 +6685,28 @@ void InGameUI::drawProductionStripRow( Int row, Int y )// A building going up carries its own progress rather than a queue entry's: the same// sweep and the same countdown, read off the construction percentage on the object.//- const Image *cameo = producer->getTemplate()->getButtonImage();- if( cameo )- TheDisplay->drawImage( cameo, x, y, x + cameoW, y + cameoH );+ draw->cameo = producer->getTemplate()->getButtonImage();const Real done = producer->getConstructionPercent();- TheDisplay->drawRemainingRectClock( x, y, cameoW, cameoH,- REAL_TO_INT( done ), GameMakeColor( 0, 0, 0, 100 ) );+ draw->percent = REAL_TO_INT( done );const Int totalFrames =producer->getTemplate()->calcTimeToBuild( producer->getControllingPlayer() );if( totalFrames > 0 ){const Real left = totalFrames * ( 1.0f - done / 100.0f );- drawStripSeconds( x, y, cameoW, cameoH,- ControlBar_secondsFromFrames( left > 0.0f ? left : 0.0f ) );+ draw->seconds = ControlBar_secondsFromFrames( left > 0.0f ? left : 0.0f );}}else if( entry ){- const Image *cameo = NULL;if( slot->isUpgrade ){if( entry->getProductionUpgrade() )- cameo = entry->getProductionUpgrade()->getButtonImage();+ draw->cameo = entry->getProductionUpgrade()->getButtonImage();}else if( entry->getProductionObject() )- cameo = entry->getProductionObject()->getButtonImage();-- if( cameo )- TheDisplay->drawImage( cameo, x, y, x + cameoW, y + cameoH );+ draw->cameo = entry->getProductionObject()->getButtonImage();//// The scrim starts covering the cameo and is swept off as the item is built, the same@@ -6571,9 +6717,7 @@ void InGameUI::drawProductionStripRow( Int row, Int y )// everything behind it is waiting and wears the full scrim.//const Bool building = ( pu->firstProduction() == entry );- const Int percent = building ? REAL_TO_INT( entry->getPercentComplete() ) : 0;- TheDisplay->drawRemainingRectClock( x, y, cameoW, cameoH,- percent, GameMakeColor( 0, 0, 0, 100 ) );+ draw->percent = building ? REAL_TO_INT( entry->getPercentComplete() ) : 0;//// How long this one still has, written in the middle of it - but only for the item@@ -6595,8 +6739,7 @@ void InGameUI::drawProductionStripRow( Int row, Int y )if( totalFrames > 0 ){const Real left = totalFrames * ( 1.0f - entry->getPercentComplete() / 100.0f );- drawStripSeconds( x, y, cameoW, cameoH,- ControlBar_secondsFromFrames( left > 0.0f ? left : 0.0f ) );+ draw->seconds = ControlBar_secondsFromFrames( left > 0.0f ? left : 0.0f );}}}@@ -6607,48 +6750,91 @@ void InGameUI::drawProductionStripRow( Int row, Int y )// the cursor is really on, and an accidental cancel costs the whole item.//// a building already standing on the map is not cancelled from here - it is sold or blown up- Bool cancelHover = FALSE;if( !m_productionStripWatching && !slot->isStructure&& TheKeyboard && TheKeyboard->isCtrl() && TheMouse ){const MouseIO *io = TheMouse->getMouseStatus();- cancelHover = io && io->pos.x >= x && io->pos.x < x + cameoW &&- io->pos.y >= y && io->pos.y < y + cameoH;+ draw->cancelHover = io && io->pos.x >= x && io->pos.x < x + cameoW &&+ io->pos.y >= y && io->pos.y < y + cameoH;}// same border colours the command bar puts on its build and upgrade buttons - except while// watching, where the border is whose row it is, since that is what the row is there to say- Color border = GameMakeColor( 160, 160, 160, 160 );- if( cancelHover )- border = GameMakeColor( 255, 80, 80, 255 );+ draw->border = GameMakeColor( 160, 160, 160, 160 );+ if( draw->cancelHover )+ draw->border = GameMakeColor( 255, 80, 80, 255 );else if( m_productionStripRowColor[ row ] != 0 ){// the stored player colour's alpha is not ours to trust, the health bars found that outUnsignedByte r, g, b, a;GameGetColorComponents( m_productionStripRowColor[ row ], &r, &g, &b, &a );- border = GameMakeColor( r, g, b, 255 );+ draw->border = GameMakeColor( r, g, b, 255 );}else if( TheControlBar )- border = slot->isUpgrade ? TheControlBar->getUpgradeBorderColor()- : TheControlBar->getBuildBorderColor();+ draw->border = slot->isUpgrade ? TheControlBar->getUpgradeBorderColor()+ : TheControlBar->getBuildBorderColor();++ trayX += trayStep;+ }++ // the pictures+ for( Int cameoSlot = 0; cameoSlot < count; cameoSlot++ )+ {+ const StripSlotDraw *draw = &slots[ cameoSlot ];+ if( draw->cameo )+ TheDisplay->drawImage( draw->cameo, draw->x, y, draw->x + cameoW, y + cameoH );+ }++ // the sweeps over them+ for( Int clockSlot = 0; clockSlot < count; clockSlot++ )+ {+ const StripSlotDraw *draw = &slots[ clockSlot ];+ if( draw->percent >= 0 )+ TheDisplay->drawRemainingRectClock( draw->x, y, cameoW, cameoH,+ draw->percent, GameMakeColor( 0, 0, 0, 100 ) );+ }++ // the countdowns written on them+ for( Int secondsSlot = 0; secondsSlot < count; secondsSlot++ )+ {+ const StripSlotDraw *draw = &slots[ secondsSlot ];+ if( draw->seconds >= 0 )+ drawStripSeconds( row * PRODUCTION_STRIP_ROW_MAX + secondsSlot,+ draw->x, y, cameoW, cameoH, draw->seconds );+ }- // a team border is the row's whole label, so it is drawn heavy enough to read as one- TheDisplay->drawOpenRect( x, y, cameoW, cameoH,- m_productionStripRowColor[ row ] != 0 ? 2.0f : 1.0f, border );+ // how many of the same thing each one stands for, in the corner the countdown leaves free+ for( Int quantitySlot = 0; quantitySlot < count; quantitySlot++ )+ {+ const StripSlotDraw *draw = &slots[ quantitySlot ];+ if( draw->quantity > 1 )+ drawStripQuantity( row * PRODUCTION_STRIP_ROW_MAX + quantitySlot,+ draw->x, y, cameoW, draw->quantity );+ }++ // and the borders round them, a team border heavy enough to read as the row's whole label+ for( Int borderSlot = 0; borderSlot < count; borderSlot++ )+ {+ const StripSlotDraw *draw = &slots[ borderSlot ];+ TheDisplay->drawOpenRect( draw->x, y, cameoW, cameoH,+ m_productionStripRowColor[ row ] != 0 ? 2.0f : 1.0f,+ draw->border );+ }- if( cancelHover )+ for( Int hoverSlot = 0; hoverSlot < count; hoverSlot++ )+ {+ const StripSlotDraw *draw = &slots[ hoverSlot ];+ if( draw->cancelHover ){const Int barInset = cameoW / 4;const Int barHeight = stripPixels( 4 );- TheDisplay->drawFillRect( x, y, cameoW, cameoH,+ TheDisplay->drawFillRect( draw->x, y, cameoW, cameoH,GameMakeColor( 190, 0, 0, 120 ) );- TheDisplay->drawFillRect( x + barInset, y + ( cameoH - barHeight ) / 2,+ TheDisplay->drawFillRect( draw->x + barInset, y + ( cameoH - barHeight ) / 2,cameoW - 2 * barInset, barHeight,GameMakeColor( 255, 255, 255, 255 ) );}-- trayX += trayStep;}x = trayX + gap;@@ -6659,31 +6845,57 @@ void InGameUI::drawProductionStripRow( Int row, Int y )//if( hidden > 0 ){- if( m_productionStripOverflow == NULL )+ // this row's own "+N" - see m_stripSecondsString+ DisplayString *&overflow = m_productionStripOverflow[ row ];++ if( overflow == NULL ){- m_productionStripOverflow = TheDisplayStringManager->newDisplayString();- m_productionStripOverflow->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,+ overflow = TheDisplayStringManager->newDisplayString();+ overflow->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,TheGlobalLanguageData->adjustFontSize( HUD_OVERLAY_POINT_SIZE ),TRUE ) );}UnicodeString text;text.format( L"+%d", hidden );- m_productionStripOverflow->setText( text );+ overflow->setText( text );Int textWidth = 0, textHeight = 0;- m_productionStripOverflow->getSize( &textWidth, &textHeight );+ overflow->getSize( &textWidth, &textHeight );- m_productionStripOverflow->draw( x + ( more - textWidth ) / 2,- y + ( cameoH - textHeight ) / 2,- GameMakeColor( 235, 235, 235, 255 ),- GameMakeColor( 0, 0, 0, 255 ) );+ overflow->draw( x + ( more - textWidth ) / 2,+ y + ( cameoH - textHeight ) / 2,+ GameMakeColor( 235, 235, 235, 255 ),+ GameMakeColor( 0, 0, 0, 255 ) );}}+#ifdef DEBUG_LOGGING+extern Real TheStripGatherMS;+extern Real TheStripDrawMS;++static Real stripElapsedMS( const Int64 &from, const Int64 &to )+{+ Int64 freq;+ QueryPerformanceFrequency( (LARGE_INTEGER *)&freq );+ if( freq == 0 )+ return 0.0f;+ return (Real)((double)( to - from ) * 1000.0 / (double)freq );+}+#endif+//-------------------------------------------------------------------------------------------------void InGameUI::drawProductionStrip( void ){+#ifdef DEBUG_LOGGING+ Int64 tGatherStart, tGatherEnd, tDrawEnd;+ QueryPerformanceCounter( (LARGE_INTEGER *)&tGatherStart );+ tGatherEnd = tGatherStart;+ tDrawEnd = tGatherStart;+ TheStripGatherMS = 0.0f;+ TheStripDrawMS = 0.0f;+#endif+for( Int row = 0; row < PRODUCTION_STRIP_ROWS; row++ ){m_productionStripCount[ row ] = 0;@@ -6719,10 +6931,10 @@ void InGameUI::drawProductionStrip( void )watch.slot = m_productionStrip[ row ];watch.count = &m_productionStripCount[ row ];watch.total = &m_productionStripTotal[ row ];- // eight rows are on screen at once here, so each one is the five soonest and a "+N"+ // eight rows are on screen at once here, so each one is the few soonest and a "+N"watch.max = PRODUCTION_STRIP_WATCH_MAX;watch.skip = INVALID_ID; // nothing is selected in somebody else's base- p->iterateObjects( gatherProductionStrip, &watch );+ p->iterateObjects( gatherStripEverything, &watch );if( m_productionStripCount[ row ] > 0 ){@@ -6776,6 +6988,11 @@ void InGameUI::drawProductionStrip( void )player->iterateObjects( gatherProductionStrip, &gather );}+#ifdef DEBUG_LOGGING+ QueryPerformanceCounter( (LARGE_INTEGER *)&tGatherEnd );+ TheStripGatherMS = stripElapsedMS( tGatherStart, tGatherEnd );+#endif+//// The rows in use are closed up before they are placed: the sites row is empty for most of a// match, and leaving the space it would have taken puts a band of nothing between the queue and@@ -6831,6 +7048,13 @@ void InGameUI::drawProductionStrip( void )const Int lowerY = barTop - trayBelow - stripPixels( PRODUCTION_STRIP_LIFT );const Int rowStep = stripRowStep( traySize.y );+ //+ // The strip is the busiest thing on the screen that is drawn a quad at a time, so it is drawn+ // as a batch: the rows hand the display their pieces in an order that lets it gather the ones+ // asking for the same state into single draw calls. See Display::beginBatch2D.+ //+ TheDisplay->beginBatch2D();+for( Int at = rowsUsed - 1; at >= 0; at-- ){const Int y = lowerY - ( rowsUsed - 1 - at ) * rowStep;@@ -6838,6 +7062,13 @@ void InGameUI::drawProductionStrip( void )break;drawProductionStripRow( used[ at ], y );}++ TheDisplay->endBatch2D();++#ifdef DEBUG_LOGGING+ QueryPerformanceCounter( (LARGE_INTEGER *)&tDrawEnd );+ TheStripDrawMS = stripElapsedMS( tGatherEnd, tDrawEnd );+#endif}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 614d523d0..e76b8bcb3 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -670,6 +670,15 @@ extern Bool GameEngine_isLogicFrameDue( Real& accumMs, Real elapsedMs, Int logicTEST(logic_tick_is_wall_clock_paced_not_render_paced){+ /* The catch-up cap is a duration, so the frames it buys follow the game speed: EA's three+ frames at the retail 30fps, and six at 60 rather than the same three - a tenth of a second+ either way. */+ const Int cap30 = GameEngine_logicCatchupMaxFrames( 30 );+ CHECK_EQ( cap30, 3 );+ CHECK_EQ( GameEngine_logicCatchupMaxFrames( 60 ), 6 );+ CHECK_EQ( GameEngine_logicCatchupMaxFrames( 15 ), 2 );+ CHECK_EQ( GameEngine_logicCatchupMaxFrames( 0 ), 1 );+/* A 300fps renderer (3.33ms/frame) at 30fps logic: 900 render frames span3 seconds, which must yield 90 logic frames, not 900. */Real accum = 0.0f;@@ -686,10 +695,10 @@ TEST(logic_tick_is_wall_clock_paced_not_render_paced)accum = 0.0f;due = 0;while( GameEngine_isLogicFrameDue( accum, due == 0 ? 100.0f : 0.0f, 30 ) )- if( ++due >= LOGIC_CATCHUP_MAX_FRAMES )+ if( ++due >= cap30 )break;CHECK( due > 1 );- CHECK( due <= LOGIC_CATCHUP_MAX_FRAMES );+ CHECK( due <= cap30 );/* ...and the debt is capped there, however far behind the pass fell. A onesecond stall must not queue thirty frames of catch-up: the surplus is@@ -697,9 +706,9 @@ TEST(logic_tick_is_wall_clock_paced_not_render_paced)accum = 0.0f;due = 0;while( GameEngine_isLogicFrameDue( accum, due == 0 ? 1000.0f : 0.0f, 30 ) )- if( ++due > LOGIC_CATCHUP_MAX_FRAMES )+ if( ++due > cap30 )break;- CHECK_EQ( due, LOGIC_CATCHUP_MAX_FRAMES );+ CHECK_EQ( due, cap30 );/* Over a run the pacer still hands out wall-clock time and no more: 3 secondsof 20fps passes is 90 logic frames, not 60 (render-paced) and not 180. */@@ -711,7 +720,7 @@ TEST(logic_tick_is_wall_clock_paced_not_render_paced)while( GameEngine_isLogicFrameDue( accum, ticks == 0 ? 50.0f : 0.0f, 30 ) ){++due;- if( ++ticks >= LOGIC_CATCHUP_MAX_FRAMES )+ if( ++ticks >= cap30 )break;}}@@ -719,6 +728,25 @@ TEST(logic_tick_is_wall_clock_paced_not_render_paced)/* A non-positive fps never throttles (the -noFPSLimit style dev mode). */CHECK( GameEngine_isLogicFrameDue( accum, 0.0f, 0 ) );++ /* And the case the fixed frame count got wrong. At the 60fps game speed a 16fps render pass+ (63ms) owes nearly four logic frames; with a cap of three the pacer threw one away every+ pass and a match that was merely rendering slowly ran in slow motion - about 40Hz where it+ should have been 60. Ten of those passes must still buy a full 60 frames of simulation. */+ accum = 0.0f;+ due = 0;+ const Int cap60 = GameEngine_logicCatchupMaxFrames( 60 );+ for( Int slowPass = 0; slowPass < 10; ++slowPass )+ {+ Int ticks = 0;+ while( GameEngine_isLogicFrameDue( accum, ticks == 0 ? 63.0f : 0.0f, 60 ) )+ {+ ++due;+ if( ++ticks >= cap60 )+ break;+ }+ }+ CHECK( due >= 36 && due <= 38 ); // 630ms of wall clock at 60Hz, and no more}/* AnimateWindowManager.cpp: the same argument one layer up. The menu animations@@ -6963,6 +6991,69 @@ TEST(a_queue_cameo_sits_in_the_general_power_tray_the_way_that_bar_sits_in_it)CHECK( rowWidth < 800 );}+/* Both strips now ask the control bar for the tray, and the control bar works the whole geometry+ out of one number: the size the window loader gave a shortcut slot. Everything downstream - the+ hole the cameo goes in, the step a row runs at - is a fraction of the artwork, so a bar the+ loader scaled to a widescreen resolution scales the strips with it instead of leaving 800x600+ cameos rattling around inside 1600x900 trays.++ The numbers checked here are the ones the strip's own constants were authored against: the+ shortcut slot is 48x41 in the 800x600 the layouts are written in. */+TEST(the_strip_tray_geometry_is_a_fraction_of_whatever_size_the_bar_was_loaded_at)+{+ ICoord2D tray, cameo, hole;+ Int step = 0;++ // nothing to measure is FALSE rather than a division by zero+ CHECK( !ControlBar::trayLayoutFromSlot( 0, 41, &tray, &cameo, &hole, &step ) );+ CHECK( !ControlBar::trayLayoutFromSlot( 48, 0, &tray, &cameo, &hole, &step ) );+ CHECK( !ControlBar::trayLayoutFromSlot( -48, -41, &tray, &cameo, &hole, &step ) );++ // the slot the strip's own constants were written against+ CHECK( ControlBar::trayLayoutFromSlot( (Int)InGameUI::PRODUCTION_STRIP_TRAY_W,+ (Int)InGameUI::PRODUCTION_STRIP_TRAY_H,+ &tray, &cameo, &hole, &step ) );++ // the tray is the slot, whole: it is never squeezed to fit anything+ CHECK_EQ( (Int)InGameUI::PRODUCTION_STRIP_TRAY_W, tray.x );+ CHECK_EQ( (Int)InGameUI::PRODUCTION_STRIP_TRAY_H, tray.y );++ // and the cameo is inside it, art and all, both ways+ CHECK( hole.x >= 0 && hole.y >= 0 );+ CHECK( hole.x + cameo.x <= tray.x );+ CHECK( hole.y + cameo.y <= tray.y );+ CHECK( cameo.x > 0 && cameo.y > 0 );++ // a row closes up rather than separating, and never eats a whole tray+ CHECK( step > 0 );+ CHECK( step < tray.x );++ //+ // Twice the bar, twice everything: an observer borrowing another side's tray gets that side's+ // slot size, and every one of these has to follow it or the borrowed art comes out with the+ // cameo hanging over its rail.+ //+ ICoord2D bigTray, bigCameo, bigHole;+ Int bigStep = 0;+ CHECK( ControlBar::trayLayoutFromSlot( 2 * (Int)InGameUI::PRODUCTION_STRIP_TRAY_W,+ 2 * (Int)InGameUI::PRODUCTION_STRIP_TRAY_H,+ &bigTray, &bigCameo, &bigHole, &bigStep ) );+ CHECK_EQ( 2 * tray.x, bigTray.x );+ CHECK_EQ( 2 * tray.y, bigTray.y );+ CHECK_EQ( 2 * step, bigStep );+ CHECK( bigCameo.x >= 2 * cameo.x - 1 && bigCameo.x <= 2 * cameo.x + 1 );+ CHECK( bigCameo.y >= 2 * cameo.y - 1 && bigCameo.y <= 2 * cameo.y + 1 );+ CHECK( bigHole.x + bigCameo.x <= bigTray.x );+ CHECK( bigHole.y + bigCameo.y <= bigTray.y );++ // every out-parameter is optional: the layout pass only wants the step+ Int stepOnly = 0;+ CHECK( ControlBar::trayLayoutFromSlot( (Int)InGameUI::PRODUCTION_STRIP_TRAY_W,+ (Int)InGameUI::PRODUCTION_STRIP_TRAY_H,+ NULL, NULL, NULL, &stepOnly ) );+ CHECK_EQ( step, stepOnly );+}+/* Rows of trays stack by the same overlap the trays close up by sideways, so a pile of rows readsas one sheet of metal. The general's power bar itself is the check: it steps 35 between 41-tallslots, and the step has to come out of the tray height as a fraction so it survives a bar the