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
fix(gameclient): tooltip weapons by target, button names, cards over the grid
Olcay Seygan693106c8827b
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex 0ec32af0e..66fa10592 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -962,6 +962,14 @@ TOOLTIP:StatNewWeapon"New weapon"END+TOOLTIP:StatNewWeaponGround+"Ground weapon"+END++TOOLTIP:StatNewWeaponAir+"Anti-air weapon"+END+TOOLTIP:StatNewWeaponFigures"%d damage, %d range"ENDdiff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex 9852162f1..48c20e230 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -15609,6 +15609,14 @@ TOOLTIP:StatNewWeapon"Yeni silah"END+TOOLTIP:StatNewWeaponGround+"Kara silahı"+END++TOOLTIP:StatNewWeaponAir+"Uçaksavar silahı"+END+TOOLTIP:StatNewWeaponFigures"%d hasar, %d menzil"ENDdiff --git a/GeneralsMD/Code/Data/Window/Html/Tooltip.html b/GeneralsMD/Code/Data/Window/Html/Tooltip.htmlindex 7fc3edb10..c92d9fc30 100644--- a/GeneralsMD/Code/Data/Window/Html/Tooltip.html+++ b/GeneralsMD/Code/Data/Window/Html/Tooltip.html@@ -57,7 +57,8 @@border-top-color: #aab4bf; border-left-color: #8a949f; }.china #box { background-color: #140806; border-top-color: #d98a72; border-left-color: #b8604b; }.gla #box { background-color: #121007; border-top-color: #cbbf82; border-left-color: #a99d62; }- #box.card { width: 210px; }+ /* wide enough for "Anti-air weapon: 50 damage, 317 range" on one line; at 210 the range wrapped */+ #box.card { width: 225px; }/* the card's header: the rail's steel, the name on it and the cost at its right hand end */.head { padding: 3px 6px 3px 6px; background: linear-gradient(to bottom, #7d8691, #3f4650);diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.hindex 010cc73c3..e764b7709 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h@@ -710,7 +710,7 @@ struct BuildTooltipCardReal attacksPerSecond; ///< shots a second over a whole clip and its reloadInt damagePerSecond;std::vector< BuildTooltipUpgrade > upgrades; ///< a unit's upgrades, or the units an upgrade changes- IRegion2D anchor; ///< the hovered window, in screen pixels+ IRegion2D anchor; ///< the hovered window in screen pixels, its top the grid's top for a command button};//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cppindex 5fa51a302..ab5b8a5b0 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp@@ -307,9 +307,15 @@ static void putChanges( const UnitFigures &from, const UnitFigures &to, const Upif( ( slot == main && main != WEAPONSLOT_COUNT && after.weapon ) || after.weapon == NULL || after.weapon == from.slots[ slot ].weapon )continue;+ // named by what it aims at, since TOW puts in one missile for the ground and one for the air+ const Int aims = after.weapon->getAntiMask();+ const Bool atGround = ( aims & WEAPON_ANTI_GROUND ) != 0;+ const Bool atAir = ( aims & WEAPON_ANTI_AIRBORNE_VEHICLE ) != 0;+ const char *label = atGround == atAir ? "TOOLTIP:StatNewWeapon" : ( atAir ? "TOOLTIP:StatNewWeaponAir" : "TOOLTIP:StatNewWeaponGround" );+UnicodeString figures;figures.format( TheGameText->fetch( "TOOLTIP:StatNewWeaponFigures" ), REAL_TO_INT( after.damage ), REAL_TO_INT( after.range ) );- const BuildTooltipChange weapon = { "TOOLTIP:StatNewWeapon", "", WideCharStringToMultiByte( figures.str() ) };+ const BuildTooltipChange weapon = { label, "", WideCharStringToMultiByte( figures.str() ) };changes.push_back( weapon );}@@ -335,6 +341,31 @@ static UpgradeEffect ownedEffect( const UpgradeEffects &effects, const Player *preturn owned;}+//-------------------------------------------------------------------------------------------------+/** What the build button that sells `upgrade` calls it, so a unit's card and the upgrade's own card+ * say the same name: the upgrade's own label reads "Ranger Flash-Bang Grenades" where its button+ * reads "Flash-Bang Grenades". The selection's own buttons first, since several buttons sell one+ * upgrade under labels that differ ("Flash-Bang Grenade" on one, "Grenades" on the Barracks'); then+ * any button; the upgrade's label when no button sells it. */+//-------------------------------------------------------------------------------------------------+static UnicodeString upgradeButtonName( const UpgradeTemplate *upgrade )+{+ const Drawable *selected = TheInGameUI->getFirstSelectedDrawable();+ const Object *seller = selected ? selected->getObject() : NULL;+ const CommandSet *set = seller ? TheControlBar->findCommandSet( seller->getCommandSetString() ) : NULL;+ for( Int slot = 0; set && slot < MAX_COMMANDS_PER_SET; ++slot )+ {+ const CommandButton *button = set->getCommandButton( slot );+ if( button && button->getUpgradeTemplate() == upgrade && button->getTextLabel().isNotEmpty() )+ return TheGameText->fetch( button->getTextLabel() );+ }++ for( const CommandButton *button = TheControlBar->getCommandButtons(); button; button = button->getNext() )+ if( button->getUpgradeTemplate() == upgrade && button->getTextLabel().isNotEmpty() )+ return TheGameText->fetch( button->getTextLabel() );+ return TheGameText->fetch( upgrade->getDisplayNameLabel() );+}+//-------------------------------------------------------------------------------------------------/** A unit's card: its figures with the upgrades the player owns, and each upgrade that changes one* of them with what it changes, from the figure without it to the figure with it. */@@ -364,7 +395,7 @@ static void putUnitFigures( BuildTooltipCard &card, const ThingTemplate *thing,continue;BuildTooltipUpgrade entry;- entry.name = TheGameText->fetch( upgrade->getDisplayNameLabel() );+ entry.name = upgradeButtonName( upgrade );entry.owned = player->hasUpgradeComplete( upgrade );UpgradeEffect without = ownedEffect( effects, player, effect->first );UpgradeEffect with = without;@@ -557,6 +588,21 @@ const BuildTooltipCard *ControlBar::getBuildTooltipCard( void )prevWindow->winGetSize( &width, &height );m_buildTooltipCard.anchor.hi.x = m_buildTooltipCard.anchor.lo.x + width;m_buildTooltipCard.anchor.hi.y = m_buildTooltipCard.anchor.lo.y + height;++ // a command button's card stands over the whole grid, the top row's top, so a bottom row+ // button's card does not come down over the buttons above it+ static const NameKeyType commandWindowKey = TheNameKeyGenerator->nameToKey( "ControlBar.wnd:CommandWindow" );+ GameWindow *grid = prevWindow->winGetParent();+ if( grid && grid->winGetWindowId() == commandWindowKey )+ {+ for( GameWindow *button = grid->winGetChild(); button; button = button->winGetNext() )+ {+ Int buttonX, buttonY;+ button->winGetScreenPosition( &buttonX, &buttonY );+ if( !button->winIsHidden() )+ m_buildTooltipCard.anchor.lo.y = min( m_buildTooltipCard.anchor.lo.y, buttonY );+ }+ }return &m_buildTooltipCard;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex f318f5b08..71bffc3c3 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -12746,7 +12746,7 @@ static void putBuildTooltipCard( const BuildTooltipCard &card, HtmlValues &valueconst BuildTooltipUpgrade &upgrade = card.upgrades[ each ];HtmlValues head;head[ "kind" ] = "upgrade";- head[ "name" ] = WideCharStringToMultiByte( upgrade.name.str() );+ head[ "name" ] = tooltipName( upgrade.name );head[ "owned" ] = upgrade.owned ? "owned" : "";upgrades.push_back( head );for( size_t change = 0; change < upgrade.changes.size(); ++change )