summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8213065)
raw | patch | inline | side by side (parent: 8213065)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 3 Sep 2017 01:28:19 +0000 (04:28 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 3 Sep 2017 01:29:31 +0000 (04:29 +0300) |
src/game/g_console.pas | patch | blob | history | |
src/game/g_holmes.pas | patch | blob | history | |
src/game/g_holmes_ui.inc | patch | blob | history | |
src/game/g_window.pas | patch | blob | history |
diff --git a/src/game/g_console.pas b/src/game/g_console.pas
index e0f401deeade15964e5c93c103ecebfa6065088c..6cd897c6d6992237ceedbab3105922cd0f5b2e65 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); overload;
procedure conRegVar (const conname: AnsiString; pvar: PSingle; amin, amax: Single; const ahelp: AnsiString; const amsg: AnsiString; acheat: 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;
+
var
gConsoleShow: Boolean = false; // True - êîíñîëü îòêðûòà èëè îòêðûâàåòñÿ
end;
+// poor man's floating literal parser; i'm sorry, but `StrToFloat()` sux cocks
+function conParseFloat (var res: Single; const s: AnsiString): Boolean;
+var
+ pos: Integer = 1;
+ frac: Single = 1;
+ slen: Integer;
+begin
+ result := false;
+ res := 0;
+ slen := Length(s);
+ while (slen > 0) and (s[slen] <= ' ') do Dec(slen);
+ while (pos <= slen) and (s[pos] <= ' ') do Inc(pos);
+ if (pos > slen) then exit;
+ if (slen-pos = 1) and (s[pos] = '.') then exit; // single dot
+ // integral part
+ while (pos <= slen) do
+ begin
+ if (s[pos] < '0') or (s[pos] > '9') then break;
+ res := res*10+Byte(s[pos])-48;
+ Inc(pos);
+ end;
+ if (pos <= slen) then
+ begin
+ // must be a dot
+ if (s[pos] <> '.') then exit;
+ Inc(pos);
+ while (pos <= slen) do
+ begin
+ if (s[pos] < '0') or (s[pos] > '9') then break;
+ frac := frac/10;
+ res += frac*(Byte(s[pos])-48);
+ Inc(pos);
+ end;
+ end;
+ if (pos <= slen) then exit; // oops
+ result := true;
+end;
+
+
// ////////////////////////////////////////////////////////////////////////// //
// <0: no arg; 0/1: true/false; 666: toggle
function conGetBoolArg (p: SArray; idx: Integer): Integer;
begin
case conGetBoolArg(p, 1) of
-1: begin end;
- 0: if conIsCheatsEnabled then flag := false else begin conwriteln('not available'); exit; end;
- 1: if conIsCheatsEnabled then flag := true else begin conwriteln('not available'); exit; end;
- 666: if conIsCheatsEnabled then flag := not flag else begin conwriteln('not available'); exit; 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 flag then conwritefln('%s: tan', [msg]) else conwritefln('%s: ona', [msg]);
end;
procedure singleVarHandler (me: PCommand; p: SArray);
- // poor man's floating literal parser; i'm sorry, but `StrToFloat()` sux cocks
- function parseFloat (var res: Single; const s: AnsiString): Boolean;
- var
- pos: Integer = 1;
- frac: Single = 1;
- slen: Integer;
- begin
- result := false;
- res := 0;
- slen := Length(s);
- while (slen > 0) and (s[slen] <= ' ') do Dec(slen);
- while (pos <= slen) and (s[pos] <= ' ') do Inc(pos);
- if (pos > slen) then exit;
- if (slen-pos = 1) and (s[pos] = '.') then exit; // single dot
- // integral part
- while (pos <= slen) do
- begin
- if (s[pos] < '0') or (s[pos] > '9') then break;
- res := res*10+Byte(s[pos])-48;
- Inc(pos);
- end;
- if (pos <= slen) then
- begin
- // must be a dot
- if (s[pos] <> '.') then exit;
- Inc(pos);
- while (pos <= slen) do
- begin
- if (s[pos] < '0') or (s[pos] > '9') then break;
- frac := frac/10;
- res += frac*(Byte(s[pos])-48);
- Inc(pos);
- end;
- end;
- if (pos <= slen) then exit; // oops
- result := true;
- end;
var
pv: PVarSingle;
nv: Single;
pv := PVarSingle(me.ptr);
if (Length(p) = 2) then
begin
- if not conIsCheatsEnabled then begin conwriteln('not available'); exit; end;
+ if me.cheat and (not conIsCheatsEnabled) then begin conwriteln('not available'); exit; end;
if (CompareText(p[1], 'default') = 0) or (CompareText(p[1], 'def') = 0) or
(CompareText(p[1], 'd') = 0) or (CompareText(p[1], 'off') = 0) or
(CompareText(p[1], 'ona') = 0) then
end
else
begin
- if not parseFloat(nv, p[1]) then
+ if not conParseFloat(nv, p[1]) then
begin
conwritefln('%s: ''%s'' doesn''t look like a floating number', [p[0], p[1]]);
exit;
diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas
index 570a1d99565d7d6e547b6418880d14011c80b86b..9f98ca3172d7c9588605a5d5115aebe4db45f114 100644 (file)
--- a/src/game/g_holmes.pas
+++ b/src/game/g_holmes.pas
var
g_holmes_enabled: Boolean = {$IF DEFINED(D2F_DEBUG)}true{$ELSE}false{$ENDIF};
+ g_holmes_ui_scale: Single = 1.0;
implementation
// ////////////////////////////////////////////////////////////////////////// //
function g_Holmes_MouseEvent (var ev: THMouseEvent): Boolean;
+var
+ he: THMouseEvent;
begin
holmesInitCommands();
holmesInitBinds();
result := true;
- msX := ev.x;
- msY := ev.y;
+ msX := trunc(ev.x/g_holmes_ui_scale);
+ msY := trunc(ev.y/g_holmes_ui_scale);
msB := ev.bstate;
kbS := ev.kstate;
msB := msB;
- if not uiMouseEvent(ev) then plrDebugMouse(ev);
+ he := ev;
+ he.x := trunc(he.x/g_holmes_ui_scale);
+ he.y := trunc(he.y/g_holmes_ui_scale);
+ if not uiMouseEvent(he) then plrDebugMouse(he);
end;
procedure g_Holmes_DrawUI ();
begin
{$IF not DEFINED(HEADLESS)}
+ glPushMatrix();
+ glScalef(g_holmes_ui_scale, g_holmes_ui_scale, 1.0);
uiDraw();
drawCursor();
+ glPopMatrix();
{$ENDIF}
end;
end;
+begin
+ conRegVar('hlm_ui_scale', @g_holmes_ui_scale, 0.01, 5.0, 'Holmes UI scale', '', false);
end.
index a6daf4f491b4d6da83f65e0ffbcf53c5de212cec..d9909a2586a3540147eb716f3128443d75674226 100644 (file)
--- a/src/game/g_holmes_ui.inc
+++ b/src/game/g_holmes_ui.inc
procedure THControl.setScissorGLInternal (x, y, w, h: Integer);
begin
if not scallowed then exit;
+ x := trunc(x*g_holmes_ui_scale);
+ y := trunc(y*g_holmes_ui_scale);
+ w := trunc(w*g_holmes_ui_scale);
+ h := trunc(h*g_holmes_ui_scale);
y := gWinSizeY-(y+h);
if not intersectRect(x, y, w, h, scxywh[0], scxywh[1], scxywh[2], scxywh[3]) then glScissor(0, 0, 0, 0) else glScissor(x, y, w, h);
end;
begin
if (mWidth > 0) and (mHeight > 0) then
begin
- mX := (gWinSizeX-mWidth) div 2;
- mY := (gWinSizeY-mHeight) div 2;
+ mX := trunc((gWinSizeX/g_holmes_ui_scale-mWidth)/2);
+ mY := trunc((gWinSizeY/g_holmes_ui_scale-mHeight)/2);
end;
end;
diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index 1b60950e0acfa4a33a15fcc31c220dc4842d63e3..0ac255fd0c580c5682ab6653929a7a9c2a2be679 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
var
idx: Integer;
ltmp: Integer;
+ arg: AnsiString;
begin
{$IFDEF HEADLESS}
e_NoGraphics := True;
{$ENDIF}
- for idx := 1 to ParamCount do
- begin
- if ParamStr(idx) = '--opengl-dump-exts' then gwin_dump_extensions := true;
- if ParamStr(idx) = '--twinkletwinkle' then gwin_k8_enable_light_experiments := true;
- if ParamStr(idx) = '--jah' then g_profile_history_size := 100;
- if ParamStr(idx) = '--no-particles' then gpart_dbg_enabled := false;
- if ParamStr(idx) = '--no-los' then gmon_dbg_los_enabled := false;
-
- if ParamStr(idx) = '--profile-render' then g_profile_frame_draw := true;
- if ParamStr(idx) = '--profile-coldet' then g_profile_collision := true;
- if ParamStr(idx) = '--profile-los' then g_profile_los := true;
-
- if ParamStr(idx) = '--no-part-phys' then gpart_dbg_phys_enabled := false;
- if ParamStr(idx) = '--no-part-physics' then gpart_dbg_phys_enabled := false;
- if ParamStr(idx) = '--no-particles-phys' then gpart_dbg_phys_enabled := false;
- if ParamStr(idx) = '--no-particles-physics' then gpart_dbg_phys_enabled := false;
- if ParamStr(idx) = '--no-particle-phys' then gpart_dbg_phys_enabled := false;
- if ParamStr(idx) = '--no-particle-physics' then gpart_dbg_phys_enabled := false;
-
- if ParamStr(idx) = '--holmes' then begin g_holmes_enabled := true; g_Game_SetDebugMode(); end;
+ idx := 1;
+ while (idx <= ParamCount) do
+ begin
+ arg := ParamStr(idx);
+ Inc(idx);
+ if arg = '--opengl-dump-exts' then gwin_dump_extensions := true;
+ if arg = '--twinkletwinkle' then gwin_k8_enable_light_experiments := true;
+ if arg = '--jah' then g_profile_history_size := 100;
+ if arg = '--no-particles' then gpart_dbg_enabled := false;
+ if arg = '--no-los' then gmon_dbg_los_enabled := false;
+
+ if arg = '--profile-render' then g_profile_frame_draw := true;
+ if arg = '--profile-coldet' then g_profile_collision := true;
+ if arg = '--profile-los' then g_profile_los := true;
+
+ if arg = '--no-part-phys' then gpart_dbg_phys_enabled := false;
+ if arg = '--no-part-physics' then gpart_dbg_phys_enabled := false;
+ if arg = '--no-particles-phys' then gpart_dbg_phys_enabled := false;
+ if arg = '--no-particles-physics' then gpart_dbg_phys_enabled := false;
+ if arg = '--no-particle-phys' then gpart_dbg_phys_enabled := false;
+ if arg = '--no-particle-physics' then gpart_dbg_phys_enabled := false;
+
+ if arg = '--holmes' then begin g_holmes_enabled := true; g_Game_SetDebugMode(); end;
+ if (arg = '--holmes-ui-scale') or (arg = '-holmes-ui-scale') then
+ begin
+ if (idx <= ParamCount) then
+ begin
+ if not conParseFloat(g_holmes_ui_scale, ParamStr(idx)) then g_holmes_ui_scale := 1.0;
+ Inc(idx);
+ end;
+ end;
end;
e_WriteLog('Initializing OpenGL', MSG_NOTIFY);