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): start spot colour cut from EA's own ring art

Olcay Seygand02439dffc90
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e9205e6d7..7d605a288 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -62,7 +62,7 @@ found and fixed — EA's own, not port damage.**
## A lobby built for your screen
- The skirmish, LAN and online rooms are laid out again from scratch, the same way in all three. Each seat is one row: a bar in that player's colour, the player or the computer's level with its personality beside it, the army, the colour and the team, with the colour swatches framed and sized like the check boxes under the map. In LAN and online games a player who is ready turns his whole row green and the host's row wears a gold edge, so you see who you are waiting for without hunting for a little light.
-- Teams have colours of their own: white, black, brown and teal for teams 1 to 4, none of them a colour a player can pick, and four different greys even to an eye that sees no colour at all. A swatch beside the team box shows it, and on the map preview a taken start spot keeps its blue ring and has its dark middle filled with its team's colour, or the player's when he has no team, so you see who starts beside whom before the match. The seat's number stays on it, in black or white, whichever reads better on that colour.
+- Teams have colours of their own: white, black, brown and teal for teams 1 to 4, none of them a colour a player can pick, and four different greys even to an eye that sees no colour at all. A swatch beside the team box shows it, and on the map preview a taken start spot keeps its blue ring and its dark middle turns its team's colour, or the player's when he has no team, so you see who starts beside whom before the match. The colour runs right up to the ring and takes the soft inner edge EA painted for the black, instead of a smaller disc with a black gap round it. The seat's number stays on it, in black or white, whichever reads better on that colour.
- The map preview is square at last, 410 pixels a side in the skirmish room at 1080p where it was a 422 by 266 oblong of a square map, and the match rules sit under it the whole time. The Info, Chat and Lobby Settings tabs are gone: the match rules never hide behind a click. In the skirmish room the seats get the whole height and your medals and career record open from the Record button beside Back, over the room dimmed behind them; Escape, Close or a click beside them puts them away. The network rooms keep their chat under the seats.
- The rooms used to be a 4:3 screen pulled out to fit a wide monitor, so every emblem, start spot and the map itself came out a third wider than tall. They are drawn for 16:9 now and keep their shape on any screen: exact at 1080p, twice that at 4K, and centred between bands on a 4:3 or 16:10 monitor instead of squashed.
- The personality list opens eight lines tall with a scroll bar. Opened from a lower seat, its sixteen lines used to run off the bottom of the screen.
diff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedLobbySpot.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedLobbySpot.tga
index b6f4267d9..6037f4db3 100644
Binary files a/GeneralsMD/Code/Data/Art/Textures/ReforgedLobbySpot.tga and b/GeneralsMD/Code/Data/Art/Textures/ReforgedLobbySpot.tga differ
diff --git a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedLobbySpot.ini b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedLobbySpot.ini
index 951465192..b111626f2 100644
--- a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedLobbySpot.ini
+++ b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedLobbySpot.ini
@@ -1,11 +1,20 @@
-; The disc a taken start spot on a staging room's map preview is filled with, tinted with its team's
-; colour as it is drawn. Written by Tools/lobby_spot.py with Art/Textures/ReforgedLobbySpot.tga; do
-; not edit by hand. Mapped images are not in the multiplayer INI checksum.
+; A start spot cut from EA's PlayerStart: the middle in white, tinted with the spot's colour as it
+; is drawn, and the ring with the middle taken out, drawn over it untinted. Written by
+; Tools/lobby_spot.py with Art/Textures/ReforgedLobbySpot.tga; do not edit by hand. Mapped images
+; are not in the multiplayer INI checksum.
MappedImage ReforgedLobbySpot
Texture = ReforgedLobbySpot.tga
TextureWidth = 64
- TextureHeight = 64
- Coords = Left:0 Top:0 Right:64 Bottom:64
+ TextureHeight = 32
+ Coords = Left:0 Top:0 Right:25 Bottom:25
+ Status = NONE
+End
+
+MappedImage ReforgedLobbySpotRing
+ Texture = ReforgedLobbySpot.tga
+ TextureWidth = 64
+ TextureHeight = 32
+ Coords = Left:32 Top:0 Right:57 Bottom:25
Status = NONE
End
diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GUIUtil.h b/GeneralsMD/Code/GameEngine/Include/GameNetwork/GUIUtil.h
index 15a3d7b64..2b1c51f1c 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GUIUtil.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameNetwork/GUIUtil.h
@@ -141,8 +141,8 @@ Color LobbyTeamColor(Int team);
Color LobbySeatColor(const GameSlot *slot);
// Black or white, whichever has the higher WCAG contrast on this fill.
Color LobbyTextColorOn(Color fill);
-// A taken start spot's colour, laid in the dark middle of EA's PlayerStart ring drawn over this
-// rectangle; the room's spot buttons and the load screen's map both draw it.
+// A taken start spot over EA's PlayerStart drawn in this rectangle: its middle in the colour and its
+// ring as EA drew it. The room's spot buttons and the load screen's map both draw it.
void LobbyStartSpotFill(Int x, Int y, Int width, Int height, Color fill);
void EnableSlotListUpdates( Bool val );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp
index a4c53c539..4932f5b0f 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp
@@ -1011,13 +1011,11 @@ Color LobbyTextColorOn(Color fill)
void LobbyStartSpotFill(Int x, Int y, Int width, Int height, Color fill)
{
- // EA's PlayerStart art is 25 pixels square with a drop shadow to the lower right, so its dark middle
- // is not centred in it: it covers source pixels 3 to 18 both ways. Those bounds scale with the
- // rectangle and round to the nearest pixel.
- const Int artSize = 25, holeStart = 3, holeEnd = 19;
- TheDisplay->drawImage(TheMappedImageCollection->findImageByName("ReforgedLobbySpot"),
- x + (width * holeStart + artSize / 2) / artSize, y + (height * holeStart + artSize / 2) / artSize,
- x + (width * holeEnd + artSize / 2) / artSize, y + (height * holeEnd + artSize / 2) / artSize, fill);
+ // both halves are cut from EA's PlayerStart cell (Tools/lobby_spot.py), so they lie on it pixel for
+ // pixel: the white middle multiplied by the colour, then the ring over it untinted, its inner edge
+ // fading into the colour as it faded into the black
+ TheDisplay->drawImage(TheMappedImageCollection->findImageByName("ReforgedLobbySpot"), x, y, x + width, y + height, fill);
+ TheDisplay->drawImage(TheMappedImageCollection->findImageByName("ReforgedLobbySpotRing"), x, y, x + width, y + height);
}
// A colour swatch drawn as one of the rules page's check boxes: their own empty box, and the colour
diff --git a/GeneralsMD/Code/Tools/lobby_spot.py b/GeneralsMD/Code/Tools/lobby_spot.py
index 7661e7c6c..ed4910157 100644
--- a/GeneralsMD/Code/Tools/lobby_spot.py
+++ b/GeneralsMD/Code/Tools/lobby_spot.py
@@ -1,48 +1,136 @@
-"""The disc a taken start spot on a staging room's map preview is filled with.
+"""The start spot on a staging room's map preview and the load screen's map, cut from EA's own.
-One white disc with a smooth edge; the game multiplies it by the spot's team colour, or its player's
-colour without a team, as it draws it (drawStartSpot in SkirmishGameOptionsMenu.cpp), and writes
-the seat's number on it in black or white, whichever reads better on that colour.
+EA's PlayerStart is a blue ring round an opaque black middle with a drop shadow, 25 pixels square in
+SCSmShellUserInterface512_001.tga. This cuts it in two: ReforgedLobbySpotRing is the ring and the
+shadow with the middle taken out, and ReforgedLobbySpot is the middle in white. The game draws the
+middle multiplied by the spot's colour and the ring over it untinted (LobbyStartSpotFill in
+GUIUtil.cpp), so a taken spot is EA's art with its black turned into that colour, the ring's inner
+edge blending into it as it blended into the black, and the seat's number goes on top.
+
+The ring's inner edge is the blue fading to black over a few pixels. Each of those pixels is read as
+the pure blue at some coverage (its blue channel over the pure ring's), and the ring layer keeps that
+coverage as alpha, so middle-then-ring rebuilds the original exactly when the middle is black.
python Tools/lobby_spot.py
- writes Data/Art/Textures/ReforgedLobbySpot.tga and the ReforgedLobbySpot.ini that maps it."""
+ reads Run/EnglishZH.big, writes Data/Art/Textures/ReforgedLobbySpot.tga and the
+ ReforgedLobbySpot.ini that maps both halves."""
+import io
+import math
import os
+import sys
-from PIL import Image, ImageDraw
+from PIL import Image
-SIZE = 64
-# drawn this many times larger and scaled down, which is what smooths the edge
-OVERSAMPLE = 8
HERE = os.path.dirname(os.path.abspath(__file__))
+sys.path.insert(0, HERE)
+from bigfile import _read_index
+
+ARCHIVE_PATH = os.path.join(HERE, "..", "..", "Run", "EnglishZH.big")
+TEXTURE_MEMBER = "data\\english\\art\\textures\\scsmshelluserinterface512_001.tga"
+# PlayerStart's Coords in SCSmShellUserInterface512.INI
+SOURCE_BOX = (337, 415, 362, 440)
+CELL = 25
+# the ring is 22 pixels across from the cell's corner, the shadow beyond it
+RING_CENTRE = 10.5
+# every pixel nearer the centre than this is middle or the ring's inner edge; the pure ring starts here
+MIDDLE_RADIUS = 8.6
+# the blue channel of the ring's pure inner pixels; darker is the edge fading into the black
+RING_BLUE = 244
+TEXTURE_WIDTH, TEXTURE_HEIGHT = 64, 32
+MIDDLE_CORNER = (0, 0)
+RING_CORNER = (32, 0)
+# a black middle rebuilds EA's art within this much per channel (rounding of the coverage)
+REBUILD_TOLERANCE = 3
OUT_PATH = os.path.join(HERE, "..", "Data", "Art", "Textures", "ReforgedLobbySpot.tga")
INI_PATH = os.path.join(HERE, "..", "Data", "INI", "MappedImages", "HandCreated", "ReforgedLobbySpot.ini")
-INI_TEXT = """; The disc a taken start spot on a staging room's map preview is filled with, tinted with its team's
-; colour as it is drawn. Written by Tools/lobby_spot.py with Art/Textures/ReforgedLobbySpot.tga; do
-; not edit by hand. Mapped images are not in the multiplayer INI checksum.
+INI_TEXT = """; A start spot cut from EA's PlayerStart: the middle in white, tinted with the spot's colour as it
+; is drawn, and the ring with the middle taken out, drawn over it untinted. Written by
+; Tools/lobby_spot.py with Art/Textures/ReforgedLobbySpot.tga; do not edit by hand. Mapped images
+; are not in the multiplayer INI checksum.
MappedImage ReforgedLobbySpot
Texture = ReforgedLobbySpot.tga
TextureWidth = %d
TextureHeight = %d
- Coords = Left:0 Top:0 Right:%d Bottom:%d
+ Coords = Left:%d Top:%d Right:%d Bottom:%d
+ Status = NONE
+End
+
+MappedImage ReforgedLobbySpotRing
+ Texture = ReforgedLobbySpot.tga
+ TextureWidth = %d
+ TextureHeight = %d
+ Coords = Left:%d Top:%d Right:%d Bottom:%d
Status = NONE
End
-""" % (SIZE, SIZE, SIZE, SIZE)
+""" % (TEXTURE_WIDTH, TEXTURE_HEIGHT, MIDDLE_CORNER[0], MIDDLE_CORNER[1], MIDDLE_CORNER[0] + CELL, MIDDLE_CORNER[1] + CELL,
+ TEXTURE_WIDTH, TEXTURE_HEIGHT, RING_CORNER[0], RING_CORNER[1], RING_CORNER[0] + CELL, RING_CORNER[1] + CELL)
+
+
+def player_start():
+ with open(ARCHIVE_PATH, "rb") as archive:
+ for path, offset, size in list(_read_index(archive)):
+ if path.lower() == TEXTURE_MEMBER:
+ archive.seek(offset)
+ texture = Image.open(io.BytesIO(archive.read(size))).convert("RGBA")
+ return texture.crop(SOURCE_BOX)
+ raise ValueError("%s has no %s" % (ARCHIVE_PATH, TEXTURE_MEMBER))
+
+
+def split(art):
+ middle = Image.new("RGBA", (CELL, CELL), (255, 255, 255, 0))
+ ring = art.copy()
+ for y in range(CELL):
+ for x in range(CELL):
+ if math.hypot(x - RING_CENTRE, y - RING_CENTRE) > MIDDLE_RADIUS:
+ continue
+ red, green, blue, alpha = art.getpixel((x, y))
+ coverage = min(1.0, blue / RING_BLUE)
+ middle.putpixel((x, y), (255, 255, 255, 255))
+ if coverage == 0:
+ ring.putpixel((x, y), (0, 0, 0, 0))
+ continue
+ ring.putpixel((x, y), (min(255, round(red / coverage)), min(255, round(green / coverage)),
+ min(255, round(blue / coverage)), round(alpha * coverage)))
+ return middle, ring
+
+
+def tinted(middle, ring, colour):
+ painted = Image.new("RGBA", (CELL, CELL), colour + (255,))
+ painted.putalpha(middle.getchannel("A"))
+ spot = Image.new("RGBA", (CELL, CELL), (0, 0, 0, 0))
+ spot.alpha_composite(painted)
+ spot.alpha_composite(ring)
+ return spot
-def disc():
- big = SIZE * OVERSAMPLE
- image = Image.new("RGBA", (big, big), (255, 255, 255, 0))
- ImageDraw.Draw(image).ellipse((OVERSAMPLE, OVERSAMPLE, big - OVERSAMPLE, big - OVERSAMPLE),
- fill=(255, 255, 255, 255))
- image = image.resize((SIZE, SIZE), Image.LANCZOS)
- if image.getpixel((0, 0))[3] != 0 or image.getpixel((SIZE // 2, SIZE // 2))[3] != 255:
- raise ValueError("expected a disc with clear corners and a solid middle")
- return image
+def check(art, middle, ring):
+ rebuilt = tinted(middle, ring, (0, 0, 0))
+ for y in range(CELL):
+ for x in range(CELL):
+ if math.hypot(x - RING_CENTRE, y - RING_CENTRE) > MIDDLE_RADIUS:
+ continue
+ worst = max(abs(a - b) for a, b in zip(rebuilt.getpixel((x, y)), art.getpixel((x, y))))
+ if worst > REBUILD_TOLERANCE:
+ raise ValueError("a black middle rebuilds pixel %d,%d %d off EA's art, expected at most %d"
+ % (x, y, worst, REBUILD_TOLERANCE))
+ # nothing dark may be left in the ring layer beside the middle: it would show as a black rim
+ for y in range(CELL):
+ for x in range(CELL):
+ distance = math.hypot(x - RING_CENTRE, y - RING_CENTRE)
+ if MIDDLE_RADIUS < distance <= MIDDLE_RADIUS + 1 and ring.getpixel((x, y))[2] < RING_BLUE * 0.8:
+ raise ValueError("pixel %d,%d just outside the middle is %r, expected the pure ring"
+ % (x, y, ring.getpixel((x, y))))
def main():
- disc().save(OUT_PATH)
+ art = player_start()
+ middle, ring = split(art)
+ check(art, middle, ring)
+ texture = Image.new("RGBA", (TEXTURE_WIDTH, TEXTURE_HEIGHT), (0, 0, 0, 0))
+ texture.paste(middle, MIDDLE_CORNER)
+ texture.paste(ring, RING_CORNER)
+ texture.save(OUT_PATH)
with open(INI_PATH, "w", newline="\r\n") as ini:
ini.write(INI_TEXT)
print(OUT_PATH)