DEADSOFTWARE

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