mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-29 04:22:16 -05:00
Comments + changes
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@385 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
2cfdce101b
commit
699432aab6
@ -18,7 +18,7 @@
|
|||||||
See the file COPYING, included in this distribution,
|
See the file COPYING, included in this distribution,
|
||||||
for details about the copyright.
|
for details about the copyright.
|
||||||
|
|
||||||
Coliur History window for Mufasa Macro Library
|
Colour History window for Mufasa Macro Library
|
||||||
}
|
}
|
||||||
unit colourhistory;
|
unit colourhistory;
|
||||||
|
|
||||||
|
@ -68,26 +68,18 @@ 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);
|
||||||
|
|
||||||
if not SettingsForm.Settings.KeyExists('Settings/Updater/RemoteVersionLink') then
|
SimbaVersionThread.InputURL := SettingsForm.Settings.GetSetLoadSaveDefaultKeyValue(
|
||||||
saveAfterSetting := true;
|
|
||||||
|
|
||||||
SimbaVersionThread.InputURL := SettingsForm.Settings.GetSetDefaultKeyValue(
|
|
||||||
'Settings/Updater/RemoteVersionLink',
|
'Settings/Updater/RemoteVersionLink',
|
||||||
'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS} +
|
'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS} +
|
||||||
'.exe'{$ENDIF} + '.version');
|
'.exe'{$ENDIF} + '.version',
|
||||||
|
SimbaSettingsFile);
|
||||||
|
|
||||||
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
|
||||||
@ -151,27 +143,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSimbaUpdateForm.PerformUpdate;
|
procedure TSimbaUpdateForm.PerformUpdate;
|
||||||
var
|
|
||||||
saveAfterSetting: Boolean = false;
|
|
||||||
begin
|
begin
|
||||||
Updater := TMMLFileDownloader.Create;
|
Updater := TMMLFileDownloader.Create;
|
||||||
|
|
||||||
FCancelling := False;
|
FCancelling := False;
|
||||||
FCancelled := False;
|
FCancelled := False;
|
||||||
|
|
||||||
// Make this a setting later
|
Updater.FileURL := SettingsForm.Settings.GetSetLoadSaveDefaultKeyValue(
|
||||||
|
|
||||||
if not SettingsForm.Settings.KeyExists('Settings/Updater/RemoteLink') then
|
|
||||||
saveAfterSetting := true;
|
|
||||||
|
|
||||||
Updater.FileURL := SettingsForm.Settings.GetSetDefaultKeyValue(
|
|
||||||
'Settings/Updater/RemoteLink',
|
'Settings/Updater/RemoteLink',
|
||||||
'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF}
|
'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF},
|
||||||
|
SimbaSettingsFile
|
||||||
);
|
);
|
||||||
|
|
||||||
if saveAfterSetting then
|
|
||||||
SettingsForm.Settings.SaveToXML(SimbaSettingsFile);
|
|
||||||
|
|
||||||
//ApplicationName{$IFDEF WINDOWS} +'.exe'{$ENDIF};
|
//ApplicationName{$IFDEF WINDOWS} +'.exe'{$ENDIF};
|
||||||
|
|
||||||
// Should work on Windows as well
|
// Should work on Windows as well
|
||||||
|
@ -1,3 +1,26 @@
|
|||||||
|
{
|
||||||
|
This file is part of the Mufasa Macro Library (MML)
|
||||||
|
Copyright (c) 2009 by Raymond van Venetië and Merlijn Wajer
|
||||||
|
|
||||||
|
MML is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
MML is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with MML. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
See the file COPYING, included in this distribution,
|
||||||
|
for details about the copyright.
|
||||||
|
|
||||||
|
Settings class for Mufasa Macro Library
|
||||||
|
}
|
||||||
|
|
||||||
unit settings;
|
unit settings;
|
||||||
|
|
||||||
{$mode objfpc}{$M+}
|
{$mode objfpc}{$M+}
|
||||||
@ -22,6 +45,20 @@ type
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
|
TMMLSettings; class to manage settings with XML.
|
||||||
|
Features:
|
||||||
|
- Loading and Saving to XML.
|
||||||
|
- Showing the settings as a tree.
|
||||||
|
- Changing, Creating settings. (No Deleting yet.)
|
||||||
|
- Bad naming conventions.
|
||||||
|
Bugs:
|
||||||
|
- Don't use '/' as a *name* for a node. It WILL fuck up.
|
||||||
|
It is no problem in values, but in NAMES for nodes, it will
|
||||||
|
simply not work.
|
||||||
|
- Poor naming.
|
||||||
|
}
|
||||||
|
|
||||||
TMMLSettings = class(TObject)
|
TMMLSettings = class(TObject)
|
||||||
|
|
||||||
public
|
public
|
||||||
@ -201,6 +238,11 @@ begin
|
|||||||
Result := N;
|
Result := N;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
|
Return the "path" of the given Node.
|
||||||
|
The node should be in Nodes. (TreeView.Items)
|
||||||
|
}
|
||||||
|
|
||||||
function TMMLSettings.GetNodePath(Node: TTreeNode): String;
|
function TMMLSettings.GetNodePath(Node: TTreeNode): String;
|
||||||
var
|
var
|
||||||
N: TTreeNode;
|
N: TTreeNode;
|
||||||
@ -224,6 +266,10 @@ begin
|
|||||||
result := result + s[i] + '/';
|
result := result + s[i] + '/';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
|
Equivalent to 'ls' or 'dir'. It lists the keys in a certain key (directory)
|
||||||
|
}
|
||||||
|
|
||||||
function TMMLSettings.ListKeys(KeyName: String): TStringArray;
|
function TMMLSettings.ListKeys(KeyName: String): TStringArray;
|
||||||
var
|
var
|
||||||
N: TTreeNode;
|
N: TTreeNode;
|
||||||
@ -243,12 +289,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
|
Return wether the given key exists or not
|
||||||
|
}
|
||||||
|
|
||||||
function TMMLSettings.KeyExists(KeyName: String): Boolean;
|
function TMMLSettings.KeyExists(KeyName: String): Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result := WalkToNode(KeyName) <> nil;
|
Result := WalkToNode(KeyName) <> nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
|
Return wether the given key is a key. (again, bad naming)
|
||||||
|
What I mean is, a 'key' only has a 'Value', which a 'directory key' has other
|
||||||
|
keys (or none) as childs.
|
||||||
|
}
|
||||||
|
|
||||||
function TMMLSettings.IsKey(KeyName: String): Boolean;
|
function TMMLSettings.IsKey(KeyName: String): Boolean;
|
||||||
var
|
var
|
||||||
N: TTreeNode;
|
N: TTreeNode;
|
||||||
@ -271,6 +327,10 @@ begin
|
|||||||
Exit(i = 0);
|
Exit(i = 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
|
Perhaps this should just do Exit(not IsKey(KeyName))
|
||||||
|
}
|
||||||
|
|
||||||
function TMMLSettings.IsDirectory(KeyName: String): Boolean;
|
function TMMLSettings.IsDirectory(KeyName: String): Boolean;
|
||||||
var
|
var
|
||||||
N: TTreeNode;
|
N: TTreeNode;
|
||||||
@ -281,6 +341,10 @@ begin
|
|||||||
Exit(False);
|
Exit(False);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
|
Get the value of a Key. (String)
|
||||||
|
}
|
||||||
|
|
||||||
function TMMLSettings.GetKeyValue(KeyName: String): String;
|
function TMMLSettings.GetKeyValue(KeyName: String): String;
|
||||||
var
|
var
|
||||||
N: TTreeNode;
|
N: TTreeNode;
|
||||||
@ -300,6 +364,12 @@ begin
|
|||||||
Exit('');
|
Exit('');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
|
If the key exists - return the value.
|
||||||
|
If it does not exist, create the key - with a possible path, set it to
|
||||||
|
defVal and return defVal.
|
||||||
|
}
|
||||||
|
|
||||||
function TMMLSettings.GetSetDefaultKeyValue(KeyName, defVal: String): String;
|
function TMMLSettings.GetSetDefaultKeyValue(KeyName, defVal: String): String;
|
||||||
var
|
var
|
||||||
Res: String;
|
Res: String;
|
||||||
@ -319,6 +389,10 @@ begin
|
|||||||
Exit(Res);
|
Exit(Res);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
|
Clear the entire tree. Load from fileName. call GetSetDefaultKeyValue.
|
||||||
|
}
|
||||||
|
|
||||||
function TMMLSettings.GetSetLoadSaveDefaultKeyValue(KeyName, defVal, fileName: String): String;
|
function TMMLSettings.GetSetLoadSaveDefaultKeyValue(KeyName, defVal, fileName: String): String;
|
||||||
begin
|
begin
|
||||||
Nodes.Clear;
|
Nodes.Clear;
|
||||||
@ -327,6 +401,9 @@ begin
|
|||||||
SaveToXML(fileName);
|
SaveToXML(fileName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
|
If Key exists, call getSetDefaultKeyValue, else call GetSetLoadSaveDefaultKeyValue
|
||||||
|
}
|
||||||
function TMMLSettings.GetSetLoadSaveDefaultKeyValueIfNotExists(KeyName, defVal, fileName: String): String;
|
function TMMLSettings.GetSetLoadSaveDefaultKeyValueIfNotExists(KeyName, defVal, fileName: String): String;
|
||||||
begin
|
begin
|
||||||
if KeyExists(KeyName) then
|
if KeyExists(KeyName) then
|
||||||
@ -335,6 +412,12 @@ begin
|
|||||||
Exit(GetSetLoadSaveDefaultKeyValue(KeyName, defVal, fileName));
|
Exit(GetSetLoadSaveDefaultKeyValue(KeyName, defVal, fileName));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
|
Create the given key. If CreatePath = true, then create every key that is
|
||||||
|
required to create the key. (Say KeyName = 'a/b/c/d/e' and only key a exists,
|
||||||
|
and CreatePath = True, then b,c,d and e are all created.
|
||||||
|
}
|
||||||
|
|
||||||
function TMMLSettings.CreateKey(KeyName: String; CreatePath: Boolean = False): Boolean;
|
function TMMLSettings.CreateKey(KeyName: String; CreatePath: Boolean = False): Boolean;
|
||||||
var
|
var
|
||||||
N, newN, nParent: TTreeNode;
|
N, newN, nParent: TTreeNode;
|
||||||
@ -374,10 +457,7 @@ begin
|
|||||||
N := WalkToNode(NewPath);
|
N := WalkToNode(NewPath);
|
||||||
|
|
||||||
if (N = nil) and (not CreatePath) then
|
if (N = nil) and (not CreatePath) then
|
||||||
begin
|
|
||||||
writeln('(N = nil) and (not CreatePath)');
|
|
||||||
exit(false);
|
exit(false);
|
||||||
end;
|
|
||||||
|
|
||||||
if (N = nil) and CreatePath then
|
if (N = nil) and CreatePath then
|
||||||
begin
|
begin
|
||||||
@ -408,6 +488,10 @@ begin
|
|||||||
newN.MoveTo(nParent, naAddChild);
|
newN.MoveTo(nParent, naAddChild);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
|
Set the value of a key.
|
||||||
|
}
|
||||||
|
|
||||||
procedure TMMLSettings.SetKeyValue(KeyName: String; KeyValue: String);
|
procedure TMMLSettings.SetKeyValue(KeyName: String; KeyValue: String);
|
||||||
var
|
var
|
||||||
N, NN: TTreeNode;
|
N, NN: TTreeNode;
|
||||||
@ -441,6 +525,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ load from xml }
|
||||||
procedure TMMLSettings.LoadFromXML(fileName: String);
|
procedure TMMLSettings.LoadFromXML(fileName: String);
|
||||||
var
|
var
|
||||||
Doc: TXMLDocument;
|
Doc: TXMLDocument;
|
||||||
@ -487,6 +573,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ save to xml }
|
||||||
|
|
||||||
procedure TMMLSettings.SaveToXML(fileName: String);
|
procedure TMMLSettings.SaveToXML(fileName: String);
|
||||||
var
|
var
|
||||||
XMLDoc: TXMLDocument;
|
XMLDoc: TXMLDocument;
|
||||||
|
Loading…
Reference in New Issue
Block a user