OpenCoD2-Plus
Call of Duty 2 client & server, rebuilt
Loading...
Searching...
No Matches
hud_align_test Namespace Reference

Functions

 gametype ()
 pixels (path, rgb)
 main ()

Variables

 ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
int SECONDS = 180
float TOLERANCE = 0.03
int MIN_PIXELS = 200
list BOXES
str HUD
str BOX

Detailed Description

A client places hud elements by their horzAlign and vertAlign.

    python3 scripts/hud_align_test.py /path/to/CoD2 --protocol {115|118} [--binary PATH] [--keep DIR]

Starts a client (cod2_linux) on its own game of mp_toujane with a gametype
that spawns the player looking up at the sky and gives it three hud elements,
40x40 boxes of the white material in pure colors, whose horzAlign and
vertAlign differ (as the killcam's title, center_safearea and top): magenta
at center_safearea/top, cyan at right/bottom, yellow at left/middle. A
hudelem's alignScreen keeps horzAlign in bits 3-5 and vertAlign in bits 0-2;
read the other way round, the killcam's title went to the left edge and the
middle of the screen. Takes a screenshot (TGA) and finds each color's pixels:
exits with 0 when each box is there, its center within TOLERANCE of where
those alignments put it (a 4:3 window: 640x480 virtual units scale alike on
both axes), and the client leaves no crash report. --keep copies the
screenshot and the log to DIR. The client opens a window and needs a CD key
in ~/.cod2/preferences; without one the test is skipped (exit 0).

Function Documentation

◆ gametype()

hud_align_test.gametype ( )

◆ main()

hud_align_test.main ( )

◆ pixels()

hud_align_test.pixels ( path,
rgb )
The (x, y) of the pixels of a TGA of exactly that color (0 or 255 a channel), top row 0.

Variable Documentation

◆ BOX

str hud_align_test.BOX
Initial value:
1= ''' e = newClientHudElem(self);
2 e.horzAlign = "%s";
3 e.vertAlign = "%s";
4 e.alignX = "%s";
5 e.alignY = "%s";
6 e.x = %d;
7 e.y = %d;
8 e.color = (%d, %d, %d);
9 e.alpha = 1;
10 e setShader("white", 40, 40);
11 self.hud_test[self.hud_test.size] = e;
12'''

◆ BOXES

list hud_align_test.BOXES
Initial value:
1= [
2 ('magenta', (1, 0, 1), 'center_safearea', 'top', 'center', 'top', 0, 40, lambda w, h, s: (w / 2, 60 * s)),
3 ('cyan', (0, 1, 1), 'right', 'bottom', 'right', 'bottom', -40, -40, lambda w, h, s: (w - 60 * s, h - 60 * s)),
4 ('yellow', (1, 1, 0), 'left', 'middle', 'left', 'middle', 40, 0, lambda w, h, s: (60 * s, h / 2)),
5]

◆ HUD

str hud_align_test.HUD
Initial value:
1= '''
2 self.hud_test = [];
3%s
4'''

◆ MIN_PIXELS

int hud_align_test.MIN_PIXELS = 200

◆ ROOT

hud_align_test.ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

◆ SECONDS

int hud_align_test.SECONDS = 180

◆ TOLERANCE

float hud_align_test.TOLERANCE = 0.03