added variable enumeration support
This commit is contained in:
parent
1036769a10
commit
3b71479a61
@ -177,6 +177,8 @@ type
|
|||||||
procedure SetTransformFProc(AMachine: TatVirtualMachine);
|
procedure SetTransformFProc(AMachine: TatVirtualMachine);
|
||||||
procedure GetTransformVarProc(AMachine: TatVirtualMachine);
|
procedure GetTransformVarProc(AMachine: TatVirtualMachine);
|
||||||
procedure SetTransformVarProc(AMachine: TatVirtualMachine);
|
procedure SetTransformVarProc(AMachine: TatVirtualMachine);
|
||||||
|
procedure GetTransformVariProc(AMachine: TatVirtualMachine);
|
||||||
|
procedure SetTransformVariProc(AMachine: TatVirtualMachine);
|
||||||
|
|
||||||
procedure GetTransformColorProc(AMachine: TatVirtualMachine);
|
procedure GetTransformColorProc(AMachine: TatVirtualMachine);
|
||||||
procedure SetTransformColorProc(AMachine: TatVirtualMachine);
|
procedure SetTransformColorProc(AMachine: TatVirtualMachine);
|
||||||
@ -419,6 +421,8 @@ type
|
|||||||
|
|
||||||
procedure VariationIndexProc(AMachine: TatVirtualMachine);
|
procedure VariationIndexProc(AMachine: TatVirtualMachine);
|
||||||
procedure VariationNameProc(AMachine: TatVirtualMachine);
|
procedure VariationNameProc(AMachine: TatVirtualMachine);
|
||||||
|
procedure VariableIndexProc(AMachine: TatVirtualMachine);
|
||||||
|
procedure VariableNameProc(AMachine: TatVirtualMachine);
|
||||||
|
|
||||||
procedure CalculateScale(AMachine: TatVirtualMachine);
|
procedure CalculateScale(AMachine: TatVirtualMachine);
|
||||||
procedure NormalizeVars(AMachine: TatVirtualMachine);
|
procedure NormalizeVars(AMachine: TatVirtualMachine);
|
||||||
@ -1230,6 +1234,8 @@ begin
|
|||||||
Scripter.AddConstant('ProgramVersionString', AppVersionString);
|
Scripter.AddConstant('ProgramVersionString', AppVersionString);
|
||||||
Scripter.DefineMethod('VariationIndex', 1, tkInteger, nil, VariationIndexProc);
|
Scripter.DefineMethod('VariationIndex', 1, tkInteger, nil, VariationIndexProc);
|
||||||
Scripter.DefineMethod('VariationName', 1, tkString, nil, VariationNameProc);
|
Scripter.DefineMethod('VariationName', 1, tkString, nil, VariationNameProc);
|
||||||
|
Scripter.DefineMethod('VariableIndex', 1, tkInteger, nil, VariableIndexProc);
|
||||||
|
Scripter.DefineMethod('VariableName', 1, tkString, nil, VariableNameProc);
|
||||||
|
|
||||||
Scripter.DefineMethod('CalculateScale', 0, tkNone, nil, CalculateScale);
|
Scripter.DefineMethod('CalculateScale', 0, tkNone, nil, CalculateScale);
|
||||||
Scripter.DefineMethod('CalculateBounds', 0, tkNone, nil, CalculateBounds);
|
Scripter.DefineMethod('CalculateBounds', 0, tkNone, nil, CalculateBounds);
|
||||||
@ -1788,7 +1794,7 @@ begin
|
|||||||
with AMachine do begin
|
with AMachine do begin
|
||||||
str := LowerCase(GetInputArgAsString(0));
|
str := LowerCase(GetInputArgAsString(0));
|
||||||
i := NRVAR-1;
|
i := NRVAR-1;
|
||||||
while (i >= 0) and (varnames(i) <> str) do Dec(i);
|
while (i >= 0) and (LowerCase(varnames(i)) <> str) do Dec(i);
|
||||||
ReturnOutputArg(i);
|
ReturnOutputArg(i);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1807,6 +1813,33 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TOperationLibrary.VariableIndexProc(AMachine: TatVirtualMachine);
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
str: string;
|
||||||
|
begin
|
||||||
|
with AMachine do begin
|
||||||
|
str := LowerCase(GetInputArgAsString(0));
|
||||||
|
i := GetNrVariableNames-1;
|
||||||
|
while (i >= 0) and (LowerCase(GetVariableNameAt(i)) <> str) do Dec(i);
|
||||||
|
ReturnOutputArg(i);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TOperationLibrary.VariableNameProc(AMachine: TatVirtualMachine);
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
str: string;
|
||||||
|
begin
|
||||||
|
with AMachine do begin
|
||||||
|
i := GetInputArgAsInteger(0);
|
||||||
|
if (i >= 0) and (i < GetNrVariableNames) then
|
||||||
|
ReturnOutputArg(GetVariableNameAt(i))
|
||||||
|
else
|
||||||
|
ReturnOutputArg('');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TOperationLibrary.FileCountProc(AMachine: TatVirtualMachine);
|
procedure TOperationLibrary.FileCountProc(AMachine: TatVirtualMachine);
|
||||||
begin
|
begin
|
||||||
with AMachine do
|
with AMachine do
|
||||||
@ -2512,7 +2545,6 @@ begin
|
|||||||
cp.FAngle := GetInputArgAsFloat(0);
|
cp.FAngle := GetInputArgAsFloat(0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ *************************** Transform interface **************************** }
|
{ *************************** Transform interface **************************** }
|
||||||
|
|
||||||
procedure TScriptEditor.GetTransformAProc(AMachine: TatVirtualMachine);
|
procedure TScriptEditor.GetTransformAProc(AMachine: TatVirtualMachine);
|
||||||
@ -2661,6 +2693,30 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TScriptEditor.GetTransformVariProc(AMachine: TatVirtualMachine);
|
||||||
|
var
|
||||||
|
v: double;
|
||||||
|
begin
|
||||||
|
with AMachine do begin
|
||||||
|
cp.xform[ActiveTransform].GetVariable(GetVariableNameAt(Integer(GetArrayIndex(0))), v);
|
||||||
|
ReturnOutPutArg(v);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TScriptEditor.SetTransformVariProc(AMachine: TatVirtualMachine);
|
||||||
|
var
|
||||||
|
v: double;
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
with AMachine do
|
||||||
|
begin
|
||||||
|
v := GetInputArgAsFloat(0);
|
||||||
|
i := GetArrayIndex(0);
|
||||||
|
if (i >= 0) and (i < GetNrVariableNames) then
|
||||||
|
cp.xform[ActiveTransform].SetVariable(GetVariableNameAt(i), v);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
// -- vars as props --
|
// -- vars as props --
|
||||||
|
|
||||||
procedure TScriptEditor.GetTransformVariationProc(AMachine: TatVirtualMachine);
|
procedure TScriptEditor.GetTransformVariationProc(AMachine: TatVirtualMachine);
|
||||||
@ -2747,7 +2803,7 @@ begin
|
|||||||
with AMachine do
|
with AMachine do
|
||||||
begin
|
begin
|
||||||
v := GetInputArgAsFloat(0);
|
v := GetInputArgAsFloat(0);
|
||||||
ScriptEditor.cp.xform[ActiveTransform].SetVariable(CurrentPropertyName, v);
|
cp.xform[ActiveTransform].SetVariable(CurrentPropertyName, v);
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3105,6 +3161,7 @@ begin
|
|||||||
DefineProp('Batches', tkInteger, GetFlameBatchesProc, SetFlameBatchesProc);
|
DefineProp('Batches', tkInteger, GetFlameBatchesProc, SetFlameBatchesProc);
|
||||||
DefineProp('FinalXformEnabled', tkInteger, GetFlameFinalxformEnabledProc, SetFlameFinalxformEnabledProc);
|
DefineProp('FinalXformEnabled', tkInteger, GetFlameFinalxformEnabledProc, SetFlameFinalxformEnabledProc);
|
||||||
DefineProp('Angle', tkFloat, GetFlameAngleProc, SetFlameAngleProc);
|
DefineProp('Angle', tkFloat, GetFlameAngleProc, SetFlameAngleProc);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
Scripter.AddObject('Flame', Flame);
|
Scripter.AddObject('Flame', Flame);
|
||||||
|
|
||||||
@ -3139,6 +3196,7 @@ begin
|
|||||||
DefineProp('e', tkFloat, GetTransformEProc, SetTransformEProc);
|
DefineProp('e', tkFloat, GetTransformEProc, SetTransformEProc);
|
||||||
DefineProp('f', tkFloat, GetTransformFProc, SetTransformFProc);
|
DefineProp('f', tkFloat, GetTransformFProc, SetTransformFProc);
|
||||||
DefineProp('Variation', tkFloat, GetTransformVarProc, SetTransformVarProc, nil, false, 1);
|
DefineProp('Variation', tkFloat, GetTransformVarProc, SetTransformVarProc, nil, false, 1);
|
||||||
|
DefineProp('Variable', tkFloat, GetTransformVariProc, SetTransformVariProc, nil, false, 1);
|
||||||
end;
|
end;
|
||||||
Scripter.AddObject('Transform', Transform);
|
Scripter.AddObject('Transform', Transform);
|
||||||
|
|
||||||
@ -3212,6 +3270,7 @@ begin
|
|||||||
{ Variables and constants }
|
{ Variables and constants }
|
||||||
Scripter.AddConstant('PI', pi);
|
Scripter.AddConstant('PI', pi);
|
||||||
Scripter.AddConstant('NVARS', NRVAR);
|
Scripter.AddConstant('NVARS', NRVAR);
|
||||||
|
Scripter.AddConstant('NumVariables', GetNrVariableNames);
|
||||||
Scripter.AddConstant('NXFORMS', NXFORMS);
|
Scripter.AddConstant('NXFORMS', NXFORMS);
|
||||||
Scripter.AddConstant('INSTALLPATH', ExtractFilePath(Application.exename));
|
Scripter.AddConstant('INSTALLPATH', ExtractFilePath(Application.exename));
|
||||||
Scripter.AddConstant('SYM_NONE', 0);
|
Scripter.AddConstant('SYM_NONE', 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user