Skip to content

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.

feat(gameclient): top strip, left panel and ready feed for spectators

Olcay Seyganaad5facfb7e1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c2c4e6a23..92fe10afe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -478,9 +478,12 @@ found and fixed — EA's own, not port damage.**
- A general who has taken Artillery Barrage to level 3 shows one Artillery Barrage on the promotions strip, not three copies of the same picture in a row.
- 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 under the strips drop-down, built from the command bar's own steel: 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.
+- 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.
- 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.
+- When a superweapon comes ready, the left side says so for eight seconds: whose it is, its picture and its name, "ready to fire". The newest is at the bottom, four at most.
- Both are an ordinary web page with a stylesheet, in the game's Window folder. Change the colours, the sizes or the order there and the next match you watch draws it that way, and the page opens in a browser too.
- A minimised command bar stays minimised. Changing seats, or clicking another player's unit while watching, put the whole bar back up over the battlefield you had just cleared. A new match still opens with the bar up.
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.str
index baa71cd21..51b444bba 100644
--- a/GeneralsMD/Code/Data/Patch.str
+++ b/GeneralsMD/Code/Data/Patch.str
@@ -1098,6 +1098,11 @@ GUI:HudArmies
"Armies"
END
+// under a superweapon's name in the spectator's feed, the moment it can fire
+GUI:HudSuperweaponReady
+"ready to fire"
+END
+
// the scoreboard on Tab
GUI:ScoreboardAllies
"YOUR SIDE"
diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.str
index 269afae80..c08876545 100644
--- a/GeneralsMD/Code/Data/Turkish/Generals.str
+++ b/GeneralsMD/Code/Data/Turkish/Generals.str
@@ -15625,6 +15625,10 @@ GUI:HudArmies
"Ordular"
END
+GUI:HudSuperweaponReady
+"ateşe hazır"
+END
+
GUI:ScoreboardAllies
"TAKIMIN"
END
diff --git a/GeneralsMD/Code/Data/Window/Html/Spectator.html b/GeneralsMD/Code/Data/Window/Html/Spectator.html
index 4d51b0f71..39bdad956 100644
--- a/GeneralsMD/Code/Data/Window/Html/Spectator.html
+++ b/GeneralsMD/Code/Data/Window/Html/Spectator.html
@@ -1,16 +1,20 @@
<!DOCTYPE html>
<!--
- What a spectator sees over the battlefield: the drop-down that switches the strips, and the
- observer's board - every player ranked by a stat picked from a drop-down, the net worth lead on a
- radar screen, and what each army is made of. It is dressed in the command bar's own materials:
- steel plates with a light top edge and a dark bottom one, the cameo tray the production strips
- stand in, and the power bar's fills. Laid out by litehtml and drawn by the game
- (GameClient/HtmlOverlay.h).
-
- A CSS pixel is a pixel of an 800x600 screen and font-size is the game font's point size there;
- the page is scaled with the rest of the interface. Text is always drawn with a black shadow.
- url(Name) is one of the game's mapped images, stretched over the box. A background on html or
- body is for a browser only. Not drawn: rounded corners, overflow clipping, list bullets,
+ What a spectator sees over the battlefield, dressed in the command bar's own materials: steel
+ plates with a lit top edge and a dark bottom one, the cameo tray the production strips stand in,
+ the power bar's fills. The steel follows the side whose bar is on screen, so selecting a Chinese
+ unit turns it red. Four pieces:
+
+ #top every player across the top of the screen, grouped by team, the match clock between two teams
+ #hud-top the left panel: the strips drop-down, the superweapon countdowns and the promotions bought
+ #feed a superweapon coming ready, on the left for a few seconds, the way Dota's kill feed runs
+ #board the right panel: every player ranked by a picked stat, the lead graph, the armies
+
+ Laid out by litehtml and drawn by the game (GameClient/HtmlOverlay.h). A CSS pixel is a pixel of
+ an 800x600 screen and font-size is the game font's point size there; the page is scaled with the
+ rest of the interface. Text is always drawn with a black shadow. url(Name) is one of the game's
+ mapped images, drawn at the size background-size gives it and never clipped. A background on html
+ or body is for a browser only. Not drawn: rounded corners, overflow clipping, list bullets,
gradients other than linear ones, and text-transform on anything but plain ASCII letters.
The game fills in, before layout (GameClient/HtmlTemplate.h):
@@ -19,6 +23,8 @@
{{pick:group}} the choice last made with data-click="pick:group:choice"
{{pick:group:choice}} "on" while that is the choice; pick:stat:networth is on until another is made
{{text:Label}} a string table label, in the player's language
+ {{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
{{teams}} how many teams are left
{{lead}} {{leader}} how much net worth the leading team is ahead by, and "team0" or "team1"
@@ -28,8 +34,17 @@
{{portrait}} (a mapped image name, for <img src>)
data-each="lead", the first team's net worth less the second's since the start, up to 48
columns, with {{up}} or {{down}} as a percent of the biggest lead either way
- data-each="army", per player a {{kind}} "head" entry with his {{image}} and {{color}}, then up to
- six "unit" entries, the most money first, with the unit's {{image}} and {{count}}
+ data-each="top", every player grouped by team: {{kind}} "player" with {{image}} {{color}} {{name}}
+ {{team}} {{cash}} and {{power}} "brownout" while his power is short; between two teams one
+ entry of kind "clock", between any others one of kind "gap"
+ Three flat lists open each player's run with a {{kind}} "head" entry carrying {{image}} (his
+ general), {{color}} and {{name}}:
+ data-each="army", then up to six "unit" entries, the most money first, with {{image}} {{count}}
+ data-each="superweapons", then his countdowns, soonest first, "weapon" with {{image}} {{time}}
+ and {{ready}} "ready" once it can fire
+ data-each="skills", then his promotions, "skill" with {{image}}
+ data-each="toasts", the superweapons that came ready in the last eight seconds, oldest first:
+ {{portrait}} {{color}} {{name}} of the owner, {{image}} the weapon's cameo and {{what}} its name
The stats: networth, cash, income, army, kills, rank, power. A data-click of option:Key flips
that option and saves it; flip:name flips the name for the rest of the match; pick:group:choice
@@ -43,17 +58,49 @@
<title>Spectator</title>
<style>
html, body { margin: 0; padding: 0; }
+ body { background-color: #3b4a36; color: #dfe5ea; font-size: 9px; }
/* a mapped image is drawn at the size background-size gives it, and nothing clips it */
.tray, .cell, .fill, .on .box { background-size: 100% 100%; background-repeat: no-repeat; }
- body { background-color: #3b4a36; color: #dfe5ea; font-size: 9px; }
-
- #hud-top { position: absolute; left: 4px; top: 4px; width: 172px; }
- /* the command bar's steel: a lit top edge, a dark bottom one */
+ /* the command bar's steel, one per side: a lit top edge, a dark bottom one */
.plate { background: linear-gradient(to bottom, #6f7782, #3f4650); border-top: 1px solid #aab4bf;
border-left: 1px solid #8a949f; border-bottom: 1px solid #0c1114; border-right: 1px solid #1a2026; color: #f1f4f6; }
.plate:hover { background: linear-gradient(to bottom, #808995, #4b535e); }
+ .china .plate { background: linear-gradient(to bottom, #8e3b2b, #4c1b13); border-top-color: #d98a72; border-left-color: #b8604b; }
+ .china .plate:hover { background: linear-gradient(to bottom, #a44734, #5a2218); }
+ .gla .plate { background: linear-gradient(to bottom, #867a45, #48401e); border-top-color: #cbbf82; border-left-color: #a99d62; }
+ .gla .plate:hover { background: linear-gradient(to bottom, #978a50, #544a24); }
.well { background-color: rgba(9, 20, 23, 0.86); border: 1px solid #0c1114; border-top-color: #000000; }
+ .china .well { background-color: rgba(26, 10, 8, 0.86); }
+ .gla .well { background-color: rgba(22, 19, 8, 0.86); }
+ .tray, .cell { background-image: url(SATraySmall); }
+ .china .tray, .china .cell { background-image: url(SNTraySmall); }
+ .gla .tray, .gla .cell { background-image: url(SUTraySmall); }
+
+ .gold { color: #e8d27a; }
+ .title { padding: 2px 5px; color: #e8d27a; }
+
+ /* ---- the strip across the top ---- */
+ #top { position: absolute; left: 180px; right: 180px; top: 2px; text-align: center; }
+ /* one entry per seat ("tplayer"), and between two teams the clock ("tclock") or a gap ("tgap") */
+ .tplayer, .tclock, .tgap { display: inline-block; position: relative; vertical-align: top; }
+ .tplayer { width: 56px; height: 36px; margin: 0 1px; background-color: rgba(9, 20, 23, 0.7); }
+ .tclock { width: 52px; height: 20px; margin: 6px 4px 0 4px; }
+ .tgap { width: 8px; height: 36px; }
+ .tclock .tray, .tclock .tint, .tclock .who, .tclock .cash, .tgap .tray, .tgap .tint, .tgap .who, .tgap .cash { display: none; }
+ .clocktext { display: none; }
+ .tclock .clocktext { display: block; line-height: 18px; font-size: 11px; font-weight: bold; color: #e8d27a; }
+ .tplayer .tray { position: absolute; left: 14px; top: 2px; width: 28px; height: 18px; }
+ .tplayer .emblem { position: absolute; left: 4px; top: 3px; width: 20px; height: 12px; }
+ .tplayer .tint { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; }
+ .tplayer .who { position: absolute; left: 0; right: 0; top: 20px; font-size: 8px; line-height: 8px; }
+ .tplayer .cash { position: absolute; left: 0; right: 0; top: 27px; font-size: 7px; line-height: 7px; color: #e8d27a; }
+ .tplayer.brownout .cash { color: #ff7a5c; }
+ .team0 .tint { background-color: #b8f08a; }
+ .team1 .tint { background-color: #ff7a5c; }
+
+ /* ---- the left panel ---- */
+ #hud-top { position: absolute; left: 4px; top: 4px; width: 172px; }
.strips { margin-bottom: 3px; }
.strips .plate { padding: 2px 5px; }
@@ -64,7 +111,33 @@
.box { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border: 1px solid #778391; background-color: #091417; vertical-align: middle; }
.on .box { background-image: url(PowerBarGreen); border-color: #b8f08a; }
- .board { padding: 0 0 3px 0; }
+ .section { display: none; margin-bottom: 3px; padding-bottom: 3px; }
+ .section.on { display: block; }
+ .section .title { margin-bottom: 1px; }
+ .shelf { overflow: hidden; padding: 0 3px; }
+ .shelf .cell { float: left; position: relative; width: 22px; height: 19px; margin: 1px 1px 0 0; }
+ .shelf .cell img { position: absolute; left: 1px; top: 1px; width: 20px; height: 17px; }
+ .shelf .cell.head { clear: left; width: 24px; height: 16px; margin: 2px 3px 0 0; }
+ .shelf .cell.head img { left: 3px; top: 2px; width: 18px; height: 12px; }
+ .time { position: absolute; left: 1px; bottom: 0; font-size: 7px; line-height: 7px; font-weight: bold; color: #ffffff; background-color: rgba(0, 0, 0, 0.6); }
+ .weapon.ready .time { color: #b8f08a; }
+ .weapon.ready { background-image: url(PowerBarGreen); }
+ .skills .cell { width: 19px; height: 17px; }
+ .skills .cell img { width: 17px; height: 15px; }
+
+ /* ---- the feed on the left ---- */
+ #feed { width: 260px; }
+ .toast { position: relative; height: 18px; margin-bottom: 2px;
+ background: linear-gradient(to right, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0)); }
+ .toast .tray { position: absolute; left: 2px; top: 1px; width: 24px; height: 16px; }
+ .toast .emblem { position: absolute; left: 3px; top: 2px; width: 18px; height: 12px; }
+ .toast .who { position: absolute; left: 30px; top: 0; line-height: 18px; font-weight: bold; }
+ .toast .weapon { position: absolute; left: 100px; top: 1px; width: 20px; height: 16px; }
+ .toast .what { position: absolute; left: 124px; top: 0; line-height: 10px; color: #e8d27a; }
+ .toast .ready { position: absolute; left: 124px; top: 10px; line-height: 8px; font-size: 7px; color: #b8f08a; }
+
+ /* ---- the right panel ---- */
+ #board { position: absolute; right: 4px; top: 28px; width: 172px; padding: 0 0 3px 0; }
.head { height: 16px; padding: 0 3px; position: relative; }
.combo { position: absolute; left: 3px; right: 3px; top: 2px; height: 11px; line-height: 11px; padding-left: 5px; color: #b8f08a; }
.combo:hover { color: #ffffff; }
@@ -77,11 +150,10 @@
.choice { padding: 2px 6px; color: #c9d2d9; }
.choice:hover { color: #ffffff; background-color: rgba(119, 131, 145, 0.25); }
.choice.on { color: #b8f08a; }
- .choice.on .box { background-image: url(PowerBarGreen); border-color: #b8f08a; }
.players { margin: 2px 3px 0 3px; }
.player { position: relative; height: 18px; border-bottom: 1px solid rgba(119, 131, 145, 0.18); }
- .tray { position: absolute; left: 1px; top: 1px; width: 24px; height: 16px; background-image: url(SATraySmall); }
+ .player .tray { position: absolute; left: 1px; top: 1px; width: 24px; height: 16px; }
.emblem { position: absolute; left: 3px; top: 2px; width: 18px; height: 12px; }
.name { position: absolute; left: 30px; top: 1px; line-height: 10px; }
.value { position: absolute; right: 3px; top: 1px; line-height: 10px; font-weight: bold; color: #e8d27a; }
@@ -92,19 +164,18 @@
.buttons { height: 13px; margin: 3px 3px 0 3px; }
.button { float: left; width: 78px; height: 11px; line-height: 11px; text-align: center; margin-right: 2px; font-size: 8px; color: #c9d2d9; }
- .button.flipped { background: linear-gradient(to bottom, #3f4650, #6f7782); border-top-color: #0c1114; border-bottom-color: #aab4bf; color: #b8f08a; }
+ .button.flipped { color: #b8f08a; }
.panel { display: none; clear: both; margin: 3px 3px 0 3px; }
.panel.flipped { display: block; }
.graph.flipped { display: none; }
.graph.flipped.shown { display: block; }
- .title { padding: 2px 5px; color: #e8d27a; }
.lead { float: right; font-weight: bold; }
.team0 .lead { color: #b8f08a; }
.team1 .lead { color: #ff7a5c; }
/* the radar's screen */
- .radar { position: relative; height: 38px; margin: 0 4px 4px 4px; background-color: #06140b; border: 1px solid #000000; border-top-color: #000000; border-bottom-color: #3d4a3f; }
+ .radar { position: relative; height: 38px; margin: 0 4px 4px 4px; background-color: #06140b; border: 1px solid #000000; border-bottom-color: #3d4a3f; }
.grid { position: absolute; left: 0; right: 0; height: 1px; background-color: #0f2a17; }
.chart { position: absolute; left: 1px; top: 1px; }
.col { float: left; width: 3px; height: 36px; }
@@ -114,14 +185,26 @@
.down { position: absolute; left: 0; right: 1px; top: 0; background-color: #e0503c; }
.army { overflow: hidden; padding: 0 3px 3px 3px; }
- .cell { float: left; position: relative; width: 19px; height: 17px; margin: 1px 1px 0 0; background-image: url(SATraySmall); }
- .cell img { position: absolute; left: 1px; top: 1px; width: 17px; height: 15px; }
- .cell.head { clear: left; width: 24px; margin-right: 3px; }
- .cell.head img { left: 3px; top: 2px; width: 18px; height: 12px; }
+ .army .cell { float: left; position: relative; width: 19px; height: 17px; margin: 1px 1px 0 0; }
+ .army .cell img { position: absolute; left: 1px; top: 1px; width: 17px; height: 15px; }
+ .army .cell.head { clear: left; width: 24px; margin-right: 3px; }
+ .army .cell.head img { left: 3px; top: 2px; width: 18px; height: 12px; }
.count { position: absolute; right: 2px; bottom: 0; font-size: 8px; font-weight: bold; color: #ffffff; }
</style>
</head>
<body>
+<div class="{{side}}">
+
+<div id="top">
+ <div class="t{{kind}} team{{team}} {{power}}" data-each="top">
+ <div class="tray"><img class="emblem" src="{{image}}"></div>
+ <div class="tint"></div>
+ <div class="who" style="color: {{color}}">{{name}}</div>
+ <div class="cash">{{cash}}</div>
+ <div class="clocktext well">{{clock}}</div>
+ </div>
+</div>
+
<div id="hud-top">
<div class="strips {{flip:strips}}">
@@ -133,62 +216,91 @@
</div>
</div>
- <div class="board well">
- <div class="head plate">
- <div class="combo well" data-click="flip:stat">{{stat}}<span class="tab">&#9660;</span></div>
+ <div class="section well {{option:ShowSuperweaponStrip}}">
+ <div class="title">{{text:GUI:HudSuperweaponStrip}}</div>
+ <div class="shelf">
+ <div class="cell {{kind}} {{ready}}" data-each="superweapons">
+ <img src="{{image}}">
+ <span class="time">{{time}}</span>
+ </div>
</div>
+ </div>
- <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>
+ <div class="section well skills {{option:ShowSkillStrip}}">
+ <div class="title">{{text:GUI:HudSkillStrip}}</div>
+ <div class="shelf">
+ <div class="cell {{kind}}" data-each="skills"><img src="{{image}}"></div>
</div>
+ </div>
- <div class="players">
- <div class="player teams{{teams}} team{{team}}" data-each="players">
- <div class="tray"><img class="emblem" src="{{portrait}}"></div>
- <span class="name" style="color: {{color}}">{{name}}</span>
- <span class="value">{{value}}</span>
- <div class="meter"><div class="fill" style="width: {{share}}%; background-color: {{color}}"></div></div>
- </div>
+ <div id="feed">
+ <div class="toast" data-each="toasts">
+ <div class="tray"><img class="emblem" src="{{portrait}}"></div>
+ <span class="who" style="color: {{color}}">{{name}}</span>
+ <img class="weapon" src="{{image}}">
+ <span class="what">{{what}}</span>
+ <span class="ready">{{text:GUI:HudSuperweaponReady}}</span>
+ </div>
+ </div>
+
+</div>
+
+<div id="board" class="well">
+ <div class="head plate">
+ <div class="combo well" data-click="flip:stat">{{stat}}<span class="tab">&#9660;</span></div>
+ </div>
+
+ <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>
+ </div>
- <div class="buttons">
- <div class="button plate {{flip:graph}}" data-click="flip:graph">{{text:GUI:HudNetWorthLead}}</div>
- <div class="button plate {{flip:army}}" data-click="flip:army">{{text:GUI:HudArmies}}</div>
+ <div class="players">
+ <div class="player teams{{teams}} team{{team}}" data-each="players">
+ <div class="tray"><img class="emblem" src="{{portrait}}"></div>
+ <span class="name" style="color: {{color}}">{{name}}</span>
+ <span class="value">{{value}}</span>
+ <div class="meter"><div class="fill" style="width: {{share}}%; background-color: {{color}}"></div></div>
</div>
+ </div>
- <div class="panel graph well {{graph}} {{flip:graph}}">
- <div class="title {{leader}}">{{text:GUI:HudNetWorthLead}}<span class="lead">{{lead}}</span></div>
- <div class="radar">
- <div class="grid" style="top: 9px"></div>
- <div class="grid" style="top: 27px"></div>
- <div class="chart">
- <div class="col" data-each="lead">
- <div class="half over"><div class="up" style="height: {{up}}%"></div></div>
- <div class="half"><div class="down" style="height: {{down}}%"></div></div>
- </div>
+ <div class="buttons">
+ <div class="button plate {{flip:graph}}" data-click="flip:graph">{{text:GUI:HudNetWorthLead}}</div>
+ <div class="button plate {{flip:army}}" data-click="flip:army">{{text:GUI:HudArmies}}</div>
+ </div>
+
+ <div class="panel graph well {{graph}} {{flip:graph}}">
+ <div class="title {{leader}}">{{text:GUI:HudNetWorthLead}}<span class="lead">{{lead}}</span></div>
+ <div class="radar">
+ <div class="grid" style="top: 9px"></div>
+ <div class="grid" style="top: 27px"></div>
+ <div class="chart">
+ <div class="col" data-each="lead">
+ <div class="half over"><div class="up" style="height: {{up}}%"></div></div>
+ <div class="half"><div class="down" style="height: {{down}}%"></div></div>
</div>
</div>
</div>
+ </div>
- <div class="panel well {{flip:army}}">
- <div class="title">{{text:GUI:HudArmies}}</div>
- <div class="army">
- <div class="cell {{kind}}" data-each="army">
- <img src="{{image}}">
- <span class="count">{{count}}</span>
- </div>
+ <div class="panel well {{flip:army}}">
+ <div class="title">{{text:GUI:HudArmies}}</div>
+ <div class="army">
+ <div class="cell {{kind}}" data-each="army">
+ <img src="{{image}}">
+ <span class="count">{{count}}</span>
</div>
</div>
</div>
+</div>
</div>
</body>
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index 431b495a1..a6a441b39 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -326,7 +326,14 @@ public:
typedef std::list< WorldAnimationData *> WorldAnimationList;
typedef WorldAnimationList::iterator WorldAnimationListIterator;
-
+/** One superweapon countdown as the spectator page lists it: whose, and how long it still has. */
+struct SpectatorSuperweapon
+{
+ Int playerIndex;
+ const Image *cameo;
+ Int seconds;
+ Bool ready;
+};
// ------------------------------------------------------------------------------------------------
/** Basic functionality common to all in-game user interfaces */
@@ -1217,6 +1224,16 @@ protected:
UnsignedInt m_spectatorLeadFrame; ///< the logic frame the last of those was taken on
Int m_hudTogglesBottom; ///< the bottom of the page's #hud-top, so the message list starts under it
+ std::vector< SpectatorSuperweapon > m_spectatorSuperweapons; ///< every countdown the superweapon pass found, rebuilt each pass
+ /** A superweapon that came ready, on the page for SPECTATOR_TOAST_FRAMES after that. */
+ struct SpectatorToast
+ {
+ HtmlValues values;
+ UnsignedInt until; ///< the logic frame it leaves on
+ };
+ std::vector< SpectatorToast > m_spectatorToasts;
+ void addSpectatorToast( Int playerIndex, const Object *weapon, const Image *cameo );
+
Bool m_placementRangeRingUp; ///< the structure on the cursor is armed, so its reach is drawn
Real m_placementRingRadius; ///< how far from its centre it hits
void drawPlacementReach( void ); ///< while placing, the reach of every armed building in sight, as one outline
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index ac07559e4..6a74b99f0 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -55,6 +55,7 @@
#include "GameClient/Anim2D.h"
#include "GameClient/ControlBar.h"
+#include "GameClient/ControlBarScheme.h"
#include "GameClient/DisplayStringManager.h"
#include "GameClient/Diplomacy.h"
#include "GameClient/Eva.h"
@@ -1763,6 +1764,10 @@ enum
LEAD_GRAPH_COLUMNS = 48, ///< the most columns the graph draws; a longer match is averaged into them
ARMY_CHART_UNITS = 6, ///< kinds of unit shown per player, the most money first
PLAYER_NAME_CHARS = 11, ///< a name longer than this is cut, there is no clipping to hide it
+ SECONDS_IN_MINUTE = 60,
+ SECONDS_PER_HOUR = 60 * 60,
+ SPECTATOR_TOAST_FRAMES = LOGICFRAMES_PER_SECOND * 8, ///< how long a "superweapon ready" message stays up
+ SPECTATOR_TOASTS_KEPT = 4, ///< the most of those on screen at once; the oldest goes first
TWO_TEAMS = 2,
PERCENT = 100
};
@@ -2049,6 +2054,184 @@ void InGameUI::sampleSpectatorLead( Int lead, Bool twoTeams )
m_spectatorLeadFrame = frame;
}
+static Int gatherPlayerSkills( const Player *player, const Image **icons, Int count, Int max );
+
+//-------------------------------------------------------------------------------------------------
+/** The class the page dresses itself in: the side whose command bar is on screen, "america",
+ * "china" or "gla". The observer bar is America's art under a name of its own, and a watcher who
+ * selects a unit gets its owner's bar, so this follows whoever is being watched. */
+//-------------------------------------------------------------------------------------------------
+static std::string spectatorSide( void )
+{
+ ControlBarSchemeManager *schemes = TheControlBar ? TheControlBar->getControlBarSchemeManager() : NULL;
+ if( schemes == NULL )
+ return "america";
+
+ AsciiString side = schemes->getCurrentSide();
+ if( side == "Observer" )
+ side = schemes->getCurrentArtTwinSide();
+ if( side.startsWith( "China" ) || side == "Boss" )
+ return "china";
+ if( side.startsWith( "GLA" ) )
+ return "gla";
+ return "america";
+}
+
+/** A player's name as the page writes it, cut where there is no clipping to hide the rest. */
+static std::string spectatorName( Player *player )
+{
+ std::wstring name( player->getPlayerDisplayName().str() );
+ if( name.size() > PLAYER_NAME_CHARS )
+ name.resize( PLAYER_NAME_CHARS );
+ return WideCharStringToMultiByte( name.c_str() );
+}
+
+/** The entry that opens a player's run in a flat list: kind "head", his general and his colour. */
+static HtmlValues spectatorHead( Player *player )
+{
+ const PlayerTemplate *side = player->getPlayerTemplate();
+ const Image *portrait = side ? side->getEnabledImage() : NULL;
+
+ HtmlValues head;
+ head[ "kind" ] = "head";
+ head[ "image" ] = portrait ? portrait->getName().str() : "";
+ head[ "color" ] = cssColor( clientPlayerColor( player ) );
+ head[ "name" ] = spectatorName( player );
+ return head;
+}
+
+/** m:ss of match time, or h:mm:ss once it runs past the hour. */
+static std::string spectatorClock( UnsignedInt frame )
+{
+ const UnsignedInt seconds = frame / LOGICFRAMES_PER_SECOND;
+ char text[ sizeof( "000:00:00" ) ];
+ if( seconds >= SECONDS_PER_HOUR )
+ sprintf( text, "%u:%02u:%02u", seconds / SECONDS_PER_HOUR, seconds / SECONDS_IN_MINUTE % SECONDS_IN_MINUTE, seconds % SECONDS_IN_MINUTE );
+ else
+ sprintf( text, "%u:%02u", seconds / SECONDS_IN_MINUTE, seconds % SECONDS_IN_MINUTE );
+ return text;
+}
+
+//-------------------------------------------------------------------------------------------------
+/** The page's "top" list, the strip across the top of the screen: every player grouped by team,
+ * each with kind "player", and between two teams an entry of kind "clock" - or kind "gap" between
+ * any others, so a free for all reads as separate seats. */
+//-------------------------------------------------------------------------------------------------
+static void fillSpectatorTop( std::vector< SpectatorStats > players, std::vector< HtmlValues > &entries )
+{
+ std::stable_sort( players.begin(), players.end(),
+ []( const SpectatorStats &a, const SpectatorStats &b ) { return a.team < b.team; } );
+
+ entries.clear();
+ for( size_t index = 0; index < players.size(); index++ )
+ {
+ const SpectatorStats &stats = players[ index ];
+ if( index > 0 && players[ index - 1 ].team != stats.team )
+ {
+ HtmlValues between;
+ between[ "kind" ] = stats.team == 1 && players.back().team == 1 ? "clock" : "gap";
+ entries.push_back( between );
+ }
+
+ HtmlValues entry = spectatorHead( stats.player );
+ entry[ "kind" ] = "player";
+ entry[ "team" ] = std::to_string( stats.team );
+ entry[ "cash" ] = std::to_string( stats.cash );
+ entry[ "power" ] = stats.power < 0 ? "brownout" : "";
+ entries.push_back( entry );
+ }
+}
+
+//-------------------------------------------------------------------------------------------------
+/** The page's "superweapons" list: per player who has one, a head entry and then his countdowns,
+ * soonest first, each of kind "weapon" with its cameo, {{time}} and {{ready}} "ready" once it can
+ * fire. Players come in the order `players` has them. */
+//-------------------------------------------------------------------------------------------------
+static void fillSpectatorSuperweapons( const std::vector< SpectatorStats > &players,
+ std::vector< SpectatorSuperweapon > weapons,
+ std::vector< HtmlValues > &cells )
+{
+ std::stable_sort( weapons.begin(), weapons.end(),
+ []( const SpectatorSuperweapon &a, const SpectatorSuperweapon &b ) { return a.seconds < b.seconds; } );
+
+ cells.clear();
+ for( size_t index = 0; index < players.size(); index++ )
+ {
+ const Int owner = players[ index ].player->getPlayerIndex();
+ Bool headed = FALSE;
+ for( size_t weapon = 0; weapon < weapons.size(); weapon++ )
+ {
+ if( weapons[ weapon ].playerIndex != owner )
+ continue;
+ if( !headed )
+ cells.push_back( spectatorHead( players[ index ].player ) );
+ headed = TRUE;
+
+ UnicodeString time;
+ formatStripSeconds( &time, weapons[ weapon ].seconds );
+ HtmlValues cell;
+ cell[ "kind" ] = "weapon";
+ cell[ "image" ] = weapons[ weapon ].cameo ? weapons[ weapon ].cameo->getName().str() : "";
+ cell[ "time" ] = WideCharStringToMultiByte( time.str() );
+ cell[ "ready" ] = weapons[ weapon ].ready ? "ready" : "";
+ cells.push_back( cell );
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------
+/** The page's "skills" list: per player who has bought any, a head entry and then each promotion
+ * at the level it has reached, of kind "skill" with its cameo. */
+//-------------------------------------------------------------------------------------------------
+static void fillSpectatorSkills( const std::vector< SpectatorStats > &players, std::vector< HtmlValues > &cells )
+{
+ enum { SKILLS_SHOWN = 12 };
+
+ cells.clear();
+ for( size_t index = 0; index < players.size(); index++ )
+ {
+ const Image *icons[ SKILLS_SHOWN ];
+ const Int count = gatherPlayerSkills( players[ index ].player, icons, 0, SKILLS_SHOWN );
+ if( count == 0 )
+ continue;
+
+ cells.push_back( spectatorHead( players[ index ].player ) );
+ for( Int skill = 0; skill < count; skill++ )
+ {
+ HtmlValues cell;
+ cell[ "kind" ] = "skill";
+ cell[ "image" ] = icons[ skill ]->getName().str();
+ cells.push_back( cell );
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------
+/** A superweapon of player `playerIndex` came ready: the page says so on its left edge for
+ * SPECTATOR_TOAST_FRAMES, newest at the bottom, the way Dota's kill feed runs. Only a watcher's
+ * page draws them, so nobody else collects any. */
+//-------------------------------------------------------------------------------------------------
+void InGameUI::addSpectatorToast( Int playerIndex, const Object *weapon, const Image *cameo )
+{
+ Player *owner = ThePlayerList->getNthPlayer( playerIndex );
+ if( owner == NULL || weapon == NULL || !localPlayerWatching() )
+ return;
+
+ SpectatorToast toast;
+ toast.values = spectatorHead( owner );
+ toast.values[ "kind" ] = "toast";
+ toast.values[ "portrait" ] = toast.values[ "image" ];
+ toast.values[ "image" ] = cameo ? cameo->getName().str() : "";
+ toast.values[ "what" ] = WideCharStringToMultiByte( weapon->getTemplate()->getDisplayName().str() );
+ toast.until = TheGameLogic->getFrame() + SPECTATOR_TOAST_FRAMES;
+
+ DEBUG_LOG(( "Spectator page: %s is ready for player %d on frame %u\n", weapon->getTemplate()->getName().str(),
+ playerIndex, TheGameLogic->getFrame() ));
+ m_spectatorToasts.push_back( toast );
+ if( m_spectatorToasts.size() > SPECTATOR_TOASTS_KEPT )
+ m_spectatorToasts.erase( m_spectatorToasts.begin() );
+}
+
//-------------------------------------------------------------------------------------------------
/** 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
@@ -2098,6 +2281,9 @@ void InGameUI::drawSpectatorPage( void )
const std::vector< SpectatorStats > players = gatherSpectatorStats( stat, teams );
fillSpectatorPlayers( players, stat, teams, m_spectatorLists[ "players" ] );
fillSpectatorArmies( players, m_spectatorLists[ "army" ] );
+ fillSpectatorTop( players, m_spectatorLists[ "top" ] );
+ fillSpectatorSuperweapons( players, m_spectatorSuperweapons, m_spectatorLists[ "superweapons" ] );
+ fillSpectatorSkills( players, m_spectatorLists[ "skills" ] );
Int lead = 0;
for( size_t index = 0; index < players.size(); index++ )
@@ -2112,9 +2298,26 @@ void InGameUI::drawSpectatorPage( void )
m_spectatorTotals[ "lead" ] = std::to_string( abs( lead ) );
m_spectatorTotals[ "leader" ] = lead == 0 ? "" : ( lead > 0 ? "team0" : "team1" );
m_spectatorTotals[ "graph" ] = teams == TWO_TEAMS && m_spectatorLead.size() >= TWO_TEAMS ? "shown" : "";
+ m_spectatorTotals[ "side" ] = spectatorSide();
+ m_spectatorTotals[ "clock" ] = spectatorClock( frame );
m_spectatorListsFrame = frame;
}
+ // the messages come and go on their own clock, not the lists' half second
+ std::vector< HtmlValues > &toasts = m_spectatorLists[ "toasts" ];
+ toasts.clear();
+ for( size_t toast = 0; toast < m_spectatorToasts.size(); )
+ {
+ const SpectatorToast &shown = m_spectatorToasts[ toast ];
+ if( frame >= shown.until || frame + SPECTATOR_TOAST_FRAMES < shown.until )
+ {
+ m_spectatorToasts.erase( m_spectatorToasts.begin() + toast );
+ continue;
+ }
+ toasts.push_back( shown.values );
+ toast++;
+ }
+
HtmlValues values = m_spectatorTotals;
for( std::map< std::string, std::string >::const_iterator pick = m_spectatorPicked.begin(); pick != m_spectatorPicked.end(); ++pick )
{
@@ -3617,6 +3820,8 @@ void InGameUI::reset( void )
m_spectatorTotals.clear();
m_spectatorLead.clear();
m_spectatorLeadFrame = 0;
+ m_spectatorSuperweapons.clear();
+ m_spectatorToasts.clear();
m_inputEnabled = true;
// reset the command bar
TheControlBar->reset();
@@ -6975,6 +7180,7 @@ void InGameUI::postDraw( void )
//
m_superweaponIconCount = 0;
m_superweaponIconTotal = 0;
+ m_spectatorSuperweapons.clear();
for (Int i=0; i<MAX_PLAYER_COUNT; ++i)
{
@@ -7017,6 +7223,8 @@ void InGameUI::postDraw( void )
{
if ( TheGameLogic->getFrame() > 0 )
{
+ addSpectatorToast( i, owningObject, superweaponCameo( info->getSpecialPowerTemplate() ) );
+
SpecialPowerType type = module->getSpecialPowerTemplate()->getSpecialPowerType();
Player *localPlayer = ThePlayerList->getLocalPlayer();
@@ -7102,6 +7310,8 @@ void InGameUI::postDraw( void )
addSuperweaponIcon( superweaponCameo( info->getSpecialPowerTemplate() ),
readySecs, percent, isReady, info->getColor() );
+ SpectatorSuperweapon listed = { i, superweaponCameo( info->getSpecialPowerTemplate() ), readySecs, isReady };
+ m_spectatorSuperweapons.push_back( listed );
}
if (info->getSpecialPowerTemplate()->isSharedNSync())
break; // Wow, it is almost too easy!
@@ -9259,7 +9469,8 @@ void InGameUI::addSuperweaponIcon( const Image *image, Int seconds, Int percent,
//-------------------------------------------------------------------------------------------------
void InGameUI::drawSuperweaponStrip( void )
{
- if( m_superweaponIconCount < 1 || stripSwitchedOff( &GlobalData::m_showSuperweaponStrip ) )
+ // watching, the spectator page's left panel lists the countdowns instead
+ if( m_superweaponIconCount < 1 || stripSwitchedOff( &GlobalData::m_showSuperweaponStrip ) || m_spectatorPageShown )
return;
if( TheGameLogic == NULL || !TheGameLogic->isInGame() || TheGameLogic->isInShellGame() )
@@ -9537,7 +9748,8 @@ static Int gatherPlayerSkills( const Player *player, const Image **icons, Int co
//-------------------------------------------------------------------------------------------------
void InGameUI::drawSkillStrip( void )
{
- if( stripSwitchedOff( &GlobalData::m_showSkillStrip ) )
+ // the spectator page's left panel lists them instead; the page's flag is the last frame's here
+ if( stripSwitchedOff( &GlobalData::m_showSkillStrip ) || m_spectatorPageShown )
return;
if( TheGameLogic == NULL || !TheGameLogic->isInGame() || TheGameLogic->isInShellGame() )
return;