Changeset 196 for trunk/UServerList.pas
- Timestamp:
- May 16, 2018, 9:56:24 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UServerList.pas
r180 r196 6 6 7 7 uses 8 Classes, SysUtils, contnrs;8 Classes, SysUtils, fgl, XMLConf; 9 9 10 10 type 11 12 { TServerInfo } 13 11 14 TServerInfo = class 12 15 Name: string; … … 18 21 MapName: string; 19 22 Latency: TTime; 23 constructor Create; 20 24 end; 21 25 22 TServerInfos = class(T ObjectList)26 TServerInfos = class(TFPGObjectList<TServerInfo>) 23 27 end; 24 28 … … 31 35 constructor Create; 32 36 destructor Destroy; override; 37 procedure LoadConfig(Config: TXmlConfig; Path: string); 38 procedure SaveConfig(Config: TXmlConfig; Path: string); 33 39 end; 34 40 41 35 42 implementation 43 44 uses 45 UGameServer; 46 47 { TServerInfo } 48 49 constructor TServerInfo.Create; 50 begin 51 Port := DefaultServerPort; 52 end; 36 53 37 54 { TServerList } … … 48 65 end; 49 66 67 procedure TServerList.LoadConfig(Config: TXmlConfig; Path: string); 68 var 69 I: Integer; 70 Server: TServerInfo; 71 begin 72 Items.Clear; 73 Items.Count := Config.GetValue(UnicodeString(Path + '/Count'), 0); 74 for I := 0 to Items.Count - 1 do begin 75 Server := TServerInfo.Create; 76 Server.Name := string(Config.GetValue(UnicodeString(Path + '/Item' + IntToStr(I) + '/Name'), '')); 77 Server.Address := string(Config.GetValue(UnicodeString(Path + '/Item' + IntToStr(I) + '/Address'), '')); 78 Server.Port := Config.GetValue(UnicodeString(Path + '/Item' + IntToStr(I) + '/Port'), 0); 79 Items[I] := Server; 80 end; 81 end; 82 83 procedure TServerList.SaveConfig(Config: TXmlConfig; Path: string); 84 var 85 I: Integer; 86 Server: TServerInfo; 87 begin 88 Config.SetValue(UnicodeString(Path + '/Count'), Items.Count); 89 for I := 0 to Items.Count - 1 do begin 90 Server := Items[I]; 91 Config.SetValue(UnicodeString(Path + '/Item' + IntToStr(I) + '/Name'), UnicodeString(Server.Name)); 92 Config.SetValue(UnicodeString(Path + '/Item' + IntToStr(I) + '/Address'), UnicodeString(Server.Address)); 93 Config.SetValue(UnicodeString(Path + '/Item' + IntToStr(I) + '/Port'), Server.Port); 94 end; 95 end; 96 50 97 end. 51 98
Note:
See TracChangeset
for help on using the changeset viewer.