6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 ComCtrls, StdCtrls, ExtCtrls, ColorCBX, BottleDef, EllipsEd, Spin,
11 TfrmSetting = class(TForm)
12 PageControl: TPageControl;
14 tstGeneral: TTabSheet;
17 rgpWhenReturn: TRadioGroup;
18 rgpWhenShiftReturn: TRadioGroup;
19 rgpWhenCtrlReturn: TRadioGroup;
20 memDefaultScript: TMemo;
21 lblDefaultScript: TLabel;
22 grpLocalConfirm: TGroupBox;
23 ColorDialog: TColorDialog;
24 cbxColorScript: TCheckBox;
25 trkColorTimeLag: TTrackBar;
26 trkColorSpeed: TTrackBar;
28 colTalkColorU: TColorCBox;
29 colMetaWordColor: TColorCBox;
33 colTalkColorH: TColorCBox;
35 colMarkUpColor: TColorCBox;
37 colMarkErrorColor: TColorCBox;
38 cbxIgnoreTimeCritical: TCheckBox;
39 lblColorTimeLag: TLabel;
40 lblColorSpeed: TLabel;
41 colBgColor: TColorCBox;
43 tstReceive: TTabSheet;
46 cbxAutoStart: TCheckBox;
47 tstChannel: TTabSheet;
48 tvwChannels: TTreeView;
49 rgpUseChannelPrefs: TRadioGroup;
50 pnlChannelOpt: TPanel;
51 edtSoundFile: TEllipsesEdit;
52 cbxSoundArrived: TCheckBox;
53 rgpTargetGhost: TGroupBox;
54 cbxIgnoreIfGhost: TCheckBox;
55 cbxTargetGhost: TComboBox;
56 cbxUsePort: TCheckBox;
57 rgpTabPosition: TRadioGroup;
58 cbxCanAutoAdd: TCheckBox;
59 OpenDialog: TOpenDialog;
60 spnWaitScriptEnd: TSpinEdit;
61 lblWaitScriptEnd: TLabel;
62 cbxNoSendGhostList: TCheckBox;
65 cbxUseHttpProxy: TCheckBox;
66 edtProxyAddress: TEdit;
68 lblProxyAddress: TLabel;
71 cbxWarnPost: TCheckBox;
72 cbxConfirmOnExit: TCheckBox;
73 ctvBottle: TCPCConfigTreeView;
74 lblGhostDropDownCount: TLabel;
75 spnGhostDropDownCount: TSpinEdit;
76 procedure ColorPick(Sender: TObject; var Col: TColor);
77 procedure FormClose(Sender: TObject; var Action: TCloseAction);
78 procedure cbxPortChange(Sender: TObject);
79 procedure edtSoundFileButtonClick(Sender: TObject);
80 procedure tvwChannelsCompare(Sender: TObject; Node1, Node2: TTreeNode;
81 Data: Integer; var Compare: Integer);
82 procedure tvwChannelsChange(Sender: TObject; Node: TTreeNode);
83 procedure rgpUseChannelPrefsClick(Sender: TObject);
84 procedure cbxSoundArrivedClick(Sender: TObject);
85 procedure edtSoundFileChange(Sender: TObject);
86 procedure cbxTargetGhostChange(Sender: TObject);
87 procedure cbxIgnoreIfGhostClick(Sender: TObject);
88 procedure cbxUsePortClick(Sender: TObject);
89 procedure cbxCanAutoAddClick(Sender: TObject);
90 procedure edtProxyPortKeyPress(Sender: TObject; var Key: Char);
91 procedure cbxWarnPostClick(Sender: TObject);
92 procedure ctvBottleNodeChecked(Sender: TObject;
93 Node: TCPCConfigItemNode);
94 procedure ctvBottleNodeChecking(Sender: TObject;
95 Node: TCPCConfigItemNode; var Allow: Boolean);
98 function SelChPref: TChannelPrefs;
99 function BottleImage(ChPref: TChannelPrefs): integer;
106 frmSetting: TfrmSetting;
110 ChannelDefaultGhost = '(
\83`
\83\83\83\93\83l
\83\8b\90\84\8f§
\83S
\81[
\83X
\83g)';
112 UnCheckedBottle = 17;
120 procedure TfrmSetting.ColorPick(Sender: TObject; var Col: TColor);
122 ColorDialog.Color := Col;
123 if ColorDialog.Execute then begin
124 Col := ColorDialog.Color;
128 procedure TfrmSetting.Execute;
132 PageControl.ActivePage := tstGeneral;
133 memDefaultScript.Text := Pref.DefaultScript;
134 cbxIgnoreTimeCritical.Checked := Pref.IgnoreTimeCritical;
135 cbxNoSendGhostList.Checked := Pref.NoSendGhostList;
136 cbxConfirmOnExit.Checked := Pref.ConfirmOnExit;
138 cbxColorScript.Checked := Pref.ColorScript;
139 colTalkColorH.SelColor := Pref.TalkColorH;
140 colTalkColorU.SelColor := Pref.TalkColorU;
141 colMarkUpColor.SelColor := Pref.MarkUpColor;
142 colMetaWordColor.SelColor := Pref.MetaWordColor;
143 colMarkErrorColor.SelColor := Pref.MarkErrorColor;
144 colBgColor.SelColor := Pref.BgColor;
145 trkColorTimeLag.Position := Pref.ColorTimeLagValue;
146 trkColorSpeed.Position := Pref.ColorSpeed;
148 cbxAutoStart.Checked := Pref.AutoStart;
149 rgpTabPosition.ItemIndex := Ord(Pref.TabPosition);
150 spnGhostDropDownCount.Value := Pref.GhostDropDownCount;
152 cbxNoTranslate.Checked := Pref.NoTranslate;
153 cbxNoDescript.Checked := Pref.NoDescript;
154 cbxNoTransUrl.Checked := Pref.NoTransUrl;
155 cbxSilentWhenHidden.Checked := Pref.SilentWhenHidden;
158 with ctvBottle do begin
159 (GetNodeFromKeyPath('Arrive\NoTranslate') as TCPCCheckBoxNode).Checked := Pref.NoTranslate;
160 (GetNodeFromKeyPath('Arrive\NoDescript') as TCPCCheckBoxNode).Checked := Pref.NoDescript;
161 if Pref.NoTransUrl then
162 (GetNodeFromKeyPath('Arrive\UrlTag\NoSelection') as TCPCRadioNode).Check
164 (GetNodeFromKeyPath('Arrive\UrlTag\WithSelection') as TCPCRadioNode).Check;
165 (GetNodeFromKeyPath('Arrive\SilentWhenHidden') as TCPCCheckBoxNode).Checked := Pref.SilentWhenHidden;
166 (GetNodeFromKeyPath('Arrive\FixMessySurface') as TCPCCheckBoxNode).Checked := Pref.FixMessySurface;
167 (GetNodeFromKeyPath('Out\ResetIfGhostAfterSend') as TCPCCheckBoxNode).Checked := Pref.ResetIfGhostAfterSend;
170 on E: Exception do ShowMessage(E.Message);
172 //cbxIgnoreFrequentYenS.Checked := Pref.IgnoreFrequentYenS;
173 spnWaitScriptEnd.Value := Pref.WaitScriptEnd;
175 rgpWhenReturn.ItemIndex := Ord(Pref.WhenReturn);
176 rgpWhenShiftReturn.ItemIndex := Ord(Pref.WhenShiftReturn);
177 rgpWhenCtrlReturn.ItemIndex := Ord(Pref.WhenCtrlReturn);
179 cbxPort.ItemIndex := cbxPort.Items.Count-1; //
\81u
\82»
\82Ì
\91¼
\81v
180 for i := 0 to cbxPort.Items.Count-2 do begin
181 if StrToIntDef(cbxPort.Items[i], 0) = Pref.ServerPort then
182 cbxPort.ItemIndex := i;
184 cbxUsePort.Checked := Pref.UsePort;
185 cbxPort.Enabled := cbxUsePort.Checked;
186 cbxUsePort.OnClick := cbxUsePortClick; //Dialog
\8aJ
\82¢
\82½
\8fu
\8aÔ
\82É
\8cx
\8d\90\82³
\82ê
\82È
\82¢
\82æ
\82¤
189 tvwChannels.Items.Clear;
190 Node := tvwChannels.Items.Add(nil, '
\83f
\83t
\83H
\83\8b\83g');
191 Node.ImageIndex := 1;
192 Node.SelectedIndex := 1;
193 Node.Data := pointer(DefaultNode);
194 for i := 0 to Pref.ChannelPrefCount-1 do begin
195 Node := tvwChannels.Items.Add(nil, Pref.ChannelPrefIndex[i].ChannelName);
196 Node.Data := pointer(i); //
\96{
\93\96\82Í
\82â
\82Á
\82¿
\82á
\82¢
\82¯
\82È
\82¢Int>Pointer
\83L
\83\83\83X
\83g
197 Node.ImageIndex := BottleImage(Pref.ChannelPrefIndex[i]);
198 Node.SelectedIndex := BottleImage(Pref.ChannelPrefIndex[i]);
200 cbxTargetGhost.Items.Clear;
201 cbxTargetGhost.Items.Add(ChannelDefaultGhost);
202 frmSender.SakuraSeeker.BeginDetect;
203 for i := 0 to frmSender.SakuraSeeker.Count-1 do begin
204 cbxTargetGhost.Items.Add(frmSender.SakuraSeeker[i].Name);
206 rgpUseChannelPrefs.Enabled := false;
207 rgpUseChannelPrefsClick(Self);
209 cbxUseHttpProxy.Checked := Pref.UseHttpProxy;
210 edtProxyAddress.Text := Pref.ProxyAddress;
211 edtProxyPort.Text := IntToStr(Pref.ProxyPort);
215 procedure TfrmSetting.FormClose(Sender: TObject; var Action: TCloseAction);
217 Pref.DefaultScript := memDefaultScript.Text;
218 Pref.IgnoreTimeCritical := cbxIgnoreTimeCritical.Checked;
219 Pref.NoSendGhostList := cbxNoSendGhostList.Checked;
220 Pref.ConfirmOnExit := cbxConfirmOnExit.Checked;
222 Pref.ColorScript := cbxColorScript.Checked;
223 Pref.TalkColorH := colTalkColorH.SelColor;
224 Pref.TalkColorU := colTalkColorU.SelColor;
225 Pref.MarkUpColor := colMarkUpColor.SelColor;
226 Pref.MetaWordColor := colMetaWordColor.SelColor;
227 Pref.MarkErrorColor := colMarkErrorColor.SelColor;
228 Pref.BgColor := colBgColor.SelColor;
229 Pref.ColorTimeLagValue := trkColorTimeLag.Position;
230 Pref.ColorSpeed := trkColorSpeed.Position;
232 Pref.AutoStart := cbxAutoStart.Checked;
233 Pref.TabPosition := TTabPosition(rgpTabPosition.ItemIndex);
234 Pref.GhostDropDownCount := spnGhostDropDownCount.Value;
236 with ctvBottle do begin
237 Pref.NoTranslate := (GetNodeFromKeyPath('Arrive\NoTranslate') as TCPCCheckBoxNode).Checked;
238 Pref.NoDescript := (GetNodeFromKeyPath('Arrive\NoDescript') as TCPCCheckBoxNode).Checked;
239 Pref.NoTransUrl := (GetNodeFromKeyPath('Arrive\UrlTag\NoSelection') as TCPCRadioNode).Checked;
240 Pref.SilentWhenHidden := (GetNodeFromKeyPath('Arrive\SilentWhenHidden') as TCPCCheckBoxNode).Checked;
241 Pref.FixMessySurface := (GetNodeFromKeyPath('Arrive\FixMessySurface') as TCPCCheckBoxNode).Checked;
242 Pref.ResetIfGhostAfterSend := (GetNodeFromKeyPath('Out\ResetIfGhostAfterSend') as TCPCCheckBoxNode).Checked;
245 on E: Exception do ShowMessage(E.Message);
247 //Pref.IgnoreFrequentYenS := cbxIgnoreFrequentYenS.Checked;
248 Pref.WaitScriptEnd := spnWaitScriptEnd.Value;
250 Pref.WhenReturn := TReturnKeyFunction(rgpWhenReturn.ItemIndex);
251 Pref.WhenShiftReturn := TReturnKeyFunction(rgpWhenShiftReturn.ItemIndex);
252 Pref.WhenCtrlReturn := TReturnKeyFunction(rgpWhenCtrlReturn.ItemIndex);
254 Pref.UsePort := cbxUsePort.Checked;
256 Pref.UseHttpProxy := cbxUseHttpProxy.Checked;
257 Pref.ProxyAddress := edtProxyAddress.Text;
258 Pref.ProxyPort := StrToInt(edtProxyPort.Text);
261 procedure TfrmSetting.cbxPortChange(Sender: TObject);
265 with cbxPort do begin
266 if ItemIndex = Items.Count-1 then begin
268 Str := IntToStr(Pref.ServerPort);
269 if InputQuery('
\83|
\81[
\83g
\94Ô
\8d\86\82Ì
\8ew
\92è', '
\83|
\81[
\83g
\94Ô
\8d\86', Str) then begin
270 Pref.ServerPort := StrToIntDef(Str, Pref.ServerPort);
273 Pref.ServerPort := StrToIntDef(Items[ItemIndex], Pref.ServerPort);
275 for i := 0 to Items.Count-2 do begin
276 if Pref.ServerPort = StrToInt(Items[i]) then ItemIndex := i;
281 procedure TfrmSetting.edtSoundFileButtonClick(Sender: TObject);
283 if OpenDialog.Execute then begin
284 edtSoundFile.Text := OpenDialog.FileName;
288 procedure TfrmSetting.tvwChannelsCompare(Sender: TObject; Node1,
289 Node2: TTreeNode; Data: Integer; var Compare: Integer);
291 if Node1.Text = '
\83f
\83t
\83H
\83\8b\83g' then
293 else if Node2.Text = '
\83f
\83t
\83H
\83\8b\83g' then
296 Compare := AnsiCompareStr(Node1.Text, Node2.Text);
299 procedure TfrmSetting.tvwChannelsChange(Sender: TObject; Node: TTreeNode);
300 var ChPref: TChannelPrefs;
302 rgpUseChannelPrefs.Enabled := true;
303 if integer(Node.Data) = DefaultNode then begin
304 ChPref := Pref.DefChannelPref;
305 cbxCanAutoAdd.Enabled := false;
306 cbxWarnPost.Enabled := false;
307 rgpUseChannelPrefs.Enabled := false;
308 cbxSoundArrived.AllowGrayed := false;
310 ChPref := Pref.ChannelPrefIndex[integer(Node.Data)];
311 cbxCanAutoAdd.Enabled := true;
312 cbxWarnPost.Enabled := true;
313 rgpUseChannelPrefs.Enabled := true;
314 cbxSoundArrived.AllowGrayed := true;
316 cbxCanAutoAdd.Checked := ChPref.CanAutoAdd;
317 cbxWarnPost.Checked := ChPref.WarnPost;
318 if ChPref.UseChannelPrefs then begin
319 rgpUseChannelPrefs.ItemIndex := 0;
321 rgpUseChannelPrefs.ItemIndex := 1;
323 cbxSoundArrived.State := TCheckBoxState(ChPref.SoundArrived);
324 edtSoundFile.Text := ChPref.SoundFile;
325 cbxIgnoreIfGhost.Checked := ChPref.IgnoreIfGhost;
326 if ChPref.TargetGhost <> '' then
327 cbxTargetGhost.Text := ChPref.TargetGhost
329 cbxTargetGhost.Text := ChannelDefaultGhost;
332 procedure TfrmSetting.rgpUseChannelPrefsClick(Sender: TObject);
334 pnlChannelOpt.Visible := ((rgpUseChannelPrefs.ItemIndex = 0) and
335 (tvwChannels.Selected <> nil));
336 if SelChPref <> nil then begin
337 SelChPref.UseChannelPrefs := (rgpUseChannelPrefs.ItemIndex = 0);
338 tvwChannels.Selected.ImageIndex := BottleImage(SelChPref);
339 tvwChannels.Selected.SelectedIndex := BottleImage(SelChPref);
343 function TfrmSetting.BottleImage(ChPref: TChannelPrefs): integer;
345 if ChPref = Pref.DefChannelPref then Result := 1
346 else if ChPref.UseChannelPrefs then Result := CheckedBottle
347 else Result := UnCheckedBottle;
350 function TfrmSetting.SelChPref: TChannelPrefs;
352 if tvwChannels.Selected = nil then begin
355 end else if integer(tvwChannels.Selected.Data) = DefaultNode then begin
356 Result := Pref.DefChannelPref;
358 Result := Pref.ChannelPrefIndex[integer(tvwChannels.Selected.Data)];
362 procedure TfrmSetting.cbxSoundArrivedClick(Sender: TObject);
364 SelChPref.SoundArrived := TSoundArrived(cbxSoundArrived.State);
367 procedure TfrmSetting.edtSoundFileChange(Sender: TObject);
369 SelChPref.SoundFile := edtSoundFile.Text;
372 procedure TfrmSetting.cbxTargetGhostChange(Sender: TObject);
374 if cbxTargetGhost.ItemIndex = 0 then
375 SelChPref.TargetGhost := ''
377 SelChPref.TargetGhost := cbxTargetGhost.Text;
380 procedure TfrmSetting.cbxIgnoreIfGhostClick(Sender: TObject);
382 SelChPref.IgnoreIfGhost := cbxIgnoreIfGhost.Checked;
385 procedure TfrmSetting.cbxUsePortClick(Sender: TObject);
387 const Mes = '
\8f]
\97\88\82Ì
\95û
\96@
\82ð
\91I
\91ð
\82µ
\82½
\8fê
\8d\87\81ASSTP
\82ð
\8eó
\90M
\82Å
\82«
\82é
\83S
\81[
\83X
\83g
\82Í'+
388 '
\83\89\83\93\83_
\83\80\82È
\88ê
\91Ì
\82¾
\82¯
\82Æ
\82È
\82è
\81AIfGhost
\82ª
\88ê
\90Ø
\8eg
\97p
\82Å
\82«
\82È
\82
\82È
\82è
\82Ü
\82·
\81B';
390 if cbxUsePort.Checked then begin
391 Re := MessageDlg(Mes, mtWarning, mbOkCancel, 0);
392 if Re = mrCancel then cbxUsePort.Checked := false;
394 cbxPort.Enabled := cbxUsePort.Checked;
395 Pref.UsePort := cbxUsePort.Checked;
398 procedure TfrmSetting.cbxCanAutoAddClick(Sender: TObject);
400 SelChPref.CanAutoAdd := cbxCanAutoAdd.Checked;
403 procedure TfrmSetting.edtProxyPortKeyPress(Sender: TObject; var Key: Char);
405 if not(Key in ['0'..'9']) then Key := Char(0);
408 procedure TfrmSetting.cbxWarnPostClick(Sender: TObject);
410 SelChPref.WarnPost := cbxWarnPost.Checked;
413 procedure TfrmSetting.ctvBottleNodeChecked(Sender: TObject;
414 Node: TCPCConfigItemNode);
416 //ShowMessage(ctvBottle.GetFullKeyPath(Node));
419 procedure TfrmSetting.ctvBottleNodeChecking(Sender: TObject;
420 Node: TCPCConfigItemNode; var Allow: Boolean);
422 if Node.KeyName = 'IgnoreBottle' then begin
423 MessageDlg('
\82±
\82Ì
\8b@
\94\
\82Í
\8eÀ
\91\95\82³
\82ê
\82Ä
\82¢
\82Ü
\82¹
\82ñ', mtError, [mbOk], 0);