mirror of
https://github.com/moparisthebest/Simba
synced 2024-12-23 07:48:50 -05:00
Fixes
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@377 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
906d4c9b98
commit
aa5fb8bda8
@ -10,7 +10,7 @@
|
||||
<TargetFileExt Value=""/>
|
||||
<Icon Value="0"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<ActiveEditorIndexAtStart Value="1"/>
|
||||
<ActiveEditorIndexAtStart Value="0"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
@ -39,7 +39,7 @@
|
||||
<Filename Value="project1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="project1"/>
|
||||
<UsageCount Value="33"/>
|
||||
<UsageCount Value="35"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
@ -47,10 +47,10 @@
|
||||
<ComponentName Value="Form1"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
<CursorPos X="30" Y="172"/>
|
||||
<TopLine Value="154"/>
|
||||
<CursorPos X="32" Y="174"/>
|
||||
<TopLine Value="151"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<UsageCount Value="33"/>
|
||||
<UsageCount Value="35"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
@ -59,8 +59,8 @@
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="colourhistory"/>
|
||||
<CursorPos X="26" Y="184"/>
|
||||
<TopLine Value="156"/>
|
||||
<CursorPos X="67" Y="236"/>
|
||||
<TopLine Value="211"/>
|
||||
<UsageCount Value="16"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
@ -84,10 +84,10 @@
|
||||
<Filename Value="settings.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="settings"/>
|
||||
<CursorPos X="75" Y="164"/>
|
||||
<TopLine Value="142"/>
|
||||
<CursorPos X="1" Y="194"/>
|
||||
<TopLine Value="168"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<UsageCount Value="31"/>
|
||||
<UsageCount Value="33"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
@ -146,124 +146,124 @@
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="130" Column="15" TopLine="113"/>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="173" Column="1" TopLine="161"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="97" Column="5" TopLine="79"/>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="184" Column="3" TopLine="166"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="96" Column="14" TopLine="78"/>
|
||||
<Caret Line="154" Column="1" TopLine="137"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="79" Column="33" TopLine="61"/>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="76" Column="3" TopLine="56"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="96" Column="12" TopLine="78"/>
|
||||
<Caret Line="65" Column="32" TopLine="39"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="79" Column="12" TopLine="61"/>
|
||||
<Caret Line="42" Column="6" TopLine="42"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="86" Column="46" TopLine="68"/>
|
||||
<Caret Line="70" Column="2" TopLine="56"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="167" Column="23" TopLine="139"/>
|
||||
<Caret Line="75" Column="8" TopLine="62"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="141" Column="6" TopLine="111"/>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="80" Column="1" TopLine="52"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="167" Column="32" TopLine="148"/>
|
||||
<Caret Line="79" Column="3" TopLine="51"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="196" Column="5" TopLine="166"/>
|
||||
<Caret Line="173" Column="19" TopLine="143"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="24" Column="1" TopLine="4"/>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="38" Column="24" TopLine="24"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="197" Column="1" TopLine="164"/>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="326" Column="45" TopLine="294"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="194" Column="30" TopLine="166"/>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="314" Column="13" TopLine="296"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="20" Column="30" TopLine="12"/>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="40" Column="21" TopLine="22"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="156" Column="3" TopLine="136"/>
|
||||
<Caret Line="325" Column="30" TopLine="306"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="84" Column="19" TopLine="59"/>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="49" Column="61" TopLine="23"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="81" Column="11" TopLine="72"/>
|
||||
<Caret Line="242" Column="6" TopLine="215"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="173" Column="1" TopLine="161"/>
|
||||
<Caret Line="235" Column="31" TopLine="213"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="184" Column="3" TopLine="166"/>
|
||||
<Caret Line="14" Column="46" TopLine="1"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="154" Column="1" TopLine="137"/>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="288" Column="26" TopLine="270"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="76" Column="3" TopLine="56"/>
|
||||
<Caret Line="337" Column="1" TopLine="319"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="65" Column="32" TopLine="39"/>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="248" Column="38" TopLine="224"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="42" Column="6" TopLine="42"/>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="42" Column="28" TopLine="23"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="70" Column="2" TopLine="56"/>
|
||||
<Caret Line="169" Column="51" TopLine="141"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="75" Column="8" TopLine="62"/>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="251" Column="63" TopLine="1"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="80" Column="1" TopLine="52"/>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="23" Column="53" TopLine="1"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="79" Column="3" TopLine="51"/>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="194" Column="12" TopLine="176"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="173" Column="19" TopLine="143"/>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="224" Column="9" TopLine="209"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="settings.pas"/>
|
||||
<Caret Line="38" Column="24" TopLine="24"/>
|
||||
<Caret Line="40" Column="21" TopLine="22"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
|
@ -39,9 +39,10 @@ type
|
||||
function KeyExists(KeyName: String): Boolean;
|
||||
function IsKey(KeyName: String): Boolean;
|
||||
function IsDirectory(KeyName: String): Boolean;
|
||||
procedure SetKey(KeyName: String; KeyValue: String);
|
||||
procedure SetKeyValue(KeyName: String; KeyValue: String);
|
||||
function CreateKey(KeyName: String; CreatePath: Boolean = False): Boolean;
|
||||
function GetKeyValue(KeyName: String): String;
|
||||
function GetSetDefaultKeyValue(KeyName, defVal: String): String;
|
||||
|
||||
end;
|
||||
|
||||
@ -197,10 +198,7 @@ begin
|
||||
while N <> nil do
|
||||
begin
|
||||
if N.Text <> 'Value' then
|
||||
begin
|
||||
writeln(N.text);
|
||||
inc(i);
|
||||
end;
|
||||
N := N.GetNextSibling;
|
||||
end;
|
||||
|
||||
@ -221,17 +219,40 @@ function TMMLSettings.GetKeyValue(KeyName: String): String;
|
||||
var
|
||||
N: TTreeNode;
|
||||
begin
|
||||
if IsKey(KeyName) then
|
||||
if not KeyExists(KeyName) then
|
||||
Exit('');
|
||||
N := WalkToNode(KeyName);
|
||||
if N <> nil then
|
||||
if N.GetFirstChild <> nil then
|
||||
if assigned(n.GetFirstChild.Data) then
|
||||
Exit(TSettingData(n.GetFirstChild.Data).Val);
|
||||
|
||||
N := N.GetFirstChild;
|
||||
while N <> nil do
|
||||
begin
|
||||
if N.Text = 'Value' then
|
||||
if assigned(n.Data) then
|
||||
Exit(TSettingData(n.Data).Val);
|
||||
N := N.GetNextSibling;
|
||||
end;
|
||||
Exit('');
|
||||
end;
|
||||
|
||||
function TMMLSettings.GetSetDefaultKeyValue(KeyName, defVal: String): String;
|
||||
var
|
||||
Res: String;
|
||||
begin
|
||||
if not IsKey(KeyName) then
|
||||
begin
|
||||
CreateKey(KeyName, True);
|
||||
SetKeyValue(KeyName, defVal);
|
||||
exit(defVal);
|
||||
end;
|
||||
Res := GetKeyValue(KeyName);
|
||||
if Res = '' then
|
||||
begin
|
||||
SetKeyValue(KeyName, defVal);
|
||||
exit(defVal);
|
||||
end;
|
||||
Exit(Res);
|
||||
end;
|
||||
|
||||
function TMMLSettings.CreateKey(KeyName: String; CreatePath: Boolean = False): Boolean;
|
||||
var
|
||||
N, newN, nParent: TTreeNode;
|
||||
@ -242,7 +263,6 @@ var
|
||||
begin
|
||||
if KeyExists(KeyName) then
|
||||
begin
|
||||
writeln('Key: ' + KeyName + ' exists');
|
||||
Exit(False);
|
||||
end;
|
||||
NewPath := '';
|
||||
@ -305,10 +325,37 @@ begin
|
||||
newN.MoveTo(nParent, naAddChild);
|
||||
end;
|
||||
|
||||
procedure TMMLSettings.SetKey(KeyName: String; KeyValue: String);
|
||||
procedure TMMLSettings.SetKeyValue(KeyName: String; KeyValue: String);
|
||||
var
|
||||
N, NN: TTreeNode;
|
||||
begin
|
||||
if IsKey(KeyName) then
|
||||
if not KeyExists(KeyName) then
|
||||
Exit;
|
||||
if not IsKey(KeyName) then
|
||||
Exit;
|
||||
|
||||
N := WalkToNode(KeyName);
|
||||
|
||||
if not N.HasChildren then
|
||||
begin
|
||||
NN := TTreeNode.Create(Nodes);
|
||||
NN.Text := 'Value';
|
||||
NN.MoveTo(N, naAddChild);
|
||||
end;
|
||||
|
||||
if n <> nil then
|
||||
N := N.GetFirstChild;
|
||||
while N <> nil do
|
||||
begin
|
||||
if N.Text = 'Value' then
|
||||
begin
|
||||
if Assigned(N.Data) then
|
||||
TSettingData(N.Data).Free;
|
||||
N.Data := TSettingData.Create;
|
||||
TSettingData(N.Data).Val := KeyValue;
|
||||
end;
|
||||
N := N.GetNextSibling;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -6,7 +6,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
ComCtrls, StdCtrls, xml2, XMLRead, XMLWrite, DOM;
|
||||
ComCtrls, StdCtrls, XMLRead, XMLWrite, DOM;
|
||||
|
||||
type
|
||||
|
||||
@ -44,7 +44,13 @@ var
|
||||
DDataNode, DataNode: TDOMNode;
|
||||
|
||||
begin
|
||||
XMLChild := XMLDoc.CreateElement(n.Text);
|
||||
if n.Text = 'Value' then
|
||||
begin
|
||||
XMLChild := XMLDoc.CreateTextNode(TSettingData(N.Data).Val);
|
||||
end else
|
||||
begin
|
||||
XMLChild := XMLDoc.CreateElement(n.Text);
|
||||
end;
|
||||
Inc(C);
|
||||
XMLNode.AppendChild(XMLChild);
|
||||
end;
|
||||
@ -156,19 +162,16 @@ var
|
||||
|
||||
begin
|
||||
sett := TMMLSettings.Create(TreeView1.Items);
|
||||
sett.CreateKey('Settings/FullScreen/wat', true);
|
||||
sett.SetKeyValue('Settings/FullScreen/wat', 'TRUE');
|
||||
writeln(sett.GetKeyValue('Settings/FullScreen/wat'));
|
||||
|
||||
if sett.KeyExists('') then
|
||||
writeln('Tree exists');
|
||||
if sett.KeyExists('Settings/a/b/c') then
|
||||
writeln('Settings exists');
|
||||
writeln(sett.GetSetDefaultKeyValue('Settings/FullScreen/wat2', 'OWAT'));
|
||||
|
||||
{writeln(sett.GetKeyValue('Settings/hoi0/Item1/Item2/Item3/wattt')); }
|
||||
sett.CreateKey('Settings/a/b/c', true);
|
||||
writeln(sett.GetSetDefaultKeyValue('Settings/Component1/hoiii', 'NO U'));
|
||||
|
||||
if sett.iskey('Settings/a/b/c') then
|
||||
writeln('is key');
|
||||
|
||||
s := sett.ListKeys('Settings');
|
||||
writeln(sett.GetSetDefaultKeyValue('Settings/Component2/hoi', 'OK'));
|
||||
s := sett.ListKeys('Settings/FullScreen');
|
||||
for i := 0 to high(s) do
|
||||
writeln(s[i]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user