From: Peter S. <zu...@us...> - 2007-10-28 13:32:05
|
Update of /cvsroot/apophysis/2.10/Source In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv3532/Source Modified Files: ScriptForm.pas Log Message: added variable enumeration support Index: ScriptForm.pas =================================================================== RCS file: /cvsroot/apophysis/2.10/Source/ScriptForm.pas,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** ScriptForm.pas 1 Jul 2007 17:29:00 -0000 1.34 --- ScriptForm.pas 28 Oct 2007 13:32:07 -0000 1.35 *************** *** 178,181 **** --- 178,183 ---- procedure GetTransformVarProc(AMachine: TatVirtualMachine); procedure SetTransformVarProc(AMachine: TatVirtualMachine); + procedure GetTransformVariProc(AMachine: TatVirtualMachine); + procedure SetTransformVariProc(AMachine: TatVirtualMachine); procedure GetTransformColorProc(AMachine: TatVirtualMachine); *************** *** 420,423 **** --- 422,427 ---- procedure VariationIndexProc(AMachine: TatVirtualMachine); procedure VariationNameProc(AMachine: TatVirtualMachine); + procedure VariableIndexProc(AMachine: TatVirtualMachine); + procedure VariableNameProc(AMachine: TatVirtualMachine); procedure CalculateScale(AMachine: TatVirtualMachine); *************** *** 1231,1234 **** --- 1235,1240 ---- Scripter.DefineMethod('VariationIndex', 1, tkInteger, nil, VariationIndexProc); 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); *************** *** 1789,1793 **** str := LowerCase(GetInputArgAsString(0)); i := NRVAR-1; ! while (i >= 0) and (varnames(i) <> str) do Dec(i); ReturnOutputArg(i); end; --- 1795,1799 ---- str := LowerCase(GetInputArgAsString(0)); i := NRVAR-1; ! while (i >= 0) and (LowerCase(varnames(i)) <> str) do Dec(i); ReturnOutputArg(i); end; *************** *** 1808,1811 **** --- 1814,1844 ---- 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); begin *************** *** 2513,2517 **** end; - { *************************** Transform interface **************************** } --- 2546,2549 ---- *************** *** 2662,2665 **** --- 2694,2721 ---- 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 -- *************** *** 2748,2752 **** begin v := GetInputArgAsFloat(0); ! ScriptEditor.cp.xform[ActiveTransform].SetVariable(CurrentPropertyName, v); end end; --- 2804,2808 ---- begin v := GetInputArgAsFloat(0); ! cp.xform[ActiveTransform].SetVariable(CurrentPropertyName, v); end end; *************** *** 3106,3109 **** --- 3162,3166 ---- DefineProp('FinalXformEnabled', tkInteger, GetFlameFinalxformEnabledProc, SetFlameFinalxformEnabledProc); DefineProp('Angle', tkFloat, GetFlameAngleProc, SetFlameAngleProc); + end; Scripter.AddObject('Flame', Flame); *************** *** 3140,3143 **** --- 3197,3201 ---- DefineProp('f', tkFloat, GetTransformFProc, SetTransformFProc); DefineProp('Variation', tkFloat, GetTransformVarProc, SetTransformVarProc, nil, false, 1); + DefineProp('Variable', tkFloat, GetTransformVariProc, SetTransformVariProc, nil, false, 1); end; Scripter.AddObject('Transform', Transform); *************** *** 3213,3216 **** --- 3271,3275 ---- Scripter.AddConstant('PI', pi); Scripter.AddConstant('NVARS', NRVAR); + Scripter.AddConstant('NumVariables', GetNrVariableNames); Scripter.AddConstant('NXFORMS', NXFORMS); Scripter.AddConstant('INSTALLPATH', ExtractFilePath(Application.exename)); |