source: branches/old/projectonlineplayes/source/Delphi - load online players, info server/Main.pas

Last change on this file was 194, checked in by maron, 17 years ago

Projekt Online hráči

File size: 2.5 KB
Line 
1unit Main;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, xmldom, XMLIntf, msxmldom, XMLDoc, ComCtrls, StdCtrls, ImgList;
8
9type
10 TForm1 = class(TForm)
11 Button1: TButton;
12 ListView1: TListView;
13 XMLDocument1: TXMLDocument;
14 ImageClass: TImageList;
15 ImageRace: TImageList;
16 Label1: TLabel;
17 Label2: TLabel;
18 Label3: TLabel;
19 Label4: TLabel;
20 Edit1: TEdit;
21 procedure Button1Click(Sender: TObject);
22 private
23 { Private declarations }
24 public
25 { Public declarations }
26 procedure DownloadOnlinePlayers;
27 end;
28
29var
30 Form1: TForm1;
31
32implementation
33
34{$R *.dfm}
35
36{ TForm1 }
37
38procedure TForm1.DownloadOnlinePlayers;
39var
40 StartItemNode : IXMLNode;
41 ANode : IXMLNode;
42 sName, sLevel, sRace, sClass, sZone, sMap, sHonor: WideString;
43begin
44 ListView1.Clear;
45
46 try
47 XMLDocument1.FileName := Edit1.Text;
48 XMLDocument1.Active:=True;
49
50 try
51 Label1.Caption := 'Název Serveru: '+XMLDocument1.DocumentElement.ChildNodes.FindNode('servername').Text;
52 Label2.Caption := 'Vlastník Serveru: '+XMLDocument1.DocumentElement.ChildNodes.FindNode('owner').Text;
53 Label3.Caption := 'Maximální poèet hráèù: '+XMLDocument1.DocumentElement.ChildNodes.FindNode('maxplayers').Text;
54 Label4.Caption := XMLDocument1.DocumentElement.ChildNodes['players'].ChildNodes.FindNode('playerscount').Text;
55 except
56 end;
57
58 StartItemNode := XMLDocument1.DocumentElement.ChildNodes['players'].ChildNodes.FindNode('player');
59
60 ANode := StartItemNode;
61 repeat
62 sName := ANode.ChildNodes['name'].Text;
63 sLevel := ANode.ChildNodes['level'].Text;
64 sRace := ANode.ChildNodes['race'].Text;
65 sClass := ANode.ChildNodes['class'].Text;
66 sZone := ANode.ChildNodes['zone'].Text;
67 sMap := ANode.ChildNodes['map'].Text;
68 sHonor := ANode.ChildNodes['honor'].Text;
69
70 with ListView1.Items.Add do begin
71 Caption := sName;
72 SubItems.Add(sLevel);
73 SubItems.Add(sZone);
74 SubItems.Add(sMap);
75 SubItems.Add(sHonor);
76 ImageIndex := StrToInt(sClass)-1;
77 StateIndex := StrToInt(sRace)-1;
78 end;
79
80 ANode := ANode.NextSibling;
81 until ANode = nil;
82
83 except
84 On E : Exception do begin
85 ShowMessage('Nepodaøilo se naèíst online hráèe!');
86 end;
87 end;
88
89 XMLDocument1.Active := False;
90end;
91
92procedure TForm1.Button1Click(Sender: TObject);
93begin
94 DownloadOnlinePlayers;
95end;
96
97end.
Note: See TracBrowser for help on using the repository browser.