1
0
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:
Merlijn Wajer 2010-03-20 13:36:35 +01:00
commit 3ffb6acc82
18 changed files with 7173 additions and 7127 deletions

View File

@ -18,21 +18,46 @@ type
public
constructor Create;
destructor Destroy; override;
private
Extensions: TList;
public
function HandleHook(HookName: String; Args: Array of Variant): Variant;
end;
implementation
uses
pseventextension, virtualextension;
constructor TExtensionManager.Create;
begin
Extensions := TList.Create;
end;
destructor TExtensionManager.Destroy;
var
i: Integer;
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.

View File

@ -1,4 +1,4 @@
unit eventextension;
unit pseventextension;
{$mode objfpc}
@ -26,7 +26,7 @@ type
public
function HookExists(HookName: String): Boolean; override;
function ExecuteHook(HookName: String): Integer; override;
function ExecuteHook(HookName: String; fArgs: Array of Variant; out OutVariant): Integer;
protected
procedure RegisterPSCComponents(Sender: TObject; x: TPSPascalCompiler);
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_extctrls, //Compile libs
uPSR_std, uPSR_controls,uPSR_classes,uPSR_graphics,uPSR_stdctrls,uPSR_forms,
uPSR_extctrls //Runtime-libs;
uPSR_extctrls //Runtime-libs
;
procedure createf;
@ -55,11 +55,20 @@ end;
function TSimbaPSEventExtension.HookExists(HookName: String): Boolean;
begin
{ FIXME: Free the .data ? }
Exit(PSInstance.GetProcMethod('init').Data <> nil);
end;
function TSimbaPSEventExtension.ExecuteHook(HookName: String): Integer;
function TSimbaPSEventExtension.ExecuteHook(HookName: String; fArgs: Array of Variant; out OutVariant): Integer;
begin
result := 0;
try
PSInstance.ExecuteFunction([], HookName);
except
result := 1;
end;
end;
constructor TSimbaPSEventExtension.Create(FileName: String);
@ -108,21 +117,20 @@ begin
writeln('It exists')
else
writeln('It does not exist - or something went wrong while executing it.');
// writeln(PSInstance.ExecuteFunction([], 'test'));
//writeln(PSInstance.ExecuteFunction([], 'test'));
end;
function TSimbaPSEventExtension.InitScript: Boolean;
begin
if PSInstance.GetProcMethod('init').Data = nil then
if not HookExists('init') then
exit(false);
result := true;
try
PSInstance.ExecuteFunction([], 'init');
except
result := false;
exit;
end;
exit(true);
end;

View File

@ -6,7 +6,7 @@ object Form1: TForm1
ActiveControl = ScriptPanel
AllowDropFiles = True
Caption = 'THA FUKING SIMBA'
ClientHeight = 535
ClientHeight = 530
ClientWidth = 739
KeyPreview = True
Menu = MainMenu
@ -207,8 +207,8 @@ object Form1: TForm1
end
object StatusBar: TStatusBar
Left = 0
Height = 23
Top = 512
Height = 21
Top = 509
Width = 739
Panels = <
item
@ -230,7 +230,7 @@ object Form1: TForm1
object PanelMemo: TPanel
Left = 0
Height = 154
Top = 358
Top = 355
Width = 739
Align = alBottom
ClientHeight = 154
@ -250,19 +250,19 @@ object Form1: TForm1
Cursor = crVSplit
Left = 0
Height = 5
Top = 353
Top = 350
Width = 739
Align = alBottom
ResizeAnchor = akBottom
end
object ScriptPanel: TPanel
Left = 0
Height = 329
Height = 326
Top = 24
Width = 739
Align = alClient
BevelOuter = bvNone
ClientHeight = 329
ClientHeight = 326
ClientWidth = 739
DockSite = True
TabOrder = 4
@ -270,7 +270,7 @@ object Form1: TForm1
OnDockOver = ScriptPanelDockOver
object PageControl1: TPageControl
Left = 155
Height = 294
Height = 291
Top = 0
Width = 584
Align = alClient
@ -289,7 +289,7 @@ object Form1: TForm1
object SearchPanel: TPanel
Left = 0
Height = 35
Top = 294
Top = 291
Width = 739
Align = alBottom
BevelOuter = bvSpace
@ -385,7 +385,7 @@ object Form1: TForm1
end
object LabeledEditSearch: TLabeledEdit
Left = 104
Height = 21
Height = 27
Top = 6
Width = 174
EditLabel.AnchorSideLeft.Control = LabeledEditSearch
@ -393,10 +393,10 @@ object Form1: TForm1
EditLabel.AnchorSideTop.Side = asrCenter
EditLabel.AnchorSideRight.Control = LabeledEditSearch
EditLabel.AnchorSideBottom.Control = LabeledEditSearch
EditLabel.Left = 73
EditLabel.Height = 14
EditLabel.Top = 9
EditLabel.Width = 28
EditLabel.Left = 67
EditLabel.Height = 18
EditLabel.Top = 10
EditLabel.Width = 34
EditLabel.Caption = 'Find: '
EditLabel.ParentColor = False
LabelPosition = lpLeft
@ -409,9 +409,9 @@ object Form1: TForm1
end
object CheckBoxMatchCase: TCheckBox
Left = 320
Height = 17
Height = 22
Top = 7
Width = 72
Width = 97
Caption = 'Match case'
OnClick = CheckBoxMatchCaseClick
TabOrder = 1
@ -419,34 +419,38 @@ object Form1: TForm1
end
object SplitterFunctionList: TSplitter
Left = 150
Height = 294
Height = 291
Top = 0
Width = 5
OnCanResize = SplitterFunctionListCanResize
Visible = False
end
inline frmFunctionList: TFunctionListFrame
Height = 294
Height = 291
Width = 150
ClientHeight = 294
ClientHeight = 291
ClientWidth = 150
OnEndDock = nil
TabOrder = 3
inherited FunctionList: TTreeView
Height = 255
Height = 242
Top = 22
Width = 150
DefaultItemHeight = 19
OnChange = FunctionListChange
OnEnter = FunctionListEnter
OnExit = FunctionListExit
end
inherited editSearchList: TEdit
Top = 273
Height = 27
Top = 264
Width = 150
OnExit = editSearchListExit
OnKeyDown = editSearchListKeyDown
OnKeyPress = editSearchListKeyPress
end
inherited FunctionListLabel: TLabel
Height = 18
Width = 146
end
end

View File

@ -42,7 +42,7 @@ uses
SynEditMarkupHighAll, LMessages, Buttons,
stringutil,mufasatypesutil,mufasabase,
about, framefunctionlist, ocr, updateform, simbasettings,
eventextension;
extensionmanager;
const
SimbaVersion = 585;
@ -2007,9 +2007,18 @@ begin
end;
procedure TForm1.ButtonTrayClick(Sender: TObject);
{var
Ext: TSimbaPSEventExtension; }
{ FIXME: Turning it into a test button again... }
begin
Form1.Hide;
{ try
Ext := TSimbaPSEventExtension.Create(MainDir + DS + 'Extensions' + DS + 'test.pas');
Ext.Free;
except
Writeln('Something went wrong with the Extensions.');
end; }
end;
procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean

View File

@ -14,7 +14,7 @@ type
function HookExists(HookName: String): Boolean; virtual; abstract;
{ 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
FName: String;