mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-24 18:22:25 -05:00
Merge branch 'extensions'
Conflicts: Projects/SAMufasaGUI/testunit.lrs
This commit is contained in:
commit
3ffb6acc82
@ -18,21 +18,46 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
private
|
||||||
|
Extensions: TList;
|
||||||
|
public
|
||||||
|
function HandleHook(HookName: String; Args: Array of Variant): Variant;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
uses
|
||||||
|
pseventextension, virtualextension;
|
||||||
|
|
||||||
|
|
||||||
constructor TExtensionManager.Create;
|
constructor TExtensionManager.Create;
|
||||||
begin
|
begin
|
||||||
|
Extensions := TList.Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TExtensionManager.Destroy;
|
destructor TExtensionManager.Destroy;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
|
{
|
||||||
|
for i := 0 to Extensions.Count - 1 do
|
||||||
|
TVirtualSimbaExtension(Extensions.Items[i]).Free;
|
||||||
|
}
|
||||||
|
Extensions.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// How do we return more than one result?
|
||||||
|
function TExtensionManager.HandleHook(HookName: String; Args: Array of Variant): Variant;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
for i := 0 to Extensions.Count -1 do
|
||||||
|
if TVirtualSimbaExtension(Extensions.Items[i]).HookExists(HookName) then
|
||||||
|
if TVirtualSimbaExtension(Extensions.Items[i]).ExecuteHook(HookName, Args, Result) <> 0 then
|
||||||
|
begin
|
||||||
|
// Not succesfull.
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
unit eventextension;
|
unit pseventextension;
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ type
|
|||||||
|
|
||||||
public
|
public
|
||||||
function HookExists(HookName: String): Boolean; override;
|
function HookExists(HookName: String): Boolean; override;
|
||||||
function ExecuteHook(HookName: String): Integer; override;
|
function ExecuteHook(HookName: String; fArgs: Array of Variant; out OutVariant): Integer;
|
||||||
protected
|
protected
|
||||||
procedure RegisterPSCComponents(Sender: TObject; x: TPSPascalCompiler);
|
procedure RegisterPSCComponents(Sender: TObject; x: TPSPascalCompiler);
|
||||||
procedure RegisterPSRComponents(Sender: TObject; se: TPSExec; x: TPSRuntimeClassImporter);
|
procedure RegisterPSRComponents(Sender: TObject; se: TPSExec; x: TPSRuntimeClassImporter);
|
||||||
@ -40,7 +40,7 @@ uses
|
|||||||
uPSC_std, uPSC_controls,uPSC_classes,uPSC_graphics,uPSC_stdctrls,uPSC_forms,
|
uPSC_std, uPSC_controls,uPSC_classes,uPSC_graphics,uPSC_stdctrls,uPSC_forms,
|
||||||
uPSC_extctrls, //Compile libs
|
uPSC_extctrls, //Compile libs
|
||||||
uPSR_std, uPSR_controls,uPSR_classes,uPSR_graphics,uPSR_stdctrls,uPSR_forms,
|
uPSR_std, uPSR_controls,uPSR_classes,uPSR_graphics,uPSR_stdctrls,uPSR_forms,
|
||||||
uPSR_extctrls //Runtime-libs;
|
uPSR_extctrls //Runtime-libs
|
||||||
;
|
;
|
||||||
|
|
||||||
procedure createf;
|
procedure createf;
|
||||||
@ -55,11 +55,20 @@ end;
|
|||||||
|
|
||||||
function TSimbaPSEventExtension.HookExists(HookName: String): Boolean;
|
function TSimbaPSEventExtension.HookExists(HookName: String): Boolean;
|
||||||
begin
|
begin
|
||||||
|
{ FIXME: Free the .data ? }
|
||||||
|
Exit(PSInstance.GetProcMethod('init').Data <> nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSimbaPSEventExtension.ExecuteHook(HookName: String): Integer;
|
function TSimbaPSEventExtension.ExecuteHook(HookName: String; fArgs: Array of Variant; out OutVariant): Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
||||||
|
result := 0;
|
||||||
|
try
|
||||||
|
PSInstance.ExecuteFunction([], HookName);
|
||||||
|
except
|
||||||
|
result := 1;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TSimbaPSEventExtension.Create(FileName: String);
|
constructor TSimbaPSEventExtension.Create(FileName: String);
|
||||||
@ -113,16 +122,15 @@ end;
|
|||||||
|
|
||||||
function TSimbaPSEventExtension.InitScript: Boolean;
|
function TSimbaPSEventExtension.InitScript: Boolean;
|
||||||
begin
|
begin
|
||||||
if PSInstance.GetProcMethod('init').Data = nil then
|
if not HookExists('init') then
|
||||||
exit(false);
|
exit(false);
|
||||||
|
|
||||||
|
result := true;
|
||||||
try
|
try
|
||||||
PSInstance.ExecuteFunction([], 'init');
|
PSInstance.ExecuteFunction([], 'init');
|
||||||
except
|
except
|
||||||
result := false;
|
result := false;
|
||||||
exit;
|
|
||||||
end;
|
end;
|
||||||
exit(true);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -6,7 +6,7 @@ object Form1: TForm1
|
|||||||
ActiveControl = ScriptPanel
|
ActiveControl = ScriptPanel
|
||||||
AllowDropFiles = True
|
AllowDropFiles = True
|
||||||
Caption = 'THA FUKING SIMBA'
|
Caption = 'THA FUKING SIMBA'
|
||||||
ClientHeight = 535
|
ClientHeight = 530
|
||||||
ClientWidth = 739
|
ClientWidth = 739
|
||||||
KeyPreview = True
|
KeyPreview = True
|
||||||
Menu = MainMenu
|
Menu = MainMenu
|
||||||
@ -207,8 +207,8 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
object StatusBar: TStatusBar
|
object StatusBar: TStatusBar
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 23
|
Height = 21
|
||||||
Top = 512
|
Top = 509
|
||||||
Width = 739
|
Width = 739
|
||||||
Panels = <
|
Panels = <
|
||||||
item
|
item
|
||||||
@ -230,7 +230,7 @@ object Form1: TForm1
|
|||||||
object PanelMemo: TPanel
|
object PanelMemo: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 154
|
Height = 154
|
||||||
Top = 358
|
Top = 355
|
||||||
Width = 739
|
Width = 739
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
ClientHeight = 154
|
ClientHeight = 154
|
||||||
@ -250,19 +250,19 @@ object Form1: TForm1
|
|||||||
Cursor = crVSplit
|
Cursor = crVSplit
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 5
|
Height = 5
|
||||||
Top = 353
|
Top = 350
|
||||||
Width = 739
|
Width = 739
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
ResizeAnchor = akBottom
|
ResizeAnchor = akBottom
|
||||||
end
|
end
|
||||||
object ScriptPanel: TPanel
|
object ScriptPanel: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 329
|
Height = 326
|
||||||
Top = 24
|
Top = 24
|
||||||
Width = 739
|
Width = 739
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 329
|
ClientHeight = 326
|
||||||
ClientWidth = 739
|
ClientWidth = 739
|
||||||
DockSite = True
|
DockSite = True
|
||||||
TabOrder = 4
|
TabOrder = 4
|
||||||
@ -270,7 +270,7 @@ object Form1: TForm1
|
|||||||
OnDockOver = ScriptPanelDockOver
|
OnDockOver = ScriptPanelDockOver
|
||||||
object PageControl1: TPageControl
|
object PageControl1: TPageControl
|
||||||
Left = 155
|
Left = 155
|
||||||
Height = 294
|
Height = 291
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 584
|
Width = 584
|
||||||
Align = alClient
|
Align = alClient
|
||||||
@ -289,7 +289,7 @@ object Form1: TForm1
|
|||||||
object SearchPanel: TPanel
|
object SearchPanel: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 35
|
Height = 35
|
||||||
Top = 294
|
Top = 291
|
||||||
Width = 739
|
Width = 739
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
BevelOuter = bvSpace
|
BevelOuter = bvSpace
|
||||||
@ -385,7 +385,7 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
object LabeledEditSearch: TLabeledEdit
|
object LabeledEditSearch: TLabeledEdit
|
||||||
Left = 104
|
Left = 104
|
||||||
Height = 21
|
Height = 27
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 174
|
Width = 174
|
||||||
EditLabel.AnchorSideLeft.Control = LabeledEditSearch
|
EditLabel.AnchorSideLeft.Control = LabeledEditSearch
|
||||||
@ -393,10 +393,10 @@ object Form1: TForm1
|
|||||||
EditLabel.AnchorSideTop.Side = asrCenter
|
EditLabel.AnchorSideTop.Side = asrCenter
|
||||||
EditLabel.AnchorSideRight.Control = LabeledEditSearch
|
EditLabel.AnchorSideRight.Control = LabeledEditSearch
|
||||||
EditLabel.AnchorSideBottom.Control = LabeledEditSearch
|
EditLabel.AnchorSideBottom.Control = LabeledEditSearch
|
||||||
EditLabel.Left = 73
|
EditLabel.Left = 67
|
||||||
EditLabel.Height = 14
|
EditLabel.Height = 18
|
||||||
EditLabel.Top = 9
|
EditLabel.Top = 10
|
||||||
EditLabel.Width = 28
|
EditLabel.Width = 34
|
||||||
EditLabel.Caption = 'Find: '
|
EditLabel.Caption = 'Find: '
|
||||||
EditLabel.ParentColor = False
|
EditLabel.ParentColor = False
|
||||||
LabelPosition = lpLeft
|
LabelPosition = lpLeft
|
||||||
@ -409,9 +409,9 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
object CheckBoxMatchCase: TCheckBox
|
object CheckBoxMatchCase: TCheckBox
|
||||||
Left = 320
|
Left = 320
|
||||||
Height = 17
|
Height = 22
|
||||||
Top = 7
|
Top = 7
|
||||||
Width = 72
|
Width = 97
|
||||||
Caption = 'Match case'
|
Caption = 'Match case'
|
||||||
OnClick = CheckBoxMatchCaseClick
|
OnClick = CheckBoxMatchCaseClick
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
@ -419,34 +419,38 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
object SplitterFunctionList: TSplitter
|
object SplitterFunctionList: TSplitter
|
||||||
Left = 150
|
Left = 150
|
||||||
Height = 294
|
Height = 291
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 5
|
Width = 5
|
||||||
OnCanResize = SplitterFunctionListCanResize
|
OnCanResize = SplitterFunctionListCanResize
|
||||||
Visible = False
|
Visible = False
|
||||||
end
|
end
|
||||||
inline frmFunctionList: TFunctionListFrame
|
inline frmFunctionList: TFunctionListFrame
|
||||||
Height = 294
|
Height = 291
|
||||||
Width = 150
|
Width = 150
|
||||||
ClientHeight = 294
|
ClientHeight = 291
|
||||||
ClientWidth = 150
|
ClientWidth = 150
|
||||||
OnEndDock = nil
|
OnEndDock = nil
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
inherited FunctionList: TTreeView
|
inherited FunctionList: TTreeView
|
||||||
Height = 255
|
Height = 242
|
||||||
|
Top = 22
|
||||||
Width = 150
|
Width = 150
|
||||||
|
DefaultItemHeight = 19
|
||||||
OnChange = FunctionListChange
|
OnChange = FunctionListChange
|
||||||
OnEnter = FunctionListEnter
|
OnEnter = FunctionListEnter
|
||||||
OnExit = FunctionListExit
|
OnExit = FunctionListExit
|
||||||
end
|
end
|
||||||
inherited editSearchList: TEdit
|
inherited editSearchList: TEdit
|
||||||
Top = 273
|
Height = 27
|
||||||
|
Top = 264
|
||||||
Width = 150
|
Width = 150
|
||||||
OnExit = editSearchListExit
|
OnExit = editSearchListExit
|
||||||
OnKeyDown = editSearchListKeyDown
|
OnKeyDown = editSearchListKeyDown
|
||||||
OnKeyPress = editSearchListKeyPress
|
OnKeyPress = editSearchListKeyPress
|
||||||
end
|
end
|
||||||
inherited FunctionListLabel: TLabel
|
inherited FunctionListLabel: TLabel
|
||||||
|
Height = 18
|
||||||
Width = 146
|
Width = 146
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -42,7 +42,7 @@ uses
|
|||||||
SynEditMarkupHighAll, LMessages, Buttons,
|
SynEditMarkupHighAll, LMessages, Buttons,
|
||||||
stringutil,mufasatypesutil,mufasabase,
|
stringutil,mufasatypesutil,mufasabase,
|
||||||
about, framefunctionlist, ocr, updateform, simbasettings,
|
about, framefunctionlist, ocr, updateform, simbasettings,
|
||||||
eventextension;
|
extensionmanager;
|
||||||
|
|
||||||
const
|
const
|
||||||
SimbaVersion = 585;
|
SimbaVersion = 585;
|
||||||
@ -2007,9 +2007,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.ButtonTrayClick(Sender: TObject);
|
procedure TForm1.ButtonTrayClick(Sender: TObject);
|
||||||
|
{var
|
||||||
|
Ext: TSimbaPSEventExtension; }
|
||||||
|
{ FIXME: Turning it into a test button again... }
|
||||||
begin
|
begin
|
||||||
Form1.Hide;
|
Form1.Hide;
|
||||||
|
{ try
|
||||||
|
Ext := TSimbaPSEventExtension.Create(MainDir + DS + 'Extensions' + DS + 'test.pas');
|
||||||
|
Ext.Free;
|
||||||
|
except
|
||||||
|
Writeln('Something went wrong with the Extensions.');
|
||||||
|
end; }
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean
|
procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean
|
||||||
|
@ -14,7 +14,7 @@ type
|
|||||||
function HookExists(HookName: String): Boolean; virtual; abstract;
|
function HookExists(HookName: String): Boolean; virtual; abstract;
|
||||||
|
|
||||||
{ No Custom Arguments just yet... }
|
{ No Custom Arguments just yet... }
|
||||||
function ExecuteHook(HookName: String): Integer; virtual; abstract;
|
function ExecuteHook(HookName: String; fArgs: Array of Variant; out OutVariant): Integer; virtual; abstract;
|
||||||
private
|
private
|
||||||
FName: String;
|
FName: String;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user