DEADSOFTWARE

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