plugin limit removed by Joel Faber
This commit is contained in:
parent
d6d1f4e5f7
commit
72d9245f74
@ -36,6 +36,27 @@ type
|
||||
|
||||
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
|
||||
|
||||
@ -113,4 +134,32 @@ begin
|
||||
Delphi_Suxx := CalcFunction;
|
||||
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.
|
||||
|
@ -372,7 +372,8 @@ type
|
||||
oldx, oldy, olddist: double;
|
||||
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;
|
||||
pnlDragPos, pnlDragOld: integer;
|
||||
|
@ -198,12 +198,13 @@ end;
|
||||
procedure TFullscreenForm.OnProgress(prog: double);
|
||||
begin
|
||||
prog := (Renderer.Slice + Prog) / Renderer.NrSlices;
|
||||
if prog = 1 then
|
||||
try
|
||||
if prog >= 1 then
|
||||
begin
|
||||
Canvas.Brush.Color := clBlack;
|
||||
Canvas.FillRect(Rect(5, ClientHeight - 15, ClientWidth - 5, ClientHeight - 5));
|
||||
end
|
||||
else begin
|
||||
else if prog >= 0 then begin
|
||||
Canvas.Brush.Color := clTeal;
|
||||
Canvas.FrameRect(Rect(5, ClientHeight - 15, ClientWidth - 5, ClientHeight - 5));
|
||||
Canvas.Brush.Color := clTeal;
|
||||
@ -211,6 +212,8 @@ begin
|
||||
Canvas.Brush.Color := clBlack;
|
||||
Canvas.Fillrect(Rect(7 + Round(prog * (ClientWidth - 14)), ClientHeight - 13, ClientWidth - 7, ClientHeight - 7));
|
||||
end;
|
||||
except
|
||||
end;
|
||||
Application.ProcessMessages;
|
||||
end;
|
||||
|
||||
|
@ -191,7 +191,7 @@ object ScriptEditor: TScriptEditor
|
||||
UrlStyle.BkColor = clWhite
|
||||
UrlStyle.Style = [fsUnderline]
|
||||
UseStyler = True
|
||||
Version = '1.6.0.13'
|
||||
Version = '1.6.0.17'
|
||||
WordWrap = wwNone
|
||||
OnChange = EditorChange
|
||||
end
|
||||
@ -609,6 +609,7 @@ object ScriptEditor: TScriptEditor
|
||||
LibOptions.SourceFileExt = '.psc'
|
||||
LibOptions.CompiledFileExt = '.pcu'
|
||||
LibOptions.UseScriptFiles = False
|
||||
CallExecHookEvent = False
|
||||
Left = 360
|
||||
Top = 32
|
||||
end
|
||||
|
@ -10,9 +10,9 @@ const
|
||||
|
||||
function NrVar: integer;
|
||||
function Varnames(const index: integer): String;
|
||||
procedure RegisterVariation(Variation: TBaseVariationClass);
|
||||
procedure RegisterVariation(Variation: TVariationLoader);
|
||||
function GetNrRegisteredVariations: integer;
|
||||
function GetRegisteredVariation(const Index: integer): TBaseVariationClass;
|
||||
function GetRegisteredVariation(const Index: integer): TVariationLoader;
|
||||
function GetNrVariableNames: integer;
|
||||
function GetVariableNameAt(const Index: integer): string;
|
||||
function GetVariationIndex(const str: string): integer;
|
||||
@ -25,7 +25,8 @@ uses
|
||||
var
|
||||
VariationList: TList;
|
||||
VariableNames: TStringlist;
|
||||
|
||||
loaderNum : integer;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
function NrVar: integer;
|
||||
begin
|
||||
@ -70,7 +71,7 @@ begin
|
||||
if Index < NRLOCVAR then
|
||||
Result := cvarnames[Index]
|
||||
else
|
||||
Result := TBaseVariationClass(VariationList[Index - NRLOCVAR]).GetName;
|
||||
Result := TVariationLoader(VariationList[Index - NRLOCVAR]).GetName;
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -84,7 +85,7 @@ begin
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
procedure RegisterVariation(Variation: TBaseVariationClass);
|
||||
procedure RegisterVariation(Variation: TVariationLoader);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
@ -101,9 +102,9 @@ begin
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
function GetRegisteredVariation(const Index: integer): TBaseVariationClass;
|
||||
function GetRegisteredVariation(const Index: integer): TVariationLoader;
|
||||
begin
|
||||
Result := TBaseVariationClass(VariationList[Index]);
|
||||
Result := TVariationLoader(VariationList[Index]);
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -122,7 +123,13 @@ end;
|
||||
initialization
|
||||
VariationList := TList.Create;
|
||||
VariableNames := TStringlist.create;
|
||||
|
||||
finalization
|
||||
|
||||
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;
|
||||
end.
|
||||
|
@ -21,9 +21,15 @@
|
||||
Variation Plugin DLL support for Apophysis:
|
||||
Generic Plugin Support Unit
|
||||
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;
|
||||
|
||||
@ -33,21 +39,9 @@ uses
|
||||
BaseVariation, XFormMan,
|
||||
Classes, //TStrings/TStringList
|
||||
SysUtils, //FindFirst/FindNext/FindClose
|
||||
Dialogs; //ShowMessage
|
||||
Forms; //MessageBox
|
||||
|
||||
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;
|
||||
|
||||
TPluginData = record
|
||||
@ -59,14 +53,15 @@ type
|
||||
PluginVarGetNrVariables: function: Integer; cdecl;
|
||||
PluginVarGetVariableNameAt: function(const Index: integer): PChar; cdecl;
|
||||
|
||||
PluginVarCreate: function: Pointer; cdecl;
|
||||
PluginVarDestroy: function(var MyVariation: Pointer): 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;
|
||||
PluginVarPrepare: function(MyVariation: Pointer): LongBool; cdecl;
|
||||
PluginVarCalc: function(MyVariation: Pointer): 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;
|
||||
PluginVarCreate: function: Pointer; cdecl;
|
||||
PluginVarDestroy: function(var MyVariation: Pointer): 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;
|
||||
PluginVarPrepare: function(MyVariation: Pointer): LongBool; cdecl;
|
||||
PluginVarCalc: function(MyVariation: Pointer): 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;
|
||||
PluginVarResetVariable:function(MyVariation: Pointer; const Name: PChar) : LongBool; cdecl;
|
||||
end;
|
||||
PPluginData = ^TPluginData;
|
||||
|
||||
@ -74,159 +69,39 @@ type
|
||||
TPluginVariation = class(TBaseVariation)
|
||||
|
||||
private
|
||||
PluginData : TPluginData;
|
||||
MyVariation : Pointer;
|
||||
|
||||
public
|
||||
constructor Create;
|
||||
constructor Create(varData : TPluginData);
|
||||
destructor Destroy; override;
|
||||
|
||||
class function GetName: string; 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 GetVariable(const Name: string; var value: double): boolean; override;
|
||||
function ResetVariable(const Name: string): boolean; override;
|
||||
|
||||
procedure Prepare; override;
|
||||
procedure CalcFunction; override;
|
||||
|
||||
class function GetPluginData : PPluginData; virtual;
|
||||
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
|
||||
|
||||
@ -238,260 +113,119 @@ uses
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
{ These overridden functions are explicitly defined here to ensure that they
|
||||
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;
|
||||
constructor TVariationPluginLoader.Create(varData : TPluginData);
|
||||
begin
|
||||
Result := @(PluginData[0]); // As the base class, this shouldn't get called...
|
||||
PluginData := varData;
|
||||
end;
|
||||
|
||||
class function TPluginVariation0.GetPluginData : PPluginData;
|
||||
destructor TVariationPluginLoader.Destroy;
|
||||
begin
|
||||
Result := @(PluginData[0]);
|
||||
FreeLibrary(PluginData.PluginHandle);
|
||||
end;
|
||||
|
||||
class function TPluginVariation1.GetPluginData : PPluginData;
|
||||
function TVariationPluginLoader.GetName : string;
|
||||
begin
|
||||
Result := @(PluginData[1]);
|
||||
Result := PluginData.PluginVarGetName;
|
||||
end;
|
||||
|
||||
class function TPluginVariation2.GetPluginData : PPluginData;
|
||||
function TVariationPluginLoader.GetInstance: TBaseVariation;
|
||||
begin
|
||||
Result := @(PluginData[2]);
|
||||
Result := TPluginVariation.Create(PluginData);
|
||||
end;
|
||||
|
||||
class function TPluginVariation3.GetPluginData : PPluginData;
|
||||
function TVariationPluginLoader.GetNrVariables: integer;
|
||||
begin
|
||||
Result := @(PluginData[3]);
|
||||
Result := PluginData.PluginVarGetNrVariables;
|
||||
end;
|
||||
|
||||
class function TPluginVariation4.GetPluginData : PPluginData;
|
||||
function TVariationPluginLoader.GetVariableNameAt(const Index: integer): string;
|
||||
begin
|
||||
Result := @(PluginData[4]);
|
||||
Result := PluginData.PluginVarGetVariableNameAt(Index);
|
||||
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;
|
||||
begin
|
||||
with GetPluginData^ do begin
|
||||
// if @PluginVarInit3D <> nil then
|
||||
// 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;
|
||||
PluginData.PluginVarInit(MyVariation, Pointer(FPx), Pointer(FPy), Pointer(FTx), Pointer(FTy), vvar);
|
||||
PluginData.PluginVarPrepare(MyVariation);
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
procedure TPluginVariation.CalcFunction;
|
||||
begin
|
||||
GetPluginData.PluginVarCalc(MyVariation);
|
||||
PluginData.PluginVarCalc(MyVariation);
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
constructor TPluginVariation.Create;
|
||||
constructor TPluginVariation.Create(varData : TPluginData);
|
||||
begin
|
||||
MyVariation := GetPluginData.PluginVarCreate;
|
||||
PluginData := varData;
|
||||
MyVariation := PluginData.PluginVarCreate;
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
destructor TPluginVariation.Destroy;
|
||||
begin
|
||||
GetPluginData.PluginVarDestroy(MyVariation);
|
||||
PluginData.PluginVarDestroy(MyVariation);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class function TPluginVariation.GetInstance: TBaseVariation;
|
||||
begin
|
||||
Result := Self.Create;
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class function TPluginVariation.GetName: string;
|
||||
begin
|
||||
Result := String(GetPluginData.PluginVarGetName());
|
||||
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));
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
function TPluginVariation.SetVariable(const Name: string; var value: double): boolean;
|
||||
begin
|
||||
Result := GetPluginData.PluginVarSetVariable(MyVariation,PChar(Name),value);
|
||||
Result := PluginData.PluginVarSetVariable(MyVariation,PChar(Name),value);
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
function TPluginVariation.GetVariable(const Name: string; var value: double): boolean;
|
||||
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;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
procedure InitializePlugins;
|
||||
var
|
||||
searchResult: TSearchRec;
|
||||
name: string;
|
||||
name, msg: string;
|
||||
PluginData : TPluginData;
|
||||
begin
|
||||
NumPlugins := 0;
|
||||
// Try to find regular files matching *.dll in the plugins dir
|
||||
if FindFirst('.\Plugins\*.dll', faAnyFile, searchResult) = 0 then
|
||||
begin
|
||||
repeat
|
||||
with PluginData[NumPlugins] do begin
|
||||
with PluginData do begin
|
||||
//Load DLL and initialize plugins!
|
||||
PluginHandle := LoadLibrary(PChar('.\Plugins\'+searchResult.Name));
|
||||
if PluginHandle<>0 then begin
|
||||
@PluginVarGetName := GetProcAddress(PluginHandle,'PluginVarGetName');
|
||||
if @PluginVarGetName = nil then begin // Must not be a valid plugin!
|
||||
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;
|
||||
end;
|
||||
name := PluginVarGetName;
|
||||
if GetVariationIndex(name) >= 0 then begin
|
||||
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
|
||||
else begin
|
||||
@PluginVarGetNrVariables := GetProcAddress(PluginHandle,'PluginVarGetNrVariables');
|
||||
@ -504,75 +238,22 @@ begin
|
||||
@PluginVarCalc := GetProcAddress(PluginHandle,'PluginVarCalc');
|
||||
@PluginVarGetVariable := GetProcAddress(PluginHandle,'PluginVarGetVariable');
|
||||
@PluginVarSetVariable := GetProcAddress(PluginHandle,'PluginVarSetVariable');
|
||||
@PluginVarResetVariable := GetProcAddress(PluginHandle,'PluginVarResetVariable');
|
||||
|
||||
Instance := NumPlugins+1;
|
||||
|
||||
RegisterVariation(PluginClass);
|
||||
|
||||
Inc(NumPlugins);
|
||||
if NumPlugins >= Length(PluginData) then
|
||||
break;
|
||||
RegisterVariation(TVariationPluginLoader.Create(PluginData));
|
||||
end;
|
||||
end else
|
||||
ShowMessage('Could not load a plugin: '+searchResult.Name);
|
||||
msg := msg + 'Cannot open plugin file: '+searchResult.Name + #13#10;
|
||||
end;
|
||||
until (FindNext(searchResult) <> 0);
|
||||
SysUtils.FindClose(searchResult); //Since we use Windows unit (LoadLibrary)
|
||||
end;
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
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;
|
||||
if msg <> '' then Application.MessageBox(PChar('There were problems with some of the plugins:' + #13#10#13#10 + msg), 'Warning', MB_OK);
|
||||
end;
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
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;
|
||||
|
||||
|
||||
finalization
|
||||
//Release all loaded plugin(s)
|
||||
FinalizePlugins;
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user