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
,
86 g_game
, g_map
, g_options
, g_console
, g_player
, g_weapons
, g_language
, g_triggers
,
88 r_draw
, r_textures
, r_fonts
, r_common
, r_console
, r_map
93 BP_LEFTUP
, BP_UP
, BP_RIGHTUP
,
94 BP_LEFT
, BP_CENTER
, BP_RIGHT
,
95 BP_LEFTDOWN
, BP_DOWN
, BP_RIGHTDOWN
99 BackgroundTexture
: THereTexture
;
101 hud
, hudbg
: TGLTexture
;
102 hudhp
: array [Boolean] of TGLTexture
;
104 hudwp
: array [0..WP_LAST
] of TGLTexture
;
105 hudkey
: array [0..2] of TGLTexture
;
108 hudrflag
, hudrflags
, hudrflagd
: TGLTexture
;
109 hudbflag
, hudbflags
, hudbflagd
: TGLTexture
;
111 procedure r_Render_LoadTextures
;
116 procedure r_Render_FreeTextures
;
121 procedure r_Render_Load
;
123 WeapName
: array [0..WP_LAST
] of AnsiString = ('KASTET', 'SAW', 'PISTOL', 'SHOTGUN1', 'SHOTGUN2', 'MGUN', 'RLAUNCHER', 'PGUN', 'BFG', 'SPULEMET', 'FLAMETHROWER');
128 BackgroundTexture
:= DEFAULT(THereTexture
);
129 hud
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/HUD');
130 hudbg
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/HUDBG');
131 hudhp
[false] := r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/MED2');
132 hudhp
[true] := r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/BMED');
133 hudap
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/ARMORHUD');
134 for i
:= 0 to WP_LAST
do
135 hudwp
[i
] := r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/' + WeapName
[i
]);
136 hudkey
[0] := r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/KEYR');
137 hudkey
[1] := r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/KEYG');
138 hudkey
[2] := r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/KEYB');
139 hudair
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/AIRBAR');
140 hudjet
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/JETBAR');
141 hudrflag
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_R_BASE');
142 hudrflags
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_R_STOLEN');
143 hudrflagd
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_R_DROP');
144 hudbflag
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_B_BASE');
145 hudbflags
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_B_STOLEN');
146 hudbflagd
:= r_Textures_LoadFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_B_DROP');
154 procedure r_Render_Free
;
173 for i
:= 0 to WP_LAST
do
175 if hudwp
[i
] <> nil then
184 r_Common_FreeThis(BackgroundTexture
);
188 {$IFDEF ENABLE_SYSTEM}
189 function GetInfo (): TGLDisplayInfo
;
190 var info
: TGLDisplayInfo
;
192 info
:= Default(TGLDisplayInfo
);
193 info
.w
:= Max(1, gRC_Width
);
194 info
.h
:= Max(1, gRC_Height
);
195 info
.bpp
:= Max(1, gBPP
);
196 info
.fullscreen
:= gRC_FullScreen
;
197 info
.maximized
:= gRC_Maximized
;
200 info
.profile
:= TGLProfile
.Compat
;
205 procedure r_Render_Initialize
;
207 {$IFDEF ENABLE_SYSTEM}
208 if sys_SetDisplayModeGL(GetInfo()) = False then
209 raise Exception
.Create('Failed to set videomode on startup.');
210 sys_EnableVSync(gVSync
);
212 r_Textures_Initialize
;
213 r_Console_Initialize
;
217 procedure r_Render_Finalize
;
224 procedure r_Render_Update
;
230 procedure r_Render_GetBasePoint (x
, y
, w
, h
: Integer; p
: TBasePoint
; out xx
, yy
: Integer);
233 TBasePoint
.BP_LEFTUP
, TBasePoint
.BP_LEFT
, TBasePoint
.BP_LEFTDOWN
: xx
:= x
;
234 TBasePoint
.BP_UP
, TBasePoint
.BP_CENTER
, TBasePoint
.BP_DOWN
: xx
:= x
- w
div 2;
235 TBasePoint
.BP_RIGHTUP
, TBasePoint
.BP_RIGHT
, TBasePoint
.BP_RIGHTDOWN
: xx
:= x
- w
;
238 TBasePoint
.BP_LEFTUP
, TBasePoint
.BP_UP
, TBasePoint
.BP_RIGHTUP
: yy
:= y
;
239 TBasePoint
.BP_LEFT
, TBasePoint
.BP_CENTER
, TBasePoint
.BP_RIGHT
: yy
:= y
- h
div 2;
240 TBasePoint
.BP_LEFTDOWN
, TBasePoint
.BP_DOWN
, TBasePoint
.BP_RIGHTDOWN
: yy
:= y
- h
;
244 procedure r_Render_DrawText (const text: AnsiString; x
, y
: Integer; r
, g
, b
, a
: Byte; f
: TGLFont
; p
: TBasePoint
);
247 if p
<> TBasePoint
.BP_LEFTUP
then
249 r_Draw_GetTextSize(text, f
, w
, h
);
250 r_Render_GetBasePoint(x
, y
, w
, h
, p
, x
, y
);
252 r_Draw_Text(text, x
, y
, r
, g
, b
, a
, f
);
255 procedure r_Render_DrawTexture (img
: TGLTexture
; x
, y
, w
, h
: Integer; p
: TBasePoint
);
257 r_Render_GetBasePoint(x
, y
, w
, h
, p
, x
, y
);
258 r_Draw_TextureRepeat(img
, x
, y
, w
, h
, false, 255, 255, 255, 255, false);
261 procedure r_Render_DrawHUD (x
, y
: Integer; p
: TPlayer
);
262 var t
: TGLTexture
; s
: AnsiString;
266 // hud area is 196 x 240 pixels
267 r_Render_DrawTexture(hud
, x
, y
, hud
.width
, hud
.height
, TBasePoint
.BP_LEFTUP
);
268 r_Render_DrawText(p
.name
, x
+ 98, y
+ 16, 255, 0, 0, 255, smallfont
, TBasePoint
.BP_CENTER
);
270 t
:= hudhp
[R_BERSERK
in p
.FRulez
];
271 r_Render_DrawTexture(t
, x
+ 51, y
+ 61, t
.width
, t
.height
, TBasePoint
.BP_CENTER
);
272 r_Render_DrawTexture(hudap
, x
+ 50, y
+ 85, hudap
.width
, hudap
.height
, TBasePoint
.BP_CENTER
);
274 r_Render_DrawText(IntToStr(MAX(0, p
.health
)), x
+ 174, y
+ 56, 255, 0, 0, 255, menufont
, TBasePoint
.BP_RIGHT
);
275 r_Render_DrawText(IntToStr(MAX(0, p
.armor
)), x
+ 174, y
+ 84, 255, 0, 0, 255, menufont
, TBasePoint
.BP_RIGHT
);
278 WEAPON_KASTET
, WEAPON_SAW
: s
:= '--';
279 else s
:= IntToStr(p
.GetAmmoByWeapon(p
.CurrWeap
));
281 r_Render_DrawText(s
, x
+ 174, y
+ 174, 255, 0, 0, 255, menufont
, TBasePoint
.BP_RIGHT
);
283 if p
.CurrWeap
<= WP_LAST
then
285 t
:= hudwp
[p
.CurrWeap
];
286 r_Render_DrawTexture(t
, x
+ 18, y
+ 160, t
.width
, t
.height
, TBasePoint
.BP_LEFTUP
);
289 if R_KEY_RED
in p
.FRulez
then
290 r_Render_DrawTexture(hudkey
[0], x
+ 76, y
+ 214, 16, 16, TBasePoint
.BP_LEFTUP
);
291 if R_KEY_GREEN
in p
.FRulez
then
292 r_Render_DrawTexture(hudkey
[1], x
+ 93, y
+ 214, 16, 16, TBasePoint
.BP_LEFTUP
);
293 if R_KEY_BLUE
in p
.FRulez
then
294 r_Render_DrawTexture(hudkey
[2], x
+ 110, y
+ 214, 16, 16, TBasePoint
.BP_LEFTUP
);
296 if p
.JetFuel
> 0 then
298 r_Render_DrawTexture(hudair
, x
, y
+ 116, hudair
.width
, hudair
.height
, TBasePoint
.BP_LEFTUP
);
300 r_Draw_FillRect(x
+ 14, y
+ 116 + 4, x
+ 14 + 168 * p
.air
div AIR_MAX
, y
+ 116 + 4 + 4, 0, 0, 196, 255);
301 r_Render_DrawTexture(hudjet
, x
, y
+ 126, hudjet
.width
, hudjet
.height
, TBasePoint
.BP_LEFTUP
);
302 r_Draw_FillRect(x
+ 14, y
+ 126 + 4, x
+ 14 + 168 * p
.JetFuel
div JET_MAX
, y
+ 126 + 4 + 4, 208, 0, 0, 255);
306 r_Render_DrawTexture(hudair
, x
, y
+ 124, hudair
.width
, hudair
.height
, TBasePoint
.BP_LEFTUP
);
308 r_Draw_FillRect(x
+ 14, y
+ 124 + 4, x
+ 14 + 168 * p
.air
div AIR_MAX
, y
+ 124 + 4 + 4, 0, 0, 196, 255);
312 procedure r_Render_DrawHUDArea (x
, y
, w
, h
: Integer; p
: TPlayer
);
315 r_Render_DrawTexture(hudbg
, x
, y
, w
, h
, TBasePoint
.BP_LEFTUP
);
318 r_Render_DrawHUD(x
+ w
- 196 + 2, y
, p
);
320 if gShowPing
and g_Game_IsClient
then
322 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
323 r_Render_DrawText(s
, x
+ 4, y
+ 242, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
328 r_Render_DrawText(_lc
[I_PLAYER_SPECT
], x
+ 4, y
+ 242, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
329 r_Render_DrawText(_lc
[I_PLAYER_SPECT2
], x
+ 4, y
+ 258, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
330 r_Render_DrawText(_lc
[I_PLAYER_SPECT1
], x
+ 4, y
+ 274, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
332 r_Render_DrawText(_lc
[I_PLAYER_SPECT1S
], x
+ 4, y
+ 290, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
336 procedure r_Render_DrawStatsView (x
, y
, w
, h
: Integer; p
: TPlayer
);
337 var fw
, i
, maxFrags
, top
, totalPlayers
: Integer; sign
: Char; stat
: TPlayerStatArray
; f
: TGLTexture
;
341 if gShowScore
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
345 if gGameSettings
.GameMode
= GM_CTF
then
347 case gFlags
[FLAG_RED
].State
of
348 FLAG_STATE_CAPTURED
: f
:= hudrflags
;
349 FLAG_STATE_DROPPED
: f
:= hudrflagd
;
350 otherwise f
:= hudrflag
;
354 fw
:= f
.width
+ 8; (* + space *)
355 r_Render_DrawTexture(f
, x
+ w
- 16, y
+ 240 - 72 - 4, f
.width
, f
.height
, TBasePoint
.BP_RIGHTUP
);
358 r_Render_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
);
360 (* BLUE TEAM GOALS *)
362 if gGameSettings
.GameMode
= GM_CTF
then
364 case gFlags
[FLAG_BLUE
].State
of
365 FLAG_STATE_CAPTURED
: f
:= hudbflags
;
366 FLAG_STATE_DROPPED
: f
:= hudbflagd
;
367 otherwise f
:= hudbflag
;
371 fw
:= f
.width
+ 8; (* + space *)
372 r_Render_DrawTexture(f
, x
+ w
- 16, y
+ 240 - 32 - 4, f
.width
, f
.height
, TBasePoint
.BP_RIGHTUP
);
375 r_Render_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
);
378 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
382 r_Render_DrawText(IntToStr(p
.Frags
), x
+ w
- 16, y
, 255, 0, 0, 255, menufont
, TBasePoint
.BP_RIGHTUP
);
387 stat
:= g_Player_GetStats();
390 totalPlayers
:= Length(stat
);
391 for i
:= 0 to High(stat
) do
393 if stat
[i
].Name
<> p
.Name
then
395 maxFrags
:= MAX(maxFrags
, stat
[i
].Frags
);
396 if stat
[i
].Frags
> p
.Frags
then
401 if p
.Frags
>= maxFrags
then sign
:= '+' else sign
:= '-';
402 r_Render_DrawText(IntToStr(top
) + ' / ' + IntToStr(totalPlayers
) + ' ' + sign
+ IntToStr(ABS(p
.Frags
- maxFrags
)), x
+ w
- 16, y
+ 32, 255, 0, 0, 255, smallfont
, TBasePoint
.BP_RIGHTUP
);
405 if gLMSRespawn
> LMS_RESPAWN_NONE
then
407 r_Render_DrawText(_lc
[I_GAME_WARMUP
], x
+ w
- 16 - 64, y
+ h
, 0, 255, 0, 255, menufont
, TBasePoint
.BP_RIGHTDOWN
);
408 r_Render_DrawText(': ' + IntToStr((gLMSRespawnTime
- gTime
) div 1000), x
+ w
- 16 - 64, y
+ h
, 0, 255, 0, 255, menufont
, TBasePoint
.BP_LEFTDOWN
);
410 else if gShowLives
and (gGameSettings
.MaxLives
> 0) then
412 r_Render_DrawText(IntToStr(p
.Lives
), x
+ w
- 16, y
+ h
, 0, 255, 0, 255, menufont
, TBasePoint
.BP_RIGHTDOWN
);
417 procedure r_Render_DrawView (x
, y
, w
, h
: Integer; p
: TPlayer
);
418 var l
, t
, r
, b
: Integer;
420 r_Draw_GetRect(l
, t
, r
, b
);
421 r_Draw_SetRect(x
, y
, x
+ w
, y
+ h
);
425 r_Map_Draw(x
, y
, w
, h
, p
.obj
.x
+ PLAYER_RECT_CX
, p
.obj
.y
+ PLAYER_RECT_CY
, p
);
426 r_Render_DrawStatsView(x
, y
, w
, h
, p
);
427 if p
.Spectator
and p
.NoRespawn
then
428 r_Render_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
);
432 r_Map_Draw(x
, y
, w
, h
, 0, 0, nil);
435 r_Draw_SetRect(l
, t
, r
, b
);
438 procedure r_Render_DrawPlayerView (x
, y
, w
, h
: Integer; p
: TPlayer
);
439 var l
, t
, r
, b
: Integer;
441 r_Draw_GetRect(l
, t
, r
, b
);
442 r_Draw_SetRect(x
, y
, x
+ w
, y
+ h
);
443 r_Render_DrawView(x
, y
, w
- 196, h
, p
);
444 r_Render_DrawHUDArea(x
+ w
- 196, y
, 196, h
, p
);
445 r_Draw_SetRect(l
, t
, r
, b
);
448 procedure r_Render_DrawBackgroundImage (img
: TGLTexture
);
449 var fw
, w
, h
: LongInt;
453 img
:= BackgroundTexture
.id
;
454 if img
.width
= img
.height
then fw
:= img
.width
* 4 div 3 else fw
:= img
.width
; // fix aspect 4:3
455 r_Common_CalcAspect(fw
, img
.height
, gScreenWidth
, gScreenHeight
, false, w
, h
);
456 r_Draw_Texture(img
, gScreenWidth
div 2 - w
div 2, 0, w
, h
, false, 255, 255, 255, 255, false);
460 procedure r_Render_DrawBackground (const name
: AnsiString);
462 if r_Common_LoadThis(name
, BackgroundTexture
) then
463 r_Render_DrawBackgroundImage(BackgroundTexture
.id
)
466 procedure r_Render_DrawServerList (var SL
: TNetServerList
; var ST
: TNetServerTable
);
467 var ip
: AnsiString; ww
, hh
, cw
, ch
, mw
, mh
, motdh
, scrx
, scry
, i
, mx
, y
: Integer; msg
: SSArray
; Srv
: TNetServer
;
469 scrx
:= gScreenWidth
div 2;
470 scry
:= gScreenHeight
div 2;
472 r_Draw_GetTextSize(_lc
[I_NET_SLIST
], menufont
, ww
, hh
);
473 r_Render_DrawText(_lc
[I_NET_SLIST
], gScreenWidth
div 2, 16, 255, 255, 255, 255, menufont
, TBasePoint
.BP_UP
);
475 r_Draw_GetTextSize('W', stdfont
, cw
, ch
);
476 motdh
:= gScreenHeight
- 49 - ch
* b_Text_LineCount(slMOTD
);
478 r_Draw_FillRect(16, 64, gScreenWidth
- 16, motdh
, 64, 64, 64, 145);
479 r_Draw_Rect(16, 64, gScreenWidth
- 16, motdh
, 255, 127, 0, 255);
481 r_Render_DrawText(_lc
[I_NET_SLIST_HELP
], gScreenWidth
div 2, gScreenHeight
- 8, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_DOWN
);
485 r_Draw_FillRect(16, motdh
, gScreenWidth
- 16, gScreenHeight
- 44, 64, 64, 64, 110);
486 r_Draw_Rect(16, motdh
, gScreenWidth
- 16, gScreenHeight
- 44, 255, 127, 0, 255);
487 msg
:= Parse2(slMOTD
, #10);
488 for i
:= 0 to High(msg
) do
489 r_Render_DrawText(msg
[i
], 20, motdh
+ 3 + ch
* i
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
492 if not slReadUrgent
and (slUrgent
<> '') then
494 r_Draw_FillRect(17, 65, gScreenWidth
- 17, motdh
- 1, 64, 64, 64, 127);
495 r_Draw_FillRect(scrx
- 256, scry
- 60, scrx
+ 256, scry
+ 60, 64, 64, 64, 127);
496 r_Draw_Rect(scrx
- 256, scry
- 60, scrx
+ 256, scry
+ 60, 255, 127, 0, 255);
497 r_Draw_FillRect(scrx
- 256, scry
- 40, scrx
+ 256, scry
- 40, 255, 127, 0, 255);
498 r_Render_DrawText(_lc
[I_NET_SLIST_URGENT
], scrx
, scry
- 58, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
499 msg
:= Parse2(slUrgent
, #10);
500 for i
:= 0 to High(msg
) do
501 r_Render_DrawText(msg
[i
], scrx
- 253, scry
- 38 + ch
* i
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
502 r_Render_DrawText(_lc
[I_NET_SLIST_URGENT_CONT
], scrx
, scry
+ 41, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
503 r_Draw_FillRect(scrx
- 256, scry
+ 40, scrx
+ 256, scry
+ 40, 255, 127, 0, 255);
505 else if SL
= nil then
507 r_Draw_FillRect(17, 65, gScreenWidth
- 17, motdh
- 1, 64, 64, 64, 127);
508 r_Draw_Rect(scrx
- 192, scry
- 10, scrx
+ 192, scry
+ 11, 255, 127, 0, 255);
509 r_Render_DrawText(slWaitStr
, scrx
, scry
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_CENTER
);
514 if slSelection
< Length(ST
) then
516 sy
:= y
+ 42 * slSelection
- 4;
517 Srv
:= GetServerFromTable(slSelection
, SL
, ST
);
518 ip
:= _lc
[I_NET_ADDRESS
] + ' ' + Srv
.IP
+ ':' + IntToStr(Srv
.Port
);
519 ip
:= ip
+ ' ' + _lc
[I_NET_SERVER_PASSWORD
] + ' ';
520 if Srv
.Password
then ip
:= ip
+ _lc
[I_MENU_YES
] else ip
:= ip
+_lc
[I_MENU_NO
];
523 mw
:= gScreenWidth
- 188;
526 r_Draw_FillRect(16 + 1, sy
, gScreenWidth
- 16 - 1, sy
+ 40, 64, 64, 64, 255);
527 r_Draw_FillRect(16 + 1, sy
, gScreenWidth
- 16 - 1, sy
, 205, 205, 205, 255);
528 r_Draw_FillRect(16 + 1, sy
+ 41, gScreenWidth
- 16 - 1, sy
+ 41, 255, 255, 255, 255);
530 r_Draw_FillRect(16, 85, gScreenWidth
- 16, 85, 255, 127, 0, 255);
531 r_Draw_FillRect(16, motdh
- 20, gScreenWidth
- 16, motdh
- 20, 255, 127, 0, 255);
533 r_Draw_FillRect(mx
- 70, 64, mx
- 70, motdh
, 255, 127, 0, 255);
534 r_Draw_FillRect(mx
, 64, mx
, motdh
- 20, 255, 127, 0, 255);
535 r_Draw_FillRect(mx
+ 52, 64, mx
+ 52, motdh
- 20, 255, 127, 0, 255);
536 r_Draw_FillRect(mx
+ 104, 64, mx
+ 104, motdh
- 20, 255, 127, 0, 255);
538 r_Render_DrawText('NAME/MAP', 18, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
539 r_Render_DrawText('PING', mx
- 68, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
540 r_Render_DrawText('MODE', mx
+ 2, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
541 r_Render_DrawText('PLRS', mx
+ 54, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
542 r_Render_DrawText('VER', mx
+ 106, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
544 for i
:= 0 to High(ST
) do
546 Srv
:= GetServerFromTable(i
, SL
, ST
);
547 r_Render_DrawText(Srv
.Name
, 18, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
548 r_Render_DrawText(Srv
.Map
, 18, y
+ 16, 210, 210, 210, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
551 r_Render_DrawText('<1' + _lc
[I_NET_SLIST_PING_MS
], mx
- 68, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
)
552 else if (Srv
.Ping
>= 0) and (Srv
.Ping
<= 999) then
553 r_Render_DrawText(IntToStr(Srv
.Ping
) + _lc
[I_NET_SLIST_PING_MS
], mx
- 68, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
)
555 r_Render_DrawText(_lc
[I_NET_SLIST_NO_ACCESS
], mx
- 68, y
, 255, 0, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
556 if Length(ST
[I
].Indices
) > 1 then
557 r_Render_DrawText('<' + IntToStr(Length(ST
[I
].Indices
)) + '>', mx
- 68, y
+ 16, 210, 210, 210, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
559 r_Render_DrawText(g_Game_ModeToText(Srv
.GameMode
), mx
+ 2, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
561 r_Render_DrawText(IntToStr(Srv
.Players
) + '/' + IntToStr(Srv
.MaxPlayers
), mx
+ 54, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
562 r_Render_DrawText(IntToStr(Srv
.LocalPl
) + '+' + IntToStr(Srv
.Bots
), mx
+ 54, y
+ 16, 210, 210, 210, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
564 r_Render_DrawText(IntToStr(Srv
.Protocol
), mx
+ 106, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
569 r_Render_DrawText(ip
, 20, motdh
- 20 + 3, 205, 205, 205, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
570 r_Render_DrawText(IntToStr(Length(ST
)) + _lc
[I_NET_SLIST_SERVERS
], gScreenWidth
- 48, motdh
- 20 + 3, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_RIGHTUP
);
574 function r_Render_TimeToStr (t
: LongWord): AnsiString;
575 var h
, m
, s
: Integer;
577 h
:= t
div 1000 div 3600;
578 m
:= t
div 1000 div 60 mod 60;
579 s
:= t
div 1000 mod 60;
580 result
:= Format('%d:%.2d:%.2d', [h
, m
, s
]);
583 procedure r_Render_DrawStatsColumns (stat
: TPlayerStatArray
; x
, y
, w
, w1
, w2
, w3
, w4
: Integer);
584 var i
, cw
, ch
, yy
, team
: Integer; r
, g
, b
, rr
, gg
, bb
: Byte; s
: AnsiString;
587 r_Draw_GetTextSize('W', stdfont
, cw
, ch
);
589 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
591 for team
:= TEAM_RED
to TEAM_BLUE
do
596 s
:= _lc
[I_GAME_TEAM_RED
];
597 r
:= 255; g
:= 0; b
:= 0;
601 s
:= _lc
[I_GAME_TEAM_BLUE
];
602 r
:= 0; g
:= 0; b
:= 255;
605 r_Render_DrawText(s
, x
, yy
, r
, g
, b
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
606 r_Render_DrawText(IntToStr(gTeamStat
[team
].Score
), x
+ w1
, yy
, r
, g
, b
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
610 r_Draw_FillRect(x
, yy
, x
+ w
- 1, yy
, r
, g
, b
, 255);
613 for i
:= 0 to High(stat
) do
615 if stat
[i
].Team
= team
then
617 rr
:= r
; gg
:= g
; bb
:= b
;
618 if stat
[i
].Spectator
then
620 rr
:= r
div 2; gg
:= g
div 2; bb
:= b
div 2;
624 if gShowPIDs
then s
:= Format('[%5d] %s', [stat
[i
].UID
, stat
[i
].Name
]) else s
:= stat
[i
].Name
;
625 r_Render_DrawText(s
, x
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
627 s
:= Format(_lc
[I_GAME_PING_MS
], [stat
[i
].Ping
, stat
[i
].Loss
]);
628 r_Render_DrawText(s
, x
+ w1
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
630 s
:= IntToStr(stat
[i
].Frags
);
631 r_Render_DrawText(s
, x
+ w1
+ w2
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
633 s
:= IntToStr(stat
[i
].Deaths
);
634 r_Render_DrawText(s
, x
+ w1
+ w2
+ w3
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
642 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
644 r_Render_DrawText(_lc
[I_GAME_PLAYER_NAME
], x
, yy
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
645 r_Render_DrawText(_lc
[I_GAME_PING
], x
+ w1
, yy
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
646 r_Render_DrawText(_lc
[I_GAME_FRAGS
], x
+ w1
+ w2
, yy
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
647 r_Render_DrawText(_lc
[I_GAME_DEATHS
], x
+ w1
+ w2
+ w3
, yy
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
649 for i
:= 0 to High(stat
) do
651 rr
:= 255; gg
:= 127; bb
:= 0;
652 if stat
[i
].Spectator
then
654 rr
:= 127; gg
:= 63; bb
:= 0;
658 r_Draw_Rect(x
, yy
, x
+ 16 - 1, yy
+ 16 - 1, 192, 192, 192, 255);
659 r_Draw_FillRect(x
+ 1, yy
+ 1, x
+ 16 - 1, yy
+ 16 - 1, stat
[i
].Color
.R
, stat
[i
].Color
.G
, stat
[i
].Color
.B
, 255);
661 if gShowPIDs
then s
:= Format('[%5d] %s', [stat
[i
].UID
, stat
[i
].Name
]) else s
:= stat
[i
].Name
;
662 r_Render_DrawText(s
, x
+ 16 + 8, yy
, 192, 192, 192, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
664 s
:= Format(_lc
[I_GAME_PING_MS
], [stat
[i
].Ping
, stat
[i
].Loss
]);
665 r_Render_DrawText(s
, x
+ w1
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
667 s
:= IntToStr(stat
[i
].Frags
);
668 r_Render_DrawText(s
, x
+ w1
+ w2
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
670 s
:= IntToStr(stat
[i
].Deaths
);
671 r_Render_DrawText(s
, x
+ w1
+ w2
+ w3
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
678 procedure r_Render_DrawStats
;
679 var x
, y
, w
, h
, cw
, ch
, players
, w1
, w2
, w3
, w4
: Integer; s
: AnsiString; stat
: TPlayerStatArray
;
681 players
:= g_Player_GetCount();
682 r_Draw_GetTextSize('W', stdfont
, cw
, ch
);
683 w
:= gScreenWidth
- (gScreenWidth
div 5);
684 h
:= IfThen(gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
], 32 + ch
* (11 + players
), 40 + ch
* 5 + (ch
+ 8) * players
);
685 x
:= (gScreenWidth
div 2) - (w
div 2);
686 y
:= (gScreenHeight
div 2) - (h
div 2);
688 r_Draw_FillRect(x
, y
, x
+ w
- 1, y
+ h
- 1, 64, 64, 64, 224);
689 r_Draw_Rect(x
, y
, x
+ w
- 1, y
+ h
- 1, 255, 127, 0, 255);
692 NET_SERVER
: s
:= _lc
[I_NET_SERVER
];
693 NET_CLIENT
: s
:= NetClientIP
+ ':' + IntToStr(NetClientPort
);
696 r_Render_DrawText(s
, x
+ 16, y
+ 8, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
697 case gGameSettings
.GameMode
of
698 GM_DM
: if gGameSettings
.MaxLives
= 0 then s
:= _lc
[I_GAME_DM
] else s
:= _lc
[I_GAME_LMS
];
699 GM_TDM
: if gGameSettings
.MaxLives
= 0 then s
:= _lc
[I_GAME_TDM
] else s
:= _lc
[I_GAME_TLMS
];
700 GM_CTF
: s
:= _lc
[I_GAME_CTF
];
701 GM_COOP
: if gGameSettings
.MaxLives
= 0 then s
:= _lc
[I_GAME_COOP
] else s
:= _lc
[I_GAME_SURV
];
702 otherwise s
:= 'Game mode ' + IntToStr(gGameSettings
.GameMode
);
704 r_Render_DrawText(s
, x
+ w
div 2, y
+ 8, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
705 r_Render_DrawText(r_Render_TimeToStr(gTime
), x
+ w
- 16, y
+ 8, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_RIGHTUP
);
707 s
:= g_ExtractWadNameNoPath(gMapInfo
.Map
) + ':\' + g_ExtractFileName(gMapInfo
.Map
) + ' - ' + gMapInfo
.Name
;
708 r_Render_DrawText(s
, x
+ w
div 2, y
+ 8 + 24, 200, 200, 200, 255, stdfont
, TBasePoint
.BP_UP
);
710 case gGameSettings
.GameMode
of
711 GM_DM
, GM_TDM
: s
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
712 GM_CTF
: s
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.ScoreLimit
]);
713 GM_COOP
: s
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
716 r_Render_DrawText(s
, x
+ 16, y
+ 8 + 48, 200, 200, 200, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
718 case gGameSettings
.GameMode
of
719 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]);
720 GM_COOP
: s
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
723 r_Render_DrawText(s
, x
+ w
- 16, y
+ 8 + 48, 200, 200, 200, 255, stdfont
, TBasePoint
.BP_RIGHTUP
);
727 stat
:= g_Player_GetStats();
729 w2
:= (w
- 16) div 6 + 48;
730 w3
:= (w
- 16) div 6;
732 w1
:= w
- 16 - w2
- w3
- w4
;
733 r_Render_DrawStatsColumns(stat
, x
+ 16, y
+ 8 + 80, w
- 16, w1
, w2
, w3
, w4
);
737 procedure r_Render_Draw
;
739 if gExit
= EXIT_QUIT
then
742 r_Draw_Setup(gScreenWidth
, gScreenHeight
);
744 glClearColor(0.0, 0.0, 0.0, 0.0);
745 glClear(GL_COLOR_BUFFER_BIT
or GL_DEPTH_BUFFER_BIT
);
747 glColor4ub(255, 255, 255, 255);
748 glEnable(GL_SCISSOR_TEST
);
749 r_Draw_SetRect(0, 0, gScreenWidth
, gScreenHeight
);
751 //e_LogWritefln('r_render_draw: %sx%s', [gScreenWidth, gScreenHeight]);
753 if gGameOn
or ((gState
in [STATE_FOLD
]) and (EndingGameCounter
< 255)) then
755 // TODO setup sectator mode
756 // TODO setup player hear point
758 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
760 r_Render_DrawPlayerView(0, 0, gScreenWidth
, gScreenHeight
div 2 - 2, gPlayer1
);
761 r_Render_DrawPlayerView(0, gScreenHeight
div 2 + 2, gScreenWidth
, gScreenHeight
div 2, gPlayer2
);
765 r_Render_DrawPlayerView(0, 0, gScreenWidth
, gScreenHeight
, gPlayer1
);
768 // TODO draw holmes inspector
770 // TODO draw messages
771 if IsDrawStat
or (gSpectMode
= SPECT_STATS
) then
773 // TODO draw spectator hud
776 if gPauseMain
and gGameOn
{$IFDEF ENABLE_MENU}and (g_ActiveWindow
= nil){$ENDIF} then
778 // TODO draw pause screen
784 STATE_NONE
: (* do nothing *) ;
785 STATE_MENU
: r_Render_DrawBackground(GameWad
+ ':TEXTURES/TITLE');
788 if EndingGameCounter
> 0 then
789 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, MIN(MAX(255 - EndingGameCounter
, 0), 255));
793 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
794 if EndPicPath
<> '' then
795 r_Render_DrawBackground(EndPicPath
)
797 r_Render_DrawBackground(GameWad
+ ':TEXTURES/' + _lc
[I_TEXTURE_ENDPIC
])
799 r_Render_DrawBackground(GameWad
+ ':TEXTURES/INTER');
800 // TODO draw custom stata
802 if g_ActiveWindow
<> nil then
803 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
806 STATE_INTERSINGLE
, STATE_INTERTEXT
, STATE_INTERPIC
:
808 if EndingGameCounter
> 0 then
810 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, MIN(MAX(255 - EndingGameCounter
, 0), 255));
814 r_Render_DrawBackground(GameWad
+ ':TEXTURES/INTER');
815 // TODO darw single stats
817 if g_ActiveWindow
<> nil then
818 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
824 if EndPicPath
<> '' then
825 r_Render_DrawBackground(EndPicPath
)
827 r_Render_DrawBackground(GameWad
+ ':TEXTURES/' + _lc
[I_TEXTURE_ENDPIC
]);
829 if g_ActiveWindow
<> nil then
830 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
835 r_Render_DrawBackground(GameWad
+ ':TEXTURES/TITLE');
836 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
837 r_Render_DrawServerList(slCurrent
, slTable
);
843 if g_ActiveWindow
<> nil then
846 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
847 r_GUI_Draw_Window(g_ActiveWindow
);
851 r_Console_Draw(false);
853 // TODO draw holmes interface
860 procedure r_Render_Resize (w
, h
: Integer);
870 procedure r_Render_Apply
;
872 {$IFDEF ENABLE_SYSTEM}
873 if sys_SetDisplayModeGL(GetInfo()) then
874 e_LogWriteln('resolution changed')
876 e_LogWriteln('resolution not changed');
877 sys_EnableVSync(gVSync
)
881 function r_Render_WriteScreenShot (filename
: String): Boolean;
887 function r_Render_GetGibRect (m
, id
: Integer): TRectWH
;
889 result
:= r_Map_GetGibSize(m
, id
);
894 procedure r_Render_QueueEffect (AnimType
, X
, Y
: Integer);
896 r_Map_NewGFX(AnimType
, X
, Y
);
900 {$IFDEF ENABLE_TOUCH}
901 procedure r_Render_GetKeyRect (key
: Integer; out x
, y
, w
, h
: Integer; out founded
: Boolean);
908 procedure r_Render_GetControlSize (ctrl
: TGUIControl
; out w
, h
: Integer);
910 r_GUI_GetSize(ctrl
, w
, h
);
913 procedure r_Render_GetLogoSize (out w
, h
: Integer);
915 r_GUI_GetLogoSize(w
, h
);
918 procedure r_Render_GetMaxFontSize (BigFont
: Boolean; out w
, h
: Integer);
920 r_GUI_GetMaxFontSize(BigFont
, w
, h
);
923 procedure r_Render_GetStringSize (BigFont
: Boolean; str
: String; out w
, h
: Integer);
925 r_GUI_GetStringSize(BigFont
, str
, w
, h
);
929 procedure r_Render_DrawLoading (force
: Boolean);
931 // TODO draw loading screen