diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 14819e284ce75d894275691a2df17ee83f2f15a9..d6a3eb2472986ccc5ab587367f81618573eeceae 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
P2MoveButton: Byte = 0;
g_profile_frame_update: Boolean = false;
- g_profile_frame_draw: Boolean = true;
+ g_profile_frame_draw: Boolean = false;
+ g_profile_collision: Boolean = false;
procedure g_ResetDynlights ();
procedure g_AddDynLight (x, y, radius: Integer; r, g, b, a: Single);
*)
-procedure drawProfiles (x, y: Integer; prof: TProfiler);
+function calcProfilesHeight (prof: TProfiler): Integer;
+begin
+ result := 0;
+ if (prof = nil) then exit;
+ if (length(prof.bars) = 0) then exit;
+ result := length(prof.bars)*(16+2);
+end;
+
+// returns width
+function drawProfiles (x, y: Integer; prof: TProfiler): Integer;
var
wdt, hgt: Integer;
yy: Integer;
ii, idx: Integer;
begin
+ result := 0;
if (prof = nil) then exit;
// gScreenWidth
if (length(prof.bars) = 0) then exit;
wdt := 192;
- hgt := length(prof.bars)*(16+2);
+ hgt := calcProfilesHeight(prof);
if (x < 0) then x := gScreenWidth-(wdt-1)+x;
if (y < 0) then y := gScreenHeight-(hgt-1)+y;
// background
e_TextureFontPrintEx(x+2+4*prof.bars[ii].level, yy, Format('%s: %d', [prof.bars[ii].name, prof.bars[ii].value]), gStdFont, 255, 255, 0, 1, false);
Inc(yy, 16+2);
end;
+ result := wdt;
end;
p.DrawGUI();
end;
+procedure drawProfilers ();
+var
+ px: Integer = -1;
+begin
+ if g_profile_frame_draw then px := px-drawProfiles(px, -1, profileFrameDraw);
+ if g_profile_collision then px := px-drawProfiles(px, -1, profMapCollision);
+end;
+
procedure g_Game_Draw();
var
ID: DWORD;
Format('%d:%.2d:%.2d', [gTime div 1000 div 3600, (gTime div 1000 div 60) mod 60, gTime div 1000 mod 60]),
gStdFont);
- if g_profile_frame_draw then drawProfiles(-1, -1, profileFrameDraw); //drawProfiles(-1, -1, 'MAP RENDER');
+ drawProfilers();
end;
procedure g_Game_Quit();
procedure ProfilerCommands (P: SArray);
var
cmd: string;
+
+ function getBool (idx: Integer): Integer;
+ begin
+ if (idx < 0) or (idx > High(P)) then begin result := -1; exit; end;
+ result := 0;
+ if (P[idx] = '1') or (P[idx] = 'on') or (P[idx] = 'true') or (P[idx] = 'tan') then result := 1;
+ end;
+
begin
//if not gDebugMode then exit;
cmd := LowerCase(P[0]);
g_profile_frame_update := not g_profile_frame_update;
exit;
end;
+ if cmd = 'dpc' then
+ begin
+ g_profile_collision := not g_profile_collision;
+ exit;
+ end;
+ if cmd = 'r_gridrender' then
+ begin
+ case getBool(1) of
+ -1: begin end;
+ 0: gdbg_map_use_grid_render := false;
+ 1: gdbg_map_use_grid_render := true;
+ end;
+ if gdbg_map_use_grid_render then g_Console_Add('grid rendering: tan') else g_Console_Add('grid rendering: ona');
+ exit;
+ end;
+ if cmd = 'dbg_coldet_grid' then
+ begin
+ case getBool(1) of
+ -1: begin end;
+ 0: gdbg_map_use_grid_coldet := false;
+ 1: gdbg_map_use_grid_coldet := true;
+ end;
+ if gdbg_map_use_grid_coldet then g_Console_Add('grid coldet: tan') else g_Console_Add('grid coldet: ona');
+ exit;
+ end;
end;
procedure DebugCommands(P: SArray);
begin
Parse_Params(pars);
+ s := Find_Param_Value(pars, '--profile-frame');
+ if (s <> '') then g_profile_frame_draw := true;
+
+ s := Find_Param_Value(pars, '--profile-coldet');
+ if (s <> '') then g_profile_collision := true;
+
// Debug mode:
s := Find_Param_Value(pars, '--debug');
if (s <> '') then