1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-21 16:55:01 -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:
Wizzup? 2010-01-08 00:09:15 +00:00
parent 2cfdce101b
commit 699432aab6
3 changed files with 100 additions and 28 deletions

View File

@ -18,7 +18,7 @@
See the file COPYING, included in this distribution,
for details about the copyright.
Coliur History window for Mufasa Macro Library
Colour History window for Mufasa Macro Library
}
unit colourhistory;

View File

@ -68,26 +68,18 @@ begin
end;
function TSimbaUpdateForm.GetLatestSimbaVersion: Integer;
var
saveAfterSetting: Boolean = false;
begin
if SimbaVersionThread = nil then//Create thread (only if no-other one is already running)
begin
SimbaVersionThread := TSimbaVersionThread.Create(true);
if not SettingsForm.Settings.KeyExists('Settings/Updater/RemoteVersionLink') then
saveAfterSetting := true;
SimbaVersionThread.InputURL := SettingsForm.Settings.GetSetDefaultKeyValue(
SimbaVersionThread.InputURL := SettingsForm.Settings.GetSetLoadSaveDefaultKeyValue(
'Settings/Updater/RemoteVersionLink',
'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;
while SimbaVersionThread.Done = false do//Wait till thread is done
begin
@ -151,27 +143,19 @@ begin
end;
procedure TSimbaUpdateForm.PerformUpdate;
var
saveAfterSetting: Boolean = false;
begin
Updater := TMMLFileDownloader.Create;
FCancelling := False;
FCancelled := False;
// Make this a setting later
if not SettingsForm.Settings.KeyExists('Settings/Updater/RemoteLink') then
saveAfterSetting := true;
Updater.FileURL := SettingsForm.Settings.GetSetDefaultKeyValue(
Updater.FileURL := SettingsForm.Settings.GetSetLoadSaveDefaultKeyValue(
'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};
// Should work on Windows as well

View File

@ -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;
{$mode objfpc}{$M+}
@ -22,6 +45,20 @@ type
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)
public
@ -201,6 +238,11 @@ begin
Result := N;
end;
{
Return the "path" of the given Node.
The node should be in Nodes. (TreeView.Items)
}
function TMMLSettings.GetNodePath(Node: TTreeNode): String;
var
N: TTreeNode;
@ -224,6 +266,10 @@ begin
result := result + s[i] + '/';
end;
{
Equivalent to 'ls' or 'dir'. It lists the keys in a certain key (directory)
}
function TMMLSettings.ListKeys(KeyName: String): TStringArray;
var
N: TTreeNode;
@ -243,12 +289,22 @@ begin
end;
end;
{
Return wether the given key exists or not
}
function TMMLSettings.KeyExists(KeyName: String): Boolean;
begin
Result := WalkToNode(KeyName) <> nil;
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;
var
N: TTreeNode;
@ -271,6 +327,10 @@ begin
Exit(i = 0);
end;
{
Perhaps this should just do Exit(not IsKey(KeyName))
}
function TMMLSettings.IsDirectory(KeyName: String): Boolean;
var
N: TTreeNode;
@ -281,6 +341,10 @@ begin
Exit(False);
end;
{
Get the value of a Key. (String)
}
function TMMLSettings.GetKeyValue(KeyName: String): String;
var
N: TTreeNode;
@ -300,6 +364,12 @@ begin
Exit('');
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;
var
Res: String;
@ -319,6 +389,10 @@ begin
Exit(Res);
end;
{
Clear the entire tree. Load from fileName. call GetSetDefaultKeyValue.
}
function TMMLSettings.GetSetLoadSaveDefaultKeyValue(KeyName, defVal, fileName: String): String;
begin
Nodes.Clear;
@ -327,6 +401,9 @@ begin
SaveToXML(fileName);
end;
{
If Key exists, call getSetDefaultKeyValue, else call GetSetLoadSaveDefaultKeyValue
}
function TMMLSettings.GetSetLoadSaveDefaultKeyValueIfNotExists(KeyName, defVal, fileName: String): String;
begin
if KeyExists(KeyName) then
@ -335,6 +412,12 @@ begin
Exit(GetSetLoadSaveDefaultKeyValue(KeyName, defVal, fileName));
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;
var
N, newN, nParent: TTreeNode;
@ -374,10 +457,7 @@ begin
N := WalkToNode(NewPath);
if (N = nil) and (not CreatePath) then
begin
writeln('(N = nil) and (not CreatePath)');
exit(false);
end;
if (N = nil) and CreatePath then
begin
@ -408,6 +488,10 @@ begin
newN.MoveTo(nParent, naAddChild);
end;
{
Set the value of a key.
}
procedure TMMLSettings.SetKeyValue(KeyName: String; KeyValue: String);
var
N, NN: TTreeNode;
@ -441,6 +525,8 @@ begin
end;
end;
{ load from xml }
procedure TMMLSettings.LoadFromXML(fileName: String);
var
Doc: TXMLDocument;
@ -487,6 +573,8 @@ begin
end;
end;
{ save to xml }
procedure TMMLSettings.SaveToXML(fileName: String);
var
XMLDoc: TXMLDocument;