1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-30 12:52:16 -05:00

Merge branch 'lape-integration' into tests

This commit is contained in:
Merlijn Wajer 2011-09-28 23:28:17 +02:00
commit 0c93796e02
3 changed files with 200 additions and 108 deletions

View File

@ -18,10 +18,12 @@ an integer:
.. code-block:: pascal .. code-block:: pascal
var bmp, x, y: integer; var bmp, x, y: integer;
begin
bmp := CreateBitmap(10, 10); // Create a bitmap of size (10, 10) bmp := CreateBitmap(10, 10); // Create a bitmap of size (10, 10)
if FindBitmapIn(bmp, x, y, 0, 0, 300, 300) then if FindBitmapIn(bmp, x, y, 0, 0, 300, 300) then
writeln('Found it!'); writeln('Found it!');
FreeBitmap(bmp); // Don't forget to free it when we are done. FreeBitmap(bmp); // Don't forget to free it when we are done.
end;
Note that the previous example doesn't make a lot of sense as the bitmap has Note that the previous example doesn't make a lot of sense as the bitmap has
only been created and not filled with any colours, they are as of yet, only been created and not filled with any colours, they are as of yet,
@ -33,7 +35,7 @@ function.
Word of caution on bitmap creation Word of caution on bitmap creation
---------------------------------- ----------------------------------
Bitmaps in Simba are internally all instances of *TMufasBitmap*. Scripts should Bitmaps in Simba are internally all instances of *TMufasaBitmap*. Scripts should
generally access bitmaps using their *handle*: an integer. All functions generally access bitmaps using their *handle*: an integer. All functions
referenced here either require a bitmap *handle* or return one. referenced here either require a bitmap *handle* or return one.
@ -46,7 +48,9 @@ free it again)
.. code-block:: pascal .. code-block:: pascal
var bmp: TMufasaBitmap; var bmp: TMufasaBitmap;
begin
bmp := TMufasBitmap.Create; bmp := TMufasBitmap.Create;
end;
Because there is no way to get a *handle* to this bitmap; as it will not be Because there is no way to get a *handle* to this bitmap; as it will not be
managed by Simba internally. (All Bitmaps created by *CreateBitmap* are managed managed by Simba internally. (All Bitmaps created by *CreateBitmap* are managed
@ -75,10 +79,12 @@ then call this function to get the class reference.
var bmp: TMufasaBitmap; var bmp: TMufasaBitmap;
bmph: integer; bmph: integer;
begin;
bmph := CreateBitmap(100, 100); bmph := CreateBitmap(100, 100);
bmp := GetMufasaBitmap(bmph); bmp := GetMufasaBitmap(bmph);
bmp.SetSize(150,150); // also changes bmph, as they are the same bitmap. bmp.SetSize(150,150); // also changes bmph, as they are the same bitmap.
end;
.. _scriptref-createbitmapstring: .. _scriptref-createbitmapstring:

View File

@ -0,0 +1,74 @@
ssSettings = 'Settings/';
ssLastConfig = 'LastConfig/';
ssUpdater = 'Updater/';
ssFonts = 'Fonts/';
ssIncludes = 'Includes/';
ssInterpreter = 'Interpreter/';
ssTabs = 'Tabs/';
ssColourPicker = 'ColourPicker/';
ssScripts = 'Scripts/';
ssExtensions = 'Extensions/';
ssMainForm = 'MainForm/';
ssSourceEditor = 'SourceEditor/';
ssTray = 'Tray/';
ssConsole = 'Console/';
ssNews = 'News/';
ssPlugins = 'Plugins/';
ssCheckUpdate = ssSettings + ssUpdater + 'CheckForUpdates';
ssCheckUpdateMinutes = ssSettings + ssUpdater + 'CheckEveryXMinutes';
ssUpdaterLink = ssSettings + ssUpdater + 'RemoteLink';
ssUpdaterVersionLink = ssSettings + ssUpdater + 'RemoteVersionLink';
ssLoadFontsOnStart = ssSettings + ssFonts + 'LoadOnStartUp';
ssFontsVersion = ssSettings + ssFonts + 'Version';
ssFontsLink = ssSettings + ssFonts + 'UpdateLink';
ssFontsVersionLink = ssSettings + ssFonts + 'VersionLink';
ssFontsPath = ssSettings + ssFonts + 'Path';
ssIncludesPath = ssSettings + ssIncludes + 'Path';
ssInterpreterType = ssSettings + ssInterpreter + 'Type';
ssTabsOpenNextOnClose = ssSettings + ssTabs + 'OpenNextOnClose';
ssTabsOpenScriptInNewTab = ssSettings + ssTabs + 'OpenScriptInNewTab';
ssTabsCheckBeforeOpen = ssSettings + ssTabs + 'CheckTabsBeforeOpen';
ssColourPickerShowHistoryOnPick = ssSettings + ssColourPicker + 'ShowHistoryOnPick';
ssColourPickerAddToHistoryOnPick = ssSettings + ssColourPicker + 'AddToHistoryOnPick';
ssScriptsPath = ssSettings + ssScripts + 'Path';
ssCodeHintsShowAutomatically = ssSettings + 'CodeHints/ShowAutomatically';
ssCodeCompletionShowAutomatically = ssSettings + 'CodeCompletion/ShowAutomatically';
ssSourceEditorLazColors = ssSettings + ssSourceEditor + 'LazColors';
ssSourceEditorDefScriptPath = ssSettings + ssSourceEditor + 'DefScriptPath';
ssNewsLink = ssSettings + ssNews + 'URL';
ssPluginsPath = ssSettings + ssPlugins + 'Path';
ssExtensionsExtensionN = ssExtensions + 'Extension';
ssExtensionsPath = ssSettings + ssExtensions + 'Path';
ssExtensionsCount = ssExtensions + 'ExtensionCount';
ssExtensionsFileExtension = ssSettings + ssExtensions + 'FileExtension';
ssTrayAlwaysVisible = ssSettings + ssTray + 'AlwaysVisible';
ssConsoleVisible = ssLastConfig + ssConsole + 'Visible';
ssMainFormPosition = ssLastConfig + ssMainForm + 'Position';
ssMainFormState = ssLastConfig + ssMainForm + 'State';
ssMainFormNormalSize = ssSettings + ssMainForm + 'NormalSize';
ssFunctionListShown = ssLastConfig + ssMainForm + 'FunctionListShown';
ssFunctionListShowOnStart = ssSettings + 'FunctionList/ShowOnStart';
ssMaxRecentFiles = ssSettings + 'General/MaxRecentFiles';
ssRecentFiles = ssLastConfig + ssMainForm + 'RecentFiles';
ssRecentFilesCount = ssLastConfig + ssMainForm + 'RecentFiles/Count';
ssRecentFileN = ssLastConfig + ssMainForm + 'RecentFiles/File';

View File

@ -83,6 +83,8 @@ const
shortcut_PickColourKey = VK_P; shortcut_PickColourKey = VK_P;
{$ENDIF} {$ENDIF}
{$I settings_const.inc}
type type
{ TMufasaTab } { TMufasaTab }
@ -774,8 +776,8 @@ end;
function TSimbaForm.GetInterpreter: Integer; function TSimbaForm.GetInterpreter: Integer;
begin begin
Result := StrToIntDef(LoadSettingDef('Settings/Interpreter/Type', '0'), 0); result := StrToIntDef(LoadSettingDef(ssInterpreterType, '0'),0);
if ((Result < 0) or (Result > 3)) then if (result < 0) or (result > 3) then
begin begin
SetInterpreter(0); SetInterpreter(0);
Result := 0; Result := 0;
@ -784,12 +786,12 @@ end;
function TSimbaForm.GetDefScriptPath: string; function TSimbaForm.GetDefScriptPath: string;
begin begin
result :=LoadSettingDef('Settings/SourceEditor/DefScriptPath', ExpandFileName(MainDir+DS+'default.simba')); result :=LoadSettingDef(ssSourceEditorDefScriptPath, ExpandFileName(MainDir+DS+'default.simba'));
end; end;
function TSimbaForm.GetScriptPath: string; function TSimbaForm.GetScriptPath: string;
begin begin
result :=IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Scripts/Path', ExpandFileName(MainDir+DS+'Scripts' + DS))); result :=IncludeTrailingPathDelimiter(LoadSettingDef(ssScriptsPath, ExpandFileName(MainDir+DS+'Scripts' + DS)));
end; end;
procedure TSimbaForm.HandleOpenFileData; procedure TSimbaForm.HandleOpenFileData;
@ -998,7 +1000,7 @@ var
begin begin
UpdateTimer.Interval := MaxInt; UpdateTimer.Interval := MaxInt;
FontUpdate; FontUpdate;
chk := LowerCase(LoadSettingDef('Settings/Updater/CheckForUpdates','True')); chk := LowerCase(LoadSettingDef(ssCheckUpdate, 'True'));
if chk <> 'true' then if chk <> 'true' then
Exit; Exit;
@ -1014,8 +1016,8 @@ begin
mDebugLn(format('Current Simba version: %d',[SimbaVersion])); mDebugLn(format('Current Simba version: %d',[SimbaVersion]));
mDebugLn('Latest Simba Version: ' + IntToStr(LatestVersion)); mDebugLn('Latest Simba Version: ' + IntToStr(LatestVersion));
end; end;
time := StrToIntDef(LoadSettingDef('Settings/Updater/CheckEveryXMinutes','30'),30); time := StrToIntDef(LoadSettingDef(ssCheckUpdateMinutes, '30'),30);
UpdateTimer.Interval := time {mins} * 60 {secs} * 1000 {ms};//Every half hour UpdateTimer.Interval:= time {mins} * 60 {secs} * 1000 {ms};//Every half hour
end; end;
procedure TSimbaForm.UpdateMenuButtonClick(Sender: TObject); procedure TSimbaForm.UpdateMenuButtonClick(Sender: TObject);
@ -1160,7 +1162,7 @@ begin
OldIndex := PageControl1.TabIndex; OldIndex := PageControl1.TabIndex;
if TabIndex = OldIndex then if TabIndex = OldIndex then
begin; begin;
if lowercase(LoadSettingDef('Settings/Tabs/OpenNextOnClose','False')) = 'false' then if lowercase(LoadSettingDef(ssTabsOpenNextOnClose, 'False')) = 'false' then
OldIndex := LastTab //We are closing the 'current' tab, lets go back in history OldIndex := LastTab //We are closing the 'current' tab, lets go back in history
else else
OldIndex := Min(Tabs.Count - 1,OldIndex + 1); OldIndex := Min(Tabs.Count - 1,OldIndex + 1);
@ -1370,43 +1372,52 @@ procedure TSimbaForm.CreateDefaultEnvironment;
var var
PluginsPath,extensionsPath : string; PluginsPath,extensionsPath : string;
begin begin
CreateSetting('Settings/Updater/CheckForUpdates','True'); CreateSetting(ssCheckUpdate, 'True');
CreateSetting('Settings/Updater/CheckEveryXMinutes','30'); CreateSetting(ssCheckUpdateMinutes, '30');
CreateSetting('Settings/Interpreter/Type', '0'); CreateSetting(ssInterpreterType, '0');
CreateSetting('Settings/Fonts/LoadOnStartUp', 'True'); CreateSetting(ssLoadFontsOnStart, 'True');
CreateSetting('Settings/Fonts/Version','-1'); CreateSetting(ssFontsVersion, '-1');
CreateSetting('Settings/Tabs/OpenNextOnClose','False'); CreateSetting(ssTabsOpenNextOnClose, 'False');
CreateSetting('Settings/Tabs/OpenScriptInNewTab','True'); CreateSetting(ssTabsOpenScriptInNewTab, 'True');
CreateSetting('Settings/Tabs/CheckTabsBeforeOpen','True'); CreateSetting(ssTabsCheckBeforeOpen, 'True');
CreateSetting('Settings/ColourPicker/ShowHistoryOnPick', 'True'); CreateSetting(ssColourPickerShowHistoryOnPick, 'True');
CreateSetting('Settings/General/MaxRecentFiles','10'); CreateSetting(ssMaxRecentFiles, '10');
CreateSetting('Settings/MainForm/NormalSize','739:555'); CreateSetting(ssMainFormNormalSize, '739:555');
CreateSetting('Settings/FunctionList/ShowOnStart','True'); CreateSetting(ssFunctionListShowOnStart, 'True');
CreateSetting('Settings/CodeHints/ShowAutomatically','True'); CreateSetting(ssCodeHintsShowAutomatically, 'True');
CreateSetting('Settings/CodeCompletion/ShowAutomatically','True'); CreateSetting(ssCodeCompletionShowAutomatically, 'True');
CreateSetting('Settings/SourceEditor/LazColors','True'); CreateSetting(ssSourceEditorLazColors, 'True');
{$IFDEF USE_EXTENSIONS}CreateSetting('Settings/Extensions/FileExtension','sex');{$ENDIF}
CreateSetting('Settings/Updater/RemoteLink',SimbaURL + 'Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF}); {$IFDEF USE_EXTENSIONS}
CreateSetting('Settings/Updater/RemoteVersionLink',SimbaURL + 'Version'); CreateSetting(ssExtensionsFileExtension, 'sex');
CreateSetting('Settings/Fonts/VersionLink', FontURL + 'Version'); {$ENDIF}
CreateSetting('Settings/Fonts/UpdateLink', FontURL + 'Fonts.tar.bz2');
CreateSetting('Settings/News/URL', 'http://simba.villavu.com/bin/news'); CreateSetting(ssUpdaterLink, SimbaURL + 'Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF});
CreateSetting(ssUpdaterVersionLink, SimbaURL + 'Version');
CreateSetting(ssFontsVersionLink, FontURL + 'Version');
CreateSetting(ssFontsLink, FontURL + 'Fonts.tar.bz2');
CreateSetting(ssNewsLink, 'http://simba.villavu.com/bin/news');
{Creates the paths and returns the path} {Creates the paths and returns the path}
PluginsPath := CreateSetting('Settings/Plugins/Path', ExpandFileName(MainDir+ DS+ 'Plugins' + DS)); PluginsPath := CreateSetting(ssPluginsPath, ExpandFileName(MainDir + DS + 'Plugins' + DS));
{$IFDEF USE_EXTENSIONS} {$IFDEF USE_EXTENSIONS}
extensionsPath := CreateSetting('Settings/Extensions/Path',ExpandFileName(MainDir +DS + 'Extensions' + DS)); extensionsPath := CreateSetting(ssExtensionsPath,
CreateSetting('Extensions/ExtensionCount','0'); ExpandFileName(MainDir +DS + 'Extensions' + DS));
CreateSetting(ssExtensionsCount, '0');
{$ENDIF} {$ENDIF}
CreateSetting('LastConfig/MainForm/Position','');
CreateSetting('LastConfig/MainForm/State','Normal'); CreateSetting(ssMainFormPosition, '');
CreateSetting(ssMainFormState, 'Normal');
{$ifdef MSWindows} {$ifdef MSWindows}
CreateSetting('LastConfig/Console/Visible','False'); CreateSetting(ssConsoleVisible, 'False');
ShowConsole(False); ShowConsole(False);
{$endif} {$endif}
CreateSetting('Settings/Tray/AlwaysVisible', 'True');
CreateSetting(ssTrayAlwaysVisible, 'True');
if not DirectoryExists(IncludePath) then if not DirectoryExists(IncludePath) then
CreateDir(IncludePath); CreateDir(IncludePath);
if not DirectoryExists(FontPath) then if not DirectoryExists(FontPath) then
@ -1435,7 +1446,7 @@ var
i,ii : integer; i,ii : integer;
begin begin
self.BeginFormUpdate; self.BeginFormUpdate;
str := LoadSettingDef('LastConfig/MainForm/Position',''); str := LoadSettingDef(ssMainFormPosition, '');
if str <> '' then if str <> '' then
begin; begin;
Data := Explode(':',str); Data := Explode(':',str);
@ -1446,36 +1457,38 @@ begin
Self.Width:= StrToIntDef(Data[2],self.width); Self.Width:= StrToIntDef(Data[2],self.width);
Self.Height:= StrToIntDef(Data[3],self.height); Self.Height:= StrToIntDef(Data[3],self.height);
end; end;
str := lowercase(LoadSettingDef('LastConfig/MainForm/State','Normal')); str := lowercase(LoadSettingDef(ssMainFormState, 'Normal'));
if str = 'maximized' then if str = 'maximized' then
self.windowstate := wsMaximized self.windowstate := wsMaximized
else else
// if str = 'normal' then // if str = 'normal' then
Self.WindowState := wsNormal; Self.WindowState := wsNormal;
if SettingExists('LastConfig/MainForm/RecentFiles/Count') then if SettingExists(ssRecentFilesCount) then
begin; begin;
ii := StrToIntDef(LoadSettingDef('LastConfig/MainForm/RecentFiles/Count','-1'),-1); ii := StrToIntDef(LoadSettingDef(ssRecentFilesCount, '-1'), -1);
for i := 0 to ii do for i := 0 to ii do
begin begin
str := LoadSettingDef('LastConfig/MainForm/RecentFiles/File' + inttostr(I),''); str := LoadSettingDef(ssRecentFileN + inttostr(I),'');
if str <> '' then if str <> '' then
AddRecentFile(str); AddRecentFile(str);
end; end;
end; end;
str := LowerCase(LoadSettingDef('Settings/FunctionList/ShowOnStart','True')); str := LowerCase(LoadSettingDef(ssFunctionListShowOnStart, 'True'));
str2 := lowercase(LoadSettingDef('LastConfig/MainForm/FunctionListShown','')); str2 := lowercase(LoadSettingDef(ssFunctionListShown, ''));
if (str = 'true') or (str2 = 'true') then if (str = 'true') or (str2 = 'true') then
FunctionListShown(True) FunctionListShown(True)
else else
FunctionListShown(false); FunctionListShown(false);
{$ifdef MSWindows} {$ifdef MSWindows}
str := LowerCase(LoadSettingDef('LastConfig/Console/Visible','True')); str := LowerCase(LoadSettingDef(ssConsoleVisible, 'True'));
if str = 'true' then if str = 'true' then
ShowConsole(True) ShowConsole(True)
else else
ShowConsole(false); ShowConsole(false);
{$endif} {$endif}
if Lowercase(LoadSettingDef('Settings/Tray/AlwaysVisible', 'True')) <> 'true' then
if Lowercase(LoadSettingDef(ssTrayAlwaysVisible, 'True')) <> 'true' then
begin begin
MTrayIcon.Hide; MTrayIcon.Hide;
writeln('Hiding tray.'); writeln('Hiding tray.');
@ -1494,36 +1507,36 @@ begin
with SettingsForm.Settings do with SettingsForm.Settings do
begin begin
if Self.WindowState = wsMaximized then if Self.WindowState = wsMaximized then
SetSetting('LastConfig/MainForm/State','maximized') SetSetting(ssMainFormState, 'maximized')
else else
begin; //Only save the form position if its not maximized. begin; //Only save the form position if its not maximized.
SetSetting('LastConfig/MainForm/State','normal'); SetSetting(ssMainFormState, 'normal');
Data := ConvArr([inttostr(Self.left),inttostr(self.top),inttostr(self.width),inttostr(self.height)]); Data := ConvArr([inttostr(Self.left),inttostr(self.top),inttostr(self.width),inttostr(self.height)]);
SetSetting('LastConfig/MainForm/Position', Implode(':',Data )); SetSetting(ssMainFormPosition, Implode(':',Data ));
end; end;
DeleteKey('LastConfig/MainForm/RecentFiles'); DeleteKey(ssRecentFiles);
if RecentFiles.Count > 0 then if RecentFiles.Count > 0 then
begin begin
SetSetting('LastConfig/MainForm/RecentFiles/Count',inttostr(RecentFiles.Count)); SetSetting(ssRecentFiles + '/Count', inttostr(RecentFiles.Count));
SetLength(data,RecentFiles.Count); SetLength(data,RecentFiles.Count);
for i := 0 to RecentFiles.Count - 1 do for i := 0 to RecentFiles.Count - 1 do
SetSetting('LastConfig/MainForm/RecentFiles/File'+inttostr(i),RecentFiles[i]); SetSetting(ssRecentFileN + inttostr(i),RecentFiles[i]);
end; end;
if MenuItemFunctionList.Checked then if MenuItemFunctionList.Checked then
SetSetting('LastConfig/MainForm/FunctionListShown','True') SetSetting(ssFunctionListShown, 'True')
else else
SetSetting('LastConfig/MainForm/FunctionListShown','False'); SetSetting(ssFunctionListShown, 'False');
{$ifdef MSWindows} {$ifdef MSWindows}
if ConsoleVisible then if ConsoleVisible then
SetSetting('LastConfig/Console/Visible','True') SetSetting(ssConsoleVisible, 'True')
else else
SetSetting('LastConfig/Console/Visible','False'); SetSetting(ssConsoleVisible, 'False');
{$endif} {$endif}
{$IFDEF USE_EXTENSIONS} {$IFDEF USE_EXTENSIONS}
SetSetting('Extensions/ExtensionCount',inttostr(ExtManager.Extensions.Count)); SetSetting(ssExtensionsCount, inttostr(ExtManager.Extensions.Count));
for i := 0 to ExtManager.Extensions.Count-1 do for i := 0 to ExtManager.Extensions.Count-1 do
begin; begin;
path :='Extensions/Extension' + inttostr(I); path := ssExtensionsExtensionN + inttostr(I);
SetSetting(Path + '/Path',TVirtualSimbaExtension(ExtManager.Extensions[i]).Filename); SetSetting(Path + '/Path',TVirtualSimbaExtension(ExtManager.Extensions[i]).Filename);
SetSetting(Path + '/Enabled',BoolToStr(TVirtualSimbaExtension(ExtManager.Extensions[i]).Enabled,True)); SetSetting(Path + '/Enabled',BoolToStr(TVirtualSimbaExtension(ExtManager.Extensions[i]).Enabled,True));
end; end;
@ -1545,7 +1558,7 @@ var
result := false; result := false;
if (number < 0) or (number >= extCount) then if (number < 0) or (number >= extCount) then
exit; exit;
path := 'Extensions/Extension' + inttostr(number); path := ssExtensionsExtensionN + inttostr(number);
if SettingExists(Path) = false then if SettingExists(Path) = false then
exit; exit;
ExtPath := LoadSettingDef(Path + '/Path',''); ExtPath := LoadSettingDef(Path + '/Path','');
@ -1561,11 +1574,11 @@ var
i : integer; i : integer;
path : string; path : string;
begin; begin;
path := 'Extensions/Extension'; path := ssExtensionsExtensionN;
SettingsForm.Settings.DeleteKey(path + inttostr(number)); SettingsForm.Settings.DeleteKey(path + inttostr(number));
for i := number + 1 to extCount - 1 do for i := number + 1 to extCount - 1 do
SettingsForm.Settings.RenameKey(path + inttostr(i),'Extension' + inttostr(i-1)); SettingsForm.Settings.RenameKey(path + inttostr(i),'Extension' + inttostr(i-1));
SetSetting('Extensions/ExtensionCount',inttostr(extCount - 1),true); SetSetting(ssExtensionsCount, inttostr(extCount - 1),true);
dec(extCount); dec(extCount);
end; end;
@ -1573,13 +1586,13 @@ var
str,str2 : string; str,str2 : string;
i : integer; i : integer;
begin begin
extCount := StrToIntDef(LoadSettingDef('Extensions/ExtensionCount/','0'),0); extCount := StrToIntDef(LoadSettingDef(ssExtensionsCount, '0'),0);
for i := 0 to extCount - 1 do for i := 0 to extCount - 1 do
while (i < extCount) and not LoadExtension(i) do while (i < extCount) and not LoadExtension(i) do
DeleteExtension(i); DeleteExtension(i);
SetSetting('Extensions/ExtensionCount',inttostr(extCount)); SetSetting(ssExtensionsCount, inttostr(extCount));
str := LoadSettingDef('Settings/Extensions/Path',ExpandFileName(MainDir +DS + 'Extensions' + DS)); str := LoadSettingDef(ssExtensionsPath, ExpandFileName(MainDir +DS + 'Extensions' + DS));
str2 := LoadSettingDef('Settings/Extensions/FileExtension','sex'); str2 := LoadSettingDef(ssExtensionsFileExtension, 'sex');
ExtManager.LoadPSExtensionsDir(str,str2); ExtManager.LoadPSExtensionsDir(str,str2);
{$ELSE} {$ELSE}
begin begin
@ -1591,7 +1604,7 @@ var
MaxRecentFiles : integer; MaxRecentFiles : integer;
Len,i : integer; Len,i : integer;
begin begin
MaxRecentFiles:= StrToIntDef(LoadSettingDef('Settings/General/MaxRecentFiles','10'),10); MaxRecentFiles:= StrToIntDef(LoadSettingDef(ssMaxRecentFiles, '10'), 10);
i := RecentFiles.IndexOf(filename); i := RecentFiles.IndexOf(filename);
if i <> -1 then if i <> -1 then
RecentFiles.Delete(i); RecentFiles.Delete(i);
@ -1686,7 +1699,7 @@ begin
if selector.haspicked then if selector.haspicked then
Thread.Client.IOManager.SetTarget(Selector.LastPick); Thread.Client.IOManager.SetTarget(Selector.LastPick);
loadFontsOnScriptStart := (lowercase(LoadSettingDef('Settings/Fonts/LoadOnStartUp', 'True')) = 'true'); loadFontsOnScriptStart := (lowercase(LoadSettingDef(ssLoadFontsOnStart, 'True')) = 'true');
if (loadFontsOnScriptStart) then if (loadFontsOnScriptStart) then
begin begin
@ -1950,12 +1963,12 @@ var
SizeStr : string; SizeStr : string;
Data : TStringArray; Data : TStringArray;
begin begin
SizeStr := LoadSettingDef('Settings/MainForm/NormalSize','739:555'); SizeStr := LoadSettingDef(ssMainFormNormalSize, '739:555');
Data := Explode(':',SizeStr); Data := Explode(':',SizeStr);
if length(Data) = 2 then if length(Data) = 2 then
begin begin
Self.Width:= StrToIntDef(Data[0],739); Self.Width:= StrToIntDef(Data[0], 739);
Self.Height:= StrToIntDef(Data[1],555); Self.Height:= StrToIntDef(Data[1], 555);
end else end else
begin; begin;
self.width := 739; self.width := 739;
@ -2833,7 +2846,7 @@ end;
procedure TSimbaForm.MTrayIconClick(Sender: TObject); procedure TSimbaForm.MTrayIconClick(Sender: TObject);
begin begin
self.Show; self.Show;
if Lowercase(LoadSettingDef('Settings/Tray/AlwaysVisible', 'True')) <> 'true' then if Lowercase(LoadSettingDef(ssTrayAlwaysVisible, 'True')) <> 'true' then
MTrayIcon.Hide; MTrayIcon.Hide;
if Self.CanFocus then if Self.CanFocus then
self.SetFocus; self.SetFocus;
@ -2843,7 +2856,7 @@ function TSimbaForm.GetSimbaNews: String;
var var
t: TDownloadThread; t: TDownloadThread;
begin begin
t := TDownloadThread.Create(LoadSettingDef('Settings/News/URL', 'http://Simba.villavu.com/bin/news'), t := TDownloadThread.Create(LoadSettingDef(ssNewsLink, 'http://Simba.villavu.com/bin/news'),
@Result); @Result);
t.Resume; t.Resume;
while not t.done do while not t.done do
@ -2855,13 +2868,13 @@ end;
procedure TSimbaForm.SetDefScriptPath(const AValue: string); procedure TSimbaForm.SetDefScriptPath(const AValue: string);
begin begin
SetSetting('Settings/SourceEditor/DefScriptPath',AValue,True); SetSetting(ssSourceEditorDefScriptPath, AValue,True);
end; end;
{$IFDEF USE_EXTENSIONS} {$IFDEF USE_EXTENSIONS}
procedure TSimbaForm.SetExtPath(const AValue: string); procedure TSimbaForm.SetExtPath(const AValue: string);
begin begin
SetSetting('Settings/Extensions/Path',AValue,true); SetSetting(ssExtensionsPath, AValue,true);
end; end;
{$ENDIF} {$ENDIF}
@ -2902,10 +2915,10 @@ begin
cobj := TColourPickerObject.Create(c, Classes.Point(x,y), ''); cobj := TColourPickerObject.Create(c, Classes.Point(x,y), '');
{ TODO: This should be no problem if the form is hidden? } { TODO: This should be no problem if the form is hidden? }
if lowercase(LoadSettingDef('Settings/ColourPicker/AddToHistoryOnPick', 'True')) = 'true' then if lowercase(LoadSettingDef(ssColourPickerAddToHistoryOnPick, 'True')) = 'true' then
ColourHistoryForm.AddColObj(cobj, true); ColourHistoryForm.AddColObj(cobj, true);
if lowercase(LoadSettingDef('Settings/ColourPicker/ShowHistoryOnPick', 'True')) = 'true' then if lowercase(LoadSettingDef(ssColourPickerShowHistoryOnPick, 'True')) = 'true' then
ColourHistoryForm.Show; ColourHistoryForm.Show;
FormWritelnEx('Picked colour: ' + inttostr(c) + ' at (' + inttostr(x) + ', ' + inttostr(y) + ')'); FormWritelnEx('Picked colour: ' + inttostr(c) + ' at (' + inttostr(x) + ', ' + inttostr(y) + ')');
@ -3025,34 +3038,34 @@ end;
function TSimbaForm.GetShowParamHintAuto: boolean; function TSimbaForm.GetShowParamHintAuto: boolean;
begin begin
Result := LowerCase(LoadSettingDef('Settings/CodeHints/ShowAutomatically','True')) = 'true'; Result := LowerCase(LoadSettingDef(ssCodeHintsShowAutomatically, 'True')) = 'true';
end; end;
function TSimbaForm.GetShowCodeCompletionAuto: boolean; function TSimbaForm.GetShowCodeCompletionAuto: boolean;
begin begin
Result := LowerCase(LoadSettingDef('Settings/CodeCompletion/ShowAutomatically','True')) = 'true'; Result := LowerCase(LoadSettingDef(ssCodeCompletionShowAutomatically, 'True')) = 'true';
end; end;
procedure TSimbaForm.SetFontPath(const AValue: String); procedure TSimbaForm.SetFontPath(const AValue: String);
begin begin
SetSetting('Settings/Fonts/Path',AValue,true); SetSetting(ssFontsPath, AValue,true);
end; end;
function TSimbaForm.GetFontPath: String; function TSimbaForm.GetFontPath: String;
begin begin
Result := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Fonts/Path', ExpandFileName(MainDir+DS+'Fonts' + DS))); Result := IncludeTrailingPathDelimiter(LoadSettingDef(ssFontsPath, ExpandFileName(MainDir+DS+'Fonts' + DS)));
end; end;
{$IFDEF USE_EXTENSIONS} {$IFDEF USE_EXTENSIONS}
function TSimbaForm.GetExtPath: string; function TSimbaForm.GetExtPath: string;
begin begin
Result := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Extensions/Path', ExpandFileName(MainDir+DS+'Extensions' + DS))); Result := IncludeTrailingPathDelimiter(LoadSettingDef(ssExtensionsPath, ExpandFileName(MainDir+DS+'Extensions' + DS)));
end; end;
{$ENDIF} {$ENDIF}
function TSimbaForm.GetHighlighter: TSynCustomHighlighter; function TSimbaForm.GetHighlighter: TSynCustomHighlighter;
begin begin
if lowercase(LoadSettingDef('Settings/SourceEditor/LazColors','True')) = 'true' then if lowercase(LoadSettingDef(ssSourceEditorLazColors, 'True')) = 'true' then
result := LazHighlighter result := LazHighlighter
else else
result := SCARHighlighter; result := SCARHighlighter;
@ -3060,17 +3073,17 @@ end;
function TSimbaForm.GetIncludePath: String; function TSimbaForm.GetIncludePath: String;
begin begin
Result := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Includes/Path', ExpandFileName(MainDir+DS+'Includes' + DS))); Result := IncludeTrailingPathDelimiter(LoadSettingDef(ssIncludesPath, ExpandFileName(MainDir+DS+'Includes' + DS)));
end; end;
function TSimbaForm.GetPluginPath: string; function TSimbaForm.GetPluginPath: string;
begin begin
Result := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Plugins/Path', ExpandFileName(MainDir+DS+'Plugins' + DS))); Result := IncludeTrailingPathDelimiter(LoadSettingDef(ssPluginsPath, ExpandFileName(MainDir+DS+'Plugins' + DS)));
end; end;
procedure TSimbaForm.SetIncludePath(const AValue: String); procedure TSimbaForm.SetIncludePath(const AValue: String);
begin begin
SetSetting('Settings/Includes/Path',AValue,true); SetSetting(ssIncludesPath, AValue,true);
end; end;
procedure TSimbaForm.SetInterpreter(const AValue: Integer); procedure TSimbaForm.SetInterpreter(const AValue: Integer);
@ -3081,9 +3094,8 @@ begin
if (CurrScript <> nil) then if (CurrScript <> nil) then
with CurrScript.Synedit do with CurrScript.Synedit do
if (Lines.text = DefaultScript) and not(CanUndo or CanRedo) then if (Lines.text = DefaultScript) and not(CanUndo or CanRedo) then
UpdateCurrScript := True; UpdateCurrScript := true;
SetSetting(ssInterpreterType, IntToStr(AValue),true);
SetSetting('Settings/Interpreter/Type', IntToStr(AValue), True);
UpdateInterpreter; UpdateInterpreter;
if UpdateCurrScript then if UpdateCurrScript then
@ -3092,12 +3104,12 @@ end;
procedure TSimbaForm.SetPluginPath(const AValue: string); procedure TSimbaForm.SetPluginPath(const AValue: string);
begin begin
SetSetting('Settings/Plugins/Path',AValue,true); SetSetting(ssPluginsPath, AValue,true);
end; end;
procedure TSimbaForm.SetScriptPath(const AValue: string); procedure TSimbaForm.SetScriptPath(const AValue: string);
begin begin
SetSetting('Settings/Scripts/Path',AValue,True); SetSetting(ssScriptsPath, AValue,True);
end; end;
procedure TSimbaForm.SetScriptState(const State: TScriptState); procedure TSimbaForm.SetScriptState(const State: TScriptState);
@ -3170,12 +3182,12 @@ begin
if UpdatingFonts then if UpdatingFonts then
exit; exit;
UpdatingFonts := True; UpdatingFonts := True;
CurrVersion := StrToIntDef(LoadSettingDef('Settings/Fonts/Version','-1'),-1); CurrVersion := StrToIntDef(LoadSettingDef(ssFontsVersion, '-1'), -1);
LatestVersion := SimbaUpdateForm.GetLatestFontVersion; LatestVersion := SimbaUpdateForm.GetLatestFontVersion;
if LatestVersion > CurrVersion then if LatestVersion > CurrVersion then
begin; begin;
formWriteln(format('New fonts available. Current version: %d. Latest version: %d',[CurrVersion,LatestVersion])); formWriteln(format('New fonts available. Current version: %d. Latest version: %d',[CurrVersion,LatestVersion]));
FontDownload := TDownloadThread.Create(LoadSettingDef('Settings/Fonts/UpdateLink',FontURL + 'Fonts.tar.bz2'), FontDownload := TDownloadThread.Create(LoadSettingDef(ssFontsLink, FontURL + 'Fonts.tar.bz2'),
@Fonts); @Fonts);
FontDownload.resume; FontDownload.resume;
while FontDownload.Done = false do while FontDownload.Done = false do
@ -3196,7 +3208,7 @@ begin
if UnTarrer.Result then if UnTarrer.Result then
begin; begin;
FormWriteln('Successfully installed the new fonts!'); FormWriteln('Successfully installed the new fonts!');
SetSetting('Settings/Fonts/Version',IntToStr(LatestVersion),true); SetSetting(ssFontsVersion, IntToStr(LatestVersion),true);
if Assigned(self.OCR_Fonts) then if Assigned(self.OCR_Fonts) then
self.OCR_Fonts.Free; self.OCR_Fonts.Free;
FormWriteln('Freeing the current fonts. Creating new ones now'); FormWriteln('Freeing the current fonts. Creating new ones now');
@ -3225,12 +3237,12 @@ end;
procedure TSimbaForm.SetShowParamHintAuto(const AValue: boolean); procedure TSimbaForm.SetShowParamHintAuto(const AValue: boolean);
begin begin
SetSetting('Settings/CodeHints/ShowAutomatically', Booltostr(AValue,true)); SetSetting(ssCodeHintsShowAutomatically, Booltostr(AValue,true));
end; end;
procedure TSimbaForm.SetShowCodeCompletionAuto(const AValue: boolean); procedure TSimbaForm.SetShowCodeCompletionAuto(const AValue: boolean);
begin begin
SetSetting('Settings/CodeCompletion/ShowAutomatically', Booltostr(AValue,true)); SetSetting(ssCodeCompletionShowAutomatically, Booltostr(AValue,true));
end; end;
{$ifdef mswindows} {$ifdef mswindows}
@ -3358,7 +3370,7 @@ var
OpenInNewTab : boolean; OpenInNewTab : boolean;
begin begin
Result := False; Result := False;
OpenInNewTab:= (LowerCase(LoadSettingDef('Settings/Tabs/OpenScriptInNewTab','True')) = 'true'); OpenInNewTab:= (LowerCase(LoadSettingDef(ssTabsOpenScriptInNewTab, 'True')) = 'true');
if not OpenInNewTab then if not OpenInNewTab then
if CanExitOrOpen = false then if CanExitOrOpen = false then
Exit; Exit;
@ -3370,7 +3382,7 @@ begin
InitialDir := ScriptDir; InitialDir := ScriptDir;
Options := [ofAllowMultiSelect, ofExtensionDifferent, ofPathMustExist, ofFileMustExist, ofEnableSizing, ofViewDetail]; Options := [ofAllowMultiSelect, ofExtensionDifferent, ofPathMustExist, ofFileMustExist, ofEnableSizing, ofViewDetail];
Filter:= 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt' + Filter:= 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt' +
{$IFDEF USE_EXTENSIONS}';*.' + LoadSettingDef('Settings/Extensions/FileExtension', 'sex') + {$ENDIF} {$IFDEF USE_EXTENSIONS}';*.' + LoadSettingDef(ssExtensionsFileExtension, 'sex') + {$ENDIF}
'|Any files|*.*'; '|Any files|*.*';
if Execute then if Execute then
begin begin
@ -3399,11 +3411,11 @@ begin
if AlwaysOpenInNewTab then if AlwaysOpenInNewTab then
OpenInNewTab := true OpenInNewTab := true
else else
OpenInNewTab:= (LowerCase(LoadSettingDef('Settings/Tabs/OpenScriptInNewTab','True')) = 'true'); OpenInNewTab:= (LowerCase(LoadSettingDef(ssTabsOpenScriptInNewTab,'True')) = 'true');
if CheckOtherTabs then if CheckOtherTabs then
CheckTabsFirst := True CheckTabsFirst := True
else else
CheckTabsFirst := (Lowercase(LoadSettingDef('Settings/Tabs/CheckTabsBeforeOpen','True')) = 'true'); CheckTabsFirst := (Lowercase(LoadSettingDef(ssTabsCheckBeforeOpen, 'True')) = 'true');
if FileExistsUTF8(FileName) then if FileExistsUTF8(FileName) then
begin; begin;
if CheckTabsFirst then if CheckTabsFirst then
@ -3478,7 +3490,7 @@ begin
else else
InitialDir := ScriptDir; InitialDir := ScriptDir;
filter := 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt' + filter := 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt' +
{$IFDEF USE_EXTENSIONS}';*.' + LoadSettingDef('Settings/Extensions/FileExtension','sex') + {$ENDIF} {$IFDEF USE_EXTENSIONS}';*.' + LoadSettingDef(ssExtensionsFileExtension, 'sex') + {$ENDIF}
'|Any files|*.*'; '|Any files|*.*';
if Execute then if Execute then
begin; begin;