summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e887dc5)
raw | patch | inline | side by side (parent: e887dc5)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 17 May 2018 16:21:23 +0000 (19:21 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 17 May 2018 16:22:36 +0000 (19:22 +0300) |
src/game/g_console.pas | patch | blob | history | |
src/game/g_game.pas | patch | blob | history |
diff --git a/src/game/g_console.pas b/src/game/g_console.pas
index 2f3103a014017aa3e0fe150310f4624f953caf15..7b68cce099b4130ca24d2a779501b32caecef2be 100644 (file)
--- a/src/game/g_console.pas
+++ b/src/game/g_console.pas
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;
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;
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 1923452907701501d2b724eddef191b6aeb3028e..5ecf971a519062e9917cd5ce0038164723bd8258 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
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:
//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;
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;
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.