Changeset 128 for trunk/Packages/Common


Ignore:
Timestamp:
May 1, 2023, 11:21:30 AM (19 months ago)
Author:
chronos
Message:
  • Added: Ability to save and load a game.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/UXMLUtils.pas

    r86 r128  
    1414procedure WriteString(Node: TDOMNode; Name: string; Value: string);
    1515procedure WriteDateTime(Node: TDOMNode; Name: string; Value: TDateTime);
     16procedure WriteDouble(Node: TDOMNode; Name: string; Value: Double);
    1617function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer;
    1718function ReadInt64(Node: TDOMNode; Name: string; DefaultValue: Int64): Int64;
     
    1920function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string;
    2021function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime): TDateTime;
     22function ReadDouble(Node: TDOMNode; Name: string; DefaultValue: Double): Double;
    2123procedure ReadXMLFileParser(out Doc: TXMLDocument; FileName: string);
    2224
    2325
    2426implementation
     27
     28function ReadDouble(Node: TDOMNode; Name: string; DefaultValue: Double): Double;
     29var
     30  NewNode: TDOMNode;
     31begin
     32  Result := DefaultValue;
     33  NewNode := Node.FindNode(DOMString(Name));
     34  if Assigned(NewNode) then
     35    Result := StrToFloat(string(NewNode.TextContent));
     36end;
    2537
    2638procedure ReadXMLFileParser(out Doc: TXMLDocument; FileName: string);
     
    200212end;
    201213
     214procedure WriteDouble(Node: TDOMNode; Name: string; Value: Double);
     215var
     216  NewNode: TDOMNode;
     217begin
     218  NewNode := Node.OwnerDocument.CreateElement(DOMString(Name));
     219  NewNode.TextContent := DOMString(FloatToStr(Value));
     220  Node.AppendChild(NewNode);
     221end;
     222
    202223function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer;
    203224var
Note: See TracChangeset for help on using the changeset viewer.