Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gameengine): compact rank insignia and a corner badge on the portrait

Olcay Seygane455fe17f3f3
diff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksChina.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksChina.tga
index 8740d5bfd..ccb955749 100644
Binary files a/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksChina.tga and b/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksChina.tga differ
diff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksUSA.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksUSA.tga
index f37b5bc45..98a374746 100644
Binary files a/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksUSA.tga and b/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksUSA.tga differ
diff --git a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksChina.ini b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksChina.ini
index 1140ceb82..c015ca673 100644
--- a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksChina.ini
+++ b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksChina.ini
@@ -7,39 +7,43 @@ MappedImage RankChina_1
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:68 Top:22 Right:124 Bottom:42
+ Coords = Left:80 Top:21 Right:112 Bottom:43
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankChina_2
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:132 Top:16 Right:188 Bottom:48
+ Coords = Left:144 Top:16 Right:176 Bottom:48
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankChina_3
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:196 Top:22 Right:252 Bottom:42
+ Coords = Left:208 Top:21 Right:240 Bottom:43
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankChina_4
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:260 Top:16 Right:316 Bottom:48
+ Coords = Left:272 Top:16 Right:304 Bottom:48
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankChina_5
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:324 Top:10 Right:380 Bottom:54
+ Coords = Left:336 Top:11 Right:368 Bottom:53
Status = NONE
DisplayHeight = 14
End
@@ -48,7 +52,7 @@ MappedImage RankChina_6
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:385 Top:10 Right:435 Bottom:54
+ Coords = Left:388 Top:11 Right:433 Bottom:53
Status = NONE
DisplayHeight = 14
End
@@ -57,7 +61,7 @@ MappedImage RankChina_7
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:449 Top:10 Right:512 Bottom:54
+ Coords = Left:452 Top:11 Right:508 Bottom:53
Status = NONE
DisplayHeight = 14
End
@@ -66,7 +70,7 @@ MappedImage RankChina_8
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:1 Top:74 Right:64 Bottom:118
+ Coords = Left:4 Top:75 Right:60 Bottom:117
Status = NONE
DisplayHeight = 14
End
@@ -75,7 +79,7 @@ MappedImage RankChina_9
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:65 Top:74 Right:128 Bottom:118
+ Coords = Left:68 Top:75 Right:124 Bottom:117
Status = NONE
DisplayHeight = 14
End
@@ -84,31 +88,34 @@ MappedImage RankChina_10
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:146 Top:74 Right:174 Bottom:100
+ Coords = Left:148 Top:72 Right:172 Bottom:98
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankChina_11
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:203 Top:74 Right:245 Bottom:100
+ Coords = Left:206 Top:72 Right:242 Bottom:98
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankChina_12
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:259 Top:74 Right:317 Bottom:100
+ Coords = Left:270 Top:64 Right:306 Bottom:105
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankChina_13
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:338 Top:74 Right:366 Bottom:106
+ Coords = Left:340 Top:72 Right:364 Bottom:104
Status = NONE
DisplayHeight = 14
End
@@ -117,7 +124,7 @@ MappedImage RankChina_14
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:395 Top:74 Right:437 Bottom:106
+ Coords = Left:398 Top:72 Right:434 Bottom:104
Status = NONE
DisplayHeight = 14
End
@@ -126,7 +133,7 @@ MappedImage RankChina_15
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:451 Top:74 Right:509 Bottom:106
+ Coords = Left:462 Top:64 Right:498 Bottom:111
Status = NONE
DisplayHeight = 14
End
@@ -135,7 +142,7 @@ MappedImage RankChina_16
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:0 Top:138 Right:64 Bottom:170
+ Coords = Left:14 Top:128 Right:50 Bottom:176
Status = NONE
DisplayHeight = 14
End
@@ -144,7 +151,7 @@ MappedImage RankChina_17
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:70 Top:135 Right:122 Bottom:172
+ Coords = Left:86 Top:137 Right:106 Bottom:165
Status = NONE
DisplayHeight = 14
End
@@ -153,7 +160,7 @@ MappedImage RankChina_18
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:134 Top:135 Right:186 Bottom:172
+ Coords = Left:141 Top:137 Right:179 Bottom:165
Status = NONE
DisplayHeight = 14
End
@@ -162,7 +169,7 @@ MappedImage RankChina_19
Texture = ReforgedRanksChina.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:194 Top:135 Right:254 Bottom:172
+ Coords = Left:205 Top:129 Right:243 Bottom:173
Status = NONE
DisplayHeight = 14
End
diff --git a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksGLA.ini b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksGLA.ini
index fa1364dfa..4f0fbf88f 100644
--- a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksGLA.ini
+++ b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksGLA.ini
@@ -9,6 +9,7 @@ MappedImage RankGLA_1
TextureHeight = 256
Coords = Left:88 Top:8 Right:105 Bottom:56
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankGLA_2
@@ -17,6 +18,7 @@ MappedImage RankGLA_2
TextureHeight = 256
Coords = Left:146 Top:8 Right:174 Bottom:58
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankGLA_3
@@ -25,6 +27,7 @@ MappedImage RankGLA_3
TextureHeight = 256
Coords = Left:205 Top:6 Right:243 Bottom:57
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankGLA_4
@@ -33,6 +36,7 @@ MappedImage RankGLA_4
TextureHeight = 256
Coords = Left:263 Top:6 Right:312 Bottom:58
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankGLA_5
@@ -41,6 +45,7 @@ MappedImage RankGLA_5
TextureHeight = 256
Coords = Left:324 Top:6 Right:381 Bottom:58
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankGLA_6
@@ -49,6 +54,7 @@ MappedImage RankGLA_6
TextureHeight = 256
Coords = Left:392 Top:8 Right:439 Bottom:53
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankGLA_7
@@ -57,6 +63,7 @@ MappedImage RankGLA_7
TextureHeight = 256
Coords = Left:455 Top:11 Right:512 Bottom:51
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankGLA_8
@@ -65,6 +72,7 @@ MappedImage RankGLA_8
TextureHeight = 256
Coords = Left:6 Top:76 Right:64 Bottom:115
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankGLA_9
@@ -73,6 +81,7 @@ MappedImage RankGLA_9
TextureHeight = 256
Coords = Left:69 Top:76 Right:128 Bottom:115
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankGLA_10
@@ -81,6 +90,7 @@ MappedImage RankGLA_10
TextureHeight = 256
Coords = Left:139 Top:72 Right:181 Bottom:118
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankGLA_11
@@ -89,6 +99,7 @@ MappedImage RankGLA_11
TextureHeight = 256
Coords = Left:201 Top:74 Right:256 Bottom:116
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankGLA_12
@@ -97,6 +108,7 @@ MappedImage RankGLA_12
TextureHeight = 256
Coords = Left:263 Top:74 Right:312 Bottom:116
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankGLA_13
@@ -105,6 +117,7 @@ MappedImage RankGLA_13
TextureHeight = 256
Coords = Left:326 Top:73 Right:380 Bottom:121
Status = NONE
+ DisplayHeight = 12
End
MappedImage RankGLA_14
diff --git a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksUSA.ini b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksUSA.ini
index 2d3e36f08..32c8bba01 100644
--- a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksUSA.ini
+++ b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksUSA.ini
@@ -9,8 +9,9 @@ MappedImage RankAmerica_1
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:64 Top:22 Right:128 Bottom:42
+ Coords = Left:64 Top:11 Right:128 Bottom:53
Status = NONE
+ DisplayHeight = 12
End
; E-3, Private First Class
@@ -18,8 +19,9 @@ MappedImage RankAmerica_2
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:128 Top:13 Right:192 Bottom:51
+ Coords = Left:128 Top:9 Right:192 Bottom:55
Status = NONE
+ DisplayHeight = 12
End
; E-4, Specialist
@@ -27,8 +29,9 @@ MappedImage RankAmerica_3
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:192 Top:3 Right:256 Bottom:61
+ Coords = Left:198 Top:1 Right:249 Bottom:63
Status = NONE
+ DisplayHeight = 12
End
; E-4, Corporal
@@ -36,8 +39,9 @@ MappedImage RankAmerica_4
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:256 Top:18 Right:320 Bottom:45
+ Coords = Left:256 Top:5 Right:320 Bottom:59
Status = NONE
+ DisplayHeight = 12
End
; E-5, Sergeant
@@ -45,8 +49,9 @@ MappedImage RankAmerica_5
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:320 Top:15 Right:384 Bottom:49
+ Coords = Left:323 Top:1 Right:381 Bottom:62
Status = NONE
+ DisplayHeight = 12
End
; E-6, Staff Sergeant
@@ -54,7 +59,7 @@ MappedImage RankAmerica_6
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:384 Top:6 Right:448 Bottom:58
+ Coords = Left:386 Top:1 Right:446 Bottom:63
Status = NONE
DisplayHeight = 14
End
@@ -64,7 +69,7 @@ MappedImage RankAmerica_7
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:450 Top:1 Right:510 Bottom:63
+ Coords = Left:456 Top:1 Right:504 Bottom:63
Status = NONE
DisplayHeight = 14
End
@@ -74,7 +79,7 @@ MappedImage RankAmerica_8
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:7 Top:65 Right:57 Bottom:127
+ Coords = Left:11 Top:65 Right:52 Bottom:127
Status = NONE
DisplayHeight = 14
End
@@ -84,7 +89,7 @@ MappedImage RankAmerica_9
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:64 Top:69 Right:127 Bottom:124
+ Coords = Left:74 Top:65 Right:117 Bottom:127
Status = NONE
DisplayHeight = 14
End
@@ -94,7 +99,7 @@ MappedImage RankAmerica_10
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:128 Top:69 Right:190 Bottom:124
+ Coords = Left:138 Top:65 Right:181 Bottom:127
Status = NONE
DisplayHeight = 14
End
@@ -104,7 +109,7 @@ MappedImage RankAmerica_11
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:192 Top:69 Right:255 Bottom:124
+ Coords = Left:202 Top:65 Right:245 Bottom:127
Status = NONE
DisplayHeight = 14
End
@@ -114,7 +119,7 @@ MappedImage RankAmerica_12
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:256 Top:69 Right:318 Bottom:124
+ Coords = Left:266 Top:65 Right:309 Bottom:127
Status = NONE
DisplayHeight = 14
End
@@ -124,8 +129,9 @@ MappedImage RankAmerica_13
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:320 Top:82 Right:384 Bottom:110
+ Coords = Left:320 Top:75 Right:384 Bottom:117
Status = NONE
+ DisplayHeight = 12
End
; W-2, Chief Warrant Officer 2
@@ -133,8 +139,9 @@ MappedImage RankAmerica_14
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:384 Top:82 Right:448 Bottom:110
+ Coords = Left:384 Top:75 Right:448 Bottom:117
Status = NONE
+ DisplayHeight = 12
End
; W-3, Chief Warrant Officer 3
@@ -142,8 +149,9 @@ MappedImage RankAmerica_15
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:448 Top:82 Right:512 Bottom:110
+ Coords = Left:448 Top:75 Right:512 Bottom:117
Status = NONE
+ DisplayHeight = 12
End
; W-4, Chief Warrant Officer 4
@@ -151,8 +159,9 @@ MappedImage RankAmerica_16
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:0 Top:146 Right:64 Bottom:174
+ Coords = Left:0 Top:139 Right:64 Bottom:181
Status = NONE
+ DisplayHeight = 12
End
; W-5, Chief Warrant Officer 5
@@ -160,8 +169,9 @@ MappedImage RankAmerica_17
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:64 Top:146 Right:128 Bottom:174
+ Coords = Left:64 Top:139 Right:128 Bottom:181
Status = NONE
+ DisplayHeight = 12
End
; O-1, Second Lieutenant
@@ -169,8 +179,9 @@ MappedImage RankAmerica_18
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:128 Top:146 Right:192 Bottom:174
+ Coords = Left:128 Top:139 Right:192 Bottom:181
Status = NONE
+ DisplayHeight = 12
End
; O-2, First Lieutenant
@@ -178,8 +189,9 @@ MappedImage RankAmerica_19
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:192 Top:146 Right:256 Bottom:174
+ Coords = Left:192 Top:139 Right:256 Bottom:181
Status = NONE
+ DisplayHeight = 12
End
; O-3, Captain
@@ -187,8 +199,9 @@ MappedImage RankAmerica_20
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:256 Top:140 Right:320 Bottom:180
+ Coords = Left:256 Top:132 Right:320 Bottom:188
Status = NONE
+ DisplayHeight = 12
End
; O-4, Major
@@ -228,6 +241,7 @@ MappedImage RankAmerica_24
TextureHeight = 256
Coords = Left:2 Top:195 Right:62 Bottom:253
Status = NONE
+ DisplayHeight = 12
End
; O-8, Major General
@@ -235,8 +249,9 @@ MappedImage RankAmerica_25
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:66 Top:208 Right:126 Bottom:240
+ Coords = Left:66 Top:197 Right:126 Bottom:251
Status = NONE
+ DisplayHeight = 12
End
; O-9, Lieutenant General
@@ -244,8 +259,9 @@ MappedImage RankAmerica_26
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:130 Top:212 Right:190 Bottom:236
+ Coords = Left:130 Top:196 Right:190 Bottom:253
Status = NONE
+ DisplayHeight = 12
End
; O-10, General
@@ -253,8 +269,9 @@ MappedImage RankAmerica_27
Texture = ReforgedRanksUSA.tga
TextureWidth = 512
TextureHeight = 256
- Coords = Left:194 Top:215 Right:254 Bottom:233
+ Coords = Left:194 Top:194 Right:254 Bottom:254
Status = NONE
+ DisplayHeight = 12
End
; O-11, General of the Army
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h
index 9a2d06a61..c3d9c375f 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h
@@ -936,7 +936,7 @@ public:
static Bool drawRankInsignia( const ThingTemplate *thing, Int insignia, Int x, Int top, Bool centred, Real scale, Color color );
static const Image *getRankInsignia( const ThingTemplate *thing, Int insignia ); ///< NULL: none drawn
static const Image *getRankInsignia( const Object *obj ); ///< what obj wears now; NULL at grade 0 and for anything that cannot climb
- /// its health bar size: DisplayHeight high (12 when unset), width following up to 36, all times `scale`
+ /// its health bar size: DisplayHeight high (12 when unset), width following up to 1.5 times the height, all times `scale`
static void rankInsigniaSize( const Image *image, Real scale, Int *width, Int *height );
#ifdef DIRTY_CONDITION_FLAGS
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
index cb96ec631..644914984 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
@@ -310,9 +310,9 @@ const Int MAX_ENABLED_MODULES = 16;
static const Image* s_rankInsignia[VETERANCY_SIDE_COUNT][RANK_GRADES_MAX + 1];
/// An insignia drawn beside a health bar holds its DisplayHeight (12 unless its cell says otherwise)
-/// and lets its width follow, up to this
+/// and lets its width follow, up to half again that height: wider marks made the bar look heavy
static const Int RANK_INSIGNIA_DEFAULT_HEIGHT = 12;
-static const Int RANK_INSIGNIA_MAX_WIDTH = 36;
+static const Real RANK_INSIGNIA_MAX_ASPECT = 1.5f;
// ------------------------------------------------------------------------------------------------
/*static*/ void Drawable::initStaticImages()
@@ -4739,10 +4739,10 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
const Real high = ( image->getDisplayHeight() > 0 ? image->getDisplayHeight() : RANK_INSIGNIA_DEFAULT_HEIGHT ) * scale;
Real wide = high * image->getImageWidth() / image->getImageHeight();
Real tall = high;
- if( wide > RANK_INSIGNIA_MAX_WIDTH * scale )
+ if( wide > high * RANK_INSIGNIA_MAX_ASPECT )
{
- tall = high * RANK_INSIGNIA_MAX_WIDTH * scale / wide;
- wide = RANK_INSIGNIA_MAX_WIDTH * scale;
+ tall = high * high * RANK_INSIGNIA_MAX_ASPECT / wide;
+ wide = high * RANK_INSIGNIA_MAX_ASPECT;
}
*width = REAL_TO_INT( wide );
*height = REAL_TO_INT( tall );
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp
index 047bf3511..d0f1de746 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp
@@ -125,7 +125,9 @@ static const Real CLASSIC_KEY_BADGE_DESIGN_POINTS = 12.0f;
//=============================================================================
/** EA's overlays (the chevrons) are drawn over the whole button. An image with its own DisplayHeight,
* a rank insignia cropped to its ink, keeps its shape in the top left corner instead: that many
- * forty-eighths of the button's height, as wide as its shape says, up to half the button. */
+ * forty-eighths of the button's height, as wide as its shape says, up to half again its height and
+ * half the button. Every rank cell carries a DisplayHeight for this; one without it was stretched
+ * over the whole portrait. */
static void drawOverlayImage( const Image *image, Int x, Int y, Int width, Int height )
{
if( image->getDisplayHeight() <= 0 )
@@ -135,10 +137,11 @@ static void drawOverlayImage( const Image *image, Int x, Int y, Int width, Int h
}
Real high = height * image->getDisplayHeight() / 48.0f;
Real wide = high * image->getImageWidth() / image->getImageHeight();
- if( wide > width * 0.5f )
+ const Real widest = MIN( high * 1.5f, width * 0.5f );
+ if( wide > widest )
{
- high *= width * 0.5f / wide;
- wide = width * 0.5f;
+ high *= widest / wide;
+ wide = widest;
}
const Int inset = 2;
TheDisplay->drawImage( image, x + inset, y + inset, x + inset + REAL_TO_INT( wide ), y + inset + REAL_TO_INT( high ) );
diff --git a/GeneralsMD/Code/Tools/rank_insignia_cells.py b/GeneralsMD/Code/Tools/rank_insignia_cells.py
index 9e8a8cc7f..de7d9307a 100644
--- a/GeneralsMD/Code/Tools/rank_insignia_cells.py
+++ b/GeneralsMD/Code/Tools/rank_insignia_cells.py
@@ -1,13 +1,16 @@
"""The rank atlases' mapped images as the game reads them, shared by the three rank_insignia_*.py
generators: each cell cropped to its ink, so a row of stars or a warrant bar draws at its own shape
instead of squeezed into a square; named for its grade, Rank<Side>_<n> in the order the atlas holds
-them, which is the order of the side's ladder; and the stacked or busy cells given DisplayHeight 14
-where the rest draw 12 high. A cell with no ink (America's E-1) gets no image and draws nothing."""
+them, which is the order of the side's ladder; and every cell given its DisplayHeight, 14 for the
+stacked or busy ones and 12 for the rest. A cell with no ink (America's E-1) gets no image and draws nothing."""
import re
ENTRY = re.compile(r"MappedImage (\S+)\n(.*?)Coords = Left:(\d+) Top:(\d+) Right:(\d+) Bottom:(\d+)\n(.*?)End\n", re.S)
INK = 16 # alpha under this is the antialiasing's fringe, not ink
TALL = " DisplayHeight = 14\n"
+# written on every cell, not only the tall ones: the command bar draws an overlay with no DisplayHeight
+# over the whole button the way EA's chevrons go, which stretched a 12-high insignia over the portrait
+SHORT = " DisplayHeight = 12\n"
def ink_entries(atlas, ini_text, side, tall=()):
@@ -23,7 +26,7 @@ def ink_entries(atlas, ini_text, side, tall=()):
return ""
return "MappedImage Rank%s_%d\n%sCoords = Left:%d Top:%d Right:%d Bottom:%d\n%s%sEnd\n" % (
side, grade, match.group(2), left + box[0], top + box[1], left + box[2], top + box[3],
- match.group(7), TALL if grade in tall else "")
+ match.group(7), TALL if grade in tall else SHORT)
return ENTRY.sub(rewrite, ini_text)
@@ -36,4 +39,6 @@ if __name__ == "__main__":
out = ink_entries(test, "; x\n" + entry % (0, 64) + entry % (64, 128), "Test", tall=(1,))
assert "RankTest_0" not in out, out
assert "MappedImage RankTest_1" in out and "Left:70 Top:10 Right:90 Bottom:20" in out and TALL in out, out
+ short = ink_entries(test, "; x\n" + entry % (0, 64) + entry % (64, 128), "Test")
+ assert SHORT in short, short
print("ok")
diff --git a/GeneralsMD/Code/Tools/rank_insignia_china.py b/GeneralsMD/Code/Tools/rank_insignia_china.py
index d1fbf9bdc..840311a59 100644
--- a/GeneralsMD/Code/Tools/rank_insignia_china.py
+++ b/GeneralsMD/Code/Tools/rank_insignia_china.py
@@ -2,8 +2,10 @@
Each mark is the shoulder board's sign without the board, simplified for twelve to fourteen pixels
high: silver chevrons for conscripts, gold for sergeants, the senior sergeants' pine branches traded
-for one to four pips beside three chevrons, a row of big stars over one stripe for company officers
-and two for field officers, and the generals' stars over a thick laurel arc. A dark red edge and no
+for one to four pips beside three chevrons, stars in a tight cluster (two side by side, three in a
+triangle, four two over two) over one short stripe for company officers and two for field officers,
+and the generals' stars cupped by a laurel arc. Chevrons are steep and narrow and no mark is wider
+than half again its height, since wide marks made the health bar look heavy. A dark red edge and no
background, so they read over sand and grass the way the America and GLA marks do.
The ranks are the 2022 ones. The reform renamed two sergeant grades and kept their boards:
@@ -51,11 +53,12 @@ MappedImage RankChina_%s
End
"""
-CHEVRON = 8.0 # every chevron one weight: the board's thin and thick came out alike at game size
-GAP = 3.5
-RISE = 9.0
-PIP = 5.5 # radius of a senior sergeant's pip
-PIP_PITCH = 12.5
+CHEVRON = 6.5 # every chevron one weight: the board's thin and thick came out alike at game size
+GAP = 3.0
+RISE = 12.0 # steep and narrow, so a lone chevron is no wider than half again its height
+CHEVRON_HALF_WIDTH = 14
+PIP = 5.0 # radius of a senior sergeant's pip
+PIP_PITCH = 11.5
SILVER_TOP = (252, 252, 252)
SILVER_BOTTOM = (138, 146, 160)
@@ -103,9 +106,17 @@ def star(draw, cx, cy, radius):
def stars(draw, count, cy, radius, pitch):
- """count stars in a row centred across the cell at height cy."""
- for i in range(count):
- star(draw, 32 + (i - (count - 1) / 2) * pitch, cy, radius)
+ """count stars in a tight cluster centred across the cell on cy: two side by side, three in a
+ triangle, four two over two, so no mark runs wider than half again its height. Returns the
+ cluster's half width and its bottom."""
+ layout = {1: [(0, 0)],
+ 2: [(-0.5, 0), (0.5, 0)],
+ 3: [(0, -0.45), (-0.5, 0.45), (0.5, 0.45)],
+ 4: [(-0.5, -0.5), (0.5, -0.5), (-0.5, 0.5), (0.5, 0.5)]}[count]
+ for x, y in layout:
+ star(draw, 32 + x * pitch, cy + y * pitch, radius)
+ half_width = max(x for x, _ in layout) * pitch + radius * 0.95
+ return half_width, cy + max(y for _, y in layout) * pitch + radius * 0.81
def chevron(draw, cx, top, half_width):
@@ -133,27 +144,30 @@ def mark(kind):
_, count, pip_count, _ = kind
height = count * CHEVRON + (count - 1) * GAP + RISE
top = (CELL - height) / 2
- cx, half_width = (19, 16) if pip_count else (32, 26)
+ cx = 32 - (PIP_PITCH + 2 * PIP + 3) / 2 if pip_count else 32
for i in range(count):
- chevron(draw, cx, top + i * (CHEVRON + GAP), half_width)
+ chevron(draw, cx, top + i * (CHEVRON + GAP), CHEVRON_HALF_WIDTH)
if pip_count:
- pips(draw, pip_count, 50, top + height / 2)
+ pips(draw, pip_count, cx + CHEVRON_HALF_WIDTH + 3 + PIP + PIP_PITCH / 2, top + height / 2)
elif kind[0] == "none":
pass
elif kind[0] == "officer":
- # big stars over the board's stripe, one for company officers and two for field officers
+ # stars over the board's stripe, one for company officers and two for field officers, the
+ # stripe only as wide as the stars
_, stripe_count, count = kind
- # the stripe only as wide as the stars, so a lone star is not a dot on a long bar
- radius, pitch = 8.5, 16.5
- half = max(12, ((count - 1) * pitch) / 2 + radius + 2)
- stars(draw, count, 20, radius, pitch)
+ half, bottom = stars(draw, count, 18, 8.5, 16)
+ half = max(half, 10)
for i in range(stripe_count):
- draw.rectangle(scaled([(32 - half, 30 + 6.5 * i), (32 + half, 34 + 6.5 * i)]), fill=255)
+ y = bottom + 3 + 6.5 * i
+ draw.rectangle(scaled([(32 - half, y), (32 + half, y + 4)]), fill=255)
else:
- # bigger stars over a plain thick laurel arc for the wreath
+ # bigger stars cupped by a plain thick laurel arc for the wreath
_, count = kind
- stars(draw, count, 18, 9.5, 19.5)
- draw.arc(scaled([(5, -14), (59, 42)]), start=25, end=155, fill=255, width=round(5.5 * SCALE))
+ cy = 20
+ half, bottom = stars(draw, count, cy, 9, 17)
+ drop = bottom - cy + 8
+ draw.arc(scaled([(32 - half, cy - drop), (32 + half, cy + drop)]),
+ start=15, end=165, fill=255, width=round(4 * SCALE))
return shape
diff --git a/GeneralsMD/Code/Tools/rank_insignia_usa.py b/GeneralsMD/Code/Tools/rank_insignia_usa.py
index 477dc1398..fc18ab225 100644
--- a/GeneralsMD/Code/Tools/rank_insignia_usa.py
+++ b/GeneralsMD/Code/Tools/rank_insignia_usa.py
@@ -5,9 +5,11 @@ warrant officers W-1 to W-5, officers O-1 to O-10, and General of the Army.
Same look as rank_insignia.py: no plate, a black edge round every mark so it reads on sand and
grass, metal lit from the top. Enlisted chevrons are gold stripes on a black patch cut to their
shape, the Army's dress pattern. The game draws these twelve to fourteen pixels high beside the
-health bar, so each mark is fitted to fill its 64-pixel cell and cut to what survives that: flat
-fat stripes, the E-8 and E-9 devices in silver beside the stripes, a solid eagle, veinless leaves,
-solid black squares on taller warrant bars, and one ringed gold star for General of the Army.
+health bar, no wider than half again their height, so each mark is fitted to fill its 64-pixel cell
+and cut to what survives that: steep chevrons and fat rockers, the E-8 and E-9 devices big in the
+middle of the stack in a colour each (silver, gold, red, blue), a solid eagle, veinless leaves,
+short warrant bars with solid black squares, stars in clusters rather than rows, and one ringed
+gold star for General of the Army.
python Tools/rank_insignia_usa.py
writes Data/Art/Textures/ReforgedRanksUSA.tga, an 8 by 4 atlas of 64-pixel cells, and
@@ -90,90 +92,94 @@ def eagle(draw, cx, cy, s, fill=255):
draw.polygon(at([(-5, 8), (5, 8), (8, 15), (-8, 15)]), fill=fill) # tail
-# Enlisted stripes, flat and fat so a rocker is a pixel and a half at fourteen high: half width, drop
-# of a chevron arm, chevron thickness and pitch (the three chevrons read as one block with hairline
-# cuts, since every sergeant has three), the gap under them, rocker thickness, pitch and sag.
-W, D, T, PITCH = 21, 6, 4, 5.5
-ROCKER_GAP, ROCKER_T, ROCKER_PITCH, SAG = 2.5, 6.5, 10, 4
-DEVICE_GAP = 2.5 # between the stripes and the device beside them
-DEVICE_SHIFT = 10 # how far the stripes move left when a device sits beside them
-DEVICE_RIGHT = 31.5
+# Enlisted stripes. Chevrons alone are steep and narrow, so a lone chevron is no wider than half again
+# its height; over rockers they flatten and widen, since the stack is tall already and the rockers
+# need the width. Rockers are fat with a wide gap, so one, two and three count at fourteen pixels.
+STEEP, FLAT = (14, 14), (18, 7) # half width and drop of a chevron arm
+T, PITCH = 4.5, 6
+ROCKER_GAP, ROCKER_T, ROCKER_PITCH, SAG = 3, 7, 11, 4
+# E-8 and E-9: the device is what tells them apart, so it goes big in the middle of the stack, in a
+# colour of its own, on one deep rocker that cradles it, in place of three rockers it had no room
+# among
+DEVICE_R = 11 # the device's half size
+CRADLE_SAG = 15
+RED = ((255, 120, 100), (170, 34, 24))
+BLUE = ((150, 200, 255), (40, 86, 190))
-def chevron(apex):
- return [(-W, apex + D), (0, apex), (W, apex + D), (W, apex + D + T), (0, apex + T), (-W, apex + D + T)]
+def chevron(apex, w, d):
+ return [(-w, apex + d), (0, apex), (w, apex + d), (w, apex + d + T), (0, apex + T), (-w, apex + d + T)]
-def curve(end_y, steps=24):
- return [(-W + 2 * W * i / steps, end_y + SAG * (1 - ((-W + 2 * W * i / steps) / W) ** 2))
+def curve(end_y, w, sag=SAG, steps=24):
+ return [(-w + 2 * w * i / steps, end_y + sag * (1 - ((-w + 2 * w * i / steps) / w) ** 2))
for i in range(steps + 1)]
def stripes(chevrons, rockers, device=None):
- """Gold chevrons and rockers on their black patch; the device that tells E-8 and E-9 apart goes
- beside them, full height, since the gap between was two pixels."""
+ """Gold chevrons and rockers on their black patch, or with a device: three chevrons, the device
+ under them and one deep rocker round it."""
+ w, d = FLAT if rockers or device else STEEP
gold, back = canvas(), canvas()
g, b = ImageDraw.Draw(gold), ImageDraw.Draw(back)
top = -30
for k in range(chevrons):
- g.polygon(px(chevron(top + PITCH * k)), fill=255)
+ g.polygon(px(chevron(top + PITCH * k, w, d)), fill=255)
low = top + PITCH * (chevrons - 1)
- first_rocker = low + D + T + ROCKER_GAP
+ if device:
+ cy = low + T + d + ROCKER_GAP + DEVICE_R
+ tips = cy - DEVICE_R * 0.3
+ g.polygon(px(curve(tips, w, CRADLE_SAG) + curve(tips + ROCKER_T, w, CRADLE_SAG)[::-1]), fill=255)
+ b.polygon(px([(-w, top + d), (0, top), (w, top + d)] + curve(tips + ROCKER_T, w, CRADLE_SAG)[::-1]),
+ fill=255)
+ layer = canvas()
+ draw_device, colours = device
+ draw_device(ImageDraw.Draw(layer), cy)
+ return gold, back, GOLD, layer, colours
+ first_rocker = low + d + T + ROCKER_GAP
for j in range(rockers):
end_y = first_rocker + ROCKER_PITCH * j
- g.polygon(px(curve(end_y) + curve(end_y + ROCKER_T)[::-1]), fill=255)
+ g.polygon(px(curve(end_y, w) + curve(end_y + ROCKER_T, w)[::-1]), fill=255)
if rockers:
- bottom = curve(first_rocker + ROCKER_PITCH * (rockers - 1) + ROCKER_T)[::-1]
- floor = first_rocker + ROCKER_PITCH * (rockers - 1) + ROCKER_T + SAG
+ bottom = curve(first_rocker + ROCKER_PITCH * (rockers - 1) + ROCKER_T, w)[::-1]
else:
- bottom = [(W, low + D + T), (0, low + T), (-W, low + D + T)]
- floor = low + D + T
- b.polygon(px([(-W, top + D), (0, top), (W, top + D)] + bottom), fill=255)
- if device:
- # the design space ends at 32 units, so the stripes move left to make room
- shift = -DEVICE_SHIFT * UNIT
- gold, back = ImageChops.offset(gold, shift, 0), ImageChops.offset(back, shift, 0)
- silver = canvas()
- device(ImageDraw.Draw(silver), W + DEVICE_GAP - DEVICE_SHIFT, top, floor)
- return gold, back, GOLD, silver # silver, so the small device parts from the gold stripes
+ bottom = [(w, low + d + T), (0, low + T), (-w, low + d + T)]
+ b.polygon(px([(-w, top + d), (0, top), (w, top + d)] + bottom), fill=255)
return gold, back, GOLD
-def lozenge(draw, left, top, bottom):
- half_w = (DEVICE_RIGHT - left) / 2
- cx, cy, half_h = left + half_w, (top + bottom) / 2, half_w * 1.7
- draw.polygon(px([(cx, cy - half_h), (cx + half_w, cy), (cx, cy + half_h), (cx - half_w, cy)]), fill=255)
+def lozenge(draw, cy):
+ r = DEVICE_R * 1.1
+ draw.polygon(px([(0, cy - r), (r * 0.75, cy), (0, cy + r), (-r * 0.75, cy)]), fill=255)
-def sgm_star(draw, left, top, bottom):
- r = (DEVICE_RIGHT - left) / 2 / 0.951
- star(draw, (left + DEVICE_RIGHT) / 2, (top + bottom) / 2 + 1, r)
+def sgm_star(draw, cy):
+ star(draw, 0, cy + 1, DEVICE_R * 1.1)
-def csm_wreath(draw, left, top, bottom):
- r = (DEVICE_RIGHT - left) / 2
- cx, cy = left + r, (top + bottom) / 2
- draw.ellipse(box(cx - r, cy - r, cx + r, cy + r), outline=255, width=round(3 * UNIT))
- star(draw, cx, cy + 0.5, r * 0.6)
+def csm_wreath(draw, cy):
+ r = DEVICE_R
+ draw.ellipse(box(-r, cy - r, r, cy + r), outline=255, width=round(3 * UNIT))
+ star(draw, 0, cy + 0.5, r * 0.62)
-def sma_stars(draw, left, top, bottom):
- r = (DEVICE_RIGHT - left) / 2 / 0.951
- for cy in (top + r + 2, bottom - r):
- star(draw, (left + DEVICE_RIGHT) / 2, cy, r)
+def sma_stars(draw, cy):
+ for x in (-7, 7):
+ star(draw, x, cy + 1, DEVICE_R * 0.75)
def specialist():
- """The Specialist's eagle on a patch with a pointed top and a round bottom, gold edged."""
+ """The Specialist's eagle, big, on a tall patch with a pointed top and a round bottom, gold
+ edged: the eagle fills the patch so the badge reads as a bird and not a disc."""
gold, back = canvas(), canvas()
- bottom = [(x * 22 / W, 6 + 13 * (1 - (x / W) ** 2)) for x, _ in curve(0)][::-1]
- outer = [(0, -22), (22, -8), (22, 6)] + bottom + [(-22, 6), (-22, -8)]
- inner = [(x * 0.85, y * 0.85 - 0.3) for x, y in outer]
+ bottom = [(x, 8 + 12 * (1 - (x / 18) ** 2)) for x, _ in curve(0, 18)][::-1]
+ outer = [(0, -26), (18, -14), (18, 8)] + bottom + [(-18, 8), (-18, -14)]
+ inner = [(x * 0.88, y * 0.9) for x, y in outer]
ImageDraw.Draw(back).polygon(px(outer), fill=255)
g = ImageDraw.Draw(gold)
g.polygon(px(outer), fill=255)
g.polygon(px(inner), fill=0)
- eagle(g, 0, -0.5, 0.7)
+ eagle(g, 0, 0, 0.68)
return gold, back, GOLD
@@ -182,15 +188,15 @@ def bar(metal, holes=0, line=False):
solid black on the patch rather than holes the edge half filled in."""
gold, back = canvas(), canvas()
g = ImageDraw.Draw(gold)
- outline = box(-25, -9, 25, 9)
+ outline = box(-16.5, -10, 16.5, 10)
g.rounded_rectangle(outline, radius=3 * UNIT, fill=255)
ImageDraw.Draw(back).rounded_rectangle(outline, radius=3 * UNIT, fill=255)
- pitch, size = 11.5, 8
+ pitch, size = 7, 5.5
for i in range(holes):
x = (i - (holes - 1) / 2) * pitch
g.rectangle(box(x - size / 2, -size / 2, x + size / 2, size / 2), fill=0)
if line:
- g.rectangle(box(-20, -2.5, 20, 2.5), fill=0)
+ g.rectangle(box(-13, -2.5, 13, 2.5), fill=0)
return gold, back, metal
@@ -199,8 +205,8 @@ def captain():
gold = canvas()
g = ImageDraw.Draw(gold)
for y in (-7, 7):
- g.rounded_rectangle(box(-20, y - 4.5, 20, y + 4.5), radius=2 * UNIT, fill=255)
- for x in (-14, 14):
+ g.rounded_rectangle(box(-13, y - 4.5, 13, y + 4.5), radius=2 * UNIT, fill=255)
+ for x in (-8.5, 8.5):
g.rectangle(box(x - 1.8, -3, x + 1.8, 3), fill=255)
return gold, gold, SILVER
@@ -227,8 +233,14 @@ def colonel():
def stars(count):
gold = canvas()
g = ImageDraw.Draw(gold)
- for i in range(count):
- star(g, (i - (count - 1) / 2) * 15, 0, 8.2)
+ # a tight cluster rather than a row: two on a slant, three in a triangle, four two over two
+ layout = {1: [(0, 0)],
+ 2: [(-0.4, -0.3), (0.4, 0.3)],
+ 3: [(0, -0.45), (-0.5, 0.45), (0.5, 0.45)],
+ 4: [(-0.5, -0.5), (0.5, -0.5), (-0.5, 0.5), (0.5, 0.5)]}[count]
+ pitch = 15
+ for x, y in layout:
+ star(g, x * pitch, y * pitch, 8.2)
return gold, gold, SILVER
@@ -257,10 +269,10 @@ RANKS = [
("RankUSA_E6", "E-6", "Staff Sergeant", lambda: stripes(3, 1)),
("RankUSA_E7", "E-7", "Sergeant First Class", lambda: stripes(3, 2)),
("RankUSA_E8", "E-8", "Master Sergeant", lambda: stripes(3, 3)),
- ("RankUSA_E8_1SG", "E-8", "First Sergeant", lambda: stripes(3, 3, lozenge)),
- ("RankUSA_E9", "E-9", "Sergeant Major", lambda: stripes(3, 3, sgm_star)),
- ("RankUSA_E9_CSM", "E-9", "Command Sergeant Major", lambda: stripes(3, 3, csm_wreath)),
- ("RankUSA_E9_SMA", "E-9", "Sergeant Major of the Army", lambda: stripes(3, 3, sma_stars)),
+ ("RankUSA_E8_1SG", "E-8", "First Sergeant", lambda: stripes(3, 1, (lozenge, SILVER))),
+ ("RankUSA_E9", "E-9", "Sergeant Major", lambda: stripes(3, 1, (sgm_star, GOLD))),
+ ("RankUSA_E9_CSM", "E-9", "Command Sergeant Major", lambda: stripes(3, 1, (csm_wreath, RED))),
+ ("RankUSA_E9_SMA", "E-9", "Sergeant Major of the Army", lambda: stripes(3, 1, (sma_stars, BLUE))),
("RankUSA_W1", "W-1", "Warrant Officer 1", lambda: bar(SILVER, 1)),
("RankUSA_W2", "W-2", "Chief Warrant Officer 2", lambda: bar(SILVER, 2)),
("RankUSA_W3", "W-3", "Chief Warrant Officer 3", lambda: bar(SILVER, 3)),
@@ -283,7 +295,7 @@ RANKS = [
def icon(design):
"""One 64-pixel cell: the design fitted to the cell, lit, edged in black."""
gold, back, colours, *device = design()
- silver = device[0] if device else canvas()
+ silver, device_colours = device if device else (canvas(), SILVER)
size = CELL * SCALE
union = ImageChops.lighter(ImageChops.lighter(gold, back), silver)
bbox = union.getbbox()
@@ -311,7 +323,7 @@ def icon(design):
# the black edge: a blur thresholded about two sigmas out, so OUTLINE pixels wide
alpha = union.filter(ImageFilter.GaussianBlur(OUTLINE * SCALE / 2)).point(lambda v: 255 if v >= 6 else 0)
art = Image.composite(lit(*colours), Image.new("RGB", (size, size), (0, 0, 0)), gold)
- art = Image.composite(lit(*SILVER), art, silver)
+ art = Image.composite(lit(*device_colours), art, silver)
art.putalpha(ImageChops.lighter(alpha, union))
return art.resize((CELL, CELL), Image.LANCZOS)