From de40ee608b5563a84872642f7fbae6ee8e4b635d Mon Sep 17 00:00:00 2001 From: Ketmar Dark Date: Thu, 17 May 2018 19:21:23 +0300 Subject: [PATCH] added "r_smallmap_align_h" and "r_smallmap_align_v" cvars --- src/game/g_console.pas | 55 ++++++++++++++++++++++++++++++++++++++++++ src/game/g_game.pas | 36 +++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/src/game/g_console.pas b/src/game/g_console.pas index 2f3103a..7b68cce 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -42,6 +42,7 @@ procedure g_Console_Chat_Switch (team: Boolean=false); procedure conRegVar (const conname: AnsiString; pvar: PBoolean; const ahelp: AnsiString; const amsg: AnsiString; acheat: Boolean=false; ahidden: Boolean=false); overload; procedure conRegVar (const conname: AnsiString; pvar: PSingle; amin, amax: Single; const ahelp: AnsiString; const amsg: AnsiString; acheat: Boolean=false; ahidden: Boolean=false); overload; +procedure conRegVar (const conname: AnsiString; pvar: PInteger; const ahelp: AnsiString; const amsg: AnsiString; acheat: Boolean=false; ahidden: Boolean=false); overload; // poor man's floating literal parser; i'm sorry, but `StrToFloat()` sux cocks function conParseFloat (var res: Single; const s: AnsiString): Boolean; @@ -192,6 +193,41 @@ begin end; +procedure intVarHandler (me: PCommand; p: SSArray); + procedure binaryFlag (var flag: Boolean; msg: AnsiString); + begin + if (Length(p) > 2) then + begin + conwritefln('too many arguments to ''%s''', [p[0]]); + end + else + begin + case conGetBoolArg(p, 1) of + -1: begin end; + 0: if not me.cheat or conIsCheatsEnabled then flag := false else begin conwriteln('not available'); exit; end; + 1: if not me.cheat or conIsCheatsEnabled then flag := true else begin conwriteln('not available'); exit; end; + 666: if not me.cheat or conIsCheatsEnabled then flag := not flag else begin conwriteln('not available'); exit; end; + end; + if (Length(msg) = 0) then msg := p[0] else msg += ':'; + if flag then conwritefln('%s tan', [msg]) else conwritefln('%s ona', [msg]); + end; + end; +begin + if (Length(p) <> 2) then + begin + conwritefln('%s %d', [me.cmd, PInteger(me.ptr)^]); + end + else + begin + try + PInteger(me.ptr)^ := StrToInt(p[1]); + except + conwritefln('invalid integer value: "%s"', [p[1]]); + end; + end; +end; + + procedure conRegVar (const conname: AnsiString; pvar: PBoolean; const ahelp: AnsiString; const amsg: AnsiString; acheat: Boolean=false; ahidden: Boolean=false); overload; var f: Integer; @@ -211,6 +247,25 @@ begin end; +procedure conRegVar (const conname: AnsiString; pvar: PInteger; const ahelp: AnsiString; const amsg: AnsiString; acheat: Boolean=false; ahidden: Boolean=false); overload; +var + f: Integer; + cp: PCommand; +begin + f := Length(commands); + SetLength(commands, f+1); + cp := @commands[f]; + cp.cmd := LowerCase(conname); + cp.proc := nil; + cp.procEx := intVarHandler; + cp.help := ahelp; + cp.hidden := ahidden; + cp.ptr := pvar; + cp.msg := amsg; + cp.cheat := acheat; +end; + + // ////////////////////////////////////////////////////////////////////////// // type PVarSingle = ^TVarSingle; diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 1923452..5ecf971 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -315,6 +315,8 @@ var gChatSounds: Array of TChatSound; g_dbg_ignore_bounds: Boolean = false; + r_smallmap_h: Integer = 0; // 0: left; 1: center; 2: right + r_smallmap_v: Integer = 0; // 0: top; 1: center; 2: bottom // move button values: // bits 0-1: l/r state: @@ -3342,6 +3344,7 @@ begin //conwritefln('OLD: (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]); fixViewportForScale(); //conwritefln(' (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]); + if (g_dbg_scale <> 1.0) and (not g_dbg_ignore_bounds) then begin if (sX+sWidth > gMapInfo.Width) then sX := gMapInfo.Width-sWidth; @@ -3352,6 +3355,36 @@ begin if (gBackSize.X <= gPlayerScreenSize.X) or (gMapInfo.Width <= sWidth) then c := 0 else c := trunc((gBackSize.X-gPlayerScreenSize.X)*sX/(gMapInfo.Width-sWidth)); if (gBackSize.Y <= gPlayerScreenSize.Y) or (gMapInfo.Height <= sHeight) then d := 0 else d := trunc((gBackSize.Y-gPlayerScreenSize.Y)*sY/(gMapInfo.Height-sHeight)); end; + + //r_smallmap_h: 0: left; 1: center; 2: right + //r_smallmap_v: 0: top; 1: center; 2: bottom + // horiz small map? + if (gMapInfo.Width = sWidth) then + begin + sX := 0; + end + else if (gMapInfo.Width < sWidth) then + begin + case r_smallmap_h of + 1: sX := -((sWidth-gMapInfo.Width) div 2); // center + 2: sX := -(sWidth-gMapInfo.Width); // right + else sX := 0; // left + end; + end; + // vert small map? + if (gMapInfo.Height = sHeight) then + begin + sY := 0; + end + else if (gMapInfo.Height < sHeight) then + begin + case r_smallmap_v of + 1: sY := -((sHeight-gMapInfo.Height) div 2); // center + 2: sY := -(sHeight-gMapInfo.Height); // bottom + else sY := 0; // top + end; + end; + p.viewPortX := sX; p.viewPortY := sY; p.viewPortW := sWidth; @@ -7563,4 +7596,7 @@ begin conRegVar('light_enabled', @gwin_k8_enable_light_experiments, 'enable/disable dynamic lighting', 'lighting'); conRegVar('light_player_halo', @g_playerLight, 'enable/disable player halo', 'player light halo'); + + conRegVar('r_smallmap_align_h', @r_smallmap_h, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps'); + conRegVar('r_smallmap_align_v', @r_smallmap_v, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps'); end. -- 2.29.2