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 owner's HUD layout for players
Olcay Seygan04064b7bb1d2
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex 7f1c1ec29..a8d1ea945 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -1112,6 +1112,25 @@ GUI:BarBeacon"Beacon"END+// opens and folds away the general's powers ready to fire, over the portrait+GUI:BarSkills+"Skills"+END++// the network box in the top right corner: frames ready out of the input delay, the room's frame+// rate, and the traffic in and out in kilobytes a second+GUI:BarNetReady+"ready"+END++GUI:BarNetRoom+"room"+END++GUI:BarNetUnits+"units"+END+// the box in the corner of the radar that lights while your forces are under attackGUI:BarUnderAttack"UNDER ATTACK"diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex a8c51f81a..6a0f33e85 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -15637,6 +15637,22 @@ GUI:BarBeacon"İşaret"END+GUI:BarSkills+"Yetenekler"+END++GUI:BarNetReady+"hazır"+END++GUI:BarNetRoom+"oda"+END++GUI:BarNetUnits+"birim"+END+GUI:BarUnderAttack"SALDIRI ALTINDA"ENDdiff --git a/GeneralsMD/Code/Data/Window/Html/ControlBar.html b/GeneralsMD/Code/Data/Window/Html/ControlBar.htmlindex f9969c1ab..fc7faa939 100644--- a/GeneralsMD/Code/Data/Window/Html/ControlBar.html+++ b/GeneralsMD/Code/Data/Window/Html/ControlBar.html@@ -21,6 +21,19 @@"yellow" or "red"; the watched player's while watchingdata-each="powercells" the same production as 40 cells, each {{lit}} "lit" up to it, standing at{{x}} pixels inside the frame's lip and {{w}} wide+ {{skillsbutton.x}} ... the skills button's place in the right panel's corner; data-click+ "flip:skills" folds the general's powers away and back, and+ {{flip:skills}} is "flipped" while they are folded+ data-each="skillcells" the grid's nine empty places behind the powers, each {{cell.x}} .y .w .h;+ none while the skills button has them folded away+ {{signals.x}} ... the column of smoke signal buttons against the left panel;+ data-click="signal:attack", "signal:defend" or "signal:look" sends one+ to the middle of the view, and {{signals}} is "disabled" where the keys+ would do nothing either+ {{net.clock}} ... the network box: net.clock, net.game, net.real, net.hz, net.fps,+ net.renderer and net.frame always; net.ready, net.runahead, net.room,+ net.in and net.out with {{net.online}} "online" in a network game;+ net.units and net.cap with {{net.capped}} "capped" under a unit limit{{blink}} "lit" for half of every second, for anything that blinks{{panelN.x}} .y .w .h N 0 to 2, left, centre and right: where the plates would have gone,moving with the bar when it slides or minimises; .w and .h are 0 and@@ -38,7 +51,7 @@and {{Name.state}} any of "disabled", "hilite", "pushed", for LeftHUD (theradar), RightHUD (the portrait's box), CameoWindow (the portrait),CommandWindow, MoneyDisplay, PowerWindow, GeneralsExp, ButtonGeneral,- ButtonLarge (minimise), ButtonOptions, ButtonIdleWorker, ButtonPlaceBeacon,+ ButtonLarge (the minimise button, stood down), ButtonOptions, ButtonIdleWorker, ButtonPlaceBeacon,PopupCommunicator and WinUAttack (the under-attack light: "disabled" whileit is lit, which is how the bar blinks it)All in the page's pixels, a pixel of an 800x600 screen. Without this page the plates draw.@@ -141,6 +154,31 @@.alert { position: absolute; left: 4px; top: -15px; height: 13px; line-height: 13px; padding: 0 6px; font-size: 7px; font-weight: bold;color: #5a2a24; background-color: rgba(20, 8, 6, 0.9); border: 1px solid #4a1a14; border-bottom: 0; }.alert.disabled { color: #ffffff; background: linear-gradient(to bottom, #ff6a50, #b0200f); border-color: #ffb0a0; }++ /* the skills button is lit while the powers are out, and dark once folded away; the grid's empty+ places stand behind the powers, and go with them */+ .skills.flipped { color: #6f7782; }+ .skillcell { margin: 1px 0 0 1px; }++ /* the smoke signals, a column of square caps against the radar panel; greyed where the keys would+ do nothing either, outside a multiplayer game */+ /* each button stands at its own top: a relatively placed box inside an absolutely placed one is+ laid out from the screen's corner here, and the column came out in the top left */+ .signals .signal { position: absolute; left: 0; width: 37px; height: 21px; font-size: 7px; }+ .signals.disabled .signal { color: #6f7782; }+ .signal.attack { border-left: 3px solid #e0503c; }+ .signal.defend { border-left: 3px solid #5a9ee0; }+ .signal.look { border-left: 3px solid #e8d27a; }++ /* the network box: everything the corner readout had, flush in the screen's top right corner */+ #net { right: 0; top: 0; padding: 3px 6px 3px 8px; border-right: 0; font-size: 7px; color: #c9d2d9; text-align: right; }+ #net .line { line-height: 10px; white-space: nowrap; }+ #net .big { font-size: 9px; font-weight: bold; color: #e8d27a; }+ #net .dim { color: #7d8a93; }+ #net .onlineonly { display: none; }+ #net.online .onlineonly { display: block; }+ #net .cappedonly { display: none; }+ #net .cappedonly.capped { display: block; }</style></head><body>@@ -182,7 +220,15 @@<div class="piece button {{ButtonPlaceBeacon.shown}} {{ButtonPlaceBeacon.state}}" style="left: {{ButtonPlaceBeacon.x}}px; top: {{ButtonPlaceBeacon.y}}px; width: {{ButtonPlaceBeacon.w}}px; height: {{ButtonPlaceBeacon.h}}px"><div class="cap">{{text:GUI:BarBeacon}}</div></div><div class="piece button promotion {{promotion}} {{blink}} {{ButtonGeneral.shown}} {{ButtonGeneral.state}}" style="left: {{ButtonGeneral.x}}px; top: {{ButtonGeneral.y}}px; width: {{ButtonGeneral.w}}px; height: {{ButtonGeneral.h}}px"><div class="cap stars">★★★</div></div>- <div class="piece button {{ButtonLarge.shown}} {{ButtonLarge.state}}" style="left: {{ButtonLarge.x}}px; top: {{ButtonLarge.y}}px; width: {{ButtonLarge.w}}px; height: {{ButtonLarge.h}}px"><div class="cap">▼</div></div>+ <div class="piece button skills {{skillsbutton.shown}} {{flip:skills}}" data-click="flip:skills" style="left: {{skillsbutton.x}}px; top: {{skillsbutton.y}}px; width: {{skillsbutton.w}}px; height: {{skillsbutton.h}}px"><div class="cap">{{text:GUI:BarSkills}}</div></div>++ <div class="piece signals {{signals.shown}} {{signals}}" style="left: {{signals.x}}px; top: {{signals.y}}px; width: {{signals.w}}px; height: {{signals.h}}px">+ <div class="button signal attack" data-click="signal:attack" style="top: 0"><div class="cap">{{text:GUI:SignalAttackLabel}}</div></div>+ <div class="button signal defend" data-click="signal:defend" style="top: 24px"><div class="cap">{{text:GUI:SignalDefendLabel}}</div></div>+ <div class="button signal look" data-click="signal:look" style="top: 48px"><div class="cap">{{text:GUI:SignalAttentionLabel}}</div></div>+ </div>++ <div class="piece skillcell well" data-each="skillcells" style="left: {{cell.x}}px; top: {{cell.y}}px; width: {{cell.w}}px; height: {{cell.h}}px"></div><div class="piece button menu {{ButtonOptions.state}}" data-click="press:ButtonOptions"><div class="bar" style="top: 4px"></div>@@ -190,6 +236,13 @@<div class="bar" style="top: 10px"></div></div>+ <div id="net" class="piece panel {{net.online}}">+ <div class="line"><span class="big">{{net.clock}}</span> {{net.game}} <span class="dim">({{net.real}})</span></div>+ <div class="line">{{net.hz}}hz {{net.fps}}fps <span class="dim">{{net.renderer}} frame {{net.frame}}</span></div>+ <div class="line onlineonly">{{text:GUI:BarNetReady}} {{net.ready}}/{{net.runahead}} {{text:GUI:BarNetRoom}} {{net.room}}fps <span class="dim">↓{{net.in}} ↑{{net.out}} KB/s</span></div>+ <div class="line cappedonly {{net.capped}}">{{net.units}}/{{net.cap}} {{text:GUI:BarNetUnits}}</div>+ </div>+</div></body></html>diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.hindex 17446cda9..929050434 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h@@ -988,8 +988,17 @@ public:Bool letsClickThrough( GameWindow *window, Int x, Int y );/** The screen rectangles the bar's CSS page drew solid, which take the place of the plates in- * letsClickThrough while the page is drawing; NULL when it is not, and the plates decide again. */- void setPageSolids( const std::vector< IRegion2D > *solids );+ * letsClickThrough while the page is drawing; NULL when it is not, and the plates decide again.+ * `holes` are the page's own buttons: a click on one goes through to the page even inside a+ * solid panel. */+ void setPageSolids( const std::vector< IRegion2D > *solids, const std::vector< IRegion2D > *holes = NULL );++ /** The HUD page's place for the general's powers: the bar laid out as rows of+ * SPECIAL_POWER_SHORTCUT_COLS filling `area`'s width, the first row at the top, standing on+ * `area`'s bottom edge so more rows grow upward; its top is not read. NULL hides it. Screen+ * pixels. Asked every frame the page draws, so it holds against the bar's own layout. `cell`,+ * when given, is set to one cell's size, 0 by 0 while there is no bar to lay out. */+ void placeSpecialPowerShortcutGrid( const IRegion2D *area, ICoord2D *cell = NULL );/// the general's stars are asking to be spent, so the button blinks; see getStarImageBool isGeneralStarFlashing( void ) const { return m_genStarFlash; }@@ -1319,6 +1328,8 @@ protected:Player *m_observerLookAtPlayer; ///< The current player we're looking at, Null if we're not looking at anyone.AsciiString m_watchedSide; ///< the side the bar is wearing while watching, so a selection change only lays it out again when it really changes sidestd::vector< IRegion2D > m_pageSolids; ///< what the CSS page drew solid, in screen pixels; see setPageSolids+ std::vector< IRegion2D > m_pageHoles; ///< the page's own buttons, which let their clicks through+ ICoord2D m_shippedShortcutSlot; ///< the powers bar's slot as its layout shipped it, before the page's grid resized itBool m_pageSolidsActive; ///< the page is drawing, so m_pageSolids decides clicks and not the platesPlayer *m_watchedSelection; ///< the player the selection last named while watching, NULL for nobodydiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex 0c5b274cc..778119010 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -1208,6 +1208,7 @@ protected:HtmlOverlay * m_controlBarOverlay;Bool m_controlBarPageLoaded;Bool m_controlBarPageShown; ///< drawn this frame, so its buttons can be clicked+ std::set< std::string > m_controlBarFlipped; ///< names a data-click="flip:name" on that page has flippedstd::string m_controlBarPage;//@@ -1247,6 +1248,7 @@ protected:void drawBlindSpots( void ); ///< shade the ground a placed or selected defence cannot shoot intoDisplayString * m_hudDisplayString; ///< the ShowHudOverlay line (fps / clock)+ HtmlValues m_hudValues; ///< that line's readings one by one, for the command bar page's network boxDisplayString * m_peaceTimeDisplayString; ///< the peace time clock at the top of the screenDisplayString * m_peaceTimeLabelDisplayString; ///< the word written over that clockDisplayString * m_peaceCountdownDisplayString; ///< the big digit of its last ten secondsdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex f913fce25..e2f515292 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -1385,6 +1385,7 @@ ControlBar::ControlBar( void )m_remainingRadarAttackGlowFrames = 0;m_radarAttackGlowWindow = NULL;m_pageSolidsActive = FALSE;+ m_shippedShortcutSlot.x = m_shippedShortcutSlot.y = 0;#if defined( _INTERNAL ) || defined( _DEBUG )m_lastFrameMarkedDirty = 0;@@ -1912,13 +1913,17 @@ static const std::vector<UnsignedByte> &plateMask( const ControlBarPlate *plate}//--------------------------------------------------------------------------------------------------void ControlBar::setPageSolids( const std::vector< IRegion2D > *solids )+void ControlBar::setPageSolids( const std::vector< IRegion2D > *solids, const std::vector< IRegion2D > *holes ){m_pageSolidsActive = solids != NULL;if( solids )m_pageSolids = *solids;elsem_pageSolids.clear();+ if( holes )+ m_pageHoles = *holes;+ else+ m_pageHoles.clear();}//-------------------------------------------------------------------------------------------------@@ -1939,6 +1944,14 @@ Bool ControlBar::letsClickThrough( GameWindow *window, Int x, Int y )// spans the whole centre - would otherwise keep a click on bare battlefieldif( m_pageSolidsActive ){+ // the page's own buttons hand their clicks on to the page, which takes them as clicks on+ // the world, even where they stand on a solid panel+ for( size_t hole = 0; hole < m_pageHoles.size(); hole++ )+ {+ const IRegion2D &rect = m_pageHoles[ hole ];+ if( x >= rect.lo.x && y >= rect.lo.y && x < rect.hi.x && y < rect.hi.y )+ return TRUE;+ }for( size_t solid = 0; solid < m_pageSolids.size(); solid++ ){const IRegion2D &rect = m_pageSolids[ solid ];@@ -6029,6 +6042,7 @@ void ControlBar::initSpecialPowershortcutBar( Player *player)m_specialPowerShortcutButtonParents[i] = NULL;m_specialPowerShortcutButtons[i] = NULL;}+ m_shippedShortcutSlot.x = m_shippedShortcutSlot.y = 0; // a new layout, measured afreshif(m_specialPowerLayout){@@ -6184,6 +6198,72 @@ void ControlBar::arrangeSpecialPowerShortcutGrid( void )m_specialPowerShortcutButtonParents[ j ]->winBringToTop();}+//-------------------------------------------------------------------------------------------------+void ControlBar::placeSpecialPowerShortcutGrid( const IRegion2D *area, ICoord2D *cell )+{+ if( cell )+ cell->x = cell->y = 0;+ if( m_specialPowerShortcutParent == NULL || m_specialPowerShortcutButtonParents[ 0 ] == NULL )+ return;++ // the cell keeps the tray's own proportions, read off the first slot the layout shipped - once,+ // since the grid below resizes that slot every frame+ if( m_shippedShortcutSlot.x <= 0 )+ m_specialPowerShortcutButtonParents[ 0 ]->winGetSize( &m_shippedShortcutSlot.x, &m_shippedShortcutSlot.y );+ const Int cellWidth = area ? ( area->hi.x - area->lo.x ) / SPECIAL_POWER_SHORTCUT_COLS : 0;+ if( m_shippedShortcutSlot.x <= 0 || cellWidth <= 0 )+ {+ if( !m_specialPowerShortcutParent->winIsHidden() )+ m_specialPowerShortcutParent->winHide( TRUE );+ return;+ }+ const Int cellHeight = cellWidth * m_shippedShortcutSlot.y / m_shippedShortcutSlot.x;+ if( cell )+ {+ cell->x = cellWidth;+ cell->y = cellHeight;+ }+ if( m_currentlyUsedSpecialPowersButtons < 1 )+ {+ if( !m_specialPowerShortcutParent->winIsHidden() )+ m_specialPowerShortcutParent->winHide( TRUE );+ return;+ }++ ICoord2D cameoSize, cameoOffset;+ if( trayLayoutFromSlot( cellWidth, cellHeight, NULL, &cameoSize, &cameoOffset, NULL ) == FALSE )+ return;++ // the bar covers every cell, or a cell off its edge draws and never takes a click. It is as tall+ // as SPECIAL_POWER_SHORTCUT_COLS rows at least, so the first power takes the grid's top left place+ // with the page's empty ones under it; a longer list grows upward. Its position is its own+ // parent's, and the layout's root is not the screen+ // the powers showing, not the slots the side has: m_currentlyUsedSpecialPowersButtons is eleven+ // for a general with one power ready, and four rows of it stood the grid a row too high+ const Int filled = ( countVisibleSpecialPowerShortcuts() + SPECIAL_POWER_SHORTCUT_COLS - 1 ) / SPECIAL_POWER_SHORTCUT_COLS;+ const Int rows = MAX( filled, (Int)SPECIAL_POWER_SHORTCUT_COLS );+ Int parentX = 0, parentY = 0;+ if( m_specialPowerShortcutParent->winGetParent() )+ m_specialPowerShortcutParent->winGetParent()->winGetScreenPosition( &parentX, &parentY );+ m_specialPowerShortcutParent->winSetPosition( area->lo.x - parentX, area->hi.y - cellHeight * rows - parentY );+ m_specialPowerShortcutParent->winSetSize( cellWidth * SPECIAL_POWER_SHORTCUT_COLS, cellHeight * rows );+ if( m_specialPowerShortcutParent->winIsHidden() )+ m_specialPowerShortcutParent->winHide( FALSE );++ for( Int i = 0; i < MAX_SPECIAL_POWER_SHORTCUTS; i++ )+ {+ GameWindow *slot = m_specialPowerShortcutButtonParents[ i ];+ GameWindow *button = m_specialPowerShortcutButtons[ i ];+ if( slot == NULL || button == NULL )+ continue;++ slot->winSetPosition( ( i % SPECIAL_POWER_SHORTCUT_COLS ) * cellWidth, ( i / SPECIAL_POWER_SHORTCUT_COLS ) * cellHeight );+ slot->winSetSize( cellWidth, cellHeight );+ button->winSetSize( cameoSize.x, cameoSize.y );+ button->winSetPosition( cameoOffset.x, cameoOffset.y );+ }+}+//-------------------------------------------------------------------------------------------------/** Control of a player changed mid-game, so the general's powers bar has to be there this frame.* populateSpecialPowerShortcut() slides it in over half a second whenever it finds it hidden -diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex b70470301..ce8146c42 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -3872,6 +3872,7 @@ void InGameUI::reset( void )m_scoreboardOpen = FALSE;m_scoreboardPageLoaded = FALSE;m_controlBarPageLoaded = FALSE;+ m_controlBarFlipped.clear();m_spectatorPageLoaded = FALSE;m_spectatorFlipped.clear();m_spectatorPicked.clear();@@ -8957,8 +8958,9 @@ void InGameUI::drawHudOverlay( void )// the corner is measured fresh every frame, and this plate is the first thing in itm_hudOverlayBottom = 0;- if( !TheGlobalData->m_showHudOverlay )- return;+ // the command bar page's network box reads these whether the plate is switched on or not; the+ // plate itself stands down while the page is up, the box is where they are written then+ const Bool plate = TheGlobalData->m_showHudOverlay && !m_controlBarPageShown;// only once a real game is under way - not in the shell, and not on the menu's background mapif( TheGameLogic == NULL || !TheGameLogic->isInGame() || TheGameLogic->isInShellGame() )@@ -9053,6 +9055,39 @@ void InGameUI::drawHudOverlay( void )text.concat( units );}+ // the same readings, one value each, for the page+ char reading[ sizeof( "00:00:00" ) ];+ m_hudValues.clear();+ sprintf( reading, "%02d:%02d", wallClock.wHour, wallClock.wMinute );+ m_hudValues[ "net.clock" ] = reading;+ sprintf( reading, "%02u:%02u:%02u", gameSecs / 3600, ( gameSecs / 60 ) % 60, gameSecs % 60 );+ m_hudValues[ "net.game" ] = reading;+ sprintf( reading, "%02u:%02u:%02u", realSecs / 3600, ( realSecs / 60 ) % 60, realSecs % 60 );+ m_hudValues[ "net.real" ] = reading;+ m_hudValues[ "net.hz" ] = std::to_string( REAL_TO_INT( m_hudLogicHz + 0.5f ) );+ m_hudValues[ "net.fps" ] = std::to_string( REAL_TO_INT( m_hudFps + 0.5f ) );+ m_hudValues[ "net.renderer" ] = WideCharStringToMultiByte( TheDisplay->getRendererName() );+ m_hudValues[ "net.frame" ] = std::to_string( logicFrame );+ if( TheNetwork != NULL )+ {+ enum { BYTES_PER_KILOBYTE = 1024 };+ m_hudValues[ "net.online" ] = "online";+ m_hudValues[ "net.ready" ] = std::to_string( TheNetwork->getFramesReady() );+ m_hudValues[ "net.runahead" ] = std::to_string( TheNetwork->getRunAhead() );+ m_hudValues[ "net.room" ] = std::to_string( TheNetwork->getFrameRate() );+ m_hudValues[ "net.in" ] = std::to_string( REAL_TO_INT( TheNetwork->getIncomingBytesPerSecond() / BYTES_PER_KILOBYTE ) );+ m_hudValues[ "net.out" ] = std::to_string( REAL_TO_INT( TheNetwork->getOutgoingBytesPerSecond() / BYTES_PER_KILOBYTE ) );+ }+ if( unitCap > 0 && localPlayer && !localPlayer->isPlayerObserver() )+ {+ m_hudValues[ "net.units" ] = std::to_string( localPlayer->countUnitsTowardCap() );+ m_hudValues[ "net.cap" ] = std::to_string( unitCap );+ m_hudValues[ "net.capped" ] = "capped";+ }++ if( !plate )+ return;+if( m_hudDisplayString == NULL ){// bold at a small point size, because this plate is read at a glance rather than read@@ -10166,9 +10201,48 @@ static void putPowerBar( HtmlValues &values, std::vector< HtmlValues > &cells )/** The bar's windows the page stands down altogether. The menu and idle worker buttons are the* page's own, pressed through data-click="press:Name" because they sit where the bar's frame takes- * no clicks; the chat button is gone, and Enter still opens the chat. */-static const char *const CONTROL_BAR_STOOD_DOWN[] = { "ButtonOptions", "ButtonIdleWorker", "PopupCommunicator" };+ * no clicks; the chat button is gone, and Enter still opens the chat; the minimise button is gone,+ * the bar is only as big as what it holds now. */+static const char *const CONTROL_BAR_STOOD_DOWN[] = { "ButtonOptions", "ButtonIdleWorker", "PopupCommunicator", "ButtonLarge" };static const std::string PRESS_ACTION = "press:";+static const std::string SIGNAL_ACTION = "signal:";++/** A smoke signal may be sent: the rule the Alt+Z/X/C keys go by, a multiplayer game that is not a+ * replay, and a player still in it. */+static Bool signalsAllowed( void )+{+ const Player *local = ThePlayerList ? ThePlayerList->getLocalPlayer() : NULL;+ return TheGameLogic->isInMultiplayerGame() && !TheGameLogic->isInReplayGame() && local && local->isPlayerActive();+}++//-------------------------------------------------------------------------------------------------+/** data-click="signal:attack", "signal:defend" or "signal:look": the smoke the Alt+Z/X/C keys send,+ * in the middle of the view, since a button has no cursor over the ground to put it under. The+ * same logic message as the keys, so the same throttle and the same allies see it. */+//-------------------------------------------------------------------------------------------------+static void placeSignalAtView( const std::string &kind )+{+ static const struct { const char *name; SignalKind kind; } KINDS[] =+ {+ { "attack", SIGNAL_ATTACK }, { "defend", SIGNAL_DEFEND }, { "look", SIGNAL_ATTENTION }+ };++ if( !signalsAllowed() || TheTacticalView == NULL )+ return;+ for( Int each = 0; each < (Int)ARRAY_SIZE( KINDS ); each++ )+ {+ if( kind != KINDS[ each ].name )+ continue;++ Coord3D world;+ TheTacticalView->getPosition( &world );+ GameMessage *message = TheMessageStream->appendMessage( GameMessage::MSG_PLACE_SIGNAL );+ message->appendLocationArgument( world );+ message->appendIntegerArgument( KINDS[ each ].kind );+ return;+ }+ DEBUG_LOG(( "Command bar page: data-click=\"signal:%s\" names no signal\n", kind.c_str() ));+}/** The windows each panel is drawn round, so a panel is only as big as what it holds: the left one* the radar, the right one the portrait and the experience bar, the centre the command grid. The@@ -10179,16 +10253,25 @@ static const char *const CONTROL_BAR_LEFT[] = { "LeftHUD", NULL };static const char *const CONTROL_BAR_RIGHT[] = { "RightHUD", "GeneralsExp", "ExpBarForeground", NULL };static const char *const CONTROL_BAR_CENTRE[] = { "CommandWindow", "ObserverPlayerListWindow", "ButtonPlaceBeacon", NULL };-/** The promotion and minimise buttons, small, side by side in the right panel's top right corner,- * the minimise button outermost. 800x600 pixels. */+/** The promotion button, small, in the right panel's top right corner beside the page's own skills+ * button, which takes the outermost place. 800x600 pixels. */enum{CORNER_BUTTON_WIDTH = 32,CORNER_BUTTON_HEIGHT = 14,CORNER_BUTTON_GAP = 2,- CORNER_BUTTON_RISE = 16 ///< how far above the portrait's box the buttons' top edge sits+ CORNER_BUTTON_RISE = 16, ///< how far above the portrait's box the buttons' top edge sits+ SKILL_GRID_WIDTH = 150, ///< the general's powers, three to a row, against the screen's right edge+ SKILL_GRID_GAP = 30, ///< between them and the right panel's top+ SIGNAL_BUTTON_SIZE = 24, ///< each smoke signal button's height, a row of the column+ SIGNAL_BUTTON_WIDTH = 40, ///< and its width, room for its word in either language+ SIGNAL_BUTTONS = 3, ///< attack, defend, look+ SKILL_GRID_ROWS = 3, ///< the empty places drawn behind the powers+ SKILL_GRID_COLUMNS = 3,+ SKILLS_BUTTON_WIDTH = 58 ///< wide enough for its name in either language};-static const char *const CORNER_BUTTONS[] = { "ButtonLarge", "ButtonGeneral" };+static const char *const SKILLS_FOLDED = "skills"; ///< the flip the skills button toggles; flipped is folded away+static const char *const CORNER_BUTTONS[] = { "ButtonGeneral" };static void drawNothing( GameWindow *window, WinInstanceData *instData ){@@ -10411,6 +10494,10 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, Iconst Bool watching = localPlayerWatching();values[ "promotion" ] = !watching && TheControlBar->isGeneralStarFlashing() ? "ready" : "";values[ "watching" ] = watching ? "watching" : "";+ values.insert( m_hudValues.begin(), m_hudValues.end() );+ values[ "signals" ] = signalsAllowed() ? "" : "disabled";+ for( std::set< std::string >::const_iterator name = m_controlBarFlipped.begin(); name != m_controlBarFlipped.end(); ++name )+ values[ FLIP_ACTION + *name ] = "flipped";values[ "blink" ] = TheGameLogic->getFrame() % LOGICFRAMES_PER_SECOND > LOGICFRAMES_PER_SECOND / 2 ? "lit" : "";for( Int panel = 0; panel < panelCount; panel++ )putPageRect( values, "panel" + std::to_string( panel ), panels[ panel ], shown[ panel ] );@@ -10424,6 +10511,15 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, Iside.lo.x = 0;side.hi.y = TheDisplay->getHeight();putPageRect( values, "left", side, leftFound && panelCount > 0 && shown[ 0 ] );++ // the three smoke signal buttons, a column standing on the screen's bottom edge against the+ // left panel's right side+ IRegion2D signalColumn;+ signalColumn.lo.x = side.hi.x;+ signalColumn.hi.x = side.hi.x + REAL_TO_INT( SIGNAL_BUTTON_WIDTH * ControlBarUniformScale() );+ signalColumn.hi.y = TheDisplay->getHeight();+ signalColumn.lo.y = signalColumn.hi.y - REAL_TO_INT( SIGNAL_BUTTON_SIZE * SIGNAL_BUTTONS * ControlBarUniformScale() );+ putPageRect( values, "signals", signalColumn, leftFound && panelCount > 0 && shown[ 0 ] );stackCentre( values, panelCount > 1 && shown[ 1 ] );HtmlLists lists;putPowerBar( values, lists[ "powercells" ] ); // after the stack, whose frame it divides into cells@@ -10433,14 +10529,53 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, Iside.hi.y = TheDisplay->getHeight();putPageRect( values, "right", side, rightFound && panelCount > 2 && shown[ 2 ] );- // the promotion and minimise buttons go to the right panel's top right corner; a bar with no- // portrait showing leaves them where the bar put them, so minimise stays in reach+ // the page's skills button takes the right panel's top right corner and the promotion button+ // stands beside it; a bar with no portrait showing leaves the promotion button where it was+ const Real scale = ControlBarUniformScale();+ const Int cornerWidth = REAL_TO_INT( CORNER_BUTTON_WIDTH * scale );+ const Int cornerHeight = REAL_TO_INT( CORNER_BUTTON_HEIGHT * scale );+ const Int cornerGap = REAL_TO_INT( CORNER_BUTTON_GAP * scale );+ IRegion2D skills;+ skills.hi.x = box.hi.x;+ skills.lo.x = skills.hi.x - REAL_TO_INT( SKILLS_BUTTON_WIDTH * scale );+ skills.lo.y = box.lo.y - REAL_TO_INT( CORNER_BUTTON_RISE * scale );+ skills.hi.y = skills.lo.y + cornerHeight;+ putPageRect( values, "skillsbutton", skills, rightFound && panelCount > 2 && shown[ 2 ] );++ // the general's powers ready to fire, three to a row over the right panel, while the skills+ // button has not folded them away+ IRegion2D powers;+ powers.hi.x = TheDisplay->getWidth();+ powers.lo.x = powers.hi.x - REAL_TO_INT( SKILL_GRID_WIDTH * scale );+ powers.hi.y = side.lo.y - REAL_TO_INT( SKILL_GRID_GAP * scale );+ powers.lo.y = powers.hi.y;+ const Bool powersOpen = m_controlBarFlipped.find( SKILLS_FOLDED ) == m_controlBarFlipped.end();+ ICoord2D cell;+ TheControlBar->placeSpecialPowerShortcutGrid( powersOpen && rightFound ? &powers : NULL, &cell );++ // the grid's empty places, three by three, drawn behind the powers the way the command grid's+ // well stands behind its buttons+ std::vector< HtmlValues > &places = lists[ "skillcells" ];+ for( Int row = 0; row < SKILL_GRID_ROWS && cell.x > 0; row++ )+ {+ for( Int column = 0; column < SKILL_GRID_COLUMNS; column++ )+ {+ IRegion2D place;+ place.lo.x = powers.lo.x + column * cell.x;+ place.lo.y = powers.hi.y - ( SKILL_GRID_ROWS - row ) * cell.y;+ place.hi.x = place.lo.x + cell.x;+ place.hi.y = place.lo.y + cell.y;+ HtmlValues entry;+ putPageRect( entry, "cell", place, TRUE );+ places.push_back( entry );+ }+ }+if( rightFound ){- const Real scale = ControlBarUniformScale();- const Int width = REAL_TO_INT( CORNER_BUTTON_WIDTH * scale );- const Int height = REAL_TO_INT( CORNER_BUTTON_HEIGHT * scale );- Int x = box.hi.x;+ const Int width = cornerWidth;+ const Int height = cornerHeight;+ Int x = skills.lo.x - cornerGap;for( Int each = 0; each < (Int)ARRAY_SIZE( CORNER_BUTTONS ); each++ ){GameWindow *button = controlBarWindow( CORNER_BUTTONS[ each ] );@@ -10451,9 +10586,9 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, IInt parentX = 0, parentY = 0;if( button->winGetParent() )button->winGetParent()->winGetScreenPosition( &parentX, &parentY );- button->winSetPosition( x - parentX, box.lo.y - REAL_TO_INT( CORNER_BUTTON_RISE * scale ) - parentY );+ button->winSetPosition( x - parentX, skills.lo.y - parentY );button->winSetSize( width, height );- x -= REAL_TO_INT( CORNER_BUTTON_GAP * scale );+ x -= cornerGap;}}@@ -10485,7 +10620,9 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, Istd::vector< IRegion2D > solids;m_controlBarOverlay->rectsOf( ".solid", solids );- TheControlBar->setPageSolids( &solids );+ std::vector< IRegion2D > buttons;+ m_controlBarOverlay->rectsOf( "[data-click]", buttons );+ TheControlBar->setPageSolids( &solids, &buttons );m_controlBarPageShown = TRUE;return TRUE;}@@ -10501,6 +10638,19 @@ Bool InGameUI::handleControlBarPageClick( const ICoord2D *mouse, Bool act )return FALSE;const std::string action = m_controlBarOverlay->click( *mouse );+ if( action.compare( 0, FLIP_ACTION.size(), FLIP_ACTION ) == 0 )+ {+ const std::string name = action.substr( FLIP_ACTION.size() );+ if( act && m_controlBarFlipped.erase( name ) == 0 )+ m_controlBarFlipped.insert( name );+ return TRUE;+ }+ if( action.compare( 0, SIGNAL_ACTION.size(), SIGNAL_ACTION ) == 0 )+ {+ if( act )+ placeSignalAtView( action.substr( SIGNAL_ACTION.size() ) );+ return TRUE;+ }if( action.compare( 0, PRESS_ACTION.size(), PRESS_ACTION ) != 0 )return FALSE;if( !act )