confirmation options for exiting program and stopping render;

.flame files are now renamed to .bak before saving to them (the notorius Index out of Range error got me! :)
This commit is contained in:
zueuk 2007-06-02 06:59:05 +00:00
parent be99b093b4
commit 7ef860f019
7 changed files with 97 additions and 17 deletions

View File

@ -612,6 +612,10 @@ begin
btnPause.caption := 'Pause'; btnPause.caption := 'Pause';
end; end;
if ConfirmStopRender then begin
if Application.MessageBox('Do you want to stop the current render?', 'Apophysis', 36) = ID_NO then exit;
end;
if SaveIncompleteRenders and not ChkLimitMem.Checked then begin if SaveIncompleteRenders and not ChkLimitMem.Checked then begin
Renderer.BreakRender; Renderer.BreakRender;
Renderer.WaitFor; //? Renderer.WaitFor; //?

View File

@ -128,6 +128,8 @@ var
ConfirmDelete: boolean; // Flag confirmation of entry deletion ConfirmDelete: boolean; // Flag confirmation of entry deletion
OldPaletteFormat: boolean; OldPaletteFormat: boolean;
ConfirmExit: boolean;
ConfirmStopRender: boolean;
SavePath, SmoothPalettePath: string; SavePath, SmoothPalettePath: string;
RandomPrefix, RandomDate: string; RandomPrefix, RandomDate: string;
RandomIndex: integer; RandomIndex: integer;

View File

@ -328,6 +328,7 @@ object MainForm: TMainForm
TabOrder = 1 TabOrder = 1
ViewStyle = vsReport ViewStyle = vsReport
OnChange = ListViewChange OnChange = ListViewChange
OnChanging = ListViewChanging
OnEdited = ListViewEdited OnEdited = ListViewEdited
end end
object BackPanel: TPanel object BackPanel: TPanel
@ -377,7 +378,7 @@ object MainForm: TMainForm
Left = 8 Left = 8
Top = 56 Top = 56
Bitmap = { Bitmap = {
494C010136003B00040010001000FFFFFFFFFF00FFFFFFFFFFFFFFFF424D3600 494C010136003B00040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
000000000000360000002800000040000000F0000000010020000000000000F0 000000000000360000002800000040000000F0000000010020000000000000F0
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000
@ -2361,7 +2362,8 @@ object MainForm: TMainForm
C003000F80018000C003000780018000C003000380018000C003000180018000 C003000F80018000C003000780018000C003000380018000C003000180018000
C003000180018000C003001F80018000C003001F80018001C003001F80018001 C003000180018000C003001F80018000C003001F80018001C003001F80018001
C0038FF180018001C007FFF980018001C00FFF7580018001C01FFF8F80018001 C0038FF180018001C007FFF980018001C00FFF7580018001C01FFF8F80018001
C03FFFFF80018001FFFFFFFFFFFFFFFF} C03FFFFF80018001FFFFFFFFFFFFFFFF00000000000000000000000000000000
000000000000}
end end
object SmallImages: TImageList object SmallImages: TImageList
Left = 40 Left = 40

View File

