mirror of
https://github.com/paleotronic/microm8-gui.git
synced 2024-11-25 17:42:21 +00:00
wrap strtoint()
This commit is contained in:
parent
765f0e662e
commit
ff94c4357c
@ -538,6 +538,18 @@ const
|
||||
const
|
||||
MOUSE_BTN_VKEYS: Array [TMouseBtnType] of Integer = (VK_LBUTTON, VK_MBUTTON, VK_RBUTTON);
|
||||
|
||||
function StrToIntSafe(s: string): integer;
|
||||
begin
|
||||
result := 0;
|
||||
try
|
||||
result := StrToInt(s)
|
||||
except
|
||||
on e: Exception do begin
|
||||
// nothing much
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
(* This function returns true when the specified mouse button is pressed *)
|
||||
{$IFDEF WINDOWS}
|
||||
function TGUIForm.IsMouseBtnDown(const AMouseBtn: TMouseBtnType): Boolean;
|
||||
@ -2320,6 +2332,8 @@ begin
|
||||
exit;
|
||||
if WindowState = wsMinimized then
|
||||
exit;
|
||||
if disableFocusStealing then
|
||||
exit;
|
||||
//if hidden then
|
||||
// exit;
|
||||
if GetTitleOfActiveWindow = 'microM8' then
|
||||
|
@ -6,7 +6,7 @@
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="poc"/>
|
||||
<Title Value="microm8-gui"/>
|
||||
<Scaled Value="True"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
|
@ -21,8 +21,8 @@
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="2523"/>
|
||||
<CursorPos X="5" Y="2542"/>
|
||||
<TopLine Value="2315"/>
|
||||
<CursorPos X="72" Y="2328"/>
|
||||
<UsageCount Value="323"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@ -51,129 +51,129 @@
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="636"/>
|
||||
<CursorPos Y="654"/>
|
||||
<UsageCount Value="6"/>
|
||||
<UsageCount Value="5"/>
|
||||
</Unit4>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="903" Column="3" TopLine="892"/>
|
||||
<Caret Line="473" Column="58" TopLine="455"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="719" Column="92" TopLine="717"/>
|
||||
<Caret Line="9" Column="60"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="904" Column="56" TopLine="902"/>
|
||||
<Caret Line="557" Column="41" TopLine="533"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="719" Column="3" TopLine="717"/>
|
||||
<Caret Line="2046" Column="35" TopLine="1936"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="721" Column="3" TopLine="719"/>
|
||||
<Caret Line="503" Column="22" TopLine="479"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="917" Column="3" TopLine="915"/>
|
||||
<Caret Line="309" Column="43" TopLine="293"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="727" Column="84" TopLine="725"/>
|
||||
<Caret Line="503" Column="5" TopLine="485"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="473" Column="58" TopLine="455"/>
|
||||
<Caret Line="508" Column="17" TopLine="486"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="9" Column="60"/>
|
||||
<Caret Line="2362" Column="39" TopLine="2350"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="557" Column="41" TopLine="533"/>
|
||||
<Caret Line="2302" Column="47" TopLine="2289"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2046" Column="35" TopLine="1936"/>
|
||||
<Caret Line="2362" Column="3" TopLine="2360"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="503" Column="22" TopLine="479"/>
|
||||
<Caret Line="2300" Column="44" TopLine="2289"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="309" Column="43" TopLine="293"/>
|
||||
<Caret Line="14" Column="42"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="503" Column="5" TopLine="485"/>
|
||||
<Caret Line="572" Column="37" TopLine="541"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="508" Column="17" TopLine="486"/>
|
||||
<Caret Line="562" Column="29" TopLine="550"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2362" Column="39" TopLine="2350"/>
|
||||
<Caret Line="590" Column="67" TopLine="662"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2302" Column="47" TopLine="2289"/>
|
||||
<Caret Line="2323" Column="34" TopLine="2297"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2362" Column="3" TopLine="2360"/>
|
||||
<Caret Line="2326" Column="34" TopLine="2300"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2300" Column="44" TopLine="2289"/>
|
||||
<Caret Line="2533" Column="3" TopLine="2530"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="14" Column="42"/>
|
||||
<Caret Line="2557" Column="68" TopLine="2538"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="572" Column="37" TopLine="541"/>
|
||||
<Caret Line="2352" Column="3" TopLine="2349"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="562" Column="29" TopLine="550"/>
|
||||
<Caret Line="2368" Column="15" TopLine="2349"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="590" Column="67" TopLine="662"/>
|
||||
<Caret Line="2367" Column="15" TopLine="2348"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2323" Column="34" TopLine="2297"/>
|
||||
<Caret Line="2555" Column="60" TopLine="2540"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2326" Column="34" TopLine="2300"/>
|
||||
<Caret Line="2314" Column="46" TopLine="2060"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2533" Column="3" TopLine="2530"/>
|
||||
<Caret Line="514" Column="43" TopLine="484"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2557" Column="68" TopLine="2538"/>
|
||||
<Caret Line="515" Column="43" TopLine="485"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2352" Column="3" TopLine="2349"/>
|
||||
<Caret Line="517" Column="43" TopLine="487"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2368" Column="15" TopLine="2349"/>
|
||||
<Caret Line="2681" Column="50" TopLine="2651"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2367" Column="15" TopLine="2348"/>
|
||||
<Caret Line="933" Column="51" TopLine="926"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
34
main.pas
34
main.pas
@ -538,6 +538,18 @@ const
|
||||
const
|
||||
MOUSE_BTN_VKEYS: Array [TMouseBtnType] of Integer = (VK_LBUTTON, VK_MBUTTON, VK_RBUTTON);
|
||||
|
||||
function StrToIntSafe(s: string): integer;
|
||||
begin
|
||||
result := 0;
|
||||
try
|
||||
result := StrToInt(s)
|
||||
except
|
||||
on e: Exception do begin
|
||||
// nothing much
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
(* This function returns true when the specified mouse button is pressed *)
|
||||
{$IFDEF WINDOWS}
|
||||
function TGUIForm.IsMouseBtnDown(const AMouseBtn: TMouseBtnType): Boolean;
|
||||
@ -552,7 +564,7 @@ var
|
||||
s: string;
|
||||
begin
|
||||
s := SimpleGet( baseUrl+'/api/control/mouse/buttonstate' );
|
||||
mstate := StrToInt( s );
|
||||
mstate := StrToIntSafe( s );
|
||||
result := (mstate and integer(AMouseBtn)) <> 0;
|
||||
end;
|
||||
{$ENDIF}
|
||||
@ -572,7 +584,7 @@ function TGUIForm.IsMouseBtnDown: Boolean;
|
||||
var
|
||||
mstate: integer;
|
||||
begin
|
||||
mstate := StrToInt( SimpleGet( baseUrl+'/api/control/mouse/buttonstate' ) );
|
||||
mstate := StrToIntSafe( SimpleGet( baseUrl+'/api/control/mouse/buttonstate' ) );
|
||||
result := mstate <> 0;
|
||||
end;
|
||||
{$ENDIF}
|
||||
@ -1533,7 +1545,7 @@ procedure TGUIForm.miTintModeClick(Sender: TObject);
|
||||
var
|
||||
t: integer;
|
||||
begin
|
||||
t := StrToInt( GetConfig( 'video/init.video.tintmode') );
|
||||
t := StrToIntSafe( GetConfig( 'video/init.video.tintmode') );
|
||||
case t of
|
||||
0: miTMNone.Checked := true;
|
||||
1: miTMGrey.Checked := true;
|
||||
@ -1584,7 +1596,7 @@ procedure TGUIForm.miVD1Click(Sender: TObject);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
i := StrToInt(Copy( TMenuItem(sender).Caption, 1, 1 )) - 1;
|
||||
i := StrToIntSafe(Copy( TMenuItem(sender).Caption, 1, 1 )) - 1;
|
||||
UpdateConfig( 'video/init.video.voxeldepth', IntToStr(i), true );
|
||||
end;
|
||||
|
||||
@ -1592,7 +1604,7 @@ procedure TGUIForm.miVDClick(Sender: TObject);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
i := StrToInt( GetConfig('video/init.video.voxeldepth') );
|
||||
i := StrToIntSafe( GetConfig('video/init.video.voxeldepth') );
|
||||
case i of
|
||||
0: miVD1.Checked := true;
|
||||
1: miVD2.Checked := true;
|
||||
@ -1706,7 +1718,7 @@ procedure TGUIForm.UpdateRenderMode;
|
||||
var
|
||||
t: integer;
|
||||
begin
|
||||
t := StrToInt( GetConfig( 'video/current.rendermode' ) );
|
||||
t := StrToIntSafe( GetConfig( 'video/current.rendermode' ) );
|
||||
case t of
|
||||
0: tbRMDots.Down := true;
|
||||
3: tbRMDots.Down := true;
|
||||
@ -1722,7 +1734,7 @@ procedure TGUIForm.tbRMClick(Sender: TObject);
|
||||
var
|
||||
t: integer;
|
||||
begin
|
||||
t := StrToInt( GetConfig( 'video/current.rendermode' ) );
|
||||
t := StrToIntSafe( GetConfig( 'video/current.rendermode' ) );
|
||||
|
||||
case TToolButton(sender).Tag of
|
||||
0:
|
||||
@ -1750,7 +1762,7 @@ procedure TGUIForm.UpdateColorMode;
|
||||
var
|
||||
t: integer;
|
||||
begin
|
||||
t := StrToInt( GetConfig( 'video/current.rendermode' ) );
|
||||
t := StrToIntSafe( GetConfig( 'video/current.rendermode' ) );
|
||||
tbRMColor.ImageIndex := 7 + (t div 3);
|
||||
end;
|
||||
|
||||
@ -1760,7 +1772,7 @@ var
|
||||
begin
|
||||
|
||||
{ increment video tint }
|
||||
t := StrToInt( GetConfig( 'video/current.rendermode' ) );
|
||||
t := StrToIntSafe( GetConfig( 'video/current.rendermode' ) );
|
||||
|
||||
if t >= 3 then
|
||||
t := t - 3
|
||||
@ -1804,7 +1816,7 @@ procedure TGUIForm.UpdateTintMode;
|
||||
var
|
||||
t: integer;
|
||||
begin
|
||||
t := StrToInt( GetConfig( 'video/init.video.tintmode' ) );
|
||||
t := StrToIntSafe( GetConfig( 'video/init.video.tintmode' ) );
|
||||
tbTintMode.ImageIndex := t;
|
||||
end;
|
||||
|
||||
@ -1814,7 +1826,7 @@ var
|
||||
begin
|
||||
|
||||
{ increment video tint }
|
||||
t := StrToInt( GetConfig( 'video/init.video.tintmode' ) );
|
||||
t := StrToIntSafe( GetConfig( 'video/init.video.tintmode' ) );
|
||||
inc(t);
|
||||
if t > 3 then
|
||||
t := 0;
|
||||
|
68
poc.lps
68
poc.lps
@ -21,8 +21,8 @@
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="2315"/>
|
||||
<CursorPos X="72" Y="2328"/>
|
||||
<TopLine Value="1890"/>
|
||||
<CursorPos X="23" Y="1927"/>
|
||||
<UsageCount Value="323"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@ -54,127 +54,123 @@
|
||||
<UsageCount Value="5"/>
|
||||
</Unit4>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<JumpHistory Count="29" HistoryIndex="28">
|
||||
<Position1>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="473" Column="58" TopLine="455"/>
|
||||
<Caret Line="2046" Column="35" TopLine="1936"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="9" Column="60"/>
|
||||
<Caret Line="503" Column="22" TopLine="479"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="557" Column="41" TopLine="533"/>
|
||||
<Caret Line="309" Column="43" TopLine="293"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2046" Column="35" TopLine="1936"/>
|
||||
<Caret Line="503" Column="5" TopLine="485"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="503" Column="22" TopLine="479"/>
|
||||
<Caret Line="508" Column="17" TopLine="486"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="309" Column="43" TopLine="293"/>
|
||||
<Caret Line="2362" Column="39" TopLine="2350"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="503" Column="5" TopLine="485"/>
|
||||
<Caret Line="2302" Column="47" TopLine="2289"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="508" Column="17" TopLine="486"/>
|
||||
<Caret Line="2362" Column="3" TopLine="2360"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2362" Column="39" TopLine="2350"/>
|
||||
<Caret Line="2300" Column="44" TopLine="2289"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2302" Column="47" TopLine="2289"/>
|
||||
<Caret Line="14" Column="42"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2362" Column="3" TopLine="2360"/>
|
||||
<Caret Line="572" Column="37" TopLine="541"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2300" Column="44" TopLine="2289"/>
|
||||
<Caret Line="562" Column="29" TopLine="550"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="14" Column="42"/>
|
||||
<Caret Line="590" Column="67" TopLine="662"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="572" Column="37" TopLine="541"/>
|
||||
<Caret Line="2323" Column="34" TopLine="2297"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="562" Column="29" TopLine="550"/>
|
||||
<Caret Line="2326" Column="34" TopLine="2300"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="590" Column="67" TopLine="662"/>
|
||||
<Caret Line="2533" Column="3" TopLine="2530"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2323" Column="34" TopLine="2297"/>
|
||||
<Caret Line="2557" Column="68" TopLine="2538"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2326" Column="34" TopLine="2300"/>
|
||||
<Caret Line="2352" Column="3" TopLine="2349"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2533" Column="3" TopLine="2530"/>
|
||||
<Caret Line="2368" Column="15" TopLine="2349"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2557" Column="68" TopLine="2538"/>
|
||||
<Caret Line="2367" Column="15" TopLine="2348"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2352" Column="3" TopLine="2349"/>
|
||||
<Caret Line="2555" Column="60" TopLine="2540"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2368" Column="15" TopLine="2349"/>
|
||||
<Caret Line="2314" Column="46" TopLine="2060"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2367" Column="15" TopLine="2348"/>
|
||||
<Caret Line="514" Column="43" TopLine="484"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2555" Column="60" TopLine="2540"/>
|
||||
<Caret Line="515" Column="43" TopLine="485"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2314" Column="46" TopLine="2060"/>
|
||||
<Caret Line="517" Column="43" TopLine="487"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="514" Column="43" TopLine="484"/>
|
||||
<Caret Line="2681" Column="50" TopLine="2651"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="515" Column="43" TopLine="485"/>
|
||||
<Caret Line="933" Column="51" TopLine="926"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="517" Column="43" TopLine="487"/>
|
||||
<Caret Line="540" Column="30" TopLine="520"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="2681" Column="50" TopLine="2651"/>
|
||||
<Caret Line="605" Column="25" TopLine="579"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="933" Column="51" TopLine="926"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
|
Loading…
Reference in New Issue
Block a user