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.

fix(gameclient): observer portrait health, side column scale, radar

Olcay Seygan344d9eb6ad3c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e497d22a8..f3afae2d9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -688,6 +688,7 @@ A third pass went through the generals' powers, promotions and unit abilities.
- 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.
- A superweapon coming ready or being fired is a line of that feed: whose it is, its picture and its name, then "ready to fire" in green or "launched" in red. Only a watcher used to be told, and only when one came ready.
- The feed also says when a general's power is used, when a promotion is bought, and when a superweapon, a Strategy Center, a Propaganda Center or a Palace goes up and when it is finished, each with its picture. A player is told that about himself and his allies, a watcher about everybody; a finished superweapon is told to everybody, as the announcer already did. A Spectre Gunship called from three command centers on the same frame is one line, not three. A player whose last dozer dies, or last worker for the GLA, gets a line too, since he can build nothing more until he makes another.
+- Watching, the selected unit's health shows beside its portrait again, and the right-hand column (the camera and follow drop-downs, the board, the armies) and the replay strip are drawn at the command bar's scale, about 30% smaller than they were, so one HUD Size setting sizes all of it. Clicking or dragging the radar while the camera is on Director or Player used to be undone a moment later by the automatic camera; the click takes the camera now and it stays where you put it.
- Chat sits in the bottom left corner over the event feed, with room left for the whole feed so neither covers the other, the way Dota writes it: each line opens on the speaker's general's flag and his name in his colour. A conversation stays up for ten seconds after its last line and then fades out as one. Enter talks to your team and Shift+Enter to everybody, in a dark typing bar under the lines that says whom it goes to, with the last eight lines kept up while you type. The next Enter after sending opens the chat again straight away. Watchers can chat now as well, and so can a player who has been beaten; what they write reaches the other watchers and never the players still fighting.
- 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/Window/Html/Spectator.html b/GeneralsMD/Code/Data/Window/Html/Spectator.html
index d5d809951..405266ee7 100644
--- a/GeneralsMD/Code/Data/Window/Html/Spectator.html
+++ b/GeneralsMD/Code/Data/Window/Html/Spectator.html
@@ -87,9 +87,10 @@
.on .box { background-image: url(PowerBarGreen); border-color: #b8f08a; }
/* ---- the right column: the camera, and under it the board ---- */
- /* under ControlBar.html's #net, 37px tall with the network line a player knocked out of an
- online match still gets */
- #right { position: absolute; right: 4px; top: 40px; width: 172px; }
+ /* under Net.html's #net, 37px tall with the network line a player knocked out of an online match
+ still gets. That page is drawn a console scale over 0.7 and this one at the console's, so its
+ 37px are 53 of these: 57 keeps the column where 40 put it before this page took the console's scale */
+ #right { position: absolute; right: 4px; top: 57px; width: 172px; }
#watch { padding: 0 0 1px 0; margin-bottom: 4px; }
#board { padding: 0 0 3px 0; }
.head { height: 16px; padding: 0 3px; position: relative; }
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
index 0ac5e0000..4d7ab34c6 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@@ -3354,7 +3354,12 @@ void ControlBar::update( void )
}
Object *obj = drawToEvaluateFor ? drawToEvaluateFor->getObject() : NULL;
setPortraitByObject( obj );
-
+
+ // the observer never reaches evaluateContextUI, so this is what keeps the context drawable
+ // (the HUD's name and health readout) on the selection; onDrawableDeselected drops it when
+ // its drawable dies before the next pass gets here
+ m_currentSelectedDrawable = drawToEvaluateFor;
+
return;
}
@@ -3591,6 +3596,11 @@ void ControlBar::onDrawableDeselected( Drawable *draw )
// set a dirty flag so next time we update we can reconstruct the UI
markUIDirty();
+ // a dying drawable is deselected and then freed inside the logic frame, and the next client
+ // pass draws the HUD (InGameUI's getContextDrawable) before update can re-evaluate - drop it now
+ if( m_currentSelectedDrawable == draw )
+ m_currentSelectedDrawable = NULL;
+
if (TheInGameUI->getSelectCount() == 0)
{
// we just deselected everything - cancel any pending GUI commands
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp
index 988d7db79..23c35c0b6 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp
@@ -52,6 +52,7 @@
#include "GameClient/GameWindowManager.h"
#include "GameClient/LanguageFilter.h"
#include "GameClient/CommandXlat.h"
+#include "GameClient/ObserverCamera.h"
#include "GameLogic/GameLogic.h"
#include "GameLogic/ScriptEngine.h"
@@ -89,6 +90,17 @@ static Bool radarPixelToWorld( const ICoord2D *pixel, Coord3D *world )
TheRadar->radarToWorld( &radar, world );
}
+//-------------------------------------------------------------------------------------------------
+/** The camera to the spot under the radar. A watcher's camera is his from then on: left with the
+ * director or a player's screen it was eased straight back, a click less than a jump away and every
+ * step of a drag (ObserverCamera.h). */
+//-------------------------------------------------------------------------------------------------
+static void radarLookAt( const Coord3D *world )
+{
+ TheTacticalView->lookAt( world );
+ TheObserverCamera.setMode( OBSERVER_CAMERA_FREE );
+}
+
//-------------------------------------------------------------------------------------------------
/** Input procedure for the left HUD */
@@ -286,7 +298,7 @@ WindowMsgHandledType LeftHUDInput( GameWindow *window, UnsignedInt msg,
Coord3D world;
if( radarPixelToWorld( &mouse, &world ) )
- TheTacticalView->lookAt( &world );
+ radarLookAt( &world );
break;
}
@@ -327,7 +339,7 @@ WindowMsgHandledType LeftHUDInput( GameWindow *window, UnsignedInt msg,
// Left on the radar looks and right orders, the same division the world has.
if( drawableList->empty() || msg == GWM_LEFT_DOWN )
{
- TheTacticalView->lookAt( &world );
+ radarLookAt( &world );
s_radarLookDrag = (msg == GWM_LEFT_DOWN) ? GWM_LEFT_DRAG : GWM_RIGHT_DRAG;
break;
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index a9e1b74d4..e3c146688 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -2286,7 +2286,7 @@ static void fillReplayValues( HtmlValues &values, Int floor )
// Spectator.html's #replay with its padding and its borders, and a gap under it
enum { REPLAY_STRIP_WIDTH = 322, REPLAY_STRIP_HEIGHT = 52 };
- const Real scale = ControlBarHudPageScale();
+ const Real scale = ControlBarHudScale();
const UnsignedInt frame = TheGameLogic->getFrame();
const UnsignedInt length = replayLength();
values[ "replay" ] = "on";
@@ -2531,7 +2531,9 @@ void InGameUI::drawSpectatorPage( void )
if( m_spectatorOverlay == NULL )
{
m_spectatorOverlay = new HtmlOverlay( m_superweaponNormalFont );
- m_spectatorOverlay->setHudPage( TRUE );
+ // the console's own scale: the column and the replay strip standing on the console were left
+ // at the old size when the console was cut to CONTROL_BAR_HUD_PERCENT
+ m_spectatorOverlay->setHud( TRUE );
}
// a unit selected turns the page to his side's steel the same frame, not half a second on
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp
index 30d8210f3..d5c9bf2c6 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp
@@ -70,8 +70,9 @@ static const UnsignedInt DIRECTOR_SIGHT_FRAMES = 8 * LOGICFRAMES_PER_SECOND;
static const size_t DIRECTOR_SEEN_COUNT = 3;
/// further apart than this the camera cuts rather than pans: a pan across the map shows nothing
static const Real CUT_DISTANCE = 700.0f;
-/// the camera found further than this from where it was put was moved by something else, the radar
-/// most likely; the edge of the map pulls it back by less
+/// the camera found further than this from where it was put was moved by something else, a click on
+/// the production strip or a jump to a group; the edge of the map pulls it back by less. The radar
+/// hands the camera over itself, since a click near the camera and a drag both move it by less
static const Real HAND_JUMP_DISTANCE = 400.0f;
/// how quickly the camera closes on where it is going, in seconds to cover about two thirds of it
static const Real DIRECTOR_PAN_SECONDS = 0.35f;