1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../../../shared/a_modes.inc}
28 procedure r_Render_Initialize
;
29 procedure r_Render_Finalize
;
31 (* load globally used textures *)
32 procedure r_Render_Load
;
33 procedure r_Render_Free
;
35 (* load map specific textures *)
36 procedure r_Render_LoadTextures
;
37 procedure r_Render_FreeTextures
;
39 procedure r_Render_Update
;
40 procedure r_Render_Draw
;
42 procedure r_Render_Resize (w
, h
: Integer);
43 procedure r_Render_Apply
;
45 function r_Render_WriteScreenShot (filename
: String): Boolean;
48 function r_Render_GetGibRect (m
, id
: Integer): TRectWH
;
52 procedure r_Render_QueueEffect (AnimType
, X
, Y
: Integer);
56 // touch screen button location and size
57 procedure r_Render_GetKeyRect (key
: Integer; out x
, y
, w
, h
: Integer; out founded
: Boolean);
61 procedure r_Render_GetControlSize (ctrl
: TGUIControl
; out w
, h
: Integer);
62 procedure r_Render_GetLogoSize (out w
, h
: Integer);
63 procedure r_Render_GetMaxFontSize (BigFont
: Boolean; out w
, h
: Integer);
64 procedure r_Render_GetStringSize (BigFont
: Boolean; str
: String; out w
, h
: Integer);
67 procedure r_Render_DrawLoading (force
: Boolean); // !!! remove it
80 {$IFDEF ENABLE_SYSTEM}
83 SysUtils
, Classes
, Math
,
85 e_log
, utils
, wadreader
, mapdef
,
86 g_game
, g_map
, g_panel
, g_options
, g_console
, g_player
, g_weapons
, g_language
, g_triggers
, g_monsters
,
88 r_draw
, r_textures
, r_fonts
, r_common
, r_console
, r_map
92 BackgroundTexture
: THereTexture
;
94 hud
, hudbg
: TGLTexture
;
95 hudhp
: array [Boolean] of TGLTexture
;
97 hudwp
: array [0..WP_LAST
] of TGLTexture
;
98 hudkey
: array [0..2] of TGLTexture
;
101 hudrflag
, hudrflags
, hudrflagd
: TGLTexture
;
102 hudbflag
, hudbflags
, hudbflagd
: TGLTexture
;
104 procedure r_Render_LoadTextures
;
109 procedure r_Render_FreeTextures
;
114 procedure r_Render_Load
;
116 WeapName
: array [0..WP_LAST
] of AnsiString = ('KASTET', 'SAW', 'PISTOL', 'SHOTGUN1', 'SHOTGUN2', 'MGUN', 'RLAUNCHER', 'PGUN', 'BFG', 'SPULEMET', 'FLAMETHROWER');
121 BackgroundTexture
:= DEFAULT(THereTexture
);
122 hud
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/HUD');
123 hudbg
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/HUDBG');
124 hudhp
[false] := r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/MED2');
125 hudhp
[true] := r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/BMED');
126 hudap
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/ARMORHUD');
127 for i
:= 0 to WP_LAST
do
128 hudwp
[i
] := r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/' + WeapName
[i
]);
129 hudkey
[0] := r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/KEYR');
130 hudkey
[1] := r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/KEYG');
131 hudkey
[2] := r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/KEYB');
132 hudair
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/AIRBAR');
133 hudjet
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/JETBAR');
134 hudrflag
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_R_BASE');
135 hudrflags
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_R_STOLEN');
136 hudrflagd
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_R_DROP');
137 hudbflag
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_B_BASE');
138 hudbflags
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_B_STOLEN');
139 hudbflagd
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_B_DROP');
147 procedure r_Render_Free
;
166 for i
:= 0 to WP_LAST
do
168 if hudwp
[i
] <> nil then
177 r_Common_FreeThis(BackgroundTexture
);
181 {$IFDEF ENABLE_SYSTEM}
182 function GetInfo (): TGLDisplayInfo
;
183 var info
: TGLDisplayInfo
;
185 info
:= Default(TGLDisplayInfo
);
186 info
.w
:= Max(1, gRC_Width
);
187 info
.h
:= Max(1, gRC_Height
);
188 info
.bpp
:= Max(1, gBPP
);
189 info
.fullscreen
:= gRC_FullScreen
;
190 info
.maximized
:= gRC_Maximized
;
193 info
.profile
:= TGLProfile
.Compat
;
198 procedure r_Render_Initialize
;
200 {$IFDEF ENABLE_SYSTEM}
201 if sys_SetDisplayModeGL(GetInfo()) = False then
202 raise Exception
.Create('Failed to set videomode on startup.');
203 sys_EnableVSync(gVSync
);
205 r_Textures_Initialize
;
206 r_Console_Initialize
;
210 procedure r_Render_Finalize
;
217 procedure r_Render_Update
;
223 procedure r_Render_DrawHUD (x
, y
: Integer; p
: TPlayer
);
224 var t
: TGLTexture
; s
: AnsiString;
228 // hud area is 196 x 240 pixels
229 r_Common_DrawTexture(hud
, x
, y
, hud
.width
, hud
.height
, TBasePoint
.BP_LEFTUP
);
230 r_Common_DrawText(p
.name
, x
+ 98, y
+ 16, 255, 0, 0, 255, smallfont
, TBasePoint
.BP_CENTER
);
232 t
:= hudhp
[R_BERSERK
in p
.FRulez
];
233 r_Common_DrawTexture(t
, x
+ 51, y
+ 61, t
.width
, t
.height
, TBasePoint
.BP_CENTER
);
234 r_Common_DrawTexture(hudap
, x
+ 50, y
+ 85, hudap
.width
, hudap
.height
, TBasePoint
.BP_CENTER
);
236 r_Common_DrawText(IntToStr(MAX(0, p
.health
)), x
+ 174, y
+ 56, 255, 0, 0, 255, menufont
, TBasePoint
.BP_RIGHT
);
237 r_Common_DrawText(IntToStr(MAX(0, p
.armor
)), x
+ 174, y
+ 84, 255, 0, 0, 255, menufont
, TBasePoint
.BP_RIGHT
);
240 WEAPON_KASTET
, WEAPON_SAW
: s
:= '--';
241 else s
:= IntToStr(p
.GetAmmoByWeapon(p
.CurrWeap
));
243 r_Common_DrawText(s
, x
+ 174, y
+ 174, 255, 0, 0, 255, menufont
, TBasePoint
.BP_RIGHT
);
245 if p
.CurrWeap
<= WP_LAST
then
247 t
:= hudwp
[p
.CurrWeap
];
248 r_Common_DrawTexture(t
, x
+ 18, y
+ 160, t
.width
, t
.height
, TBasePoint
.BP_LEFTUP
);
251 if R_KEY_RED
in p
.FRulez
then
252 r_Common_DrawTexture(hudkey
[0], x
+ 76, y
+ 214, 16, 16, TBasePoint
.BP_LEFTUP
);
253 if R_KEY_GREEN
in p
.FRulez
then
254 r_Common_DrawTexture(hudkey
[1], x
+ 93, y
+ 214, 16, 16, TBasePoint
.BP_LEFTUP
);
255 if R_KEY_BLUE
in p
.FRulez
then
256 r_Common_DrawTexture(hudkey
[2], x
+ 110, y
+ 214, 16, 16, TBasePoint
.BP_LEFTUP
);
258 if p
.JetFuel
> 0 then
260 r_Common_DrawTexture(hudair
, x
, y
+ 116, hudair
.width
, hudair
.height
, TBasePoint
.BP_LEFTUP
);
262 r_Draw_FillRect(x
+ 14, y
+ 116 + 4, x
+ 14 + 168 * p
.air
div AIR_MAX
, y
+ 116 + 4 + 4, 0, 0, 196, 255);
263 r_Common_DrawTexture(hudjet
, x
, y
+ 126, hudjet
.width
, hudjet
.height
, TBasePoint
.BP_LEFTUP
);
264 r_Draw_FillRect(x
+ 14, y
+ 126 + 4, x
+ 14 + 168 * p
.JetFuel
div JET_MAX
, y
+ 126 + 4 + 4, 208, 0, 0, 255);
268 r_Common_DrawTexture(hudair
, x
, y
+ 124, hudair
.width
, hudair
.height
, TBasePoint
.BP_LEFTUP
);
270 r_Draw_FillRect(x
+ 14, y
+ 124 + 4, x
+ 14 + 168 * p
.air
div AIR_MAX
, y
+ 124 + 4 + 4, 0, 0, 196, 255);
274 procedure r_Render_DrawHUDArea (x
, y
, w
, h
: Integer; p
: TPlayer
);
277 r_Common_DrawTexture(hudbg
, x
, y
, w
, h
, TBasePoint
.BP_LEFTUP
);
281 r_Render_DrawHUD(x
+ w
- 196 + 2, y
, p
);
284 r_Common_DrawText(_lc
[I_PLAYER_SPECT
], x
+ 4, y
+ 242, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
285 r_Common_DrawText(_lc
[I_PLAYER_SPECT2
], x
+ 4, y
+ 258, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
286 r_Common_DrawText(_lc
[I_PLAYER_SPECT1
], x
+ 4, y
+ 274, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
288 r_Common_DrawText(_lc
[I_PLAYER_SPECT1S
], x
+ 4, y
+ 290, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
292 if gShowPing
and g_Game_IsClient
then
294 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
295 r_Common_DrawText(s
, x
+ 4, y
+ 242, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
299 procedure r_Render_DrawStatsView (x
, y
, w
, h
: Integer; p
: TPlayer
);
300 var fw
, i
, maxFrags
, top
, totalPlayers
: Integer; sign
: Char; stat
: TPlayerStatArray
; f
: TGLTexture
;
304 if gShowScore
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
308 if gGameSettings
.GameMode
= GM_CTF
then
310 case gFlags
[FLAG_RED
].State
of
311 FLAG_STATE_CAPTURED
: f
:= hudrflags
;
312 FLAG_STATE_DROPPED
: f
:= hudrflagd
;
313 otherwise f
:= hudrflag
;
317 fw
:= f
.width
+ 8; (* + space *)
318 r_Common_DrawTexture(f
, x
+ w
- 16, y
+ 240 - 72 - 4, f
.width
, f
.height
, TBasePoint
.BP_RIGHTUP
);
321 r_Common_DrawText(IntToStr(gTeamStat
[TEAM_RED
].Score
), x
+ w
- 16 - fw
, y
+ 240 - 72 - 4, TEAMCOLOR
[TEAM_RED
].R
, TEAMCOLOR
[TEAM_RED
].G
, TEAMCOLOR
[TEAM_RED
].B
, 255, menufont
, TBasePoint
.BP_RIGHTUP
);
323 (* BLUE TEAM GOALS *)
325 if gGameSettings
.GameMode
= GM_CTF
then
327 case gFlags
[FLAG_BLUE
].State
of
328 FLAG_STATE_CAPTURED
: f
:= hudbflags
;
329 FLAG_STATE_DROPPED
: f
:= hudbflagd
;
330 otherwise f
:= hudbflag
;
334 fw
:= f
.width
+ 8; (* + space *)
335 r_Common_DrawTexture(f
, x
+ w
- 16, y
+ 240 - 32 - 4, f
.width
, f
.height
, TBasePoint
.BP_RIGHTUP
);
338 r_Common_DrawText(IntToStr(gTeamStat
[TEAM_BLUE
].Score
), x
+ w
- 16 - fw
, y
+ 240 - 32 - 4, TEAMCOLOR
[TEAM_BLUE
].R
, TEAMCOLOR
[TEAM_BLUE
].G
, TEAMCOLOR
[TEAM_BLUE
].B
, 255, menufont
, TBasePoint
.BP_RIGHTUP
);
341 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
345 r_Common_DrawText(IntToStr(p
.Frags
), x
+ w
- 16, y
, 255, 0, 0, 255, menufont
, TBasePoint
.BP_RIGHTUP
);
350 stat
:= g_Player_GetStats();
353 totalPlayers
:= Length(stat
);
354 for i
:= 0 to High(stat
) do
356 if stat
[i
].Name
<> p
.Name
then
358 maxFrags
:= MAX(maxFrags
, stat
[i
].Frags
);
359 if stat
[i
].Frags
> p
.Frags
then
364 if p
.Frags
>= maxFrags
then sign
:= '+' else sign
:= '-';
365 r_Common_DrawText(IntToStr(top
) + ' / ' + IntToStr(totalPlayers
) + ' ' + sign
+ IntToStr(ABS(p
.Frags
- maxFrags
)), x
+ w
- 16, y
+ 32, 255, 0, 0, 255, smallfont
, TBasePoint
.BP_RIGHTUP
);
368 if gLMSRespawn
> LMS_RESPAWN_NONE
then
370 r_Common_DrawText(_lc
[I_GAME_WARMUP
], x
+ w
- 16 - 64, y
+ h
, 0, 255, 0, 255, menufont
, TBasePoint
.BP_RIGHTDOWN
);
371 r_Common_DrawText(': ' + IntToStr((gLMSRespawnTime
- gTime
) div 1000), x
+ w
- 16 - 64, y
+ h
, 0, 255, 0, 255, menufont
, TBasePoint
.BP_LEFTDOWN
);
373 else if gShowLives
and (gGameSettings
.MaxLives
> 0) then
375 r_Common_DrawText(IntToStr(p
.Lives
), x
+ w
- 16, y
+ h
, 0, 255, 0, 255, menufont
, TBasePoint
.BP_RIGHTDOWN
);
380 procedure r_Render_DrawView (x
, y
, w
, h
: Integer; p
: TPlayer
);
381 var l
, t
, r
, b
, xx
, yy
: Integer;
383 r_Draw_GetRect(l
, t
, r
, b
);
384 r_Draw_SetRect(x
, y
, x
+ w
, y
+ h
);
386 r_Common_GetCameraPos(p
, true, xx
, yy
);
389 r_Map_Draw(x
, y
, w
, h
, xx
, yy
, p
);
390 r_Render_DrawStatsView(x
, y
, w
, h
, p
);
391 if p
.Spectator
and p
.NoRespawn
then
392 r_Common_DrawText(_lc
[I_PLAYER_SPECT4
], x
div 2 + w
div 2, y
div 2 + h
div 2, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_CENTER
);
396 r_Map_Draw(x
, y
, w
, h
, xx
, yy
, nil);
399 r_Draw_SetRect(l
, t
, r
, b
);
402 procedure r_Render_DrawMapView (x
, y
, w
, h
, camx
, camy
: Integer);
403 var l
, t
, r
, b
: Integer;
405 r_Draw_GetRect(l
, t
, r
, b
);
406 r_Draw_SetRect(x
, y
, x
+ w
, y
+ h
);
407 r_Map_Draw(x
, y
, w
, h
, camx
, camy
, nil);
408 r_Draw_SetRect(l
, t
, r
, b
);
411 procedure r_Render_DrawPlayerView (x
, y
, w
, h
: Integer; p
: TPlayer
);
412 var l
, t
, r
, b
: Integer;
414 r_Draw_GetRect(l
, t
, r
, b
);
415 r_Draw_SetRect(x
, y
, x
+ w
, y
+ h
);
416 r_Render_DrawView(x
, y
, w
- 196, h
, p
);
417 r_Render_DrawHUDArea(x
+ w
- 196, y
, 196, h
, p
);
418 r_Draw_SetRect(l
, t
, r
, b
);
421 procedure r_Render_DrawBackgroundImage (img
: TGLTexture
);
422 var fw
, w
, h
: LongInt;
426 img
:= BackgroundTexture
.id
;
427 if img
.width
= img
.height
then fw
:= img
.width
* 4 div 3 else fw
:= img
.width
; // fix aspect 4:3
428 r_Common_CalcAspect(fw
, img
.height
, gScreenWidth
, gScreenHeight
, false, w
, h
);
429 r_Draw_Texture(img
, gScreenWidth
div 2 - w
div 2, 0, w
, h
, false, 255, 255, 255, 255, false);
433 procedure r_Render_DrawBackground (const name
: AnsiString);
435 if r_Common_LoadThis(name
, BackgroundTexture
) then
436 r_Render_DrawBackgroundImage(BackgroundTexture
.id
)
439 procedure r_Render_DrawServerList (var SL
: TNetServerList
; var ST
: TNetServerTable
);
440 var ip
: AnsiString; ww
, hh
, cw
, ch
, mw
, mh
, motdh
, scrx
, scry
, i
, mx
, y
: Integer; msg
: SSArray
; Srv
: TNetServer
;
442 scrx
:= gScreenWidth
div 2;
443 scry
:= gScreenHeight
div 2;
445 r_Draw_GetTextSize(_lc
[I_NET_SLIST
], menufont
, ww
, hh
);
446 r_Common_DrawText(_lc
[I_NET_SLIST
], gScreenWidth
div 2, 16, 255, 255, 255, 255, menufont
, TBasePoint
.BP_UP
);
448 r_Draw_GetTextSize('W', stdfont
, cw
, ch
);
449 motdh
:= gScreenHeight
- 49 - ch
* b_Text_LineCount(slMOTD
);
451 r_Draw_FillRect(16, 64, gScreenWidth
- 16, motdh
, 64, 64, 64, 145);
452 r_Draw_Rect(16, 64, gScreenWidth
- 16, motdh
, 255, 127, 0, 255);
454 r_Common_DrawText(_lc
[I_NET_SLIST_HELP
], gScreenWidth
div 2, gScreenHeight
- 8, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_DOWN
);
458 r_Draw_FillRect(16, motdh
, gScreenWidth
- 16, gScreenHeight
- 44, 64, 64, 64, 110);
459 r_Draw_Rect(16, motdh
, gScreenWidth
- 16, gScreenHeight
- 44, 255, 127, 0, 255);
460 r_Common_DrawFormatText(slMOTD
, 20, motdh
+ 3 + ch
* i
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
463 if not slReadUrgent
and (slUrgent
<> '') then
465 r_Draw_FillRect(17, 65, gScreenWidth
- 17, motdh
- 1, 64, 64, 64, 127);
466 r_Draw_FillRect(scrx
- 256, scry
- 60, scrx
+ 256, scry
+ 60, 64, 64, 64, 127);
467 r_Draw_Rect(scrx
- 256, scry
- 60, scrx
+ 256, scry
+ 60, 255, 127, 0, 255);
468 r_Draw_FillRect(scrx
- 256, scry
- 40, scrx
+ 256, scry
- 40, 255, 127, 0, 255);
469 r_Common_DrawText(_lc
[I_NET_SLIST_URGENT
], scrx
, scry
- 58, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
470 r_Common_DrawFormatText(slUrgent
, scrx
- 253, scry
- 38 + ch
* i
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
471 r_Common_DrawText(_lc
[I_NET_SLIST_URGENT_CONT
], scrx
, scry
+ 41, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
472 r_Draw_FillRect(scrx
- 256, scry
+ 40, scrx
+ 256, scry
+ 40, 255, 127, 0, 255);
474 else if SL
= nil then
476 r_Draw_FillRect(17, 65, gScreenWidth
- 17, motdh
- 1, 64, 64, 64, 127);
477 r_Draw_Rect(scrx
- 192, scry
- 10, scrx
+ 192, scry
+ 11, 255, 127, 0, 255);
478 r_Common_DrawText(slWaitStr
, scrx
, scry
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_CENTER
);
483 if slSelection
< Length(ST
) then
485 sy
:= y
+ 42 * slSelection
- 4;
486 Srv
:= GetServerFromTable(slSelection
, SL
, ST
);
487 ip
:= _lc
[I_NET_ADDRESS
] + ' ' + Srv
.IP
+ ':' + IntToStr(Srv
.Port
);
488 ip
:= ip
+ ' ' + _lc
[I_NET_SERVER_PASSWORD
] + ' ';
489 if Srv
.Password
then ip
:= ip
+ _lc
[I_MENU_YES
] else ip
:= ip
+_lc
[I_MENU_NO
];
492 mw
:= gScreenWidth
- 188;
495 r_Draw_FillRect(16 + 1, sy
, gScreenWidth
- 16 - 1, sy
+ 40, 64, 64, 64, 255);
496 r_Draw_FillRect(16 + 1, sy
, gScreenWidth
- 16 - 1, sy
, 205, 205, 205, 255);
497 r_Draw_FillRect(16 + 1, sy
+ 41, gScreenWidth
- 16 - 1, sy
+ 41, 255, 255, 255, 255);
499 r_Draw_FillRect(16, 85, gScreenWidth
- 16, 85, 255, 127, 0, 255);
500 r_Draw_FillRect(16, motdh
- 20, gScreenWidth
- 16, motdh
- 20, 255, 127, 0, 255);
502 r_Draw_FillRect(mx
- 70, 64, mx
- 70, motdh
, 255, 127, 0, 255);
503 r_Draw_FillRect(mx
, 64, mx
, motdh
- 20, 255, 127, 0, 255);
504 r_Draw_FillRect(mx
+ 52, 64, mx
+ 52, motdh
- 20, 255, 127, 0, 255);
505 r_Draw_FillRect(mx
+ 104, 64, mx
+ 104, motdh
- 20, 255, 127, 0, 255);
507 r_Common_DrawText('NAME/MAP', 18, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
508 r_Common_DrawText('PING', mx
- 68, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
509 r_Common_DrawText('MODE', mx
+ 2, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
510 r_Common_DrawText('PLRS', mx
+ 54, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
511 r_Common_DrawText('VER', mx
+ 106, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
513 for i
:= 0 to High(ST
) do
515 Srv
:= GetServerFromTable(i
, SL
, ST
);
516 r_Common_DrawText(Srv
.Name
, 18, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
517 r_Common_DrawText(Srv
.Map
, 18, y
+ 16, 210, 210, 210, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
520 r_Common_DrawText('<1' + _lc
[I_NET_SLIST_PING_MS
], mx
- 68, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
)
521 else if (Srv
.Ping
>= 0) and (Srv
.Ping
<= 999) then
522 r_Common_DrawText(IntToStr(Srv
.Ping
) + _lc
[I_NET_SLIST_PING_MS
], mx
- 68, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
)
524 r_Common_DrawText(_lc
[I_NET_SLIST_NO_ACCESS
], mx
- 68, y
, 255, 0, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
525 if Length(ST
[I
].Indices
) > 1 then
526 r_Common_DrawText('<' + IntToStr(Length(ST
[I
].Indices
)) + '>', mx
- 68, y
+ 16, 210, 210, 210, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
528 r_Common_DrawText(g_Game_ModeToText(Srv
.GameMode
), mx
+ 2, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
530 r_Common_DrawText(IntToStr(Srv
.Players
) + '/' + IntToStr(Srv
.MaxPlayers
), mx
+ 54, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
531 r_Common_DrawText(IntToStr(Srv
.LocalPl
) + '+' + IntToStr(Srv
.Bots
), mx
+ 54, y
+ 16, 210, 210, 210, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
533 r_Common_DrawText(IntToStr(Srv
.Protocol
), mx
+ 106, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
538 r_Common_DrawText(ip
, 20, motdh
- 20 + 3, 205, 205, 205, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
539 r_Common_DrawText(IntToStr(Length(ST
)) + _lc
[I_NET_SLIST_SERVERS
], gScreenWidth
- 48, motdh
- 20 + 3, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_RIGHTUP
);
543 procedure r_Render_DrawStatsColumns (constref cs
: TEndCustomGameStat
; x
, y
, w
: Integer; endview
: Boolean);
544 var i
, cw
, ch
, yy
, team
, players
, w1
, w2
, w3
, w4
, tw
: Integer; r
, g
, b
, rr
, gg
, bb
: Byte; s
: AnsiString;
546 r_Draw_GetTextSize('W', stdfont
, cw
, ch
);
547 w4
:= cw
* 6; (* deaths width *)
548 w3
:= cw
* 8; (* frags width *)
549 w2
:= cw
* 12; (* ping/loss width *)
550 w1
:= w
- w2
- w3
- w4
; (* name width *)
551 tw
:= w1
- cw
* 2 - w2
; (* team goals *)
552 if cs
.PlayerStat
= nil then players
:= 0 else players
:= Length(cs
.PlayerStat
);
554 if cs
.GameMode
in [GM_TDM
, GM_CTF
] then
556 for team
:= TEAM_RED
to TEAM_BLUE
do
561 s
:= _lc
[I_GAME_TEAM_RED
];
562 r
:= 255; g
:= 0; b
:= 0;
566 s
:= _lc
[I_GAME_TEAM_BLUE
];
567 r
:= 0; g
:= 0; b
:= 255;
570 r_Common_DrawText(s
, x
, yy
, r
, g
, b
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
571 r_Common_DrawText(IntToStr(cs
.TeamStat
[team
].Score
), x
+ tw
, yy
, r
, g
, b
, 255, stdfont
, TBasePoint
.BP_UP
);
572 if endview
= false then
573 r_Common_DrawText(_lc
[I_GAME_PING
], x
+ w1
, yy
, r
, g
, b
, 255, stdfont
, TBasePoint
.BP_UP
);
574 r_Common_DrawText(_lc
[I_GAME_FRAGS
], x
+ w1
+ w2
, yy
, r
, g
, b
, 255, stdfont
, TBasePoint
.BP_UP
);
575 r_Common_DrawText(_lc
[I_GAME_DEATHS
], x
+ w1
+ w2
+ w3
, yy
, r
, g
, b
, 255, stdfont
, TBasePoint
.BP_UP
);
579 r_Draw_FillRect(x
, yy
, x
+ w
- 1, yy
, r
, g
, b
, 255);
582 for i
:= 0 to players
- 1 do
584 if cs
.PlayerStat
[i
].Team
= team
then
586 rr
:= r
; gg
:= g
; bb
:= b
;
587 if cs
.PlayerStat
[i
].Spectator
then
589 rr
:= r
div 2; gg
:= g
div 2; bb
:= b
div 2;
593 if gShowPIDs
then s
:= Format('[%5d] %s', [cs
.PlayerStat
[i
].UID
, cs
.PlayerStat
[i
].Name
]) else s
:= cs
.PlayerStat
[i
].Name
;
594 if (gPlayers
[cs
.PlayerStat
[i
].Num
] <> nil) and (gPlayers
[cs
.PlayerStat
[i
].Num
].FReady
) then s
:= s
+ ' *';
595 r_Common_DrawText(s
, x
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
596 if endview
= false then
599 s
:= Format(_lc
[I_GAME_PING_MS
], [cs
.PlayerStat
[i
].Ping
, cs
.PlayerStat
[i
].Loss
]);
600 r_Common_DrawText(s
, x
+ w1
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_UP
);
603 s
:= IntToStr(cs
.PlayerStat
[i
].Frags
);
604 r_Common_DrawText(s
, x
+ w1
+ w2
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_UP
);
606 s
:= IntToStr(cs
.PlayerStat
[i
].Deaths
);
607 r_Common_DrawText(s
, x
+ w1
+ w2
+ w3
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_UP
);
615 else if cs
.GameMode
in [GM_DM
, GM_COOP
] then
617 r_Common_DrawText(_lc
[I_GAME_PLAYER_NAME
], x
, yy
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
618 if endview
= false then
619 r_Common_DrawText(_lc
[I_GAME_PING
], x
+ w1
, yy
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_UP
);
620 r_Common_DrawText(_lc
[I_GAME_FRAGS
], x
+ w1
+ w2
, yy
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_UP
);
621 r_Common_DrawText(_lc
[I_GAME_DEATHS
], x
+ w1
+ w2
+ w3
, yy
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_UP
);
622 INC(yy
, ch
+ ch
div 2);
623 for i
:= 0 to players
- 1 do
625 // rr := 255; gg := 127; bb := 0;
626 rr
:= 255; gg
:= 255; bb
:= 255;
627 if cs
.PlayerStat
[i
].Spectator
then
629 rr
:= rr
div 2; gg
:= gg
div 2; bb
:= bb
div 2;
633 r_Draw_Rect(x
, yy
, x
+ 16 - 1, yy
+ 16 - 1, 192, 192, 192, 255);
634 r_Draw_FillRect(x
+ 1, yy
+ 1, x
+ 16 - 1, yy
+ 16 - 1, cs
.PlayerStat
[i
].Color
.R
, cs
.PlayerStat
[i
].Color
.G
, cs
.PlayerStat
[i
].Color
.B
, 255);
636 if gShowPIDs
then s
:= Format('[%5d] %s', [cs
.PlayerStat
[i
].UID
, cs
.PlayerStat
[i
].Name
]) else s
:= cs
.PlayerStat
[i
].Name
;
637 if (gPlayers
[cs
.PlayerStat
[i
].Num
] <> nil) and (gPlayers
[cs
.PlayerStat
[i
].Num
].FReady
) then s
:= s
+ ' *';
638 r_Common_DrawText(s
, x
+ 16 + 8, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
639 if endview
= false then
642 s
:= Format(_lc
[I_GAME_PING_MS
], [cs
.PlayerStat
[i
].Ping
, cs
.PlayerStat
[i
].Loss
]);
643 r_Common_DrawText(s
, x
+ w1
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_UP
);
646 s
:= IntToStr(cs
.PlayerStat
[i
].Frags
);
647 r_Common_DrawText(s
, x
+ w1
+ w2
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_UP
);
649 s
:= IntToStr(cs
.PlayerStat
[i
].Deaths
);
650 r_Common_DrawText(s
, x
+ w1
+ w2
+ w3
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_UP
);
652 INC(yy
, ch
+ ch
div 2);
657 procedure r_Render_DrawStatsWindow (x
, y
, w
, h
: Integer; cs
: TEndCustomGameStat
; endview
: Boolean);
658 var xoff
, yoff
, cw
, ch
: Integer; s
: AnsiString;
660 xoff
:= 0; yoff
:= 8;
661 r_Draw_GetTextSize('W', stdfont
, cw
, ch
);
662 r_Draw_FillRect(x
, y
, x
+ w
- 1, y
+ h
- 1, 64, 64, 64, 224);
663 r_Draw_Rect(x
, y
, x
+ w
- 1, y
+ h
- 1, 255, 127, 0, 255);
667 if endview
= false then
670 NET_SERVER
: s
:= _lc
[I_NET_SERVER
];
671 NET_CLIENT
: s
:= NetClientIP
+ ':' + IntToStr(NetClientPort
);
674 r_Common_DrawText(s
, x
+ 16, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
678 GM_DM
: if gGameSettings
.MaxLives
= 0 then s
:= _lc
[I_GAME_DM
] else s
:= _lc
[I_GAME_LMS
];
679 GM_TDM
: if gGameSettings
.MaxLives
= 0 then s
:= _lc
[I_GAME_TDM
] else s
:= _lc
[I_GAME_TLMS
];
680 GM_CTF
: s
:= _lc
[I_GAME_CTF
];
681 GM_COOP
: if gGameSettings
.MaxLives
= 0 then s
:= _lc
[I_GAME_COOP
] else s
:= _lc
[I_GAME_SURV
];
682 otherwise s
:= 'GAME MODE ' + IntToStr(gGameSettings
.GameMode
);
684 r_Common_DrawText(s
, x
+ w
div 2, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
686 if endview
= false then
688 s
:= r_Common_TimeToStr(cs
.GameTime
);
689 r_Common_DrawText(s
, x
+ w
- 16, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_RIGHTUP
);
692 INC(yoff
, ch
+ ch
div 2);
697 if cs
.MapName
<> '' then
698 s
:= s
+ ' - ' + cs
.MapName
;
700 if endview
= false then
702 r_Common_DrawText(s
, x
+ w
div 2, y
+ yoff
, 200, 200, 200, 255, stdfont
, TBasePoint
.BP_UP
);
703 INC(yoff
, ch
+ ch
div 2);
705 GM_DM
, GM_TDM
: s
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
706 GM_CTF
: s
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.ScoreLimit
]);
707 GM_COOP
: s
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
710 r_Common_DrawText(s
, x
+ 16, y
+ yoff
, 200, 200, 200, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
712 GM_DM
, GM_TDM
, GM_CTF
: s
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
713 GM_COOP
: s
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
716 r_Common_DrawText(s
, x
+ w
- 16, y
+ yoff
, 200, 200, 200, 255, stdfont
, TBasePoint
.BP_RIGHTUP
);
721 xoff
:= MAX(Length(_lc
[I_MENU_MAP
]) + 1, Length(_lc
[I_GAME_GAME_TIME
]) + 1) * cw
;
722 r_Common_DrawText(_lc
[I_MENU_MAP
], x
+ 16, y
+ yoff
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
723 r_Common_DrawText(s
, x
+ 16 + xoff
, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
725 r_Common_DrawText(_lc
[I_GAME_GAME_TIME
], x
+ 16, y
+ yoff
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
726 r_Common_DrawText(r_Common_TimeToStr(cs
.GameTime
), x
+ 16 + xoff
, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
734 if endview
and (cs
.GameMode
= GM_COOP
) then
736 xoff
:= MAX(Length(_lc
[I_GAME_MONSTERS
]) + 1, Length(_lc
[I_GAME_SECRETS
]) + 1) * cw
;
737 r_Common_DrawText(_lc
[I_GAME_MONSTERS
], x
+ 16, y
+ yoff
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
738 r_Common_DrawText(IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), x
+ 16 + xoff
, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
740 r_Common_DrawText(_lc
[I_GAME_SECRETS
], x
+ 16, y
+ yoff
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
741 r_Common_DrawText(IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), x
+ 16 + xoff
, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
748 if endview
and (cs
.GameMode
= GM_COOP
) and gLastMap
then
750 xoff
:= MAX(Length(_lc
[I_GAME_MONSTERS_TOTAL
]) + 1, Length(_lc
[I_GAME_SECRETS_TOTAL
]) + 1) * cw
;
751 r_Common_DrawText(_lc
[I_GAME_MONSTERS_TOTAL
], x
+ 16, y
+ yoff
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
752 r_Common_DrawText(IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), x
+ 16 + xoff
, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
754 r_Common_DrawText(_lc
[I_GAME_SECRETS_TOTAL
], x
+ 16, y
+ yoff
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
755 r_Common_DrawText(IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), x
+ 16 + xoff
, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
762 if endview
and (cs
.GameMode
in [GM_TDM
, GM_CTF
]) then
764 if cs
.TeamStat
[TEAM_RED
].Score
> cs
.TeamStat
[TEAM_BLUE
].Score
then s
:= _lc
[I_GAME_WIN_RED
]
765 else if cs
.TeamStat
[TEAM_BLUE
].Score
> cs
.TeamStat
[TEAM_RED
].Score
then s
:= _lc
[I_GAME_WIN_BLUE
]
766 else s
:= _lc
[I_GAME_WIN_DRAW
];
767 r_Common_DrawText(s
, x
+ w
div 2, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
774 r_Render_DrawStatsColumns(cs
, x
+ 16, y
+ yoff
, w
- 16 - 16, endview
);
777 function r_Render_StatsHeight (players
: Integer): Integer;
780 ASSERT(players
>= 0);
781 r_Draw_GetTextSize('W', stdfont
, cw
, ch
);
782 case gGameSettings
.GameMode
of
783 GM_TDM
, GM_CTF
: result
:= 32 + ch
* (11 + players
);
784 otherwise result
:= 40 + ch
* 5 + (ch
+ 8) * players
;
788 procedure r_Render_DrawStats
;
789 var x
, y
, w
, h
, players
: Integer; cs
: TEndCustomGameStat
;
791 cs
.PlayerStat
:= g_Player_GetStats();
792 SortGameStat(cs
.PlayerStat
);
793 cs
.TeamStat
:= gTeamStat
;
794 cs
.GameTime
:= gTime
;
795 cs
.GameMode
:= gGameSettings
.GameMode
;
796 cs
.Map
:= g_ExtractWadNameNoPath(gMapInfo
.Map
) + ':' + g_ExtractFileName(gMapInfo
.Map
);
797 cs
.MapName
:= gMapInfo
.Name
;
798 if cs
.PlayerStat
= nil then players
:= 0 else players
:= Length(cs
.PlayerStat
);
799 w
:= gScreenWidth
- (gScreenWidth
div 5);
800 h
:= r_Render_StatsHeight(players
);
801 x
:= (gScreenWidth
div 2) - (w
div 2);
802 y
:= (gScreenHeight
div 2) - (h
div 2);
803 r_Render_DrawStatsWindow(x
, y
, w
, h
, cs
, false);
806 procedure r_Render_DrawCustomStats
;
807 var cw
, ch
, s
: AnsiString;
811 r_Common_DrawText(_lc
[I_MENU_INTER_NOTICE_TAB
], gScreenWidth
div 2, 8, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
815 case gGameSettings
.GameMode
of
816 GM_COOP
: if gMissionFailed
then s
:= _lc
[I_MENU_INTER_MISSION_FAIL
] else s
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
817 otherwise s
:= _lc
[I_MENU_INTER_ROUND_OVER
];
819 r_Common_DrawText(s
, gScreenWidth
div 2, 16, 255, 255, 255, 255, menufont
, TBasePoint
.BP_UP
);
821 if gChatShow
= false then
823 if g_Game_IsClient
then s
:= _lc
[I_MENU_INTER_NOTICE_MAP
] else s
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
824 r_Common_DrawText(s
, gScreenWidth
div 2, gScreenHeight
- 4, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_DOWN
);
827 s
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
828 r_Common_DrawText(s
, gScreenWidth
div 2, gScreenHeight
- 16 - 4, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_DOWN
);
832 r_Render_DrawStatsWindow(32, 64, gScreenWidth
- 32 * 2, gScreenHeight
- 64 * 2, CustomStat
, true);
836 procedure r_Render_DrawValueOf (a
, b
, x
, y
: Integer; f
: TGLFont
);
837 var wa
, wb
, ch
: Integer; sa
, sb
: AnsiString;
841 r_Draw_GetTextSize(sa
, f
, wa
, ch
);
842 r_Draw_GetTextSize(sa
+ ' / ', f
, wb
, ch
);
843 r_Common_DrawText(sa
, x
, y
, 255, 0, 0, 255, f
, TBasePoint
.BP_LEFTUP
);
844 r_Common_DrawText(' / ', x
+ wa
, y
, 255, 255, 255, 255, f
, TBasePoint
.BP_LEFTUP
);
845 r_Common_DrawText(sb
, x
+ wb
, y
, 255, 0, 0, 255, f
, TBasePoint
.BP_LEFTUP
);
848 procedure r_Render_DrawSinglStatsPlayer (player
, x
, y
, w1
: Integer);
849 var time
, kpm
: Single;
851 r_Common_DrawText(_lc
[I_MENU_INTER_KILLS
], x
, y
, 255, 255, 255, 255, menufont
, TBasePoint
.BP_LEFTUP
);
852 r_Render_DrawValueOf(SingleStat
.PlayerStat
[player
].Kills
, gTotalMonsters
, x
+ w1
, y
, MenuFont
);
853 r_Common_DrawText(_lc
[I_MENU_INTER_KPM
], x
, y
+ 32, 255, 255, 255, 255, menufont
, TBasePoint
.BP_LEFTUP
);
854 time
:= SingleStat
.GameTime
/ 1000;
855 kpm
:= SingleStat
.PlayerStat
[player
].Kills
;
856 if time
> 0 then kpm
:= kpm
/ time
* 60;
857 r_Common_DrawText(Format('%.1f', [kpm
]), x
+ w1
, y
+ 32, 255, 0, 0, 255, menufont
, TBasePoint
.BP_LEFTUP
);
858 r_Common_DrawText(_lc
[I_MENU_INTER_SECRETS
], x
, y
+ 64, 255, 255, 255, 255, menufont
, TBasePoint
.BP_LEFTUP
);
859 r_Render_DrawValueOf(SingleStat
.PlayerStat
[player
].Secrets
, SingleStat
.TotalSecrets
, x
+ w1
, y
+ 64, MenuFont
);
862 procedure r_Render_DrawSingleStats
;
863 var xx
, wa
, wb
, ww
, ch
: Integer; s
: AnsiString;
865 r_Common_DrawText(_lc
[I_MENU_INTER_LEVEL_COMPLETE
], gScreenWidth
div 2, 32, 255, 255, 255, 255, menufont
, TBasePoint
.BP_UP
);
867 r_Draw_GetTextSize(_lc
[I_MENU_INTER_KPM
] + ' ', menufont
, wa
, ch
);
868 r_Draw_GetTextSize(' 9999.9', menufont
, wb
, ch
);
870 xx
:= gScreenWidth
div 2 - ww
div 2;
872 s
:= r_Common_TimeToStr(SingleStat
.GameTime
);
873 r_Common_DrawText(_lc
[I_MENU_INTER_TIME
], xx
, 80, 255, 255, 255, 255, menufont
, TBasePoint
.BP_LEFTUP
);
874 r_Common_DrawText(s
, xx
+ wa
, 80, 255, 0, 0, 255, menufont
, TBasePoint
.BP_LEFTUP
);
876 if SingleStat
.TwoPlayers
then
878 r_Common_DrawText(_lc
[I_MENU_PLAYER_1
], gScreenWidth
div 2, 128, 255, 255, 255, 255, menufont
, TBasePoint
.BP_UP
);
879 r_Render_DrawSinglStatsPlayer(0, xx
, 176, wa
);
880 r_Common_DrawText(_lc
[I_MENU_PLAYER_2
], gScreenWidth
div 2, 288, 255, 255, 255, 255, menufont
, TBasePoint
.BP_UP
);
881 r_Render_DrawSinglStatsPlayer(1, xx
, 336, wa
);
885 r_Render_DrawSinglStatsPlayer(0, xx
, 128, wa
);
889 procedure r_Render_DrawSpectHud
;
890 var xoff
: Integer; s
: AnsiString;
892 procedure AddText (s1
, s2
: AnsiString);
893 var w1
, w2
, ww
, ch
: Integer;
895 r_Draw_GetTextSize(s1
, stdfont
, w1
, ch
);
896 r_Draw_GetTextSize(s2
, stdfont
, w2
, ch
);
898 r_Common_DrawText(s1
, xoff
+ ww
div 2, gScreenHeight
- ch
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_DOWN
);
899 r_Common_DrawText(s2
, xoff
+ ww
div 2, gScreenHeight
- ch
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
900 xoff
:= xoff
+ ww
+ 16;
906 SPECT_STATS
: s
:= 'MODE: Stats';
907 SPECT_MAPVIEW
: s
:= 'MODE: Observe Map';
908 SPECT_PLAYERS
: s
:= 'MODE: Watch Players';
909 otherwise s
:= 'MODE: ' + IntToStr(gSpectMode
);
911 AddText(s
, '< jump >');
912 if gSpectMode
= SPECT_STATS
then
913 AddText('Autoview', '< fire >');
914 if gSpectMode
= SPECT_MAPVIEW
then
915 AddText('[-] Step ' + IntToStr(gSpectStep
) + ' [+]', '<prev weap> <next weap>');
916 if gSpectMode
= SPECT_PLAYERS
then
918 AddText('Player 1', '<left/right>');
919 if gSpectViewTwo
then
920 AddText('Player 2', '<prev w/next w>');
921 AddText('2x View', '<up/down>');
925 function GetActivePlayer_ByID (id
: Integer): TPlayer
;
926 var i
, len
: Integer; p
: TPlayer
;
929 if (id
>= 0) and (gPlayers
<> nil) then
931 i
:= 0; len
:= Length(gPlayers
);
932 while (i
< len
) and ((IsActivePlayer(gPlayers
[i
]) = false) or (gPlayers
[i
].UID
<> id
)) do INC(i
);
933 if i
< len
then p
:= gPlayers
[i
];
938 procedure r_Render_DrawMinimap (x
, y
: Integer; alpha
: Byte);
941 function IsMinimapPanel (const p
: TPanel
): Boolean;
943 result
:= (p
<> nil) and p
.Enabled
;
947 PANEL_WALL
, PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
948 PANEL_STEP
, PANEL_OPENDOOR
, PANEL_CLOSEDOOR
,
949 PANEL_LIFTUP
, PANEL_LIFTDOWN
, PANEL_LIFTLEFT
, PANEL_LIFTRIGHT
:
957 procedure DrawObject (xx
, yy
, ww
, hh
: Integer; r
, g
, b
: Byte);
958 var x0
, y0
, x1
, y1
: Integer;
960 x0
:= x
+ xx
div scale
;
961 y0
:= y
+ yy
div scale
;
962 x1
:= x
+ (xx
+ ww
- 1) div scale
;
963 y1
:= y
+ (yy
+ hh
- 1) div scale
;
964 r_Draw_FillRect(x0
, y0
, x1
, y1
, r
, g
, b
, alpha
);
967 procedure DrawPanels (const a
: TPanelArray
);
968 var i
: Integer; p
: TPanel
; c
: TRGB
;
972 for i
:= 0 to HIGH(a
) do
975 if IsMinimapPanel(p
) then
978 PANEL_WALL
: c
:= _RGB(208, 208, 208);
979 PANEL_OPENDOOR
: c
:= _RGB(160, 160, 160);
980 PANEL_CLOSEDOOR
: c
:= _RGB(160, 160, 160);
981 PANEL_STEP
: c
:= _RGB(128, 128, 128);
982 PANEL_LIFTUP
, PANEL_LIFTDOWN
, PANEL_LIFTLEFT
, PANEL_LIFTRIGHT
:
984 LIFTTYPE_UP
: c
:= _RGB(116, 72, 36);
985 LIFTTYPE_DOWN
: c
:= _RGB(116, 124, 96);
986 LIFTTYPE_LEFT
: c
:= _RGB(116, 200, 80);
987 LIFTTYPE_RIGHT
: c
:= _RGB(116, 252, 140);
988 otherwise c
:= _RGB(255, 0, 0);
990 PANEL_WATER
: c
:= _RGB(0, 0, 192);
991 PANEL_ACID1
: c
:= _RGB(0, 176, 0);
992 PANEL_ACID2
: c
:= _RGB(176, 0, 0);
993 otherwise c
:= _RGB(255, 0, 0);
995 DrawObject(p
.x
, p
.y
, p
.width
, p
.height
, c
.r
, c
.g
, c
.b
);
1001 procedure DrawPlayers
;
1002 var i
: Integer; p
: TPlayer
; c
: TRGB
;
1004 if gPlayers
<> nil then
1006 for i
:= 0 to HIGH(gPlayers
) do
1012 TEAM_RED
: c
:= _RGB(255, 0, 0);
1013 TEAM_BLUE
: c
:= _RGB(0, 0, 255);
1014 otherwise c
:= _RGB(255, 128, 0);
1016 DrawObject(p
.obj
.x
, p
.obj
.y
, p
.obj
.rect
.width
, p
.obj
.rect
.height
, c
.r
, c
.g
, c
.b
);
1022 function DrawMonster (m
: TMonster
): Boolean;
1024 result
:= false; // don't stop
1026 DrawObject(m
.obj
.x
, m
.obj
.y
, m
.obj
.rect
.width
, m
.obj
.rect
.height
, 255, 255, 0);
1030 r_Draw_FillRect(x
, y
, (x
+ gMapInfo
.Width
- 1) div scale
, (y
+ gMapInfo
.Height
- 1) div scale
, 0, 0, 0, alpha
);
1037 g_Mons_ForEach(DrawMonster
);
1041 procedure r_Render_Draw
;
1042 var p1
, p2
: TPlayer
;
1044 if gExit
= EXIT_QUIT
then
1047 r_Draw_Setup(gScreenWidth
, gScreenHeight
);
1049 glClearColor(0.0, 0.0, 0.0, 0.0);
1050 glClear(GL_COLOR_BUFFER_BIT
or GL_DEPTH_BUFFER_BIT
);
1052 glColor4ub(255, 255, 255, 255);
1053 glEnable(GL_SCISSOR_TEST
);
1054 r_Draw_SetRect(0, 0, gScreenWidth
, gScreenHeight
);
1056 //e_LogWritefln('r_render_draw: %sx%s', [gScreenWidth, gScreenHeight]);
1060 if gGameOn
or (gState
= STATE_FOLD
) then
1062 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
1064 if gRevertPlayers
then
1075 else if gPlayer1
<> nil then
1079 else if gPlayer2
<> nil then
1083 if (gSpectMode
= SPECT_PLAYERS
) and (gPlayers
<> nil) then
1085 p1
:= GetActivePlayer_ByID(gSpectPID1
);
1087 p1
:= GetActivePlayer_ByID(GetActivePlayerID_Next());
1088 if gSpectViewTwo
then
1090 p2
:= GetActivePlayer_ByID(gSpectPID2
);
1092 p2
:= GetActivePlayer_ByID(GetActivePlayerID_Next());
1097 if gGameOn
or ((gState
in [STATE_FOLD
]) and (EndingGameCounter
< 255)) then
1099 // TODO setup player hear point
1101 if gSpectMode
= SPECT_MAPVIEW
then
1103 r_Render_DrawMapView(0, 0, gScreenWidth
, gScreenHeight
, gSpectX
+ gScreenWidth
div 2, gSpectY
+ gScreenHeight
div 2);
1105 else if (p1
<> nil) and (p2
<> nil) then
1107 r_Render_DrawPlayerView(0, 0, gScreenWidth
, gScreenHeight
div 2 - 2, p1
);
1108 r_Render_DrawPlayerView(0, gScreenHeight
div 2 + 2, gScreenWidth
, gScreenHeight
div 2, p2
);
1110 else if p1
<> nil then
1112 r_Render_DrawPlayerView(0, 0, gScreenWidth
, gScreenHeight
, p1
);
1114 else if p2
<> nil then
1116 r_Render_DrawPlayerView(0, 0, gScreenWidth
, gScreenHeight
, p2
);
1120 r_Render_DrawMiniMap(0, 0, 160);
1122 // TODO draw holmes inspector
1124 if MessageText
<> '' then
1125 r_Common_DrawFormatText(MessageText
, (gScreenWidth
- 196) div 2, gScreenHeight
div 2, 255, menufont
, TBasePoint
.BP_CENTER
);
1127 if IsDrawStat
or (gSpectMode
= SPECT_STATS
) then
1130 if gSpectHUD
and (gChatShow
= false) and (gSpectMode
<> SPECT_NONE
) and (gSpectAuto
= false) then
1131 r_Render_DrawSpectHud
;
1134 if gPauseMain
and gGameOn
{$IFDEF ENABLE_MENU}and (g_ActiveWindow
= nil){$ENDIF} then
1136 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
1137 r_Common_DrawText(_lc
[I_MENU_PAUSE
], gScreenWidth
div 2, gScreenHeight
div 2, 255, 255, 255, 255, menufont
, TBasePoint
.BP_CENTER
);
1143 STATE_NONE
: (* do nothing *) ;
1144 STATE_MENU
: r_Render_DrawBackground(GameWad
+ ':TEXTURES/TITLE');
1147 if EndingGameCounter
> 0 then
1148 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, MIN(MAX(255 - EndingGameCounter
, 0), 255));
1152 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1153 if EndPicPath
<> '' then
1154 r_Render_DrawBackground(EndPicPath
)
1156 r_Render_DrawBackground(GameWad
+ ':TEXTURES/' + _lc
[I_TEXTURE_ENDPIC
])
1158 r_Render_DrawBackground(GameWad
+ ':TEXTURES/INTER');
1160 r_Render_DrawCustomStats
;
1162 {$IFDEF ENABLE_MENU}
1163 if g_ActiveWindow
<> nil then
1164 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
1167 STATE_INTERSINGLE
, STATE_INTERTEXT
, STATE_INTERPIC
:
1169 if EndingGameCounter
> 0 then
1171 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, MIN(MAX(255 - EndingGameCounter
, 0), 255));
1175 r_Render_DrawBackground(GameWad
+ ':TEXTURES/INTER');
1176 r_Render_DrawSingleStats
;
1177 {$IFDEF ENABLE_MENU}
1178 if g_ActiveWindow
<> nil then
1179 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
1185 if EndPicPath
<> '' then
1186 r_Render_DrawBackground(EndPicPath
)
1188 r_Render_DrawBackground(GameWad
+ ':TEXTURES/' + _lc
[I_TEXTURE_ENDPIC
]);
1189 {$IFDEF ENABLE_MENU}
1190 if g_ActiveWindow
<> nil then
1191 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
1196 r_Render_DrawBackground(GameWad
+ ':TEXTURES/TITLE');
1197 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
1198 r_Render_DrawServerList(slCurrent
, slTable
);
1203 {$IFDEF ENABLE_MENU}
1204 if g_ActiveWindow
<> nil then
1207 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
1208 r_GUI_Draw_Window(g_ActiveWindow
);
1212 r_Console_Draw(false);
1214 // TODO draw holmes interface
1221 procedure r_Render_Resize (w
, h
: Integer);
1231 procedure r_Render_Apply
;
1233 {$IFDEF ENABLE_SYSTEM}
1234 if sys_SetDisplayModeGL(GetInfo()) then
1235 e_LogWriteln('resolution changed')
1237 e_LogWriteln('resolution not changed');
1238 sys_EnableVSync(gVSync
)
1242 function r_Render_WriteScreenShot (filename
: String): Boolean;
1247 {$IFDEF ENABLE_GIBS}
1248 function r_Render_GetGibRect (m
, id
: Integer): TRectWH
;
1250 result
:= r_Map_GetGibSize(m
, id
);
1255 procedure r_Render_QueueEffect (AnimType
, X
, Y
: Integer);
1257 r_Map_NewGFX(AnimType
, X
, Y
);
1261 {$IFDEF ENABLE_TOUCH}
1262 procedure r_Render_GetKeyRect (key
: Integer; out x
, y
, w
, h
: Integer; out founded
: Boolean);
1268 {$IFDEF ENABLE_MENU}
1269 procedure r_Render_GetControlSize (ctrl
: TGUIControl
; out w
, h
: Integer);
1271 r_GUI_GetSize(ctrl
, w
, h
);
1274 procedure r_Render_GetLogoSize (out w
, h
: Integer);
1276 r_GUI_GetLogoSize(w
, h
);
1279 procedure r_Render_GetMaxFontSize (BigFont
: Boolean; out w
, h
: Integer);
1281 r_GUI_GetMaxFontSize(BigFont
, w
, h
);
1284 procedure r_Render_GetStringSize (BigFont
: Boolean; str
: String; out w
, h
: Integer);
1286 r_GUI_GetStringSize(BigFont
, str
, w
, h
);
1290 procedure r_Render_DrawLoading (force
: Boolean);
1292 // TODO draw loading screen