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): draw the superweapon countdowns as a strip of cameos
Olcay Seygan43978d0c5b3a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 551500eb7..26a6b5444 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -256,6 +256,8 @@ found and fixed — EA's own, not port damage.**- Ordered by time left, so it reads as the order things arrive.- Click a picture to jump the camera there; Ctrl-click cancels it.- One picture is one order, cut to match the command bar's artwork.+- The strip is half the size it was: it says the same thing and takes back the screen it was eating.+- Whatever is actually being built counts down inside its own picture. The ones queued behind it stay blank, because their wait depends on everything in front of them.- A unit finishes walking out of its factory before it takes an order.- An upgrade stays available if any selected building can still buy it.- One right click cancels one thing, counted the moment you press.@@ -273,7 +275,9 @@ found and fixed — EA's own, not port damage.**- Workers go back to collecting supplies when they finish.- Every countdown reads real seconds and answers the game speed.- The clock and frame-rate readout is drawn on top of everything.-- The superweapon countdowns start below that readout instead of behind it.+- The superweapon countdowns are pictures now, not a list of names: the same strip treatment, in the top right corner, under that readout. Each one wears its own seconds and a sweeping clock, the next to land sits at the right hand end, and if you are watching more than eighteen of them the rest become a count.+- Every button's corner markings - the hotkey, the price, the time, the number queued - sit flush in the corners instead of floating a few pixels inside them, and are set a size smaller than the button's own text: four labels at full size were eating the picture they were meant to annotate.+- 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.- A game opens with nothing selected, so your first click is not a rally point.- The tilde key opens the general's promotions.- `S` stops your units again; the key was simply never bound.@@ -310,6 +314,7 @@ found and fixed — EA's own, not port damage.**- Supply piles and docks say what is left in them, in cash, over the pile. No more guessing which expansion is worth taking from the art on the model.- Every build button carries its price in the top right corner, opposite the build time already in the other one. It was only ever in the tooltip, which means hovering one button at a time to compare two of them.- A worker fetching or handing over a box shows a bar while it works.+- That bar is now the work itself. A worker used to reset it to empty at the very moment it finished and then walk away, so every trip looked like it left mid-handover; and after taking its last box it stood at the pile for one more full loading cycle, taking nothing. It leaves the instant the load is done - which is a little more money per trip, on every worker you own.- Hackers show how far off the next payout is. So do the black market and the oil derricks.- Factories take a hundred units in the queue, not nine. The build queue only ever had nine buttons and that had become the limit.@@ -438,6 +443,7 @@ found and fixed — EA's own, not port damage.**- Audio is real, through the audio library the retail game ships with.- The videos play: the intro, the sizzle reel, the mission briefings, the general portraits.+- The pointer is on screen over them. It used to appear only once the main menu did, so clicking through the logos was done blind.- About 5,600 graphics calls are translated to a modern path, none of them touched.- No disc, no registry keys, no retail installer — a normal install works.- The startup screen is this build's own, so you can see which one you launched before the menu loads.@@ -453,7 +459,7 @@ found and fixed — EA's own, not port damage.**- An opponent can be set to Human in the skirmish screen: a base with no brain behind it.- Its sight is yours from the first frame, and clicking any of it hands you the base itself.- Shift-Ctrl-T does the same to any opponent, a computer one included, and walks around the table.-- Headless, a 23-minute skirmish plays out in 38 seconds, identically every run.+- Headless, a 23-minute skirmish plays out in 38 seconds, identically every run - and opens no window at all, so twenty of them in a row leave the desktop and the keyboard focus alone.- It plays itself over a network too — two copies, one real connection.- That found every multiplayer replay falsely accusing itself of desync since 2003.- Every fix was proved by putting the bug back and watching the test fail.diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex 0f12bb187..c1f4a3f55 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -60,6 +60,7 @@ class WindowLayout;class Anim2DTemplate;class Anim2D;class Shadow;+class Image;enum LegalBuildCode;enum KindOfType;enum ShadowType;@@ -197,6 +198,7 @@ public:);const SpecialPowerTemplate* getSpecialPowerTemplate() const { return m_powerTemplate; }+ Color getColor() const { return m_color; }void setFont(const AsciiString& superweaponNormalFont, Int superweaponNormalPointSize, Bool superweaponNormalBold);void setText(const UnicodeString& name, const UnicodeString& time);void drawBackdrop(Int x, Int y); ///< plate behind the name and time, so they stay readable over terrain@@ -601,6 +603,22 @@ public: // ********************************************************************/// a click landed on the strip: jump to that producer, or cancel the item when 'cancel' is setBool handleProductionStripClick( const ICoord2D *mouse, Bool cancel );+ //+ // One superweapon countdown of the top right strip. The list is rebuilt every frame out of+ // whatever timers are live, so nothing here outlives the draw that filled it in.+ //+ enum { SUPERWEAPON_STRIP_COLS = 6 }; ///< cameos in one row, the soonest at the right hand end+ enum { SUPERWEAPON_STRIP_ROWS = 3 }; ///< rows of them, and the rest become a "+N"+ enum { SUPERWEAPON_STRIP_MAX = SUPERWEAPON_STRIP_COLS * SUPERWEAPON_STRIP_ROWS };+ struct SuperweaponIconSlot+ {+ const Image * image; ///< the cameo the command bar wears for this power+ Int seconds; ///< seconds until it can be fired, 0 once it is ready+ Int percent; ///< how much of the charge is done, for the radial sweep+ Bool ready; ///< charged: it flashes instead of counting+ Color color; ///< whose it is, the colour the timer was registered with+ };+/// Ingame video playbackvirtual void playMovie( const AsciiString& movieName );virtual void stopMovie( void );@@ -902,6 +920,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+ void updateStripCameoSize( void ); ///< cameo box both strips draw into, in the command bar's aspect+ void drawStripSeconds( Int x, Int y, Int w, Int h, Int seconds ); ///< countdown written inside a cameo+ void addSuperweaponIcon( const Image *image, Int seconds, Int percent, Bool ready, Color color );+ void drawSuperweaponStrip( void ); ///< those icons, top right, soonest at the right hand endBool m_placementRangeRingUp; ///< we put a radius cursor up for a pending structure, so we owe a clearReal m_placementRingRadius; ///< the radius that ring was built at, so it is not rebuilt every frame@@ -947,6 +969,15 @@ protected:Int m_productionStripCameoW; ///< cameo size this frame, in the control bar's aspectInt m_productionStripCameoH;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++ //+ // The superweapon strip: the same cameos the command bar fires them from, in the top right+ // under the clock plate, rebuilt every frame from the timers below and laid out soonest first.+ //+ SuperweaponIconSlot m_superweaponIcons[ SUPERWEAPON_STRIP_MAX ];+ Int m_superweaponIconCount; ///< icons drawn+ Int m_superweaponIconTotal; ///< timers live, drawn or not; the difference is the "+N"Coord2D m_superweaponPosition;Real m_superweaponFlashDuration;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex ea0942f5e..bc3eae299 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -110,11 +110,12 @@ static const RGBColor illegalBuildColor = { 1.0, 0.0, 0.0 };// ------------------------------------------------------------------------------------------------enum{- PRODUCTION_STRIP_CAMEO = 32, ///< nominal cameo edge in pixels; the real one keeps this area- PRODUCTION_STRIP_GAP = 3, ///< space between cameos, and between the two rows+ PRODUCTION_STRIP_CAMEO = 16, ///< nominal cameo edge in pixels; the real one keeps this area+ PRODUCTION_STRIP_GAP = 2, ///< space between cameos, and between the two rowsPRODUCTION_STRIP_LEFT = 8, ///< inset from the left edge of the screenPRODUCTION_STRIP_LIFT = 24, ///< clearance above the control bar- PRODUCTION_STRIP_MORE = 34 ///< width kept for the "+N" that closes an overflowing row+ PRODUCTION_STRIP_MORE = 18, ///< width kept for the "+N" that closes an overflowing row+ PRODUCTION_STRIP_SECS = 7 ///< point size of the countdown written inside a cameo};//-------------------------------------------------------------------------------------------------@@ -128,6 +129,43 @@ static Int stripPixels( Int nominal )return REAL_TO_INT_CEIL( nominal * TheUIScale() );}+//-------------------------------------------------------------------------------------------------+/** A countdown short enough to be written inside a cameo: bare seconds while there are fewer than+ * sixty of them, m:ss once there are more. A tank takes seconds and a superweapon charges for+ * minutes, and both are written into the same little box. */+//-------------------------------------------------------------------------------------------------+static void formatStripSeconds( UnicodeString *text, Int seconds )+{+ if( seconds < 0 )+ seconds = 0;++ if( seconds < 60 )+ text->format( L"%d", seconds );+ else+ text->format( L"%d:%2.2d", seconds / 60, seconds % 60 );+}++//-------------------------------------------------------------------------------------------------+/** The cameo a special power is fired from. A SpecialPowerTemplate carries no art of its own -+ * the picture lives on whichever command button launches it - so the button list is what has to+ * be asked. A power with no button anywhere (a scripted one, a mod's) draws as an empty box+ * with its countdown in it, which is still the timer it was asked for. */+//-------------------------------------------------------------------------------------------------+static const Image *superweaponCameo( const SpecialPowerTemplate *powerTemplate )+{+ if( powerTemplate == NULL || TheControlBar == NULL )+ return NULL;++ for( const CommandButton *button = TheControlBar->getCommandButtons(); button;+ button = button->getNext() )+ {+ if( button->getSpecialPowerTemplate() == powerTemplate && button->getButtonImage() )+ return button->getButtonImage();+ }++ return NULL;+}+//-------------------------------------------------------------------------------------------------/** Pointer to show while a structure rides the cursor. Mouse::BUILD_PLACEMENT and* INVALID_BUILD_PLACEMENT are two names in CursorININames[] that no shipped Mouse.ini ever@@ -1104,6 +1142,9 @@ InGameUI::InGameUI()m_productionStripCameoW = PRODUCTION_STRIP_CAMEO;m_productionStripCameoH = PRODUCTION_STRIP_CAMEO;m_productionStripOverflow = NULL;+ m_stripSecondsString = NULL;+ m_superweaponIconCount = 0;+ m_superweaponIconTotal = 0;m_superweaponPosition.x = 0.7f;m_superweaponPosition.y = 0.7f;@@ -4116,48 +4157,26 @@ void InGameUI::postDraw( void )// want to display the timers -- Eva still needs to be checkedif (TheGameLogic->getFrame() > 0 ){-// Int superweaponCount = 0;- Int startX = (Int)(m_superweaponPosition.x * TheDisplay->getWidth());- Int startY = (Int)(m_superweaponPosition.y * TheDisplay->getHeight());-//- // The corner clock plate owns the top right, and the first timer was drawn straight- // underneath it - a superweapon counting down behind the readout is one nobody can read.- // The list starts below the plate whenever the plate is up.+ // The countdowns are cameos in the top right, not a column of names and clocks running down+ // over the battlefield. A superweapon is recognised by the picture it is fired from, a name+ // and a colon and a clock is a paragraph to read at a glance, and eight of them was a wall+ // of text over the terrain. Everything the loop below finds is gathered into one list and+ // laid out at the end of it, soonest first.//- if( TheGlobalData->m_showHudOverlay && startY < m_hudOverlayBottom + 4 )- startY = m_hudOverlayBottom + 4;-- Int bottomMargin = (Int)( (Real)TheTacticalView->getHeight() * 0.82f );---- Bool marginExceeded = FALSE;+ m_superweaponIconCount = 0;+ m_superweaponIconTotal = 0;for (Int i=0; i<MAX_PLAYER_COUNT; ++i){- Color bgColor = GameMakeColor( 0, 0, 0, 255 );for (SuperweaponMap::iterator mapIt = m_superweapons[i].begin(); mapIt != m_superweapons[i].end(); ++mapIt){- AsciiString templateName = mapIt->first;for (SuperweaponList::iterator listIt = mapIt->second.begin(); listIt != mapIt->second.end(); ++listIt){SuperweaponInfo *info = *listIt;DEBUG_ASSERTCRASH(info, ("No superweapon info!"));if (info && !info->m_hiddenByScript && !info->m_hiddenByScience){- //enforce bottom margin of tactical view- if ( startY >= bottomMargin)- {- UnicodeString ellipsis;- ellipsis.format(L"...");- info->setText( ellipsis, ellipsis );- info->setFont( m_superweaponReadyFont, m_superweaponNormalPointSize, m_superweaponNormalBold );- info->drawTime( startX, startY, m_superweaponFlashColor, bgColor );-- marginExceeded = TRUE;- }-Object * owningObject = TheGameLogic->findObjectByID(info->m_id);if (owningObject){@@ -4250,72 +4269,30 @@ void InGameUI::postDraw( void )info->m_evaReadyPlayed = false; // Reset Eva for next time}- // draw the text- if ( !m_superweaponHiddenByScript && !marginExceeded )+ // hand it to the strip+ if ( !m_superweaponHiddenByScript ){- // Similarly, only checking timers is not truly indicitive of readyness.- Bool changeBolding = (readySecs != info->m_timestamp) || (isReady != info->m_ready) || info->m_forceUpdateText;- if (changeBolding)- {- if (isReady)- {- // go bold - we're good to go- info->setFont( m_superweaponReadyFont, m_superweaponReadyPointSize, m_superweaponReadyBold );- }- else- {- // if we were at 0, we've just fired - kill the bold- if (info->m_timestamp == 0)- {- info->setFont( m_superweaponNormalFont, m_superweaponNormalPointSize, m_superweaponNormalBold );- }- }--- info->m_forceUpdateText = false;- info->m_ready = isReady;- info->m_timestamp = readySecs;- Int min = readySecs/60;- Int sec = readySecs - min*60;- AsciiString strIndex;- strIndex.format("GUI:%s", templateName.str());- UnicodeString name, time;- name.format(L"%ls: ", TheGameText->fetch(strIndex.str()).str());- time.format(L"%d:%2.2d", min, sec);- info->setText(name, time);+ info->m_forceUpdateText = false;+ info->m_ready = isReady;+ info->m_timestamp = readySecs;++ //+ // How far through the charge it is, for the radial sweep. The module knows the+ // frame it comes ready on and the template knows how long a whole charge takes,+ // and the difference between the two is everything that has already been paid.+ //+ const UnsignedInt reload = info->getSpecialPowerTemplate()->getReloadTime();+ Int percent = 100;+ if ( !isReady && reload > 0 )+ {+ const UnsignedInt left = ( module->getReadyFrame() > TheGameLogic->getFrame() )+ ? module->getReadyFrame() - TheGameLogic->getFrame() : 0;+ percent = ( left >= reload ) ? 0+ : REAL_TO_INT( 100.0f * (Real)( reload - left ) / (Real)reload );}- info->drawBackdrop( startX, startY );-- if (isReady)- {- if ( m_superweaponFlashDuration != 0.0f )- {- if ( TheGameLogic->getFrame() >= m_superweaponLastFlashFrame + (Int)(m_superweaponFlashDuration) )- {- m_superweaponUsedFlashColor = !m_superweaponUsedFlashColor;- m_superweaponLastFlashFrame = TheGameLogic->getFrame();- }- info->drawName( startX,- startY, (m_superweaponUsedFlashColor)?0:m_superweaponFlashColor, bgColor );- info->drawTime( startX,- startY, (m_superweaponUsedFlashColor)?0:m_superweaponFlashColor, bgColor );- }- else- {- info->drawName( startX, startY, 0, bgColor );- info->drawTime( startX, startY, 0, bgColor );- }- }- else- {- info->drawName( startX, startY, 0, bgColor );- info->drawTime( startX, startY, 0, bgColor );- }-- // increment text spot to next location- startY += info->getHeight();-+ addSuperweaponIcon( superweaponCameo( info->getSpecialPowerTemplate() ),+ readySecs, percent, isReady, info->getColor() );}if (info->getSpecialPowerTemplate()->isSharedNSync())break; // Wow, it is almost too easy!@@ -4330,6 +4307,8 @@ void InGameUI::postDraw( void )}}}++ drawSuperweaponStrip();}// draw named timers@@ -6064,6 +6043,231 @@ static const ProductionEntry *findStripEntry( ProductionUpdateInterface *pu,return NULL;}+//-------------------------------------------------------------------------------------------------+/** The cameo box both strips draw into.+ *+ * The same cameo art the command bar draws is not square, so drawing it into a square box+ * squashed it and the strip read as a different set of icons than the bar right below it. Take+ * the aspect from a real command button and keep the box's area at the nominal size, so a row+ * stays as long as it was: a wider cameo is a correspondingly shorter one. */+//-------------------------------------------------------------------------------------------------+void InGameUI::updateStripCameoSize( void )+{+ m_productionStripCameoW = stripPixels( PRODUCTION_STRIP_CAMEO );+ m_productionStripCameoH = stripPixels( PRODUCTION_STRIP_CAMEO );++ static NameKeyType commandButtonKey = TheNameKeyGenerator->nameToKey( "ControlBar.wnd:ButtonCommand01" );+ GameWindow *commandButton = TheWindowManager->winGetWindowFromId( NULL, commandButtonKey );+ if( commandButton == NULL )+ return;++ ICoord2D buttonSize;+ commandButton->winGetSize( &buttonSize.x, &buttonSize.y );+ if( buttonSize.x <= 0 || buttonSize.y <= 0 )+ return;++ const Real aspect = INT_TO_REAL( buttonSize.x ) / INT_TO_REAL( buttonSize.y );+ const Real area = INT_TO_REAL( m_productionStripCameoW * m_productionStripCameoH );+ m_productionStripCameoH = REAL_TO_INT_CEIL( (Real)sqrt( area / aspect ) );+ m_productionStripCameoW = REAL_TO_INT_CEIL( m_productionStripCameoH * aspect );+}++//-------------------------------------------------------------------------------------------------+/** Write a countdown inside a cameo. The radial sweep says how much of the whole is left, which+ * 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 )+{+ if( m_stripSecondsString == NULL )+ {+ m_stripSecondsString = TheDisplayStringManager->newDisplayString();+ m_stripSecondsString->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,+ TheGlobalLanguageData->adjustFontSize( PRODUCTION_STRIP_SECS ),+ TRUE ) );+ }++ UnicodeString text;+ formatStripSeconds( &text, seconds );+ m_stripSecondsString->setText( text );++ Int textWidth = 0, textHeight = 0;+ m_stripSecondsString->getSize( &textWidth, &textHeight );++ const Int textX = x + ( w - textWidth ) / 2;+ const Int textY = y + ( h - textHeight ) / 2;++ // 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 ) );+}++//-------------------------------------------------------------------------------------------------+/** Keep one superweapon timer for the strip, in a list sorted by how long it still has to wait -+ * soonest first. Everything live is counted; only the ones that will be drawn get a slot. */+//-------------------------------------------------------------------------------------------------+void InGameUI::addSuperweaponIcon( const Image *image, Int seconds, Int percent, Bool ready, Color color )+{+ m_superweaponIconTotal++;++ // walk back over the ones that come ready later than this and drop it in front of them; ties+ // keep the order they were met in, so a pair of identical silos stays put frame to frame+ Int at = m_superweaponIconCount;+ while( at > 0 && m_superweaponIcons[ at - 1 ].seconds > seconds )+ at--;++ if( at >= SUPERWEAPON_STRIP_MAX )+ return; // everything already kept is sooner: counted into the "+N", not drawn++ if( m_superweaponIconCount < SUPERWEAPON_STRIP_MAX )+ m_superweaponIconCount++;++ for( Int j = m_superweaponIconCount - 1; j > at; j-- )+ m_superweaponIcons[ j ] = m_superweaponIcons[ j - 1 ];++ SuperweaponIconSlot *slot = &m_superweaponIcons[ at ];+ slot->image = image;+ slot->seconds = seconds;+ slot->percent = percent;+ slot->ready = ready;+ slot->color = color;+}++//-------------------------------------------------------------------------------------------------+/** The superweapon strip: the cameos gathered this frame, top right, under the clock plate.+ *+ * Rows fill from the right, because the right hand end is where the strip is anchored and the+ * one countdown that matters is the next one to land - it is always in the same place, however+ * many are behind it. Three rows of six, and whatever is left over closes the last row as a+ * "+N", the same way the production strip's rows do. */+//-------------------------------------------------------------------------------------------------+void InGameUI::drawSuperweaponStrip( void )+{+ if( m_superweaponIconCount < 1 )+ return;++ if( TheGameLogic == NULL || !TheGameLogic->isInGame() || TheGameLogic->isInShellGame() )+ return;++ updateStripCameoSize();++ const Int cameoW = m_productionStripCameoW;+ const Int cameoH = m_productionStripCameoH;+ 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 );++ //+ // The corner clock plate owns the top right, so the strip starts under it whenever it is up -+ // a countdown drawn behind the readout is one nobody can read.+ //+ Int top = plate;+ if( TheGlobalData->m_showHudOverlay && m_hudOverlayBottom + plate > top )+ top = m_hudOverlayBottom + plate;++ //+ // one flash for the whole strip rather than one per icon, so every charged superweapon blinks+ // together instead of each on its own clock+ //+ if( m_superweaponFlashDuration != 0.0f &&+ TheGameLogic->getFrame() >= m_superweaponLastFlashFrame + (Int)(m_superweaponFlashDuration) )+ {+ m_superweaponUsedFlashColor = !m_superweaponUsedFlashColor;+ m_superweaponLastFlashFrame = TheGameLogic->getFrame();+ }++ const Int right = TheDisplay->getWidth() - edge;+ const Int hidden = m_superweaponIconTotal - m_superweaponIconCount;++ for( Int row = 0; row < SUPERWEAPON_STRIP_ROWS; row++ )+ {+ const Int first = row * SUPERWEAPON_STRIP_COLS;+ if( first >= m_superweaponIconCount )+ break;++ Int inRow = m_superweaponIconCount - first;+ if( inRow > SUPERWEAPON_STRIP_COLS )+ inRow = SUPERWEAPON_STRIP_COLS;++ const Bool lastRow = ( first + inRow >= m_superweaponIconCount );+ Int rowWidth = inRow * cameoW + ( inRow - 1 ) * gap;+ if( hidden > 0 && lastRow )+ rowWidth += gap + more;++ const Int y = top + row * ( cameoH + gap );++ // one plate behind the row, so the cameos read over any terrain+ TheDisplay->drawFillRect( right - rowWidth - plate, y - plate,+ rowWidth + 2 * plate, cameoH + 2 * plate,+ GameMakeColor( 0, 0, 0, 130 ) );++ for( Int i = 0; i < inRow; i++ )+ {+ const SuperweaponIconSlot *slot = &m_superweaponIcons[ first + i ];+ const Int x = right - cameoW - i * ( cameoW + gap );++ 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.+ //+ if( !slot->ready )+ {+ TheDisplay->drawRemainingRectClock( x, y, cameoW, cameoH, slot->percent,+ GameMakeColor( 0, 0, 0, 130 ) );+ drawStripSeconds( x, y, cameoW, cameoH, slot->seconds );+ }++ //+ // The border is whose weapon it is - the colour the timer was registered with - except+ // while it is charged, where it flashes: a ready superweapon is the one thing on this+ // strip that wants to be noticed rather than looked up.+ //+ Color border = slot->color;+ UnsignedByte r, g, b, a;+ GameGetColorComponents( border, &r, &g, &b, &a );+ border = GameMakeColor( r, g, b, 255 );+ if( slot->ready && !m_superweaponUsedFlashColor )+ border = m_superweaponFlashColor;++ TheDisplay->drawOpenRect( x, y, cameoW, cameoH, 2.0f, border );+ }++ //+ // whatever did not fit closes the last row as a "+N", on the left hand end: the strip is+ // read from the right, so the overflow sits at the far end of it+ //+ if( hidden > 0 && lastRow )+ {+ if( m_productionStripOverflow == NULL )+ {+ m_productionStripOverflow = TheDisplayStringManager->newDisplayString();+ m_productionStripOverflow->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,+ TheGlobalLanguageData->adjustFontSize( HUD_OVERLAY_POINT_SIZE ),+ TRUE ) );+ }++ UnicodeString text;+ text.format( L"+%d", hidden );+ m_productionStripOverflow->setText( text );++ Int textWidth = 0, textHeight = 0;+ m_productionStripOverflow->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 ) );+ }+ }+}+//-------------------------------------------------------------------------------------------------/** Lay out and draw one row, with its top edge at y. *///-------------------------------------------------------------------------------------------------@@ -6122,10 +6326,35 @@ void InGameUI::drawProductionStripRow( Int row, Int y )// nearly finished one looked alike. Only the head of a building's queue has progress;// everything behind it is waiting and wears the full scrim.//- const Int percent = ( pu->firstProduction() == entry )- ? REAL_TO_INT( entry->getPercentComplete() ) : 0;+ 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 ) );++ //+ // How long this one still has, written in the middle of it - but only for the item+ // actually being built. The ones behind it in the queue have no clock running: their+ // wait depends on everything in front of them, so a number there would be a guess.+ //+ if( building )+ {+ Player *player = producer->getControllingPlayer();+ Int totalFrames = 0;+ if( slot->isUpgrade )+ {+ if( entry->getProductionUpgrade() )+ totalFrames = entry->getProductionUpgrade()->calcTimeToBuild( player );+ }+ else if( entry->getProductionObject() )+ totalFrames = entry->getProductionObject()->calcTimeToBuild( player );++ 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 ) );+ }+ }}//@@ -6297,28 +6526,7 @@ void InGameUI::drawProductionStrip( void )barTop = barPos.y;}- //- // the same cameo art the command bar draws is not square, so drawing it into a square box- // squashed it and the strip read as a different set of icons than the bar right below it.- // Take the aspect from a real command button and keep the box's area at the nominal size, so- // the row stays as long as it was: a wider cameo is a correspondingly shorter one.- //- m_productionStripCameoW = stripPixels( PRODUCTION_STRIP_CAMEO );- m_productionStripCameoH = stripPixels( PRODUCTION_STRIP_CAMEO );- static NameKeyType commandButtonKey = TheNameKeyGenerator->nameToKey( "ControlBar.wnd:ButtonCommand01" );- GameWindow *commandButton = TheWindowManager->winGetWindowFromId( NULL, commandButtonKey );- if( commandButton )- {- ICoord2D buttonSize;- commandButton->winGetSize( &buttonSize.x, &buttonSize.y );- if( buttonSize.x > 0 && buttonSize.y > 0 )- {- const Real aspect = INT_TO_REAL( buttonSize.x ) / INT_TO_REAL( buttonSize.y );- const Real area = INT_TO_REAL( m_productionStripCameoW * m_productionStripCameoH );- m_productionStripCameoH = REAL_TO_INT_CEIL( (Real)sqrt( area / aspect ) );- m_productionStripCameoW = REAL_TO_INT_CEIL( m_productionStripCameoH * aspect );- }- }+ updateStripCameoSize();//// rows stack upwards from just above the control bar, last row nearest the bar: playing, thatdiff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cppindex 648996ea4..8e96d7db9 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp@@ -50,6 +50,7 @@// USER INCLUDES //////////////////////////////////////////////////////////////#include "GameClient/Gadget.h"+#include "GameClient/GameFont.h"#include "GameClient/GameWindowGlobal.h"#include "GameClient/GameWindowManager.h"#include "GameClient/GadgetPushButton.h"@@ -82,6 +83,31 @@ void W3DGadgetPushButtonImageDrawOne(GameWindow *window, WinInstanceData *instDa// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////+// getBadgeFont ===============================================================+/** The font the corner markings wear.+ *+ * A hotkey letter, a price, a countdown and a queue count are labels on a picture,+ * not text to be read at length: at the window's own point size four of them crowd+ * a button that is barely thirty pixels wide, and the button stops reading as its+ * own art. One step down from whatever font the button was given, so the markings+ * still follow the wnd file and the resolution exactly as the button does. */+//=============================================================================+static GameFont *getBadgeFont( GameWindow *window )+{+ GameFont *font = window->winGetFont();+ if( font == NULL )+ return NULL;++ Int pointSize = font->pointSize * 5 / 6;+ if( pointSize < 6 )+ pointSize = 6;+ if( pointSize >= font->pointSize )+ return font;++ return TheFontLibrary->getFont( font->nameString, pointSize, font->bold );++} // end getBadgeFont+// drawButtonText =============================================================/** Draw button text to the screen *///=============================================================================@@ -120,9 +146,13 @@ static void drawButtonText( GameWindow *window, WinInstanceData *instData )dropColor = window->winGetEnabledTextBorderColor();} // end enabled only- // set our font to that of our parent if not the same- if( text->getFont() != window->winGetFont() )- text->setFont( window->winGetFont() );+ // set our font to that of our parent if not the same - except the shortcut letter, which is a+ // corner marking and wears the marking font+ GameFont *font = window->winGetFont();+ if( BitTest( window->winGetStatus(), WIN_STATUS_SHORTCUT_BUTTON ) )+ font = getBadgeFont( window );+ if( font != NULL && text->getFont() != font )+ text->setFont( font );// get text sizetext->getSize( &width, &height );@@ -174,18 +204,23 @@ static void drawCountBadge( GameWindow *window, Int count )text.format( L"%d", count );badge->setText( text );- if( badge->getFont() != window->winGetFont() )- badge->setFont( window->winGetFont() );+ GameFont *font = getBadgeFont( window );+ if( font != NULL && badge->getFont() != font )+ badge->setFont( font );window->winGetScreenPosition( &origin.x, &origin.y );window->winGetSize( &size.x, &size.y );badge->getSize( &width, &height );- textPos.x = origin.x + size.x - width - 3;- textPos.y = origin.y + size.y - height - 1;+ // the plate is what the eye reads as the badge, so it is the plate that sits in the corner -+ // hanging it a few pixels short left a stripe of button art outside it and the three badges+ // looked scattered rather than pinned to the button+ const Int plateWidth = width + 4;+ textPos.x = origin.x + size.x - plateWidth + 2;+ textPos.y = origin.y + size.y - height;// same translucent plate the shortcut letter wears - button art can be any colour- TheDisplay->drawFillRect( textPos.x - 2, textPos.y, width + 4, height,+ TheDisplay->drawFillRect( textPos.x - 2, textPos.y, plateWidth, height,GameMakeColor( 0, 0, 0, 160 ) );badge->draw( textPos.x, textPos.y, GameMakeColor( 255, 255, 255, 255 ),GameMakeColor( 0, 0, 0, 255 ) );@@ -213,15 +248,16 @@ static void drawSecondsBadge( GameWindow *window, Int seconds )text.format( L"%ds", seconds );label->setText( text );- if( label->getFont() != window->winGetFont() )- label->setFont( window->winGetFont() );+ GameFont *font = getBadgeFont( window );+ if( font != NULL && label->getFont() != font )+ label->setFont( font );window->winGetScreenPosition( &origin.x, &origin.y );window->winGetSize( &size.x, &size.y );label->getSize( &width, &height );- textPos.x = origin.x + 3;- textPos.y = origin.y + size.y - height - 1;+ textPos.x = origin.x + 2;+ textPos.y = origin.y + size.y - height;// same translucent plate the count badge wears - button art can be any colourTheDisplay->drawFillRect( textPos.x - 2, textPos.y, width + 4, height,@@ -253,18 +289,20 @@ static void drawCostBadge( GameWindow *window, Int cost )text.format( L"$%d", cost );label->setText( text );- if( label->getFont() != window->winGetFont() )- label->setFont( window->winGetFont() );+ GameFont *font = getBadgeFont( window );+ if( font != NULL && label->getFont() != font )+ label->setFont( font );window->winGetScreenPosition( &origin.x, &origin.y );window->winGetSize( &size.x, &size.y );label->getSize( &width, &height );- textPos.x = origin.x + size.x - width - 3;- textPos.y = origin.y + 1;+ const Int plateWidth = width + 4;+ textPos.x = origin.x + size.x - plateWidth + 2;+ textPos.y = origin.y;// same translucent plate the other two badges wear - button art can be any colour- TheDisplay->drawFillRect( textPos.x - 2, textPos.y, width + 4, height,+ TheDisplay->drawFillRect( textPos.x - 2, textPos.y, plateWidth, height,GameMakeColor( 0, 0, 0, 160 ) );label->draw( textPos.x, textPos.y, GameMakeColor( 235, 210, 120, 255 ),GameMakeColor( 0, 0, 0, 255 ) );