source: trunk/Options.pas

Last change on this file was 13, checked in by george, 15 years ago
  • Opraveno: Všechny odkazy na starý web wow.zdechov.net opraveny na aktuální www.heroesoffantasy.cz.
File size: 14.1 KB
Line 
1unit Options;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, ShellApi, Registry, Spin, ExtCtrls, ComCtrls, Buttons,
8 Menus;
9
10type
11 TForm2 = class(TForm)
12 CheckBox1: TCheckBox;
13 CheckBox6: TCheckBox;
14 CheckBox7: TCheckBox;
15 CheckBox5: TCheckBox;
16 Button1: TButton;
17 Button2: TButton;
18 OpenDialog1: TOpenDialog;
19 Label1: TLabel;
20 Label2: TLabel;
21 CheckBox2: TCheckBox;
22 SpinEdit1: TSpinEdit;
23 CheckBox8: TCheckBox;
24 CheckBox9: TCheckBox;
25 CheckBox3: TCheckBox;
26 Edit1: TEdit;
27 Button3: TButton;
28 Label3: TLabel;
29 SpinEdit2: TSpinEdit;
30 Label4: TLabel;
31 CheckBox11: TCheckBox;
32 CheckBox12: TCheckBox;
33 Button4: TButton;
34 SaveDialog1: TSaveDialog;
35 PageControl1: TPageControl;
36 TabSheet1: TTabSheet;
37 TabSheet2: TTabSheet;
38 TabSheet3: TTabSheet;
39 TabSheet4: TTabSheet;
40 Edit2: TEdit;
41 Label5: TLabel;
42 GroupBox1: TGroupBox;
43 Edit3: TEdit;
44 Button5: TButton;
45 Button6: TButton;
46 ListView1: TListView;
47 CheckBox13: TCheckBox;
48 CheckBox14: TCheckBox;
49 CheckBox15: TCheckBox;
50 Edit4: TEdit;
51 Button7: TButton;
52 SpeedButton1: TSpeedButton;
53 CheckBox16: TCheckBox;
54 Edit5: TEdit;
55 PopupMenu1: TPopupMenu;
56 Smazat1: TMenuItem;
57 Smazatve1: TMenuItem;
58 Button8: TButton;
59 TabSheet5: TTabSheet;
60 CheckBox10: TCheckBox;
61 CheckBox4: TCheckBox;
62 RadioGroup1: TRadioGroup;
63 RadioButton1: TRadioButton;
64 RadioButton2: TRadioButton;
65 RadioButton3: TRadioButton;
66 CheckBox17: TCheckBox;
67 CheckBox18: TCheckBox;
68 Edit6: TEdit;
69 SpeedButton2: TSpeedButton;
70 Button9: TButton;
71 Button10: TButton;
72 procedure FormShow(Sender: TObject);
73 procedure Button1Click(Sender: TObject);
74 procedure CheckBox3Click(Sender: TObject);
75 procedure Button3Click(Sender: TObject);
76 procedure Button2Click(Sender: TObject);
77 procedure Button4Click(Sender: TObject);
78 procedure Button5Click(Sender: TObject);
79 procedure Edit3KeyPress(Sender: TObject; var Key: Char);
80 procedure Button6Click(Sender: TObject);
81 procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
82 Selected: Boolean);
83 procedure CheckBox15Click(Sender: TObject);
84 procedure Button7Click(Sender: TObject);
85 procedure SpeedButton1Click(Sender: TObject);
86 procedure CheckBox16Click(Sender: TObject);
87 procedure Smazat1Click(Sender: TObject);
88 procedure Button8Click(Sender: TObject);
89 procedure Smazatve1Click(Sender: TObject);
90 procedure Button9Click(Sender: TObject);
91 procedure SpeedButton2Click(Sender: TObject);
92 procedure CheckBox18Click(Sender: TObject);
93 procedure Button10Click(Sender: TObject);
94 private
95 { Private declarations }
96 public
97 { Public declarations }
98 procedure Save;
99 procedure StandartOptions;
100 end;
101
102var
103 Form2: TForm2;
104
105implementation
106
107uses Main, OnlinePlayers, News;
108
109{$R *.dfm}
110
111procedure TForm2.FormShow(Sender: TObject);
112var
113 Reg: TRegistry;
114 i: integer;
115begin
116 // checkbox1 spuštění po startu win
117 Reg := TRegistry.Create(KEY_READ);
118 try
119 Reg.RootKey := HKEY_CURRENT_USER;
120 if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run', True) then begin
121 CheckBox1.Checked := Reg.KeyExists('ClientHoF');
122 end;
123 finally
124 Reg.Free;
125 end;
126
127 CheckBox17.Checked := CopyFonts;
128 CheckBox6.Checked := StartMinimalize;
129 CheckBox7.Checked := Form1.CoolTrayIcon1.MinimizeToTray;
130 if AfterWoWStartClose and AfterWoWStartMinimalize then begin
131 RadioButton3.Checked := True;
132 end else begin
133 RadioButton2.Checked := AfterWoWStartClose;
134 RadioButton1.Checked := AfterWoWStartMinimalize;
135 end;
136 CheckBox5.Checked := UpdateApplication;
137 //CheckBox3.Checked := Form1.SkinData1.Active;
138 //Edit1.Text := Form1.SkinData1.SkinFile;
139 CheckBox10.Checked := ShowDetails;
140 CheckBox4.Checked := Form1.Timer4.Enabled;
141 CheckBox12.Checked := OnCloseMinimalize;
142 //aktuality
143 CheckBox8.Checked := SoundAfterNewNews;
144 CheckBox9.Checked := ShowBalloonHint;
145 CheckBox2.Checked := Form1.Timer1.Enabled;
146 SpinEdit1.Value := Form1.Timer1.Interval div 60000;
147 Edit2.Text := RSSAddress;
148 Edit6.Text := SoundFileNews;
149 CheckBox18.Checked := PlaySoundNews;
150 //online hráči
151 CheckBox11.Checked := Form1.Timer2.Enabled;
152 SpinEdit2.Value := Form1.Timer2.Interval div 60000;
153 CheckBox16.Checked := LockOnlineAddres;
154 Edit5.Text := LockAddres;
155 //přátelé
156 CheckBox13.Checked := BeepAfterNewFriend;
157 CheckBox14.Checked := ShowBalloonHintAfterNewFriend;
158 ListView1.Clear;
159 for i:=0 to Length(Form5.Friends)-1 do begin
160 ListView1.Items.Add.caption := Form5.Friends[i];
161 end;
162 CheckBox15.Checked := FriendPlaySound;
163 Edit4.Text := FriendSoundFile;
164
165 CheckBox3Click(nil);
166 CheckBox15Click(nil);
167 CheckBox16Click(nil);
168 CheckBox18Click(nil);
169end;
170
171procedure TForm2.Button1Click(Sender: TObject);
172begin
173 Save;
174 Close;
175 Form1.SaveRegOptions;
176 Form5.SaveRegOptions;
177 Form6.SaveRegNewsOptions;
178 Form1.StatusBar1.SimpleText := 'Nastavení bylo uloženo';
179end;
180
181procedure TForm2.Save;
182var
183 Reg: TRegistry;
184 i: integer;
185begin
186 // uložení checkbox1 spustění po startu win.
187 Reg := TRegistry.Create(KEY_WRITE);
188 try
189 Reg.RootKey := HKEY_CURRENT_USER;
190 if CheckBox1.Checked = True then
191 if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run', True) then begin
192 Reg.WriteString('ClientHoF', Application.ExeName);
193 end;
194 if CheckBox1.Checked = False then
195 if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run', True) then begin
196 Reg.DeleteValue('ClientHoF');
197 end;
198 finally
199 Reg.Free;
200 end;
201 // ostatní nastavení
202
203 CopyFonts := CheckBox17.Checked;
204 StartMinimalize := CheckBox6.Checked;
205 Form1.CoolTrayIcon1.MinimizeToTray := CheckBox7.Checked;
206 AfterWoWStartClose := RadioButton2.Checked;
207 AfterWoWStartMinimalize := RadioButton1.Checked;
208 UpdateApplication := CheckBox5.Checked;
209 //Form1.SkinData1.Active := CheckBox3.Checked;
210 ShowDetails := CheckBox10.Checked;
211 Form1.Timer4.Enabled := CheckBox4.Checked;
212 OnCloseMinimalize := CheckBox12.Checked;
213
214 SoundAfterNewNews := CheckBox8.Checked;
215 ShowBalloonHint := CheckBox9.Checked;
216 //aktuality
217 Form1.Timer1.Enabled := CheckBox2.Checked;
218 Form1.Aktuality1.Checked := CheckBox2.Checked;
219 Form1.Timer1.Interval := SpinEdit1.Value*60000;
220 PlaySoundNews := CheckBox18.Checked;
221 SoundFileNews := Edit6.Text;
222 if RSSAddress <> Edit2.Text then begin
223 try
224 RSSAddress := Edit2.Text;
225 Form6.ListView1.Clear;
226 SetLength(Form6.News,0);
227 Form6.DownloadRSS;
228 Form6.WriteNews;
229 except
230 Form1.StatusBar1.SimpleText := 'Adresa RSS je neplatná!';
231 end;
232 end;
233 //online hráči
234// Form1.OnlineHri1.Checked := CheckBox11.Checked;
235 Form1.Timer2.Enabled := CheckBox11.Checked;
236 Form1.Timer2.Interval := SpinEdit2.Value*60000;
237 LockOnlineAddres := CheckBox16.Checked;
238 LockAddres := Edit5.Text;
239 if LockOnlineAddres then
240 Form5.Button2.Enabled := false
241 else
242 Form5.Button2.Enabled := True;
243 // seznam přátel
244 BeepAfterNewFriend := CheckBox13.Checked;
245 ShowBalloonHintAfterNewFriend := CheckBox14.Checked;
246 SetLength(Form5.Friends,0);
247 SetLength(Form5.Friends,ListView1.Items.Count);
248 for i:=0 to ListView1.Items.Count-1 do begin
249 Form5.Friends[i] := ListView1.Items[i].Caption;
250 end;
251 FriendPlaySound := CheckBox15.Checked;
252 FriendSoundFile := Edit4.Text;
253
254 { if CheckBox11.Checked then
255 form5.show
256 else Form5.Close; }
257 if CheckBox2.Checked then
258 form6.show
259 else form6.Close;
260 //else close
261end;
262
263procedure TForm2.CheckBox3Click(Sender: TObject);
264begin
265 if CheckBox3.Checked = False then begin
266 Edit1.Enabled := False;
267 Button3.Enabled := False;
268 //Form1.SkinData1.Active := False;
269 end else begin
270 Edit1.Enabled := True;
271 Button3.Enabled := True;
272 //Form1.SkinData1.Active := True;
273 end;
274end;
275
276procedure TForm2.Button3Click(Sender: TObject);
277begin
278 OpenDialog1.Filter:= 'Skiny (*.skn)|*.skn|Všechny soubory|*.*';
279 if Edit1.Text = '' then
280 OpenDialog1.FileName:= ExtractFileDir(Application.ExeName)
281 else
282 OpenDialog1.FileName:= Edit1.Text;
283 if OpenDialog1.Execute then begin
284 Edit1.Text:= OpenDialog1.FileName;
285 //Form1.SkinData1.SkinFile := Edit1.Text;
286 //Form1.SkinData1.Active := False;
287 //Form1.SkinData1.Active := True;
288 end;
289end;
290
291procedure TForm2.Button2Click(Sender: TObject);
292begin
293 Close;
294end;
295
296procedure TForm2.Button4Click(Sender: TObject);
297begin
298 SaveDialog1.Filter:= 'Registrové soubory|*.reg|Všechny soubory|*.*';
299 SaveDialog1.FileName:= 'Nastavení aplikace ClientHof '+DateToStr(Now)+'.reg';
300 if SaveDialog1.Execute then begin
301 ShellExecute(0, 'open', PChar('regedit.exe'), PChar('/e "'+SaveDialog1.FileName+'" "HKEY_CURRENT_USER'+R+'"'), '', SW_SHOWNORMAL);
302 Form1.StatusBar1.SimpleText := 'Nastavení bylo uloženo';
303 close;
304 end;
305end;
306
307procedure TForm2.Button5Click(Sender: TObject);
308begin
309// if Assigned(ListView1.Selected) then
310 // if Assigned(ListBox1.Items.);
311
312 if Assigned(ListView1.Selected) then
313 ListView1.Selected.Caption := Edit3.Text
314 else
315 ListView1.Items.Add.caption := Edit3.Text;
316 // ListBox1.AddItem(Edit3.Text,nil);
317end;
318
319procedure TForm2.Edit3KeyPress(Sender: TObject; var Key: Char);
320begin
321 if Key = #13 then begin
322 Key:= #0;
323 Button5Click(nil);
324 end;
325end;
326
327procedure TForm2.Button6Click(Sender: TObject);
328begin
329 if Assigned(ListView1.Selected) then begin
330 ListView1.Selected.Delete;
331 if Assigned(ListView1.Items[0]) then
332 ListView1.Items[0].Selected := True;
333 end;
334end;
335
336procedure TForm2.ListView1SelectItem(Sender: TObject; Item: TListItem;
337 Selected: Boolean);
338begin
339 if Assigned(ListView1.Selected) then
340 Edit3.Text := ListView1.Selected.Caption;
341end;
342
343procedure TForm2.CheckBox15Click(Sender: TObject);
344begin
345 if CheckBox15.Checked = False then begin
346 Edit4.Enabled := False;
347 Button7.Enabled := False;
348 SpeedButton1.Enabled := False;
349 end else begin
350 Edit4.Enabled := True;
351 Button7.Enabled := True;
352 SpeedButton1.Enabled := True;
353 end;
354end;
355
356procedure TForm2.Button7Click(Sender: TObject);
357begin
358 OpenDialog1.Filter:= 'Zvuky (*.mp3;*.wav)|*.mp3;*.wav|Všechny soubory|*.*';
359 if Edit4.Text = '' then
360 OpenDialog1.FileName:= ExtractFileDir(Application.ExeName)
361 else
362 OpenDialog1.FileName:= Edit4.Text;
363
364 if OpenDialog1.Execute then begin
365 Edit4.Text:= OpenDialog1.FileName;
366 end;
367end;
368
369procedure TForm2.SpeedButton1Click(Sender: TObject);
370begin
371 try
372 Form1.MediaPlayer1.FileName := Edit4.Text;
373 Form1.MediaPlayer1.Open;
374 Form1.MediaPlayer1.Play;
375 except
376 ShowMessage('Soubor nelze přehrát');
377 end;
378end;
379
380procedure TForm2.CheckBox16Click(Sender: TObject);
381begin
382 if CheckBox16.Checked = False then begin
383 Edit5.Enabled := False;
384 end else begin
385 Edit5.Enabled := True;
386 end;
387end;
388
389procedure TForm2.Smazat1Click(Sender: TObject);
390begin
391 Button6Click(nil);
392end;
393
394procedure TForm2.Button8Click(Sender: TObject);
395begin
396 if Form1.ReallyYes('Opravdu smazat všechny přátelé') then
397 ListView1.Clear;
398end;
399
400procedure TForm2.Smazatve1Click(Sender: TObject);
401begin
402 Button8Click(nil);
403end;
404
405procedure TForm2.Button9Click(Sender: TObject);
406begin
407 OpenDialog1.Filter:= 'Zvuky (*.mp3;*.wav)|*.mp3;*.wav|Všechny soubory|*.*';
408 if Edit6.Text = '' then
409 OpenDialog1.FileName:= ExtractFileDir(Application.ExeName)
410 else
411 OpenDialog1.FileName:= Edit6.Text;
412
413 if OpenDialog1.Execute then begin
414 Edit6.Text:= OpenDialog1.FileName;
415 end;
416end;
417
418procedure TForm2.SpeedButton2Click(Sender: TObject);
419begin
420 try
421 Form1.MediaPlayer1.FileName := Edit6.Text;
422 Form1.MediaPlayer1.Open;
423 Form1.MediaPlayer1.Play;
424 except
425 ShowMessage('Soubor nelze přehrát');
426 end;
427end;
428
429procedure TForm2.CheckBox18Click(Sender: TObject);
430begin
431 if CheckBox18.Checked = False then begin
432 Edit6.Enabled := False;
433 Button9.Enabled := False;
434 SpeedButton2.Enabled := False;
435 end else begin
436 Edit6.Enabled := True;
437 Button9.Enabled := True;
438 SpeedButton2.Enabled := True;
439 end;
440end;
441
442procedure TForm2.StandartOptions;
443var
444 Reg: TRegistry;
445begin
446 // spustění po startu win.
447 Reg := TRegistry.Create(KEY_WRITE);
448 try
449 Reg.RootKey := HKEY_CURRENT_USER;
450 if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run', True) then begin
451 Reg.WriteString('ClientHoF', Application.ExeName);
452 end;
453 finally
454 Reg.Free;
455 end;
456 CopyFonts := True;
457 StartMinimalize := False;
458 OnCloseMinimalize := True;
459 AfterWoWStartClose := False;
460 AfterWoWStartMinimalize := True;
461 UpdateApplication := True;
462 SoundAfterNewNews := True;
463 ShowBalloonHint := True;
464 ShowDetails := False;
465 RSSAddress := DefaultRSSChannel;
466 Form1.CoolTrayIcon1.MinimizeToTray := True;
467 //Form1.SkinData1.Active := False;
468 Form1.Timer4.Enabled := True;
469
470 //aktuality
471 Form1.Timer1.Enabled := True;
472 Form1.Aktuality1.Checked := True;
473 Form1.Timer1.Interval := 10 * 60000;
474 PlaySoundNews := False;
475 SoundFileNews := '';
476
477 //online hráči
478 Form1.Timer2.Enabled := True;
479 Form1.Timer2.Interval := 10 * 60000;
480 LockOnlineAddres := True;
481 LockAddres := HoFOnlineListURL;
482 if LockOnlineAddres then
483 Form5.Button2.Enabled := false
484 else
485 Form5.Button2.Enabled := True;
486 // seznam přátel
487 BeepAfterNewFriend := True;
488 ShowBalloonHintAfterNewFriend := True;
489 FriendPlaySound := False;
490 FriendSoundFile := '';
491
492 if CheckBox2.Checked then
493 form6.show
494 else form6.Close;
495
496 //nastavení panelů
497 Form1.Panel2.Left := 224;
498 Form5.Panel2.Top := 432;
499 Form6.Panel1.Top := 136;
500 //vykreslení formu
501 Form1.DrawForm;
502 Form5.DrawForm;
503 Form6.DrawForm;
504 //načtení do formuláře nastavení
505 FormShow(nil);
506end;
507
508procedure TForm2.Button10Click(Sender: TObject);
509begin
510 if Form1.ReallyYes('Obnovit výchozí nastavení?') then begin
511 StandartOptions;
512 close;
513 end;
514end;
515
516end.
Note: See TracBrowser for help on using the repository browser.