new way to store random variations selection in registry

This commit is contained in:
zueuk 2008-08-25 15:12:56 +00:00
parent f0be40833a
commit cededfd346
6 changed files with 85 additions and 26 deletions

View File

@ -155,8 +155,8 @@ var
SymmetryType: integer;
SymmetryOrder: integer;
SymmetryNVars: integer;
Variations: array[0..63] of boolean;
VariationOptions: int64;
Variations: array of boolean;
//VariationOptions: int64;
MainForm_RotationMode: integer;
PreserveQuality: boolean;

View File

@ -42,7 +42,7 @@ const
RS_XO = 2;
RS_VO = 3;
AppVersionString = 'Apophysis 2.08 beta';
AppVersionString = 'Apophysis 2.08 beta 2 pre2';
type
TMouseMoveState = (msUsual, msZoomWindow, msZoomOutWindow, msZoomWindowMove,
@ -368,8 +368,8 @@ function DeleteEntry(Entry, FileName: string): boolean;
function CleanIdentifier(ident: string): string;
function CleanUPRTitle(ident: string): string;
function GradientString(c: TColorMap): string;
function PackVariations: int64;
procedure UnpackVariations(v: int64);
//function PackVariations: int64;
//procedure UnpackVariations(v: int64);
//procedure NormalizeWeights(var cp: TControlPoint);
//procedure EqualizeWeights(var cp: TControlPoint);
procedure MultMatrix(var s: TMatrix; const m: TMatrix);
@ -466,6 +466,7 @@ begin
end;
(*
function PackVariations: int64;
{ Packs the variation options into an integer with Linear as lowest bit }
var
@ -486,6 +487,7 @@ begin
for i := 0 to NRVAR - 1 do
Variations[i] := boolean(v shr i and 1);
end;
*)
function GetWinVersion: TWin32Version;
{ Returns current version of a host Win32 platform }
@ -2511,14 +2513,18 @@ begin
Application.OnHelp := ApplicationOnHelp;
AppPath := ExtractFilePath(Application.ExeName);
CanDrawOnResize := False;
ReadSettings;
Dte := FormatDateTime('yymmdd', Now);
if Dte <> RandomDate then
RandomIndex := 0;
RandomDate := Dte;
mnuExit.ShortCut := TextToShortCut('Alt+F4');
if VariationOptions = 0 then VariationOptions := 16383; // it shouldn't hapen but just in case;
UnpackVariations(VariationOptions);
//if VariationOptions = 0 then VariationOptions := 16383; // it shouldn't hapen but just in case;
//UnpackVariations(VariationOptions);
FillVariantMenu;
tbQualityBox.Text := FloatToStr(defSampleDensity);
@ -4034,7 +4040,7 @@ begin
Assert(Count = 256, 'only 256 color Colormaps are supported at the moment');
data := '';
for i := 0 to Length(in_data) do
for i := 1 to Length(in_data) do
begin
c := in_data[i];
if c in ['0'..'9']+['A'..'F']+['a'..'f'] then data := data + c;
@ -4070,7 +4076,15 @@ begin
Tokens := TStringList.Create;
try
if TagName='flame' then
if TagName='xformset' then // unused in this release...
begin
v := Attributes.Value('enabled');
if v <> '' then ParseCP.finalXformEnabled := (StrToInt(v) <> 0)
else ParseCP.finalXformEnabled := true;
inc(activeXformSet);
end
else if TagName='flame' then
begin
v := Attributes.value('name');
if v <> '' then Parsecp.name := v else Parsecp.name := 'untitled';

View File

@ -739,7 +739,6 @@ object OptionsForm: TOptionsForm
Height = 21
Associate = txtMaxXforms
Min = 2
Max = 100
Position = 6
TabOrder = 3
end

View File

@ -376,7 +376,7 @@ begin
udSymNVars.Position := SymmetryNVars;
{ Variations tab }
UnpackVariations(VariationOptions);
//UnpackVariations(VariationOptions);
for i := 0 to NRVAR -1 do
clbVarEnabled.Checked[i] := Variations[i];
@ -416,22 +416,23 @@ end;
procedure TOptionsForm.btnOKClick(Sender: TObject);
var
v: int64;
vars: boolean;
i: integer;
begin
{ Variations tab }
{ Get option values from controls. Disallow bad values }
for i := 0 to NRVAR -1 do
vars := false;
for i := 0 to NRVAR-1 do begin
Variations[i] := clbVarEnabled.Checked[i];
vars := vars or Variations[i];
end;
v := PackVariations;
if v <> 0 then VariationOptions := v
else
begin
Application.MessageBox('You must select at least one variation.', 'Apophysis', 48);
Tabs.ActivePage := VariationsPage;
Exit;
if vars = false then begin
//Application.MessageBox('You must select at least one variation.', 'Apophysis', 48);
//Tabs.ActivePage := VariationsPage;
//Exit;
Variations[0] := true;
end;
{ General tab }

View File

@ -1,6 +1,6 @@
{
Apophysis Copyright (C) 2001-2004 Mark Townsend
Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov
Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -29,6 +29,7 @@ implementation
uses Windows, SysUtils, Forms, Registry, Global, Dialogs, XFormMan;
(*
procedure UnpackVariations(v: int64);
{ Unpacks the variation options form an integer }
var
@ -37,11 +38,14 @@ begin
for i := 0 to NRVAR - 1 do
Variations[i] := boolean(v shr i and 1);
end;
*)
procedure ReadSettings;
var
Registry: TRegistry;
DefaultPath: string;
i, maxVars: integer;
VariationOptions: int64;
begin
DefaultPath := ExtractFilePath(Application.Exename);
// ShowMessage(DefaultPath);
@ -312,7 +316,7 @@ begin
begin
VariationOptions := VariationOptions or (int64(Registry.ReadInteger('VariationOptions2')) shl 32);
end;
UnpackVariations(VariationOptions);
// UnpackVariations(VariationOptions);
if Registry.ValueExists('MinNodes') then
begin
@ -581,7 +585,6 @@ begin
InternalBitsPerSample := 0;
end;
end
else
begin
@ -618,7 +621,7 @@ begin
SymmetryOrder := 4;
SymmetryNVars := 12;
VariationOptions := 262143;
UnpackVariations(VariationOptions);
// UnpackVariations(VariationOptions);
MinNodes := 2;
MaxNodes := 10;
MinHue := 0;
@ -657,6 +660,24 @@ begin
end;
Registry.CloseKey;
SetLength(Variations, NRVAR);
if Registry.OpenKey('Software\' + APP_NAME + '\Variations', False) then
begin
for i := 0 to NRVAR-1 do begin
if Registry.ValueExists(Varnames(i)) then
Variations[i] := Registry.ReadBool(Varnames(i))
else
Variations[i] := false;
end;
end
else begin
if NRVAR >= 64 then maxVars := 63
else maxVars := NRVAR-1;
for i := 0 to maxVars do
Variations[i] := boolean(VariationOptions shr i and 1);
end;
Registry.CloseKey;
{ Editor } // --Z-- moved from EditForm
if Registry.OpenKey('Software\' + APP_NAME + '\Forms\Editor', False) then
begin
@ -995,6 +1016,7 @@ end;
procedure SaveSettings;
var
Registry: TRegistry;
i: integer;
begin
Registry := TRegistry.Create;
try
@ -1039,8 +1061,8 @@ begin
Registry.WriteInteger('SymmetryType', SymmetryType);
Registry.WriteInteger('SymmetryOrder', SymmetryOrder);
Registry.WriteInteger('SymmetryNVars', SymmetryNVars);
Registry.WriteInteger('VariationOptions', VariationOptions);
Registry.WriteInteger('VariationOptions2', VariationOptions shr 32);
// Registry.WriteInteger('VariationOptions', VariationOptions);
// Registry.WriteInteger('VariationOptions2', VariationOptions shr 32);
Registry.WriteInteger('ReferenceMode', ReferenceMode);
Registry.WriteInteger('RotationMode', MainForm_RotationMode);
Registry.WriteInteger('MinNodes', MinNodes);
@ -1084,6 +1106,19 @@ begin
Registry.WriteInteger('UseNrThreads', UseNrThreads);
Registry.WriteInteger('InternalBitsPerSample', InternalBitsPerSample);
end;
Registry.CloseKey;
if Registry.OpenKey('\Software\' + APP_NAME + '\Variations', True) then
begin
for i := 0 to NRVAR-1 do begin
if Registry.ValueExists(Varnames(i)) then
if Registry.ReadBool(Varnames(i)) = Variations[i] then
continue;
Registry.WriteBool(Varnames(i), Variations[i]);
end;
end;
Registry.CloseKey;
{ Editor }
if Registry.OpenKey('\Software\' + APP_NAME + '\Forms\Editor', True) then
begin
@ -1099,6 +1134,8 @@ begin
Registry.WriteBool('LockTransformAxis', TransformAxisLock);
Registry.WriteBool('DoubleClickSetVars', DoubleClickSetVars);
end;
Registry.CloseKey;
{ Display }
if Registry.OpenKey('\Software\' + APP_NAME + '\Display', True) then
begin
@ -1113,6 +1150,8 @@ begin
Registry.WriteFloat('PreviewMediumQuality', prevMediumQuality);
Registry.WriteFloat('PreviewHighQuality', prevHighQuality);
end;
Registry.CloseKey;
{ UPR }
if Registry.OpenKey('\Software\' + APP_NAME + '\UPR', True) then
begin
@ -1125,6 +1164,8 @@ begin
Registry.WriteInteger('FlameOversample', UPROversample);
Registry.WriteBool('FlameAdjustDensity', UPRAdjustDensity);
end;
Registry.CloseKey;
if Registry.OpenKey('\Software\' + APP_NAME + '\Render', True) then
begin
Registry.WriteString('Path', renderPath);
@ -1137,6 +1178,8 @@ begin
Registry.WriteInteger('FileFormat', renderFileFormat);
Registry.WriteInteger('BitsPerSample', renderBitsPerSample);
end;
Registry.CloseKey;
finally
Registry.Free;
end;

View File

@ -878,11 +878,13 @@ begin
if (i >= 0) and (i < NRVAR) then
begin
Variations[i] := v;
{
vars := PackVariations;
if vars <> 0 then
VariationOptions := vars
else
VariationOptions := 1;
}
end;
end;