added fast read+write
fixed modified bug for the notes
This commit is contained in:
parent
2c541f338c
commit
98a1d2b3da
|
@ -115,7 +115,7 @@ AutoIncBuild=1
|
||||||
MajorVer=1
|
MajorVer=1
|
||||||
MinorVer=4
|
MinorVer=4
|
||||||
Release=2
|
Release=2
|
||||||
Build=2
|
Build=5
|
||||||
Debug=0
|
Debug=0
|
||||||
PreRelease=0
|
PreRelease=0
|
||||||
Special=0
|
Special=0
|
||||||
|
@ -126,7 +126,7 @@ CodePage=1252
|
||||||
[Version Info Keys]
|
[Version Info Keys]
|
||||||
CompanyName=AMX Mod X Dev Team
|
CompanyName=AMX Mod X Dev Team
|
||||||
FileDescription=
|
FileDescription=
|
||||||
FileVersion=1.4.2.2
|
FileVersion=1.4.2.5
|
||||||
InternalName=gaben
|
InternalName=gaben
|
||||||
LegalCopyright=AMX Mod X Dev Team
|
LegalCopyright=AMX Mod X Dev Team
|
||||||
LegalTrademarks=
|
LegalTrademarks=
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -828,7 +828,6 @@ end;
|
||||||
|
|
||||||
function TDocument.Save: Boolean;
|
function TDocument.Save: Boolean;
|
||||||
var i: integer;
|
var i: integer;
|
||||||
F: Textfile;
|
|
||||||
sLines: TStringList;
|
sLines: TStringList;
|
||||||
sNotes: String;
|
sNotes: String;
|
||||||
eFound: Boolean;
|
eFound: Boolean;
|
||||||
|
@ -840,8 +839,8 @@ begin
|
||||||
|
|
||||||
Result := True;
|
Result := True;
|
||||||
Cancel := False;
|
Cancel := False;
|
||||||
|
Screen.Cursor := crHourGlass;
|
||||||
|
|
||||||
ShowProgress(True);
|
|
||||||
if (FileExists(FFileName)) and (frmSettings.chkMakeBaks.Checked) then begin
|
if (FileExists(FFileName)) and (frmSettings.chkMakeBaks.Checked) then begin
|
||||||
try
|
try
|
||||||
CopyFile(PChar(FFileName), PChar(FFileName + '.bak'), False);
|
CopyFile(PChar(FFileName), PChar(FFileName + '.bak'), False);
|
||||||
|
@ -855,51 +854,32 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
try
|
try
|
||||||
AssignFile(F, FFilename);
|
sLines := TStringList.Create;
|
||||||
Rewrite(F);
|
|
||||||
if ActiveDoc = Self then begin
|
if ActiveDoc = Self then begin
|
||||||
sLines := TStringList(frmMain.sciEditor.Lines);
|
sLines.Assign(frmMain.sciEditor.Lines);
|
||||||
sNotes := GetRTFText(frmMain.rtfNotes);
|
sNotes := GetRTFText(frmMain.rtfNotes);
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
sLines := TStringList.Create;
|
|
||||||
sLines.Text := Code;
|
sLines.Text := Code;
|
||||||
sNotes := NotesText;
|
sNotes := NotesText;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
frmMain.pbLoading.Max := sLines.Count -1;
|
// ... save file and append notes if neccessary ...
|
||||||
frmMain.pbLoading.Position := 0;
|
|
||||||
// ... save file...
|
|
||||||
for i := 0 to sLines.Count -1 do begin
|
|
||||||
if Cancel then begin
|
|
||||||
CloseFile(F);
|
|
||||||
Cancel := False;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
WriteLn(F, sLines[i]);
|
|
||||||
frmMain.pbLoading.Position := i;
|
|
||||||
SetProgressStatus('Saving File...');
|
|
||||||
Application.ProcessMessages;
|
|
||||||
end;
|
|
||||||
// ... and notes ...
|
|
||||||
if frmSettings.optFileComment.Checked then begin
|
if frmSettings.optFileComment.Checked then begin
|
||||||
WriteLn(F, GetCurrLang.CommentBoxStart + ' AMXX-Studio Notes - DO NOT MODIFY BELOW HERE');
|
sLines.Add(GetCurrLang.CommentBoxStart + ' AMXX-Studio Notes - DO NOT MODIFY BELOW HERE');
|
||||||
WriteLn(F, GetCurrLang.CommentBoxMiddle + sNotes);
|
sLines.Add(GetCurrLang.CommentBoxMiddle + sNotes);
|
||||||
WriteLn(F, GetCurrLang.CommentBoxEnd);
|
sLines.Add(GetCurrLang.CommentBoxEnd);
|
||||||
CloseFile(F);
|
end;
|
||||||
end
|
sLines.SaveToFile(FFileName);
|
||||||
else begin
|
// ... and if the user stores their notes somewhere else save them now ...
|
||||||
CloseFile(F);
|
if not frmSettings.optFileComment.Checked then begin
|
||||||
sLines := TStringList.Create;
|
sLines := TStringList.Create; // don't overwrite our .Lines object
|
||||||
|
|
||||||
i := 0; // line 1 should be a comment
|
i := 0; // line 1 should be a comment
|
||||||
if FileExists(ParamStr(0) + 'config\Notes.dat') then
|
if FileExists(ParamStr(0) + 'config\Notes.dat') then
|
||||||
sLines.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'config\Notes.dat')
|
sLines.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'config\Notes.dat')
|
||||||
else begin
|
else
|
||||||
sLines.Clear; // something must be wrong, clear
|
|
||||||
sLines.Add('AMXX-Studio Notes - DO NOT MODIFY THIS FILE');
|
sLines.Add('AMXX-Studio Notes - DO NOT MODIFY THIS FILE');
|
||||||
end;
|
|
||||||
|
|
||||||
eFound := False;
|
eFound := False;
|
||||||
if sLines.Count > 2 then begin
|
if sLines.Count > 2 then begin
|
||||||
|
@ -918,15 +898,15 @@ begin
|
||||||
sLines.Add(sNotes);
|
sLines.Add(sNotes);
|
||||||
end;
|
end;
|
||||||
sLines.SaveToFile(ExtractFilePath(ParamStr(0)) + 'config\Notes.dat');
|
sLines.SaveToFile(ExtractFilePath(ParamStr(0)) + 'config\Notes.dat');
|
||||||
sLines.Destroy;
|
sLines.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FModified := False;
|
Modified := False;
|
||||||
except
|
except
|
||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
HideProgress;
|
Screen.Cursor := crDefault;
|
||||||
Plugin_FileSave(FFilename, False);
|
Plugin_FileSave(FFilename, False);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1152,10 +1132,9 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TDocCollection.Open(AFilename: String; AHighlighter: String = ''): Integer;
|
function TDocCollection.Open(AFilename: String; AHighlighter: String = ''): Integer;
|
||||||
var F: TextFile;
|
var eLines: TStringList;
|
||||||
|
eFound: Boolean;
|
||||||
i: integer;
|
i: integer;
|
||||||
eString: String;
|
|
||||||
eLines: TStringList;
|
|
||||||
begin
|
begin
|
||||||
Result := -1;
|
Result := -1;
|
||||||
|
|
||||||
|
@ -1189,71 +1168,36 @@ begin
|
||||||
|
|
||||||
Screen.Cursor := crHourGlass;
|
Screen.Cursor := crHourGlass;
|
||||||
Cancel := False;
|
Cancel := False;
|
||||||
ShowProgress(True);
|
|
||||||
|
|
||||||
AssignFile(F, AFilename);
|
|
||||||
{ ... count lines ... }
|
|
||||||
i := 0;
|
|
||||||
Reset(F);
|
|
||||||
|
|
||||||
while not EOF(F) do begin
|
|
||||||
ReadLn(F, eString);
|
|
||||||
Inc(i, 1);
|
|
||||||
end;
|
|
||||||
{ ... read lines ... }
|
{ ... read lines ... }
|
||||||
Reset(F);
|
eLines := TStringList.Create;
|
||||||
|
eLines.LoadFromFile(AFilename);
|
||||||
|
eFound := False;
|
||||||
|
// ... add the doc and load notes ...
|
||||||
with Add(AFilename, AHighlighter) do begin
|
with Add(AFilename, AHighlighter) do begin
|
||||||
ShowProgress(True);
|
Result := Index;
|
||||||
frmMain.pbLoading.Max := i;
|
{ notes, zomg! }
|
||||||
i := 0;
|
if eLines.Count > 3 then begin
|
||||||
while not EOF(F) do begin
|
if eLines[eLines.Count -3] = GetCurrLang(AFilename).CommentBoxStart + ' AMXX-Studio Notes - DO NOT MODIFY BELOW HERE' then begin
|
||||||
if Cancel then begin
|
|
||||||
Cancel := False;
|
|
||||||
CloseFile(F);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
ReadLn(F, eString);
|
|
||||||
if Assigned(GetCurrLang(AFilename)) then begin
|
|
||||||
if (eString = GetCurrLang(AFilename).CommentBoxStart + ' AMXX-Studio Notes - DO NOT MODIFY BELOW HERE') and (frmSettings.optFileComment.Checked) then begin
|
|
||||||
try
|
try
|
||||||
ReadLn(F, eString);
|
NotesText := Copy(eLines[eLines.Count -2], Length(GetCurrLang(AFilename).CommentBoxMiddle) +1, Length(eLines[eLines.Count -2]));
|
||||||
eString := Copy(eString, Length(GetCurrLang(AFilename).CommentBoxMiddle) +1, Length(eString));
|
|
||||||
NotesText := eString;
|
eLines.Delete(eLines.Count -1);
|
||||||
ReadLn(F, eString);
|
eLines.Delete(eLines.Count -1);
|
||||||
|
eLines.Delete(eLines.Count -1);
|
||||||
|
|
||||||
|
eFound := True;
|
||||||
except
|
except
|
||||||
MessageBox(frmMain.Handle, PChar(lFailedLoadNotes), PChar(Application.Title), MB_ICONERROR);
|
MessageBox(frmMain.Handle, PChar(lFailedLoadNotes), PChar(Application.Title), MB_ICONERROR);
|
||||||
end;
|
end;
|
||||||
end
|
|
||||||
else begin
|
|
||||||
if i = 0 then
|
|
||||||
Code := eString
|
|
||||||
else
|
|
||||||
Code := Code + #13#10 + eString;
|
|
||||||
end;
|
end;
|
||||||
end
|
|
||||||
else begin
|
|
||||||
if i = 0 then
|
|
||||||
Code := eString
|
|
||||||
else
|
|
||||||
Code := Code + #13#10 + eString;
|
|
||||||
end;
|
end;
|
||||||
|
Code := eLines.Text;
|
||||||
|
|
||||||
frmMain.pbLoading.Position := i;
|
if (frmSettings.optConfig.Checked) and (not eFound) then begin
|
||||||
SetProgressStatus('Loading file...');
|
eLines.Clear;
|
||||||
Inc(i, 1);
|
|
||||||
Application.ProcessMessages;
|
|
||||||
end;
|
|
||||||
HideProgress;
|
|
||||||
Result := Index;
|
|
||||||
|
|
||||||
CloseFile(F);
|
|
||||||
|
|
||||||
if frmSettings.optConfig.Checked then begin
|
|
||||||
eLines := TStringList.Create;
|
|
||||||
if FileExists(ExtractFilePath(ParamStr(0)) + 'config\Notes.dat') then
|
if FileExists(ExtractFilePath(ParamStr(0)) + 'config\Notes.dat') then
|
||||||
eLines.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'config\Notes.dat')
|
eLines.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'config\Notes.dat')
|
||||||
else begin
|
else begin
|
||||||
eLines.Clear; // something must be wrong, clear
|
|
||||||
eLines.Add('AMXX-Studio Notes - DO NOT MODIFY THIS FILE');
|
eLines.Add('AMXX-Studio Notes - DO NOT MODIFY THIS FILE');
|
||||||
eLines.SaveToFile(ExtractFilePath(ParamStr(0)) + 'config\Notes.dat');
|
eLines.SaveToFile(ExtractFilePath(ParamStr(0)) + 'config\Notes.dat');
|
||||||
end;
|
end;
|
||||||
|
@ -1266,11 +1210,10 @@ begin
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
eLines.Destroy;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Screen.Cursor := crDefault;
|
Screen.Cursor := crDefault;
|
||||||
|
eLines.Free;
|
||||||
|
|
||||||
if not Plugin_FileLoad(AFilename, False) then exit;
|
if not Plugin_FileLoad(AFilename, False) then exit;
|
||||||
|
|
||||||
|
|
|
@ -4498,8 +4498,8 @@ object frmMain: TfrmMain
|
||||||
OnMouseMove = lstOutputMouseMove
|
OnMouseMove = lstOutputMouseMove
|
||||||
end
|
end
|
||||||
object pnlLoading: TSpTBXPanel
|
object pnlLoading: TSpTBXPanel
|
||||||
Left = 268
|
Left = 206
|
||||||
Top = 278
|
Top = 306
|
||||||
Width = 253
|
Width = 253
|
||||||
Height = 57
|
Height = 57
|
||||||
Caption = 'pnlLoading'
|
Caption = 'pnlLoading'
|
||||||
|
|
|
@ -488,6 +488,9 @@ procedure TfrmMain.rtfNotesKeyDown(Sender: TObject; var Key: Word;
|
||||||
Shift: TShiftState);
|
Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
UpdateNotes;
|
UpdateNotes;
|
||||||
|
|
||||||
|
mnuModified.Caption := lModified;
|
||||||
|
ActiveDoc.Modified := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ <- Notes - Code-Explorer -> }
|
{ <- Notes - Code-Explorer -> }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user