Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(gameclient): the command bar's top row picks the spectator's stat
Olcay Seygan53111d7e19c1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 92fe10afe..5362f55d7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -479,7 +479,7 @@ found and fixed — EA's own, not port damage.**- The strips close up again: across a row the trays slide an eighth of a tray under each other, so a row reads as one run of metal. The cameos never overlap each other, because every tray goes down before any picture does.- Watching, the strips can be switched off. A small "Strips" drop-down in the top left corner opens into three boxes - the production queue, the generals' promotions and the superweapon timers - and each box switches its strip the moment it is clicked and is remembered for the next match you watch. The message list moves down to start under it. Playing, there is no drop-down and every strip is up, whatever you chose in the stands.- Watching, an observer's board sits on the right of the screen, built from the command bar's own steel, and the steel is the watched side's: grey for America, red for China, sand for GLA, changing when you select a unit of another side: every player's general in the same metal tray the production strip uses, his name in his colour, the number in gold, and under it a bar filled the way the power bar is, green for one side and red for the other in a two-sided match and each player's own colour in a free for all. It opens on net worth, the cash in hand plus what everything the player has standing would cost to build again, counted twice a second, richest first.-- The number the board ranks by is yours to pick from the drop-down at its top: net worth, cash, income per minute, army value, kills and losses, the general's rank and power. The list re-sorts the moment you choose.+- The number the board ranks by is yours to pick from the drop-down at its top: net worth, cash, income per minute, army value, kills and losses, the general's rank and power. The list re-sorts the moment you choose. The command bar's top row of keys picks them too while you watch, Q W E R T Y U, or Q E R T Y U I with the WASD camera, and the drop-down writes each stat's key beside it.- Two buttons under the list. One opens the net worth lead since the first minute on a green radar screen, the first team's lead rising above the line and the second's falling below it in red, with how far ahead the leader is right now; it needs a match with two sides. The other opens the armies: every player's six most expensive kinds of unit in cameo trays, with how many of each he has on the field.- Across the top, every player in the match, grouped by team with the match clock between two teams: his general, his name, his cash, and the cash in red while his power is short.- The superweapon countdowns and the promotions each general has bought moved into a panel on the left, one row per player with his general at the head of it, where they used to be two strips down the right-hand edge.diff --git a/GeneralsMD/Code/Data/Window/Html/Spectator.html b/GeneralsMD/Code/Data/Window/Html/Spectator.htmlindex 39bdad956..a49d96c14 100644--- a/GeneralsMD/Code/Data/Window/Html/Spectator.html+++ b/GeneralsMD/Code/Data/Window/Html/Spectator.html@@ -26,6 +26,7 @@{{side}} "america", "china" or "gla": the side whose command bar is on screen{{clock}} the match time, m:ss{{stat}} the label of the picked stat+ {{statkey:stat}} the key that picks that stat: the command bar's top row, "Q" and so on{{teams}} how many teams are left{{lead}} {{leader}} how much net worth the leading team is ahead by, and "team0" or "team1"{{graph}} "shown" once two teams have a lead worth drawing@@ -150,6 +151,9 @@.choice { padding: 2px 6px; color: #c9d2d9; }.choice:hover { color: #ffffff; background-color: rgba(119, 131, 145, 0.25); }.choice.on { color: #b8f08a; }+ /* the command bar's top row picks a stat while watching, and {{statkey:stat}} is its key */+ .choice { position: relative; }+ .key { position: absolute; right: 6px; top: 2px; color: #8a949f; font-size: 8px; }.players { margin: 2px 3px 0 3px; }.player { position: relative; height: 18px; border-bottom: 1px solid rgba(119, 131, 145, 0.18); }@@ -253,13 +257,13 @@<div class="{{flip:stat}}"><div class="choices well"><div class="caption">{{text:GUI:HudGameStats}}</div>- <div class="choice {{pick:stat:networth}}" data-click="pick:stat:networth"><span class="box"></span>{{text:GUI:HudNetWorth}}</div>- <div class="choice {{pick:stat:cash}}" data-click="pick:stat:cash"><span class="box"></span>{{text:GUI:HudStatCash}}</div>- <div class="choice {{pick:stat:income}}" data-click="pick:stat:income"><span class="box"></span>{{text:GUI:HudStatIncome}}</div>- <div class="choice {{pick:stat:army}}" data-click="pick:stat:army"><span class="box"></span>{{text:GUI:HudStatArmy}}</div>- <div class="choice {{pick:stat:kills}}" data-click="pick:stat:kills"><span class="box"></span>{{text:GUI:HudStatKills}}</div>- <div class="choice {{pick:stat:rank}}" data-click="pick:stat:rank"><span class="box"></span>{{text:GUI:HudStatRank}}</div>- <div class="choice {{pick:stat:power}}" data-click="pick:stat:power"><span class="box"></span>{{text:GUI:HudStatPower}}</div>+ <div class="choice {{pick:stat:networth}}" data-click="pick:stat:networth"><span class="box"></span>{{text:GUI:HudNetWorth}}<span class="key">{{statkey:networth}}</span></div>+ <div class="choice {{pick:stat:cash}}" data-click="pick:stat:cash"><span class="box"></span>{{text:GUI:HudStatCash}}<span class="key">{{statkey:cash}}</span></div>+ <div class="choice {{pick:stat:income}}" data-click="pick:stat:income"><span class="box"></span>{{text:GUI:HudStatIncome}}<span class="key">{{statkey:income}}</span></div>+ <div class="choice {{pick:stat:army}}" data-click="pick:stat:army"><span class="box"></span>{{text:GUI:HudStatArmy}}<span class="key">{{statkey:army}}</span></div>+ <div class="choice {{pick:stat:kills}}" data-click="pick:stat:kills"><span class="box"></span>{{text:GUI:HudStatKills}}<span class="key">{{statkey:kills}}</span></div>+ <div class="choice {{pick:stat:rank}}" data-click="pick:stat:rank"><span class="box"></span>{{text:GUI:HudStatRank}}<span class="key">{{statkey:rank}}</span></div>+ <div class="choice {{pick:stat:power}}" data-click="pick:stat:power"><span class="box"></span>{{text:GUI:HudStatPower}}<span class="key">{{statkey:power}}</span></div></div></div>diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex a6a441b39..e24898ecd 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -400,6 +400,7 @@ public: // ********************************************************************virtual void message( AsciiString stringManagerLabel, ... );///< display a message to the uservirtual void toggleMessages( void ) { m_messagesOn = 1 - m_messagesOn; } ///< toggle messages on/offvoid toggleScoreboard( void ) { m_scoreboardOpen = !m_scoreboardOpen; } ///< the Tab scoreboard, on or off+ Bool pickSpectatorStat( Int commandSlot ); ///< a command bar key while watching: TRUE when it picked a statvoid drawScoreboard( void ); ///< that scoreboard, over everythingvirtual Bool isMessagesOn( void ) { return m_messagesOn; } ///< are the display messages onvoid freeMessageResources( void ); ///< free resources for the ui messagesdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 6a74b99f0..64bd8e067 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -56,6 +56,7 @@#include "GameClient/Anim2D.h"#include "GameClient/ControlBar.h"#include "GameClient/ControlBarScheme.h"+#include "GameClient/MetaEvent.h"#include "GameClient/DisplayStringManager.h"#include "GameClient/Diplomacy.h"#include "GameClient/Eva.h"@@ -1768,6 +1769,7 @@ enumSECONDS_PER_HOUR = 60 * 60,SPECTATOR_TOAST_FRAMES = LOGICFRAMES_PER_SECOND * 8, ///< how long a "superweapon ready" message stays upSPECTATOR_TOASTS_KEPT = 4, ///< the most of those on screen at once; the oldest goes first+ COMMAND_SLOTS_PER_COLUMN = 2, ///< the command bar numbers its slots down each column, top then bottomTWO_TEAMS = 2,PERCENT = 100};@@ -2232,6 +2234,43 @@ void InGameUI::addSpectatorToast( Int playerIndex, const Object *weapon, const Im_spectatorToasts.erase( m_spectatorToasts.begin() );}+//-------------------------------------------------------------------------------------------------+/** The key a command bar slot is bound to right now, "Q" for KEY_Q, so the page names the key the+ * player really has: the WASD camera moves the whole top row along by one. Empty when unbound. */+//-------------------------------------------------------------------------------------------------+static std::string commandSlotKey( Int commandSlot )+{+ static const std::string KEY_PREFIX = "KEY_";+ const GameMessage::Type meta = (GameMessage::Type)( GameMessage::MSG_META_COMMAND_SLOT01 + commandSlot );+ for( const MetaMapRec *map = TheMetaMap ? TheMetaMap->getFirstMetaMapRec() : NULL; map; map = map->m_next )+ {+ if( map->m_meta != meta )+ continue;+ for( const LookupListRec *key = KeyNames; key->name; key++ )+ if( key->value == map->m_key )+ return std::string( key->name ).substr( KEY_PREFIX.size() );+ }+ return std::string();+}++//-------------------------------------------------------------------------------------------------+/** The command bar's top row while the spectator page is up: slots 1, 3, 5... - Q, W, E, R, T, Y,+ * U by default, Q, E, R, T, Y, U, I with the WASD camera - pick the stats in the order the+ * drop-down lists them, and {{statkey:stat}} names each one's key. The bottom row and anything+ * past the last stat are left to the command bar. */+//-------------------------------------------------------------------------------------------------+Bool InGameUI::pickSpectatorStat( Int commandSlot )+{+ const Int stat = commandSlot / COMMAND_SLOTS_PER_COLUMN;+ if( !m_spectatorPageShown || commandSlot % COMMAND_SLOTS_PER_COLUMN != 0 || stat >= (Int)ARRAY_SIZE( SPECTATOR_STATS ) )+ return FALSE;++ m_spectatorPicked[ STAT_GROUP ] = SPECTATOR_STATS[ stat ].key;+ m_spectatorFlipped.erase( STAT_GROUP );+ m_spectatorLists.clear();+ return TRUE;+}+//-------------------------------------------------------------------------------------------------/** The spectator's page: the drop-down that switches the strips on and off, every player ranked by* the number picked in the stat drop-down, the net worth lead over the match and each army's most@@ -2300,6 +2339,8 @@ void InGameUI::drawSpectatorPage( void )m_spectatorTotals[ "graph" ] = teams == TWO_TEAMS && m_spectatorLead.size() >= TWO_TEAMS ? "shown" : "";m_spectatorTotals[ "side" ] = spectatorSide();m_spectatorTotals[ "clock" ] = spectatorClock( frame );+ for( Int each = 0; each < (Int)ARRAY_SIZE( SPECTATOR_STATS ); each++ )+ m_spectatorTotals[ std::string( "statkey:" ) + SPECTATOR_STATS[ each ].key ] = commandSlotKey( each * COMMAND_SLOTS_PER_COLUMN );m_spectatorListsFrame = frame;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cppindex 0fd60a808..7a98b860b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp@@ -2860,7 +2860,11 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessagecase GameMessage::MSG_META_COMMAND_SLOT13:case GameMessage::MSG_META_COMMAND_SLOT14:{- TheControlBar->pressCommandButton( t - GameMessage::MSG_META_COMMAND_SLOT01 );+ // a watcher has no commands to press, and the top row picks the spectator's stat instead,+ // the keys Dota's spectator uses for the same list+ const Int slot = t - GameMessage::MSG_META_COMMAND_SLOT01;+ if( !TheInGameUI->pickSpectatorStat( slot ) )+ TheControlBar->pressCommandButton( slot );disp = DESTROY_MESSAGE;break;} // end command bar grid slots