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';
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
Renderer.BreakRender;
Renderer.WaitFor; //?

View File

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

View File

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

View File

@ -282,6 +282,8 @@ type
procedure tbShowAlphaClick(Sender: TObject);
procedure tbShowTraceClick(Sender: TObject);
procedure XmlScannerContent(Sender: TObject; Content: String);
procedure ListViewChanging(Sender: TObject; Item: TListItem;
Change: TItemChange; var AllowChange: Boolean);
private
Renderer: TRenderThread;
@ -1453,20 +1455,39 @@ var
Tag: string;
IFile: TextFile;
FileList: TStringList;
i, p: integer;
bakname: string;
begin
Tag := RemoveExt(filename);
Result := True;
try
if FileExists(filename) then
begin
if XMLEntryExists(title, filename) then
begin
DeleteXMLEntry(title, filename);
end;
bakname := ChangeFileExt(filename, '.bak');
if FileExists(bakname) then DeleteFile(bakname);
RenameFile(filename, bakname);
FileList := TStringList.create;
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
if (FileList.Count > 0) then begin
@ -1580,6 +1601,7 @@ function RenameXML(OldIdent: string; var NewIdent: string): boolean;
var
Strings: TStringList;
i: integer;
bakname: string;
begin
Result := True;
Strings := TStringList.Create;
@ -1594,6 +1616,11 @@ begin
inc(i);
end;
Strings[i] := StringReplace(Strings[i], OldIdent, NewIdent, []);
bakname := ChangeFileExt(OpenFile, '.bak');
if FileExists(bakname) then DeleteFile(bakname);
RenameFile(OpenFile, bakname);
Strings.SaveToFile(OpenFile);
end
else
@ -2600,6 +2627,14 @@ procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
var
Registry: TRegistry;
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;
HtmlHelp(0, nil, HH_CLOSE_ALL, 0);
{ To capture secondary window positions }
@ -4828,4 +4863,19 @@ begin
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.

View File

@ -250,6 +250,23 @@ object OptionsForm: TOptionsForm
TabOrder = 5
WordWrap = True
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
object EditorPage: TTabSheet
Caption = 'Editor'

View File

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

View File

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