@ -282,6 +282,8 @@ type
procedure tbShowAlphaClick(Sender: TObject); procedure tbShowAlphaClick(Sender: TObject);
procedure tbShowTraceClick(Sender: TObject); procedure tbShowTraceClick(Sender: TObject);
procedure XmlScannerContent(Sender: TObject; Content: String); procedure XmlScannerContent(Sender: TObject; Content: String);
procedure ListViewChanging(Sender: TObject; Item: TListItem;
Change: TItemChange; var AllowChange: Boolean);
private private
Renderer: TRenderThread; Renderer: TRenderThread;
@ -1453,20 +1455,39 @@ var
Tag: string; Tag: string;
IFile: TextFile; IFile: TextFile;
FileList: TStringList; FileList: TStringList;
i, p: integer;
bakname: string;
begin begin
Tag := RemoveExt(filename); Tag := RemoveExt(filename);
Result := True; Result := True;
try try
if FileExists(filename) then if FileExists(filename) then
begin begin
if XMLEntryExists(title, filename) then bakname := ChangeFileExt(filename, '.bak');
begin if FileExists(bakname) then DeleteFile(bakname);
DeleteXMLEntry(title, filename); RenameFile(filename, bakname);
end;
FileList := TStringList.create; FileList := TStringList.create;
try try
FileList.LoadFromFile(filename); FileList.LoadFromFile(bakname);
if Pos(title, FileList.Text) <> 0 then
begin
i := 0;
while Pos('name="' + title + '"', Trim(FileList[i])) = 0 do
inc(i);
p := 0;
while p = 0 do
begin
p := Pos('</flame>', FileList[i]);
FileList.Delete(i);
end;
end;
// FileList := TStringList.create;
// try
// FileList.LoadFromFile(filename);
// fix first line // fix first line
if (FileList.Count > 0) then begin if (FileList.Count > 0) then begin
@ -1580,6 +1601,7 @@ function RenameXML(OldIdent: string; var NewIdent: string): boolean;
var var
Strings: TStringList; Strings: TStringList;
i: integer; i: integer;
bakname: string;
begin begin
Result := True; Result := True;
Strings := TStringList.Create; Strings := TStringList.Create;
@ -1594,6 +1616,11 @@ begin
inc(i); inc(i);
end; end;
Strings[i] := StringReplace(Strings[i], OldIdent, NewIdent, []); Strings[i] := StringReplace(Strings[i], OldIdent, NewIdent, []);
bakname := ChangeFileExt(OpenFile, '.bak');
if FileExists(bakname) then DeleteFile(bakname);
RenameFile(OpenFile, bakname);
Strings.SaveToFile(OpenFile); Strings.SaveToFile(OpenFile);
end end
else else
@ -2600,6 +2627,14 @@ procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
var var
Registry: TRegistry; Registry: TRegistry;
begin begin
if ConfirmExit and (UndoIndex <> 0) then
if Application.MessageBox('Do you really want to exit?' + #13#10 +
'All unsaved data will be lost!', 'Apophysis', MB_ICONWARNING or MB_YESNO) <> IDYES then
begin
Action := caNone;
exit;
end;
ScriptEditor.Stopped := True; ScriptEditor.Stopped := True;
HtmlHelp(0, nil, HH_CLOSE_ALL, 0); HtmlHelp(0, nil, HH_CLOSE_ALL, 0);
{ To capture secondary window positions } { To capture secondary window positions }
@ -4828,4 +4863,19 @@ begin
end; end;
end; end;
procedure TMainForm.ListViewChanging(Sender: TObject; Item: TListItem;
Change: TItemChange; var AllowChange: Boolean);
begin
{
if (Trim(Item.Caption) = Trim(maincp.name)) and
(Item.Selected) and (Change = ctState) then
if UndoIndex <> 0 then
if Application.MessageBox('Are you sure?', 'Apophysis', MB_ICONWARNING or MB_YESNO) <> IDYES then
begin
AllowChange := false;
exit;
end;
}
end;
end. end.

View File

@ -250,6 +250,23 @@ object OptionsForm: TOptionsForm
TabOrder = 5 TabOrder = 5
WordWrap = True WordWrap = True
end end
object chkConfirmExit: TCheckBox
Left = 136
Top = 183
Width = 81
Height = 17
HelpContext = 1005
Caption = 'Confirm exit'
TabOrder = 6
end
object chkConfirmStopRender: TCheckBox
Left = 136
Top = 210
Width = 121
Height = 17
Caption = 'Confirm stop render'
TabOrder = 7
end
end end
object EditorPage: TTabSheet object EditorPage: TTabSheet
Caption = 'Editor' Caption = 'Editor'

View File

