Skip to content

Commit

Permalink
Displays statistics in automap (Doom branch)
Browse files Browse the repository at this point in the history
  • Loading branch information
jval1972 committed May 1, 2022
1 parent 95616a7 commit ab2e696
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 2 deletions.
130 changes: 130 additions & 0 deletions Doom/hu_stuff.pas
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ function HU_FPS: integer;
var
drawfps: boolean;
drawcrosshair: boolean;
amdrawstats: boolean;

implementation

Expand All @@ -194,6 +195,7 @@ implementation
r_draw,
r_main,
s_sound,
st_stuff,
sounddata,
v_data,
v_video;
Expand Down Expand Up @@ -786,6 +788,131 @@ procedure HU_DrawDemoProgress;
Z_ChangeTag(dp, PU_CACHE);
end;

var
lump_trn: Integer = -2;

//==============================================================================
//
// HU_WriteText
// Write a string using the hu_font, use white for numeric characters
//
//==============================================================================
function HU_WriteText(x, y: integer; const str: string; const highlightnums: boolean = false): menupos_t;
var
w: integer;
ch: integer;
c: integer;
currchar: char;
cx: integer;
cy: integer;
len: integer;
oldtranslation, newtranslation: PByteArray;
dowhite: boolean;
begin
len := Length(str);
if len = 0 then
begin
result.x := x;
result.y := y;
exit;
end;

ch := 1;
cx := x;
cy := y;

if lump_trn < 0 then
lump_trn := W_GetNumForName('TRN_MENU');

oldtranslation := v_translation;
newtranslation := W_CacheLumpNum(lump_trn, PU_STATIC);

dowhite := False;

while true do
begin
if ch > len then
break;

currchar := str[ch];
c := Ord(currchar);
inc(ch);

if highlightnums then
dowhite := dowhite or (currchar in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']);

if c = 0 then
break;

if c = 10 then
begin
cx := x;
continue;
end;

if c = 13 then
begin
cy := cy + 12;
continue;
end;

c := Ord(toupper(Chr(c))) - Ord(HU_FONTSTART);
if (c < 0) or (c >= HU_FONTSIZE) then
begin
cx := cx + 4;
continue;
end;

w := hu_font[c].width;
if (cx + w) > 320 then
break;

if dowhite then
v_translation := newtranslation
else
v_translation := oldtranslation;

V_DrawPatch(cx, cy, SCN_FG, hu_font[c], true);

cx := cx + w;
end;

Z_ChangeTag(newtranslation, PU_CACHE);
v_translation := oldtranslation;

result.x := cx;
result.y := cy;
end;

procedure HU_DrawAMStats;
const
XOFFS = 320 - 2;
YOFFS = ST_Y - 1;
var
s1, s2, s3: string;
x, y: integer;
begin
if not amdrawstats then
exit;

if plr = nil then
exit;

sprintf(s1, 'Kills: %d/%d', [plr.killcount, totalkills]);
sprintf(s2, 'Items: %d/%d', [plr.itemcount, totalitems]);
sprintf(s3, 'Secrets: %d/%d', [plr.secretcount, totalsecret]);

x := XOFFS - Max3I(M_StringWidth(s1), M_StringWidth(s2), M_StringWidth(s3));
y := YOFFS - M_StringHeight(s3);
HU_WriteText(x, y, s3, True);

y := y - M_StringHeight(s2);
HU_WriteText(x, y, s2, True);

y := y - M_StringHeight(s1);
HU_WriteText(x, y, s1, True);
end;

//==============================================================================
//
// HU_Drawer
Expand Down Expand Up @@ -841,6 +968,9 @@ procedure HU_Drawer;
HUlib_addCharToTextLine(@w_leveltime, lt[i]);
HUlib_drawTextLine(@w_leveltime, false);
HUlib_drawTextLine(@w_title, false);

// JVAL: 20220501 - Draw automap stats (https://www.doomworld.com/forum/topic/92113-delphidoom-207734-udmf-umapinfo-mbf21-apr-28-2022/?do=findComment&comment=2488715)
HU_DrawAMStats;
end;
end;

Expand Down
11 changes: 10 additions & 1 deletion Doom/m_defs.pas
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ default_t = record
Pdefault_t = ^default_t;

const
NUMDEFAULTS = {$IFDEF FPC}230{$ELSE}232{$ENDIF};
NUMDEFAULTS = {$IFDEF FPC}231{$ELSE}233{$ENDIF};

// JVAL
// Note: All setable defaults must be in lowercase, don't ask why. Just do it. :)
Expand Down Expand Up @@ -1082,6 +1082,15 @@ default_t = record
defaultbvalue: false;
_type: tInteger),

(name: 'amdrawstats';
location: @amdrawstats;
oldlocation: nil;
setable: DFS_ALWAYS;
defaultsvalue: '';
defaultivalue: 1;
defaultbvalue: true;
_type: tBoolean),

// Textures
(name: 'Textures';
location: nil;
Expand Down
2 changes: 1 addition & 1 deletion Doom32.dof
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Conditionals=DOOM;OPTIMIZE_FOR_SPEED;
DebugSourceDirs=.\Base\;F:\DelphiDoom_Release\DelphiDoom_Src\Src\Doom\
UsePackages=0
[Parameters]
RunParams=oldbinfiles\Hellbnd.wad oldbinfiles\HBFM29.wad
RunParams=-iwad doomu.wad
HostApplication=
Launcher=
UseLauncher=0
Expand Down
1 change: 1 addition & 0 deletions Doom_what's new.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Fix problem when starting from different folder than the executable. (https://ww
Fixed crash when enter automap mode in certain screen resolutions. (https://www.doomworld.com/forum/topic/92113-delphidoom-207734-udmf-umapinfo-mbf21-apr-28-2022/?do=findComment&comment=2488715)
Fixed drawing problem in OpenGL mode when changing screen resolution.
Improved overlay drawing accuracy in hi-res.
Displays statistics in automap.

Version 2.0.7 build 734 - (20220428)
-----------------------
Expand Down

0 comments on commit ab2e696

Please sign in to comment.