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(gameengine): scoreboard build cards, promotion screen without the old fade

Olcay Seygan7cf047c14b20
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 276b261f3..869f2939c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -537,7 +537,7 @@ found and fixed — EA's own, not port damage.**
- 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.
- The command bar's frame is drawn new, in the same steel as the boards. Each panel holds one thing and is exactly its size, the radar, the command grid, the portrait with the experience bar, and wears a steel border outside it. Grey for America, red for China, sand for GLA. It slides and minimises with the bar, and like the boards it is a page in the Window folder; take the page away and the old painted bar comes back.
- Every panel of the bar is only as big as what it holds now, and stands on the bottom of the screen. The radar's border runs out to the screen's left edge, the portrait's to the right edge, and the middle is built up like bricks laid flush: the command grid's panel at the bottom, the power bar standing on its border in a steel frame of its own, a row of forty cells that light up from the left with your production and fill the frame from edge to edge when full, the consumption marked by a white needle, and on top of that a narrower block no taller than the money written on it. Everything the old painting filled round them is battlefield again, and a click there lands on the battlefield.
-- The bar's own buttons are drawn to match, steel caps lit gold under the pointer and pressed in when pushed. The menu is a small square with three bars in the screen's top left corner. The idle worker button is a key like the smoke signals', a hard hat on it, in a steel step against the middle panel's bottom left corner, where it no longer hides the end of the power bar, and the build buttons sit down level with it, a few pixels over the bottom of the screen. Each of the fourteen build places is its own dark cell with steel running between them, so an empty place reads as a slot waiting for a button, and the steel is laid over the edge of every picture the way a frame holds a card, the whole picture showing inside it. The production queue and the general's powers are framed the same way. The power bar is sunk into the same steel plate as the build grid, the plate carried on upward as wide as it, and the money's block sits on top of that plate with no seam between them: the build grid, the power and the money read as one piece. The power bar is as long as the build grid on every side, where it used to change length from one faction to the next, and the money sits over the grid's middle. The build grid's panel no longer carries an empty strip down its left side. There is no chat button any more: Enter opens the chat as it always did. The beacon button is gone from the bar too; the smoke signals over the radar are how you point your team at a spot. The portrait sits in the radar's lit steel too. The experience bar beside it is ten gold rungs in a sunk groove, climbing from the bottom as you earn your way to the next rank, and your rank stands in a steel tab on the portrait's top right corner, a key sunk in it like the idle worker's with one star for every rank there is, gold up to the one you hold. A watcher has nothing to promote and no longer gets the tab, which used to hang half into the screen's corner. Its button goes with it: a watcher who clicked a unit used to find an empty patch of screen there that still showed the promotions tooltip and opened the promotion screen. The portrait's grid is steel between dark cells on every side, where America's was drawn in blue lines that matched nothing else on the bar. That key is the promotions button: point at it and it comes up with a gold rim, it blinks bright in your side's own steel while you have a promotion to spend, and a click opens the promotion screen. That screen is rebuilt in the same steel and half its old size: each rank's promotions stand in a grid of build-button cells five wide, like the command grid, an empty place a dark hole, each rank in a steel well of its own with its heading, the wells a plate's thickness apart, the grid's steel laid over the edge of every picture so the picture sits in its cell like a card in a frame, your rank and the points to spend on one line over the experience bar, and Done in the last row's spare place. A gold rim marks what you have bought and a light one what you can buy now. The bar has no minimise arrow any more: it is only as big as what it holds. The radar sits sunk in a bezel of lit steel, bright along the top and shadowed down the right, and the build grid and the money wear the same steel, the figure in a dark window of its own, and the under-attack light is a long red lamp set in a steel tab on its top left corner, dark until you are hit and then blinking. No words on it, so it reads the same in any language.
+- The bar's own buttons are drawn to match, steel caps lit gold under the pointer and pressed in when pushed. The menu is a small square with three bars in the screen's top left corner. The idle worker button is a key like the smoke signals', a hard hat on it, in a steel step against the middle panel's bottom left corner, where it no longer hides the end of the power bar, and the build buttons sit down level with it, a few pixels over the bottom of the screen. Each of the fourteen build places is its own dark cell with steel running between them, so an empty place reads as a slot waiting for a button, and the steel is laid over the edge of every picture the way a frame holds a card, the whole picture showing inside it. The production queue and the general's powers are framed the same way. The power bar is sunk into the same steel plate as the build grid, the plate carried on upward as wide as it, and the money's block sits on top of that plate with no seam between them: the build grid, the power and the money read as one piece. The power bar is as long as the build grid on every side, where it used to change length from one faction to the next, and the money sits over the grid's middle. The build grid's panel no longer carries an empty strip down its left side. There is no chat button any more: Enter opens the chat as it always did. The beacon button is gone from the bar too; the smoke signals over the radar are how you point your team at a spot. The portrait sits in the radar's lit steel too. The experience bar beside it is ten gold rungs in a sunk groove, climbing from the bottom as you earn your way to the next rank, and your rank stands in a steel tab on the portrait's top right corner, a key sunk in it like the idle worker's with one star for every rank there is, gold up to the one you hold. A watcher has nothing to promote and no longer gets the tab, which used to hang half into the screen's corner. Its button goes with it: a watcher who clicked a unit used to find an empty patch of screen there that still showed the promotions tooltip and opened the promotion screen. The portrait's grid is steel between dark cells on every side, where America's was drawn in blue lines that matched nothing else on the bar. That key is the promotions button: point at it and it comes up with a gold rim, it blinks bright in your side's own steel while you have a promotion to spend, and a click opens the promotion screen. That screen is rebuilt in the same steel and half its old size: each rank's promotions stand in a grid of build-button cells five wide, like the command grid, an empty place a dark hole, each rank in a steel well of its own with its heading, the wells a plate's thickness apart, the grid's steel laid over the edge of every picture so the picture sits in its cell like a card in a frame, your rank and the points to spend on one line over the experience bar, and Done in the last row's spare place. A gold rim marks what you have bought and a light one what you can buy now. It opens straight away; the side's old painted screen no longer fades in over it for the first nine frames. The bar has no minimise arrow any more: it is only as big as what it holds. The radar sits sunk in a bezel of lit steel, bright along the top and shadowed down the right, and the build grid and the money wear the same steel, the figure in a dark window of its own, and the under-attack light is a long red lamp set in a steel tab on its top left corner, dark until you are hit and then blinking. No words on it, so it reads the same in any language.
- The general's powers you have bought and can fire, the column that climbed the right edge of the screen, stand over the portrait now in a tray of the bar's own steel. The first sits in the corner against the right edge of the screen, and each one you gain takes the place to the left of the last, three to a row before a new row starts above, so the tray is only ever as big as what you hold and an empty one takes no room at all. Each power sits on a dark cell three quarters the size of a build button, where the side's old tray art used to frame it. It is always out; there is no button to fold it away.
- Three buttons sit in a step of the radar's own steel, on its right: the smoke signals Alt+Z, X and C send. Press one and the pointer turns to a cross; your next click puts the signal there, on the ground or on the radar, and a right click or Escape takes it back; until now a button dropped its smoke in the middle of your view. Every signal now leaves a mark on the ground in your colour for ten seconds, and the radar ping lasts as long: crossed swords to attack, a shield to defend, an eye to look, each in a ring a few tanks across, fading out over its last two seconds. Each is a key sunk into the steel with a sharp white picture on it instead of a word: a crosshair to attack, a shield to defend, an eye to look. Point at one and it comes up out of its well as lit steel with a gold rim, and it sinks in darker while you hold the button down. They rise into place one after another from the bottom of the screen when the match starts. A game with nobody on your side to see the smoke, a skirmish against the computer or a replay, has no signal buttons at all.
- Tooltips wear the bar's steel. Point at a build button and a card opens right above it rather than in a fixed box at the side: the name on a steel header in your side's colour with the price in gold at its end, every "Power Supplied: 5" or "Strong: infantry" line of the description laid out as a label and a bold figure, then the unit's health, damage, attacks a second, damage a second, range and build time in gold, counted with the upgrades you own. Under them every upgrade that touches the unit and what it does to it: a Gattling Tank's card says Chain Guns takes its damage from 15 to 18 and its damage a second from 37 to 46, a Humvee's that TOW adds a 50 damage missile with a range of 317, and an upgrade you already bought turns gold. Point at the upgrade itself and the card lists the units it changes, Composite Armor putting a Crusader from 480 health to 680. At the bottom, "not enough money" or what you still need in a sunk red note at the bottom. Point at something on the battlefield and a small dark box beside the pointer names it, its owner's colour in a stripe down the left edge.
@@ -766,7 +766,7 @@ found and fixed — EA's own, not port damage.**
## A scoreboard on Tab
- Hold Tab and a scoreboard opens in the top left corner of the screen, beside the menu key; let go and it is gone. All eight seats of a full game fit in the top half of a 720 line screen. It is built from your command bar's steel, grey, red or sand for your side, with the match clock in its corner. Each side sits under a band edged green for yours and red for the enemy, and the band says how many of that side are still in the game, 4/4 down to 0/4. Watching, there is a band for every team. With a group selected, Tab still steps through the units in it as before, so the scoreboard wants one unit or none selected.
-- Every row on your side opens on a stripe of that player's colour, then the general's flag, the player's name and the general under it. Then rank, money in the bank, income per minute, kills and losses, every promotion bought, once, at the level it has reached, and the unit that player has built the most of. Numbers line up on their last digit, and your own row is lit. The promotions are drawn the size of the favourite unit's picture and the same shape, where they used to be 13 pixel squares you had to squint at. Point at a promotion, the favourite unit, a superweapon or something in a player's queue and the tooltip names it.
+- Every row on your side opens on a stripe of that player's colour, then the general's flag, the player's name and the general under it. Then rank, money in the bank, income per minute, kills and losses, every promotion bought, once, at the level it has reached, and the unit that player has built the most of. Numbers line up on their last digit, and your own row is lit. The promotions are drawn the size of the favourite unit's picture and the same shape, where they used to be 13 pixel squares you had to squint at. Point at a promotion, the favourite unit, a superweapon or something in a player's queue and the same card opens as over a build button: what it is, what it costs, and for a unit its health, damage, attacks a second and range.
- Beside income per minute, in brackets, is what that player earned a second over the last half minute, "1250(24)" on one line under "PER MIN(PER SEC)". The per-minute number is the average of the whole match, and ten minutes in a lost supply line hardly moves it. The small one falls within half a minute of the trucks stopping, and climbs again once a new line starts paying.
- Names are written in white and the player's colour goes on the stripe. Dark red on a black panel measured about 2 to 1 and could barely be read. A player who is out goes grey.
- An enemy row is a colour, a name and a team and nothing more. What they are playing and what they have in the bank is theirs to know.
diff --git a/GeneralsMD/Code/Data/Window/Html/Scoreboard.html b/GeneralsMD/Code/Data/Window/Html/Scoreboard.html
index 1cb8b8d53..3ee84374d 100644
--- a/GeneralsMD/Code/Data/Window/Html/Scoreboard.html
+++ b/GeneralsMD/Code/Data/Window/Html/Scoreboard.html
@@ -14,8 +14,8 @@
"hidden", plus " own" on your own seat and " defeated" once a seat is out. A full seat also
has {{portrait}} {{general}} {{rank}} {{cash}} {{income}}, the match's average a minute, with
{{persecond}} after it in brackets, what it earned a second over the last half minute, {{kills}}
- {{losses}}, its promotions as {{skill0}} to {{skill6}} named by {{skill0.tip}} to {{skill6.tip}},
- and {{favourite}} with {{favouritename}}, the unit built most.
+ {{losses}}, its promotions as {{skill0}} to {{skill6}} with {{skill0.tip}} to {{skill6.tip}},
+ and {{favourite}} with {{favouritename}} and {{favourite.tip}}, the unit built most.
A hidden seat is an enemy: a name, a colour and a team, nothing else.
Every seat has its five soonest superweapons as {{w0.image}} {{w0.time}} {{w0.state}} {{w0.tip}} to
{{w4...}}, the state "ready" once it can fire and "none" for an unused place; {{more}} counts
@@ -26,8 +26,10 @@
{{j2...}}, "none" for an unused place; {{jobsmore}} counts the rest, {{jobsmoremark}} "off" at
zero, and {{watching}} is "watching" on every seat, coming or not.
- An image whose name is empty is not drawn, so an unused {{skillN}} leaves no box. A data-tip is
- the tooltip the pointer gets over that element, and an empty one gets none.
+ An image whose name is empty is not drawn, so an unused {{skillN}} leaves no box. Every .tip is
+ the row's player and a command button, "3 Command_ConstructChinaTankBattlemaster", and the pointer
+ on an element whose data-tip holds one gets that button's build card, the command bar's tooltip
+ with its health, damage and range counted with that player's upgrades; an empty one gets none.
Edit the copy under Run/Window/Html and the next match reads it.
-->
<html>
@@ -165,7 +167,7 @@
<img class="skill" src="{{skill4}}" data-tip="{{skill4.tip}}" style="left: 614px">
<img class="skill" src="{{skill5}}" data-tip="{{skill5.tip}}" style="left: 635px">
<img class="skill" src="{{skill6}}" data-tip="{{skill6.tip}}" style="left: 656px">
- <img class="favourite c-favourite" src="{{favourite}}" data-tip="{{favouritename}}">
+ <img class="favourite c-favourite" src="{{favourite}}" data-tip="{{favourite.tip}}">
<div class="jobs">
<div class="arm w0 {{j0.state}}" data-tip="{{j0.tip}}"><img class="cameo" src="{{j0.image}}"><span class="count">{{j0.count}}</span><span class="time">{{j0.time}}</span></div>
<div class="arm w1 {{j1.state}}" data-tip="{{j1.tip}}"><img class="cameo" src="{{j1.image}}"><span class="count">{{j1.count}}</span><span class="time">{{j1.time}}</span></div>
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
index 307f6b805..c3e83559c 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
@@ -1389,14 +1389,26 @@ protected:
WindowLayout *m_buildToolTipLayout; ///< The window that will slide on/display tooltips
Bool m_showBuildToolTipLayout; ///< every frame we test to see if we aregoing to continue showing this or not.
BuildTooltipCard m_buildTooltipCard; ///< what the layout says, piece by piece
+ BuildTooltipCard m_boardCard; ///< the card for what the pointer is on in a page, the Tab scoreboard's
+ const CommandButton *m_boardCardButton; ///< the button m_boardCard was filled in from
+ Player *m_boardCardOwner; ///< and the player its figures were counted for
+ Bool m_boardCardShown; ///< a page asked for m_boardCard this frame
+ Bool m_boardCardWasShown; ///< and the frame before, so a card pointed at again is filled in again
public:
/** What the build tooltip up on screen says, NULL while none is. */
const BuildTooltipCard *getBuildTooltipCard( void );
+ /** The build card for a button a page draws rather than a window, its prices and figures counted
+ * for owner, standing against anchor, for this frame: a page calls hideBoardCard every frame and
+ * this while the pointer is on one. */
+ void showBoardCard( const CommandButton *button, Player *owner, const IRegion2D &anchor );
+ void hideBoardCard( void );
void showBuildTooltipLayout( GameWindow *cmdButton );
void hideBuildTooltipLayout( void );
void deleteBuildTooltipLayout( void );
Bool getShowBuildTooltipLayout( void ){return m_showBuildToolTipLayout; }
void populateBuildTooltipLayout( const CommandButton *commandButton, GameWindow *tooltipWin = NULL );
+ /// the same with the prices and figures counted for player rather than the local one
+ void populateBuildTooltipLayout( const CommandButton *commandButton, GameWindow *tooltipWin, Player *player );
void repopulateBuildTooltipLayout( void );
/// where the popup lives, so -uidrill can read the rectangle it landed in. The tooltip is placed
/// against BackgroundMarker's screen position, so it goes wherever the bar's windows went
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/HtmlOverlay.h b/GeneralsMD/Code/GameEngine/Include/GameClient/HtmlOverlay.h
index cabc4777e..49d11dcff 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/HtmlOverlay.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/HtmlOverlay.h
@@ -67,8 +67,9 @@ public:
/** Click at the pointer and return the data-click of what was clicked, empty for nothing. */
std::string click( const ICoord2D &mouse );
- /** The data-tip of what the last hover() found under the pointer, empty for nothing. */
- std::string tip( void );
+ /** The data-tip of what the last hover() found under the pointer, empty for nothing, and the
+ * screen rectangle of the element that carries it. */
+ std::string tip( IRegion2D &rect );
/** The bottom edge in screen pixels of the first element the CSS selector finds, 0 for none. */
Int bottomOf( const char *selector );
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index af63f4d4b..36deab56c 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -346,7 +346,7 @@ struct SpectatorSuperweapon
const Image *cameo;
Int seconds;
Bool ready;
- UnicodeString name;
+ const CommandButton *button; ///< the power's own, for its tooltip card; NULL for a power with none
};
// ------------------------------------------------------------------------------------------------
@@ -431,6 +431,8 @@ public: // ********************************************************************
/** The general's promotion screen, Window/Html/Promotion.html, drawn as `parent`'s picture: the
* screen's windows keep their clicks and the promotions' own cameos paint over it. */
void drawPromotionPage( GameWindow *parent, Bool front );
+ /** TRUE once the promotion screen is the page's, so the painted screen's own fade-in stays off. */
+ Bool isPromotionPageShown( void ) const { return m_promotionPageLoaded && !m_promotionPage.empty(); }
/** The Esc menu hands its look to Window/Html/QuitMenu.html: `parent` draws the page and its keys
* draw nothing and keep their clicks. Left as it is when there is no page. */
void themeQuitMenu( GameWindow *parent );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
index fb5837458..58b158867 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@@ -1270,6 +1270,10 @@ ControlBar::ControlBar( void )
m_currentControlBarStage = CONTROL_BAR_STAGE_DEFAULT;
m_buildToolTipLayout = NULL;
m_showBuildToolTipLayout = FALSE;
+ m_boardCardButton = NULL;
+ m_boardCardOwner = NULL;
+ m_boardCardShown = FALSE;
+ m_boardCardWasShown = FALSE;
// Added By Sadullah Nader
// initializing vars to zero
@@ -5565,7 +5569,9 @@ void ControlBar::showPurchaseScience( void )
m_purchaseScienceOpen = TRUE;
//switchToContext(CB_CONTEXT_PURCHASE_SCIENCE, NULL);
m_contextParent[ CP_PURCHASE_SCIENCE ]->winHide(FALSE);
- if (TheGlobalData->m_animateWindows)
+ // the fade holds the screen hidden for nine frames and draws the side's old painting of it fading
+ // in, which the page has replaced
+ if (TheGlobalData->m_animateWindows && !TheInGameUI->isPromotionPageShown())
TheTransitionHandler->setGroup("GenExpFade");
//m_generalsScreenAnimate->registerGameWindow( m_contextParent[ CP_PURCHASE_SCIENCE ], WIN_ANIMATION_SLIDE_TOP, TRUE, 200 );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp
index ab5b8a5b0..80771b83a 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp
@@ -578,8 +578,33 @@ void ControlBar::showBuildTooltipLayout( GameWindow *cmdButton )
}
+void ControlBar::showBoardCard( const CommandButton *button, Player *owner, const IRegion2D &anchor )
+{
+ if( button != m_boardCardButton || owner != m_boardCardOwner || !m_boardCardWasShown )
+ {
+ populateBuildTooltipLayout( button, NULL, owner );
+ m_boardCard = m_buildTooltipCard;
+ // the money short and the buildings missing are the buyer's, and on the board nobody is buying
+ m_boardCard.warning.clear();
+ m_boardCard.requires.clear();
+ m_boardCardButton = button;
+ m_boardCardOwner = owner;
+ }
+ m_boardCard.anchor = anchor;
+ m_boardCardShown = TRUE;
+}
+
+void ControlBar::hideBoardCard( void )
+{
+ m_boardCardWasShown = m_boardCardShown;
+ m_boardCardShown = FALSE;
+}
+
const BuildTooltipCard *ControlBar::getBuildTooltipCard( void )
{
+ // the pointer is on the page, over whatever window was pointed at last
+ if( m_boardCardShown )
+ return &m_boardCard;
if( m_buildToolTipLayout == NULL || m_buildToolTipLayout->isHidden() || prevWindow == NULL )
return NULL;
@@ -617,11 +642,15 @@ void ControlBar::repopulateBuildTooltipLayout( void )
}
void ControlBar::populateBuildTooltipLayout( const CommandButton *commandButton, GameWindow *tooltipWin)
+{
+ populateBuildTooltipLayout( commandButton, tooltipWin, ThePlayerList->getLocalPlayer() );
+}
+
+void ControlBar::populateBuildTooltipLayout( const CommandButton *commandButton, GameWindow *tooltipWin, Player *player )
{
if(!m_buildToolTipLayout)
return;
- Player *player = ThePlayerList->getLocalPlayer();
UnicodeString name, cost, descrip;
UnicodeString requires = UnicodeString::TheEmptyString, requiresList;
Bool firstRequirement = true;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/HtmlOverlay.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/HtmlOverlay.cpp
index 9fcafbaac..62865ee2d 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/HtmlOverlay.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/HtmlOverlay.cpp
@@ -105,7 +105,7 @@ public:
void draw( void );
Bool hover( const ICoord2D &mouse );
std::string click( const ICoord2D &mouse );
- std::string tip( void );
+ std::string tip( IRegion2D &rect );
Int bottomOf( const char *selector );
void rectsOf( const char *selector, std::vector< IRegion2D > &rects );
void setAlpha( Int alpha ) { m_alpha = alpha; }
@@ -315,16 +315,24 @@ std::string HtmlOverlayContainer::click( const ICoord2D &mouse )
}
//-------------------------------------------------------------------------------------------------
-std::string HtmlOverlayContainer::tip( void )
+std::string HtmlOverlayContainer::tip( IRegion2D &rect )
{
+ rect.lo.x = rect.lo.y = rect.hi.x = rect.hi.y = 0;
if( !m_document )
return std::string();
for( std::shared_ptr< const litehtml::element > element = m_document->get_over_element(); element; element = element->parent() )
{
const char *text = element->get_attr( "data-tip" );
- if( text )
- return text;
+ if( text == NULL )
+ continue;
+
+ const litehtml::position placement = element->get_placement();
+ rect.lo.x = screen( placement.x );
+ rect.lo.y = screen( placement.y );
+ rect.hi.x = screen( placement.x + placement.width );
+ rect.hi.y = screen( placement.y + placement.height );
+ return text;
}
return std::string();
}
@@ -789,6 +797,6 @@ void HtmlOverlay::draw( void ) { m_container->draw(); }
void HtmlOverlay::setAlpha( Int alpha ) { m_container->setAlpha( alpha ); }
Bool HtmlOverlay::hover( const ICoord2D &mouse ) { return m_container->hover( mouse ); }
std::string HtmlOverlay::click( const ICoord2D &mouse ) { return m_container->click( mouse ); }
-std::string HtmlOverlay::tip( void ) { return m_container->tip(); }
+std::string HtmlOverlay::tip( IRegion2D &rect ) { return m_container->tip( rect ); }
Int HtmlOverlay::bottomOf( const char *selector ) { return m_container->bottomOf( selector ); }
void HtmlOverlay::rectsOf( const char *selector, std::vector< IRegion2D > &rects ) { m_container->rectsOf( selector, rects ); }
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index 128a99bb4..a104bef76 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -7243,8 +7243,7 @@ void InGameUI::postDraw( void )
const CommandButton *button = powerButton( info->getSpecialPowerTemplate() );
const Image *cameo = button ? button->getButtonImage() : NULL;
addSuperweaponIcon( cameo, readySecs, percent, isReady, info->getColor() );
- SpectatorSuperweapon listed = { i, cameo, readySecs, isReady,
- button ? TheGameText->fetch( button->getTextLabel() ) : UnicodeString::TheEmptyString };
+ SpectatorSuperweapon listed = { i, cameo, readySecs, isReady, button };
m_spectatorSuperweapons.push_back( listed );
}
if (info->getSpecialPowerTemplate()->isSharedNSync())
@@ -9341,18 +9340,50 @@ static const Image *stripSlotCameo( const Object *producer, const ProductionEntr
return entry->getProductionObject() ? entry->getProductionObject()->getButtonImage() : NULL;
}
-/** The name of what stripSlotCameo draws, empty where it draws nothing. */
-static UnicodeString stripSlotName( const Object *producer, const ProductionEntry *entry,
- const InGameUI::ProductionStripSlot *slot )
+/** The command button that builds a unit or a building, the one its build card is filled in from. */
+static const CommandButton *buildButtonForThing( const ThingTemplate *thing )
+{
+ for( const CommandButton *button = TheControlBar->getCommandButtons(); button; button = button->getNext() )
+ {
+ const GUICommandType type = button->getCommandType();
+ if( ( type == GUI_COMMAND_UNIT_BUILD || type == GUI_COMMAND_DOZER_CONSTRUCT ) && button->getThingTemplate()
+ && button->getThingTemplate()->isEquivalentTo( thing ) )
+ return button;
+ }
+ return NULL;
+}
+
+/** The command button that buys an upgrade. */
+static const CommandButton *buildButtonForUpgrade( const UpgradeTemplate *upgrade )
+{
+ for( const CommandButton *button = TheControlBar->getCommandButtons(); button; button = button->getNext() )
+ {
+ const GUICommandType type = button->getCommandType();
+ if( ( type == GUI_COMMAND_PLAYER_UPGRADE || type == GUI_COMMAND_OBJECT_UPGRADE ) && button->getUpgradeTemplate() == upgrade )
+ return button;
+ }
+ return NULL;
+}
+
+/** A page's data-tip for a button on a player's row: the player's index, a space and the button's
+ * name, which ControlBar::findCommandButton finds it by. Button names are INI tokens and hold no
+ * space. Empty for no button. */
+static std::string buttonTip( const CommandButton *button, const Player *owner )
+{
+ return button ? std::to_string( owner->getPlayerIndex() ) + " " + button->getName().str() : "";
+}
+
+/** The button that builds what stripSlotCameo draws, NULL where it draws nothing. */
+static const CommandButton *stripSlotButton( const Object *producer, const ProductionEntry *entry,
+ const InGameUI::ProductionStripSlot *slot )
{
if( slot->isStructure )
- return producer ? producer->getTemplate()->getDisplayName() : UnicodeString::TheEmptyString;
+ return producer ? buildButtonForThing( producer->getTemplate() ) : NULL;
if( entry == NULL )
- return UnicodeString::TheEmptyString;
+ return NULL;
if( slot->isUpgrade )
- return entry->getProductionUpgrade() ? TheGameText->fetch( entry->getProductionUpgrade()->getDisplayNameLabel() )
- : UnicodeString::TheEmptyString;
- return entry->getProductionObject() ? entry->getProductionObject()->getDisplayName() : UnicodeString::TheEmptyString;
+ return entry->getProductionUpgrade() ? buildButtonForUpgrade( entry->getProductionUpgrade() ) : NULL;
+ return entry->getProductionObject() ? buildButtonForThing( entry->getProductionObject() ) : NULL;
}
//-------------------------------------------------------------------------------------------------
@@ -10032,7 +10063,7 @@ static HtmlValues scoreboardSeat( Player *player, const GameSlot *slot, Bool ful
{
const std::string name = "skill" + std::to_string( skill );
seat[ name ] = skills[ skill ]->getButtonImage()->getName().str();
- seat[ name + ".tip" ] = WideCharStringToMultiByte( TheGameText->fetch( skills[ skill ]->getTextLabel() ).str() );
+ seat[ name + ".tip" ] = buttonTip( skills[ skill ], player );
}
const ThingTemplate *favourite = score->getMostBuiltUnit();
@@ -10040,6 +10071,7 @@ static HtmlValues scoreboardSeat( Player *player, const GameSlot *slot, Bool ful
{
seat[ "favourite" ] = favourite->getButtonImage()->getName().str();
seat[ "favouritename" ] = WideCharStringToMultiByte( favourite->getDisplayName().str() );
+ seat[ "favourite.tip" ] = buttonTip( buildButtonForThing( favourite ), player );
}
return seat;
}
@@ -10077,7 +10109,7 @@ static void putSeatSuperweapons( HtmlValues &row, Int playerIndex, const std::ve
row[ name + ".image" ] = owned[ place ].cameo ? owned[ place ].cameo->getName().str() : "";
row[ name + ".time" ] = WideCharStringToMultiByte( time.str() );
row[ name + ".state" ] = owned[ place ].ready ? "ready" : "";
- row[ name + ".tip" ] = WideCharStringToMultiByte( owned[ place ].name.str() );
+ row[ name + ".tip" ] = buttonTip( owned[ place ].button, ThePlayerList->getNthPlayer( playerIndex ) );
}
Int more = 0;
@@ -10138,7 +10170,7 @@ static void putSeatQueue( HtmlValues &row, Player *player )
row[ name + ".time" ] = WideCharStringToMultiByte( time.str() );
row[ name + ".count" ] = slot->quantity > 1 ? "x" + std::to_string( slot->quantity ) : "";
row[ name + ".state" ] = "";
- row[ name + ".tip" ] = WideCharStringToMultiByte( stripSlotName( producer, entry, slot ).str() );
+ row[ name + ".tip" ] = buttonTip( stripSlotButton( producer, entry, slot ), player );
shown += slot->quantity;
}
row[ "jobsmore" ] = std::to_string( total - shown );
@@ -10157,6 +10189,7 @@ static void putSeatQueue( HtmlValues &row, Player *player )
//-------------------------------------------------------------------------------------------------
void InGameUI::drawScoreboard( void )
{
+ TheControlBar->hideBoardCard();
if( !m_scoreboardOpen || TheGameInfo == NULL )
return;
if( TheGameLogic == NULL || !TheGameLogic->isInGame() || TheGameLogic->isInShellGame() )
@@ -10181,10 +10214,21 @@ void InGameUI::drawScoreboard( void )
m_scoreboardHtmlFrame = frame;
}
m_scoreboardOverlay->setPage( m_scoreboardHtml );
- // the mouse clears its tooltip every frame, so one set here lasts as long as the pointer stays on
- // a promotion, a cameo or the favourite unit, and the board hides whatever is under it
+ // a promotion, a cameo or the favourite unit under the pointer gets the command bar's build card,
+ // its health, damage and range; the board hides the battlefield's tooltips under it
if( m_scoreboardOverlay->hover( TheMouse->getMouseStatus()->pos ) )
- TheMouse->setCursorTooltip( UnicodeString( MultiByteToWideCharSingleLine( m_scoreboardOverlay->tip().c_str() ).c_str() ) );
+ {
+ TheMouse->setCursorTooltip( UnicodeString::TheEmptyString );
+ IRegion2D anchor;
+ const std::string tip = m_scoreboardOverlay->tip( anchor );
+ if( !tip.empty() )
+ {
+ // counted for the row's player: his prices, and his upgrades in the damage and the health
+ const size_t space = tip.find( ' ' );
+ TheControlBar->showBoardCard( TheControlBar->findCommandButton( AsciiString( tip.c_str() + space + 1 ) ),
+ ThePlayerList->getNthPlayer( atoi( tip.c_str() ) ), anchor );
+ }
+ }
m_scoreboardOverlay->draw();
}