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 TProcedure
= procedure;
31 procedure r_Render_Initialize
;
32 procedure r_Render_Finalize
;
34 (* load globally used textures *)
35 procedure r_Render_Load
;
36 procedure r_Render_Free
;
38 (* load map specific textures *)
39 procedure r_Render_LoadTextures
;
40 procedure r_Render_FreeTextures
;
42 procedure r_Render_Update
;
43 procedure r_Render_Draw
;
45 procedure r_Render_Resize (w
, h
: Integer);
46 procedure r_Render_Apply
;
48 function r_Render_WriteScreenShot (filename
: String): Boolean;
51 function r_Render_GetGibRect (m
, id
: Integer): TRectWH
;
55 procedure r_Render_QueueEffect (AnimType
, X
, Y
: Integer);
59 // touch screen button location and size
60 procedure r_Render_GetKeyRect (key
: Integer; out x
, y
, w
, h
: Integer; out founded
: Boolean);
64 procedure r_Render_GetControlSize (ctrl
: TGUIControl
; out w
, h
: Integer);
65 procedure r_Render_GetLogoSize (out w
, h
: Integer);
66 procedure r_Render_GetMaxFontSize (BigFont
: Boolean; out w
, h
: Integer);
67 procedure r_Render_GetStringSize (BigFont
: Boolean; str
: String; out w
, h
: Integer);
70 procedure r_Render_SetProcessLoadingCallback (p
: TProcedure
);
71 procedure r_Render_ClearLoading
;
72 procedure r_Render_SetLoading (const text: String; maxval
: Integer);
73 procedure r_Render_StepLoading (incval
: Integer);
74 procedure r_Render_DrawLoading (force
: Boolean);
87 {$IFDEF ENABLE_SYSTEM}
90 SysUtils
, Classes
, Math
,
92 e_log
, utils
, wadreader
, mapdef
,
93 g_game
, g_map
, g_panel
, g_options
, g_console
, g_player
, g_weapons
, g_language
, g_triggers
, g_monsters
,
95 r_draw
, r_textures
, r_fonts
, r_common
, r_console
, r_map
, r_loadscreen
99 hud
, hudbg
: TGLTexture
;
100 hudhp
: array [Boolean] of TGLTexture
;
102 hudwp
: array [0..WP_LAST
] of TGLTexture
;
103 hudkey
: array [0..2] of TGLTexture
;
106 hudrflag
, hudrflags
, hudrflagd
: TGLTexture
;
107 hudbflag
, hudbflags
, hudbflagd
: TGLTexture
;
109 FPS
, FPSCounter
, FPSTime
: LongWord;
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');
129 r_Common_SetLoading('HUD Textures', 5 + (WP_LAST
+ 1) + 11);
130 hud
:= r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/HUD', [TGLHints
.txNoRepeat
]);
131 hudbg
:= r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/HUDBG', []);
132 hudhp
[false] := r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/MED2', [TGLHints
.txNoRepeat
]);
133 hudhp
[true] := r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/BMED', [TGLHints
.txNoRepeat
]);
134 hudap
:= r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/ARMORHUD', [TGLHints
.txNoRepeat
]);
135 for i
:= 0 to WP_LAST
do
136 hudwp
[i
] := r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/' + WeapName
[i
], [TGLHints
.txNoRepeat
]);
137 hudkey
[0] := r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/KEYR', [TGLHints
.txNoRepeat
]);
138 hudkey
[1] := r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/KEYG', [TGLHints
.txNoRepeat
]);
139 hudkey
[2] := r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/KEYB', [TGLHints
.txNoRepeat
]);
140 hudair
:= r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/AIRBAR', [TGLHints
.txNoRepeat
]);
141 hudjet
:= r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/JETBAR', [TGLHints
.txNoRepeat
]);
142 hudrflag
:= r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_R_BASE', [TGLHints
.txNoRepeat
]);
143 hudrflags
:= r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_R_STOLEN', [TGLHints
.txNoRepeat
]);
144 hudrflagd
:= r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_R_DROP', [TGLHints
.txNoRepeat
]);
145 hudbflag
:= r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_B_BASE', [TGLHints
.txNoRepeat
]);
146 hudbflags
:= r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_B_STOLEN', [TGLHints
.txNoRepeat
]);
147 hudbflagd
:= r_Common_LoadTextureFromFile(GameWAD
+ ':TEXTURES/FLAGHUD_B_DROP', [TGLHints
.txNoRepeat
]);
155 procedure r_Render_Free
;
163 r_Common_FreeAndNil(hudbflagd
);
164 r_Common_FreeAndNil(hudbflags
);
165 r_Common_FreeAndNil(hudbflag
);
166 r_Common_FreeAndNil(hudrflagd
);
167 r_Common_FreeAndNil(hudrflags
);
168 r_Common_FreeAndNil(hudrflag
);
169 r_Common_FreeAndNil(hudjet
);
170 r_Common_FreeAndNil(hudair
);
171 r_Common_FreeAndNil(hudkey
[0]);
172 r_Common_FreeAndNil(hudkey
[1]);
173 r_Common_FreeAndNil(hudkey
[2]);
174 for i
:= 0 to WP_LAST
do
175 r_Common_FreeAndNil(hudwp
[i
]);
176 r_Common_FreeAndNil(hudap
);
177 r_Common_FreeAndNil(hudhp
[true]);
178 r_Common_FreeAndNil(hudhp
[false]);
179 r_Common_FreeAndNil(hudbg
);
180 r_Common_FreeAndNil(hud
);
184 {$IFDEF ENABLE_SYSTEM}
185 function GetInfo (): TGLDisplayInfo
;
186 var info
: TGLDisplayInfo
;
188 info
:= Default(TGLDisplayInfo
);
189 info
.w
:= Max(1, gRC_Width
);
190 info
.h
:= Max(1, gRC_Height
);
191 info
.bpp
:= Max(1, gBPP
);
192 info
.fullscreen
:= gRC_FullScreen
;
193 info
.maximized
:= gRC_Maximized
;
196 info
.profile
:= TGLProfile
.Compat
;
201 procedure r_Render_Initialize
;
203 {$IFDEF ENABLE_SYSTEM}
204 if sys_SetDisplayModeGL(GetInfo()) = False then
205 raise Exception
.Create('Failed to set videomode on startup.');
206 sys_EnableVSync(gVSync
);
208 r_LoadScreen_Initialize
;
209 r_Textures_Initialize
;
210 r_Console_Initialize
;
214 procedure r_Render_Finalize
;
219 r_LoadScreen_Finalize
;
222 procedure r_Render_Update
;
228 procedure r_Render_DrawHUD (x
, y
: Integer; p
: TPlayer
);
229 var t
: TGLTexture
; s
: AnsiString;
233 // hud area is 196 x 240 pixels
234 r_Common_DrawTexture(hud
, x
, y
, hud
.width
, hud
.height
, TBasePoint
.BP_LEFTUP
);
235 r_Common_DrawText(p
.name
, x
+ 98, y
+ 16, 255, 0, 0, 255, smallfont
, TBasePoint
.BP_CENTER
);
237 t
:= hudhp
[R_BERSERK
in p
.FRulez
];
238 r_Common_DrawTexture(t
, x
+ 51, y
+ 61, t
.width
, t
.height
, TBasePoint
.BP_CENTER
);
239 r_Common_DrawTexture(hudap
, x
+ 50, y
+ 85, hudap
.width
, hudap
.height
, TBasePoint
.BP_CENTER
);
241 r_Common_DrawText(IntToStr(MAX(0, p
.health
)), x
+ 174, y
+ 56, 255, 0, 0, 255, menufont
, TBasePoint
.BP_RIGHT
);
242 r_Common_DrawText(IntToStr(MAX(0, p
.armor
)), x
+ 174, y
+ 84, 255, 0, 0, 255, menufont
, TBasePoint
.BP_RIGHT
);
245 WEAPON_KASTET
, WEAPON_SAW
: s
:= '--';
246 else s
:= IntToStr(p
.GetAmmoByWeapon(p
.CurrWeap
));
248 r_Common_DrawText(s
, x
+ 174, y
+ 174, 255, 0, 0, 255, menufont
, TBasePoint
.BP_RIGHT
);
250 if p
.CurrWeap
<= WP_LAST
then
252 t
:= hudwp
[p
.CurrWeap
];
253 r_Common_DrawTexture(t
, x
+ 18, y
+ 160, t
.width
, t
.height
, TBasePoint
.BP_LEFTUP
);
256 if R_KEY_RED
in p
.FRulez
then
257 r_Common_DrawTexture(hudkey
[0], x
+ 76, y
+ 214, 16, 16, TBasePoint
.BP_LEFTUP
);
258 if R_KEY_GREEN
in p
.FRulez
then
259 r_Common_DrawTexture(hudkey
[1], x
+ 93, y
+ 214, 16, 16, TBasePoint
.BP_LEFTUP
);
260 if R_KEY_BLUE
in p
.FRulez
then
261 r_Common_DrawTexture(hudkey
[2], x
+ 110, y
+ 214, 16, 16, TBasePoint
.BP_LEFTUP
);
263 if p
.JetFuel
> 0 then
265 r_Common_DrawTexture(hudair
, x
, y
+ 116, hudair
.width
, hudair
.height
, TBasePoint
.BP_LEFTUP
);
267 r_Draw_FillRect(x
+ 14, y
+ 116 + 4, x
+ 14 + 168 * p
.air
div AIR_MAX
, y
+ 116 + 4 + 4, 0, 0, 196, 255);
268 r_Common_DrawTexture(hudjet
, x
, y
+ 126, hudjet
.width
, hudjet
.height
, TBasePoint
.BP_LEFTUP
);
269 r_Draw_FillRect(x
+ 14, y
+ 126 + 4, x
+ 14 + 168 * p
.JetFuel
div JET_MAX
, y
+ 126 + 4 + 4, 208, 0, 0, 255);
273 r_Common_DrawTexture(hudair
, x
, y
+ 124, hudair
.width
, hudair
.height
, TBasePoint
.BP_LEFTUP
);
275 r_Draw_FillRect(x
+ 14, y
+ 124 + 4, x
+ 14 + 168 * p
.air
div AIR_MAX
, y
+ 124 + 4 + 4, 0, 0, 196, 255);
279 procedure r_Render_DrawHUDArea (x
, y
, w
, h
: Integer; p
: TPlayer
);
282 r_Common_DrawTexture(hudbg
, x
, y
, w
, h
, TBasePoint
.BP_LEFTUP
);
286 r_Render_DrawHUD(x
+ w
- 196 + 2, y
, p
);
289 r_Common_DrawText(_lc
[I_PLAYER_SPECT
], x
+ 4, y
+ 242, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
290 r_Common_DrawText(_lc
[I_PLAYER_SPECT2
], x
+ 4, y
+ 258, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
291 r_Common_DrawText(_lc
[I_PLAYER_SPECT1
], x
+ 4, y
+ 274, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
293 r_Common_DrawText(_lc
[I_PLAYER_SPECT1S
], x
+ 4, y
+ 290, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
297 if gShowPing
and g_Game_IsClient
then
299 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
300 r_Common_DrawText(s
, x
+ 4, y
+ 242, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
304 procedure r_Render_DrawStatsView (x
, y
, w
, h
: Integer; p
: TPlayer
);
305 var fw
, i
, maxFrags
, top
, totalPlayers
: Integer; sign
: Char; stat
: TPlayerStatArray
; f
: TGLTexture
;
309 if gShowScore
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
313 if gGameSettings
.GameMode
= GM_CTF
then
315 case gFlags
[FLAG_RED
].State
of
316 FLAG_STATE_CAPTURED
: f
:= hudrflags
;
317 FLAG_STATE_DROPPED
: f
:= hudrflagd
;
318 otherwise f
:= hudrflag
;
322 fw
:= f
.width
+ 8; (* + space *)
323 r_Common_DrawTexture(f
, x
+ w
- 16, y
+ 240 - 72 - 4, f
.width
, f
.height
, TBasePoint
.BP_RIGHTUP
);
326 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
);
328 (* BLUE TEAM GOALS *)
330 if gGameSettings
.GameMode
= GM_CTF
then
332 case gFlags
[FLAG_BLUE
].State
of
333 FLAG_STATE_CAPTURED
: f
:= hudbflags
;
334 FLAG_STATE_DROPPED
: f
:= hudbflagd
;
335 otherwise f
:= hudbflag
;
339 fw
:= f
.width
+ 8; (* + space *)
340 r_Common_DrawTexture(f
, x
+ w
- 16, y
+ 240 - 32 - 4, f
.width
, f
.height
, TBasePoint
.BP_RIGHTUP
);
343 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
);
346 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
350 r_Common_DrawText(IntToStr(p
.Frags
), x
+ w
- 16, y
, 255, 0, 0, 255, menufont
, TBasePoint
.BP_RIGHTUP
);
355 stat
:= g_Player_GetStats();
358 totalPlayers
:= Length(stat
);
359 for i
:= 0 to High(stat
) do
361 if stat
[i
].Name
<> p
.Name
then
363 maxFrags
:= MAX(maxFrags
, stat
[i
].Frags
);
364 if stat
[i
].Frags
> p
.Frags
then
369 if p
.Frags
>= maxFrags
then sign
:= '+' else sign
:= '-';
370 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
);
373 if gLMSRespawn
> LMS_RESPAWN_NONE
then
375 r_Common_DrawText(_lc
[I_GAME_WARMUP
], x
+ w
- 16 - 64, y
+ h
, 0, 255, 0, 255, menufont
, TBasePoint
.BP_RIGHTDOWN
);
376 r_Common_DrawText(': ' + IntToStr((gLMSRespawnTime
- gTime
) div 1000), x
+ w
- 16 - 64, y
+ h
, 0, 255, 0, 255, menufont
, TBasePoint
.BP_LEFTDOWN
);
378 else if gShowLives
and (gGameSettings
.MaxLives
> 0) then
380 r_Common_DrawText(IntToStr(p
.Lives
), x
+ w
- 16, y
+ h
, 0, 255, 0, 255, menufont
, TBasePoint
.BP_RIGHTDOWN
);
385 procedure r_Render_DrawView (x
, y
, w
, h
: Integer; p
: TPlayer
);
386 var l
, t
, r
, b
, xx
, yy
: Integer;
388 r_Draw_GetRect(l
, t
, r
, b
);
389 r_Draw_SetRect(x
, y
, x
+ w
, y
+ h
);
391 r_Common_GetCameraPos(p
, true, xx
, yy
);
394 r_Map_Draw(x
, y
, w
, h
, xx
, yy
, p
);
395 r_Render_DrawStatsView(x
, y
, w
, h
, p
);
396 if p
.Spectator
and p
.NoRespawn
then
397 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
);
401 r_Map_Draw(x
, y
, w
, h
, xx
, yy
, nil);
404 r_Draw_SetRect(l
, t
, r
, b
);
407 procedure r_Render_DrawMapView (x
, y
, w
, h
, camx
, camy
: Integer);
408 var l
, t
, r
, b
: Integer;
410 r_Draw_GetRect(l
, t
, r
, b
);
411 r_Draw_SetRect(x
, y
, x
+ w
, y
+ h
);
412 r_Map_Draw(x
, y
, w
, h
, camx
, camy
, nil);
413 r_Draw_SetRect(l
, t
, r
, b
);
416 procedure r_Render_DrawPlayerView (x
, y
, w
, h
: Integer; p
: TPlayer
);
417 var l
, t
, r
, b
: Integer;
419 r_Draw_GetRect(l
, t
, r
, b
);
420 r_Draw_SetRect(x
, y
, x
+ w
, y
+ h
);
421 r_Render_DrawView(x
, y
, w
- 196, h
, p
);
422 r_Render_DrawHUDArea(x
+ w
- 196, y
, 196, h
, p
);
423 r_Draw_SetRect(l
, t
, r
, b
);
426 procedure r_Render_DrawServerList (var SL
: TNetServerList
; var ST
: TNetServerTable
);
427 var ip
: AnsiString; ww
, hh
, cw
, ch
, mw
, mh
, motdh
, scrx
, scry
, i
, mx
, y
: Integer; msg
: SSArray
; Srv
: TNetServer
;
429 scrx
:= gScreenWidth
div 2;
430 scry
:= gScreenHeight
div 2;
432 r_Draw_GetTextSize(_lc
[I_NET_SLIST
], menufont
, ww
, hh
);
433 r_Common_DrawText(_lc
[I_NET_SLIST
], gScreenWidth
div 2, 16, 255, 255, 255, 255, menufont
, TBasePoint
.BP_UP
);
435 r_Draw_GetTextSize('W', stdfont
, cw
, ch
);
436 motdh
:= gScreenHeight
- 49 - ch
* b_Text_LineCount(slMOTD
);
438 r_Draw_FillRect(16, 64, gScreenWidth
- 16, motdh
, 64, 64, 64, 145);
439 r_Draw_Rect(16, 64, gScreenWidth
- 16, motdh
, 255, 127, 0, 255);
441 r_Common_DrawText(_lc
[I_NET_SLIST_HELP
], gScreenWidth
div 2, gScreenHeight
- 8, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_DOWN
);
445 r_Draw_FillRect(16, motdh
, gScreenWidth
- 16, gScreenHeight
- 44, 64, 64, 64, 110);
446 r_Draw_Rect(16, motdh
, gScreenWidth
- 16, gScreenHeight
- 44, 255, 127, 0, 255);
447 r_Common_DrawFormatText(slMOTD
, 20, motdh
+ 3, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
450 if not slReadUrgent
and (slUrgent
<> '') then
452 r_Draw_FillRect(17, 65, gScreenWidth
- 17, motdh
- 1, 64, 64, 64, 127);
453 r_Draw_FillRect(scrx
- 256, scry
- 60, scrx
+ 256, scry
+ 60, 64, 64, 64, 127);
454 r_Draw_Rect(scrx
- 256, scry
- 60, scrx
+ 256, scry
+ 60, 255, 127, 0, 255);
455 r_Draw_FillRect(scrx
- 256, scry
- 40, scrx
+ 256, scry
- 40, 255, 127, 0, 255);
456 r_Common_DrawText(_lc
[I_NET_SLIST_URGENT
], scrx
, scry
- 58, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
457 r_Common_DrawFormatText(slUrgent
, scrx
- 253, scry
- 38, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
458 r_Common_DrawText(_lc
[I_NET_SLIST_URGENT_CONT
], scrx
, scry
+ 41, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
459 r_Draw_FillRect(scrx
- 256, scry
+ 40, scrx
+ 256, scry
+ 40, 255, 127, 0, 255);
461 else if SL
= nil then
463 r_Draw_FillRect(17, 65, gScreenWidth
- 17, motdh
- 1, 64, 64, 64, 127);
464 r_Draw_Rect(scrx
- 192, scry
- 10, scrx
+ 192, scry
+ 11, 255, 127, 0, 255);
465 r_Common_DrawText(slWaitStr
, scrx
, scry
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_CENTER
);
470 if slSelection
< Length(ST
) then
472 sy
:= y
+ 42 * slSelection
- 4;
473 Srv
:= GetServerFromTable(slSelection
, SL
, ST
);
474 ip
:= _lc
[I_NET_ADDRESS
] + ' ' + Srv
.IP
+ ':' + IntToStr(Srv
.Port
);
475 ip
:= ip
+ ' ' + _lc
[I_NET_SERVER_PASSWORD
] + ' ';
476 if Srv
.Password
then ip
:= ip
+ _lc
[I_MENU_YES
] else ip
:= ip
+_lc
[I_MENU_NO
];
479 mw
:= gScreenWidth
- 188;
482 r_Draw_FillRect(16 + 1, sy
, gScreenWidth
- 16 - 1, sy
+ 40, 64, 64, 64, 255);
483 r_Draw_FillRect(16 + 1, sy
, gScreenWidth
- 16 - 1, sy
, 205, 205, 205, 255);
484 r_Draw_FillRect(16 + 1, sy
+ 41, gScreenWidth
- 16 - 1, sy
+ 41, 255, 255, 255, 255);
486 r_Draw_FillRect(16, 85, gScreenWidth
- 16, 85, 255, 127, 0, 255);
487 r_Draw_FillRect(16, motdh
- 20, gScreenWidth
- 16, motdh
- 20, 255, 127, 0, 255);
489 r_Draw_FillRect(mx
- 70, 64, mx
- 70, motdh
, 255, 127, 0, 255);
490 r_Draw_FillRect(mx
, 64, mx
, motdh
- 20, 255, 127, 0, 255);
491 r_Draw_FillRect(mx
+ 52, 64, mx
+ 52, motdh
- 20, 255, 127, 0, 255);
492 r_Draw_FillRect(mx
+ 104, 64, mx
+ 104, motdh
- 20, 255, 127, 0, 255);
494 r_Common_DrawText('NAME/MAP', 18, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
495 r_Common_DrawText('PING', mx
- 68, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
496 r_Common_DrawText('MODE', mx
+ 2, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
497 r_Common_DrawText('PLRS', mx
+ 54, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
498 r_Common_DrawText('VER', mx
+ 106, 68, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
500 for i
:= 0 to High(ST
) do
502 Srv
:= GetServerFromTable(i
, SL
, ST
);
503 r_Common_DrawText(Srv
.Name
, 18, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
504 r_Common_DrawText(Srv
.Map
, 18, y
+ 16, 210, 210, 210, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
507 r_Common_DrawText('<1' + _lc
[I_NET_SLIST_PING_MS
], mx
- 68, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
)
508 else if (Srv
.Ping
>= 0) and (Srv
.Ping
<= 999) then
509 r_Common_DrawText(IntToStr(Srv
.Ping
) + _lc
[I_NET_SLIST_PING_MS
], mx
- 68, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
)
511 r_Common_DrawText(_lc
[I_NET_SLIST_NO_ACCESS
], mx
- 68, y
, 255, 0, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
512 if Length(ST
[I
].Indices
) > 1 then
513 r_Common_DrawText('<' + IntToStr(Length(ST
[I
].Indices
)) + '>', mx
- 68, y
+ 16, 210, 210, 210, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
515 r_Common_DrawText(g_Game_ModeToText(Srv
.GameMode
), mx
+ 2, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
517 r_Common_DrawText(IntToStr(Srv
.Players
) + '/' + IntToStr(Srv
.MaxPlayers
), mx
+ 54, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
518 r_Common_DrawText(IntToStr(Srv
.LocalPl
) + '+' + IntToStr(Srv
.Bots
), mx
+ 54, y
+ 16, 210, 210, 210, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
520 r_Common_DrawText(IntToStr(Srv
.Protocol
), mx
+ 106, y
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
525 r_Common_DrawText(ip
, 20, motdh
- 20 + 3, 205, 205, 205, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
526 r_Common_DrawText(IntToStr(Length(ST
)) + _lc
[I_NET_SLIST_SERVERS
], gScreenWidth
- 48, motdh
- 20 + 3, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_RIGHTUP
);
530 procedure r_Render_DrawStatsColumns (constref cs
: TEndCustomGameStat
; x
, y
, w
: Integer; endview
: Boolean);
531 var i
, cw
, ch
, yy
, team
, players
, w1
, w2
, w3
, w4
, tw
: Integer; r
, g
, b
, rr
, gg
, bb
: Byte; s
: AnsiString;
533 r_Draw_GetTextSize('W', stdfont
, cw
, ch
);
534 w4
:= cw
* 6; (* deaths width *)
535 w3
:= cw
* 8; (* frags width *)
536 w2
:= cw
* 12; (* ping/loss width *)
537 w1
:= w
- w2
- w3
- w4
; (* name width *)
538 tw
:= w1
- cw
* 2 - w2
; (* team goals *)
539 if cs
.PlayerStat
= nil then players
:= 0 else players
:= Length(cs
.PlayerStat
);
541 if cs
.GameMode
in [GM_TDM
, GM_CTF
] then
543 for team
:= TEAM_RED
to TEAM_BLUE
do
548 s
:= _lc
[I_GAME_TEAM_RED
];
549 r
:= 255; g
:= 0; b
:= 0;
553 s
:= _lc
[I_GAME_TEAM_BLUE
];
554 r
:= 0; g
:= 0; b
:= 255;
557 r_Common_DrawText(s
, x
, yy
, r
, g
, b
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
558 r_Common_DrawText(IntToStr(cs
.TeamStat
[team
].Score
), x
+ tw
, yy
, r
, g
, b
, 255, stdfont
, TBasePoint
.BP_UP
);
559 if endview
= false then
560 r_Common_DrawText(_lc
[I_GAME_PING
], x
+ w1
, yy
, r
, g
, b
, 255, stdfont
, TBasePoint
.BP_UP
);
561 r_Common_DrawText(_lc
[I_GAME_FRAGS
], x
+ w1
+ w2
, yy
, r
, g
, b
, 255, stdfont
, TBasePoint
.BP_UP
);
562 r_Common_DrawText(_lc
[I_GAME_DEATHS
], x
+ w1
+ w2
+ w3
, yy
, r
, g
, b
, 255, stdfont
, TBasePoint
.BP_UP
);
566 r_Draw_FillRect(x
, yy
, x
+ w
- 1, yy
, r
, g
, b
, 255);
569 for i
:= 0 to players
- 1 do
571 if cs
.PlayerStat
[i
].Team
= team
then
573 rr
:= r
; gg
:= g
; bb
:= b
;
574 if cs
.PlayerStat
[i
].Spectator
then
576 rr
:= r
div 2; gg
:= g
div 2; bb
:= b
div 2;
580 if gShowPIDs
then s
:= Format('[%5d] %s', [cs
.PlayerStat
[i
].UID
, cs
.PlayerStat
[i
].Name
]) else s
:= cs
.PlayerStat
[i
].Name
;
581 if (gPlayers
[cs
.PlayerStat
[i
].Num
] <> nil) and (gPlayers
[cs
.PlayerStat
[i
].Num
].FReady
) then s
:= s
+ ' *';
582 r_Common_DrawText(s
, x
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
583 if endview
= false then
586 s
:= Format(_lc
[I_GAME_PING_MS
], [cs
.PlayerStat
[i
].Ping
, cs
.PlayerStat
[i
].Loss
]);
587 r_Common_DrawText(s
, x
+ w1
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_UP
);
590 s
:= IntToStr(cs
.PlayerStat
[i
].Frags
);
591 r_Common_DrawText(s
, x
+ w1
+ w2
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_UP
);
593 s
:= IntToStr(cs
.PlayerStat
[i
].Deaths
);
594 r_Common_DrawText(s
, x
+ w1
+ w2
+ w3
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_UP
);
602 else if cs
.GameMode
in [GM_DM
, GM_COOP
] then
604 r_Common_DrawText(_lc
[I_GAME_PLAYER_NAME
], x
, yy
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
605 if endview
= false then
606 r_Common_DrawText(_lc
[I_GAME_PING
], x
+ w1
, yy
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_UP
);
607 r_Common_DrawText(_lc
[I_GAME_FRAGS
], x
+ w1
+ w2
, yy
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_UP
);
608 r_Common_DrawText(_lc
[I_GAME_DEATHS
], x
+ w1
+ w2
+ w3
, yy
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_UP
);
609 INC(yy
, ch
+ ch
div 2);
610 for i
:= 0 to players
- 1 do
612 // rr := 255; gg := 127; bb := 0;
613 rr
:= 255; gg
:= 255; bb
:= 255;
614 if cs
.PlayerStat
[i
].Spectator
then
616 rr
:= rr
div 2; gg
:= gg
div 2; bb
:= bb
div 2;
620 r_Draw_Rect(x
, yy
, x
+ 16 - 1, yy
+ 16 - 1, 192, 192, 192, 255);
621 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);
623 if gShowPIDs
then s
:= Format('[%5d] %s', [cs
.PlayerStat
[i
].UID
, cs
.PlayerStat
[i
].Name
]) else s
:= cs
.PlayerStat
[i
].Name
;
624 if (gPlayers
[cs
.PlayerStat
[i
].Num
] <> nil) and (gPlayers
[cs
.PlayerStat
[i
].Num
].FReady
) then s
:= s
+ ' *';
625 r_Common_DrawText(s
, x
+ 16 + 8, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
626 if endview
= false then
629 s
:= Format(_lc
[I_GAME_PING_MS
], [cs
.PlayerStat
[i
].Ping
, cs
.PlayerStat
[i
].Loss
]);
630 r_Common_DrawText(s
, x
+ w1
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_UP
);
633 s
:= IntToStr(cs
.PlayerStat
[i
].Frags
);
634 r_Common_DrawText(s
, x
+ w1
+ w2
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_UP
);
636 s
:= IntToStr(cs
.PlayerStat
[i
].Deaths
);
637 r_Common_DrawText(s
, x
+ w1
+ w2
+ w3
, yy
, rr
, gg
, bb
, 255, stdfont
, TBasePoint
.BP_UP
);
639 INC(yy
, ch
+ ch
div 2);
644 procedure r_Render_DrawStatsWindow (x
, y
, w
, h
: Integer; cs
: TEndCustomGameStat
; endview
: Boolean);
645 var xoff
, yoff
, cw
, ch
: Integer; s
: AnsiString;
647 xoff
:= 0; yoff
:= 8;
648 r_Draw_GetTextSize('W', stdfont
, cw
, ch
);
649 r_Draw_FillRect(x
, y
, x
+ w
- 1, y
+ h
- 1, 64, 64, 64, 224);
650 r_Draw_Rect(x
, y
, x
+ w
- 1, y
+ h
- 1, 255, 127, 0, 255);
654 if endview
= false then
657 NET_SERVER
: s
:= _lc
[I_NET_SERVER
];
658 NET_CLIENT
: s
:= NetClientIP
+ ':' + IntToStr(NetClientPort
);
661 r_Common_DrawText(s
, x
+ 16, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
665 GM_DM
: if gGameSettings
.MaxLives
= 0 then s
:= _lc
[I_GAME_DM
] else s
:= _lc
[I_GAME_LMS
];
666 GM_TDM
: if gGameSettings
.MaxLives
= 0 then s
:= _lc
[I_GAME_TDM
] else s
:= _lc
[I_GAME_TLMS
];
667 GM_CTF
: s
:= _lc
[I_GAME_CTF
];
668 GM_COOP
: if gGameSettings
.MaxLives
= 0 then s
:= _lc
[I_GAME_COOP
] else s
:= _lc
[I_GAME_SURV
];
669 otherwise s
:= 'GAME MODE ' + IntToStr(gGameSettings
.GameMode
);
671 r_Common_DrawText(s
, x
+ w
div 2, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
673 if endview
= false then
675 s
:= r_Common_TimeToStr(cs
.GameTime
);
676 r_Common_DrawText(s
, x
+ w
- 16, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_RIGHTUP
);
679 INC(yoff
, ch
+ ch
div 2);
684 if cs
.MapName
<> '' then
685 s
:= s
+ ' - ' + cs
.MapName
;
687 if endview
= false then
689 r_Common_DrawText(s
, x
+ w
div 2, y
+ yoff
, 200, 200, 200, 255, stdfont
, TBasePoint
.BP_UP
);
690 INC(yoff
, ch
+ ch
div 2);
692 GM_DM
, GM_TDM
: s
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
693 GM_CTF
: s
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.ScoreLimit
]);
694 GM_COOP
: s
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
697 r_Common_DrawText(s
, x
+ 16, y
+ yoff
, 200, 200, 200, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
699 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]);
700 GM_COOP
: s
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
703 r_Common_DrawText(s
, x
+ w
- 16, y
+ yoff
, 200, 200, 200, 255, stdfont
, TBasePoint
.BP_RIGHTUP
);
708 xoff
:= MAX(Length(_lc
[I_MENU_MAP
]) + 1, Length(_lc
[I_GAME_GAME_TIME
]) + 1) * cw
;
709 r_Common_DrawText(_lc
[I_MENU_MAP
], x
+ 16, y
+ yoff
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
710 r_Common_DrawText(s
, x
+ 16 + xoff
, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
712 r_Common_DrawText(_lc
[I_GAME_GAME_TIME
], x
+ 16, y
+ yoff
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
713 r_Common_DrawText(r_Common_TimeToStr(cs
.GameTime
), x
+ 16 + xoff
, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
721 if endview
and (cs
.GameMode
= GM_COOP
) then
723 xoff
:= MAX(Length(_lc
[I_GAME_MONSTERS
]) + 1, Length(_lc
[I_GAME_SECRETS
]) + 1) * cw
;
724 r_Common_DrawText(_lc
[I_GAME_MONSTERS
], x
+ 16, y
+ yoff
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
725 r_Common_DrawText(IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), x
+ 16 + xoff
, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
727 r_Common_DrawText(_lc
[I_GAME_SECRETS
], x
+ 16, y
+ yoff
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
728 r_Common_DrawText(IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), x
+ 16 + xoff
, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
735 if endview
and (cs
.GameMode
= GM_COOP
) and gLastMap
then
737 xoff
:= MAX(Length(_lc
[I_GAME_MONSTERS_TOTAL
]) + 1, Length(_lc
[I_GAME_SECRETS_TOTAL
]) + 1) * cw
;
738 r_Common_DrawText(_lc
[I_GAME_MONSTERS_TOTAL
], x
+ 16, y
+ yoff
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
739 r_Common_DrawText(IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), x
+ 16 + xoff
, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
741 r_Common_DrawText(_lc
[I_GAME_SECRETS_TOTAL
], x
+ 16, y
+ yoff
, 255, 127, 0, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
742 r_Common_DrawText(IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), x
+ 16 + xoff
, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
749 if endview
and (cs
.GameMode
in [GM_TDM
, GM_CTF
]) then
751 if cs
.TeamStat
[TEAM_RED
].Score
> cs
.TeamStat
[TEAM_BLUE
].Score
then s
:= _lc
[I_GAME_WIN_RED
]
752 else if cs
.TeamStat
[TEAM_BLUE
].Score
> cs
.TeamStat
[TEAM_RED
].Score
then s
:= _lc
[I_GAME_WIN_BLUE
]
753 else s
:= _lc
[I_GAME_WIN_DRAW
];
754 r_Common_DrawText(s
, x
+ w
div 2, y
+ yoff
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
761 r_Render_DrawStatsColumns(cs
, x
+ 16, y
+ yoff
, w
- 16 - 16, endview
);
764 function r_Render_StatsHeight (players
: Integer): Integer;
767 ASSERT(players
>= 0);
768 r_Draw_GetTextSize('W', stdfont
, cw
, ch
);
769 case gGameSettings
.GameMode
of
770 GM_TDM
, GM_CTF
: result
:= 32 + ch
* (11 + players
);
771 otherwise result
:= 40 + ch
* 5 + (ch
+ 8) * players
;
775 procedure r_Render_DrawStats
;
776 var x
, y
, w
, h
, players
: Integer; cs
: TEndCustomGameStat
;
778 cs
.PlayerStat
:= g_Player_GetStats();
779 SortGameStat(cs
.PlayerStat
);
780 cs
.TeamStat
:= gTeamStat
;
781 cs
.GameTime
:= gTime
;
782 cs
.GameMode
:= gGameSettings
.GameMode
;
783 cs
.Map
:= g_ExtractWadNameNoPath(gMapInfo
.Map
) + ':' + g_ExtractFileName(gMapInfo
.Map
);
784 cs
.MapName
:= gMapInfo
.Name
;
785 if cs
.PlayerStat
= nil then players
:= 0 else players
:= Length(cs
.PlayerStat
);
786 w
:= gScreenWidth
- (gScreenWidth
div 5);
787 h
:= r_Render_StatsHeight(players
);
788 x
:= (gScreenWidth
div 2) - (w
div 2);
789 y
:= (gScreenHeight
div 2) - (h
div 2);
790 r_Render_DrawStatsWindow(x
, y
, w
, h
, cs
, false);
793 procedure r_Render_DrawCustomStats
;
794 var cw
, ch
, s
: AnsiString;
798 r_Common_DrawText(_lc
[I_MENU_INTER_NOTICE_TAB
], gScreenWidth
div 2, 8, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
802 case gGameSettings
.GameMode
of
803 GM_COOP
: if gMissionFailed
then s
:= _lc
[I_MENU_INTER_MISSION_FAIL
] else s
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
804 otherwise s
:= _lc
[I_MENU_INTER_ROUND_OVER
];
806 r_Common_DrawText(s
, gScreenWidth
div 2, 16, 255, 255, 255, 255, menufont
, TBasePoint
.BP_UP
);
808 if gChatShow
= false then
810 if g_Game_IsClient
then s
:= _lc
[I_MENU_INTER_NOTICE_MAP
] else s
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
811 r_Common_DrawText(s
, gScreenWidth
div 2, gScreenHeight
- 4, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_DOWN
);
814 s
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
815 r_Common_DrawText(s
, gScreenWidth
div 2, gScreenHeight
- 16 - 4, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_DOWN
);
819 r_Render_DrawStatsWindow(32, 64, gScreenWidth
- 32 * 2, gScreenHeight
- 64 * 2, CustomStat
, true);
823 procedure r_Render_DrawValueOf (a
, b
, x
, y
: Integer; f
: TGLFont
);
824 var wa
, wb
, ch
: Integer; sa
, sb
: AnsiString;
828 r_Draw_GetTextSize(sa
, f
, wa
, ch
);
829 r_Draw_GetTextSize(sa
+ ' / ', f
, wb
, ch
);
830 r_Common_DrawText(sa
, x
, y
, 255, 0, 0, 255, f
, TBasePoint
.BP_LEFTUP
);
831 r_Common_DrawText(' / ', x
+ wa
, y
, 255, 255, 255, 255, f
, TBasePoint
.BP_LEFTUP
);
832 r_Common_DrawText(sb
, x
+ wb
, y
, 255, 0, 0, 255, f
, TBasePoint
.BP_LEFTUP
);
835 procedure r_Render_DrawSinglStatsPlayer (player
, x
, y
, w1
: Integer);
836 var time
, kpm
: Single;
838 r_Common_DrawText(_lc
[I_MENU_INTER_KILLS
], x
, y
, 255, 255, 255, 255, menufont
, TBasePoint
.BP_LEFTUP
);
839 r_Render_DrawValueOf(SingleStat
.PlayerStat
[player
].Kills
, gTotalMonsters
, x
+ w1
, y
, MenuFont
);
840 r_Common_DrawText(_lc
[I_MENU_INTER_KPM
], x
, y
+ 32, 255, 255, 255, 255, menufont
, TBasePoint
.BP_LEFTUP
);
841 time
:= SingleStat
.GameTime
/ 1000;
842 kpm
:= SingleStat
.PlayerStat
[player
].Kills
;
843 if time
> 0 then kpm
:= kpm
/ time
* 60;
844 r_Common_DrawText(Format('%.1f', [kpm
]), x
+ w1
, y
+ 32, 255, 0, 0, 255, menufont
, TBasePoint
.BP_LEFTUP
);
845 r_Common_DrawText(_lc
[I_MENU_INTER_SECRETS
], x
, y
+ 64, 255, 255, 255, 255, menufont
, TBasePoint
.BP_LEFTUP
);
846 r_Render_DrawValueOf(SingleStat
.PlayerStat
[player
].Secrets
, SingleStat
.TotalSecrets
, x
+ w1
, y
+ 64, MenuFont
);
849 procedure r_Render_DrawSingleStats
;
850 var xx
, wa
, wb
, ww
, ch
: Integer; s
: AnsiString;
852 r_Common_DrawText(_lc
[I_MENU_INTER_LEVEL_COMPLETE
], gScreenWidth
div 2, 32, 255, 255, 255, 255, menufont
, TBasePoint
.BP_UP
);
854 r_Draw_GetTextSize(_lc
[I_MENU_INTER_KPM
] + ' ', menufont
, wa
, ch
);
855 r_Draw_GetTextSize(' 9999.9', menufont
, wb
, ch
);
857 xx
:= gScreenWidth
div 2 - ww
div 2;
859 s
:= r_Common_TimeToStr(SingleStat
.GameTime
);
860 r_Common_DrawText(_lc
[I_MENU_INTER_TIME
], xx
, 80, 255, 255, 255, 255, menufont
, TBasePoint
.BP_LEFTUP
);
861 r_Common_DrawText(s
, xx
+ wa
, 80, 255, 0, 0, 255, menufont
, TBasePoint
.BP_LEFTUP
);
863 if SingleStat
.TwoPlayers
then
865 r_Common_DrawText(_lc
[I_MENU_PLAYER_1
], gScreenWidth
div 2, 128, 255, 255, 255, 255, menufont
, TBasePoint
.BP_UP
);
866 r_Render_DrawSinglStatsPlayer(0, xx
, 176, wa
);
867 r_Common_DrawText(_lc
[I_MENU_PLAYER_2
], gScreenWidth
div 2, 288, 255, 255, 255, 255, menufont
, TBasePoint
.BP_UP
);
868 r_Render_DrawSinglStatsPlayer(1, xx
, 336, wa
);
872 r_Render_DrawSinglStatsPlayer(0, xx
, 128, wa
);
876 procedure r_Render_DrawSpectHud
;
877 var xoff
: Integer; s
: AnsiString;
879 procedure AddText (s1
, s2
: AnsiString);
880 var w1
, w2
, ww
, ch
: Integer;
882 r_Draw_GetTextSize(s1
, stdfont
, w1
, ch
);
883 r_Draw_GetTextSize(s2
, stdfont
, w2
, ch
);
885 r_Common_DrawText(s1
, xoff
+ ww
div 2, gScreenHeight
- ch
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_DOWN
);
886 r_Common_DrawText(s2
, xoff
+ ww
div 2, gScreenHeight
- ch
, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_UP
);
887 xoff
:= xoff
+ ww
+ 16;
893 SPECT_STATS
: s
:= 'MODE: Stats';
894 SPECT_MAPVIEW
: s
:= 'MODE: Observe Map';
895 SPECT_PLAYERS
: s
:= 'MODE: Watch Players';
896 otherwise s
:= 'MODE: ' + IntToStr(gSpectMode
);
898 AddText(s
, '< jump >');
899 if gSpectMode
= SPECT_STATS
then
900 AddText('Autoview', '< fire >');
901 if gSpectMode
= SPECT_MAPVIEW
then
902 AddText('[-] Step ' + IntToStr(gSpectStep
) + ' [+]', '<prev weap> <next weap>');
903 if gSpectMode
= SPECT_PLAYERS
then
905 AddText('Player 1', '<left/right>');
906 if gSpectViewTwo
then
907 AddText('Player 2', '<prev w/next w>');
908 AddText('2x View', '<up/down>');
912 function GetActivePlayer_ByID (id
: Integer): TPlayer
;
913 var i
, len
: Integer; p
: TPlayer
;
916 if (id
>= 0) and (gPlayers
<> nil) then
918 i
:= 0; len
:= Length(gPlayers
);
919 while (i
< len
) and ((IsActivePlayer(gPlayers
[i
]) = false) or (gPlayers
[i
].UID
<> id
)) do INC(i
);
920 if i
< len
then p
:= gPlayers
[i
];
925 procedure r_Render_DrawMinimap (x
, y
: Integer; alpha
: Byte);
928 function IsMinimapPanel (const p
: TPanel
): Boolean;
930 result
:= (p
<> nil) and p
.Enabled
;
934 PANEL_WALL
, PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
935 PANEL_STEP
, PANEL_OPENDOOR
, PANEL_CLOSEDOOR
,
936 PANEL_LIFTUP
, PANEL_LIFTDOWN
, PANEL_LIFTLEFT
, PANEL_LIFTRIGHT
:
944 procedure DrawObject (xx
, yy
, ww
, hh
: Integer; r
, g
, b
: Byte);
945 var x0
, y0
, x1
, y1
: Integer;
947 x0
:= x
+ xx
div scale
;
948 y0
:= y
+ yy
div scale
;
949 x1
:= x
+ (xx
+ ww
- 1) div scale
;
950 y1
:= y
+ (yy
+ hh
- 1) div scale
;
951 r_Draw_FillRect(x0
, y0
, x1
, y1
, r
, g
, b
, alpha
);
954 procedure DrawPanels (const a
: TPanelArray
);
955 var i
: Integer; p
: TPanel
; c
: TRGB
;
959 for i
:= 0 to HIGH(a
) do
962 if IsMinimapPanel(p
) then
965 PANEL_WALL
: c
:= _RGB(208, 208, 208);
966 PANEL_OPENDOOR
: c
:= _RGB(160, 160, 160);
967 PANEL_CLOSEDOOR
: c
:= _RGB(160, 160, 160);
968 PANEL_STEP
: c
:= _RGB(128, 128, 128);
969 PANEL_LIFTUP
, PANEL_LIFTDOWN
, PANEL_LIFTLEFT
, PANEL_LIFTRIGHT
:
971 LIFTTYPE_UP
: c
:= _RGB(116, 72, 36);
972 LIFTTYPE_DOWN
: c
:= _RGB(116, 124, 96);
973 LIFTTYPE_LEFT
: c
:= _RGB(116, 200, 80);
974 LIFTTYPE_RIGHT
: c
:= _RGB(116, 252, 140);
975 otherwise c
:= _RGB(255, 0, 0);
977 PANEL_WATER
: c
:= _RGB(0, 0, 192);
978 PANEL_ACID1
: c
:= _RGB(0, 176, 0);
979 PANEL_ACID2
: c
:= _RGB(176, 0, 0);
980 otherwise c
:= _RGB(255, 0, 0);
982 DrawObject(p
.x
, p
.y
, p
.width
, p
.height
, c
.r
, c
.g
, c
.b
);
988 procedure DrawPlayers
;
989 var i
: Integer; p
: TPlayer
; c
: TRGB
;
991 if gPlayers
<> nil then
993 for i
:= 0 to HIGH(gPlayers
) do
999 TEAM_RED
: c
:= _RGB(255, 0, 0);
1000 TEAM_BLUE
: c
:= _RGB(0, 0, 255);
1001 otherwise c
:= _RGB(255, 128, 0);
1003 DrawObject(p
.obj
.x
, p
.obj
.y
, p
.obj
.rect
.width
, p
.obj
.rect
.height
, c
.r
, c
.g
, c
.b
);
1009 function DrawMonster (m
: TMonster
): Boolean;
1011 result
:= false; // don't stop
1013 DrawObject(m
.obj
.x
, m
.obj
.y
, m
.obj
.rect
.width
, m
.obj
.rect
.height
, 255, 255, 0);
1017 r_Draw_FillRect(x
, y
, (x
+ gMapInfo
.Width
- 1) div scale
, (y
+ gMapInfo
.Height
- 1) div scale
, 0, 0, 0, alpha
);
1024 g_Mons_ForEach(DrawMonster
);
1028 procedure r_Render_Draw
;
1029 var p1
, p2
: TPlayer
; time
: LongWord;
1031 if gExit
= EXIT_QUIT
then
1035 time
:= GetTickCount64();
1036 if time
- FPSTime
>= 1000 then
1043 r_Draw_Setup(gScreenWidth
, gScreenHeight
);
1045 glClearColor(0.0, 0.0, 0.0, 0.0);
1046 glClear(GL_COLOR_BUFFER_BIT
or GL_DEPTH_BUFFER_BIT
);
1050 if gGameOn
or (gState
= STATE_FOLD
) then
1052 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
1054 if gRevertPlayers
then
1065 else if gPlayer1
<> nil then
1069 else if gPlayer2
<> nil then
1073 if (gSpectMode
= SPECT_PLAYERS
) and (gPlayers
<> nil) then
1075 p1
:= GetActivePlayer_ByID(gSpectPID1
);
1077 p1
:= GetActivePlayer_ByID(GetActivePlayerID_Next());
1078 if gSpectViewTwo
then
1080 p2
:= GetActivePlayer_ByID(gSpectPID2
);
1082 p2
:= GetActivePlayer_ByID(GetActivePlayerID_Next());
1087 if gGameOn
or ((gState
in [STATE_FOLD
]) and (EndingGameCounter
< 255)) then
1089 if gSpectMode
= SPECT_MAPVIEW
then
1091 r_Render_DrawMapView(0, 0, gScreenWidth
, gScreenHeight
, gSpectX
+ gScreenWidth
div 2, gSpectY
+ gScreenHeight
div 2);
1093 else if (p1
<> nil) and (p2
<> nil) then
1095 r_Render_DrawPlayerView(0, 0, gScreenWidth
, gScreenHeight
div 2 - 2, p1
);
1096 r_Render_DrawPlayerView(0, gScreenHeight
div 2 + 2, gScreenWidth
, gScreenHeight
div 2, p2
);
1098 else if p1
<> nil then
1100 r_Render_DrawPlayerView(0, 0, gScreenWidth
, gScreenHeight
, p1
);
1102 else if p2
<> nil then
1104 r_Render_DrawPlayerView(0, 0, gScreenWidth
, gScreenHeight
, p2
);
1108 r_Render_DrawMiniMap(0, 0, 160);
1110 // TODO draw holmes inspector
1112 if MessageText
<> '' then
1113 r_Common_DrawFormatText(MessageText
, (gScreenWidth
- 196) div 2, gScreenHeight
div 2, 255, menufont
, TBasePoint
.BP_CENTER
);
1115 if IsDrawStat
or (gSpectMode
= SPECT_STATS
) then
1118 if gSpectHUD
and (gChatShow
= false) and (gSpectMode
<> SPECT_NONE
) and (gSpectAuto
= false) then
1119 r_Render_DrawSpectHud
;
1122 if gPauseMain
and gGameOn
{$IFDEF ENABLE_MENU}and (g_ActiveWindow
= nil){$ENDIF} then
1124 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
1125 r_Common_DrawText(_lc
[I_MENU_PAUSE
], gScreenWidth
div 2, gScreenHeight
div 2, 255, 255, 255, 255, menufont
, TBasePoint
.BP_CENTER
);
1130 // TODO F key handle
1132 STATE_NONE
: (* do nothing *) ;
1133 STATE_MENU
: r_Common_DrawBackground(GameWad
+ ':TEXTURES/TITLE');
1136 if EndingGameCounter
> 0 then
1137 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, MIN(MAX(255 - EndingGameCounter
, 0), 255));
1141 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1142 if EndPicPath
<> '' then
1143 r_Common_DrawBackground(EndPicPath
)
1145 r_Common_DrawBackground(GameWad
+ ':TEXTURES/' + _lc
[I_TEXTURE_ENDPIC
])
1147 r_Common_DrawBackground(GameWad
+ ':TEXTURES/INTER');
1149 r_Render_DrawCustomStats
;
1151 {$IFDEF ENABLE_MENU}
1152 if g_ActiveWindow
<> nil then
1153 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
1156 STATE_INTERSINGLE
, STATE_INTERTEXT
, STATE_INTERPIC
:
1158 if EndingGameCounter
> 0 then
1160 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, MIN(MAX(255 - EndingGameCounter
, 0), 255));
1164 r_Common_DrawBackground(GameWad
+ ':TEXTURES/INTER');
1165 r_Render_DrawSingleStats
;
1166 {$IFDEF ENABLE_MENU}
1167 if g_ActiveWindow
<> nil then
1168 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
1174 if EndPicPath
<> '' then
1175 r_Common_DrawBackground(EndPicPath
)
1177 r_Common_DrawBackground(GameWad
+ ':TEXTURES/' + _lc
[I_TEXTURE_ENDPIC
]);
1178 {$IFDEF ENABLE_MENU}
1179 if g_ActiveWindow
<> nil then
1180 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
1185 r_Common_DrawBackground(GameWad
+ ':TEXTURES/TITLE');
1186 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
1187 r_Render_DrawServerList(slCurrent
, slTable
);
1192 {$IFDEF ENABLE_MENU}
1193 if g_ActiveWindow
<> nil then
1196 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
1197 r_GUI_Draw_Window(g_ActiveWindow
);
1201 r_Console_Draw(false);
1203 // TODO g_debug_Sounds
1207 r_Common_DrawText('FPS: ' + IntToStr(FPS
), 0, 0, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
1208 r_Common_DrawText('UPS: ' + IntToStr(UPS
), 0, 16, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_LEFTUP
);
1211 if gGameOn
and gShowTime
then
1213 r_Common_DrawText(r_Common_TimeToStr(gTime
), gScreenWidth
- 4, gScreenHeight
- 1, 255, 255, 255, 255, stdfont
, TBasePoint
.BP_RIGHTDOWN
);
1216 // TODO draw profilers
1218 // TODO draw holmes interface
1220 // TODO draw touch screen controls
1225 procedure r_Render_Resize (w
, h
: Integer);
1235 procedure r_Render_Apply
;
1237 {$IFDEF ENABLE_SYSTEM}
1238 if sys_SetDisplayModeGL(GetInfo()) then
1239 e_LogWriteln('resolution changed')
1241 e_LogWriteln('resolution not changed');
1242 sys_EnableVSync(gVSync
)
1246 function r_Render_WriteScreenShot (filename
: String): Boolean;
1248 // TODO write screenshot file
1252 {$IFDEF ENABLE_GIBS}
1253 function r_Render_GetGibRect (m
, id
: Integer): TRectWH
;
1255 result
:= r_Map_GetGibSize(m
, id
);
1260 procedure r_Render_QueueEffect (AnimType
, X
, Y
: Integer);
1262 r_Map_NewGFX(AnimType
, X
, Y
);
1266 {$IFDEF ENABLE_TOUCH}
1267 procedure r_Render_GetKeyRect (key
: Integer; out x
, y
, w
, h
: Integer; out founded
: Boolean);
1269 // TODO implement touchscreen
1274 {$IFDEF ENABLE_MENU}
1275 procedure r_Render_GetControlSize (ctrl
: TGUIControl
; out w
, h
: Integer);
1277 r_GUI_GetSize(ctrl
, w
, h
);
1280 procedure r_Render_GetLogoSize (out w
, h
: Integer);
1282 r_GUI_GetLogoSize(w
, h
);
1285 procedure r_Render_GetMaxFontSize (BigFont
: Boolean; out w
, h
: Integer);
1287 r_GUI_GetMaxFontSize(BigFont
, w
, h
);
1290 procedure r_Render_GetStringSize (BigFont
: Boolean; str
: String; out w
, h
: Integer);
1292 r_GUI_GetStringSize(BigFont
, str
, w
, h
);
1296 procedure r_Render_SetProcessLoadingCallback (p
: TProcedure
);
1298 r_Common_ProcessLoadingCallback
:= p
;
1301 procedure r_Render_ClearLoading
;
1303 r_Common_ClearLoading
;
1306 procedure r_Render_SetLoading (const text: String; maxval
: Integer);
1308 r_Common_SetLoading(text, maxval
);
1311 procedure r_Render_StepLoading (incval
: Integer);
1313 r_Common_StepLoading(incval
);
1316 procedure r_Render_DrawLoading (force
: Boolean);
1318 r_Common_DrawLoading(force
);