1 | unit Add;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
7 | Dialogs, StdCtrls, ExtCtrls, ExtDlgs, Buttons;
|
---|
8 |
|
---|
9 | type
|
---|
10 | TForm4 = class(TForm)
|
---|
11 | Label1: TLabel;
|
---|
12 | Edit1: TEdit;
|
---|
13 | Label2: TLabel;
|
---|
14 | Edit2: TEdit;
|
---|
15 | Label3: TLabel;
|
---|
16 | Edit3: TEdit;
|
---|
17 | Button1: TButton;
|
---|
18 | Image1: TImage;
|
---|
19 | Memo1: TMemo;
|
---|
20 | Label4: TLabel;
|
---|
21 | Button2: TButton;
|
---|
22 | OpenPictureDialog1: TOpenPictureDialog;
|
---|
23 | OpenDialog1: TOpenDialog;
|
---|
24 | Button3: TButton;
|
---|
25 | Button4: TButton;
|
---|
26 | Label5: TLabel;
|
---|
27 | SpeedButton1: TSpeedButton;
|
---|
28 | SpeedButton2: TSpeedButton;
|
---|
29 | Label6: TLabel;
|
---|
30 | Edit4: TEdit;
|
---|
31 | procedure Button1Click(Sender: TObject);
|
---|
32 | procedure Button3Click(Sender: TObject);
|
---|
33 | procedure Button4Click(Sender: TObject);
|
---|
34 | procedure Button2Click(Sender: TObject);
|
---|
35 | procedure SpeedButton1Click(Sender: TObject);
|
---|
36 | procedure SpeedButton2Click(Sender: TObject);
|
---|
37 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
38 | procedure Edit1KeyPress(Sender: TObject; var Key: Char);
|
---|
39 | procedure FormKeyDown(Sender: TObject; var Key: Word;
|
---|
40 | Shift: TShiftState);
|
---|
41 | private
|
---|
42 | { Private declarations }
|
---|
43 | public
|
---|
44 | { Public declarations }
|
---|
45 | procedure Save;
|
---|
46 | end;
|
---|
47 |
|
---|
48 | var
|
---|
49 | Form4: TForm4;
|
---|
50 | ImageFile: string;
|
---|
51 | ServerIndex: integer; // TODO
|
---|
52 |
|
---|
53 | implementation
|
---|
54 |
|
---|
55 | uses Main;
|
---|
56 |
|
---|
57 | {$R *.dfm}
|
---|
58 |
|
---|
59 | procedure TForm4.Button1Click(Sender: TObject);
|
---|
60 | begin
|
---|
61 | OpenDialog1.Filter:= 'Spustitelné soubory|*.exe|Všechny soubory|*.*';
|
---|
62 | OpenDialog1.FileName:= ExtractFileDir(Edit3.Text);
|
---|
63 | if OpenDialog1.Execute then begin
|
---|
64 | Edit3.Text:= OpenDialog1.FileName;
|
---|
65 | end;
|
---|
66 | end;
|
---|
67 |
|
---|
68 | procedure TForm4.Save;
|
---|
69 | begin
|
---|
70 | if ServerIndex <> -1 then begin
|
---|
71 | Form1.Servers[ServerIndex].Name := Edit1.Text;
|
---|
72 | Form1.Servers[ServerIndex].Address := Edit2.Text;
|
---|
73 | Form1.Servers[ServerIndex].ExeFile := Edit3.Text;
|
---|
74 | Form1.Servers[ServerIndex].Description := Memo1.Lines.Text;
|
---|
75 | Form1.Servers[ServerIndex].Image := ImageFile;
|
---|
76 | Form1.Servers[ServerIndex].OnlinePlayersAddress := Edit4.Text;
|
---|
77 | Form1.StatusBar1.SimpleText := 'Server byl upraven';
|
---|
78 | end else begin
|
---|
79 | SetLength(Form1.Servers, Length(Form1.Servers)+1);
|
---|
80 | Form1.Servers[Length(Form1.Servers)-1].Name := Edit1.Text;
|
---|
81 | Form1.Servers[Length(Form1.Servers)-1].Address := Edit2.Text;
|
---|
82 | Form1.Servers[Length(Form1.Servers)-1].ExeFile := Edit3.Text;
|
---|
83 | Form1.Servers[Length(Form1.Servers)-1].Description := Memo1.Lines.Text;
|
---|
84 | Form1.Servers[Length(Form1.Servers)-1].Image := ImageFile;
|
---|
85 | Form1.Servers[Length(Form1.Servers)-1].OnlinePlayersAddress := Edit4.Text;
|
---|
86 | Form1.StatusBar1.SimpleText := 'Server byl uložen';
|
---|
87 | end;
|
---|
88 | Form1.WriteImages;
|
---|
89 | Form1.WriteServers;
|
---|
90 | Close;
|
---|
91 | end;
|
---|
92 |
|
---|
93 | procedure TForm4.Button3Click(Sender: TObject);
|
---|
94 | begin
|
---|
95 | Save;
|
---|
96 | Form1.SaveRegServers;
|
---|
97 | end;
|
---|
98 |
|
---|
99 | procedure TForm4.Button4Click(Sender: TObject);
|
---|
100 | begin
|
---|
101 | close;
|
---|
102 | end;
|
---|
103 |
|
---|
104 | procedure TForm4.Button2Click(Sender: TObject);
|
---|
105 | begin
|
---|
106 | if OpenPictureDialog1.Execute then begin
|
---|
107 | Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
|
---|
108 | ImageFile := OpenPictureDialog1.FileName;
|
---|
109 | end;
|
---|
110 | end;
|
---|
111 |
|
---|
112 | procedure TForm4.SpeedButton1Click(Sender: TObject);
|
---|
113 | var
|
---|
114 | BitMap: TBitmap;
|
---|
115 | begin
|
---|
116 | ImageFile := '';
|
---|
117 | BitMap := TBitmap.Create;
|
---|
118 | Form1.ImageList32default.GetBitmap(0,BitMap);
|
---|
119 | Form4.Image1.Picture.Graphic := BitMap;
|
---|
120 | end;
|
---|
121 |
|
---|
122 | procedure TForm4.SpeedButton2Click(Sender: TObject);
|
---|
123 | var
|
---|
124 | BitMap: TBitmap;
|
---|
125 | begin
|
---|
126 | ImageFile := '1';
|
---|
127 | BitMap := TBitmap.Create;
|
---|
128 | Form1.ImageList32default.GetBitmap(1,BitMap);
|
---|
129 | Form4.Image1.Picture.Graphic := BitMap;
|
---|
130 | end;
|
---|
131 |
|
---|
132 | procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
133 | begin
|
---|
134 | Edit1.Text := '';
|
---|
135 | Edit2.Text := '';
|
---|
136 | Edit3.Text := '';
|
---|
137 | Edit4.Text := '';
|
---|
138 | Memo1.Clear;
|
---|
139 | ImageFile := '';
|
---|
140 | ServerIndex := -1;
|
---|
141 | end;
|
---|
142 |
|
---|
143 | procedure TForm4.Edit1KeyPress(Sender: TObject; var Key: Char);
|
---|
144 | begin
|
---|
145 | if Key = #13 then begin
|
---|
146 | Key:= #0;
|
---|
147 | Button3Click(nil);
|
---|
148 | end;
|
---|
149 | end;
|
---|
150 |
|
---|
151 | procedure TForm4.FormKeyDown(Sender: TObject; var Key: Word;
|
---|
152 | Shift: TShiftState);
|
---|
153 | begin
|
---|
154 | // Form1.Show;
|
---|
155 | end;
|
---|
156 |
|
---|
157 | end.
|
---|