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): mod factions wear our american controlbar pro bar

Olcay Seygan7108314a3734
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 40d881355..bd7732004 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -27,7 +27,7 @@ found and fixed — EA's own, not port damage.**
- Reforged stays on top of every mod. This build's balance, its fixes to EA's data, its AI and its menus load after the mod and win where they touch the same unit, weapon or button, so a mod plays with Reforged's rules. A change that names something the mod renamed or removed is passed over instead of stopping the game, which is how ShockWave starts and plays. A mod's own copy of a file Reforged ships, the skirmish setup screen among them, is ignored, and so are any upscaled art archives it carries. The one exception is the skirmish AI's scripts: a mod's are written for its own generals, so they replace Reforged's, and Reforged's smarter AI plays them.
- A `mod.json` in the folder names the mod and its version. The names stand beside the version number in the options menu, in the order the mods were given, and go into every replay you record, so a replay made with mods says which ones, and the replay list marks it as another version when the game is running without them.
- Joining a LAN game that runs different mods used to end in a box about a mismatch and nothing else. It names the host's mods now, or tells you the host plays without any.
-- Two total conversions in one match. Add `-modfactions` to the mods you give, and each mod's armies join Zero Hour's own instead of replacing them: the faction list reads "ShockWave - USA" and "The End of Days - USA" under plain "USA", and a ShockWave army can fight an End of Days one. Each side builds from its own mod's units, weapons, upgrades and generals' powers, and each looks and sounds like its own mod: a ShockWave tank wears ShockWave's model and textures even where The End of Days replaces the same file, and speaks with ShockWave's voice. Playing a mod's faction, your command bar, build pictures, unit names and tooltips are that mod's; on one of Zero Hour's own you keep our bar. The End of Days' Russia is in the list under its own name. Menus, lobby and colours stay ours whatever mods you load. The skirmish AI lays out a mod's base from the mod's own buildings, but it still trains the army it knows from Zero Hour.
+- Two total conversions in one match. Add `-modfactions` to the mods you give, and each mod's armies join Zero Hour's own instead of replacing them: the faction list reads "ShockWave - USA" and "The End of Days - USA" under plain "USA", and a ShockWave army can fight an End of Days one. Each side builds from its own mod's units, weapons, upgrades and generals' powers, and each looks and sounds like its own mod: a ShockWave tank wears ShockWave's model and textures even where The End of Days replaces the same file, and speaks with ShockWave's voice. Playing a mod's faction, your buttons, build pictures, unit names and tooltips are that mod's, set in our American command bar whichever side you picked. The End of Days' Russia is in the list under its own name. Menus, lobby and colours stay ours whatever mods you load. The skirmish AI lays out a mod's base from the mod's own buildings, but it still trains the army it knows from Zero Hour.
- A patch for a mod stays with that mod. Give it with `-modpatch` right after the mod it changes, and its files replace that mod's one for one, even beside a second total conversion: a ShockWave balance patch reaches ShockWave's armies and leaves The End of Days alone. Given first, a patch changes Zero Hour's own files. The launcher's MODS page marks each mod a patch or a full mod, and a `mod.json` can say `"patch": true`. With two full mods switched on the launcher now plays them side by side; before, ShockWave and The End of Days together stopped the game at startup.
## One interface
@@ -40,7 +40,7 @@ found and fixed — EA's own, not port damage.**
## The command bar moves to the middle
-- ControlBar Pro is the command bar, in every match and for every side, and nothing has to be installed for it. The radar sits in the bottom left corner, the command buttons with your money and power in the middle of the bottom edge, and your selection, rank and general's buttons in the bottom right. Each piece is drawn at your screen's height and keeps the shape it was painted in, so nothing stretches on a 4:3 monitor or a 32:9 one, and the battlefield shows between the three. At 1920x1080 they stand where ControlBar Pro's own layout puts them, to the pixel. Its rank screen, power buttons, chat, diplomacy, quit and disconnect screens come with it, and a mod faction under `-modfactions` still wears its mod's bar. Thanks to xezon and FAS, whose bar this is.
+- ControlBar Pro is the command bar, in every match and for every side, and nothing has to be installed for it. The radar sits in the bottom left corner, the command buttons with your money and power in the middle of the bottom edge, and your selection, rank and general's buttons in the bottom right. Each piece is drawn at your screen's height and keeps the shape it was painted in, so nothing stretches on a 4:3 monitor or a 32:9 one, and the battlefield shows between the three. At 1920x1080 they stand where ControlBar Pro's own layout puts them, to the pixel. Its rank screen, power buttons, chat, diplomacy, quit and disconnect screens come with it. A mod's faction plays on its American bar, with the mod's own buttons and pictures in it, whether the mod brings a bar of its own or not. Thanks to xezon and FAS, whose bar this is.
- The command bar is one console standing in the middle of the bottom edge: a taller radar, your selection and the build grid side by side, with the power bar over the grid. The idle worker and rank keys sit in a row over your selection, and in multiplayer the smoke signals join them. The red under-attack lamp is gone: the ping on the radar, the voice and the line in the event feed already tell you where you are hit, and the lamp only blinked about it a second time.
- Your general's powers grow out of the console's right end, a column for each F key with its powers stacked up it, and only the powers you have take any room.
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/INI.h b/GeneralsMD/Code/GameEngine/Include/Common/INI.h
index 91cbdf839..e6ff684a9 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/INI.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/INI.h
@@ -178,7 +178,7 @@ enum ModNameType
MODNAME_OBJECT, MODNAME_WEAPON, MODNAME_ARMOR, MODNAME_DAMAGEFX, MODNAME_UPGRADE, MODNAME_SCIENCE,
MODNAME_SPECIALPOWER, MODNAME_COMMANDSET, MODNAME_COMMANDBUTTON, MODNAME_FXLIST, MODNAME_OCL,
MODNAME_PARTICLESYSTEM, MODNAME_LOCOMOTOR, MODNAME_PLAYERTEMPLATE, MODNAME_MAPPEDIMAGE,
- MODNAME_CONTROLBARSCHEME, MODNAME_AUDIOEVENT,
+ MODNAME_AUDIOEVENT,
MODNAME_COUNT
};
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBarScheme.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBarScheme.h
index 7d47abdda..1ea1c38d3 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBarScheme.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBarScheme.h
@@ -50,12 +50,6 @@
#ifndef __CONTROL_BAR_SCHEME_H_
#define __CONTROL_BAR_SCHEME_H_
-//-----------------------------------------------------------------------------
-// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
-//-----------------------------------------------------------------------------
-#include <map>
-#include <vector>
-
//-----------------------------------------------------------------------------
// USER INCLUDES //////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
@@ -278,17 +272,10 @@ public:
* is really showing. Empty when nothing else shares it. */
AsciiString getCurrentArtTwinSide( void ) const;
- /// -modfactions: the mod (0-based) whose own bar ("M<n>~" scheme) is on screen, -1 for ours;
- /// a mod's bar brings its own painting
- Int getCurrentSchemeMod( void ) const;
- Bool isCurrentSchemeMod( void ) const { return getCurrentSchemeMod() >= 0; }
- /// the bar on screen wears its scheme's own painting: a mod's, or ControlBar Pro's on every other side
+ /// the bar on screen wears its scheme's own painting, ControlBar Pro's
Bool isCurrentSchemePainted( void ) const;
- /// a mod scheme's painting, cut at the panel seams and each piece drawn where its panel stands
- void drawModPainting( ICoord2D offset, Bool foreground );
- /// where the mod's own ControlBar.wnd puts the window with this decorated name, in 800x600 design
- /// units; FALSE when the mod ships no ControlBar.wnd or no window of that name
- Bool findModWindowRect( Int mod, const AsciiString& decoratedName, Real *x, Real *y, Real *w, Real *h ) const;
+ /// the scheme's painting, cut at the panel seams and each piece drawn where its panel stands
+ void drawPainting( ICoord2D offset, Bool foreground );
// parse Functions for the INI file
@@ -304,9 +291,8 @@ public:
void preloadAssets( TimeOfDay timeOfDay ); ///< preload the assets
private:
- ControlBarScheme *findSchemeForSide( const AsciiString& side, Int mod ) const; ///< the widest of that side's schemes from mod (-1 ours) the screen can wear
- ControlBarScheme *findSchemeForFaction( const AsciiString& side, Int mod ) const; ///< a mod faction's own scheme, else ours
- void readModWindowRects( void ); ///< fills m_modWindowRects
+ ControlBarScheme *findSchemeForSide( const AsciiString& side ) const; ///< the widest of that side's schemes the screen can wear
+ ControlBarScheme *findSchemeForFaction( AsciiString side, const PlayerTemplate *pt, Bool useSmall ) const; ///< a mod faction wears America's (ControlBarIsModFaction)
ControlBarScheme *m_currentScheme; ///< the current scheme that everythign uses
Coord2D m_multiplyer;
@@ -314,11 +300,6 @@ private:
typedef std::list< ControlBarScheme* > ControlBarSchemeList; ///< list of control bar schemes
ControlBarSchemeList m_schemeList;
- /// -modfactions: each mod's ControlBar.wnd rectangles by window name key, read once in init
- struct ModWindowRect { Real x, y, w, h; };
- typedef std::map< UnsignedInt, ModWindowRect > ModWindowRectMap;
- std::vector< ModWindowRectMap > m_modWindowRects;
-
};
//-----------------------------------------------------------------------------
@@ -328,5 +309,7 @@ private:
//-----------------------------------------------------------------------------
// EXTERNALS //////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
+/// a mod's faction, which wears our American bar and tray whatever bar the mod ships (owner's call)
+Bool ControlBarIsModFaction( const PlayerTemplate *pt );
#endif // __CONTROL_BAR_SCHEME_H_
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp
index 542574683..f17463ecf 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp
@@ -472,7 +472,7 @@ const char *const ModNamespace::FactionFiles[] =
"Data\\INI\\ObjectCreationList.ini", "Data\\INI\\Locomotor.ini", "Data\\INI\\SpecialPower.ini",
"Data\\INI\\DamageFX.ini", "Data\\INI\\Armor.ini", "Data\\INI\\Object", "Data\\INI\\Upgrade.ini",
"Data\\INI\\CommandButton.ini", "Data\\INI\\CommandSet.ini", "Data\\INI\\ParticleSystem.ini",
- "Data\\INI\\MappedImages", "Data\\INI\\ControlBarScheme.ini", "Data\\INI\\Music.ini",
+ "Data\\INI\\MappedImages", "Data\\INI\\Music.ini",
"Data\\INI\\SoundEffects.ini", "Data\\INI\\Speech.ini", "Data\\INI\\Voice.ini",
NULL
};
@@ -489,7 +489,7 @@ static const struct { const char *keyword; ModNameType type; } ModBlockTypes[] =
{ "CommandSet", MODNAME_COMMANDSET }, { "CommandButton", MODNAME_COMMANDBUTTON }, { "FXList", MODNAME_FXLIST },
{ "ObjectCreationList", MODNAME_OCL }, { "ParticleSystem", MODNAME_PARTICLESYSTEM },
{ "Locomotor", MODNAME_LOCOMOTOR }, { "PlayerTemplate", MODNAME_PLAYERTEMPLATE },
- { "MappedImage", MODNAME_MAPPEDIMAGE }, { "ControlBarScheme", MODNAME_CONTROLBARSCHEME },
+ { "MappedImage", MODNAME_MAPPEDIMAGE },
{ "AudioEvent", MODNAME_AUDIOEVENT }, { "DialogEvent", MODNAME_AUDIOEVENT }, { "MusicTrack", MODNAME_AUDIOEVENT },
};
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
index 8cf3db97f..d08a42060 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@@ -621,8 +621,8 @@ void ControlBar::watchPlayer( Player *player )
const PlayerTemplate *wear = player ? player->getPlayerTemplate()
: ThePlayerList->getLocalPlayer()->getPlayerTemplate();
- // by template name rather than side: under -modfactions a mod's America and ours share the side
- // and not the bar
+ // by template name rather than side: under -modfactions a mod's GLA wears the American bar and
+ // ours the GLA one, the same side and not the same bar
if( m_controlBarSchemeManager && wear && wear->getName().compare( m_watchedSide ) != 0 )
{
// a scheme lays the whole bar out again, so it is set when the side really changes and not
@@ -1594,30 +1594,20 @@ static const Real thePanelAnchorFraction[ ControlBar::CB_PANEL_COUNT ] = { 0.0f,
/// ...and which authored x that anchor is, so at 4:3 the three plates reassemble the shipped bar
static const Real thePanelAnchorDesignX[ ControlBar::CB_PANEL_COUNT ] = { 0.0f, 400.0f, 800.0f };
-/// -modfactions: a mod's bar is up. Its painting was made for EA's layout, one stretch per axis over
-/// the whole screen, so under it the panels are not at one scale and not pulled apart: the three
-/// transforms below are the loader's own, and the windows go where the mod authored them.
-static Int barModIndex( void )
-{
- if( TheControlBar == NULL || TheControlBar->getControlBarSchemeManager() == NULL )
- return -1;
- return TheControlBar->getControlBarSchemeManager()->getCurrentSchemeMod();
-}
-
//-------------------------------------------------------------------------------------------------
-/** ControlBar Pro's bar (xezon and FAS, MIT; Data/Window/ControlBarPro.txt), the bar of every side but
- * a mod faction's. It was painted at 1920x1080 and goes on screen in three pieces: the radar
- * pinned bottom left, the command grid bottom centre and the selection with the general's buttons
+/** ControlBar Pro's bar (xezon and FAS, MIT; Data/Window/ControlBarPro.txt), the bar of every side,
+ * a mod faction's too (ControlBarIsModFaction). It was painted at 1920x1080 and goes on screen in
+ * three pieces: the radar pinned bottom left, the command grid bottom centre and the selection with the general's buttons
* bottom right. Each is drawn at the screen's height alone, 1080 lines to one, so it keeps the
* painting's shape and never stretches across the width, and from 4:3 to 32:9 the world shows
* between them. The pieces are the three panels with their anchors (thePanelAnchorFraction,
* thePanelAnchorDesignX); a window goes to a piece by which side of the seams its middle lies, and
- * drawModPainting cuts the painting at the same seams, which fall in the gaps of every side's art.
+ * drawPainting cuts the painting at the same seams, which fall in the gaps of every side's art.
* Fills the transform from 800x600 design units, where the .wnd loader's stretch is taken back to,
* to the screen. Not static: the test calls it. */
//-------------------------------------------------------------------------------------------------
static const Real HUD_ART_ASPECT = 1920.0f / 1080.0f; ///< what ControlBar Pro was painted at
-static const Real theHudSeamDesignX[ ControlBar::CB_PANEL_COUNT - 1 ] = { 182.0f, 616.0f }; ///< drawModPainting's seams
+static const Real theHudSeamDesignX[ ControlBar::CB_PANEL_COUNT - 1 ] = { 182.0f, 616.0f }; ///< drawPainting's seams
void ControlBarHudPieceTransform( Int panel, Real dispW, Real dispH, Real *sx, Real *sy, Real *originX )
{
@@ -1634,20 +1624,6 @@ Int ControlBarHudPieceForDesignX( Real designCenterX )
return designCenterX > theHudSeamDesignX[ 1 ] ? ControlBar::CB_PANEL_RIGHT : ControlBar::CB_PANEL_CENTER;
}
-/// Design units to the screen for the bar that is up: a mod's bar keeps the loader's stretch
-/// (barModIndex), ours is ControlBar Pro's pieces
-static void barTransform( Int panel, Real dispW, Real dispH, Real *sx, Real *sy, Real *originX )
-{
- if( barModIndex() >= 0 )
- {
- *sx = dispW / CONTROL_BAR_DESIGN_W;
- *sy = dispH / CONTROL_BAR_DESIGN_H;
- *originX = 0.0f;
- return;
- }
- ControlBarHudPieceTransform( panel, dispW, dispH, sx, sy, originX );
-}
-
//-------------------------------------------------------------------------------------------------
/** One scale for both axes, the smaller of the two, so nothing anywhere in the HUD is distorted.
* Everything that used to work this out for itself now asks here. */
@@ -1743,14 +1719,9 @@ void ControlBarLayoutUniform( GameWindow *root, Real anchorFracX, Real anchorFra
const Real loadScaleX = dispW / CONTROL_BAR_DESIGN_W;
const Real loadScaleY = dispH / CONTROL_BAR_DESIGN_H;
- // ControlBar Pro's rank screen and power bars at its pieces' scale, a mod's at one scale
- Real sx = ControlBarUniformScale();
- Real sy = sx;
- if( barModIndex() < 0 )
- {
- Real unusedOriginX;
- ControlBarHudPieceTransform( ControlBar::CB_PANEL_RIGHT, dispW, dispH, &sx, &sy, &unusedOriginX );
- }
+ // the rank screen and power bars at ControlBar Pro's pieces' scale
+ Real sx, sy, unusedOriginX;
+ ControlBarHudPieceTransform( ControlBar::CB_PANEL_RIGHT, dispW, dispH, &sx, &sy, &unusedOriginX );
//
// The anchor is a point that does not move: the same fraction of the screen and of the design
@@ -1796,9 +1767,9 @@ Bool ControlBarPanelDesignToScreen( Int panel, const IRegion2D *design,
// stretching to fill it. ControlBarUniformScale() is this same number for the display that is
// actually up; here the size is a parameter, because the tests ask about screens we are not on.
//
- // a mod's bar keeps the loader's stretch, panels and all; ours is ControlBar Pro's pieces
+ // ControlBar Pro's pieces
Real sx, sy, originX;
- barTransform( panel, dispW, dispH, &sx, &sy, &originX );
+ ControlBarHudPieceTransform( panel, dispW, dispH, &sx, &sy, &originX );
rectOut->lo.x = REAL_TO_INT_FLOOR( originX + design->lo.x * sx );
rectOut->hi.x = REAL_TO_INT_CEIL ( originX + design->hi.x * sx );
@@ -1839,49 +1810,12 @@ typedef std::map< GameWindow *, ControlBarPanelPlacement > ControlBarPanelPlacem
static ControlBarPanelPlacementMap theControlBarPlacement;
//-------------------------------------------------------------------------------------------------
-/** Which panel a direct child of ControlBarParent belongs to. Everything not named here rides in
- * the middle, which is where the .wnd already puts the money, power and command windows - and
- * where the plate art puts the column of worker/beacon/chat/options slots.
- *
- * The three GameWinBlockInput panes have no name at all, and one of them sits over each panel in
- * the authored layout, so they go by where they were drawn: the pane that used to cover the radar
- * keeps covering the radar. */
+/** Which piece of ControlBar Pro's bar a direct child of ControlBarParent belongs to: a window goes
+ * by its middle, and the observer's panes with the radar they are drawn beside. */
//-------------------------------------------------------------------------------------------------
static Int panelForWindow( const char *shortName, Real designCenterX )
{
- static const char *leftNames[] =
- {
- "LeftHUD", "WinUAttack", "BackgroundMarker", "ForegroundMarker", "OnTopDraw", NULL
- };
- static const char *rightNames[] =
- {
- "RightHUD", "GeneralsExp", "ExpBarForeground", "ButtonGeneral",
- "ButtonSmall", "ButtonMedium", "ButtonLarge", NULL
- };
-
- // ControlBar Pro's bar: a window goes by its middle, and the observer's panes with the radar they
- // are drawn beside
- if( barModIndex() < 0 )
- return strncmp( shortName, "ObserverPlayer", 14 ) == 0 ? ControlBar::CB_PANEL_LEFT : ControlBarHudPieceForDesignX( designCenterX );
-
- if( shortName[ 0 ] == 0 )
- {
- for( Int p = 0; p < ControlBar::CB_PANEL_COUNT; p++ )
- if( designCenterX >= thePanelDesignRect[ p ].lo.x &&
- designCenterX <= thePanelDesignRect[ p ].hi.x )
- return p;
- return ControlBar::CB_PANEL_CENTER;
- }
-
- for( const char **n = leftNames; *n; n++ )
- if( strcmp( shortName, *n ) == 0 )
- return ControlBar::CB_PANEL_LEFT;
-
- for( const char **n = rightNames; *n; n++ )
- if( strcmp( shortName, *n ) == 0 )
- return ControlBar::CB_PANEL_RIGHT;
-
- return ControlBar::CB_PANEL_CENTER;
+ return strncmp( shortName, "ObserverPlayer", 14 ) == 0 ? ControlBar::CB_PANEL_LEFT : ControlBarHudPieceForDesignX( designCenterX );
}
//-------------------------------------------------------------------------------------------------
@@ -1969,10 +1903,8 @@ const ControlBarPlate *ControlBarPlateForSide( const AsciiString& side, Int pane
if( side.isEmpty() || panel < 0 || panel >= ControlBar::CB_PANEL_COUNT )
return NULL;
- // -modfactions: a mod's bar wears the mod's own painting (drawModPainting), never our plates,
- // so nothing shifts its windows off the mod's layout or masks its clicks with our art. Ours is
- // ControlBar Pro's, its scheme's painting too, so a bar that is up wears no plate; the plates are
- // only the tests' to measure now
+ // the bar is ControlBar Pro's, its scheme's painting (drawPainting), so a bar that is up wears no
+ // plate; the plates are only the tests' to measure now
if( TheControlBar != NULL )
return NULL;
@@ -1999,20 +1931,6 @@ static const char *shortWindowName( GameWindow *win )
return colon ? colon + 1 : name;
}
-/// The windows ControlBarScheme::init puts at the scheme's own UL/LR rather than where the .wnd has them.
-static Bool isSchemePlacedWindow( const char *shortName )
-{
- static const char *names[] =
- {
- "PopupCommunicator", "ButtonIdleWorker", "ButtonOptions", "ButtonPlaceBeacon", "MoneyDisplay",
- "PowerWindow", "ButtonGeneral", "ButtonLarge", "WinUAttack", NULL
- };
- for( const char **n = names; *n; n++ )
- if( strcmp( shortName, *n ) == 0 )
- return TRUE;
- return FALSE;
-}
-
//-------------------------------------------------------------------------------------------------
// Where a plate is transparent ---------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
@@ -2194,9 +2112,8 @@ void ControlBar::placeInPanel( GameWindow *win, Int panel,
const Real loadScaleX = dispW / CONTROL_BAR_DESIGN_W;
const Real loadScaleY = dispH / CONTROL_BAR_DESIGN_H;
const Real s = ControlBarUniformScale();
- const Int mod = barModIndex();
Real sx, sy, originX;
- barTransform( panel, dispW, dispH, &sx, &sy, &originX );
+ ControlBarHudPieceTransform( panel, dispW, dispH, &sx, &sy, &originX );
ICoord2D rel, size;
win->winGetPosition( &rel.x, &rel.y );
@@ -2218,25 +2135,10 @@ void ControlBar::placeInPanel( GameWindow *win, Int panel,
const char *shortName = shortWindowName( win );
- // ControlBar Pro's own input panes and overlays belong to its painting, not to a mod's
- if( strncmp( shortName, "ControlBarPro", 13 ) == 0 )
- win->winHide( mod >= 0 );
-
- //
- // Under a mod's bar a window the mod's own ControlBar.wnd places goes where that file says, since
- // that is what the painting was made around. Not the ones ControlBarScheme::init has just put at
- // the scheme's UL/LR (the mod's file leaves those at 0,0 100x100), and not the nameless panes.
- // place.design* stays ours, so the window comes back to our layout when our bar does.
- //
- Real designX = place.designX, designY = place.designY, designW = place.designW, designH = place.designH;
- if( mod >= 0 && shortName[ 0 ] != 0 && !isSchemePlacedWindow( shortName ) )
- m_controlBarSchemeManager->findModWindowRect( mod, win->winGetInstanceData()->m_decoratedNameString,
- &designX, &designY, &designW, &designH );
-
- Int newX = REAL_TO_INT_FLOOR( originX + designX * sx );
- Int newY = REAL_TO_INT_FLOOR( dispH - ( CONTROL_BAR_DESIGN_H - designY ) * sy );
- Int newW = REAL_TO_INT_CEIL( designW * sx );
- Int newH = REAL_TO_INT_CEIL( designH * sy );
+ Int newX = REAL_TO_INT_FLOOR( originX + place.designX * sx );
+ Int newY = REAL_TO_INT_FLOOR( dispH - ( CONTROL_BAR_DESIGN_H - place.designY ) * sy );
+ Int newW = REAL_TO_INT_CEIL( place.designW * sx );
+ Int newH = REAL_TO_INT_CEIL( place.designH * sy );
//
// A plate is its side's own painting rather than a cut of the shipped one, so where it draws the
@@ -2264,24 +2166,6 @@ void ControlBar::placeInPanel( GameWindow *win, Int panel,
if( strcmp( shortName, "CenterBackground" ) == 0 )
childShiftX = plate ? REAL_TO_INT_FLOOR( plate->gridShiftX * s ) : 0;
- //
- // The unnamed children are the GameWinBlockInput panes: their only job is to keep clicks on the
- // bar out of the world, so they become exactly their panel. CenterBackground blocks input as
- // well as holding the command windows, and is authored full width, so it gets the same
- // treatment - left alone it would swallow every click over the gaps we just opened up.
- // ControlBar Pro's panes are its own, one per piece, and stay as its file draws them.
- //
- if( mod >= 0 && ( shortName[ 0 ] == 0 || strcmp( shortName, "CenterBackground" ) == 0 ) )
- {
- newX = m_panelRect[ panel ].lo.x;
- newW = m_panelRect[ panel ].width();
- if( shortName[ 0 ] == 0 )
- {
- newY = m_panelRect[ panel ].lo.y;
- newH = m_panelRect[ panel ].height();
- }
- }
-
win->winSetPosition( newX - newParentX, newY - newParentY );
win->winSetSize( newW, newH );
@@ -2467,7 +2351,7 @@ void ControlBar::layoutPanels( void )
// the frame itself stays full width - it draws nothing and passes input through
Real sx, sy, originX;
- barTransform( CB_PANEL_LEFT, dispW, dispH, &sx, &sy, &originX ); // the same height for every piece
+ ControlBarHudPieceTransform( CB_PANEL_LEFT, dispW, dispH, &sx, &sy, &originX ); // the same height for every piece
const Int parentTop =
REAL_TO_INT_FLOOR( dispH - ( CONTROL_BAR_DESIGN_H - CONTROL_BAR_DESIGN_TOP ) * sy );
parent->winSetPosition( 0, parentTop );
@@ -5478,7 +5362,9 @@ void ControlBar::initSpecialPowershortcutBar( Player *player)
return;
m_currentlyUsedSpecialPowersButtons = pt->getSpecialPowerShortcutButtonCount();
AsciiString layoutName, tempName, windowName, parentName;
- layoutName = pt->getSpecialPowerShortcutWinName();
+ // a mod faction's tray is our American one beside our American bar, whatever .wnd the mod names;
+ // its buttons are still the mod's SpecialPowerShortcutCommandSet
+ layoutName = ControlBarIsModFaction( pt ) ? AsciiString( "GenPowersShortcutBarUS.wnd" ) : pt->getSpecialPowerShortcutWinName();
m_specialPowerLayout = TheWindowManager->winCreateLayout(layoutName);
m_specialPowerLayout->hide(TRUE);
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp
index 15eb1d54c..cb258780a 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp
@@ -55,9 +55,6 @@
//-----------------------------------------------------------------------------
#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
#include "Lib/Clock.h"
-#include <string>
-#include "Common/file.h"
-#include "Common/FileSystem.h"
#include "Common/GlobalData.h"
#include "Common/NameKeyGenerator.h"
@@ -937,11 +934,9 @@ void ControlBarSchemeManager::init( void )
// the fork's edits to EA's schemes, each block naming only what it changes
ini.load( AsciiString( "Data\\INI\\ControlBarSchemeReforged.ini" ), INI_LOAD_MULTIFILE, NULL );
// ControlBar Pro's schemes, the bar every side wears: each replaces EA's of the same name whole,
- // so nothing above reaches it (a Debug build asserts once a scheme, newControlBarScheme)
+ // and under a single -mod the mod's of that name, so nothing above reaches it (a Debug build
+ // asserts once a scheme, newControlBarScheme). -modfactions loads no mod's schemes at all.
ini.load( AsciiString( "Data\\INI\\ControlBarProReforged.ini" ), INI_LOAD_OVERWRITE, NULL );
- // -modfactions: each mod's own bars, "M<n>~" names, worn only by that mod's factions
- INI::loadModPasses( "Data\\INI\\ControlBarScheme.ini", NULL );
- readModWindowRects();
// //Load the user modified control bar schemes
// WIN32_FIND_DATA findData;
@@ -1050,24 +1045,13 @@ AsciiString ControlBarSchemeManager::getCurrentArtTwinSide( void ) const
/** The side's widest scheme, as EA picked. Neither interface draws a scheme's painting; the plates
* stand in for it (ControlBarPlateForSide), and the scheme only places the bar's own windows. */
//-----------------------------------------------------------------------------
-/// -modfactions: the mod (0-based) a scheme's "M<n>~" name says it came from, -1 for ours
-static Int schemeModIndex( const AsciiString& name )
-{
- const char *text = name.str();
- if( text[ 0 ] != 'M' && text[ 0 ] != 'm' )
- return -1;
- char *tilde = NULL;
- const long mod = strtol( text + 1, &tilde, 10 );
- return ( tilde != text + 1 && *tilde == '~' && mod >= 1 ) ? (Int)mod - 1 : -1;
-}
-
-ControlBarScheme *ControlBarSchemeManager::findSchemeForSide( const AsciiString& side, Int mod ) const
+ControlBarScheme *ControlBarSchemeManager::findSchemeForSide( const AsciiString& side ) const
{
ControlBarScheme *best = NULL;
for( ControlBarSchemeList::const_iterator it = m_schemeList.begin(); it != m_schemeList.end(); ++it )
{
ControlBarScheme *scheme = *it;
- if( scheme->m_side.compareNoCase( side ) != 0 || schemeModIndex( scheme->m_name ) != mod )
+ if( scheme->m_side.compareNoCase( side ) != 0 )
continue;
if( best == NULL || scheme->m_ScreenCreationRes.x > best->m_ScreenCreationRes.x )
best = scheme;
@@ -1075,91 +1059,40 @@ ControlBarScheme *ControlBarSchemeManager::findSchemeForSide( const AsciiString&
return best;
}
-/// a mod faction wears its mod's bar for the side, ours where the mod has none; ours never a mod's
-ControlBarScheme *ControlBarSchemeManager::findSchemeForFaction( const AsciiString& side, Int mod ) const
-{
- ControlBarScheme *scheme = mod >= 0 ? findSchemeForSide( side, mod ) : NULL;
- return scheme ? scheme : findSchemeForSide( side, -1 );
-}
-
-Int ControlBarSchemeManager::getCurrentSchemeMod( void ) const
-{
- return m_currentScheme ? schemeModIndex( m_currentScheme->m_name ) : -1;
-}
-
-Bool ControlBarSchemeManager::isCurrentSchemePainted( void ) const
-{
- return m_currentScheme != NULL;
-}
-
//-----------------------------------------------------------------------------
-/** A mod's bar is painted for the window rectangles of the mod's own ControlBar.wnd: ShockWave's are
- * EA's (the same 96 rectangles as ours, at 800x600), The End of Days' are a 1920x1080 layout of its
- * own with the command grid at 668-1308 and the radar at 5-327. The windows stay ours, but under a
- * mod's bar layoutPanels gives each the rectangle the mod's file names for it (findModWindowRect).
- * Only SCREENRECT and NAME are read; nothing of the mod's callbacks or draw data is. */
+/** The owner's call: a mod's faction plays on our bar, ControlBar Pro's American one, whatever its
+ * side and whatever bar the mod ships. Its buttons, cameos and portrait are still the mod's. Under
+ * -modfactions that is a faction with a mod index; under a single -mod every faction is the mod's.
+ * The observer keeps its own bar. */
//-----------------------------------------------------------------------------
-void ControlBarSchemeManager::readModWindowRects( void )
+Bool ControlBarIsModFaction( const PlayerTemplate *pt )
{
- m_modWindowRects.clear();
- if( TheGlobalData == NULL || !TheGlobalData->m_modFactions )
- return;
+ if( pt == NULL || pt->getSide().isEmpty() || pt->getSide().compareNoCase( "Observer" ) == 0 )
+ return FALSE;
+ return pt->getModIndex() >= 0 || ( !TheGlobalData->m_mods.empty() && !TheGlobalData->m_modFactions );
+}
- m_modWindowRects.resize( TheGlobalData->m_mods.size() );
- for( Int mod = 0; mod < (Int)TheGlobalData->m_mods.size(); ++mod )
+ControlBarScheme *ControlBarSchemeManager::findSchemeForFaction( AsciiString side, const PlayerTemplate *pt, Bool useSmall ) const
+{
+ if( ControlBarIsModFaction( pt ) )
{
- TheFileSystem->setFocus( mod );
- File *file = TheFileSystem->openFile( "Window\\ControlBar.wnd" );
- TheFileSystem->setFocus( FILE_FOCUS_ALL );
- if( file == NULL )
- continue;
- const Int length = file->size();
- char *raw = file->readEntireAndClose();
- const std::string text( raw, length ); // the read is not terminated
- delete [] raw;
-
- // SCREENRECT = UPPERLEFT: x y, BOTTOMRIGHT: x y, CREATIONRESOLUTION: w h; NAME = "...";
- for( const char *rect = strstr( text.c_str(), "SCREENRECT" ); rect; rect = strstr( rect + 1, "SCREENRECT" ) )
- {
- Int ulx, uly, lrx, lry, resx, resy;
- char name[ 128 ];
- if( sscanf( rect, "SCREENRECT = UPPERLEFT: %d %d , BOTTOMRIGHT: %d %d , CREATIONRESOLUTION: %d %d ; NAME = \"%127[^\"]\"",
- &ulx, &uly, &lrx, &lry, &resx, &resy, name ) != 7 || resx <= 0 || resy <= 0 )
- continue;
-
- ModWindowRect r;
- r.x = ulx * 800.0f / resx;
- r.y = uly * 600.0f / resy;
- r.w = ( lrx - ulx ) * 800.0f / resx;
- r.h = ( lry - uly ) * 600.0f / resy;
- m_modWindowRects[ mod ][ TheNameKeyGenerator->nameToKey( AsciiString( name ) ) ] = r;
- }
- DEBUG_LOG(( "MODNS M%d~ ControlBar.wnd: %d windows\n", mod + 1, (Int)m_modWindowRects[ mod ].size() ));
+ side.set( "America" );
+ if( useSmall )
+ side.concat( "Small" );
}
+ return findSchemeForSide( side );
}
-Bool ControlBarSchemeManager::findModWindowRect( Int mod, const AsciiString& decoratedName,
- Real *x, Real *y, Real *w, Real *h ) const
+Bool ControlBarSchemeManager::isCurrentSchemePainted( void ) const
{
- if( mod < 0 || mod >= (Int)m_modWindowRects.size() )
- return FALSE;
- ModWindowRectMap::const_iterator it = m_modWindowRects[ mod ].find( TheNameKeyGenerator->nameToKey( decoratedName ) );
- if( it == m_modWindowRects[ mod ].end() )
- return FALSE;
- *x = it->second.x;
- *y = it->second.y;
- *w = it->second.w;
- *h = it->second.h;
- return TRUE;
+ return m_currentScheme != NULL;
}
//-----------------------------------------------------------------------------
-/** A mod's bar is laid out EA's way, one stretch per axis over the whole screen (see
- * ControlBarPanelDesignToScreen), so the three panel transforms are one and the same and the
- * painting goes back together at the seams below. The seams lie in the gaps of The End of Days' painting (radar to 142, middle 247-552,
- * right from 677, in design units) and inside ShockWave's one-piece one. */
+/** ControlBar Pro's painting, cut at the seams below and each piece drawn where its panel stands
+ * (ControlBarPanelDesignToScreen). The seams fall in the gaps of every side's art. */
//-----------------------------------------------------------------------------
-void ControlBarSchemeManager::drawModPainting( ICoord2D offset, Bool foreground )
+void ControlBarSchemeManager::drawPainting( ICoord2D offset, Bool foreground )
{
// where the left and centre, and the centre and right panels meet, in 800x600 design units
static const Int seams[ ControlBar::CB_PANEL_COUNT + 1 ] = { 0, 182, 616, 800 };
@@ -1222,7 +1155,7 @@ void ControlBarSchemeManager::setControlBarSchemeByPlayerTemplate( const PlayerT
side.set("Observer");
// picked again every time, even for the side on screen: a new resolution can want a different
// scheme for it (findSchemeForSide), and the multiplier below is the screen's
- ControlBarScheme *tempScheme = findSchemeForFaction( side, pt->getModIndex() );
+ ControlBarScheme *tempScheme = findSchemeForFaction( side, pt, useSmall );
DEBUG_LOG(("setControlBarSchemeByPlayer used %s as its side\n", side.str()));
if(tempScheme)
@@ -1265,7 +1198,7 @@ void ControlBarSchemeManager::setControlBarSchemeByPlayer(Player *p)
// scheme for it (findSchemeForSide), and the multiplier below is the screen's
// the neutral and civilian players have no template, and wear ours
const PlayerTemplate *pt = p->getPlayerTemplate();
- ControlBarScheme *tempScheme = findSchemeForFaction( side, pt ? pt->getModIndex() : -1 );
+ ControlBarScheme *tempScheme = findSchemeForFaction( side, pt, FALSE );
DEBUG_LOG(("setControlBarSchemeByPlayer used %s as its side\n", side.str()));
if(tempScheme)
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp
index 4f515d0bd..5b52a4a43 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp
@@ -711,11 +711,10 @@ void W3DCommandBarBackgroundDraw( GameWindow *window, WinInstanceData *instData
offset.y = now.y - TheControlBar->getPanelOrigin()->y;
}
- // -modfactions: a mod faction's bar is the mod's own painting, not our plates or our page, and so
- // is a HUD addon's
+ // the bar is ControlBar Pro's painting, a mod faction's too, not our plates
if( man->isCurrentSchemePainted() )
{
- man->drawModPainting( offset, FALSE );
+ man->drawPainting( offset, FALSE );
return;
}
@@ -741,8 +740,7 @@ void W3DCommandBarBackgroundDraw( GameWindow *window, WinInstanceData *instData
void W3DCommandBarForegroundDraw( GameWindow *window, WinInstanceData *instData )
{
- // nothing sits on top of the plates - see W3DCommandBarBackgroundDraw. A mod's bar keeps its
- // scheme's foreground layers, moved with the bar the same way, and a HUD addon's bar too
+ // the scheme's foreground layers, moved with the bar the same way as W3DCommandBarBackgroundDraw's
ControlBarSchemeManager *man = TheControlBar ? TheControlBar->getControlBarSchemeManager() : NULL;
if( man == NULL || TheDisplay == NULL || !man->isCurrentSchemePainted() )
return;
@@ -757,7 +755,7 @@ void W3DCommandBarForegroundDraw( GameWindow *window, WinInstanceData *instData
offset.x = now.x - TheControlBar->getPanelOrigin()->x;
offset.y = now.y - TheControlBar->getPanelOrigin()->y;
}
- man->drawModPainting( offset, TRUE );
+ man->drawPainting( offset, TRUE );
}
void W3DNoDraw( GameWindow *window, WinInstanceData *instData )