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): Classic hotkeys are the English letters, on a badge

Olcay Seygan55f9dcd79f94
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 70be21deb..d6b6a712e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1090,7 +1090,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same
- Display, graphics, effects, audio, controls, interface and network, behind seven buttons across the top. The original screen was one panel with everything on it at once, and it was already full the day it shipped: the language filter, the keyboard button and four camera checkboxes are all still in there, parked off the right edge where nobody can reach them, because there was nowhere left to put them.
- Every setting sits with the ones that do the same kind of job. Display is the screen and its brightness. Graphics is what the picture costs and how sharp it is, with the glow and the lighting in a group of their own instead of mixed in with the anti-aliasing. Effects is what stands in the world: all seven shadow boxes together, cloud shadows included, then the scenery, then smoke. Controls splits the camera, the orders, building placement and the mouse into four groups, and Interface holds the command bar size, the income readout, the health bars, the colours, the order lines and the language. In Classic the screen leaves out the twelve boxes Classic ignores anyway, from zoom to cursor and grid placement to the HUD size and the health bar choice, and closes the gaps they leave, so a box on that screen always does something.
- Classic Graphics, on the Graphics page, puts the game back the way it looked in 2003 in one click: its own textures and ground in place of the upscaled ones, the old hard shadows, the round dark patch under every tree where Reforged lays the tree's own outline on the ground, no bump detail on the models and no glow or sharpening over the picture. Leave it off and you have Reforged. The rest of the options stay yours either way, and the box takes effect the next time the game starts.
-- Interface, in the launcher, picks between Classic and Reforged. Classic is the command bar, mouse and hotkeys of Zero Hour 1.04 that your hands still remember; Reforged is the console in the middle, right-click orders and the key grid this version built. Every player starts on Classic, and a game started without the launcher is Classic too. The choice is yours alone: two players on different styles still play the same match and the same replay. It takes effect the next time the game starts. Classic's screen is EA's again: the one-piece command bar in each side's own painting, the radar with its flashing under-attack lamp, the beacon button, six lines of messages in the top left that fade as they did, superweapon countdowns written out by name, the old chat line and quit menu, lettering at the old sizes, and Tab opening diplomacy. What it does not do is stretch. On a 16:9 or 21:9 screen the bar, the menus and every dialog sit in a 4:3 frame in the middle at their drawn shape, and the battlefield runs out to both edges past them; at 2560x1080 that is 560 pixels of ground on either side of the bar. The mouse and keys are 1.04's as well. The left button selects and gives the order, so an enemy under it is an attack and a bunker under your infantry is a way in; the right button drops your selection or takes back a half-given order, and a right drag scrolls the map. Ctrl held is force fire. Alt held lays waypoints, and the white path joining them is drawn again. A guard order holds the range it always held, Shift and a number adds that group to what you have selected, and a build button is one unit a click. The keys are your language's own key map from the game's files, with nothing of Reforged's grid laid over it, and a build button's key is the letter painted yellow in its name again. A structure is selected on its own, as it always was. The radar shows no money piles or tech buildings, the piles carry no money over them, and the clock plate, the frame counter and the experience bar under the portrait stay off the screen. The money readout is the money alone, with no income figure beside it. So does the peace time plate, though a host's truce still holds. Health bars are 1.04's: only over what you have selected or have the pointer on, red to green by health and blue while building or disabled, with no build, reload, charge or work clocks over them, and a building shows its garrison squares only when it is yours and somebody is inside. The build buttons are the pictures alone, without the seconds, price and power figures. Those seconds were measured against the wall clock, so on a match running just under full speed a 120 second build read 125. An upgrade bought for a group of buildings goes to the one whose buttons you see. The building and unit keys are the yellow letters in Turkish as well: İkmal Kamyonu is the i key on a Turkish keyboard, wherever that key sits. In a network game a Classic player's camera is not sent to observers, as it never was in 1.04. The camera zooms on the middle of the screen ten units a notch, as near and as far as Reforged's camera goes, turns without snapping, and scrolls from the last three pixels of a full screen and not at all in a window, whatever the options say. A move order puts 1.04's animated ring on the ground where it lands, and no marker or line stays behind it. None of it reaches the battle itself: Classic sends the game only the orders 1.04 sent, so a Classic player and a Reforged one share a match, and a replay plays back the same in either.
+- Interface, in the launcher, picks between Classic and Reforged. Classic is the command bar, mouse and hotkeys of Zero Hour 1.04 that your hands still remember; Reforged is the console in the middle, right-click orders and the key grid this version built. Every player starts on Classic, and a game started without the launcher is Classic too. The choice is yours alone: two players on different styles still play the same match and the same replay. It takes effect the next time the game starts. Classic's screen is EA's again: the one-piece command bar in each side's own painting, the radar with its flashing under-attack lamp, the beacon button, six lines of messages in the top left that fade as they did, superweapon countdowns written out by name, the old chat line and quit menu, lettering at the old sizes, and Tab opening diplomacy. What it does not do is stretch. On a 16:9 or 21:9 screen the bar, the menus and every dialog sit in a 4:3 frame in the middle at their drawn shape, and the battlefield runs out to both edges past them; at 2560x1080 that is 560 pixels of ground on either side of the bar. The mouse and keys are 1.04's as well. The left button selects and gives the order, so an enemy under it is an attack and a bunker under your infantry is a way in; the right button drops your selection or takes back a half-given order, and a right drag scrolls the map. Ctrl held is force fire. Alt held lays waypoints, and the white path joining them is drawn again. A guard order holds the range it always held, Shift and a number adds that group to what you have selected, and a build button is one unit a click. The keys are your language's own key map from the game's files, with nothing of Reforged's grid laid over it, and a build button's key is the letter 1.04 gave it, taken from the English name in every language, so a Turkish or German player presses the same key an English one does. The letter sits in the button's corner on the dark badge Reforged puts its grid keys on; the tooltip's name is plain white with no letter picked out. A structure is selected on its own, as it always was. The radar shows no money piles or tech buildings, the piles carry no money over them, and the clock plate, the frame counter and the experience bar under the portrait stay off the screen. So does the peace time plate, though a host's truce still holds. The money readout is the money alone, with no income figure beside it. Health bars and garrison squares look and behave as they do in Reforged, and the Health Bars and empty garrison squares settings are back on Classic's options page. The build buttons are the pictures alone, without the seconds, price and power figures. Those seconds were measured against the wall clock, so on a match running just under full speed a 120 second build read 125. An upgrade bought for a group of buildings goes to the one whose buttons you see. In a network game a Classic player's camera is not sent to observers, as it never was in 1.04. The camera zooms on the middle of the screen ten units a notch, as near and as far as Reforged's camera goes, turns without snapping, and scrolls from the last three pixels of a full screen and not at all in a window, whatever the options say. A move order puts 1.04's animated ring on the ground where it lands, and no marker or line stays behind it. None of it reaches the battle itself: Classic sends the game only the orders 1.04 sent, so a Classic player and a Reforged one share a match, and a replay plays back the same in either.
- Every graphics setting is on the Graphics and Effects pages. Shadows, clouds, ground lighting, soft water edges, trees, extra animations, heat haze, texture resolution and the particle limit used to hide in a popup that only opened if you picked Custom from the detail box on another page, so choosing High never showed you what High turns on. Pick a preset now and its settings change in front of you; touch any one of them and the box reads Custom. Texture filtering and the number of anisotropic samples, which needed a text editor, sit there too.
- Every page is sorted into titled groups by what the settings do, and the groups sit in the same three columns on every tab. On Graphics the detail preset heads the first column with the texture and particle sliders under it, the picture settings take the second and the terrain the third. The framed boxes the original drew inside each page are gone. They were sized for headings that no longer exist, which is why no two pages started their first setting at the same height.
- The detail box has Ultra above High, and a preset now sets everything it is responsible for. Picking High used to leave antialiasing and texture filtering wherever they happened to be; High now brings 4x antialiasing and 8 anisotropic samples with it, and Low turns both down for the machines that need it. Ultra is High with the particle limit at the top of its slider, 5,000 against High's 3,000, detail that is never dropped when the frame rate dips, 8x antialiasing, 16 anisotropic samples, thick smoke and every new shadow and effect switched on. Glow stays yours whichever you pick: the artwork was painted without it.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GameText.h b/GeneralsMD/Code/GameEngine/Include/GameClient/GameText.h
index 23ee73def..ff17f2896 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/GameText.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/GameText.h
@@ -84,6 +84,10 @@ class GameTextInterface : public SubsystemInterface
virtual AsciiStringVec& getStringsWithLabelPrefix(AsciiString label) = 0;
virtual void initMapStringFile( const AsciiString& filename ) = 0;
+
+ /// the letter after '&' in the English text of this label (the game's own table and Patch.str,
+ /// before any translation), or 0: Classic's command keys are the English ones in every language
+ virtual WideChar fetchEnglishHotKey( const AsciiString& label ) { return 0; }
};
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
index f4895820b..6480997eb 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@@ -5272,12 +5272,26 @@ void ControlBar::setControlCommand( GameWindow *button, const CommandButton *com
// the key in the button's top left corner is its place's, and a place is only known once the
// whole set is on the bar: labelCommandPlaces paints it. Classic has no places: its key is the
- // letter after the '&' in the button's own label, as the game shipped
+ // game's own, the letter after the '&' in the button's label - the English label's in every
+ // language, so a Turkish or German player presses what an English one does - and it wears it
+ // on the button the way Reforged wears a grid key
if( TheHotKeyManager && TheGlobalData->isClassicUI() )
{
- AsciiString hotKey = TheHotKeyManager->searchHotKey( commandButton->getTextLabel() );
- if( hotKey.isNotEmpty() )
- TheHotKeyManager->addHotKey( button, hotKey );
+ WideChar letter = TheGameText ? TheGameText->fetchEnglishHotKey( commandButton->getTextLabel() ) : 0;
+ if( letter >= u'a' && letter <= u'z' )
+ letter -= ( u'a' - u'A' );
+ if( letter != 0 )
+ {
+ TheHotKeyManager->addHotKey( button, HotKeyManager::nameOf( letter ) );
+ const WideChar text[ 2 ] = { letter, 0 };
+ GadgetButtonSetText( button, UnicodeString( text ) );
+ button->winSetStatus( WIN_STATUS_SHORTCUT_BUTTON );
+ }
+ else
+ {
+ GadgetButtonSetText( button, UnicodeString( u"" ) );
+ button->winClearStatus( WIN_STATUS_SHORTCUT_BUTTON );
+ }
}
GadgetButtonSetAltSound(button, "GUICommandBarClick");
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GameText.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GameText.cpp
index 3ca00ce01..f719f81e6 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GameText.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GameText.cpp
@@ -60,6 +60,8 @@
#include "Common/GlobalData.h"
#include "Common/file.h"
#include "Common/FileSystem.h"
+#include <map>
+#include <string>
#ifdef _INTERNAL
@@ -159,9 +161,13 @@ class GameTextManager : public GameTextInterface
virtual AsciiStringVec& getStringsWithLabelPrefix(AsciiString label);
virtual void initMapStringFile( const AsciiString& filename );
+ virtual WideChar fetchEnglishHotKey( const AsciiString& label );
protected:
+ /// label (lower case) -> its English hotkey letter, filled once the table is read
+ std::map< std::string, WideChar > m_englishHotKeys;
+
Int m_textCount;
Int m_maxLabelLen;
Char m_buffer[MAX_UITEXT_LENGTH];
@@ -427,6 +433,7 @@ void GameTextManager::init( void )
// the tail in turn and restore afterwards.
StringInfo *wholeTable = m_stringInfo;
Int filled = mainCount;
+ Int englishEnd = mainCount; // the CSF and Patch.str: everything before the translation
for ( Int overlay = 0; overlay < OVERLAY_COUNT; ++overlay )
{
if ( overlayCounts[ overlay ] == 0 )
@@ -438,10 +445,27 @@ void GameTextManager::init( void )
{
filled += overlayCounts[ overlay ];
}
+ if ( overlay == 0 )
+ englishEnd = filled;
}
m_stringInfo = wholeTable;
m_textCount = filled;
+ // Classic's command keys are the English labels' letters whatever language the text is in, so
+ // every player presses the same key. Read in table order, so Patch.str overrules the CSF.
+ m_englishHotKeys.clear();
+ for ( Int i = 0; i < englishEnd; i++ )
+ {
+ const WideChar *amp = m_stringInfo[ i ].text.str();
+ while ( amp && *amp && *amp != u'&' )
+ amp++;
+ if ( amp == NULL || *amp == 0 || amp[ 1 ] <= u' ' )
+ continue;
+ AsciiString label = m_stringInfo[ i ].label;
+ label.toLower();
+ m_englishHotKeys[ label.str() ] = amp[ 1 ];
+ }
+
m_stringLUT = NEW StringLookUp[m_textCount];
StringLookUp *lut = m_stringLUT;
@@ -1439,6 +1463,18 @@ UnicodeString GameTextManager::fetch( AsciiString label, Bool *exists )
return fetch(label.str(), exists);
}
+//============================================================================
+// GameTextManager::fetchEnglishHotKey
+//============================================================================
+
+WideChar GameTextManager::fetchEnglishHotKey( const AsciiString& label )
+{
+ AsciiString key = label;
+ key.toLower();
+ std::map< std::string, WideChar >::const_iterator it = m_englishHotKeys.find( key.str() );
+ return it == m_englishHotKeys.end() ? 0 : it->second;
+}
+
//============================================================================
// GameTextManager::getStringsWithLabelPrefix
//============================================================================
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplayString.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplayString.h
index 0ea8584d7..d86cf3f36 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplayString.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplayString.h
@@ -105,9 +105,6 @@ protected:
Bool m_textChanged; ///< when contents of string change this is TRUE
Bool m_fontChanged; ///< when font has chagned this is TRUE
Bool m_useHotKey; ///< '&' hotkey markers are hidden
- Render2DSentenceClass m_textRendererHotKey; ///< Classic: the hotkey letter again, bold, in HotKeyTextColor over its own
- ICoord2D m_hotKeyPos; ///< where Build_Sentence found that letter, from the text's corner
- Bool m_drawHotKey; ///< the sentence was built with a letter to paint over
ICoord2D m_textPos; ///< current text pos set in text renderer
Color m_currTextColor, ///< current color used in text renderer
m_currDropColor; ///< current color used for shadow in text
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayString.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayString.cpp
index c1766c24f..ee1fc2dcc 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayString.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayString.cpp
@@ -59,7 +59,6 @@
#include "W3DDevice/GameClient/W3DDisplayString.h"
#include "GameClient/GameFont.h"
#include "GameClient/GlobalLanguage.h"
-#include "Common/GlobalData.h"
// DEFINES ////////////////////////////////////////////////////////////////////
#ifdef _INTERNAL
@@ -125,9 +124,6 @@ W3DDisplayString::W3DDisplayString( void )
m_clipRegion.hi.y = 0;
m_lastResourceFrame = 0;
m_useHotKey = FALSE;
- m_hotKeyPos.x = 0;
- m_hotKeyPos.y = 0;
- m_drawHotKey = FALSE;
} // end W3DDisplayString
@@ -202,38 +198,7 @@ void W3DDisplayString::draw( Int x, Int y, Color color, Color dropColor, Int xDr
{
// Reset() clears the parse flag on every text change, so it is put back here, where it is read
m_textRenderer.Set_Hot_Key_Parse( m_useHotKey != FALSE );
- m_textRenderer.Build_Sentence( getText().str(), &m_hotKeyPos.x, &m_hotKeyPos.y );
-
- //
- // Classic paints the hotkey letter again in the hotkey colour, in the bold cut, over the one
- // the sentence already drew, the way the game shipped. Over rather than in a gap: a letter
- // the bold renderer cannot draw still reads in the text's own colour.
- //
- m_drawHotKey = FALSE;
- m_textRendererHotKey.Reset();
- if( m_useHotKey && TheGlobalData && TheGlobalData->isClassicUI() && m_font )
- {
- // the letter after the first '&', by the sentence's own test, kept wide so a Turkish letter
- // is painted as itself
- UnicodeString letter;
- for( const WideChar *c = getText().str(); *c; ++c )
- {
- if( c[ 0 ] == L'&' && c[ 1 ] > L' ' && c[ 1 ] != L'\n' )
- {
- const WideChar text[ 2 ] = { c[ 1 ], 0 };
- letter.set( text );
- break;
- }
- }
- if( !letter.isEmpty() )
- {
- GameFont *boldFont = TheFontLibrary->getFont( m_font->nameString, m_font->pointSize, TRUE );
- m_textRendererHotKey.Set_Font( static_cast<FontCharsClass *>( boldFont ? boldFont->fontData : m_font->fontData ) );
- m_textRendererHotKey.Build_Sentence( letter.str(), NULL, NULL );
- m_drawHotKey = TRUE;
- }
- }
-
+ m_textRenderer.Build_Sentence( getText().str(), NULL, NULL );
m_fontChanged = FALSE;
m_textChanged = FALSE;
needNewPolys = TRUE;
@@ -272,19 +237,10 @@ void W3DDisplayString::draw( Int x, Int y, Color color, Color dropColor, Int xDr
m_textRenderer.Set_Location( Vector2( m_textPos.x, m_textPos.y ) );
m_textRenderer.Draw_Sentence( m_currTextColor );
- if( m_drawHotKey )
- {
- m_textRendererHotKey.Reset_Polys();
- m_textRendererHotKey.Set_Location( Vector2( m_textPos.x + m_hotKeyPos.x, m_textPos.y + m_hotKeyPos.y ) );
- m_textRendererHotKey.Draw_Sentence( TheGlobalData->m_hotKeyTextColor );
- }
-
} // end if
// render the text
m_textRenderer.Render();
- if( m_drawHotKey )
- m_textRendererHotKey.Render();
// we are for sure using display resources now
if( TheGameClient )
@@ -389,10 +345,6 @@ void W3DDisplayString::setClipRegion( IRegion2D *region )
m_clipRegion.lo.y,
m_clipRegion.hi.x,
m_clipRegion.hi.y ) );
- m_textRendererHotKey.Set_Clipping_Rect( RectClass( m_clipRegion.lo.x,
- m_clipRegion.lo.y,
- m_clipRegion.hi.x,
- m_clipRegion.hi.y ) );
} // end if
} // end setClipRegion
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayStringManager.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayStringManager.cpp
index 339de5877..85599fd04 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayStringManager.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayStringManager.cpp
@@ -206,7 +206,6 @@ void W3DDisplayStringManager::update( void )
// free the resources
string->m_textRenderer.Reset();
- string->m_textRendererHotKey.Reset();
//
// mark data in the string as changed so that if it needs to
// be drawn again it will know to reconstruct the render data