1
0
mirror of https://github.com/moparisthebest/Simba synced 2025-01-11 05:38:00 -05:00

Added some settings.

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@381 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Wizzup? 2010-01-07 19:29:03 +00:00
parent 4a0e4dde3b
commit 96b83db57d
3 changed files with 56 additions and 5 deletions

View File

@ -8,6 +8,9 @@ uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ComCtrls, settings; ComCtrls, settings;
const
SimbaSettingsFile = 'settings.xml';
type type
{ TSettingsForm } { TSettingsForm }

View File

@ -39,7 +39,7 @@ uses
SynExportHTML, SynExportHTML,
SynEditKeyCmds, SynEditHighlighter, SynEditMarkupSpecialLine,SynEditMarkupHighAll, SynEditKeyCmds, SynEditHighlighter, SynEditMarkupSpecialLine,SynEditMarkupHighAll,
SynEditMiscClasses, LMessages, Buttons, PairSplitter,about, framefunctionlist, SynEditMiscClasses, LMessages, Buttons, PairSplitter,about, framefunctionlist,
ocr, updateform; ocr, updateform, simbasettings;
type type
@ -469,6 +469,9 @@ end;
procedure TForm1.RunScript; procedure TForm1.RunScript;
var var
DbgImgInfo : TDbgImgInfo; DbgImgInfo : TDbgImgInfo;
fontPath: String;
saveAfterSetting: Boolean = false;
begin begin
with CurrScript do with CurrScript do
begin begin
@ -513,8 +516,26 @@ begin
if not assigned(Self.OCR_Fonts) then if not assigned(Self.OCR_Fonts) then
begin begin
Self.OCR_Fonts :=TMOCR.Create(ScriptThread.Client); Self.OCR_Fonts :=TMOCR.Create(ScriptThread.Client);
if not SettingsForm.Settings.KeyExists('Settings/Fonts/Path') then
saveAfterSetting := True;
fontPath := SettingsForm.Settings.GetSetDefaultKeyValue('Settings/Fonts/Path',
IncludeTrailingPathDelimiter(ExpandFileName(MainDir +DS + '..' + DS + '..' + ds)) + 'Fonts' + DS);
if saveAfterSetting then
SettingsForm.Settings.SaveToXML('settings.xml');
if DirectoryExists(fontPath) then
begin
OCR_Fonts.InitTOCR(fontPath);
end
else
begin
writeln('Warning: The Font directory in the Settings is not valid. Changing to default.');
OCR_Fonts.InitTOCR(IncludeTrailingPathDelimiter(ExpandFileName(MainDir +DS + '..' + DS + '..' + ds)) + 'Fonts' + DS); OCR_Fonts.InitTOCR(IncludeTrailingPathDelimiter(ExpandFileName(MainDir +DS + '..' + DS + '..' + ds)) + 'Fonts' + DS);
end; end;
end;
ScriptThread.Client.MOCR.SetFonts(OCR_Fonts.GetFonts); ScriptThread.Client.MOCR.SetFonts(OCR_Fonts.GetFonts);
ScriptThread.OnTerminate:=@ScriptThreadTerminate; ScriptThread.OnTerminate:=@ScriptThreadTerminate;

View File

@ -57,7 +57,7 @@ var
implementation implementation
uses uses
internets, TestUnit; internets, TestUnit, simbasettings;
function TSimbaUpdateForm.CanUpdate: Boolean; function TSimbaUpdateForm.CanUpdate: Boolean;
begin begin
@ -68,11 +68,26 @@ begin
end; end;
function TSimbaUpdateForm.GetLatestSimbaVersion: Integer; function TSimbaUpdateForm.GetLatestSimbaVersion: Integer;
var
saveAfterSetting: Boolean = false;
begin begin
if SimbaVersionThread = nil then//Create thread (only if no-other one is already running) if SimbaVersionThread = nil then//Create thread (only if no-other one is already running)
begin begin
SimbaVersionThread := TSimbaVersionThread.Create(true); SimbaVersionThread := TSimbaVersionThread.Create(true);
SimbaVersionThread.InputURL:= 'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF} + '.version';
if not SettingsForm.Settings.KeyExists('Settings/Updater/RemoteVersionLink') then
saveAfterSetting := true;
SimbaVersionThread.InputURL := SettingsForm.Settings.GetSetDefaultKeyValue(
'Settings/Updater/RemoteVersionLink',
'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS} +
'.exe'{$ENDIF} + '.version');
if saveAfterSetting then
SettingsForm.Settings.SaveToXML(SimbaSettingsFile);
// SimbaVersionThread.InputURL:= 'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF} + '.version';
SimbaVersionThread.Resume; SimbaVersionThread.Resume;
while SimbaVersionThread.Done = false do//Wait till thread is done while SimbaVersionThread.Done = false do//Wait till thread is done
begin begin
@ -136,6 +151,8 @@ begin
end; end;
procedure TSimbaUpdateForm.PerformUpdate; procedure TSimbaUpdateForm.PerformUpdate;
var
saveAfterSetting: Boolean = false;
begin begin
Updater := TMMLFileDownloader.Create; Updater := TMMLFileDownloader.Create;
@ -143,7 +160,17 @@ begin
FCancelled := False; FCancelled := False;
// Make this a setting later // Make this a setting later
Updater.FileURL := 'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF};
if not SettingsForm.Settings.KeyExists('Settings/Updater/RemoteLink') then
saveAfterSetting := true;
Updater.FileURL := SettingsForm.Settings.GetSetDefaultKeyValue(
'Settings/Updater/RemoteLink',
'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF}
);
if saveAfterSetting then
SettingsForm.Settings.SaveToXML(SimbaSettingsFile);
//ApplicationName{$IFDEF WINDOWS} +'.exe'{$ENDIF}; //ApplicationName{$IFDEF WINDOWS} +'.exe'{$ENDIF};