Changeset 64 for trunk


Ignore:
Timestamp:
Sep 26, 2014, 9:01:50 PM (10 years ago)
Author:
chronos
Message:
  • Modified: Improved saving game state to XML file. Not yet finished and can't be loaded yet.
Location:
trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Languages/xtactics.cs.po

    r61 r64  
    476476msgstr "Potřebujete alespoň dva hráče"
    477477
     478#: ugame.snewgamefile
     479msgid "New game.xtg"
     480msgstr ""
     481
    478482#: ugame.sunfinishedbattle
    479483msgid "Unfinished battle"
    480484msgstr "Neukončená bitva"
     485
     486#: ugame.swrongfileformat
     487msgid "Wrong file format"
     488msgstr ""
     489
  • trunk/Languages/xtactics.po

    r61 r64  
    464464msgstr ""
    465465
     466#: ugame.snewgamefile
     467msgid "New game.xtg"
     468msgstr ""
     469
    466470#: ugame.sunfinishedbattle
    467471msgid "Unfinished battle"
    468472msgstr ""
    469473
     474#: ugame.swrongfileformat
     475msgid "Wrong file format"
     476msgstr ""
     477
  • trunk/Packages/Common/UXMLUtils.pas

    r43 r64  
    77uses
    88  {$IFDEF WINDOWS}Windows,{$ENDIF}
    9   Classes, SysUtils, DateUtils;
     9  Classes, SysUtils, DateUtils, XMLRead, XMLWrite, DOM;
    1010
    1111function XMLTimeToDateTime(XMLDateTime: string): TDateTime;
    1212function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): WideString;
     13procedure WriteInteger(Node: TDOMNode; Name: string; Value: Integer);
     14procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean);
     15procedure WriteString(Node: TDOMNode; Name: string; Value: string);
     16function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer;
     17function ReadBoolean(Node: TDOMNode; Name: string; DefaultValue: Boolean): Boolean;
     18function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string;
    1319
    1420
     
    123129end;
    124130
     131procedure WriteInteger(Node: TDOMNode; Name: string; Value: Integer);
     132var
     133  NewNode: TDOMNode;
     134begin
     135  NewNode := Node.OwnerDocument.CreateElement(Name);
     136  NewNode.TextContent := IntToStr(Value);
     137  Node.AppendChild(NewNode);
     138end;
     139
     140procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean);
     141var
     142  NewNode: TDOMNode;
     143begin
     144  NewNode := Node.OwnerDocument.CreateElement(Name);
     145  NewNode.TextContent := BoolToStr(Value);
     146  Node.AppendChild(NewNode);
     147end;
     148
     149procedure WriteString(Node: TDOMNode; Name: string; Value: string);
     150var
     151  NewNode: TDOMNode;
     152begin
     153  NewNode := Node.OwnerDocument.CreateElement(Name);
     154  NewNode.TextContent := Value;
     155  Node.AppendChild(NewNode);
     156end;
     157
     158function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer;
     159var
     160  NewNode: TDOMNode;
     161begin
     162  Result := DefaultValue;
     163  NewNode := Node.FindNode(Name);
     164  if Assigned(NewNode) then
     165    Result := StrToInt(NewNode.TextContent);
     166end;
     167
     168function ReadBoolean(Node: TDOMNode; Name: string; DefaultValue: Boolean): Boolean;
     169var
     170  NewNode: TDOMNode;
     171begin
     172  Result := DefaultValue;
     173  NewNode := Node.FindNode(Name);
     174  if Assigned(NewNode) then
     175    Result := StrToBool(NewNode.TextContent);
     176end;
     177
     178function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string;
     179var
     180  NewNode: TDOMNode;
     181begin
     182  Result := DefaultValue;
     183  NewNode := Node.FindNode(Name);
     184  if Assigned(NewNode) then
     185    Result := NewNode.TextContent;
     186end;
     187
    125188end.
    126189
  • trunk/UCore.lfm

    r62 r64  
    5555    object AGameSave: TAction
    5656      Caption = 'Save'
     57      ImageIndex = 11
    5758      OnExecute = AGameSaveExecute
    5859      ShortCut = 16467
     
    6061    object AGameLoad: TAction
    6162      Caption = 'Load'
     63      ImageIndex = 10
    6264      OnExecute = AGameLoadExecute
    6365      ShortCut = 16463
     
    6567    object AAbout: TAction
    6668      Caption = 'About'
     69      ImageIndex = 2
    6770      OnExecute = AAboutExecute
    6871    end
     
    7275    top = 224
    7376    Bitmap = {
    74       4C690A00000010000000100000000000000000000000E3AA4BD6E5B35EFFE3B1
     77      4C690C00000010000000100000000000000000000000E3AA4BD6E5B35EFFE3B1
    7578      61F2DEA85AF3D9A156F3D49B50F3CF904AF3CA8C47F3C58743F3C0813CF3BF80
    7679      38F8A75E20FB00000000000000000000000000000000E6AF53E7F6D084FFF8D8
     
    392395      88FF327FBBFF3791D5FF215286FF000000000000000000000000000000000000
    393396      0000000000000000000000000000000000000000000000000000000000000000
    394       0000215286FF235A90FF00000000
     397      0000215286FF235A90FF00000000000000000000000000000000000000000000
     398      0000000000000000000000000000000000000000000000000000000000000000
     399      0000000000000000000000000000000000000000000000000000000000000000
     400      000000000000000000000000000000000000000000FF000000FF000000FF0000
     401      0000000000000000000000000000000000000000000000000000000000000000
     402      0000000000000000000000000000000000FF0000000000000000000000000000
     403      00FF00000000000000FF00000000000000000000000000000000000000000000
     404      0000000000000000000000000000000000000000000000000000000000000000
     405      0000000000FF000000FF0000000000000000000000FF000000FF000000FF0000
     406      0000000000000000000000000000000000000000000000000000000000000000
     407      00FF000000FF000000FF00000000000000FF00FFFFFFFFFFFFFF00FFFFFF0000
     408      00FF000000FF000000FF000000FF000000FF000000FF000000FF000000000000
     409      0000000000000000000000000000000000FFFFFFFFFF00FFFFFFFFFFFFFF00FF
     410      FFFFFFFFFFFF00FFFFFFFFFFFFFF00FFFFFFFFFFFFFF000000FF000000000000
     411      0000000000000000000000000000000000FF00FFFFFFFFFFFFFF00FFFFFFFFFF
     412      FFFF00FFFFFFFFFFFFFF00FFFFFFFFFFFFFF00FFFFFF000000FF000000000000
     413      0000000000000000000000000000000000FFFFFFFFFF00FFFFFFFFFFFFFF00FF
     414      FFFF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000
     415      00FF000000FF000000FF000000FF000000FF00FFFFFFFFFFFFFF00FFFFFF0000
     416      00FF008484FF008484FF008484FF008484FF008484FF008484FF008484FF0084
     417      84FF008484FF000000FF00000000000000FFFFFFFFFF00FFFFFF000000FF0084
     418      84FF008484FF008484FF008484FF008484FF008484FF008484FF008484FF0084
     419      84FF000000FF0000000000000000000000FF00FFFFFF000000FF008484FF0084
     420      84FF008484FF008484FF008484FF008484FF008484FF008484FF008484FF0000
     421      00FF000000000000000000000000000000FF000000FF008484FF008484FF0084
     422      84FF008484FF008484FF008484FF008484FF008484FF008484FF000000FF0000
     423      0000000000000000000000000000000000FF000000FF000000FF000000FF0000
     424      00FF000000FF000000FF000000FF000000FF000000FF000000FF000000000000
     425      0000000000000000000000000000000000000000000000000000000000000000
     426      0000000000000000000000000000000000000000000000000000000000000000
     427      0000000000000000000000000000000000000000000000000000000000000000
     428      0000000000000000000000000000000000000000000000000000000000000000
     429      0000000000000000000000000000000000000000000000000000000000000000
     430      0000000000000000000000000000000000000000000000000000000000000000
     431      000000000000000000000000000000000000000000FF000000FF000000FF0000
     432      00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000
     433      00FF000000FF000000FF0000000000000000000000FF008484FF000000FFFFFF
     434      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000
     435      00FFFFFFFFFF000000FF0000000000000000000000FF008484FF000000FFFFFF
     436      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000
     437      00FF000000FF000000FF0000000000000000000000FF008484FF000000FFFFFF
     438      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000
     439      00FF008484FF000000FF0000000000000000000000FF008484FF000000FFFFFF
     440      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000
     441      00FF008484FF000000FF0000000000000000000000FF008484FF000000FFFFFF
     442      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000
     443      00FF008484FF000000FF0000000000000000000000FF008484FF000000FFFFFF
     444      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000
     445      00FF008484FF000000FF0000000000000000000000FF008484FF008484FF0000
     446      00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0084
     447      84FF008484FF000000FF0000000000000000000000FF008484FF008484FF0084
     448      84FF008484FF008484FF008484FF008484FF008484FF008484FF008484FF0084
     449      84FF008484FF000000FF0000000000000000000000FF008484FF008484FF0000
     450      00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000
     451      00FF008484FF000000FF0000000000000000000000FF008484FF008484FF0000
     452      00FF000000FF000000FF000000FF000000FF000000FFFFFFFFFFFFFFFFFF0000
     453      00FF008484FF000000FF0000000000000000000000FF008484FF008484FF0000
     454      00FF000000FF000000FF000000FF000000FF000000FFFFFFFFFFFFFFFFFF0000
     455      00FF008484FF000000FF0000000000000000000000FF008484FF008484FF0000
     456      00FF000000FF000000FF000000FF000000FF000000FFFFFFFFFFFFFFFFFF0000
     457      00FF008484FF000000FF000000000000000000000000000000FF000000FF0000
     458      00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000
     459      00FF000000FF000000FF00000000000000000000000000000000000000000000
     460      0000000000000000000000000000000000000000000000000000000000000000
     461      0000000000000000000000000000
    395462    }
    396463  end
     
    407474    top = 152
    408475    Bitmap = {
    409       4C690A0000002000000020000000000000000000000000000000E2AA4B36E2A9
     476      4C690C0000002000000020000000000000000000000000000000E2AA4B36E2A9
    410477      4AA1E4AD50E0E4B059F5E4B25FFCE3B160F5E1AE5FF2DFAA5CF3DDA559F3DAA2
    411478      57F3D89F55F3D59C51F3D2984EF3CF924BF3CD8E49F3CA8C48F3C88A46F3C688
     
    16871754      0000000000000000000000000000000000000000000000000000000000000000
    16881755      0000000000000000000000000000000000001F538740215286BF225489FF2358
    1689       8EFF225A90BF235B8F4000000000
     1756      8EFF225A90BF235B8F4000000000000000000000000000000000000000000000
     1757      0000000000000000000000000000000000000000000000000000000000000000
     1758      0000000000000000000000000000000000000000000000000000000000000000
     1759      0000000000000000000000000000000000000000000000000000000000000000
     1760      0000000000000000000000000000000000000000000000000000000000000000
     1761      0000000000000000000000000000000000000000000000000000000000000000
     1762      000000000000000000000000000000000000000000140000005E0000007A0000
     1763      007A0000007A0000007A000000700000002A0000000000000000000000000000
     1764      0000000000000000000000000000000000000000000000000000000000000000
     1765      0000000000000000000000000000000000000000000000000000000000000000
     1766      00000000000000000000000000000000000000000029000000C1000000FB0000
     1767      00FB000000FB000000FB000000E6000000570000000000000000000000000000
     1768      0000000000000000000000000000000000000000000000000000000000000000
     1769      0000000000000000000000000000000000000000000000000000000000000000
     1770      0000000000000000000000000015000000590000007400000088000000910000
     1771      009100000091000000910000008E0000007A000000680000002B000000040000
     1772      003F0000006C0000003400000000000000000000000000000000000000000000
     1773      0000000000000000000000000000000000000000000000000000000000000000
     1774      0000000000000000000000000030000000C6000000CE00000040000000090000
     1775      000900000009000000090000001C000000A4000000E800000060000000090000
     1776      008C000000F20000007600000000000000000000000000000000000000000000
     1777      0000000000000000000000000000000000000000000000000000000000000000
     1778      000000000000000000000000001F0000007E0000008200000024000000000000
     1779      000000000000000000000000000D00000067000000990000007A000000690000
     1780      00BC000000FB0000007A00000000000000000000000000000000000000000000
     1781      0000000000000000000000000000000000000000000000000000000000000000
     1782      00000000000000000000000000030000000C0000000D00000003000000000000
     1783      00000000000000000000000000010000000A0000001C00000099000000F10000
     1784      00F9000000FB0000007A00000000000000000000002A00000057000000580000
     1785      005800000058000000580000003A000000070000000000000000000000000000
     1786      0000000000000000000000000000000000000000000000000000000000000000
     1787      00000000000000000000000000070000003A00000062000000BE000000FF0000
     1788      00FF000000FB0000007A000000000000000000000070000000E6000000EA0000
     1789      00EA000000EA000000EA00000099000000130000000000000000000000000000
     1790      0000000000000000000000000000000000000000000000000000000000000000
     1791      000000000000000000000000001300000099000000EB000000F7000000FF0000
     1792      00FF000000FB0000007A000000000000004E003A3AA2004E4EFC224E4EFF4B4E
     1793      4EFF304E4EFF054E4EFF004343C20010105D0000004E0000004E0000004E0000
     1794      004E0000004E0000004E0000004E0000004E0000004E0000004E0000004E0000
     1795      004E00000046000000180000000F00000075000000B1000000B1000000B10000
     1796      00B1000000AE0000005500000000000000E4007373F100E0E0FF62E4E4FFDCE4
     1797      E4FF8BE4E4FF0DE4E4FF009B9BF6001515E6000000E4000000E4000000E40000
     1798      00E4000000E4000000E4000000E4000000E4000000E4000000E4000000E40000
     1799      00E4000000CC0000004600000002000000120000001B0000001B0000001B0000
     1800      001B0000001B0000000D00000000000000FF207A7AFF43FBFBFF78FFFFFFB6FF
     1801      FFFF8CFFFFFF4BFFFFFF2DBEBEFF065353FF154444FF3D4444FF324444FF0944
     1802      44FF104444FF394444FF374444FF0D4444FF0B4444FF344444FF3B3B3BFF1212
     1803      12FF000000E40000004E00000000000000000000000000000000000000000000
     1804      0000000000000000000000000000000000FF6A7A7AFFDAFBFBFF8DFFFFFF29FF
     1805      FFFF6BFFFFFFD2FFFFFF91F3F3FF12E0E0FF44DDDDFFC6DDDDFFA2DDDDFF1DDD
     1806      DDFF33DDDDFFB9DDDDFFB2DDDDFF2BDDDDFF24DDDDFFAADDDDFFC0C0C0FF3B3B
     1807      3BFF000000E40000004E00000000000000000000000000000000000000000000
     1808      0000000000000000000000000000000000FF5E7A7AFFC1FBFBFF88FFFFFF40FF
     1809      FFFF70FFFFFFBBFFFFFF94FFFFFF46FFFFFF65FFFFFFB5FFFFFFA0FFFFFF4DFF
     1810      FFFF5AFFFFFFAEFFFFFFAAFFFFFF55FFFFFF51FFFFFFA5FFFFFFAADDDDFF3444
     1811      44FF000000E40000004E00000000000000000000000000000000000000000000
     1812      0000000000000000000000000000000000FF147A7AFF29FBFBFF74FFFFFFCEFF
     1813      FFFF92FFFFFF35FFFFFF66FFFFFFC6FFFFFFA1FFFFFF3DFFFFFF58FFFFFFBFFF
     1814      FFFFAEFFFFFF46FFFFFF4CFFFFFFB3FFFFFFB9FFFFFF51FFFFFF24DDDDFF0B44
     1815      44FF000000E40000004E00000000000000000000000000000000000000000000
     1816      0000000000000000000000000000000000FF187A7AFF31FBFBFF76FFFFFFC8FF
     1817      FFFF90FFFFFF3BFFFFFF68FFFFFFC0FFFFFF8EF0F0FF16D2D2FF37CDCDFFB2CD
     1818      CDFF9ECDCDFF22CDCDFF28CDCDFFA5CDCDFFABCDCDFF2FCDCDFF00B2B2FF0037
     1819      37FF000000E90000007100000032000000320000003200000032000000320000
     1820      0032000000320000003200000032000000FF627A7AFFCAFBFBFF89FFFFFF37FF
     1821      FFFF6FFFFFFFC4FFFFFF97FFFFFF3FFFFFFF23C0C0FF054848FF0D3232FF2B32
     1822      32FF263232FF083232FF0A3232FF283232FF2A3232FF0C3232FF002B2BFF000D
     1823      0DFF000000FA000000DC000000CD000000CD000000CD000000CD000000CD0000
     1824      00CD000000CD000000CD000000CD000000FF667A7AFFD2FBFBFF8BFFFFFF31FF
     1825      FFFF6DFFFFFFCAFFFFFF8BF1F1FF12D8D8FF009B9BFF002B2BFF001616FF0016
     1826      16FF001616FF001616FF001616FF001616FF001616FF001616FF001616FF0016
     1827      16FF001616FF001616FF001616FF001616FF001616FF001616FF001515FF0009
     1828      09FF000000FE000000E9000000D5000000FF1C7A7AFF3AFBFBFF77FFFFFFBFFF
     1829      FFFF8FFFFFFF44FFFFFF27BBBBFF054B4BFF004848FF006161FF006666FF0066
     1830      66FF006666FF006666FF006666FF006666FF006666FF006666FF006666FF0066
     1831      66FF006666FF006666FF006666FF006666FF006666FF006666FF006262FF002C
     1832      2CFF000000FC000000980000003B000000FF107A7AFF21FBFBFF72FFFFFFD6FF
     1833      FFFF87F2F2FF0DDFDFFF009898FF002222FF003535FF007878FF008484FF0084
     1834      84FF008484FF008484FF008484FF008484FF008484FF008484FF008484FF0084
     1835      84FF008484FF008484FF008484FF008484FF008383FF007979FF006F6FFE0035
     1836      35EC000000DA0000006A00000000000000FF5A7A7AFFB8FBFBFF87FFFFFF49FF
     1837      FFFF2AB6B6FF044F4FFF004E4EFF005F5FFF006C6CFF008080FF008484FF0084
     1838      84FF008484FF008484FF008484FF008484FF008484FF008484FF008484FF0084
     1839      84FF008484FF008484FF008484FF008484FF007E7EFF004949FF002323F8001A
     1840      1A94000000430000002000000000000000FF6D7A7AFFE0FBFBFF82F3F3FF08E5
     1841      E5FF009191FF001A1AFF003737FF007A7AFF008484FF008484FF008484FF0084
     1842      84FF008484FF008484FF008484FF008484FF008484FF008484FF008484FF0084
     1843      84FF008484FF008484FF008383FF007B7BFF007070FD003131EE000000DC0000
     1844      0062000000000000000000000000000000FF257A7AFF4DFBFBFF2CB3B3FF0354
     1845      54FF005353FF005C5CFF006A6AFF008181FF008484FF008484FF008484FF0084
     1846      84FF008484FF008484FF008484FF008484FF008484FF008484FF008484FF0084
     1847      84FF008484FF008484FF007C7CFF004848FF002727F5001B1B920000004B0000
     1848      0022000000000000000000000000000000FF007070FF00E6E6FF008A8AFF0012
     1849      12FF003A3AFF007D7DFF008484FF008484FF008484FF008484FF008484FF0084
     1850      84FF008484FF008484FF008484FF008484FF008484FF008484FF008484FF0084
     1851      84FF008383FF007C7CFF007070FD002C2CF1000000DC0000005B000000000000
     1852      0000000000000000000000000000000000FF002A2AFF005757FF005757FF0057
     1853      57FF006868FF008181FF008484FF008484FF008484FF008484FF008484FF0084
     1854      84FF008484FF008484FF008484FF008484FF008484FF008484FF008484FF0084
     1855      84FF007B7BFF004848FF002C2CF1001B1B910000005300000022000000000000
     1856      0000000000000000000000000000000000FF000000FF000000FF003636FF0078
     1857      78FF007C7CFF007C7CFF007C7CFF007C7CFF007C7CFF007C7CFF007C7CFF007C
     1858      7CFF007C7CFF007C7CFF007C7CFF007C7CFF007C7CFF007C7CFF007C7CFF007C
     1859      7CFF007070FD002727F5000000DC000000530000000000000000000000000000
     1860      0000000000000000000000000000000000FF000000FF000000FF001616FF0032
     1861      32FF003333FF003333FF003333FF003333FF003333FF003333FF003333FF0033
     1862      33FF003333FF003333FF003333FF003333FF003333FF003333FF003333FF0033
     1863      33FF003131EE001B1B920000005B000000220000000000000000000000000000
     1864      0000000000000000000000000000000000F6000000F6000000F6000000F60000
     1865      00F6000000F6000000F6000000F6000000F6000000F6000000F6000000F60000
     1866      00F6000000F6000000F6000000F6000000F6000000F6000000F6000000F60000
     1867      00F6000000DC0000004B00000000000000000000000000000000000000000000
     1868      00000000000000000000000000000000006E0000006E0000006E0000006E0000
     1869      006E0000006E0000006E0000006E0000006E0000006E0000006E0000006E0000
     1870      006E0000006E0000006E0000006E0000006E0000006E0000006E0000006E0000
     1871      006E000000620000002200000000000000000000000000000000000000000000
     1872      0000000000000000000000000000000000000000000000000000000000000000
     1873      0000000000000000000000000000000000000000000000000000000000000000
     1874      0000000000000000000000000000000000000000000000000000000000000000
     1875      0000000000000000000000000000000000000000000000000000000000000000
     1876      0000000000000000000000000000000000000000000000000000000000000000
     1877      0000000000000000000000000000000000000000000000000000000000000000
     1878      0000000000000000000000000000000000000000000000000000000000000000
     1879      0000000000000000000000000000000000000000000000000000000000000000
     1880      0000000000000000000000000000000000000000000000000000000000000000
     1881      0000000000000000000000000000000000000000000000000000000000000000
     1882      0000000000000000000000000000000000000000000000000000000000000000
     1883      0000000000000000000000000000000000000000000000000000000000000000
     1884      0000000000000000000000000000000000000000000000000000000000000000
     1885      0000000000000000000000000000000000000000000000000000000000000000
     1886      0000000000000000000000000000000000000000000000000000000000000000
     1887      0000000000000000000000000000000000000000000000000000000000000000
     1888      0000000000000000000000000000000000000000003A000000780000007A0000
     1889      007A0000007A0000007A0000007A0000007A0000007A0000007A0000007A0000
     1890      007A0000007A0000007A0000007A0000007A0000007A0000007A0000007A0000
     1891      007A0000007A0000007A0000007A0000007A0000007A0000007A0000007A0000
     1892      007A000000780000003A000000000000000000000078000000F7000000FB0000
     1893      00FB000000FB000000FB000000FB000000FB000000FB000000FB000000FB0000
     1894      00FB000000FB000000FB000000FB000000FB000000FB000000FB000000FB0000
     1895      00FB000000FB000000FB000000FB000000FB000000FB000000FB000000FB0000
     1896      00FB000000F70000007800000000000000000000007A000000FB001818FF0037
     1897      37FF002323FF000303FF262626FF656565FF6E6E6EFF6E6E6EFF6E6E6EFF6E6E
     1898      6EFF6E6E6EFF6E6E6EFF6E6E6EFF6E6E6EFF6E6E6EFF6E6E6EFF6E6E6EFF6E6E
     1899      6EFF6E6E6EFF6E6E6EFF656565FF262626FF060606FF434343FF6A6A6AFF2F2F
     1900      2FFF000000FB0000007A00000000000000000000007A000000FB003737FF007B
     1901      7BFF004E4EFF000707FF555555FFE2E2E2FFF6F6F6FFF6F6F6FFF6F6F6FFF6F6
     1902      F6FFF6F6F6FFF6F6F6FFF6F6F6FFF6F6F6FFF6F6F6FFF6F6F6FFF6F6F6FFF6F6
     1903      F6FFF6F6F6FFF6F6F6FFE2E2E2FF555555FF0E0E0EFF969696FFEDEDEDFF6A6A
     1904      6AFF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1905      7FFF005151FF000808FF585858FFEAEAEAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1906      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1907      FFFFFFFFFFFFFFFFFFFFEAEAEAFF585858FF090909FF606060FF969696FF4343
     1908      43FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1909      7FFF005151FF000808FF585858FFEAEAEAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1910      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1911      FFFFFFFFFFFFFFFFFFFFEAEAEAFF585858FF010101FF090909FF0E0E0EFF0606
     1912      06FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1913      7FFF005151FF000808FF585858FFEAEAEAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1914      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1915      FFFFFFFFFFFFFFFFFFFFEAEAEAFF585858FF000303FF001C1CFF002C2CFF0014
     1916      14FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1917      7FFF005151FF000808FF585858FFEAEAEAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1918      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1919      FFFFFFFFFFFFFFFFFFFFEAEAEAFF585858FF000707FF004A4AFF007575FF0034
     1920      34FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1921      7FFF005151FF000808FF585858FFEAEAEAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1922      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1923      FFFFFFFFFFFFFFFFFFFFEAEAEAFF585858FF000808FF005151FF007F7FFF0039
     1924      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1925      7FFF005151FF000808FF585858FFEAEAEAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1926      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1927      FFFFFFFFFFFFFFFFFFFFEAEAEAFF585858FF000808FF005151FF007F7FFF0039
     1928      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1929      7FFF005151FF000808FF585858FFEAEAEAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1930      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1931      FFFFFFFFFFFFFFFFFFFFEAEAEAFF585858FF000808FF005151FF007F7FFF0039
     1932      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1933      7FFF005151FF000808FF585858FFEAEAEAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1934      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1935      FFFFFFFFFFFFFFFFFFFFEAEAEAFF585858FF000808FF005151FF007F7FFF0039
     1936      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1937      7FFF005151FF000808FF585858FFEAEAEAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1938      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1939      FFFFFFFFFFFFFFFFFFFFEAEAEAFF585858FF000808FF005151FF007F7FFF0039
     1940      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1941      7FFF005151FF000808FF585858FFEAEAEAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1942      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     1943      FFFFFFFFFFFFFFFFFFFFEAEAEAFF585858FF000808FF005151FF007F7FFF0039
     1944      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1945      7FFF005B5BFF002020FF475858FFBCBEBEFFCDCDCDFFCDCDCDFFCDCDCDFFCDCD
     1946      CDFFCDCDCDFFCDCDCDFFCDCDCDFFCDCDCDFFCDCDCDFFCDCDCDFFCDCDCDFFCDCD
     1947      CDFFCDCDCDFFCDCDCDFFBCBEBEFF475858FF002020FF005B5BFF007F7FFF0039
     1948      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1949      7FFF007A7AFF006C6CFF115757FF2E3737FF323232FF323232FF323232FF3232
     1950      32FF323232FF323232FF323232FF323232FF323232FF323232FF323232FF3232
     1951      32FF323232FF323232FF2E3737FF115757FF006C6CFF007A7AFF007F7FFF0039
     1952      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1953      7FFF008484FF008484FF005E5EFF001F1FFF001616FF001616FF001616FF0016
     1954      16FF001616FF001616FF001616FF001616FF001616FF001616FF001616FF0016
     1955      16FF001616FF001616FF001F1FFF005E5EFF008484FF008484FF007F7FFF0039
     1956      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1957      7FFF008484FF008484FF007A7AFF006868FF006666FF006666FF006666FF0066
     1958      66FF006666FF006666FF006666FF006666FF006666FF006666FF006666FF0066
     1959      66FF006666FF006666FF006868FF007A7AFF008484FF008484FF007F7FFF0039
     1960      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1961      7FFF008484FF008484FF007E7EFF007474FF007272FF007272FF007272FF0072
     1962      72FF007272FF007272FF007272FF007272FF007272FF007272FF007272FF0072
     1963      72FF007272FF007272FF007272FF007272FF007474FF007D7DFF007F7FFF0039
     1964      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1965      7FFF008484FF008484FF006262FF002B2BFF002323FF002323FF002323FF0023
     1966      23FF002323FF002323FF002323FF002323FF002323FF002323FF002323FF0023
     1967      23FF002323FF002323FF002323FF002323FF002929FF005E5EFF007F7FFF0039
     1968      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1969      7FFF008484FF008484FF005757FF000B0BFF000000FF000000FF000000FF0000
     1970      00FF000000FF000000FF000000FF000000FF000000FF000000FF040404FF1414
     1971      14FF1B1B1BFF1B1B1BFF191919FF090909FF000808FF005151FF007F7FFF0039
     1972      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1973      7FFF008484FF008484FF005757FF000B0BFF000000FF000000FF000000FF0000
     1974      00FF000000FF000000FF000000FF000000FF000000FF000000FF181818FF8282
     1975      82FFB1B1B1FFB1B1B1FFA2A2A2FF3D3D3DFF000808FF005151FF007F7FFF0039
     1976      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1977      7FFF008484FF008484FF005757FF000B0BFF000000FF000000FF000000FF0000
     1978      00FF000000FF000000FF000000FF000000FF000000FF000000FF222222FFBBBB
     1979      BBFFFFFFFFFFFFFFFFFFEAEAEAFF585858FF000808FF005151FF007F7FFF0039
     1980      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1981      7FFF008484FF008484FF005757FF000B0BFF000000FF000000FF000000FF0000
     1982      00FF000000FF000000FF000000FF000000FF000000FF000000FF222222FFBBBB
     1983      BBFFFFFFFFFFFFFFFFFFEAEAEAFF585858FF000808FF005151FF007F7FFF0039
     1984      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1985      7FFF008484FF008484FF005757FF000B0BFF000000FF000000FF000000FF0000
     1986      00FF000000FF000000FF000000FF000000FF000000FF000000FF222222FFBBBB
     1987      BBFFFFFFFFFFFFFFFFFFEAEAEAFF585858FF000808FF005151FF007F7FFF0039
     1988      39FF000000FB0000007A00000000000000000000007A000000FB003939FF007F
     1989      7FFF008484FF008484FF005757FF000B0BFF000000FF000000FF000000FF0000
     1990      00FF000000FF000000FF000000FF000000FF000000FF000000FF222222FFBBBB
     1991      BBFFFFFFFFFFFFFFFFFFEAEAEAFF585858FF000808FF005151FF007F7FFF0039
     1992      39FF000000FB0000007A000000000000000000000076000000F2003838FA007B
     1993      7BFF007F7FFF007F7FFF005454FF000A0AFF000000FF000000FF000000FF0000
     1994      00FF000000FF000000FF000000FF000000FF000000FF000000FF212121FFB4B4
     1995      B4FFF6F6F6FFF6F6F6FFE2E2E2FF555555FF000707FF004E4EFF007B7BFF0037
     1996      37FF000000FB0000007A0000000000000000000000340000006C002424AC0038
     1997      38FA003939FF003939FF002525FF000505FF000000FF000000FF000000FF0000
     1998      00FF000000FF000000FF000000FF000000FF000000FF000000FF0F0F0FFF5151
     1999      51FF6E6E6EFF6E6E6EFF656565FF262626FF000303FF002323FF003737FF0018
     2000      18FF000000FB0000007A000000000000000000000000000000000000006C0000
     2001      00F2000000FB000000FB000000FB000000FB000000FB000000FB000000FB0000
     2002      00FB000000FB000000FB000000FB000000FB000000FB000000FB000000FB0000
     2003      00FB000000FB000000FB000000FB000000FB000000FB000000FB000000FB0000
     2004      00FB000000F70000007800000000000000000000000000000000000000340000
     2005      00760000007A0000007A0000007A0000007A0000007A0000007A0000007A0000
     2006      007A0000007A0000007A0000007A0000007A0000007A0000007A0000007A0000
     2007      007A0000007A0000007A0000007A0000007A0000007A0000007A0000007A0000
     2008      007A000000780000003A00000000000000000000000000000000000000000000
     2009      0000000000000000000000000000000000000000000000000000000000000000
     2010      0000000000000000000000000000000000000000000000000000000000000000
     2011      0000000000000000000000000000000000000000000000000000000000000000
     2012      0000000000000000000000000000
    16902013    }
    16912014  end
  • trunk/UCore.pas

    r63 r64  
    149149procedure TCore.AGameLoadExecute(Sender: TObject);
    150150begin
    151   OpenDialog1.FileName := LastMapFileName;
     151  if Game.FileName = '' then
     152    OpenDialog1.FileName := LastMapFileName
     153    else OpenDialog1.FileName := Game.FileName;
    152154  if OpenDialog1.Execute then begin
    153     Game.Map.LoadFromFile(OpenDialog1.FileName);
     155    Game.LoadFromFile(OpenDialog1.FileName);
    154156    LastMapFileName := OpenDialog1.FileName;
    155157    FormMain.Redraw;
     
    180182procedure TCore.AGameSaveExecute(Sender: TObject);
    181183begin
    182   SaveDialog1.FileName := ExtractFileDir(LastMapFileName);
     184  if Game.FileName = '' then
     185    SaveDialog1.FileName := ExtractFileDir(LastMapFileName)
     186    else SaveDialog1.FileName := Game.FileName;
    183187  if SaveDialog1.Execute then begin
    184     Game.Map.SaveToFile(SaveDialog1.FileName);
     188    Game.SaveToFile(SaveDialog1.FileName);
    185189    LastMapFileName := SaveDialog1.FileName;
    186190  end;
  • trunk/UGame.pas

    r62 r64  
    77uses
    88  Classes, SysUtils, ExtCtrls, Graphics, Contnrs, XMLConf, XMLRead, XMLWrite,
    9   DOM, Math;
     9  DOM, Math, FileUtil, UXMLUtils;
    1010
    1111const
     
    2323  TPlayer = class;
    2424  TView = class;
     25  TUnitMoves = class;
    2526
    2627  TFloatPoint = record
     
    3940    procedure SetPower(AValue: Integer);
    4041  public
     42    Id: Integer;
    4143    PosPx: TPoint;
    4244    Polygon: TPointArray;
    4345    Terrain: TTerrainType;
    4446    Player: TPlayer;
    45     MovesFrom: TObjectList; // TList<TMove>
    46     MovesTo: TObjectList; // TList<TMove>
     47    MovesFrom: TUnitMoves;
     48    MovesTo: TUnitMoves;
    4749    Neighbors: TObjectList; // TList<TCell>
    4850    procedure Assign(Source: TCell);
     
    106108    procedure LoadFromFile(FileName: string); virtual;
    107109    procedure SaveToFile(FileName: string); virtual;
     110    procedure LoadFromNode(Node: TDOMNode);
     111    procedure SaveToNode(Node: TDOMNode);
    108112    function PosToCell(Pos: TPoint; View: TView): TCell; virtual;
    109113    function CellToPos(Cell: TCell): TPoint; virtual;
     
    173177    procedure SetGame(AValue: TGame);
    174178  public
     179    Id: Integer;
    175180    Name: string;
    176181    Color: TColor;
     
    181186    TotalCities: Integer;
    182187    StartUnits: Integer;
     188    procedure LoadFromNode(Node: TDOMNode);
     189    procedure SaveToNode(Node: TDOMNode);
    183190    procedure ComputerTurn;
    184191    procedure Paint(PaintBox: TPaintBox);
     
    191198  TPlayerArray = array of TPlayer;
    192199
     200  { TPlayers }
     201
    193202  TPlayers = class(TObjectList)
    194 
     203    procedure LoadFromNode(Node: TDOMNode);
     204    procedure SaveToNode(Node: TDOMNode);
    195205  end;
    196206
     
    207217    CountOnce: Integer;
    208218    CountRepeat: Integer;
     219    procedure LoadFromNode(Node: TDOMNode);
     220    procedure SaveToNode(Node: TDOMNode);
    209221    constructor Create;
    210222    destructor Destroy; override;
    211223    property CellFrom: TCell read FCellFrom write SetCellFrom;
    212224    property CellTo: TCell read FCellTo write SetCellTo;
     225  end;
     226
     227  { TUnitMoves }
     228
     229  TUnitMoves = class(TObjectList)
     230    procedure LoadFromNode(Node: TDOMNode);
     231    procedure SaveToNode(Node: TDOMNode);
    213232  end;
    214233
     
    248267    CityPercentage: Integer;
    249268    CurrentPlayer: TPlayer;
    250     Moves: TObjectList; // TList<TUnitMove>
     269    Moves: TUnitMoves;
    251270    TurnCounter: Integer;
    252271    WinObjective: TWinObjective;
     
    254273    StayAliveForDefinedTurns: Integer;
    255274    MaxNeutralUnits: Integer;
     275    FileName: string;
    256276    function AttackProbability(AttackCount, DefendCount, Depth: Integer): Double;
    257277    procedure SaveConfig(Config: TXmlConfig; Path: string);
    258278    procedure LoadConfig(Config: TXmlConfig; Path: string);
     279    procedure LoadFromFile(FileName: string);
     280    procedure SaveToFile(FileName: string);
    259281    procedure ComputePlayerStats;
    260282    function GetAlivePlayers: TPlayerArray;
     
    292314  SComputer = 'Computer';
    293315  SCannotSetPlayerStartCells = 'Cannot choose start cell for player';
     316  SWrongFileFormat = 'Wrong file format';
    294317  SUnfinishedBattle = 'Unfinished battle';
     318  SNewGameFile = 'New game.xtg';
    295319
    296320procedure InitStrings;
     
    354378    if Y < Result.Top then
    355379      Result.Top := Y;
     380  end;
     381end;
     382
     383{ TPlayers }
     384
     385procedure TPlayers.LoadFromNode(Node: TDOMNode);
     386begin
     387
     388end;
     389
     390procedure TPlayers.SaveToNode(Node: TDOMNode);
     391var
     392  I: Integer;
     393  NewNode: TDOMNode;
     394begin
     395  for I := 0 to Count - 1 do begin;
     396    NewNode := Node.OwnerDocument.CreateElement('Player');
     397    Node.AppendChild(NewNode);
     398    TPlayer(Items[I]).SaveToNode(NewNode);
     399  end;
     400end;
     401
     402{ TUnitMoves }
     403
     404procedure TUnitMoves.LoadFromNode(Node: TDOMNode);
     405begin
     406
     407end;
     408
     409procedure TUnitMoves.SaveToNode(Node: TDOMNode);
     410var
     411  I: Integer;
     412  NewNode: TDOMNode;
     413begin
     414  for I := 0 to Count - 1 do begin;
     415    NewNode := Node.OwnerDocument.CreateElement('UnitMove');
     416    Node.AppendChild(NewNode);
     417    TUnitMove(Items[I]).SaveToNode(NewNode);
    356418  end;
    357419end;
     
    595657end;
    596658
     659procedure TMap.LoadFromNode(Node: TDOMNode);
     660begin
     661  DefaultCellSize.X := ReadInteger(Node, 'DefaultCellSizeX', 1);
     662  DefaultCellSize.Y := ReadInteger(Node, 'DefaultCellSizeY', 1);
     663  MaxPower := ReadInteger(Node, 'MaxPower', 99);
     664end;
     665
     666procedure TMap.SaveToNode(Node: TDOMNode);
     667var
     668  NewNode: TDOMNode;
     669  NewNode2: TDOMNode;
     670  I: Integer;
     671begin
     672  WriteInteger(Node, 'DefaultCellSizeX', DefaultCellSize.X);
     673  WriteInteger(Node, 'DefaultCellSizeY', DefaultCellSize.Y);
     674  WriteInteger(Node, 'MaxPower', MaxPower);
     675  NewNode := Node.OwnerDocument.CreateElement('Cells');
     676  Node.AppendChild(NewNode);
     677  for I := 0 to Cells.Count - 1 do
     678  with TCell(Cells[I]) do begin
     679    NewNode2 := Node.OwnerDocument.CreateElement('Cell');
     680    NewNode.AppendChild(NewNode2);
     681    WriteInteger(NewNode2, 'Id', I);
     682    WriteInteger(NewNode2, 'Power', Power);
     683    WriteInteger(NewNode2, 'Terrain', Integer(Terrain));
     684    WriteInteger(NewNode2, 'PosX', PosPx.X);
     685    WriteInteger(NewNode2, 'PosY', PosPx.Y);
     686  end;
     687end;
     688
    597689function TMap.PosToCell(Pos: TPoint; View: TView): TCell;
    598690var
     
    792884end;
    793885
     886procedure TUnitMove.LoadFromNode(Node: TDOMNode);
     887begin
     888  CountOnce := ReadInteger(Node, 'CountOnce', 0);
     889  CountRepeat := ReadInteger(Node, 'CountRepeat', 0);
     890  //CellFrom := ReadInteger(Node, 'CellFrom', 0);
     891  //CellTo := ReadInteger(Node, 'CellTo', 0);
     892end;
     893
     894procedure TUnitMove.SaveToNode(Node: TDOMNode);
     895begin
     896  WriteInteger(Node, 'CountOnce', CountOnce);
     897  WriteInteger(Node, 'CountRepeat', CountRepeat);
     898  WriteInteger(Node, 'CellFrom', CellFrom.Id);
     899  WriteInteger(Node, 'CellTo', CellTo.Id);
     900end;
     901
    794902constructor TUnitMove.Create;
    795903begin
     
    9171025  Neighbors := TObjectList.Create;
    9181026  Neighbors.OwnsObjects := False;
    919   MovesFrom := TObjectList.Create;
     1027  MovesFrom := TUnitMoves.Create;
    9201028  MovesFrom.OwnsObjects := False;
    921   MovesTo := TObjectList.Create;
     1029  MovesTo := TUnitMoves.Create;
    9221030  MovesTo.OwnsObjects := False;
    9231031end;
     
    9771085  FGame := AValue;
    9781086  View.Game := Game;
     1087end;
     1088
     1089procedure TPlayer.LoadFromNode(Node: TDOMNode);
     1090begin
     1091  Id := ReadInteger(Node, 'Id', 0);
     1092  Name := ReadString(Node, 'Name', '');
     1093  Color := ReadInteger(Node, 'Color', clSilver);
     1094  Mode := TPlayerMode(ReadInteger(Node, 'Mode', Integer(pmHuman)));
     1095end;
     1096
     1097procedure TPlayer.SaveToNode(Node: TDOMNode);
     1098begin
     1099  WriteInteger(Node, 'Id', Id);
     1100  WriteString(Node, 'Name', Name);
     1101  WriteInteger(Node, 'Color', Color);
     1102  WriteInteger(Node, 'Mode', Integer(Mode));
    9791103end;
    9801104
     
    13491473begin
    13501474  I := 0;
    1351   while (I < Moves.Count) and ((TUnitMove(Moves[I]).CellTo <> Move.CellFrom) and
     1475  while (I < Moves.Count) and ((TUnitMove(Moves[I]).CellTo <> Move.CellFrom) or
    13521476    (TUnitMove(Moves[I]).CellFrom <> Move.CellTo)) do Inc(I);
    13531477  if I < Moves.Count then CounterMove := TUnitMove(Moves[I])
     
    13901514    GrowCells := TGrowCells(GetValue(Path + '/GrowCells', Integer(gcPlayerAll)));
    13911515    WinObjective := TWinObjective(GetValue(Path + '/WinObjective', Integer(woDefeatAllOponents)));
     1516  end;
     1517end;
     1518
     1519procedure TGame.LoadFromFile(FileName: string);
     1520var
     1521  NewNode: TDOMNode;
     1522  Value: Integer;
     1523  Doc: TXMLDocument;
     1524  Dump: TStringList;
     1525  RootNode: TDOMNode;
     1526begin
     1527  Self.FileName := FileName;
     1528  ReadXMLFile(Doc, UTF8Decode(FileName));
     1529  with Doc do try
     1530    if Doc.DocumentElement.NodeName <> 'XtacticsGame' then
     1531      raise Exception.Create(SWrongFileFormat);
     1532    RootNode := Doc.DocumentElement;
     1533    with RootNode do begin
     1534      VoidEnabled := ReadBoolean(RootNode, 'VoidEnabled', False);
     1535      VoidPercentage := ReadInteger(RootNode, 'VoidPercentage', 0);
     1536      MaxNeutralUnits := ReadInteger(RootNode, 'MaxNeutralUnits', 3);
     1537      GrowCells := TGrowCells(ReadInteger(RootNode, 'GrowCells', Integer(gcNone)));
     1538      GrowAmount := TGrowAmount(ReadInteger(RootNode, 'GrowAmount', Integer(gaByOne)));
     1539      CityEnabled := ReadBoolean(RootNode, 'CityEnabled', False);
     1540      CityPercentage := ReadInteger(RootNode, 'CityPercentage', 0);
     1541      TurnCounter := ReadInteger(RootNode, 'TurnCounter', 0);
     1542      WinObjective := TWinObjective(ReadInteger(RootNode, 'WinObjective', Integer(woDefeatAllOponents)));
     1543      ReadInteger(RootNode, 'StayAliveForDefinedTurns', StayAliveForDefinedTurns);
     1544
     1545      NewNode := FindNode('Map');
     1546      if Assigned(NewNode) then
     1547        Map.LoadFromNode(NewNode);
     1548
     1549      NewNode := FindNode('Players');
     1550      if Assigned(NewNode) then
     1551        Players.LoadFromNode(NewNode);
     1552
     1553      NewNode := FindNode('UnitMoves');
     1554      if Assigned(NewNode) then
     1555        Moves.LoadFromNode(NewNode);
     1556    end;
     1557  finally
     1558    Doc.Free;
     1559  end;
     1560end;
     1561
     1562procedure TGame.SaveToFile(FileName: string);
     1563var
     1564  NewNode: TDOMNode;
     1565  NewNode2: TDOMNode;
     1566  Doc: TXMLDocument;
     1567  RootNode: TDOMNode;
     1568  I: Integer;
     1569begin
     1570  Self.FileName := FileName;
     1571  Doc := TXMLDocument.Create;
     1572  with Doc do try
     1573    RootNode := CreateElement('XtacticsGame');
     1574    AppendChild(RootNode);
     1575    with RootNode do begin
     1576      WriteBoolean(RootNode, 'VoidEnabled', VoidEnabled);
     1577      WriteInteger(RootNode, 'VoidPercentage', VoidPercentage);
     1578      WriteInteger(RootNode, 'MaxNeutralUnits', MaxNeutralUnits);
     1579      WriteInteger(RootNode, 'GrowCells', Integer(GrowCells));
     1580      WriteInteger(RootNode, 'GrowAmount', Integer(GrowAmount));
     1581      WriteBoolean(RootNode, 'CityEnabled', CityEnabled);
     1582      WriteInteger(RootNode, 'CityPercentage', CityPercentage);
     1583      WriteInteger(RootNode, 'TurnCounter', TurnCounter);
     1584      WriteInteger(RootNode, 'WinObjective', Integer(WinObjective));
     1585      WriteInteger(RootNode, 'StayAliveForDefinedTurns', StayAliveForDefinedTurns);
     1586
     1587      NewNode := OwnerDocument.CreateElement('Map');
     1588      AppendChild(NewNode);
     1589      Map.SaveToNode(NewNode);
     1590
     1591      NewNode := OwnerDocument.CreateElement('Players');
     1592      AppendChild(NewNode);
     1593      for I := 0 to Players.Count - 1 do begin;
     1594        NewNode2 := OwnerDocument.CreateElement('Player');
     1595        NewNode.AppendChild(NewNode2);
     1596        TPlayer(Players[I]).SaveToNode(NewNode2);
     1597      end;
     1598
     1599      NewNode := OwnerDocument.CreateElement('UnitMoves');
     1600      AppendChild(NewNode);
     1601      Moves.SaveToNode(NewNode);
     1602  end;
     1603    ForceDirectoriesUTF8(ExtractFileDir(FileName));
     1604    WriteXMLFile(Doc, UTF8Decode(FileName));
     1605  finally
     1606    Doc.Free;
    13921607  end;
    13931608end;
     
    14841699  Player: TPlayer;
    14851700begin
    1486   Moves := TObjectList.Create;
     1701  Moves := TUnitMoves.Create;
    14871702  Map := TMap.Create;
    14881703  Players := TPlayers.Create;
     
    15281743  C: Integer;
    15291744begin
     1745  FileName := SNewGameFile;
    15301746  TurnCounter := 1;
    15311747  Moves.Clear;
Note: See TracChangeset for help on using the changeset viewer.