diff --git a/Source/simba.target.pas b/Source/simba.target.pas index 177838fea..a4aad9847 100644 --- a/Source/simba.target.pas +++ b/Source/simba.target.pas @@ -357,6 +357,8 @@ procedure TSimbaTarget.SetEIOS(FileName, Args: String); FMethods.GetDimensions := @EIOSTarget_GetDimensions; FMethods.GetImageData := @EIOSTarget_GetImageData; + + FMethods.IsValid := @EIOSTarget_IsValid; end; procedure TSimbaTarget.SetPlugin(FileName, Args: String); @@ -364,6 +366,7 @@ procedure TSimbaTarget.SetPlugin(FileName, Args: String); ChangeTarget(ETargetType.PLUGIN); FTargetPlugin := LoadPluginTarget(FileName, Args); + FTarget := @FTargetPlugin; FMethods.KeyDown := @PluginTarget_KeyDown; FMethods.KeyUp := @PluginTarget_KeyUp; @@ -379,6 +382,8 @@ procedure TSimbaTarget.SetPlugin(FileName, Args: String); FMethods.GetDimensions := @PluginTarget_GetDimensions; FMethods.GetImageData := @PluginTarget_GetImageData; + + FMethods.IsValid := @PluginTarget_IsValid; end; procedure TSimbaTarget.SetPlugin(FileName, Args: String; out DebugImage: TSimbaExternalImage); diff --git a/Source/targets/simba.target_eios.pas b/Source/targets/simba.target_eios.pas index d7e880444..c1570bb9b 100644 --- a/Source/targets/simba.target_eios.pas +++ b/Source/targets/simba.target_eios.pas @@ -95,6 +95,8 @@ procedure EIOSTarget_MouseDown(Target: Pointer; Button: EMouseButton); procedure EIOSTarget_MouseUp(Target: Pointer; Button: EMouseButton); procedure EIOSTarget_MouseScroll(Target: Pointer; Scrolls: Integer); +function EIOSTarget_IsValid(Target: Pointer): Boolean; + implementation uses @@ -253,6 +255,11 @@ procedure EIOSTarget_MouseScroll(Target: Pointer; Scrolls: Integer); end; end; +function EIOSTarget_IsValid(Target: Pointer): Boolean; +begin + Result := True; +end; + procedure EIOSTarget_KeyDown(Target: Pointer; Key: EKeyCode); begin with PEIOSTarget(Target)^ do diff --git a/Source/targets/simba.target_plugin.pas b/Source/targets/simba.target_plugin.pas index c4d4e05b5..6a1812b10 100644 --- a/Source/targets/simba.target_plugin.pas +++ b/Source/targets/simba.target_plugin.pas @@ -53,11 +53,19 @@ procedure PluginTarget_KeyUp(Target: Pointer; Key: EKeyCode); procedure PluginTarget_KeySend(Target: Pointer; Key: Char; KeyDownTime, KeyUpTime, ModifierDownTime, ModifierUpTime: Integer); function PluginTarget_KeyPressed(Target: Pointer; Key: EKeyCode): Boolean; +function PluginTarget_IsValid(Target: Pointer): Boolean; + implementation uses simba.env, simba.files, simba.script_pluginloader; +procedure CheckExported(const MethodName: String; const Method: Pointer); inline; +begin + if (Method = nil) then + SimbaException('SimbaPluginTarget: "' + MethodName + '" is not exported'); +end; + function Load(AFileName: String): TSimbaPluginTarget; begin Result := Default(TSimbaPluginTarget); @@ -97,85 +105,148 @@ function Load(AFileName: String): TSimbaPluginTarget; function LoadPluginTarget(FileName, Args: String): TSimbaPluginTarget; begin Result := Load(FileName); - Result.Target := Result.Request(PChar(Args)); + with Result do + begin + CheckExported('SimbaPluginTarget_Request', Request); + + Result.Target := Result.Request(PChar(Args)); + end; end; function LoadPluginTarget(FileName, Args: String; out DebugImage: TSimbaExternalImage): TSimbaPluginTarget; begin Result := Load(FileName); - Result.Target := Result.RequestWithDebugImage(PChar(Args), DebugImage); + with Result do + begin + CheckExported('SimbaPluginTarget_RequestWithDebugImage', RequestWithDebugImage); + + Target := Result.RequestWithDebugImage(PChar(Args), DebugImage); + end; end; procedure PluginTarget_GetDimensions(Target: Pointer; out W, H: Integer); begin with PSimbaPluginTarget(Target)^ do + begin + CheckExported('SimbaPluginTarget_GetDimensions', GetDimensions); + GetDimensions(Target, W, H); + end; end; function PluginTarget_GetImageData(Target: Pointer; X, Y, Width, Height: Integer; var Data: PColorBGRA; var DataWidth: Integer): Boolean; begin with PSimbaPluginTarget(Target)^ do + begin + CheckExported('SimbaPluginTarget_GetImageData', GetImageData); + Result := GetImageData(Target, X, Y, Width, Height, Data, DataWidth); + end; end; function PluginTarget_MousePressed(Target: Pointer; Button: EMouseButton): Boolean; begin with PSimbaPluginTarget(Target)^ do + begin + CheckExported('SimbaPluginTarget_MousePressed', MousePressed); + Result := MousePressed(Target, Integer(Button)); + end; end; function PluginTarget_MousePosition(Target: Pointer): TPoint; begin with PSimbaPluginTarget(Target)^ do + begin + CheckExported('SimbaPluginTarget_MousePosition', MousePosition); + Result := MousePosition(Target); + end; end; procedure PluginTarget_MouseTeleport(Target: Pointer; P: TPoint); begin with PSimbaPluginTarget(Target)^ do + begin + CheckExported('SimbaPluginTarget_MouseTeleport', MouseTeleport); + MouseTeleport(Target, P); + end; end; procedure PluginTarget_MouseUp(Target: Pointer; Button: EMouseButton); begin with PSimbaPluginTarget(Target)^ do + begin + CheckExported('SimbaPluginTarget_MouseUp', MouseUp); + MouseUp(Target, Integer(Button)); + end; end; procedure PluginTarget_MouseDown(Target: Pointer; Button: EMouseButton); begin with PSimbaPluginTarget(Target)^ do + begin + CheckExported('SimbaPluginTarget_MouseDown', MouseDown); + MouseDown(Target, Integer(Button)); + end; end; procedure PluginTarget_MouseScroll(Target: Pointer; Scrolls: Integer); begin with PSimbaPluginTarget(Target)^ do + begin + CheckExported('SimbaPluginTarget_MouseScroll', MouseScroll); + MouseScroll(Target, Scrolls); + end; end; procedure PluginTarget_KeyDown(Target: Pointer; Key: EKeyCode); begin with PSimbaPluginTarget(Target)^ do + begin + CheckExported('SimbaPluginTarget_KeyDown', KeyDown); + KeyDown(Target, Integer(Key)); + end; end; procedure PluginTarget_KeyUp(Target: Pointer; Key: EKeyCode); begin with PSimbaPluginTarget(Target)^ do + begin + CheckExported('SimbaPluginTarget_KeyUp', KeyUp); + KeyUp(Target, Integer(Key)); + end; end; procedure PluginTarget_KeySend(Target: Pointer; Key: Char; KeyDownTime, KeyUpTime, ModifierDownTime, ModifierUpTime: Integer); begin with PSimbaPluginTarget(Target)^ do + begin + CheckExported('SimbaPluginTarget_KeySend', KeySend); + KeySend(Target, Key, KeyDownTime, KeyUpTime, ModifierDownTime, ModifierUpTime); + end; end; function PluginTarget_KeyPressed(Target: Pointer; Key: EKeyCode): Boolean; begin with PSimbaPluginTarget(Target)^ do + begin + CheckExported('SimbaPluginTarget_KeyPressed', KeyPressed); + Result := KeyPressed(Target, Integer(Key)); + end; +end; + +function PluginTarget_IsValid(Target: Pointer): Boolean; +begin + Result := True; end; end.