DEADSOFTWARE

gl: implement d_sounds
[d2df-sdl.git] / src / game / renders / opengl / r_render.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
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.
6 *
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.
11 *
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/>.
14 *)
15 {$INCLUDE ../../../shared/a_modes.inc}
16 unit r_render;
18 interface
20 uses
21 {$IFDEF ENABLE_MENU}
22 g_gui,
23 {$ENDIF}
24 g_base // TRectWH
25 ;
27 type
28 TProcedure = procedure;
30 (* render startup *)
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_Reset;
43 procedure r_Render_Update;
44 procedure r_Render_Draw;
46 procedure r_Render_Resize (w, h: Integer);
47 procedure r_Render_Apply;
49 procedure r_Render_RequestScreenShot;
51 {$IFDEF ENABLE_GIBS}
52 function r_Render_GetGibRect (m, id: Integer): TRectWH;
53 {$ENDIF}
55 {$IFDEF ENABLE_GFX}
56 procedure r_Render_QueueEffect (AnimType, X, Y: Integer);
57 {$ENDIF}
59 {$IFDEF ENABLE_TOUCH}
60 // touch screen button location and size
61 procedure r_Render_GetKeyRect (key: Integer; out x, y, w, h: Integer; out founded: Boolean);
62 {$ENDIF}
64 {$IFDEF ENABLE_MENU}
65 procedure r_Render_GetControlSize (ctrl: TGUIControl; out w, h: Integer);
66 procedure r_Render_GetLogoSize (out w, h: Integer);
67 procedure r_Render_GetMaxFontSize (BigFont: Boolean; out w, h: Integer);
68 procedure r_Render_GetStringSize (BigFont: Boolean; str: String; out w, h: Integer);
69 {$ENDIF}
71 procedure r_Render_SetProcessLoadingCallback (p: TProcedure);
72 procedure r_Render_ClearLoading;
73 procedure r_Render_SetLoading (const text: String; maxval: Integer);
74 procedure r_Render_StepLoading (incval: Integer);
75 procedure r_Render_DrawLoading (force: Boolean);
77 {$IFDEF ENABLE_HOLMES}
78 function pmsCurMapX (): Integer;
79 function pmsCurMapY (): Integer;
80 function r_Render_HolmesViewIsSet (): Boolean;
81 {$ENDIF}
83 implementation
85 uses
86 {$I ../../../nogl/noGLuses.inc}
87 Imaging, ImagingTypes, ImagingUtility, (* for screenshots *)
88 {$IFDEF ENABLE_MENU}
89 r_gui,
90 {$ENDIF}
91 {$IFDEF ENABLE_SYSTEM}
92 g_system,
93 {$ENDIF}
94 {$IFDEF ENABLE_TOUCH}
95 r_touch,
96 {$ENDIF}
97 {$IFDEF ENABLE_HOLMES}
98 r_holmes,
99 {$ENDIF}
100 SysUtils, Classes, Math,
101 g_basic,
102 e_sound, // DebugSound
103 e_log, e_res, utils, wadreader, mapdef,
104 g_game, g_map, g_panel, g_options, g_console, g_player, g_weapons, g_language, g_triggers, g_monsters,
105 g_net, g_netmaster,
106 r_draw, r_textures, r_fonts, r_common, r_console, r_map, r_loadscreen
109 var
110 hud, hudbg: TGLTexture;
111 hudhp: array [Boolean] of TGLTexture;
112 hudap: TGLTexture;
113 hudwp: array [0..WP_LAST] of TGLTexture;
114 hudkey: array [0..2] of TGLTexture;
115 hudair: TGLTexture;
116 hudjet: TGLTexture;
117 hudrflag, hudrflags, hudrflagd: TGLTexture;
118 hudbflag, hudbflags, hudbflagd: TGLTexture;
120 FPS, FPSCounter, FPSTime: LongWord;
121 TakeScreenShot: Boolean;
122 DebugSound: Boolean;
124 procedure r_Render_LoadTextures;
125 begin
126 r_Map_LoadTextures;
127 end;
129 procedure r_Render_FreeTextures;
130 begin
131 r_Map_FreeTextures;
132 end;
134 procedure r_Render_Load;
135 const
136 WeapName: array [0..WP_LAST] of AnsiString = ('KASTET', 'SAW', 'PISTOL', 'SHOTGUN1', 'SHOTGUN2', 'MGUN', 'RLAUNCHER', 'PGUN', 'BFG', 'SPULEMET', 'FLAMETHROWER');
137 var
138 i: Integer;
139 begin
140 r_LoadScreen_Load;
141 r_Common_Load;
142 r_Common_SetLoading('HUD Textures', 5 + (WP_LAST + 1) + 11);
143 hud := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/HUD', [TGLHints.txNoRepeat]);
144 hudbg := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/HUDBG', []);
145 hudhp[false] := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/MED2', [TGLHints.txNoRepeat]);
146 hudhp[true] := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/BMED', [TGLHints.txNoRepeat]);
147 hudap := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/ARMORHUD', [TGLHints.txNoRepeat]);
148 for i := 0 to WP_LAST do
149 hudwp[i] := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/' + WeapName[i], [TGLHints.txNoRepeat]);
150 hudkey[0] := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/KEYR', [TGLHints.txNoRepeat]);
151 hudkey[1] := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/KEYG', [TGLHints.txNoRepeat]);
152 hudkey[2] := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/KEYB', [TGLHints.txNoRepeat]);
153 hudair := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/AIRBAR', [TGLHints.txNoRepeat]);
154 hudjet := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/JETBAR', [TGLHints.txNoRepeat]);
155 hudrflag := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/FLAGHUD_R_BASE', [TGLHints.txNoRepeat]);
156 hudrflags := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/FLAGHUD_R_STOLEN', [TGLHints.txNoRepeat]);
157 hudrflagd := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/FLAGHUD_R_DROP', [TGLHints.txNoRepeat]);
158 hudbflag := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/FLAGHUD_B_BASE', [TGLHints.txNoRepeat]);
159 hudbflags := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/FLAGHUD_B_STOLEN', [TGLHints.txNoRepeat]);
160 hudbflagd := r_Common_LoadTextureFromFile(GameWAD + ':TEXTURES/FLAGHUD_B_DROP', [TGLHints.txNoRepeat]);
161 r_Console_Load;
162 r_Map_Load;
163 {$IFDEF ENABLE_MENU}
164 r_GUI_Load;
165 {$ENDIF}
166 end;
168 procedure r_Render_Free;
169 var i: Integer;
170 begin
171 {$IFDEF ENABLE_MENU}
172 r_GUI_Free;
173 {$ENDIF}
174 r_Map_Free;
175 r_Console_Free;
176 r_Common_FreeAndNil(hudbflagd);
177 r_Common_FreeAndNil(hudbflags);
178 r_Common_FreeAndNil(hudbflag);
179 r_Common_FreeAndNil(hudrflagd);
180 r_Common_FreeAndNil(hudrflags);
181 r_Common_FreeAndNil(hudrflag);
182 r_Common_FreeAndNil(hudjet);
183 r_Common_FreeAndNil(hudair);
184 r_Common_FreeAndNil(hudkey[0]);
185 r_Common_FreeAndNil(hudkey[1]);
186 r_Common_FreeAndNil(hudkey[2]);
187 for i := 0 to WP_LAST do
188 r_Common_FreeAndNil(hudwp[i]);
189 r_Common_FreeAndNil(hudap);
190 r_Common_FreeAndNil(hudhp[true]);
191 r_Common_FreeAndNil(hudhp[false]);
192 r_Common_FreeAndNil(hudbg);
193 r_Common_FreeAndNil(hud);
194 r_Common_Free;
195 end;
197 {$IFDEF ENABLE_SYSTEM}
198 function GetInfo (): TGLDisplayInfo;
199 var info: TGLDisplayInfo;
200 begin
201 info := Default(TGLDisplayInfo);
202 info.w := Max(1, gRC_Width);
203 info.h := Max(1, gRC_Height);
204 info.bpp := Max(1, gBPP);
205 info.fullscreen := gRC_FullScreen;
206 info.maximized := gRC_Maximized;
207 info.major := 1;
208 info.minor := 1;
209 {$IFDEF USE_GLES1}
210 info.profile := TGLProfile.Common;
211 {$ELSE}
212 info.profile := TGLProfile.Compat;
213 {$ENDIF}
214 result := info;
215 end;
216 {$ENDIF}
218 procedure r_Render_LogGLInfo;
219 begin
220 e_LogWritefln('GL Vendor: %s', [glGetString(GL_VENDOR)]);
221 e_LogWritefln('GL Renderer: %s', [glGetString(GL_RENDERER)]);
222 e_LogWritefln('GL Version: %s', [glGetString(GL_VERSION)]);
223 e_LogWritefln('GL Shaders: %s', [glGetString(GL_SHADING_LANGUAGE_VERSION)]);
224 e_LogWritefln('GL Extensions: %s', [glGetString(GL_EXTENSIONS)]);
225 end;
227 procedure r_Render_Initialize;
228 begin
229 {$IFDEF ENABLE_SYSTEM}
230 if sys_SetDisplayModeGL(GetInfo()) = False then
231 raise Exception.Create('Failed to set videomode on startup.');
232 sys_EnableVSync(gVSync);
233 {$ENDIF}
234 {$IFDEF NOGL_INIT}
235 nogl_Init;
236 {$ENDIF}
237 r_Render_LogGLInfo;
238 r_LoadScreen_Initialize;
239 r_Textures_Initialize;
240 r_Console_Initialize;
241 r_Map_Initialize;
242 end;
244 procedure r_Render_Finalize;
245 begin
246 r_Map_Finalize;
247 r_Console_Finalize;
248 r_Textures_Finalize;
249 r_LoadScreen_Finalize;
250 {$IFDEF NOGL_INIT}
251 nogl_Quit;
252 {$ENDIF}
253 end;
255 procedure r_Render_Reset;
256 begin
257 r_Map_Reset;
258 end;
260 procedure r_Render_Update;
261 begin
262 r_Console_Update;
263 r_Map_Update;
264 end;
266 procedure r_Render_DrawHUD (x, y: Integer; p: TPlayer);
267 var t: TGLTexture; s: AnsiString;
268 begin
269 ASSERT(p <> nil);
271 // hud area is 196 x 240 pixels
272 r_Common_DrawTexture(hud, x, y, hud.width, hud.height, TBasePoint.BP_LEFTUP);
273 r_Common_DrawText(p.name, x + 98, y + 16, 255, 0, 0, 255, smallfont, TBasePoint.BP_CENTER);
275 t := hudhp[R_BERSERK in p.FRulez];
276 r_Common_DrawTexture(t, x + 51, y + 61, t.width, t.height, TBasePoint.BP_CENTER);
277 r_Common_DrawTexture(hudap, x + 50, y + 85, hudap.width, hudap.height, TBasePoint.BP_CENTER);
279 r_Common_DrawText(IntToStr(MAX(0, p.health)), x + 174, y + 56, 255, 0, 0, 255, menufont, TBasePoint.BP_RIGHT);
280 r_Common_DrawText(IntToStr(MAX(0, p.armor)), x + 174, y + 84, 255, 0, 0, 255, menufont, TBasePoint.BP_RIGHT);
282 case p.CurrWeap of
283 WEAPON_KASTET, WEAPON_SAW: s := '--';
284 else s := IntToStr(p.GetAmmoByWeapon(p.CurrWeap));
285 end;
286 r_Common_DrawText(s, x + 174, y + 174, 255, 0, 0, 255, menufont, TBasePoint.BP_RIGHT);
288 if p.CurrWeap <= WP_LAST then
289 begin
290 t := hudwp[p.CurrWeap];
291 r_Common_DrawTexture(t, x + 18, y + 160, t.width, t.height, TBasePoint.BP_LEFTUP);
292 end;
294 if R_KEY_RED in p.FRulez then
295 r_Common_DrawTexture(hudkey[0], x + 76, y + 214, 16, 16, TBasePoint.BP_LEFTUP);
296 if R_KEY_GREEN in p.FRulez then
297 r_Common_DrawTexture(hudkey[1], x + 93, y + 214, 16, 16, TBasePoint.BP_LEFTUP);
298 if R_KEY_BLUE in p.FRulez then
299 r_Common_DrawTexture(hudkey[2], x + 110, y + 214, 16, 16, TBasePoint.BP_LEFTUP);
301 if p.JetFuel > 0 then
302 begin
303 r_Common_DrawTexture(hudair, x, y + 116, hudair.width, hudair.height, TBasePoint.BP_LEFTUP);
304 if p.air > 0 then
305 r_Draw_FillRect(x + 14, y + 116 + 4, x + 14 + 168 * p.air div AIR_MAX, y + 116 + 4 + 4, 0, 0, 196, 255);
306 r_Common_DrawTexture(hudjet, x, y + 126, hudjet.width, hudjet.height, TBasePoint.BP_LEFTUP);
307 r_Draw_FillRect(x + 14, y + 126 + 4, x + 14 + 168 * p.JetFuel div JET_MAX, y + 126 + 4 + 4, 208, 0, 0, 255);
308 end
309 else
310 begin
311 r_Common_DrawTexture(hudair, x, y + 124, hudair.width, hudair.height, TBasePoint.BP_LEFTUP);
312 if p.air > 0 then
313 r_Draw_FillRect(x + 14, y + 124 + 4, x + 14 + 168 * p.air div AIR_MAX, y + 124 + 4 + 4, 0, 0, 196, 255);
314 end;
315 end;
317 procedure r_Render_DrawHUDArea (x, y, w, h: Integer; p: TPlayer);
318 var s: AnsiString; oldy: Integer;
319 begin
320 r_Common_DrawTexture(hudbg, x, y, w, h, TBasePoint.BP_LEFTUP);
322 if p <> nil then
323 begin
324 oldy := y;
325 if h < 239 then y := y - 32; (* hack: hide nickname on 640x400 *)
326 r_Render_DrawHUD(x + w - 196 + 2, y, p);
327 if p.Spectator then
328 begin
329 r_Common_DrawText(_lc[I_PLAYER_SPECT], x + 4, y + 242, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
330 r_Common_DrawText(_lc[I_PLAYER_SPECT2], x + 4, y + 258, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
331 r_Common_DrawText(_lc[I_PLAYER_SPECT1], x + 4, y + 274, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
332 if p.NoRespawn then
333 r_Common_DrawText(_lc[I_PLAYER_SPECT1S], x + 4, y + 290, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
334 end;
335 y := oldy;
336 end;
338 if gShowPing and g_Game_IsClient then
339 begin
340 s := _lc[I_GAME_PING_HUD] + IntToStr(NetPeer.lastRoundTripTime) + _lc[I_NET_SLIST_PING_MS];
341 r_Common_DrawText(s, x + 4, y + 242, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
342 end;
343 end;
345 procedure r_Render_DrawStatsView (x, y, w, h: Integer; p: TPlayer);
346 var fw, i, maxFrags, top, totalPlayers: Integer; sign: Char; stat: TPlayerStatArray; f: TGLTexture;
347 begin
348 ASSERT(p <> nil);
350 if gShowScore and (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
351 begin
352 (* RED TEAM SCORE *)
353 fw := 0;
354 if gGameSettings.GameMode = GM_CTF then
355 begin
356 case gFlags[FLAG_RED].State of
357 FLAG_STATE_CAPTURED: f := hudrflags;
358 FLAG_STATE_DROPPED: f := hudrflagd;
359 otherwise f := hudrflag;
360 end;
361 if f <> nil then
362 begin
363 fw := f.width + 8; (* + space *)
364 r_Common_DrawTexture(f, x + w - 16, y + 240 - 72 - 4, f.width, f.height, TBasePoint.BP_RIGHTUP);
365 end;
366 end;
367 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);
369 (* BLUE TEAM SCORE *)
370 fw := 0;
371 if gGameSettings.GameMode = GM_CTF then
372 begin
373 case gFlags[FLAG_BLUE].State of
374 FLAG_STATE_CAPTURED: f := hudbflags;
375 FLAG_STATE_DROPPED: f := hudbflagd;
376 otherwise f := hudbflag;
377 end;
378 if f <> nil then
379 begin
380 fw := f.width + 8; (* + space *)
381 r_Common_DrawTexture(f, x + w - 16, y + 240 - 32 - 4, f.width, f.height, TBasePoint.BP_RIGHTUP);
382 end;
383 end;
384 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);
385 end;
387 if gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT] then
388 begin
389 if gShowStat then
390 begin
391 r_Common_DrawText(IntToStr(p.Frags), x + w - 16, y, 255, 0, 0, 255, menufont, TBasePoint.BP_RIGHTUP);
393 top := 1;
394 maxFrags := 0;
395 totalPlayers := 0;
396 stat := g_Player_GetStats();
397 if stat <> nil then
398 begin
399 totalPlayers := Length(stat);
400 for i := 0 to High(stat) do
401 begin
402 if stat[i].Name <> p.Name then
403 begin
404 maxFrags := MAX(maxFrags, stat[i].Frags);
405 if stat[i].Frags > p.Frags then
406 top := top + 1;
407 end;
408 end;
409 end;
410 if p.Frags >= maxFrags then sign := '+' else sign := '-';
411 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);
412 end;
414 if gLMSRespawn > LMS_RESPAWN_NONE then
415 begin
416 r_Common_DrawText(_lc[I_GAME_WARMUP], x + w - 16 - 64, y + h, 0, 255, 0, 255, menufont, TBasePoint.BP_RIGHTDOWN);
417 r_Common_DrawText(': ' + IntToStr((gLMSRespawnTime - gTime) div 1000), x + w - 16 - 64, y + h, 0, 255, 0, 255, menufont, TBasePoint.BP_LEFTDOWN);
418 end
419 else if gShowLives and (gGameSettings.MaxLives > 0) then
420 begin
421 r_Common_DrawText(IntToStr(p.Lives), x + w - 16, y + h, 0, 255, 0, 255, menufont, TBasePoint.BP_RIGHTDOWN);
422 end;
423 end;
424 end;
426 procedure r_Render_DrawView (x, y, w, h: Integer; p: TPlayer);
427 var l, t, r, b, xx, yy, cx, cy: Integer;
428 begin
429 r_Draw_GetRect(l, t, r, b);
430 r_Draw_SetRect(x, y, x + w, y + h);
432 r_Common_GetCameraPos(p, true, xx, yy);
433 if p <> nil then
434 begin
435 r_Map_Draw(x, y, w, h, xx, yy, p, cx, cy);
436 {$IFDEF ENABLE_HOLMES}
437 if p = gPlayer1 then
438 begin
439 r_Holmes_plrViewPos(cx, cy);
440 r_Holmes_plrViewSize(h, w);
441 end;
442 {$ENDIF}
443 r_Render_DrawStatsView(x, y, w, h, p);
444 if p.Spectator and p.NoRespawn then
445 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);
446 end
447 else
448 begin
449 r_Map_Draw(x, y, w, h, xx, yy, nil, cx, cy);
450 end;
452 r_Draw_SetRect(l, t, r, b);
453 end;
455 procedure r_Render_DrawMapView (x, y, w, h, camx, camy: Integer);
456 var l, t, r, b, cx, cy: Integer;
457 begin
458 r_Draw_GetRect(l, t, r, b);
459 r_Draw_SetRect(x, y, x + w, y + h);
460 r_Map_Draw(x, y, w, h, camx, camy, nil, cx, cy);
461 r_Draw_SetRect(l, t, r, b);
462 end;
464 procedure r_Render_DrawPlayerView (x, y, w, h: Integer; p: TPlayer);
465 var l, t, r, b: Integer;
466 begin
467 r_Draw_GetRect(l, t, r, b);
468 r_Draw_SetRect(x, y, x + w, y + h);
469 r_Render_DrawView(x, y, w - 196, h, p);
470 r_Render_DrawHUDArea(x + w - 196, y, 196, h, p);
471 r_Draw_SetRect(l, t, r, b);
472 end;
474 procedure r_Render_DrawServerList (var SL: TNetServerList; var ST: TNetServerTable);
475 var ip: AnsiString; ww, hh, cw, ch, mw, mh, motdh, scrx, scry, i, mx, y: Integer; msg: SSArray; Srv: TNetServer;
476 begin
477 scrx := gScreenWidth div 2;
478 scry := gScreenHeight div 2;
480 r_Draw_GetTextSize(_lc[I_NET_SLIST], menufont, ww, hh);
481 r_Common_DrawText(_lc[I_NET_SLIST], gScreenWidth div 2, 16, 255, 255, 255, 255, menufont, TBasePoint.BP_UP);
483 r_Draw_GetTextSize('W', stdfont, cw, ch);
484 motdh := gScreenHeight - 49 - ch * b_Text_LineCount(slMOTD);
486 (* window background *)
487 r_Draw_Rect(16, 64, gScreenWidth - 16, motdh + 1, 255, 127, 0, 255);
488 r_Draw_FillRect(16 + 1, 64 + 1, gScreenWidth - 16 - 1, motdh, 64, 64, 64, 145);
490 r_Common_DrawText(_lc[I_NET_SLIST_HELP], gScreenWidth div 2, gScreenHeight - 8, 255, 255, 255, 255, stdfont, TBasePoint.BP_DOWN);
492 if slMOTD <> '' then
493 begin
494 r_Draw_Rect(16, motdh, gScreenWidth - 16, gScreenHeight - 44, 255, 127, 0, 255);
495 r_Draw_FillRect(16 + 1, motdh + 1, gScreenWidth - 16 - 1, gScreenHeight - 44 - 1, 64, 64, 64, 145);
496 r_Common_DrawFormatText(slMOTD, 20, motdh + 3, 255, stdfont, TBasePoint.BP_LEFTUP);
497 end;
499 if not slReadUrgent and (slUrgent <> '') then
500 begin
501 r_Draw_Rect(scrx - 256, scry - 60, scrx + 256, scry + 60 + 1, 255, 127, 0, 255);
502 r_Draw_FillRect(scrx - 256 + 1, scry - 60 + 1, scrx + 256 - 1, scry + 60, 64, 64, 64, 127);
503 r_Draw_FillRect(scrx - 256, scry - 40, scrx + 256, scry - 40 + 1, 255, 127, 0, 255);
504 r_Draw_FillRect(scrx - 256, scry + 40, scrx + 256, scry + 40 + 1, 255, 127, 0, 255);
505 r_Common_DrawText(_lc[I_NET_SLIST_URGENT], scrx, scry - 58, 255, 255, 255, 255, stdfont, TBasePoint.BP_UP);
506 r_Common_DrawText(_lc[I_NET_SLIST_URGENT_CONT], scrx, scry + 41, 255, 255, 255, 255, stdfont, TBasePoint.BP_UP);
507 r_Common_DrawFormatText(slUrgent, scrx - 253, scry - 38, 255, stdfont, TBasePoint.BP_LEFTUP);
508 end
509 else if SL = nil then
510 begin
511 r_Draw_Rect(scrx - 192, scry - 10, scrx + 192, scry + 10, 255, 127, 0, 255);
512 r_Draw_FillRect(scrx - 192 + 1, scry - 10 + 1, scrx + 192 - 1, scry + 10 - 1, 64, 64, 64, 145);
513 r_Common_DrawText(slWaitStr, scrx, scry, 255, 255, 255, 255, stdfont, TBasePoint.BP_CENTER);
514 end
515 else
516 begin
517 y := 90;
518 if slSelection < Length(ST) then
519 begin
520 sy := y + 42 * slSelection - 4;
521 Srv := GetServerFromTable(slSelection, SL, ST);
522 ip := _lc[I_NET_ADDRESS] + ' ' + Srv.IP + ':' + IntToStr(Srv.Port);
523 ip := ip + ' ' + _lc[I_NET_SERVER_PASSWORD] + ' ';
524 if Srv.Password then ip := ip + _lc[I_MENU_YES] else ip := ip +_lc[I_MENU_NO];
525 end;
527 mw := gScreenWidth - 188;
528 mx := 16 + mw;
530 (* current selection *)
531 r_Draw_FillRect(16 + 1, sy + 1, gScreenWidth - 16 - 1, sy + 1 + 40, 64, 64, 64, 255);
532 r_Draw_FillRect(16 + 1, sy, gScreenWidth - 16 - 1, sy + 1, 255, 255, 255, 255);
533 r_Draw_FillRect(16 + 1, sy + 1 + 40, gScreenWidth - 16 - 1, sy + 1 + 40 + 1, 255, 255, 255, 255);
535 (* line separators for name/ping/mode.. & address/pasword *)
536 r_Draw_FillRect(16, 85, gScreenWidth - 16, 85 + 1, 255, 127, 0, 255);
537 r_Draw_FillRect(16, motdh - 20, gScreenWidth - 16, motdh - 20 + 1, 255, 127, 0, 255);
539 (* column separators for name/ping/mode/players/version *)
540 r_Draw_FillRect(mx - 70, 64 + 1, mx - 70 + 1, motdh, 255, 127, 0, 255);
541 r_Draw_FillRect(mx, 64 + 1, mx + 1, motdh - 20, 255, 127, 0, 255);
542 r_Draw_FillRect(mx + 52, 64 + 1, mx + 52 + 1, motdh - 20, 255, 127, 0, 255);
543 r_Draw_FillRect(mx + 104, 64 + 1, mx + 104 + 1, motdh - 20, 255, 127, 0, 255);
545 r_Common_DrawText('NAME/MAP', 18, 68, 255, 127, 0, 255, stdfont, TBasePoint.BP_LEFTUP);
546 r_Common_DrawText('PING', mx - 68, 68, 255, 127, 0, 255, stdfont, TBasePoint.BP_LEFTUP);
547 r_Common_DrawText('MODE', mx + 2, 68, 255, 127, 0, 255, stdfont, TBasePoint.BP_LEFTUP);
548 r_Common_DrawText('PLRS', mx + 54, 68, 255, 127, 0, 255, stdfont, TBasePoint.BP_LEFTUP);
549 r_Common_DrawText('VER', mx + 106, 68, 255, 127, 0, 255, stdfont, TBasePoint.BP_LEFTUP);
551 for i := 0 to High(ST) do
552 begin
553 Srv := GetServerFromTable(i, SL, ST);
554 r_Common_DrawText(Srv.Name, 18, y, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
555 r_Common_DrawText(Srv.Map, 18, y + 16, 210, 210, 210, 255, stdfont, TBasePoint.BP_LEFTUP);
557 if Srv.Ping = 0 then
558 r_Common_DrawText('<1' + _lc[I_NET_SLIST_PING_MS], mx - 68, y, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP)
559 else if (Srv.Ping >= 0) and (Srv.Ping <= 999) then
560 r_Common_DrawText(IntToStr(Srv.Ping) + _lc[I_NET_SLIST_PING_MS], mx - 68, y, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP)
561 else
562 r_Common_DrawText(_lc[I_NET_SLIST_NO_ACCESS], mx - 68, y, 255, 0, 0, 255, stdfont, TBasePoint.BP_LEFTUP);
563 if Length(ST[I].Indices) > 1 then
564 r_Common_DrawText('<' + IntToStr(Length(ST[I].Indices)) + '>', mx - 68, y + 16, 210, 210, 210, 255, stdfont, TBasePoint.BP_LEFTUP);
566 r_Common_DrawText(g_Game_ModeToText(Srv.GameMode), mx + 2, y, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
568 r_Common_DrawText(IntToStr(Srv.Players) + '/' + IntToStr(Srv.MaxPlayers), mx + 54, y, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
569 r_Common_DrawText(IntToStr(Srv.LocalPl) + '+' + IntToStr(Srv.Bots), mx + 54, y + 16, 210, 210, 210, 255, stdfont, TBasePoint.BP_LEFTUP);
571 r_Common_DrawText(IntToStr(Srv.Protocol), mx + 106, y, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
573 y := y + 42;
574 end;
576 r_Common_DrawText(ip, 20, motdh - 20 + 3, 205, 205, 205, 255, stdfont, TBasePoint.BP_LEFTUP);
577 r_Common_DrawText(IntToStr(Length(ST)) + _lc[I_NET_SLIST_SERVERS], gScreenWidth - 48, motdh - 20 + 3, 255, 255, 255, 255, stdfont, TBasePoint.BP_RIGHTUP);
578 end;
579 end;
581 procedure r_Render_DrawStatsColumns (constref cs: TEndCustomGameStat; x, y, w: Integer; endview: Boolean);
582 var i, cw, ch, yy, team, players, w1, w2, w3, w4, tw: Integer; r, g, b, rr, gg, bb: Byte; s: AnsiString;
583 begin
584 r_Draw_GetTextSize('W', stdfont, cw, ch);
585 w4 := cw * 6; (* deaths width *)
586 w3 := cw * 8; (* frags width *)
587 w2 := cw * 12; (* ping/loss width *)
588 w1 := w - w2 - w3 - w4; (* name width *)
589 tw := w1 - cw * 2 - w2; (* team score *)
590 if cs.PlayerStat = nil then players := 0 else players := Length(cs.PlayerStat);
591 yy := y;
592 if cs.GameMode in [GM_TDM, GM_CTF] then
593 begin
594 for team := TEAM_RED to TEAM_BLUE do
595 begin
596 case team of
597 TEAM_RED:
598 begin
599 s := _lc[I_GAME_TEAM_RED];
600 r := 255; g := 0; b := 0;
601 end;
602 TEAM_BLUE:
603 begin
604 s := _lc[I_GAME_TEAM_BLUE];
605 r := 0; g := 0; b := 255;
606 end;
607 end;
608 r_Common_DrawText(s, x, yy, r, g, b, 255, stdfont, TBasePoint.BP_LEFTUP);
609 r_Common_DrawText(IntToStr(cs.TeamStat[team].Score), x + tw, yy, r, g, b, 255, stdfont, TBasePoint.BP_UP);
610 if endview = false then
611 r_Common_DrawText(_lc[I_GAME_PING], x + w1, yy, r, g, b, 255, stdfont, TBasePoint.BP_UP);
612 r_Common_DrawText(_lc[I_GAME_FRAGS], x + w1 + w2, yy, r, g, b, 255, stdfont, TBasePoint.BP_UP);
613 r_Common_DrawText(_lc[I_GAME_DEATHS], x + w1 + w2 + w3, yy, r, g, b, 255, stdfont, TBasePoint.BP_UP);
614 INC(yy, ch);
616 INC(yy, ch div 4);
617 r_Draw_FillRect(x, yy, x + w, yy + 1, r, g, b, 255);
618 INC(yy, ch div 4);
620 for i := 0 to players - 1 do
621 begin
622 if cs.PlayerStat[i].Team = team then
623 begin
624 rr := r; gg := g; bb := b;
625 if cs.PlayerStat[i].Spectator then
626 begin
627 rr := r div 2; gg := g div 2; bb := b div 2;
628 end;
630 // Player name
631 if gShowPIDs then s := Format('[%5d] %s', [cs.PlayerStat[i].UID, cs.PlayerStat[i].Name]) else s := cs.PlayerStat[i].Name;
632 if (gPlayers[cs.PlayerStat[i].Num] <> nil) and (gPlayers[cs.PlayerStat[i].Num].FReady) then s := s + ' *';
633 r_Common_DrawText(s, x, yy, rr, gg, bb, 255, stdfont, TBasePoint.BP_LEFTUP);
634 if endview = false then
635 begin
636 // Player ping/loss
637 s := Format(_lc[I_GAME_PING_MS], [cs.PlayerStat[i].Ping, cs.PlayerStat[i].Loss]);
638 r_Common_DrawText(s, x + w1, yy, rr, gg, bb, 255, stdfont, TBasePoint.BP_UP);
639 end;
640 // Player frags
641 s := IntToStr(cs.PlayerStat[i].Frags);
642 r_Common_DrawText(s, x + w1 + w2, yy, rr, gg, bb, 255, stdfont, TBasePoint.BP_UP);
643 // Player deaths
644 s := IntToStr(cs.PlayerStat[i].Deaths);
645 r_Common_DrawText(s, x + w1 + w2 + w3, yy, rr, gg, bb, 255, stdfont, TBasePoint.BP_UP);
647 INC(yy, ch);
648 end;
649 end;
650 INC(yy, ch);
651 end;
652 end
653 else if cs.GameMode in [GM_DM, GM_COOP] then
654 begin
655 r_Common_DrawText(_lc[I_GAME_PLAYER_NAME], x, yy, 255, 127, 0, 255, stdfont, TBasePoint.BP_LEFTUP);
656 if endview = false then
657 r_Common_DrawText(_lc[I_GAME_PING], x + w1, yy, 255, 127, 0, 255, stdfont, TBasePoint.BP_UP);
658 r_Common_DrawText(_lc[I_GAME_FRAGS], x + w1 + w2, yy, 255, 127, 0, 255, stdfont, TBasePoint.BP_UP);
659 r_Common_DrawText(_lc[I_GAME_DEATHS], x + w1 + w2 + w3, yy, 255, 127, 0, 255, stdfont, TBasePoint.BP_UP);
660 INC(yy, ch + ch div 2);
661 for i := 0 to players - 1 do
662 begin
663 // rr := 255; gg := 127; bb := 0;
664 rr := 255; gg := 255; bb := 255;
665 if cs.PlayerStat[i].Spectator then
666 begin
667 rr := rr div 2; gg := gg div 2; bb := bb div 2;
668 end;
670 // Player color
671 r_Draw_Rect(x, yy, x + 16, yy + 16, 192, 192, 192, 255);
672 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);
673 // Player name
674 if gShowPIDs then s := Format('[%5d] %s', [cs.PlayerStat[i].UID, cs.PlayerStat[i].Name]) else s := cs.PlayerStat[i].Name;
675 if (gPlayers[cs.PlayerStat[i].Num] <> nil) and (gPlayers[cs.PlayerStat[i].Num].FReady) then s := s + ' *';
676 r_Common_DrawText(s, x + 16 + 8, yy, rr, gg, bb, 255, stdfont, TBasePoint.BP_LEFTUP);
677 if endview = false then
678 begin
679 // Player ping/loss
680 s := Format(_lc[I_GAME_PING_MS], [cs.PlayerStat[i].Ping, cs.PlayerStat[i].Loss]);
681 r_Common_DrawText(s, x + w1, yy, rr, gg, bb, 255, stdfont, TBasePoint.BP_UP);
682 end;
683 // Player frags
684 s := IntToStr(cs.PlayerStat[i].Frags);
685 r_Common_DrawText(s, x + w1 + w2, yy, rr, gg, bb, 255, stdfont, TBasePoint.BP_UP);
686 // Player deaths
687 s := IntToStr(cs.PlayerStat[i].Deaths);
688 r_Common_DrawText(s, x + w1 + w2 + w3, yy, rr, gg, bb, 255, stdfont, TBasePoint.BP_UP);
690 INC(yy, ch + ch div 2);
691 end;
692 end;
693 end;
695 procedure r_Render_DrawStatsWindow (x, y, w, h: Integer; cs: TEndCustomGameStat; endview: Boolean);
696 var xoff, yoff, cw, ch: Integer; s: AnsiString;
697 begin
698 xoff := 0; yoff := 8;
699 r_Draw_GetTextSize('W', stdfont, cw, ch);
700 r_Draw_Rect(x, y, x + w, y + h, 255, 127, 0, 255);
701 r_Draw_FillRect(x + 1, y + 1, x + w - 1, y + h - 1, 64, 64, 64, 224);
703 (* LINE 1 *)
705 if endview = false then
706 begin
707 case NetMode of
708 NET_SERVER: s := _lc[I_NET_SERVER];
709 NET_CLIENT: s := NetClientIP + ':' + IntToStr(NetClientPort);
710 otherwise s := '';
711 end;
712 r_Common_DrawText(s, x + 16, y + yoff, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
713 end;
715 case cs.GameMode of
716 GM_DM: if gGameSettings.MaxLives = 0 then s := _lc[I_GAME_DM] else s := _lc[I_GAME_LMS];
717 GM_TDM: if gGameSettings.MaxLives = 0 then s := _lc[I_GAME_TDM] else s := _lc[I_GAME_TLMS];
718 GM_CTF: s := _lc[I_GAME_CTF];
719 GM_COOP: if gGameSettings.MaxLives = 0 then s := _lc[I_GAME_COOP] else s := _lc[I_GAME_SURV];
720 otherwise s := 'GAME MODE ' + IntToStr(gGameSettings.GameMode);
721 end;
722 r_Common_DrawText(s, x + w div 2, y + yoff, 255, 255, 255, 255, stdfont, TBasePoint.BP_UP);
724 if endview = false then
725 begin
726 s := r_Common_TimeToStr(cs.GameTime);
727 r_Common_DrawText(s, x + w - 16, y + yoff, 255, 255, 255, 255, stdfont, TBasePoint.BP_RIGHTUP);
728 end;
730 INC(yoff, ch + ch div 2);
732 (* LINE 2/3 *)
734 s := cs.Map;
735 if cs.MapName <> '' then
736 s := s + ' - ' + cs.MapName;
738 if endview = false then
739 begin
740 r_Common_DrawText(s, x + w div 2, y + yoff, 200, 200, 200, 255, stdfont, TBasePoint.BP_UP);
741 INC(yoff, ch + ch div 2);
742 case cs.GameMode of
743 GM_DM, GM_TDM: s := Format(_lc[I_GAME_FRAG_LIMIT], [gGameSettings.ScoreLimit]);
744 GM_CTF: s := Format(_lc[I_GAME_SCORE_LIMIT], [gGameSettings.ScoreLimit]);
745 GM_COOP: s := _lc[I_GAME_MONSTERS] + ' ' + IntToStr(gCoopMonstersKilled) + '/' + IntToStr(gTotalMonsters);
746 otherwise s := '';
747 end;
748 r_Common_DrawText(s, x + 16, y + yoff, 200, 200, 200, 255, stdfont, TBasePoint.BP_LEFTUP);
749 case cs.GameMode of
750 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]);
751 GM_COOP: s := _lc[I_GAME_SECRETS] + ' ' + IntToStr(gCoopSecretsFound) + '/' + IntToStr(gSecretsCount);
752 otherwise s := '';
753 end;
754 r_Common_DrawText(s, x + w - 16, y + yoff, 200, 200, 200, 255, stdfont, TBasePoint.BP_RIGHTUP);
755 INC(yoff, ch);
756 end
757 else
758 begin
759 xoff := MAX(Length(_lc[I_MENU_MAP]) + 1, Length(_lc[I_GAME_GAME_TIME]) + 1) * cw;
760 r_Common_DrawText(_lc[I_MENU_MAP], x + 16, y + yoff, 255, 127, 0, 255, stdfont, TBasePoint.BP_LEFTUP);
761 r_Common_DrawText(s, x + 16 + xoff, y + yoff, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
762 INC(yoff, ch);
763 r_Common_DrawText(_lc[I_GAME_GAME_TIME], x + 16, y + yoff, 255, 127, 0, 255, stdfont, TBasePoint.BP_LEFTUP);
764 r_Common_DrawText(r_Common_TimeToStr(cs.GameTime), x + 16 + xoff, y + yoff, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
765 INC(yoff, ch);
766 end;
768 INC(yoff, ch);
770 (* LINE 4/5 *)
772 if endview and (cs.GameMode = GM_COOP) then
773 begin
774 xoff := MAX(Length(_lc[I_GAME_MONSTERS]) + 1, Length(_lc[I_GAME_SECRETS]) + 1) * cw;
775 r_Common_DrawText(_lc[I_GAME_MONSTERS], x + 16, y + yoff, 255, 127, 0, 255, stdfont, TBasePoint.BP_LEFTUP);
776 r_Common_DrawText(IntToStr(gCoopMonstersKilled) + '/' + IntToStr(gTotalMonsters), x + 16 + xoff, y + yoff, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
777 INC(yoff, ch);
778 r_Common_DrawText(_lc[I_GAME_SECRETS], x + 16, y + yoff, 255, 127, 0, 255, stdfont, TBasePoint.BP_LEFTUP);
779 r_Common_DrawText(IntToStr(gCoopSecretsFound) + '/' + IntToStr(gSecretsCount), x + 16 + xoff, y + yoff, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
780 INC(yoff, ch);
781 INC(yoff, ch);
782 end;
784 (* LINE 6/7 *)
786 if endview and (cs.GameMode = GM_COOP) and gLastMap then
787 begin
788 xoff := MAX(Length(_lc[I_GAME_MONSTERS_TOTAL]) + 1, Length(_lc[I_GAME_SECRETS_TOTAL]) + 1) * cw;
789 r_Common_DrawText(_lc[I_GAME_MONSTERS_TOTAL], x + 16, y + yoff, 255, 127, 0, 255, stdfont, TBasePoint.BP_LEFTUP);
790 r_Common_DrawText(IntToStr(gCoopTotalMonstersKilled) + '/' + IntToStr(gCoopTotalMonsters), x + 16 + xoff, y + yoff, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
791 INC(yoff, ch);
792 r_Common_DrawText(_lc[I_GAME_SECRETS_TOTAL], x + 16, y + yoff, 255, 127, 0, 255, stdfont, TBasePoint.BP_LEFTUP);
793 r_Common_DrawText(IntToStr(gCoopTotalSecretsFound) + '/' + IntToStr(gCoopTotalSecrets), x + 16 + xoff, y + yoff, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
794 INC(yoff, ch);
795 INC(yoff, ch);
796 end;
798 (* LINE *)
800 if endview and (cs.GameMode in [GM_TDM, GM_CTF]) then
801 begin
802 if cs.TeamStat[TEAM_RED].Score > cs.TeamStat[TEAM_BLUE].Score then s := _lc[I_GAME_WIN_RED]
803 else if cs.TeamStat[TEAM_BLUE].Score > cs.TeamStat[TEAM_RED].Score then s := _lc[I_GAME_WIN_BLUE]
804 else s := _lc[I_GAME_WIN_DRAW];
805 r_Common_DrawText(s, x + w div 2, y + yoff, 255, 255, 255, 255, stdfont, TBasePoint.BP_UP);
806 INC(yoff, ch);
807 INC(yoff, ch);
808 end;
810 (* LINE n *)
812 r_Render_DrawStatsColumns(cs, x + 16, y + yoff, w - 16 - 16, endview);
813 end;
815 function r_Render_StatsHeight (players: Integer): Integer;
816 var cw, ch: Integer;
817 begin
818 ASSERT(players >= 0);
819 r_Draw_GetTextSize('W', stdfont, cw, ch);
820 case gGameSettings.GameMode of
821 GM_TDM, GM_CTF: result := 32 + ch * (11 + players);
822 otherwise result := 40 + ch * 5 + (ch + 8) * players;
823 end;
824 end;
826 procedure r_Render_DrawStats;
827 var x, y, w, h, players: Integer; cs: TEndCustomGameStat;
828 begin
829 cs.PlayerStat := g_Player_GetStats();
830 SortGameStat(cs.PlayerStat);
831 cs.TeamStat := gTeamStat;
832 cs.GameTime := gTime;
833 cs.GameMode := gGameSettings.GameMode;
834 cs.Map := g_ExtractWadNameNoPath(gMapInfo.Map) + ':' + g_ExtractFileName(gMapInfo.Map);
835 cs.MapName := gMapInfo.Name;
836 if cs.PlayerStat = nil then players := 0 else players := Length(cs.PlayerStat);
837 w := gScreenWidth - (gScreenWidth div 5);
838 h := r_Render_StatsHeight(players);
839 x := (gScreenWidth div 2) - (w div 2);
840 y := (gScreenHeight div 2) - (h div 2);
841 r_Render_DrawStatsWindow(x, y, w, h, cs, false);
842 end;
844 procedure r_Render_DrawCustomStats;
845 var cw, ch, s: AnsiString;
846 begin
847 if gStatsOff then
848 begin
849 r_Common_DrawText(_lc[I_MENU_INTER_NOTICE_TAB], gScreenWidth div 2, 8, 255, 255, 255, 255, stdfont, TBasePoint.BP_UP);
850 end
851 else
852 begin
853 case gGameSettings.GameMode of
854 GM_COOP: if gMissionFailed then s := _lc[I_MENU_INTER_MISSION_FAIL] else s := _lc[I_MENU_INTER_LEVEL_COMPLETE];
855 otherwise s := _lc[I_MENU_INTER_ROUND_OVER];
856 end;
857 r_Common_DrawText(s, gScreenWidth div 2, 16, 255, 255, 255, 255, menufont, TBasePoint.BP_UP);
859 if gChatShow = false then
860 begin
861 if g_Game_IsClient then s := _lc[I_MENU_INTER_NOTICE_MAP] else s := _lc[I_MENU_INTER_NOTICE_SPACE];
862 r_Common_DrawText(s, gScreenWidth div 2, gScreenHeight - 4, 255, 255, 255, 255, stdfont, TBasePoint.BP_DOWN);
863 if g_Game_IsNet then
864 begin
865 s := Format(_lc[I_MENU_INTER_NOTICE_TIME], [gServInterTime]);
866 r_Common_DrawText(s, gScreenWidth div 2, gScreenHeight - 16 - 4, 255, 255, 255, 255, stdfont, TBasePoint.BP_DOWN);
867 end;
868 end;
870 r_Render_DrawStatsWindow(32, 64, gScreenWidth - 32 * 2, gScreenHeight - 64 * 2, CustomStat, true);
871 end;
872 end;
874 procedure r_Render_DrawValueOf (a, b, x, y: Integer; f: TGLFont);
875 var wa, wb, ch: Integer; sa, sb: AnsiString;
876 begin
877 sa := IntToStr(a);
878 sb := IntToStr(b);
879 r_Draw_GetTextSize(sa, f, wa, ch);
880 r_Draw_GetTextSize(sa + ' / ', f, wb, ch);
881 r_Common_DrawText(sa, x, y, 255, 0, 0, 255, f, TBasePoint.BP_LEFTUP);
882 r_Common_DrawText(' / ', x + wa, y, 255, 255, 255, 255, f, TBasePoint.BP_LEFTUP);
883 r_Common_DrawText(sb, x + wb, y, 255, 0, 0, 255, f, TBasePoint.BP_LEFTUP);
884 end;
886 procedure r_Render_DrawSinglStatsPlayer (player, x, y, w1: Integer);
887 var time, kpm: Single;
888 begin
889 r_Common_DrawText(_lc[I_MENU_INTER_KILLS], x, y, 255, 255, 255, 255, menufont, TBasePoint.BP_LEFTUP);
890 r_Render_DrawValueOf(SingleStat.PlayerStat[player].Kills, gTotalMonsters, x + w1, y, MenuFont);
891 r_Common_DrawText(_lc[I_MENU_INTER_KPM], x, y + 32, 255, 255, 255, 255, menufont, TBasePoint.BP_LEFTUP);
892 time := SingleStat.GameTime / 1000;
893 kpm := SingleStat.PlayerStat[player].Kills;
894 if time > 0 then kpm := kpm / time * 60;
895 r_Common_DrawText(Format('%.1f', [kpm]), x + w1, y + 32, 255, 0, 0, 255, menufont, TBasePoint.BP_LEFTUP);
896 r_Common_DrawText(_lc[I_MENU_INTER_SECRETS], x, y + 64, 255, 255, 255, 255, menufont, TBasePoint.BP_LEFTUP);
897 r_Render_DrawValueOf(SingleStat.PlayerStat[player].Secrets, SingleStat.TotalSecrets, x + w1, y + 64, MenuFont);
898 end;
900 procedure r_Render_DrawSingleStats;
901 var xx, wa, wb, ww, ch: Integer; s: AnsiString;
902 begin
903 r_Common_DrawText(_lc[I_MENU_INTER_LEVEL_COMPLETE], gScreenWidth div 2, 32, 255, 255, 255, 255, menufont, TBasePoint.BP_UP);
905 r_Draw_GetTextSize(_lc[I_MENU_INTER_KPM] + ' ', menufont, wa, ch);
906 r_Draw_GetTextSize(' 9999.9', menufont, wb, ch);
907 ww := wa + wb;
908 xx := gScreenWidth div 2 - ww div 2;
910 s := r_Common_TimeToStr(SingleStat.GameTime);
911 r_Common_DrawText(_lc[I_MENU_INTER_TIME], xx, 80, 255, 255, 255, 255, menufont, TBasePoint.BP_LEFTUP);
912 r_Common_DrawText(s, xx + wa, 80, 255, 0, 0, 255, menufont, TBasePoint.BP_LEFTUP);
914 if SingleStat.TwoPlayers then
915 begin
916 r_Common_DrawText(_lc[I_MENU_PLAYER_1], gScreenWidth div 2, 128, 255, 255, 255, 255, menufont, TBasePoint.BP_UP);
917 r_Render_DrawSinglStatsPlayer(0, xx, 176, wa);
918 r_Common_DrawText(_lc[I_MENU_PLAYER_2], gScreenWidth div 2, 288, 255, 255, 255, 255, menufont, TBasePoint.BP_UP);
919 r_Render_DrawSinglStatsPlayer(1, xx, 336, wa);
920 end
921 else
922 begin
923 r_Render_DrawSinglStatsPlayer(0, xx, 128, wa);
924 end;
925 end;
927 procedure r_Render_DrawSpectHud;
928 var xoff: Integer; s: AnsiString;
930 procedure AddText (s1, s2: AnsiString);
931 var w1, w2, ww, ch: Integer;
932 begin
933 r_Draw_GetTextSize(s1, stdfont, w1, ch);
934 r_Draw_GetTextSize(s2, stdfont, w2, ch);
935 ww := MAX(w1, w2);
936 r_Common_DrawText(s1, xoff + ww div 2, gScreenHeight - ch, 255, 255, 255, 255, stdfont, TBasePoint.BP_DOWN);
937 r_Common_DrawText(s2, xoff + ww div 2, gScreenHeight - ch, 255, 255, 255, 255, stdfont, TBasePoint.BP_UP);
938 xoff := xoff + ww + 16;
939 end;
941 begin
942 xoff := 0;
943 case gSpectMode of
944 SPECT_STATS: s := 'MODE: Stats';
945 SPECT_MAPVIEW: s := 'MODE: Observe Map';
946 SPECT_PLAYERS: s := 'MODE: Watch Players';
947 otherwise s := 'MODE: ' + IntToStr(gSpectMode);
948 end;
949 AddText(s, '< jump >');
950 if gSpectMode = SPECT_STATS then
951 AddText('Autoview', '< fire >');
952 if gSpectMode = SPECT_MAPVIEW then
953 AddText('[-] Step ' + IntToStr(gSpectStep) + ' [+]', '<prev weap> <next weap>');
954 if gSpectMode = SPECT_PLAYERS then
955 begin
956 AddText('Player 1', '<left/right>');
957 if gSpectViewTwo then
958 AddText('Player 2', '<prev w/next w>');
959 AddText('2x View', '<up/down>');
960 end;
961 end;
963 function GetActivePlayer_ByID (id: Integer): TPlayer;
964 var i, len: Integer; p: TPlayer;
965 begin
966 p := nil;
967 if (id >= 0) and (gPlayers <> nil) then
968 begin
969 i := 0; len := Length(gPlayers);
970 while (i < len) and ((IsActivePlayer(gPlayers[i]) = false) or (gPlayers[i].UID <> id)) do INC(i);
971 if i < len then p := gPlayers[i];
972 end;
973 result := p;
974 end;
976 procedure r_Render_DrawMinimap (x, y: Integer; alpha: Byte);
977 const scale = 16;
979 function IsMinimapPanel (const p: TPanel): Boolean;
980 begin
981 result := (p <> nil) and p.Enabled;
982 if result then
983 begin
984 case p.PanelType of
985 PANEL_WALL, PANEL_WATER, PANEL_ACID1, PANEL_ACID2,
986 PANEL_STEP, PANEL_OPENDOOR, PANEL_CLOSEDOOR,
987 PANEL_LIFTUP, PANEL_LIFTDOWN, PANEL_LIFTLEFT, PANEL_LIFTRIGHT:
988 result := true;
989 otherwise
990 result := false;
991 end;
992 end;
993 end;
995 procedure DrawObject (xx, yy, ww, hh: Integer; r, g, b: Byte);
996 var x0, y0, x1, y1: Integer;
997 begin
998 x0 := x + xx div scale;
999 y0 := y + yy div scale;
1000 x1 := x + (xx + ww) div scale;
1001 y1 := y + (yy + hh) div scale;
1002 r_Draw_FillRect(x0, y0, x1, y1, r, g, b, alpha);
1003 end;
1005 procedure DrawPanels (const a: TPanelArray);
1006 var i: Integer; p: TPanel; c: TRGB;
1007 begin
1008 if a <> nil then
1009 begin
1010 for i := 0 to HIGH(a) do
1011 begin
1012 p := a[i];
1013 if IsMinimapPanel(p) then
1014 begin
1015 case p.PanelType of
1016 PANEL_WALL: c := _RGB(208, 208, 208);
1017 PANEL_OPENDOOR: c := _RGB(160, 160, 160);
1018 PANEL_CLOSEDOOR: c := _RGB(160, 160, 160);
1019 PANEL_STEP: c := _RGB(128, 128, 128);
1020 PANEL_LIFTUP, PANEL_LIFTDOWN, PANEL_LIFTLEFT, PANEL_LIFTRIGHT:
1021 case p.LiftType of
1022 LIFTTYPE_UP: c := _RGB(116, 72, 36);
1023 LIFTTYPE_DOWN: c := _RGB(116, 124, 96);
1024 LIFTTYPE_LEFT: c := _RGB(116, 200, 80);
1025 LIFTTYPE_RIGHT: c := _RGB(116, 252, 140);
1026 otherwise c := _RGB(255, 0, 0);
1027 end;
1028 PANEL_WATER: c := _RGB(0, 0, 192);
1029 PANEL_ACID1: c := _RGB(0, 176, 0);
1030 PANEL_ACID2: c := _RGB(176, 0, 0);
1031 otherwise c := _RGB(255, 0, 0);
1032 end;
1033 DrawObject(p.x, p.y, p.width, p.height, c.r, c.g, c.b);
1034 end;
1035 end;
1036 end;
1037 end;
1039 procedure DrawPlayers;
1040 var i: Integer; p: TPlayer; c: TRGB;
1041 begin
1042 if gPlayers <> nil then
1043 begin
1044 for i := 0 to HIGH(gPlayers) do
1045 begin
1046 p := gPlayers[i];
1047 if p.Alive then
1048 begin
1049 case p.Team of
1050 TEAM_RED: c := _RGB(255, 0, 0);
1051 TEAM_BLUE: c := _RGB(0, 0, 255);
1052 otherwise c := _RGB(255, 128, 0);
1053 end;
1054 DrawObject(p.obj.x, p.obj.y, p.obj.rect.width, p.obj.rect.height, c.r, c.g, c.b);
1055 end;
1056 end;
1057 end;
1058 end;
1060 function DrawMonster (m: TMonster): Boolean;
1061 begin
1062 result := false; // don't stop
1063 if m.alive then
1064 DrawObject(m.obj.x, m.obj.y, m.obj.rect.width, m.obj.rect.height, 255, 255, 0);
1065 end;
1067 begin
1068 r_Draw_FillRect(x, y, (x + gMapInfo.Width) div scale, (y + gMapInfo.Height) div scale, 0, 0, 0, alpha);
1069 DrawPanels(gSteps);
1070 DrawPanels(gLifts);
1071 DrawPanels(gWater);
1072 DrawPanels(gAcid1);
1073 DrawPanels(gAcid2);
1074 DrawPanels(gWalls);
1075 g_Mons_ForEach(DrawMonster);
1076 DrawPlayers;
1077 end;
1079 function GetScreenShotName (AsStats: Boolean): AnsiString;
1080 var dir, date: AnsiString;
1081 begin
1082 result := '';
1083 dir := e_GetWriteableDir(ScreenshotDirs);
1084 if dir <> '' then
1085 begin
1086 if AsStats then
1087 begin
1088 dir := e_CatPath(dir, 'stats'); (* TODO: use e_GetWriteableDir *)
1089 result := e_CatPath(dir, StatFilename + '.png');
1090 end
1091 else
1092 begin
1093 DateTimeToString(date, 'yyyy-mm-dd-hh-nn-ss', Now());
1094 result := e_CatPath(dir, 'screenshot-' + date + '.png');
1095 end;
1096 end;
1097 end;
1099 procedure SaveScreenShot (AsStats: Boolean);
1100 var img: TImageData; typ: GLenum; ok: Boolean; fname: AnsiString;
1101 begin
1102 ok := false;
1103 fname := GetScreenShotName(AsStats);
1104 if fname <> '' then
1105 begin
1106 if (gWinSizeX > 0) and (gWinSizeY > 0) then
1107 begin
1108 Imaging.SetOption(ImagingPNGPreFilter, 5);
1109 Imaging.SetOption(ImagingPNGCompressLevel, 5);
1110 InitImage(img);
1111 if NewImage(gWinSizeX, gWinSizeY, TImageFormat.ifA8R8G8B8, img) then
1112 begin
1113 {$IFDEF ENDIAN_LITTLE}
1114 typ := GL_UNSIGNED_INT_8_8_8_8_REV;
1115 {$ELSE}
1116 typ := GL_UNSIGNED_INT_8_8_8_8;
1117 {$ENDIF}
1118 glReadPixels(0, 0, gWinSizeX, gWinSizeY, GL_BGRA, typ, img.bits);
1119 if glGetError() = GL_NO_ERROR then
1120 begin
1121 if FlipImage(img) then
1122 begin
1123 ok := SaveImageToFile(fname, img);
1124 end;
1125 end;
1126 end;
1127 FreeImage(img);
1128 end;
1129 end;
1130 if ok then
1131 g_Console_Add(Format(_lc[I_CONSOLE_SCREENSHOT], [fname]))
1132 else
1133 g_Console_Add(Format(_lc[I_CONSOLE_ERROR_WRITE], [fname]));
1134 end;
1136 procedure r_Render_Draw;
1137 var p1, p2: TPlayer; time: LongWord; pw, ph, i, j: Integer;
1138 begin
1139 if gExit = EXIT_QUIT then
1140 exit;
1142 {$IFDEF ENABLE_SYSTEM}
1143 (* hack: if r_pixel_scale changed, reset menu and other things *)
1144 pw := Round(gWinSizeX / r_pixel_scale);
1145 ph := Round(gWinSizeY / r_pixel_scale);
1146 if (pw <> gScreenWidth) or (ph <> gScreenHeight) then
1147 if assigned(sys_ScreenResize) then
1148 sys_ScreenResize(gWinSizeX, gWinSizeY);
1149 {$ENDIF}
1151 INC(FPSCounter);
1152 time := GetTickCount64();
1153 if time - FPSTime >= 1000 then
1154 begin
1155 FPS := FPSCounter;
1156 FPSCounter := 0;
1157 FPSTime := time;
1158 end;
1160 r_Draw_Setup(gWinSizeX, gWinSizeY, gScreenWidth, gScreenHeight);
1162 glClearColor(0.0, 0.0, 0.0, 0.0);
1163 glClear(GL_COLOR_BUFFER_BIT);
1165 p1 := nil;
1166 p2 := nil;
1167 if gGameOn or (gState = STATE_FOLD) then
1168 begin
1169 if (gPlayer1 <> nil) and (gPlayer2 <> nil) then
1170 begin
1171 if gRevertPlayers then
1172 begin
1173 p1 := gPlayer2;
1174 p2 := gPlayer1;
1175 end
1176 else
1177 begin
1178 p1 := gPlayer1;
1179 p2 := gPlayer2;
1180 end;
1181 end
1182 else if gPlayer1 <> nil then
1183 begin
1184 p1 := gPlayer1;
1185 end
1186 else if gPlayer2 <> nil then
1187 begin
1188 p1 := gPlayer2;
1189 end;
1190 if (gSpectMode = SPECT_PLAYERS) and (gPlayers <> nil) then
1191 begin
1192 p1 := GetActivePlayer_ByID(gSpectPID1);
1193 if p1 = nil then
1194 p1 := GetActivePlayer_ByID(GetActivePlayerID_Next());
1195 if gSpectViewTwo then
1196 begin
1197 p2 := GetActivePlayer_ByID(gSpectPID2);
1198 if p2 = nil then
1199 p2 := GetActivePlayer_ByID(GetActivePlayerID_Next());
1200 end;
1201 end;
1202 end;
1204 if gGameOn or ((gState in [STATE_FOLD]) and (EndingGameCounter < 255)) then
1205 begin
1206 if gSpectMode = SPECT_MAPVIEW then
1207 begin
1208 r_Render_DrawMapView(0, 0, gScreenWidth, gScreenHeight, gSpectX + gScreenWidth div 2, gSpectY + gScreenHeight div 2);
1209 end
1210 else if (p1 <> nil) and (p2 <> nil) then
1211 begin
1212 r_Render_DrawPlayerView(0, 0, gScreenWidth, gScreenHeight div 2 - 2, p1);
1213 r_Render_DrawPlayerView(0, gScreenHeight div 2 + 2, gScreenWidth, gScreenHeight div 2, p2);
1214 end
1215 else if p1 <> nil then
1216 begin
1217 r_Render_DrawPlayerView(0, 0, gScreenWidth, gScreenHeight, p1);
1218 end
1219 else if p2 <> nil then
1220 begin
1221 r_Render_DrawPlayerView(0, 0, gScreenWidth, gScreenHeight, p2);
1222 end;
1224 if gShowMap then
1225 r_Render_DrawMiniMap(0, 0, 160);
1227 {$IFDEF ENABLE_HOLMES}
1228 r_Holmes_Draw;
1229 {$ENDIF}
1231 if MessageText <> '' then
1232 r_Common_DrawFormatText(MessageText, (gScreenWidth - 196) div 2, gScreenHeight div 2, 255, menufont, TBasePoint.BP_CENTER);
1234 if IsDrawStat or (gSpectMode = SPECT_STATS) then
1235 r_Render_DrawStats;
1237 if gSpectHUD and (gChatShow = false) and (gSpectMode <> SPECT_NONE) and (gSpectAuto = false) then
1238 r_Render_DrawSpectHud;
1239 end;
1241 if gPauseMain and gGameOn {$IFDEF ENABLE_MENU}and (g_ActiveWindow = nil){$ENDIF} then
1242 begin
1243 r_Draw_FillRect(0, 0, gScreenWidth, gScreenHeight, 0, 0, 0, 105);
1244 r_Common_DrawText(_lc[I_MENU_PAUSE], gScreenWidth div 2, gScreenHeight div 2, 255, 255, 255, 255, menufont, TBasePoint.BP_CENTER);
1245 end;
1247 if not gGameOn then
1248 begin
1249 // TODO F key handle
1250 case gState of
1251 STATE_NONE: (* do nothing *) ;
1252 STATE_MENU:
1253 begin
1254 r_Common_DrawBackground(GameWad + ':TEXTURES/TITLE');
1255 {$IFDEF ENABLE_MENU}
1256 if g_ActiveWindow <> nil then
1257 r_Draw_FillRect(0, 0, gScreenWidth, gScreenHeight, 0, 0, 0, 105);
1258 {$ENDIF}
1259 end;
1260 STATE_FOLD:
1261 begin
1262 if EndingGameCounter > 0 then
1263 r_Draw_FillRect(0, 0, gScreenWidth, gScreenHeight, 0, 0, 0, MIN(MAX(255 - EndingGameCounter, 0), 255));
1264 end;
1265 STATE_INTERCUSTOM:
1266 begin
1267 if gLastMap and (gGameSettings.GameMode = GM_COOP) then
1268 if EndPicPath <> '' then
1269 r_Common_DrawBackground(EndPicPath)
1270 else
1271 r_Common_DrawBackground(GameWad + ':TEXTURES/' + _lc[I_TEXTURE_ENDPIC])
1272 else
1273 r_Common_DrawBackground(GameWad + ':TEXTURES/INTER');
1275 r_Render_DrawCustomStats;
1277 {$IFDEF ENABLE_MENU}
1278 if g_ActiveWindow <> nil then
1279 r_Draw_FillRect(0, 0, gScreenWidth, gScreenHeight, 0, 0, 0, 105);
1280 {$ENDIF}
1281 end;
1282 STATE_INTERSINGLE, STATE_INTERTEXT, STATE_INTERPIC:
1283 begin
1284 if EndingGameCounter > 0 then
1285 begin
1286 r_Draw_FillRect(0, 0, gScreenWidth, gScreenHeight, 0, 0, 0, MIN(MAX(255 - EndingGameCounter, 0), 255));
1287 end
1288 else
1289 begin
1290 r_Common_DrawBackground(GameWad + ':TEXTURES/INTER');
1291 r_Render_DrawSingleStats;
1292 {$IFDEF ENABLE_MENU}
1293 if g_ActiveWindow <> nil then
1294 r_Draw_FillRect(0, 0, gScreenWidth, gScreenHeight, 0, 0, 0, 105);
1295 {$ENDIF}
1296 end;
1297 end;
1298 STATE_ENDPIC:
1299 begin
1300 if EndPicPath <> '' then
1301 r_Common_DrawBackground(EndPicPath)
1302 else
1303 r_Common_DrawBackground(GameWad + ':TEXTURES/' + _lc[I_TEXTURE_ENDPIC]);
1304 {$IFDEF ENABLE_MENU}
1305 if g_ActiveWindow <> nil then
1306 r_Draw_FillRect(0, 0, gScreenWidth, gScreenHeight, 0, 0, 0, 105);
1307 {$ENDIF}
1308 end;
1309 STATE_SLIST:
1310 begin
1311 r_Common_DrawBackground(GameWad + ':TEXTURES/TITLE');
1312 r_Draw_FillRect(0, 0, gScreenWidth, gScreenHeight, 0, 0, 0, 105);
1313 r_Render_DrawServerList(slCurrent, slTable);
1314 end;
1315 end;
1316 end;
1318 {$IFDEF ENABLE_MENU}
1319 if g_ActiveWindow <> nil then
1320 begin
1321 if gGameOn then
1322 r_Draw_FillRect(0, 0, gScreenWidth, gScreenHeight, 0, 0, 0, 105);
1323 r_GUI_Draw_Window(g_ActiveWindow);
1324 end;
1325 {$ENDIF}
1327 r_Console_Draw(false);
1329 if DebugSound and gGameOn then
1330 begin
1331 for i := 0 to High(e_SoundsArray) do
1332 for j := 0 to e_SoundsArray[i].nRefs do
1333 r_Draw_FillRect(i + 100, j + 100, i + 100 + 1, j + 100 + 1, 255, 0, 0, 255);
1334 end;
1336 if gShowFPS then
1337 begin
1338 r_Common_DrawText('FPS: ' + IntToStr(FPS), 0, 0, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
1339 r_Common_DrawText('UPS: ' + IntToStr(UPS), 0, 16, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
1340 end;
1342 if gGameOn and gShowTime then
1343 begin
1344 r_Common_DrawText(r_Common_TimeToStr(gTime), gScreenWidth - 4, gScreenHeight - 1, 255, 255, 255, 255, stdfont, TBasePoint.BP_RIGHTDOWN);
1345 end;
1347 // TODO draw profilers
1349 {$IFDEF ENABLE_HOLMES}
1350 r_Holmes_DrawUI;
1351 {$ENDIF}
1353 {$IFDEF ENABLE_TOUCH}
1354 glScalef(1 / r_pixel_scale, 1 / r_pixel_scale, 0);
1355 r_Touch_Draw;
1356 {$ENDIF}
1358 if TakeScreenShot then
1359 begin
1360 SaveScreenShot(false);
1361 TakeScreenShot := false;
1362 end;
1364 (* take stats screenshot immediately after the first frame of the stats showing *)
1365 if gScreenshotStats and (StatShotDone = false) and (Length(CustomStat.PlayerStat) > 1) then
1366 begin
1367 SaveScreenShot(true);
1368 StatShotDone := true;
1369 end;
1371 sys_Repaint;
1372 end;
1374 procedure r_Render_Resize (w, h: Integer);
1375 begin
1376 gWinSizeX := w;
1377 gWinSizeY := h;
1378 gRC_Width := w;
1379 gRC_Height := h;
1380 gScreenWidth := Round(w / r_pixel_scale);
1381 gScreenHeight := Round(h / r_pixel_scale);
1382 end;
1384 procedure r_Render_Apply;
1385 begin
1386 {$IFDEF ENABLE_SYSTEM}
1387 if sys_SetDisplayModeGL(GetInfo()) then
1388 e_LogWriteln('resolution changed')
1389 else
1390 e_LogWriteln('resolution not changed');
1391 sys_EnableVSync(gVSync);
1392 {$ENDIF}
1393 {$IFDEF NOGL_INIT}
1394 nogl_Init;
1395 {$ENDIF}
1396 end;
1398 procedure r_Render_RequestScreenShot;
1399 begin
1400 TakeScreenShot := true;
1401 end;
1403 {$IFDEF ENABLE_GIBS}
1404 function r_Render_GetGibRect (m, id: Integer): TRectWH;
1405 begin
1406 result := r_Map_GetGibSize(m, id);
1407 end;
1408 {$ENDIF}
1410 {$IFDEF ENABLE_GFX}
1411 procedure r_Render_QueueEffect (AnimType, X, Y: Integer);
1412 begin
1413 r_Map_NewGFX(AnimType, X, Y);
1414 end;
1415 {$ENDIF}
1417 {$IFDEF ENABLE_TOUCH}
1418 procedure r_Render_GetKeyRect (key: Integer; out x, y, w, h: Integer; out founded: Boolean);
1419 begin
1420 r_Touch_GetKeyRect(key, x, y, w, h, founded)
1421 end;
1422 {$ENDIF}
1424 {$IFDEF ENABLE_MENU}
1425 procedure r_Render_GetControlSize (ctrl: TGUIControl; out w, h: Integer);
1426 begin
1427 r_GUI_GetSize(ctrl, w, h);
1428 end;
1430 procedure r_Render_GetLogoSize (out w, h: Integer);
1431 begin
1432 r_GUI_GetLogoSize(w, h);
1433 end;
1435 procedure r_Render_GetMaxFontSize (BigFont: Boolean; out w, h: Integer);
1436 begin
1437 r_GUI_GetMaxFontSize(BigFont, w, h);
1438 end;
1440 procedure r_Render_GetStringSize (BigFont: Boolean; str: String; out w, h: Integer);
1441 begin
1442 r_GUI_GetStringSize(BigFont, str, w, h);
1443 end;
1444 {$ENDIF}
1446 procedure r_Render_SetProcessLoadingCallback (p: TProcedure);
1447 begin
1448 r_Common_ProcessLoadingCallback := p;
1449 end;
1451 procedure r_Render_ClearLoading;
1452 begin
1453 r_Common_ClearLoading;
1454 end;
1456 procedure r_Render_SetLoading (const text: String; maxval: Integer);
1457 begin
1458 r_Common_SetLoading(text, maxval);
1459 end;
1461 procedure r_Render_StepLoading (incval: Integer);
1462 begin
1463 r_Common_StepLoading(incval);
1464 end;
1466 procedure r_Render_DrawLoading (force: Boolean);
1467 begin
1468 r_Common_DrawLoading(force);
1469 end;
1471 {$IFDEF ENABLE_HOLMES}
1472 function pmsCurMapX (): Integer;
1473 begin
1474 result := r_holmes.pmsCurMapX();
1475 end;
1477 function pmsCurMapY (): Integer;
1478 begin
1479 result := r_holmes.pmsCurMapY();
1480 end;
1482 function r_Render_HolmesViewIsSet (): Boolean;
1483 begin
1484 result := vpSet;
1485 end;
1486 {$ENDIF}
1488 begin
1489 conRegVar('d_sounds', @DebugSound, '', '');
1490 DebugSound := false;
1491 end.