📄 mainunit.pas.svn-base
字号:
i:=vartype.ItemIndex;
if newscan.Caption=strNewScan then
newscan.Click; //start new scan
vartype.ItemIndex:=i;
vartype.OnChange(vartype);
scantype.ItemIndex:=scantype.Items.IndexOf(StrUnknownInitialValue);
scantype.OnChange(scantype);
newscan.Click;
end;
22: //next scan Exact value
begin
if not newscan.Enabled then exit;
if (formscanning<>nil) and (formscanning.Visible) then exit; //it's scanning
if nextscanbutton.Enabled then
begin
scantype.ItemIndex:=scantype.Items.IndexOf(StrExactValue);
scantype.OnChange(scantype);
nextscanbutton.click;
end
else Errorbeep;
end;
23: //next scan IncreasedValue
begin
if not newscan.Enabled then exit;
if (formscanning<>nil) and (formscanning.Visible) then exit; //it's scanning
if nextscanbutton.Enabled then
begin
scantype.ItemIndex:=scantype.Items.IndexOf(StrIncreasedValue);
scantype.OnChange(scantype);
nextscanbutton.click;
end
else Errorbeep;
end;
24: //next scan DecreasedValue
begin
if not newscan.Enabled then exit;
if (formscanning<>nil) and (formscanning.Visible) then exit; //it's scanning
if nextscanbutton.Enabled then
begin
scantype.ItemIndex:=scantype.Items.IndexOf(StrDecreasedValue);
scantype.OnChange(scantype);
nextscanbutton.click;
end
else Errorbeep;
end;
25: //next scan ChangedValue
begin
if not newscan.Enabled then exit;
if (formscanning<>nil) and (formscanning.Visible) then exit; //it's scanning
if nextscanbutton.Enabled then
begin
scantype.ItemIndex:=scantype.Items.IndexOf(StrChangedValue);
scantype.OnChange(scantype);
nextscanbutton.click;
end
else Errorbeep;
end;
26: //next scan unchangedValue
begin
if not newscan.Enabled then exit;
if (formscanning<>nil) and (formscanning.Visible) then exit; //it's scanning
if nextscanbutton.Enabled then
begin
scantype.ItemIndex:=scantype.Items.IndexOf(StrUnchangedValue);
scantype.OnChange(scantype);
nextscanbutton.click;
end
else Errorbeep;
end;
27: //undo lastscan
begin
if not newscan.Enabled then exit;
if (formscanning<>nil) and (formscanning.Visible) then exit; //it's scanning
if undoscan.Enabled then
undoscan.Click
else
Errorbeep;
end;
28: //cancel current scan
begin
if (formscanning<>nil) and (formscanning.btnCancel.Enabled) then
formscanning.btnCancel.Click;
end;
end;
end;
procedure TMainForm.hotkey(var Message: TMessage); //stays because the old hotkeyhandler is still used in some places
var x: TDevMode;
i: integer;
c: integer;
begin
if ((hotkeyform<>nil) and (hotkeyform.Visible)) or ((formhotkey<>nil) and (formhotkey.visible)) then exit;
if Message.wparam=0 then
begin
//bring to front
try
unregisterhotkey(mainform.handle,0);
if advancedoptions.Pausebutton.Down then
begin
beep;
sleep(100);
beep;
sleep(100);
beep;
sleep(100);
exit;
end;
beep;
if formsettings.cbHideAllWindows.checked then
begin
ToggleWindow;
// ToggleOtherWindows;
if formsettings.cbCenterOnPopup.checked then
if not allwindowsareback then
setwindowpos(mainform.Handle,HWND_NOTOPMOST,(screen.Width div 2)-(mainform.Width div 2),(screen.Height div 2)-(mainform.height div 2),mainform.Width,mainform.Height,SWP_NOZORDER or SWP_NOACTIVATE);
if not allwindowsareback then application.BringToFront else
begin
setforegroundwindow(lastforeground);
// setactivewindow(lastactive);
end;
adjustbringtofronttext;
exit;
end;
// if length(windowlist)<>0 then
application.BringToFront;
if formsettings.cbCenterOnPopup.checked then
setwindowpos(mainform.Handle,HWND_NOTOPMOST,(screen.Width div 2)-(mainform.Width div 2),(screen.Height div 2)-(mainform.height div 2),mainform.Width,mainform.Height,SWP_NOZORDER or SWP_NOACTIVATE);
formstyle:=fsStayOnTop;
finally
registerhotkey(mainform.handle,0,message.lparamlo,message.LParamHi); //restore the hotkey
end;
end;
if message.WParam=2 then //toggle speedhack
begin
try
unregisterhotkey(mainform.handle,2);
if cbSpeedhack.Enabled then
begin
beep;
cbSpeedhack.checked:=not cbSpeedhack.Checked;
end;
finally
registerhotkey(mainform.handle,2,message.lparamlo,message.LParamHi); //restore the hotkey
end;
end;
if message.WParam>=10 then //it's a record with a hotkey
begin
for i:=0 to numberofrecords-1 do
begin //find the record
if message.WParam=hotkeys[i] then
begin
if memrec[i].VarType=255 then
begin
if memrec[i].Frozen then
disableautoassemblecheat(i)
else
enableautoassemblecheat(i);
updatescreen;
exit;
end;
//set the value to what it was when the hotkey got set
hotkeypressed:=i;
memrec[i].Frozen:=true;
FreezeThem;
memrec[i].Frozen:=false;
hotkeypressed:=-1;
exit;
end;
end;
end;
end;
//----------------------------------
function TMainform.getSelectedCustomScanData: TStringlist;
var index: integer;
begin
index:=scantype.itemindex;
if (getSelectedVariableType=vtCustom) and (index>=0) then
result:=CustomScanScripts[index].data
else
result:=nil;
end;
function TMainform.getSelectedCustomScanType: TCustomScanType;
var index: integer;
begin
index:=scantype.itemindex;
if (getSelectedVariableType=vtCustom) and (index>=0) then
result:=CustomScanScripts[index].CustomScanType
else
result:=cstNone;
end;
function TMainform.getSelectedVariableType: TVariableType;
{wrapper for the new getVarType2 in the new scanroutine}
begin
result:=getVarType2;
end;
function TMainform.getScanStart: Dword;
begin
try
result:=strtoint('$'+FromAddress.text);
except
raise exception.Create('Invalid start address: '+FromAddress.text);
end;
end;
procedure TMainform.setScanStart(newscanstart: dword);
begin
FromAddress.text:=inttohex(newscanstart,8);
end;
function TMainform.getScanStop: Dword;
begin
try
result:=strtoint('$'+ToAddress.text);
except
raise exception.Create('Invalid start address: '+FromAddress.text);
end;
end;
procedure TMainform.setScanStop(newscanstop: dword);
begin
ToAddress.text:=inttohex(newscanstop,8);
end;
function TMainform.getFastscan: boolean;
begin
result:=cbFastscan.checked;
end;
procedure TMainform.setFastScan(state: boolean);
begin
cbFastscan.checked:=state;
end;
function TMainform.getScanReadonly: boolean;
begin
result:=Readonly.checked;
end;
procedure TMainform.setScanReadOnly(state: boolean);
begin
readonly.checked:=state;
end;
function TMainform.GetRoundingType: TRoundingType;
{Property function to get the current rounding type}
begin
if rt1.checked then result:=rtRounded else
if rt2.checked then result:=rtExtremerounded else
if rt3.Checked then result:=rtTruncated;
end;
procedure TMainform.SetRoundingType(rt: TRoundingType);
{Property function to set the current rounding type}
begin
case rt of
rtRounded: rt1.checked;
rtExtremerounded: rt2.checked;
rtTruncated: rt3.checked;
end;
end;
procedure TMainform.setfoundcount(x: int64);
begin
ffoundcount:=x;
foundcountlabel.Caption:=inttostr(x);
end;
procedure TMainform.DestroyCancelButton;
begin
if cancelbutton<>nil then
freeandnil(cancelbutton);
end;
procedure TMainform.SpawnCancelButton;
begin
cancelbutton:=TButton.create(self);
with cancelbutton do
begin
top:=newscan.top;
left:=newscan.left;
width:=(nextscanbutton.left+nextscanbutton.width)-left;
height:=newscan.height;
caption:='Cancel';
onclick:=cancelbuttonclick;
parent:=self;
end;
end;
procedure TMainform.DisableGui;
{
This procedure will disable the gui. E.g while scanning the memory with no wait
screen.
}
var i: integer;
begin
Groupbox1.Enabled:=false;
for i:=0 to groupbox1.ControlCount-1 do
groupbox1.Controls[i].Enabled:=false;
scanvalue.Enabled:=false;
vartype.Enabled:=false;
scantype.Enabled:=false;
scantext.enabled:=false;
label4.enabled:=false;
label8.Enabled:=false;
HexadecimalCheckbox.Enabled:=false;
cbCaseSensitive.Enabled:=false;
newscan.enabled:=false;
nextscanbutton.enabled:=false;
undoscan.enabled:=false;
end;
procedure TMainform.EnableGui(isnextscan: boolean);
{
Enables the gui options according to what type of scan is currently used
no scan, enable everything
already scanning, disable the group and type
}
var i: integer;
fname,expectedfilename: string;
scanstarted: boolean;
begin
scanstarted:=newscan.caption=strnewscan;
if not scanstarted then
begin
Groupbox1.Enabled:=true;
for i:=0 to groupbox1.ControlCount-1 do
groupbox1.Controls[i].Enabled:=true;
end;
scanvalue.Enabled:=true;
newscan.Enabled:=true;
undoscan.Enabled:=isnextscan; //nextascan was already enabled
nextscanbutton.Enabled:=scanstarted;
vartype.Enabled:=not scanstarted;
scantype.Enabled:=true;
scantext.enabled:=true;
label4.enabled:=true;
label8.Enabled:=true;
HexadecimalCheckbox.Enabled:=true;
cbCaseSensitive.Enabled:=true;
scanvalue.visible:=true;
scantext.Visible:=true;
Updatescantype;
Scantype.ItemIndex:=0;
//-----------------------
//Get the expectedFilename
//-----------------------
SetExpectedTableName;
cbspeedhack.enabled:=true;
cbunrandomizer.Enabled:=true;
end;
procedure TMainform.toggleWindow;
resourcestring
strWindowFailedToHide='A window failed to hide';
var c: integer;
begin
togglewindows:=TTogglewindows.Create(false);
c:=0;
while togglewindows<>nil do
begin
if c=500 then
begin
togglewindows.free;
raise exception.Create(strWindowFailedToHide);
end;
sleep(10);
inc(c);
end;
end;
procedure TMainForm.ReserveMem;
var before: integer;
i: integer;
begin
before:=length(memrec);
if numberofrecords<before then
begin
//cleanup some extra memory
for i:=numberofrecords to before-1 do
begin
setlength(memrec[i].pointers,0);
setlength(memrec[i].allocs,0);
end;
end;
setlength(memrec,numberofrecords);
setlength(frozenfvalue,numberofrecords);
setlength(frozenStrings,numberofrecords);
setlength(frozenbytes,NumberOfRecords);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -