Skip to content

Commit

Permalink
add memrec hotkey option for "Only while down"
Browse files Browse the repository at this point in the history
  • Loading branch information
cheat-engine committed Mar 21, 2022
1 parent 6e918ae commit 84aae09
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 32 deletions.
61 changes: 36 additions & 25 deletions Cheat Engine/HotKeys.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object HotKeyForm: THotKeyForm
LCLVersion = '2.0.6.0'
object ListView1: TListView
Left = 0
Height = 173
Height = 154
Top = 0
Width = 582
Align = alClient
Expand Down Expand Up @@ -51,17 +51,17 @@ object HotKeyForm: THotKeyForm
end
object Panel1: TPanel
Left = 0
Height = 208
Top = 173
Height = 227
Top = 154
Width = 582
Align = alBottom
AutoSize = True
ClientHeight = 208
ClientHeight = 227
ClientWidth = 582
TabOrder = 1
object PageControl1: TPageControl
Left = 1
Height = 173
Height = 192
Top = 1
Width = 580
ActivePage = TabSheet2
Expand Down Expand Up @@ -105,15 +105,15 @@ object HotKeyForm: THotKeyForm
end
object TabSheet2: TTabSheet
Caption = 'TabSheet2'
ClientHeight = 165
ClientHeight = 184
ClientWidth = 572
object btnApply: TButton
AnchorSideLeft.Control = Panel3
AnchorSideTop.Control = Panel3
AnchorSideTop.Side = asrBottom
Left = 0
Height = 25
Top = 138
Top = 157
Width = 75
AutoSize = True
BorderSpacing.Top = 4
Expand All @@ -129,7 +129,7 @@ object HotKeyForm: THotKeyForm
AnchorSideTop.Control = btnApply
Left = 77
Height = 25
Top = 138
Top = 157
Width = 75
AutoSize = True
BorderSpacing.Left = 2
Expand All @@ -143,12 +143,12 @@ object HotKeyForm: THotKeyForm
AnchorSideLeft.Control = TabSheet2
AnchorSideTop.Control = TabSheet2
Left = 0
Height = 134
Height = 153
Top = 0
Width = 292
AutoSize = True
BevelOuter = bvNone
ClientHeight = 134
ClientHeight = 153
ClientWidth = 292
TabOrder = 2
object Label1: TLabel
Expand Down Expand Up @@ -219,13 +219,13 @@ object HotKeyForm: THotKeyForm
end
object edtFreezeValue: TEdit
AnchorSideLeft.Control = Label1
AnchorSideTop.Control = cbFreezedirection
AnchorSideTop.Control = cbOnlyWhileDown
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtHotkey
AnchorSideRight.Side = asrBottom
Left = 4
Height = 23
Top = 69
Top = 88
Width = 235
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2
Expand All @@ -238,7 +238,7 @@ object HotKeyForm: THotKeyForm
AnchorSideTop.Side = asrBottom
Left = 4
Height = 15
Top = 94
Top = 113
Width = 117
BorderSpacing.Top = 2
Caption = 'Description (Optional)'
Expand All @@ -253,14 +253,25 @@ object HotKeyForm: THotKeyForm
Left = 4
Height = 23
Hint = 'When autogenerating a trainer this field will be used as description'
Top = 111
Top = 130
Width = 235
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2
ParentShowHint = False
ShowHint = True
TabOrder = 4
end
object cbOnlyWhileDown: TCheckBox
AnchorSideLeft.Control = cbFreezedirection
AnchorSideTop.Control = cbFreezedirection
AnchorSideTop.Side = asrBottom
Left = 4
Height = 19
Top = 67
Width = 281
Caption = 'Only while hotkey is down/Restore when released'
TabOrder = 5
end
end
object lblActivateSound: TLabel
AnchorSideLeft.Control = Panel3
Expand All @@ -271,7 +282,7 @@ object HotKeyForm: THotKeyForm
AnchorSideBottom.Control = cbActivateSound
Left = 300
Height = 15
Top = 3
Top = 7
Width = 79
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
Expand All @@ -285,7 +296,7 @@ object HotKeyForm: THotKeyForm
AnchorSideTop.Side = asrBottom
Left = 300
Height = 23
Top = 20
Top = 24
Width = 149
Anchors = [akLeft]
BorderSpacing.Top = 2
Expand All @@ -308,7 +319,7 @@ object HotKeyForm: THotKeyForm
AnchorSideTop.Side = asrCenter
Left = 451
Height = 22
Top = 20
Top = 24
Width = 23
BorderSpacing.Left = 2
Enabled = False
Expand Down Expand Up @@ -356,7 +367,7 @@ object HotKeyForm: THotKeyForm
AnchorSideTop.Side = asrBottom
Left = 300
Height = 15
Top = 68
Top = 72
Width = 91
BorderSpacing.Top = 2
Caption = 'Deactivate sound'
Expand All @@ -371,7 +382,7 @@ object HotKeyForm: THotKeyForm
AnchorSideRight.Side = asrBottom
Left = 300
Height = 23
Top = 85
Top = 89
Width = 149
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2
Expand All @@ -394,7 +405,7 @@ object HotKeyForm: THotKeyForm
AnchorSideTop.Side = asrCenter
Left = 451
Height = 22
Top = 85
Top = 89
Width = 23
BorderSpacing.Left = 2
Enabled = False
Expand Down Expand Up @@ -444,7 +455,7 @@ object HotKeyForm: THotKeyForm
AnchorSideRight.Side = asrBottom
Left = 300
Height = 23
Top = 43
Top = 47
Width = 149
Anchors = [akTop, akLeft, akRight]
ParentShowHint = False
Expand All @@ -459,7 +470,7 @@ object HotKeyForm: THotKeyForm
Left = 451
Height = 19
Hint = 'Tries to set the language of the windows speech synthesizer to English when speaking this. Won''t speak if there is no English voice installed'
Top = 45
Top = 49
Width = 90
BorderSpacing.Left = 2
Caption = 'Force English'
Expand All @@ -478,7 +489,7 @@ object HotKeyForm: THotKeyForm
AnchorSideRight.Side = asrBottom
Left = 300
Height = 23
Top = 108
Top = 112
Width = 149
Anchors = [akTop, akLeft, akRight]
ParentShowHint = False
Expand All @@ -493,7 +504,7 @@ object HotKeyForm: THotKeyForm
Left = 451
Height = 19
Hint = 'Tries to set the language of the windows speech synthesizer to English when speaking this. Won''t speak if there is no English voice installed'
Top = 110
Top = 114
Width = 90
BorderSpacing.Left = 2
Caption = 'Force English'
Expand All @@ -508,7 +519,7 @@ object HotKeyForm: THotKeyForm
object Panel2: TPanel
Left = 1
Height = 33
Top = 174
Top = 193
Width = 580
Align = alBottom
AutoSize = True
Expand Down
27 changes: 26 additions & 1 deletion Cheat Engine/HotKeys.pas
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ THotKeyForm = class(TForm)
cbFreezedirection: TComboBox;
cbForceEnglishActivate: TCheckBox;
cbForceEnglishDeactivate: TCheckBox;
cbOnlyWhileDown: TCheckBox;
edtActivateText: TEdit;
edtDeactivateText: TEdit;
edtDescription: TEdit;
Expand Down Expand Up @@ -123,6 +124,8 @@ implementation
rsTextToSpeechHint = 'The text to speak'#13#10'{Description} = The description of the hotkey'#13#10'{MRDescription} = The description field of the memory record'#13#10'{MRValue} = The value of the memory record';
rsDefaultActivated = '%s Activated';
rsDefaultDeactivated = '%s Deactivated';
rsDeactivateOnRelease = 'Deactivate on release';
rsRestoreToOriginalOnRelease = 'Restore to original on release';


function THotkeyform.getBtnOKCustomButton: TCustomButton;
Expand Down Expand Up @@ -343,10 +346,11 @@ procedure THotKeyForm.btnApplyClick(Sender: TObject);
hk.action:=getHotkeyAction;
hk.value:=edtFreezeValue.text;
hk.fdescription:=edtDescription.text;
hk.fOnlyWhileDown:=cbOnlyWhileDown.checked;
hk.registerkeys;
end
else
hk:=memrec.Addhotkey(keys, getHotkeyAction, edtFreezeValue.text, edtDescription.text );
hk:=memrec.Addhotkey(keys, getHotkeyAction, edtFreezeValue.text, edtDescription.text, cbOnlyWhileDown.checked );



Expand Down Expand Up @@ -447,11 +451,30 @@ procedure THotKeyForm.cbFreezedirectionSelect(Sender: TObject);
begin
onpossible:=cbFreezeDirection.itemindex in [0,1];
offpossible:=cbFreezeDirection.itemindex in [0,2];

if onpossible then
begin
cbOnlyWhileDown.Caption:=rsDeactivateOnRelease;
cbOnlyWhileDown.visible:=true;
end
else
cbOnlyWhileDown.visible:=false;
end
else
begin
onpossible:=cbFreezeDirection.itemindex in [0,1,2,3,5,6,7];
offpossible:=cbFreezeDirection.itemindex in [0,1,2,4];

if cbFreezeDirection.itemindex in [0,1,2,3,5] then
begin
case cbFreezeDirection.itemindex of
0, 1, 2, 3: cbOnlyWhileDown.Caption:=rsDeactivateOnRelease;
5: cbOnlyWhileDown.Caption:=rsRestoreToOriginalOnRelease;
end;
cbOnlyWhileDown.visible:=true;
end
else
cbOnlyWhileDown.visible:=false;
end;

lblActivateSound.enabled:=onpossible;
Expand All @@ -462,6 +485,8 @@ procedure THotKeyForm.cbFreezedirectionSelect(Sender: TObject);
cbDeactivateSound.enabled:=offpossible;
sbPlayDeactivate.enabled:=offpossible;



end;

procedure THotKeyForm.cbPlaySoundChange(Sender: TObject);
Expand Down
Loading

0 comments on commit 84aae09

Please sign in to comment.