plugin limit removed by Joel Faber
This commit is contained in:
parent
d6d1f4e5f7
commit
72d9245f74
@ -36,6 +36,27 @@ type
|
|||||||
|
|
||||||
TBaseVariationClass = class of TBaseVariation;
|
TBaseVariationClass = class of TBaseVariation;
|
||||||
|
|
||||||
|
type
|
||||||
|
TVariationLoader = class
|
||||||
|
public
|
||||||
|
function GetName: string; virtual; abstract;
|
||||||
|
function GetInstance: TBaseVariation; virtual; abstract;
|
||||||
|
function GetNrVariables: integer; virtual; abstract;
|
||||||
|
function GetVariableNameAt(const Index: integer): string; virtual; abstract;
|
||||||
|
end;
|
||||||
|
|
||||||
|
type
|
||||||
|
TVariationClassLoader = class (TVariationLoader)
|
||||||
|
public
|
||||||
|
constructor Create(varClass : TBaseVariationClass);
|
||||||
|
function GetName: string; override;
|
||||||
|
function GetInstance: TBaseVariation; override;
|
||||||
|
function GetNrVariables: integer; override;
|
||||||
|
function GetVariableNameAt(const Index: integer): string; override;
|
||||||
|
|
||||||
|
private
|
||||||
|
VariationClass : TBaseVariationClass;
|
||||||
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -113,4 +134,32 @@ begin
|
|||||||
Delphi_Suxx := CalcFunction;
|
Delphi_Suxx := CalcFunction;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
{ TVariationClassLoader }
|
||||||
|
|
||||||
|
constructor TVariationClassLoader.Create(varClass : TBaseVariationClass);
|
||||||
|
begin
|
||||||
|
VariationClass := varClass;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TVariationClassLoader.GetName: string;
|
||||||
|
begin
|
||||||
|
Result := VariationClass.GetName();
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TVariationClassLoader.GetInstance: TBaseVariation;
|
||||||
|
begin
|
||||||
|
Result := VariationClass.GetInstance();
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TVariationClassLoader.GetNrVariables: integer;
|
||||||
|
begin
|
||||||
|
Result := VariationClass.GetNrVariables();
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TVariationClassLoader.GetVariableNameAt(const Index: integer): string;
|
||||||
|
begin
|
||||||
|
Result := VariationClass.GetVariableNameAt(Index);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -372,7 +372,8 @@ type
|
|||||||
oldx, oldy, olddist: double;
|
oldx, oldy, olddist: double;
|
||||||
Pivot: TSPoint;
|
Pivot: TSPoint;
|
||||||
|
|
||||||
VarsCache: array[0..64] of double; // hack: to prevent slow valuelist redraw
|
VarsCache: array[0..150] of double; // hack: to prevent slow valuelist redraw
|
||||||
|
// -JF- 64 wasn't big enough... buffer overrun
|
||||||
|
|
||||||
pnlDragMode: boolean;
|
pnlDragMode: boolean;
|
||||||
pnlDragPos, pnlDragOld: integer;
|
pnlDragPos, pnlDragOld: integer;
|
||||||
|
@ -198,12 +198,13 @@ end;
|
|||||||
procedure TFullscreenForm.OnProgress(prog: double);
|
procedure TFullscreenForm.OnProgress(prog: double);
|
||||||
begin
|
begin
|
||||||
prog := (Renderer.Slice + Prog) / Renderer.NrSlices;
|
prog := (Renderer.Slice + Prog) / Renderer.NrSlices;
|
||||||
if prog = 1 then
|
try
|
||||||
|
if prog >= 1 then
|
||||||
begin
|
begin
|
||||||
Canvas.Brush.Color := clBlack;
|
Canvas.Brush.Color := clBlack;
|
||||||
Canvas.FillRect(Rect(5, ClientHeight - 15, ClientWidth - 5, ClientHeight - 5));
|
Canvas.FillRect(Rect(5, ClientHeight - 15, ClientWidth - 5, ClientHeight - 5));
|
||||||
end
|
end
|
||||||
else begin
|
else if prog >= 0 then begin
|
||||||
Canvas.Brush.Color := clTeal;
|
Canvas.Brush.Color := clTeal;
|
||||||
Canvas.FrameRect(Rect(5, ClientHeight - 15, ClientWidth - 5, ClientHeight - 5));
|
Canvas.FrameRect(Rect(5, ClientHeight - 15, ClientWidth - 5, ClientHeight - 5));
|
||||||
Canvas.Brush.Color := clTeal;
|
Canvas.Brush.Color := clTeal;
|
||||||
@ -211,6 +212,8 @@ begin
|
|||||||
Canvas.Brush.Color := clBlack;
|
Canvas.Brush.Color := clBlack;
|
||||||
Canvas.Fillrect(Rect(7 + Round(prog * (ClientWidth - 14)), ClientHeight - 13, ClientWidth - 7, ClientHeight - 7));
|
Canvas.Fillrect(Rect(7 + Round(prog * (ClientWidth - 14)), ClientHeight - 13, ClientWidth - 7, ClientHeight - 7));
|
||||||
end;
|
end;
|
||||||
|
except
|
||||||
|
end;
|
||||||
Application.ProcessMessages;
|
Application.ProcessMessages;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ object ScriptEditor: TScriptEditor
|
|||||||
UrlStyle.BkColor = clWhite
|
UrlStyle.BkColor = clWhite
|
||||||
UrlStyle.Style = [fsUnderline]
|
UrlStyle.Style = [fsUnderline]
|
||||||
UseStyler = True
|
UseStyler = True
|
||||||
Version = '1.6.0.13'
|
Version = '1.6.0.17'
|
||||||
WordWrap = wwNone
|
WordWrap = wwNone
|
||||||
OnChange = EditorChange
|
OnChange = EditorChange
|
||||||
end
|
end
|
||||||
@ -609,6 +609,7 @@ object ScriptEditor: TScriptEditor
|
|||||||
LibOptions.SourceFileExt = '.psc'
|
LibOptions.SourceFileExt = '.psc'
|
||||||
LibOptions.CompiledFileExt = '.pcu'
|
LibOptions.CompiledFileExt = '.pcu'
|
||||||
LibOptions.UseScriptFiles = False
|
LibOptions.UseScriptFiles = False
|
||||||
|
CallExecHookEvent = False
|
||||||
Left = 360
|
Left = 360
|
||||||
Top = 32
|
Top = 32
|
||||||
end
|
end
|
||||||
|
@ -10,9 +10,9 @@ const
|
|||||||
|
|
||||||
function NrVar: integer;
|
function NrVar: integer;
|
||||||
function Varnames(const index: integer): String;
|
function Varnames(const index: integer): String;
|
||||||
procedure RegisterVariation(Variation: TBaseVariationClass);
|
procedure RegisterVariation(Variation: TVariationLoader);
|
||||||
function GetNrRegisteredVariations: integer;
|
function GetNrRegisteredVariations: integer;
|
||||||
function GetRegisteredVariation(const Index: integer): TBaseVariationClass;
|
function GetRegisteredVariation(const Index: integer): TVariationLoader;
|
||||||
function GetNrVariableNames: integer;
|
function GetNrVariableNames: integer;
|
||||||
function GetVariableNameAt(const Index: integer): string;
|
function GetVariableNameAt(const Index: integer): string;
|
||||||
function GetVariationIndex(const str: string): integer;
|
function GetVariationIndex(const str: string): integer;
|
||||||
@ -25,7 +25,8 @@ uses
|
|||||||
var
|
var
|
||||||
VariationList: TList;
|
VariationList: TList;
|
||||||
VariableNames: TStringlist;
|
VariableNames: TStringlist;
|
||||||
|
loaderNum : integer;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
function NrVar: integer;
|
function NrVar: integer;
|
||||||
begin
|
begin
|
||||||
@ -70,7 +71,7 @@ begin
|
|||||||
if Index < NRLOCVAR then
|
if Index < NRLOCVAR then
|
||||||
Result := cvarnames[Index]
|
Result := cvarnames[Index]
|
||||||
else
|
else
|
||||||
Result := TBaseVariationClass(VariationList[Index - NRLOCVAR]).GetName;
|
Result := TVariationLoader(VariationList[Index - NRLOCVAR]).GetName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -84,7 +85,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
procedure RegisterVariation(Variation: TBaseVariationClass);
|
procedure RegisterVariation(Variation: TVariationLoader);
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
@ -101,9 +102,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
function GetRegisteredVariation(const Index: integer): TBaseVariationClass;
|
function GetRegisteredVariation(const Index: integer): TVariationLoader;
|
||||||
begin
|
begin
|
||||||
Result := TBaseVariationClass(VariationList[Index]);
|
Result := TVariationLoader(VariationList[Index]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -122,7 +123,13 @@ end;
|
|||||||
initialization
|
initialization
|
||||||
VariationList := TList.Create;
|
VariationList := TList.Create;
|
||||||
VariableNames := TStringlist.create;
|
VariableNames := TStringlist.create;
|
||||||
|
|
||||||
finalization
|
finalization
|
||||||
|
|
||||||
VariableNames.Free;
|
VariableNames.Free;
|
||||||
|
|
||||||
|
// The registered variation loaders are owned here, so we must free them.
|
||||||
|
for loaderNum := 0 to VariationList.Count-1 do
|
||||||
|
TVariationLoader(VariationList[loaderNum]).Free;
|
||||||
VariationList.Free;
|
VariationList.Free;
|
||||||
end.
|
end.
|
||||||
|
@ -21,9 +21,15 @@
|
|||||||
Variation Plugin DLL support for Apophysis:
|
Variation Plugin DLL support for Apophysis:
|
||||||
Generic Plugin Support Unit
|
Generic Plugin Support Unit
|
||||||
Started by Jed Kelsey, June 2007
|
Started by Jed Kelsey, June 2007
|
||||||
}
|
|
||||||
|
|
||||||
{TODO : Make it creating new classes at runtime for itself...}
|
|
||||||
|
|
||||||
|
Portions Copyright (C) 2008 Joel Faber
|
||||||
|
|
||||||
|
February 2008:
|
||||||
|
- Remove 30 plugin limit
|
||||||
|
- Reset variables
|
||||||
|
}
|
||||||
|
|
||||||
unit varGenericPlugin;
|
unit varGenericPlugin;
|
||||||
|
|
||||||
@ -33,21 +39,9 @@ uses
|
|||||||
BaseVariation, XFormMan,
|
BaseVariation, XFormMan,
|
||||||
Classes, //TStrings/TStringList
|
Classes, //TStrings/TStringList
|
||||||
SysUtils, //FindFirst/FindNext/FindClose
|
SysUtils, //FindFirst/FindNext/FindClose
|
||||||
Dialogs; //ShowMessage
|
Forms; //MessageBox
|
||||||
|
|
||||||
type
|
type
|
||||||
// TPluginVarGetName = function : PChar; cdecl;
|
|
||||||
// TPluginVarGetNrVariables = function : Integer; cdecl;
|
|
||||||
// TPluginVarGetVariableNameAt = function(const Index: integer): PChar; cdecl;
|
|
||||||
|
|
||||||
// TPluginVarCreate = function : Pointer; cdecl;
|
|
||||||
// TPluginVarDestroy = function(var MyVariation : Pointer) : LongBool; cdecl;
|
|
||||||
// TPluginVarInit = function(MyVariation, FPx, FPy, FTx, FTy: Pointer; vvar: double) : LongBool; cdecl;
|
|
||||||
// TPluginVarPrepare = function(MyVariation : Pointer) : LongBool; cdecl;
|
|
||||||
// TPluginVarCalc = function(MyVariation : Pointer) : LongBool; cdecl;
|
|
||||||
// TPluginVarGetVariable = function(MyVariation:Pointer; const Name: PChar; var value: double) : LongBool; cdecl;
|
|
||||||
// TPluginVarSetVariable = function(MyVariation:Pointer; const Name: PChar; var value: double) : LongBool; cdecl;
|
|
||||||
|
|
||||||
TPluginVariationClass = class of TPluginVariation;
|
TPluginVariationClass = class of TPluginVariation;
|
||||||
|
|
||||||
TPluginData = record
|
TPluginData = record
|
||||||
@ -59,14 +53,15 @@ type
|
|||||||
PluginVarGetNrVariables: function: Integer; cdecl;
|
PluginVarGetNrVariables: function: Integer; cdecl;
|
||||||
PluginVarGetVariableNameAt: function(const Index: integer): PChar; cdecl;
|
PluginVarGetVariableNameAt: function(const Index: integer): PChar; cdecl;
|
||||||
|
|
||||||
PluginVarCreate: function: Pointer; cdecl;
|
PluginVarCreate: function: Pointer; cdecl;
|
||||||
PluginVarDestroy: function(var MyVariation: Pointer): LongBool; cdecl;
|
PluginVarDestroy: function(var MyVariation: Pointer): LongBool; cdecl;
|
||||||
PluginVarInit: function(MyVariation, FPx, FPy, FTx, FTy: Pointer; vvar: double): LongBool; cdecl;
|
PluginVarInit: function(MyVariation, FPx, FPy, FTx, FTy: Pointer; vvar: double): LongBool; cdecl;
|
||||||
PluginVarInit3D: function(MyVariation, FPx, FPy, FPz, FTx, FTy, FTz: Pointer; vvar: double): LongBool; cdecl;
|
PluginVarInit3D: function(MyVariation, FPx, FPy, FPz, FTx, FTy, FTz: Pointer; vvar: double): LongBool; cdecl;
|
||||||
PluginVarPrepare: function(MyVariation: Pointer): LongBool; cdecl;
|
PluginVarPrepare: function(MyVariation: Pointer): LongBool; cdecl;
|
||||||
PluginVarCalc: function(MyVariation: Pointer): LongBool; cdecl;
|
PluginVarCalc: function(MyVariation: Pointer): LongBool; cdecl;
|
||||||
PluginVarGetVariable: function(MyVariation: Pointer; const Name: PChar; var value: double): LongBool; cdecl;
|
PluginVarGetVariable: function(MyVariation: Pointer; const Name: PChar; var value: double): LongBool; cdecl;
|
||||||
PluginVarSetVariable: function(MyVariation: Pointer; const Name: PChar; var value: double): LongBool; cdecl;
|
PluginVarSetVariable: function(MyVariation: Pointer; const Name: PChar; var value: double): LongBool; cdecl;
|
||||||
|
PluginVarResetVariable:function(MyVariation: Pointer; const Name: PChar) : LongBool; cdecl;
|
||||||
end;
|
end;
|
||||||
PPluginData = ^TPluginData;
|
PPluginData = ^TPluginData;
|
||||||
|
|
||||||
@ -74,159 +69,39 @@ type
|
|||||||
TPluginVariation = class(TBaseVariation)
|
TPluginVariation = class(TBaseVariation)
|
||||||
|
|
||||||
private
|
private
|
||||||
|
PluginData : TPluginData;
|
||||||
MyVariation : Pointer;
|
MyVariation : Pointer;
|
||||||
|
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create(varData : TPluginData);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
class function GetName: string; override;
|
class function GetName: string; override;
|
||||||
class function GetInstance: TBaseVariation; override;
|
class function GetInstance: TBaseVariation; override;
|
||||||
|
|
||||||
class function GetNrVariables: integer; override;
|
|
||||||
class function GetVariableNameAt(const Index: integer): string; override;
|
|
||||||
|
|
||||||
function SetVariable(const Name: string; var value: double): boolean; override;
|
function SetVariable(const Name: string; var value: double): boolean; override;
|
||||||
function GetVariable(const Name: string; var value: double): boolean; override;
|
function GetVariable(const Name: string; var value: double): boolean; override;
|
||||||
|
function ResetVariable(const Name: string): boolean; override;
|
||||||
|
|
||||||
procedure Prepare; override;
|
procedure Prepare; override;
|
||||||
procedure CalcFunction; override;
|
procedure CalcFunction; override;
|
||||||
|
|
||||||
class function GetPluginData : PPluginData; virtual;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
type
|
||||||
|
TVariationPluginLoader = class (TVariationLoader)
|
||||||
|
public
|
||||||
|
constructor Create(varData : TPluginData);
|
||||||
|
destructor Destroy; override;
|
||||||
|
|
||||||
|
function GetName: string; override;
|
||||||
|
function GetInstance: TBaseVariation; override;
|
||||||
|
function GetNrVariables: integer; override;
|
||||||
|
function GetVariableNameAt(const Index: integer): string; override;
|
||||||
|
|
||||||
|
private
|
||||||
|
PluginData : TPluginData;
|
||||||
|
end;
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
{
|
|
||||||
Either this, either interfaces...
|
|
||||||
Anyone has some other suggestion?... :) please?
|
|
||||||
}
|
|
||||||
|
|
||||||
TPluginVariation0 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation1 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation2 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation3 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation4 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation5 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation6 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation7 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation8 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation9 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation10 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation11 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation12 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation13 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation14 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation15 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation16 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation17 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation18 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation19 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation20 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation21 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation22 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation23 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation24 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation25 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation26 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation27 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation28 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TPluginVariation29 = class(TPluginVariation)
|
|
||||||
class function GetPluginData : PPluginData; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
var
|
|
||||||
//PluginVariationClasses : array of TPluginVariationClass;
|
|
||||||
PluginData : array of TPluginData;
|
|
||||||
NumPlugins : Integer;
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -238,260 +113,119 @@ uses
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
{ These overridden functions are explicitly defined here to ensure that they
|
constructor TVariationPluginLoader.Create(varData : TPluginData);
|
||||||
return the appropriate data record for the class (need to have one per
|
|
||||||
derived class so that class methods for multiple plugins get executed
|
|
||||||
correctly. Again, I'm sure there's a much better way around this, but being
|
|
||||||
new to Delphi, I don't know what it is. }
|
|
||||||
|
|
||||||
class function TPluginVariation.GetPluginData : PPluginData;
|
|
||||||
begin
|
begin
|
||||||
Result := @(PluginData[0]); // As the base class, this shouldn't get called...
|
PluginData := varData;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TPluginVariation0.GetPluginData : PPluginData;
|
destructor TVariationPluginLoader.Destroy;
|
||||||
begin
|
begin
|
||||||
Result := @(PluginData[0]);
|
FreeLibrary(PluginData.PluginHandle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TPluginVariation1.GetPluginData : PPluginData;
|
function TVariationPluginLoader.GetName : string;
|
||||||
begin
|
begin
|
||||||
Result := @(PluginData[1]);
|
Result := PluginData.PluginVarGetName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TPluginVariation2.GetPluginData : PPluginData;
|
function TVariationPluginLoader.GetInstance: TBaseVariation;
|
||||||
begin
|
begin
|
||||||
Result := @(PluginData[2]);
|
Result := TPluginVariation.Create(PluginData);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TPluginVariation3.GetPluginData : PPluginData;
|
function TVariationPluginLoader.GetNrVariables: integer;
|
||||||
begin
|
begin
|
||||||
Result := @(PluginData[3]);
|
Result := PluginData.PluginVarGetNrVariables;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TPluginVariation4.GetPluginData : PPluginData;
|
function TVariationPluginLoader.GetVariableNameAt(const Index: integer): string;
|
||||||
begin
|
begin
|
||||||
Result := @(PluginData[4]);
|
Result := PluginData.PluginVarGetVariableNameAt(Index);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TPluginVariation5.GetPluginData : PPluginData;
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
begin
|
|
||||||
Result := @(PluginData[5]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation6.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[6]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation7.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[7]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation8.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[8]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation9.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[9]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation10.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[10]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation11.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[11]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation12.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[12]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation13.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[13]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation14.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[14]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation15.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[15]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation16.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[16]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation17.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[17]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation18.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[18]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation19.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[19]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation20.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[20]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation21.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[21]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation22.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[22]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation23.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[23]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation24.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[24]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation25.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[25]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation26.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[26]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation27.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[27]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation28.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[28]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TPluginVariation29.GetPluginData : PPluginData;
|
|
||||||
begin
|
|
||||||
Result := @(PluginData[29]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
//////////// ////////// ////////////
|
|
||||||
|
|
||||||
procedure TPluginVariation.Prepare;
|
procedure TPluginVariation.Prepare;
|
||||||
begin
|
begin
|
||||||
with GetPluginData^ do begin
|
PluginData.PluginVarInit(MyVariation, Pointer(FPx), Pointer(FPy), Pointer(FTx), Pointer(FTy), vvar);
|
||||||
// if @PluginVarInit3D <> nil then
|
PluginData.PluginVarPrepare(MyVariation);
|
||||||
// PluginVarInit3D(MyVariation, Pointer(FPX), Pointer(FPy), Pointer(FPz), Pointer(FTx), Pointer(FTy), Pointer(FTz), vvar)
|
|
||||||
// else
|
|
||||||
PluginVarInit(MyVariation, Pointer(FPX), Pointer(FPy), Pointer(FTx), Pointer(FTy), vvar);
|
|
||||||
PluginVarPrepare(MyVariation);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
procedure TPluginVariation.CalcFunction;
|
procedure TPluginVariation.CalcFunction;
|
||||||
begin
|
begin
|
||||||
GetPluginData.PluginVarCalc(MyVariation);
|
PluginData.PluginVarCalc(MyVariation);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
constructor TPluginVariation.Create;
|
constructor TPluginVariation.Create(varData : TPluginData);
|
||||||
begin
|
begin
|
||||||
MyVariation := GetPluginData.PluginVarCreate;
|
PluginData := varData;
|
||||||
|
MyVariation := PluginData.PluginVarCreate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
destructor TPluginVariation.Destroy;
|
destructor TPluginVariation.Destroy;
|
||||||
begin
|
begin
|
||||||
GetPluginData.PluginVarDestroy(MyVariation);
|
PluginData.PluginVarDestroy(MyVariation);
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
class function TPluginVariation.GetInstance: TBaseVariation;
|
class function TPluginVariation.GetInstance: TBaseVariation;
|
||||||
begin
|
begin
|
||||||
Result := Self.Create;
|
Result := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
class function TPluginVariation.GetName: string;
|
class function TPluginVariation.GetName: string;
|
||||||
begin
|
begin
|
||||||
Result := String(GetPluginData.PluginVarGetName());
|
Result := '';
|
||||||
end;
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
class function TPluginVariation.GetNrVariables: integer;
|
|
||||||
begin
|
|
||||||
Result := GetPluginData.PluginVarGetNrVariables();
|
|
||||||
end;
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
class function TPluginVariation.GetVariableNameAt(const Index: integer): string;
|
|
||||||
begin
|
|
||||||
Result := String(GetPluginData.PluginVarGetVariableNameAt(Index));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
function TPluginVariation.SetVariable(const Name: string; var value: double): boolean;
|
function TPluginVariation.SetVariable(const Name: string; var value: double): boolean;
|
||||||
begin
|
begin
|
||||||
Result := GetPluginData.PluginVarSetVariable(MyVariation,PChar(Name),value);
|
Result := PluginData.PluginVarSetVariable(MyVariation,PChar(Name),value);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
function TPluginVariation.GetVariable(const Name: string; var value: double): boolean;
|
function TPluginVariation.GetVariable(const Name: string; var value: double): boolean;
|
||||||
begin
|
begin
|
||||||
Result := GetPluginData.PluginVarGetVariable(MyVariation,PChar(Name),value);
|
Result := PluginData.PluginVarGetVariable(MyVariation,PChar(Name),value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
function TPluginVariation.ResetVariable(const Name: string) : boolean;
|
||||||
|
begin
|
||||||
|
Result := PluginData.PluginVarResetVariable(MyVariation, PChar(Name));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
procedure InitializePlugins;
|
procedure InitializePlugins;
|
||||||
var
|
var
|
||||||
searchResult: TSearchRec;
|
searchResult: TSearchRec;
|
||||||
name: string;
|
name, msg: string;
|
||||||
|
PluginData : TPluginData;
|
||||||
begin
|
begin
|
||||||
NumPlugins := 0;
|
|
||||||
// Try to find regular files matching *.dll in the plugins dir
|
// Try to find regular files matching *.dll in the plugins dir
|
||||||
if FindFirst('.\Plugins\*.dll', faAnyFile, searchResult) = 0 then
|
if FindFirst('.\Plugins\*.dll', faAnyFile, searchResult) = 0 then
|
||||||
begin
|
begin
|
||||||
repeat
|
repeat
|
||||||
with PluginData[NumPlugins] do begin
|
with PluginData do begin
|
||||||
//Load DLL and initialize plugins!
|
//Load DLL and initialize plugins!
|
||||||
PluginHandle := LoadLibrary(PChar('.\Plugins\'+searchResult.Name));
|
PluginHandle := LoadLibrary(PChar('.\Plugins\'+searchResult.Name));
|
||||||
if PluginHandle<>0 then begin
|
if PluginHandle<>0 then begin
|
||||||
@PluginVarGetName := GetProcAddress(PluginHandle,'PluginVarGetName');
|
@PluginVarGetName := GetProcAddress(PluginHandle,'PluginVarGetName');
|
||||||
if @PluginVarGetName = nil then begin // Must not be a valid plugin!
|
if @PluginVarGetName = nil then begin // Must not be a valid plugin!
|
||||||
FreeLibrary(PluginHandle);
|
FreeLibrary(PluginHandle);
|
||||||
ShowMessage('Invalid Plugin: Could not find PluginVarGetName in '+searchResult.Name);
|
msg := msg + 'Invalid plugin type: "'+searchResult.Name + '" is not a plugin' + #13#10;
|
||||||
continue;
|
continue;
|
||||||
end;
|
end;
|
||||||
name := PluginVarGetName;
|
name := PluginVarGetName;
|
||||||
if GetVariationIndex(name) >= 0 then begin
|
if GetVariationIndex(name) >= 0 then begin
|
||||||
FreeLibrary(PluginHandle);
|
FreeLibrary(PluginHandle);
|
||||||
ShowMessage('Plugin "' + searchResult.Name + '" not loaded: Variation ' + name + ' already exists!');
|
msg := msg + 'Cannot load plugin from ' + searchResult.Name + ': variation "' + name + '" already exists!' + #13#10;
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
@PluginVarGetNrVariables := GetProcAddress(PluginHandle,'PluginVarGetNrVariables');
|
@PluginVarGetNrVariables := GetProcAddress(PluginHandle,'PluginVarGetNrVariables');
|
||||||
@ -504,75 +238,22 @@ begin
|
|||||||
@PluginVarCalc := GetProcAddress(PluginHandle,'PluginVarCalc');
|
@PluginVarCalc := GetProcAddress(PluginHandle,'PluginVarCalc');
|
||||||
@PluginVarGetVariable := GetProcAddress(PluginHandle,'PluginVarGetVariable');
|
@PluginVarGetVariable := GetProcAddress(PluginHandle,'PluginVarGetVariable');
|
||||||
@PluginVarSetVariable := GetProcAddress(PluginHandle,'PluginVarSetVariable');
|
@PluginVarSetVariable := GetProcAddress(PluginHandle,'PluginVarSetVariable');
|
||||||
|
@PluginVarResetVariable := GetProcAddress(PluginHandle,'PluginVarResetVariable');
|
||||||
|
|
||||||
Instance := NumPlugins+1;
|
RegisterVariation(TVariationPluginLoader.Create(PluginData));
|
||||||
|
|
||||||
RegisterVariation(PluginClass);
|
|
||||||
|
|
||||||
Inc(NumPlugins);
|
|
||||||
if NumPlugins >= Length(PluginData) then
|
|
||||||
break;
|
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
ShowMessage('Could not load a plugin: '+searchResult.Name);
|
msg := msg + 'Cannot open plugin file: '+searchResult.Name + #13#10;
|
||||||
end;
|
end;
|
||||||
until (FindNext(searchResult) <> 0);
|
until (FindNext(searchResult) <> 0);
|
||||||
SysUtils.FindClose(searchResult); //Since we use Windows unit (LoadLibrary)
|
SysUtils.FindClose(searchResult); //Since we use Windows unit (LoadLibrary)
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
if msg <> '' then Application.MessageBox(PChar('There were problems with some of the plugins:' + #13#10#13#10 + msg), 'Warning', MB_OK);
|
||||||
procedure FinalizePlugins;
|
|
||||||
var
|
|
||||||
I : Integer;
|
|
||||||
begin
|
|
||||||
for I := 0 to NumPlugins - 1 do begin
|
|
||||||
if PluginData[NumPlugins].PluginHandle<>0 then begin
|
|
||||||
FreeLibrary(PluginData[NumPlugins].PluginHandle);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
initialization
|
initialization
|
||||||
SetLength(PluginData,30);
|
|
||||||
|
|
||||||
PluginData[0].PluginClass := TPluginVariation0;
|
|
||||||
PluginData[1].PluginClass := TPluginVariation1;
|
|
||||||
PluginData[2].PluginClass := TPluginVariation2;
|
|
||||||
PluginData[3].PluginClass := TPluginVariation3;
|
|
||||||
PluginData[4].PluginClass := TPluginVariation4;
|
|
||||||
PluginData[5].PluginClass := TPluginVariation5;
|
|
||||||
PluginData[6].PluginClass := TPluginVariation6;
|
|
||||||
PluginData[7].PluginClass := TPluginVariation7;
|
|
||||||
PluginData[8].PluginClass := TPluginVariation8;
|
|
||||||
PluginData[9].PluginClass := TPluginVariation9;
|
|
||||||
PluginData[10].PluginClass := TPluginVariation10;
|
|
||||||
PluginData[11].PluginClass := TPluginVariation11;
|
|
||||||
PluginData[12].PluginClass := TPluginVariation12;
|
|
||||||
PluginData[13].PluginClass := TPluginVariation13;
|
|
||||||
PluginData[14].PluginClass := TPluginVariation14;
|
|
||||||
PluginData[15].PluginClass := TPluginVariation15;
|
|
||||||
PluginData[16].PluginClass := TPluginVariation16;
|
|
||||||
PluginData[17].PluginClass := TPluginVariation17;
|
|
||||||
PluginData[18].PluginClass := TPluginVariation18;
|
|
||||||
PluginData[19].PluginClass := TPluginVariation19;
|
|
||||||
PluginData[20].PluginClass := TPluginVariation20;
|
|
||||||
PluginData[21].PluginClass := TPluginVariation21;
|
|
||||||
PluginData[22].PluginClass := TPluginVariation22;
|
|
||||||
PluginData[23].PluginClass := TPluginVariation23;
|
|
||||||
PluginData[24].PluginClass := TPluginVariation24;
|
|
||||||
PluginData[25].PluginClass := TPluginVariation25;
|
|
||||||
PluginData[26].PluginClass := TPluginVariation26;
|
|
||||||
PluginData[27].PluginClass := TPluginVariation27;
|
|
||||||
PluginData[28].PluginClass := TPluginVariation28;
|
|
||||||
PluginData[29].PluginClass := TPluginVariation29;
|
|
||||||
|
|
||||||
InitializePlugins;
|
InitializePlugins;
|
||||||
|
|
||||||
|
|
||||||
finalization
|
|
||||||
//Release all loaded plugin(s)
|
|
||||||
FinalizePlugins;
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user