@ -219,6 +219,8 @@ type
chkShowAllXforms: TCheckBox; chkShowAllXforms: TCheckBox;
txtGradientsFile: TEdit; txtGradientsFile: TEdit;
btnGradientsFile: TSpeedButton; btnGradientsFile: TSpeedButton;
chkConfirmExit: TCheckBox;
chkConfirmStopRender: TCheckBox;
procedure btnCancelClick(Sender: TObject); procedure btnCancelClick(Sender: TObject);
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
procedure btnOKClick(Sender: TObject); procedure btnOKClick(Sender: TObject);
@ -308,6 +310,8 @@ begin
chkConfirmDel.Checked := ConfirmDelete; chkConfirmDel.Checked := ConfirmDelete;
chkOldPaletteFormat.Checked := OldPaletteFormat; chkOldPaletteFormat.Checked := OldPaletteFormat;
chkConfirmExit.Checked := ConfirmExit;
chkConfirmStopRender.Checked := ConfirmStopRender;
rgRotationMode.ItemIndex := MainForm_RotationMode; rgRotationMode.ItemIndex := MainForm_RotationMode;
if PreserveQuality then if PreserveQuality then
@ -448,6 +452,8 @@ begin
NrTreads := StrToIntDef(cbNrTheads.text, 0); NrTreads := StrToIntDef(cbNrTheads.text, 0);
ConfirmDelete := chkConfirmDel.Checked; ConfirmDelete := chkConfirmDel.Checked;
OldPaletteFormat := chkOldPaletteFormat.Checked; OldPaletteFormat := chkOldPaletteFormat.Checked;
ConfirmExit := chkConfirmExit.Checked;
ConfirmStopRender := chkConfirmStopRender.Checked;
MainForm_RotationMode := rgRotationMode.ItemIndex; MainForm_RotationMode := rgRotationMode.ItemIndex;
PreserveQuality := (rgZoomingMode.ItemIndex = 0); PreserveQuality := (rgZoomingMode.ItemIndex = 0);

View File

@ -94,21 +94,18 @@ begin
RenderCompleteSoundFile := ''; RenderCompleteSoundFile := '';
if Registry.ValueExists('ConfirmDelete') then if Registry.ValueExists('ConfirmDelete') then
begin ConfirmDelete := Registry.ReadBool('ConfirmDelete')
ConfirmDelete := Registry.ReadBool('ConfirmDelete');
end
else else
begin
ConfirmDelete := True; ConfirmDelete := True;
end;
if Registry.ValueExists('OldPaletteFormat') then if Registry.ValueExists('OldPaletteFormat') then
begin OldPaletteFormat := Registry.ReadBool('OldPaletteFormat')
OldPaletteFormat := Registry.ReadBool('OldPaletteFormat');
end
else else
begin
OldPaletteFormat := false; OldPaletteFormat := false;
end; if Registry.ValueExists('ConfirmExit') then
ConfirmExit := Registry.ReadBool('ConfirmExit')
else
ConfirmExit := True;
if Registry.ValueExists('PreserveQuality') then if Registry.ValueExists('PreserveQuality') then
begin begin
PreserveQuality := Registry.ReadBool('PreserveQuality'); PreserveQuality := Registry.ReadBool('PreserveQuality');
@ -598,6 +595,7 @@ begin
SavePath := DefaultPath + 'Parameters\My Flames.flame'; SavePath := DefaultPath + 'Parameters\My Flames.flame';
defSmoothPaletteFile := DefaultPath + 'smooth.ugr'; defSmoothPaletteFile := DefaultPath + 'smooth.ugr';
ConfirmDelete := True; ConfirmDelete := True;
ConfirmExit := True;
OldPaletteFormat := false; OldPaletteFormat := false;
NumTries := 10; NumTries := 10;
TryLength := 100000; TryLength := 100000;
@ -1011,6 +1009,7 @@ begin
Registry.WriteBool('ConfirmDelete', ConfirmDelete); Registry.WriteBool('ConfirmDelete', ConfirmDelete);
Registry.WriteBool('OldPaletteFormat', OldPaletteFormat); Registry.WriteBool('OldPaletteFormat', OldPaletteFormat);
Registry.WriteBool('ConfirmExit', ConfirmExit);
Registry.WriteInteger('NumTries', NumTries); Registry.WriteInteger('NumTries', NumTries);
Registry.WriteInteger('TryLength', TryLength); Registry.WriteInteger('TryLength', TryLength);
Registry.WriteInteger('MinTransforms', randMinTransforms); Registry.WriteInteger('MinTransforms', randMinTransforms);