OSDN Git Service

cab0f8239fc1b411f03875dfa7b8cc251833974b
[winbottle/winbottle.git] / bottleclient / BottleDef.pas
1 unit BottleDef;
2
3 (*
4   \83A\83v\83\8a\83P\81[\83V\83\87\83\93\91S\91Ì\82Å\8eg\82¤\82³\82Ü\82´\82Ü\82È\83f\81[\83^\82ð\92è\8b`
5 *)
6
7 interface
8
9 uses Windows, IniFiles, BRegExp, Graphics, SysUtils, Forms, Dialogs, Classes,
10   ComCtrls, Contnrs, SsPlayTime, StrReplace;
11
12 type
13   TReturnKeyFunction = (kfYenN, kfReturn, kfYenNReturn, kfConstText);
14   TSoundArrived = (saFalse, saTrue, saParent);
15   TLogWindowPreviewStyle = (psConversation, psImageConversation,
16     psScript, psScriptWithLineBreak);
17   TLogListPreviewStyle = (psNoColor, psNormal, psTagStripped);
18   TSurfacePreviewOnScriptPointPosition = (spspMainWindowLeft, spspMainWindowRight);
19
20   //SSTP Bottle\82Ì\90Ý\92è
21   TBottlePrefs = class(TObject)
22   private
23     FIni: TIniFile;
24     //
25     FIgnoreTimeCritical: boolean;
26     FStayOnTop: boolean;
27     FShowConstBar: boolean;
28     FNoConfirm: boolean;
29     FDblClkInsert: boolean;
30     FShowToolBar: boolean;
31     FDefaultScript: TStringList;
32     FTalkColorH: TColor;
33     FMetaWordColor: TColor;
34     FTalkColorU: TColor;
35     FMarkErrorColor: TColor;
36     FMarkUpColor: TColor;
37     FAutoStart: boolean;
38     FCgiName: string;
39     FHomePage: string;
40     FWhenCtrlReturn: TReturnKeyFunction;
41     FWhenShiftReturn: TReturnKeyFunction;
42     FWhenReturn: TReturnKeyFunction;
43     FNoTranslate: boolean;
44     FNoDescript: boolean;
45     FBgColor: TColor;
46     FTextColor: TColor;
47     FServerPort: integer;
48     FSilentWhenHidden: boolean;
49     FLUID: String;
50     FSenderWindowPosition: TRect;
51     FTabPosition: TTabPosition;
52     FLogWindowPosition: TRect;
53     FNoTransUrl: boolean;
54     FIgnoreFrequentYenS: boolean;
55     FWaitScriptEnd: integer;
56     FCgiNameGhost: String;
57     FGLogPage: String;
58     FVotePage: String;
59     FLogWindowDividerPos: integer;
60     FHelpPage: String;
61     FUseHttpProxy: boolean;
62     FProxyPort: integer;
63     FProxyAddress: String;
64     FConfirmOnExit: boolean;
65     FFixMessySurface: boolean;
66     FResetIfGhostAfterSend: boolean;
67     FGhostDropDownCount: integer;
68     FLogWindowPreviewStyle: TLogWindowPreviewStyle;
69     FCgiFetchLog: String;
70     FTalkColorS: TColor;
71     FLogWindowColumnWidth: String;
72     FClearAfterSend: boolean;
73     FAutoJoinChannels: TStrings;
74     FFMOName: TStrings;
75     FHUTagTo01Tag: boolean;
76     FWarnYenTNotExist: boolean;
77     FWarnScopeChangeInSynchronize: boolean;
78     FNeedConfirmBeforeSend: boolean;
79     FShowRuler: boolean;
80     FHideGhosts: boolean;
81     FVisibleGhostsList: TStringList;
82     FSurfacePreviewOnHint: boolean;
83     FSurfacePreviewOnScriptPoint: boolean;
84     FSurfacePreviewOnScriptPointPosition: TSurfacePreviewOnScriptPointPosition;
85     FNoExtraSSTPHeaders: boolean;
86     FLogListPreviewStyle: TLogListPreviewStyle;
87     FEditorPreviewWindowPosition: TRect;
88     FAutoClip: boolean;
89     FConfirmOnTabClose: boolean;
90     FReconnectWait: integer;
91     FPartialConfirmFormat: String;
92     FAutoPartialConfirm: boolean;
93     FPlayTimeParams: TSsPlayTimeParams;
94     FBottleServerPort: integer;
95     FBottleServer: String;
96     FTabWidth: integer;
97     FBrowserExeName: string;
98     FReplacePresets: TReplacePresets;
99
100     procedure SetDblClkInsert(const Value: boolean);
101     procedure SetDefaultScript(const Value: String);
102     procedure SetIgnoreTimeCritical(const Value: boolean);
103     procedure SetMarkErrorColor(const Value: TColor);
104     procedure SetMarkUpColor(const Value: TColor);
105     procedure SetMetaWordColor(const Value: TColor);
106     procedure SetTextColor(const Value: TColor);
107     procedure SetNoConfirm(const Value: boolean);
108     procedure SetShowConstBar(const Value: boolean);
109     procedure SetShowToolBar(const Value: boolean);
110     procedure SetStayOnTop(const Value: boolean);
111     procedure SetTalkColorH(const Value: TColor);
112     procedure SetTalkColorU(const Value: TColor);
113     procedure SetAutoStart(const Value: boolean);
114     procedure SetWhenCtrlReturn(const Value: TReturnKeyFunction);
115     procedure SetWhenReturn(const Value: TReturnKeyFunction);
116     procedure SetWhenShiftReturn(const Value: TReturnKeyFunction);
117     procedure SetNoTranslate(const Value: boolean);
118     procedure SetNoDescript(const Value: boolean);
119     procedure SetBgColor(const Value: TColor);
120     procedure SetServerPort(const Value: integer);
121     procedure SetSilentWhenHidden(const Value: boolean);
122     procedure SetLUID(const Value: String);
123     procedure SetSenderWindowPosition(const Value: TRect);
124     procedure SetTabPosition(const Value: TTabPosition);
125     procedure SetLogWindowPosition(const Value: TRect);
126     procedure SetIgnoreFrequentYenS(const Value: boolean);
127     procedure SetNoTransUrl(const Value: boolean);
128     procedure SetWaitScriptEnd(const Value: integer);
129     procedure SetLogWindowDividerPos(const Value: integer);
130     procedure SetProxyAddress(const Value: String);
131     procedure SetProxyPort(const Value: integer);
132     procedure SetUseHttpProxy(const Value: boolean);
133     procedure SetConfirmOnExit(const Value: boolean);
134     procedure SetFixMessySurface(const Value: boolean);
135     procedure SetResetIfGhostAfterSend(const Value: boolean);
136     procedure SetGhostDropDownCount(const Value: integer);
137     procedure SetLogWindowPreviewStyle(const Value: TLogWindowPreviewStyle);
138     procedure SetTalkColorS(const Value: TColor);
139     procedure SetLogWindowColumnWidth(const Value: String);
140     procedure SetClearAfterSend(const Value: boolean);
141     procedure SetAutoJoinChannels(const Value: TStrings);
142     procedure SetFMOName(const Value: TStrings);
143     function GetDefaultScript: String;
144     procedure SetHUTagTo01Tag(const Value: boolean);
145     procedure SetWarnScopeChangeInSynchronize(const Value: boolean);
146     procedure SetWarnYenTNotExist(const Value: boolean);
147     procedure SetNeedConfirmBeforeSend(const Value: boolean);
148     procedure SetShowRuler(const Value: boolean);
149     procedure SetHideGhosts(const Value: boolean);
150     procedure SetVisibleGhostsList(const Value: TStringList);
151     procedure SetSurfacePreviewOnHint(const Value: boolean);
152     procedure SetSurfacePreviewOnScriptPoint(const Value: boolean);
153     procedure SetSurfacePreviewOnScriptPointPosition(
154       const Value: TSurfacePreviewOnScriptPointPosition);
155     procedure SetNoExtraSSTPHeaders(const Value: boolean);
156     procedure SetLogListPreviewStyle(const Value: TLogListPreviewStyle);
157     procedure SetEditorPreviewWindowPosition(const Value: TRect);
158     procedure SetAutoClip(const Value: boolean);
159     procedure SetConfirmOnTabClose(const Value: boolean);
160     procedure SetReconnectWait(const Value: integer);
161     procedure SetPartialConfirmFormat(const Value: String);
162     procedure SetAutoPartialConfirm(const Value: boolean);
163     procedure SetPlayTimeParams(const Value: TSsPlayTimeParams);
164     procedure SetTabWidth(const Value: integer);
165     procedure SetBrowserExeName(const Value: string);
166   protected
167     function InScreen(ARect: TRect): boolean;
168   public
169     property BottleServer: String read FBottleServer;
170     property BottleServerPort: integer read FBottleServerPort;
171     property PartialConfirmFormat: String read FPartialConfirmFormat write SetPartialConfirmFormat;
172     property AutoPartialConfirm: boolean read FAutoPartialConfirm write SetAutoPartialConfirm;
173     property ConfirmOnExit: boolean read FConfirmOnExit write SetConfirmOnExit;
174     property ConfirmOnTabClose: boolean read FConfirmOnTabClose write SetConfirmOnTabClose;
175     property AutoClip: boolean read FAutoClip write SetAutoClip;
176     property AutoStart: boolean read FAutoStart write SetAutoStart;
177     property TabPosition: TTabPosition read FTabPosition write SetTabPosition;
178     property TabWidth: integer read FTabWidth write SetTabWidth;
179     property GhostDropDownCount: integer read FGhostDropDownCount write SetGhostDropDownCount;
180     property NoTranslate: boolean read FNoTranslate write SetNoTranslate;
181     property NoDescript: boolean read FNoDescript write SetNoDescript;
182     property NoTransUrl: boolean read FNoTransUrl write SetNoTransUrl;
183     property SilentWhenHidden: boolean read FSilentWhenHidden write SetSilentWhenHidden;
184     property FixMessySurface: boolean read FFixMessySurface write SetFixMessySurface;
185     property HUTagTo01Tag: boolean read FHUTagTo01Tag write SetHUTagTo01Tag;
186     property ResetIfGhostAfterSend: boolean read FResetIfGhostAfterSend write SetResetIfGhostAfterSend;
187     property ClearAfterSend: boolean read FClearAfterSend write SetClearAfterSend;
188     property NeedConfirmBeforeSend: boolean read FNeedConfirmBeforeSend write SetNeedConfirmBeforeSend;
189     property IgnoreFrequentYenS: boolean read FIgnoreFrequentYenS write SetIgnoreFrequentYenS;
190     property WarnYenTNotExist: boolean read FWarnYenTNotExist write SetWarnYenTNotExist;
191     property WarnScopeChangeInSynchronize: boolean read FWarnScopeChangeInSynchronize write SetWarnScopeChangeInSynchronize;
192     property WaitScriptEnd: integer read FWaitScriptEnd write SetWaitScriptEnd;
193     property StayOnTop: boolean read FStayOnTop write SetStayOnTop;
194     property IgnoreTimeCritical: boolean read FIgnoreTimeCritical write SetIgnoreTimeCritical;
195     property TalkColorH: TColor read FTalkColorH write SetTalkColorH;
196     property TalkColorU: TColor read FTalkColorU write SetTalkColorU;
197     property TalkColorS: TColor read FTalkColorS write SetTalkColorS;
198     property MarkUpColor: TColor read FMarkUpColor write SetMarkUpColor;
199     property MetaWordColor: TColor read FMetaWordColor write SetMetaWordColor;
200     property MarkErrorColor: TColor read FMarkErrorColor write SetMarkErrorColor;
201     property BgColor: TColor read FBgColor write SetBgColor;
202     property TextColor: TColor read FTextColor write SetTextColor;
203     property DefaultScript: String read GetDefaultScript write SetDefaultScript;
204     property ShowRuler: boolean read FShowRuler write SetShowRuler;
205     property DblClkInsert: boolean read FDblClkInsert write SetDblClkInsert;
206     property ShowToolBar: boolean read FShowToolBar write SetShowToolBar;
207     property ShowConstBar: boolean read FShowConstBar write SetShowConstBar;
208     property NoConfirm: boolean read FNoConfirm write SetNoConfirm;
209     property HomePage: string read FHomePage;
210     property WhenReturn: TReturnKeyFunction read FWhenReturn write SetWhenReturn;
211     property WhenShiftReturn: TReturnKeyFunction read FWhenShiftReturn write SetWhenShiftReturn;
212     property WhenCtrlReturn: TReturnKeyFunction read FWhenCtrlReturn write SetWhenCtrlReturn;
213     property ServerPort: integer read FServerPort write SetServerPort;
214     //URL\8aÖ\8cW
215     property CgiName: string read FCgiName;
216     property CgiNameGhost: String read FCgiNameGhost;
217     property CgiFetchLog: String read FCgiFetchLog;
218     property GLogPage: String read FGLogPage;
219     property VotePage: String read FVotePage;
220     property HelpPage: String read FHelpPage;
221
222     //\83`\83\83\83\93\83l\83\8b\8aÖ\8cW
223     property AutoJoinChannels: TStrings read FAutoJoinChannels write SetAutoJoinChannels;
224
225     property LUID: String read FLUID write SetLUID;
226
227     //\83E\83B\83\93\83h\83E\88Ê\92u
228     property SenderWindowPosition: TRect
229       read FSenderWindowPosition write SetSenderWindowPosition;
230     property LogWindowPosition: TRect read FLogWindowPosition write SetLogWindowPosition;
231     property LogWindowDividerPos: integer
232       read FLogWindowDividerPos write SetLogWindowDividerPos;
233     property LogWindowColumnWidth: String
234       read FLogWindowColumnWidth write SetLogWindowColumnWidth;
235     property EditorPreviewWindowPosition: TRect read FEditorPreviewWindowPosition write SetEditorPreviewWindowPosition;
236     //\83v\83\8d\83L\83V\8aÖ\8cW
237     property UseHttpProxy: boolean read FUseHttpProxy write SetUseHttpProxy;
238     property ProxyAddress: String read FProxyAddress write SetProxyAddress;
239     property ProxyPort: integer read FProxyPort write SetProxyPort;
240     //\8dÄ\90Ú\91±
241     property ReconnectWait: integer read FReconnectWait write SetReconnectWait;
242     //\83\8d\83O\83E\83B\83\93\83h\83E\8aÖ\8cW
243     property LogWindowPreviewStyle: TLogWindowPreviewStyle
244       read FLogWindowPreviewStyle write SetLogWindowPreviewStyle;
245     property LogListPreviewStyle: TLogListPreviewStyle
246       read FLogListPreviewStyle write SetLogListPreviewStyle;
247     //\8fÚ\8d×\90Ý\92è
248     property FMOName: TStrings read FFMOName write SetFMOName;
249     property HideGhosts: boolean read FHideGhosts write SetHideGhosts;
250     property VisibleGhostsList: TStringList read FVisibleGhostsList write SetVisibleGhostsList;
251     property NoExtraSSTPHeaders: boolean read FNoExtraSSTPHeaders write SetNoExtraSSTPHeaders;
252     //\83T\81[\83t\83B\83X\83v\83\8c\83r\83\85\81[
253     property SurfacePreviewOnHint: boolean
254       read FSurfacePreviewOnHint write SetSurfacePreviewOnHint;
255     property SurfacePreviewOnScriptPoint: boolean
256       read FSurfacePreviewOnScriptPoint write SetSurfacePreviewOnScriptPoint;
257     property SurfacePreviewOnScriptPointPosition: TSurfacePreviewOnScriptPointPosition
258       read FSurfacePreviewOnScriptPointPosition write SetSurfacePreviewOnScriptPointPosition;
259     //\8dÄ\90\8e\9e\8aÔ\97\\91ª
260     property PlayTimeParams: TSsPlayTimeParams read FPlayTimeParams write SetPlayTimeParams;
261     //URL\83I\81[\83v\83\93\8e\9e\82É\8eg\82¤\83u\83\89\83E\83U\82Ì\8eÀ\8ds\83t\83@\83C\83\8b\96¼
262     property BrowserExeName: string read FBrowserExeName write SetBrowserExeName;
263     //\8e©\93®\92u\8a·\83v\83\8a\83Z\83b\83g
264     property ReplacePresets: TReplacePresets read FReplacePresets;
265
266     //\83R\83\93\83X\83g\83\89\83N\83^\81E\83f\83X\83g\83\89\83N\83^\81E\95Û\91
267     constructor Create;
268     destructor Destroy; override;
269     procedure SaveSettings;
270   end;
271
272   TChannelListItem = class(TObject)
273   private
274     FMembers: integer;
275     FGhost: String;
276     FInfo: String;
277     FName: String;
278     FNoPost: boolean;
279     FWarnPost: boolean;
280     procedure SetGhost(const Value: String);
281     procedure SetInfo(const Value: String);
282     procedure SetMembers(const Value: integer);
283     procedure SetName(const Value: String);
284     procedure SetNoPost(const Value: boolean);
285     procedure SetWarnPost(const Value: boolean);
286   public
287     property Name: String read FName write SetName;
288     property Info: String read FInfo write SetInfo;
289     property Ghost: String read FGhost write SetGhost;
290     property Members: integer read FMembers write SetMembers;
291     property NoPost: boolean read FNoPost write SetNoPost;
292     property WarnPost: boolean read FWarnPost write SetWarnPost;
293   end;
294
295   TChannelList = class(TList)
296   private
297     function GetChannel(Name: String): TChannelListItem;
298     function GetChannelItem(Index: integer): TChannelListItem;
299   public
300     procedure Clear; override;
301     property Channel[Name: String]: TChannelListItem read GetChannel;
302     property ChannelItem[Index: integer]: TChannelListItem read GetChannelItem;
303   end;
304
305   TScriptTransOption = (
306     toIgnoreTimeCritical,
307     toConvertURL,
308     toNoChoice,
309     toIgnoreFrequentYenS,
310     toWaitScriptEnd,
311     toFixMessySurface,
312     toWarnMessySurface,
313     toHUTagTo01Tag,
314     toWarnCheck
315   );
316
317   TScriptTransOptions = set of TScriptTransOption;
318
319 var
320   Pref: TBottlePrefs;
321   ChannelList: TChannelList; //\83`\83\83\83\93\83l\83\8b\83\8a\83X\83g\82ð\95Û\8e\9d\82·\82é
322   JoinChannels: TStringList; // \8c»\8dÝ\8eQ\89Á\82µ\82Ä\82¢\82é\83`\83\83\83\93\83l\83\8b
323
324 const
325   DefaultBottleServer    = 'bottle.mikage.to';
326   DefaultBottleServerPort = 9871;
327   DefaultCGI      = '/bottle2.cgi';
328   DefaultCGIGhost = '/glog/bottleglog.cgi';
329   DefaultCGIFetchLog = '/fetchlog.cgi';
330
331
332   DefaultHomePage = 'http://bottle.mikage.to/';
333   DefaultGLogPage = 'http://bottle.mikage.to/glog/glogview.cgi';
334   DefaultVotePage = 'http://bottle.mikage.to/viewvotes.cgi';
335   DefaultHelpPage = 'http://bottle.mikage.to/clihelp/index.html';
336
337   Version = '2.70';
338
339   {$IFDEF NOMUTEX}
340   VersionString = 'SSTP Bottle Client ver ' + Version + 'a NO MUTEX VERSION';
341   {$ELSE}
342   VersionString = 'SSTP Bottle Client ver ' + Version;
343   {$ENDIF}
344
345   SentLogFile     = 'sent.log';
346
347   BottleDisclaimer = '(C)2001-2004 WinBottle Project'#13#10 +
348     'naru, C.Ponapalt, Yune Kotomi, yese, Mikage Sawatari'#13#10 +
349     DefaultHomePage;
350
351   ChannelDefault = '(CH\90\84\8f§)';
352   ClipChannel    = '(\83N\83\8a\83b\83v)'; 
353
354 function ParamsEncode(const ASrc: string): string;
355 function XMLEntity(From: String): String;
356 function SafeFileName(From: String; ChangePathDelimiters: boolean = true): String;
357 function ComponentToString(Component: TComponent): string;
358 function StringToComponent(Value: string): TComponent;
359
360 function ReplacePresetFileName: string;
361
362 procedure BuildShortCutList(Target: TStrings);
363
364 implementation
365
366 function ParamsEncode(const ASrc: string): string;
367 var
368   i: Integer;
369 const
370   UnsafeChars = ['*', '#', '%', '<', '>', ' ', '[', ']', '+'];
371 begin
372   Result := '';    {Do not Localize}
373   for i := 1 to Length(ASrc) do
374   begin
375     if (ASrc[i] in UnsafeChars) or (not (ord(ASrc[i])in [33..128])) then
376     begin {do not localize}
377       Result := Result + '%' + IntToHex(Ord(ASrc[i]), 2);  {do not localize}
378     end
379     else
380     begin
381       Result := Result + ASrc[i];
382     end;
383   end;
384 end;
385
386 // XML\8eÀ\91Ì\8eQ\8fÆ\82É\92u\82«\8a·\82¦\82é
387 function XMLEntity(From: String): String;
388 var
389   i: integer;
390   InLead: boolean;
391 begin
392   InLead := false;
393   Result := '';
394   for i := 1 to Length(From) do
395   begin
396     if InLead then
397     begin
398       InLead := false;
399       Result := Result + From[i];
400     end else if From[i] in LeadBytes then
401     begin
402       InLead := true;
403       Result := Result + From[i];
404     end else
405     begin
406       case Ord(From[i]) of
407         60: Result := Result + '&lt;'; // Less than
408         62: Result := Result + '&gt;'; // Greater than
409         38: Result := Result + '&amp;'; // Ampersand
410         39: Result := Result + '&#39;'; // Single quote
411         34: Result := Result + '&quot;'; // Double quote
412         else
413           Result := Result + From[i];
414       end;
415     end;
416   end;
417 end;
418
419 // Escape characters which can not be used as a filename
420 function SafeFileName(From: String; ChangePathDelimiters: boolean = true): String;
421 begin
422   Result := StringReplace(From, '*', '\81\96', [rfReplaceAll]);
423   Result := StringReplace(Result, '|', '\81b', [rfReplaceAll]);
424   Result := StringReplace(Result, '"', '''''', [rfReplaceAll]);
425   Result := StringReplace(Result, '<', '\81\83', [rfReplaceAll]);
426   Result := StringReplace(Result, '>', '\81\84', [rfReplaceAll]);
427   Result := StringReplace(Result, '?', '\81H', [rfReplaceAll]);
428   if ChangePathDelimiters then
429   begin
430     Result := StringReplace(Result, '\', '\81\8f', [rfReplaceAll]);
431     Result := StringReplace(Result, ':', '\81F', [rfReplaceAll]);
432     Result := StringReplace(Result, '/', '\81^', [rfReplaceAll]);
433   end;
434 end;
435
436 function ComponentToString(Component: TComponent): string;
437 var
438   BinStream:TMemoryStream;
439   StrStream: TStringStream;
440   s: string;
441 begin
442   BinStream := TMemoryStream.Create;
443   try
444     StrStream := TStringStream.Create(s);
445     try
446       BinStream.WriteComponent(Component);
447       BinStream.Seek(0, soFromBeginning);
448       ObjectBinaryToText(BinStream, StrStream);
449       StrStream.Seek(0, soFromBeginning);
450       Result:= StrStream.DataString;
451     finally
452       StrStream.Free;
453     end;
454   finally
455     BinStream.Free
456   end;
457 end;
458
459 function StringToComponent(Value: string): TComponent;
460 var
461   StrStream:TStringStream;
462   BinStream: TMemoryStream;
463 begin
464   StrStream := TStringStream.Create(Value);
465   try
466     BinStream := TMemoryStream.Create;
467     try
468       ObjectTextToBinary(StrStream, BinStream);
469       BinStream.Seek(0, soFromBeginning);
470       Result := BinStream.ReadComponent(nil);
471     finally
472       BinStream.Free;
473     end;
474   finally
475     StrStream.Free;
476   end;
477 end;
478
479 function ReplacePresetFileName: string;
480 begin
481   Result := ExtractFilePath(Application.ExeName) + 'replace.txt';
482 end;
483
484 procedure BuildShortCutList(Target: TStrings);
485 var
486   c: Char;
487   i: Integer;
488 begin
489   // \83V\83\87\81[\83g\83J\83b\83g\83\8a\83X\83g\82Ì\91I\91ð\8e\88\82ð\8dì\90¬
490   with Target do
491   begin
492     BeginUpdate;
493     try
494       for c := 'A' to 'Z' do
495         Add('Ctrl+' + c);
496       for c := 'A' to 'Z' do
497         Add('Shift+Ctrl+' + c);
498       for c := 'A' to 'Z' do
499         Add('Alt+Ctrl+' + c);
500       for i := 1 to 12 do
501         Add('F' + IntToStr(i));
502       for i := 1 to 12 do
503         Add('Shift+F' + IntToStr(i));
504     finally
505       EndUpdate;
506     end;
507   end;
508 end;
509
510 { TBottlePrefs }
511
512 constructor TBottlePrefs.Create;
513 var ARect: TRect;
514     Strs: TStringList;
515 begin
516   FAutoJoinChannels := TStringList.Create;
517   FDefaultScript := TStringList.Create;
518   FFMOName := TStringList.Create;
519   FVisibleGhostsList := TStringList.Create;
520   try
521     FIni := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
522     //
523     PartialConfirmFormat := FIni.ReadString('System', 'PartialConfirmFormat', '\t|\e');
524     AutoPartialConfirm := FIni.ReadBool('System', 'AutoPartialConfirm', false);
525     ConfirmOnExit := FIni.ReadBool('System', 'ConfirmOnExit', false);
526     ConfirmOnExit := FIni.ReadBool('System', 'ConfirmOnExit', false);
527     ConfirmOnTabClose := FIni.ReadBool('System', 'ConfirmOnTabClose', false);
528     AutoClip := FIni.ReadBool('System', 'AutoClip', false);
529     AutoStart := FIni.ReadBool('System', 'AutoStart', false);
530     TabPosition := TTabPosition(FIni.ReadInteger('System', 'TabPosition', 0));
531     TabWidth := FIni.ReadInteger('System', 'TabWidth', 0);
532     GhostDropDownCount := FIni.ReadInteger('System', 'GhostDropDownCount', 30);
533
534     NoTranslate := FIni.ReadBool('System', 'NoTranslate', true);
535     NoDescript := FIni.ReadBool('System', 'NoDescript', false);
536     NoTransUrl := FIni.ReadBool('System', 'NoTransUrl', false);
537     SilentWhenHidden:= FIni.ReadBool('System', 'SilentWhenHidden', true);
538     FixMessySurface := FIni.ReadBool('System', 'FixMessySurface', false);
539     HUTagTo01Tag := FIni.ReadBool('System', 'HUTagTo01Tag', false);
540     ResetIfGhostAfterSend := FIni.ReadBool('System', 'ResetIfGhostAfterSend', false);
541     ClearAfterSend := FIni.ReadBool('System', 'ClearAfterSend', true);
542     NeedConfirmBeforeSend := FIni.ReadBool('System', 'NeedConfirmBeforeSend', true);
543     WarnYenTNotExist := FIni.ReadBool('System', 'WarnYenTNotExist', false);
544     WarnScopeChangeInSynchronize := FIni.ReadBool('System', 'WarnScopeChangeInSynchronize', false);
545
546     IgnoreFrequentYenS := FIni.ReadBool('System', 'IgnoreFrequentYenS', false);
547     WaitScriptEnd := FIni.ReadInteger('System', 'WaitScriptEnd', 0);
548     StayOnTop := FIni.ReadBool('System', 'StayOnTop', false);
549     ShowConstBar := FIni.ReadBool('System', 'ShowConstBar', true);
550     ShowToolBar := FIni.ReadBool('System', 'ShowToolBar', true);
551     NoConfirm := FIni.ReadBool('System', 'NoConfirm', false);
552     IgnoreTimeCritical := FIni.ReadBool('System', 'IgnoreTimeCritical', false);
553     FDefaultScript.CommaText := FIni.ReadString('System', 'DefaultScript', '\t\u\s[10]\h\s[0]|\e');
554     ShowRuler := FIni.ReadBool('System', 'ShowRuler', false);
555     //
556     try
557       TalkColorH := StringToColor(FIni.ReadString('System', 'TalkColorH', 'clBlack'));
558       TalkColorU := StringToColor(FIni.ReadString('System', 'TalkColorU', 'clMaroon'));
559       TalkColorS := StringToColor(FIni.ReadString('System', 'TalkColorS', 'clPurple'));
560       MarkUpColor := StringToColor(FIni.ReadString('System', 'MarkUpColor', 'clGreen'));
561       MetaWordColor := StringToColor(FIni.ReadString('System', 'MetaWordColor', 'clBlue'));
562       MarkErrorColor := StringToColor(FIni.ReadString('System', 'MarkErrorColor', 'clRed'));
563       TextColor := StringToColor(FIni.ReadString('System', 'TextColor', ColorToString(TalkColorH)));
564       BgColor := StringToColor(FIni.ReadString('System', 'BgColor', 'clWhite'));
565     except
566       on EConvertError do begin
567         ShowMessage('\83J\83\89\81[\82Ì\90Ý\92è\93Ç\82Ý\8d\9e\82Ý\83G\83\89\81[');
568         FTalkColorH := clBlack;
569         FTalkColorU := clMaroon;
570         FMarkUpColor := clGreen;
571         FMetaWordColor := clBlue;
572         FMarkErrorColor := clRed;
573         FTextColor := clBlack;
574       end;
575     end;
576
577     try
578       if FIni.ReadString('System', 'PlayTimeParams', '') = '' then
579       begin
580         FPlayTimeParams := TSsPlayTimeParams.Create(nil);
581         FPlayTimeParams.ProfileName := '\83f\83t\83H\83\8b\83g';
582       end else
583       begin
584         Strs := TStringList.Create;
585         try
586           Strs.CommaText := FIni.ReadString('System', 'PlayTimeParams', '');
587           FPlayTimeParams := StringToComponent(Strs.Text) as TSsPlayTimeParams;
588         finally
589           Strs.Free;
590         end;
591       end;
592     except
593       on E: Exception do
594       begin
595         ShowMessage('\8dÄ\90\8e\9e\8aÔ\97\\91ª\90Ý\92è\82Ì\93Ç\82Ý\8d\9e\82Ý\83G\83\89\81[' + E.Message);
596         if FPlayTimeParams = nil then
597           FPlayTimeParams := TSsPlayTimeParams.Create(nil);
598       end;
599     end;
600
601     WhenReturn      := TReturnKeyFunction(FIni.ReadInteger('System', 'WhenReturn', 0));
602     WhenShiftReturn := TReturnKeyFunction(FIni.ReadInteger('System', 'WhenShiftReturn', 0));
603     WhenCtrlReturn  := TReturnKeyFunction(FIni.ReadInteger('System', 'WhenCtrlReturn', 0));
604     //\83\\83P\83b\83g\82ð\83{\83g\83\8b\94z\91\97\82ÌSSTP\92Ê\90M\82É\8eg\97p\82·\82é\8fê\8d\87\82Ì\90Ý\92è
605     ServerPort      := FIni.ReadInteger('System', 'ServerPort', 11000);
606
607     FBottleServer := FIni.ReadString('System', 'BottleServer', DefaultBottleServer);
608     FBottleServerPort := FIni.ReadInteger('System', 'BottleServerPort', DefaultBottleServerPort);
609     FCgiName  := FIni.ReadString('System', 'CgiName', DefaultCGI);
610     FCgiFetchLog := FIni.ReadString('System', 'CgiFetchLog', DefaultCGIFetchLog);
611     FHomePage := FIni.ReadString('System', 'HomePage', DefaultHomePage);
612     FGLogPage := FIni.ReadString('System', 'GLogPage', DefaultGLogPage);
613     FVotePage := FIni.ReadString('System', 'VotePage', DefaultVotePage);
614     FHelpPage := FIni.ReadString('System', 'HelpPage', DefaultHelpPage);
615     FCgiNameGhost := FIni.ReadString('System', 'GHOST', DefaultCGIGhost);
616     FLUID     := FIni.ReadString('System', 'LUID', '');
617     FAutoJoinChannels.CommaText := FIni.ReadString('System', 'AutoJoinChannels', '');
618     //
619     ARect.Top    := FIni.ReadInteger('System', 'SenderWindowPositionTop', 100);
620     ARect.Left   := FIni.ReadInteger('System', 'SenderWindowPositionLeft', 100);
621     ARect.Bottom := FIni.ReadInteger('System', 'SenderWindowPositionBottom', 500);
622     ARect.Right  := FIni.ReadInteger('System', 'SenderWindowPositionRight', 500);
623     if not InScreen(ARect) then
624       ARect := Rect(100, 100, 500, 500);
625     SenderWindowPosition := ARect;
626     ARect.Top    := FIni.ReadInteger('System', 'LogWindowPositionTop', 200);
627     ARect.Left   := FIni.ReadInteger('System', 'LogWindowPositionLeft', 200);
628     ARect.Bottom := FIni.ReadInteger('System', 'LogWindowPositionBottom', 600);
629     ARect.Right  := FIni.ReadInteger('System', 'LogWindowPositionRight', 400);
630     LogWindowDividerPos := FIni.ReadInteger('System', 'LogWindowDividerPos', 150);
631     LogWindowColumnWidth := FIni.ReadString('System', 'LogWindowColumnWidth', '');
632     if not InScreen(ARect) then begin
633       ARect := Rect(200, 200, 600, 400);
634       LogWindowDividerPos := 150;
635     end;
636     LogWindowPosition := ARect;
637     Strs := TStringList.Create;
638     try
639       Strs.CommaText := FIni.ReadString('System', 'EditorPreviewWindowPosition', '500,100,800,500');
640       try
641         ARect.Left   := StrToInt(Strs[0]);
642         ARect.Top    := StrToInt(Strs[1]);
643         ARect.Right  := StrToInt(Strs[2]);
644         ARect.Bottom := StrToInt(Strs[3]);
645       except
646         ARect := Rect(500, 100, 800, 500);
647       end;
648       EditorPreviewWindowPosition := ARect;
649     finally
650       Strs.Free;
651     end;
652     //
653     UseHttpProxy := FIni.ReadBool('System', 'UseHttpProxy', false);
654     ProxyAddress := FIni.ReadString('System', 'ProxyAddress', '');
655     ProxyPort    := FIni.ReadInteger('System', 'ProxyPort', 0);
656     //
657     ReconnectWait := FIni.ReadInteger('System', 'ReconnectWait', 6);
658     //\83\8d\83O\83E\83B\83\93\83h\83E\8aÖ\8cW
659     LogWindowPreviewStyle := TLogWindowPreviewStyle(
660       FIni.ReadInteger('System', 'LogWindowPreviewStyle', 0));
661     LogListPreviewStyle := TLogListPreviewStyle(
662       FIni.ReadInteger('System', 'LogListPreviewStyle', 0));
663     //\8fÚ\8d×
664     FMOName.CommaText := FIni.ReadString('System', 'FMOName', 'Sakura');
665     HideGhosts := FIni.ReadBool('System', 'HideGhosts', false);
666     VisibleGhostsList.CommaText := FIni.ReadString('System', 'VisibleGhostsList', '');
667     NoExtraSSTPHeaders := FIni.ReadBool('System', 'NoExtraSSTPHeaders', false);
668     //\83T\81[\83t\83B\83X\83v\83\8c\83r\83\85\81[
669     SurfacePreviewOnHint := FIni.ReadBool('System', 'SurfacePreviewOnHint', false);
670     SurfacePreviewOnScriptPoint := FIni.ReadBool('System', 'SurfacePreviewOnScriptPoint', false);
671     SurfacePreviewOnScriptPointPosition :=
672       TSurfacePreviewOnScriptPointPosition(FIni.ReadInteger('System', 'SurfacePreviewOnScriptPointPosition', 0));
673
674     //URL\82ð\8aJ\82­\83u\83\89\83E\83U
675     FBrowserExeName:= FIni.ReadString('System', 'BrowserExeName', '');
676
677     //\8e©\93®\92u\8a·\83v\83\8a\83Z\83b\83g
678     if FileExists(ReplacePresetFileName) then
679     begin
680       try
681         Strs := TStringList.Create;
682         try
683           Strs.LoadFromFile(ReplacePresetFileName);
684           FReplacePresets := StringToComponent(Strs.Text) as TReplacePresets;
685         finally
686           Strs.Free;
687         end;
688       except
689         ShowMessage('Replace.txt\93Ç\82Ý\8d\9e\82Ý\92\86\82Ì\83G\83\89\81[\81B'#13#10+
690           '\83t\83@\83C\83\8b\82ª\94j\91¹\82µ\82Ä\82¢\82é\8fê\8d\87\82Í\81A\82±\82Ì\83t\83@\83C\83\8b\82ð\8dí\8f\9c\82µ\82Ä\8dÄ\8bN\93®\82µ\82Ä\82­\82¾\82³\82¢');
691         raise;
692       end;
693     end else
694       FReplacePresets := TReplacePresets.Create(nil);
695   except
696     on E: Exception do
697     begin
698       ShowMessage('\90Ý\92è\93Ç\82Ý\8d\9e\82Ý\83G\83\89\81['#13#10 + E.Message);
699       Application.Terminate;
700     end;
701   end;
702 end;
703
704 destructor TBottlePrefs.Destroy;
705 begin
706   inherited;
707   SaveSettings;
708   if FReplacePresets <> nil then
709     FReplacePresets.Free;
710   if FIni <> nil then
711     FIni.Free;
712   if FAutoJoinChannels <> nil then
713     FAutoJoinChannels.Free;
714   if FDefaultScript <> nil then
715     FDefaultScript.Free;
716   if FFMOName <> nil then
717     FFMOName.Free;
718   if FVisibleGhostsList <> nil then
719     FVisibleGhostsList.Free;
720   if FPlayTimeParams <> nil then
721     FPlayTimeParams.Free;
722 end;
723
724 procedure TBottlePrefs.SetAutoStart(const Value: boolean);
725 begin
726   FAutoStart := Value;
727 end;
728
729 procedure TBottlePrefs.SetBgColor(const Value: TColor);
730 begin
731   FBgColor := Value;
732 end;
733
734 procedure TBottlePrefs.SetConfirmOnExit(const Value: boolean);
735 begin
736   FConfirmOnExit := Value;
737 end;
738
739 procedure TBottlePrefs.SetDblClkInsert(const Value: boolean);
740 begin
741   FDblClkInsert := Value;
742 end;
743
744 procedure TBottlePrefs.SetDefaultScript(const Value: String);
745 begin
746   FDefaultScript.Text := Value;
747 end;
748
749 procedure TBottlePrefs.SetFixMessySurface(const Value: boolean);
750 begin
751   FFixMessySurface := Value;
752 end;
753
754 procedure TBottlePrefs.SetGhostDropDownCount(const Value: integer);
755 begin
756   FGhostDropDownCount := Value;
757 end;
758
759 procedure TBottlePrefs.SetIgnoreFrequentYenS(const Value: boolean);
760 begin
761   FIgnoreFrequentYenS := Value;
762 end;
763
764 procedure TBottlePrefs.SetIgnoreTimeCritical(const Value: boolean);
765 begin
766   FIgnoreTimeCritical := Value;
767 end;
768
769 procedure TBottlePrefs.SetLogWindowDividerPos(const Value: integer);
770 begin
771   FLogWindowDividerPos := Value;
772 end;
773
774 procedure TBottlePrefs.SetLogWindowPosition(const Value: TRect);
775 begin
776   FLogWindowPosition := Value;
777 end;
778
779 procedure TBottlePrefs.SetLUID(const Value: String);
780 begin
781   FLUID := Value;
782 end;
783
784 procedure TBottlePrefs.SetMarkErrorColor(const Value: TColor);
785 begin
786   FMarkErrorColor := Value;
787 end;
788
789 procedure TBottlePrefs.SetTextColor(const Value: TColor);
790 begin
791   FTextColor := Value;
792 end;
793
794 procedure TBottlePrefs.SetMarkUpColor(const Value: TColor);
795 begin
796   FMarkUpColor := Value;
797 end;
798
799 procedure TBottlePrefs.SetMetaWordColor(const Value: TColor);
800 begin
801   FMetaWordColor := Value;
802 end;
803
804 procedure TBottlePrefs.SetNoConfirm(const Value: boolean);
805 begin
806   FNoConfirm := Value;
807 end;
808
809 procedure TBottlePrefs.SetNoDescript(const Value: boolean);
810 begin
811   FNoDescript := Value;
812 end;
813
814 procedure TBottlePrefs.SetNoTranslate(const Value: boolean);
815 begin
816   FNoTranslate := Value;
817 end;
818
819 procedure TBottlePrefs.SetNoTransUrl(const Value: boolean);
820 begin
821   FNoTransUrl := Value;
822 end;
823
824 procedure TBottlePrefs.SetLogWindowPreviewStyle(
825   const Value: TLogWindowPreviewStyle);
826 begin
827   FLogWindowPreviewStyle := Value;
828 end;
829
830 procedure TBottlePrefs.SetProxyAddress(const Value: String);
831 begin
832   FProxyAddress := Value;
833 end;
834
835 procedure TBottlePrefs.SetProxyPort(const Value: integer);
836 begin
837   FProxyPort := Value;
838 end;
839
840 procedure TBottlePrefs.SetResetIfGhostAfterSend(const Value: boolean);
841 begin
842   FResetIfGhostAfterSend := Value;
843 end;
844
845 procedure TBottlePrefs.SetSenderWindowPosition(const Value: TRect);
846 begin
847   FSenderWindowPosition := Value;
848 end;
849
850 procedure TBottlePrefs.SetServerPort(const Value: integer);
851 begin
852   if Value > 0 then FServerPort := Value;
853 end;
854
855 procedure TBottlePrefs.SetShowConstBar(const Value: boolean);
856 begin
857   FShowConstBar := Value;
858 end;
859
860 procedure TBottlePrefs.SetShowToolBar(const Value: boolean);
861 begin
862   FShowToolBar := Value;
863 end;
864
865 procedure TBottlePrefs.SetSilentWhenHidden(const Value: boolean);
866 begin
867   FSilentWhenHidden := Value;
868 end;
869
870 procedure TBottlePrefs.SetStayOnTop(const Value: boolean);
871 begin
872   FStayOnTop := Value;
873 end;
874
875 procedure TBottlePrefs.SetTabPosition(const Value: TTabPosition);
876 begin
877   FTabPosition := Value;
878 end;
879
880 procedure TBottlePrefs.SetTalkColorH(const Value: TColor);
881 begin
882   FTalkColorH := Value;
883 end;
884
885 procedure TBottlePrefs.SetTalkColorU(const Value: TColor);
886 begin
887   FTalkColorU := Value;
888 end;
889
890 procedure TBottlePrefs.SetUseHttpProxy(const Value: boolean);
891 begin
892   FUseHttpProxy := Value;
893 end;
894
895 procedure TBottlePrefs.SetWaitScriptEnd(const Value: integer);
896 begin
897   if Value > 0 then FWaitScriptEnd := Value;
898 end;
899
900 procedure TBottlePrefs.SetWhenCtrlReturn(const Value: TReturnKeyFunction);
901 begin
902   FWhenCtrlReturn := Value;
903 end;
904
905 procedure TBottlePrefs.SetWhenReturn(const Value: TReturnKeyFunction);
906 begin
907   FWhenReturn := Value;
908 end;
909
910 procedure TBottlePrefs.SetWhenShiftReturn(const Value: TReturnKeyFunction);
911 begin
912   FWhenShiftReturn := Value;
913 end;
914
915 procedure TBottlePrefs.SetTalkColorS(const Value: TColor);
916 begin
917   FTalkColorS := Value;
918 end;
919
920 procedure TBottlePrefs.SetLogWindowColumnWidth(const Value: String);
921 begin
922   FLogWindowColumnWidth := Value;
923 end;
924
925 procedure TBottlePrefs.SetClearAfterSend(const Value: boolean);
926 begin
927   FClearAfterSend := Value;
928 end;
929
930 procedure TBottlePrefs.SetAutoJoinChannels(const Value: TStrings);
931 begin
932   FAutoJoinChannels.Assign(Value);
933 end;
934
935 procedure TBottlePrefs.SetFMOName(const Value: TStrings);
936 begin
937   FFMOName.Assign(Value);
938 end;
939
940 procedure TBottlePrefs.SaveSettings;
941 var
942   Strs: TStringList;
943 begin
944   FIni.WriteString('System', 'PartialConfirmFormat', PartialConfirmFormat);
945   FIni.WriteBool('System', 'AutoPartialConfirm', AutoPartialConfirm);
946   FIni.WriteBool('System', 'ConfirmOnExit', ConfirmOnExit);
947   FIni.WriteBool('System', 'ConfirmOnTabClose', ConfirmOnTabClose);
948   FIni.WriteBool('System', 'AutoClip', AutoClip);
949   FIni.WriteBool('System', 'AutoStart', AutoStart);
950   FIni.WriteInteger('System', 'TabPosition', Ord(TabPosition));
951   FIni.WriteInteger('System', 'TabWidth', TabWidth);
952   FIni.WriteInteger('System', 'GhostDropDownCount', GhostDropDownCount);
953
954   FIni.WriteBool('System', 'NoTranslate', NoTranslate);
955   FIni.WriteBool('System', 'NoDescript', NoDescript);
956   FIni.WriteBool('System', 'NoTransUrl', NoTransUrl);
957   FIni.WriteBool('System', 'SilentWhenHidden', SilentWhenHidden);
958   FIni.WriteBool('System', 'FixMessySurface', FixMessySurface);
959   FIni.WriteBool('System', 'HUTagTo01Tag', HUTagTo01Tag);
960   FIni.WriteBool('System', 'ResetIfGhostAfterSend', ResetIfGhostAfterSend);
961   FIni.WriteBool('System', 'ClearAfterSend', ClearAfterSend);
962   FIni.WriteBool('System', 'NeedConfirmBeforeSend', NeedConfirmBeforeSend);
963   FIni.WriteBool('System', 'WarnYenTNotExist', WarnYenTNotExist);
964   FIni.WriteBool('System', 'WarnScopeChangeInSynchronize', WarnScopeChangeInSynchronize);
965
966   FIni.WriteBool('System', 'IgnoreFrequentYenS', IgnoreFrequentYenS);
967   FIni.WriteInteger('System', 'WaitScriptEnd', WaitScriptEnd);
968   FIni.WriteBool('System', 'StayOnTop', StayOnTop);
969   FIni.WriteBool('System', 'NoConfirm', NoConfirm);
970   FIni.WriteBool('System', 'IgnoreTimeCritical', IgnoreTimeCritical);
971   FIni.WriteString('System', 'TalkColorH',     ColorToString(TalkColorH));
972   FIni.WriteString('System', 'TalkColorU',     ColorToString(TalkColorU));
973   FIni.WriteString('System', 'TalkColorS',     ColorToString(TalkColorS));
974   FIni.WriteString('System', 'MarkUpColor',    ColorToString(MarkUpColor));
975   FIni.WriteString('System', 'MetaWordColor',  ColorToString(MetaWordColor));
976   FIni.WriteString('System', 'MarkErrorColor', ColorToString(MarkErrorColor));
977   FIni.WriteString('System', 'TextColor', ColorToString(TextColor));
978
979   Strs := TStringList.Create;
980   try
981     Strs.Text := ComponentToString(FPlayTimeParams);
982     FIni.WriteString('System', 'PlayTimeParams', Strs.CommaText);
983   finally
984     Strs.Free;
985   end;
986
987   FIni.WriteString('System', 'BgColor', ColorToString(BgColor));
988   FIni.WriteBool('System', 'ShowToolBar', ShowToolBar);
989   FIni.WriteBool('System', 'ShowConstBar', ShowConstBar);
990   FIni.WriteString('System', 'DefaultScript', FDefaultScript.CommaText);
991   FIni.WriteBool('System', 'ShowRuler', ShowRuler);
992   FIni.WriteInteger('System', 'WhenReturn', Ord(WhenReturn));
993   FIni.WriteInteger('System', 'WhenShiftReturn', Ord(WhenShiftReturn));
994   FIni.WriteInteger('System', 'WhenCtrlReturn', Ord(WhenCtrlReturn));
995   FIni.WriteInteger('System', 'ServerPort', ServerPort);
996   FIni.WriteString('System', 'LUID', LUID);
997   FIni.WriteString('System', 'AutoJoinChannels', FAutoJoinChannels.CommaText);
998   //
999   FIni.WriteInteger('System', 'SenderWindowPositionLeft', SenderWindowPosition.Left);
1000   FIni.WriteInteger('System', 'SenderWindowPositionTop', SenderWindowPosition.Top);
1001   FIni.WriteInteger('System', 'SenderWindowPositionRight', SenderWindowPosition.Right);
1002   FIni.WriteInteger('System', 'SenderWindowPositionBottom', SenderWindowPosition.Bottom);
1003   FIni.WriteInteger('System', 'LogWindowPositionLeft', LogWindowPosition.Left);
1004   FIni.WriteInteger('System', 'LogWindowPositionTop', LogWindowPosition.Top);
1005   FIni.WriteInteger('System', 'LogWindowPositionRight', LogWindowPosition.Right);
1006   FIni.WriteInteger('System', 'LogWindowPositionBottom', LogWindowPosition.Bottom);
1007   FIni.WriteInteger('System', 'LogWindowDividerPos', LogWindowDividerPos);
1008   FIni.WriteString('System', 'LogWindowColumnWidth', LogWindowColumnWidth);
1009   with EditorPreviewWindowPosition do
1010     FIni.WriteString('System', 'EditorPreviewWindowPosition',
1011       Format('%d,%d,%d,%d', [Left, Top, Right, Bottom]));
1012   //
1013   FIni.WriteBool('System', 'UseHttpProxy', UseHttpProxy);
1014   FIni.WriteString('System', 'ProxyAddress', ProxyAddress);
1015   FIni.WriteInteger('System', 'ProxyPort', ProxyPort);
1016   //
1017   FIni.WriteInteger('System', 'ReconnectWait', ReconnectWait);
1018   //
1019   FIni.WriteInteger('System', 'LogWindowPreviewStyle', Ord(LogWindowPreviewStyle));
1020   FIni.WriteInteger('System', 'LogListPreviewStyle', Ord(LogListPreviewStyle));
1021   FIni.WriteString('System', 'FMOName', FFMOName.CommaText);
1022   FIni.WriteBool('System', 'HideGhosts', HideGhosts);
1023   FIni.WriteString('System', 'VisibleGhostsList', VisibleGhostsList.CommaText);
1024   FIni.WriteBool('System', 'NoExtraSSTPHeaders', NoExtraSSTPHeaders);
1025   //
1026   FIni.WriteBool('System', 'SurfacePreviewOnHint', SurfacePreviewOnHint);
1027   FIni.WriteBool('System', 'SurfacePreviewOnScriptPoint', SurfacePreviewOnScriptPoint);
1028   FIni.WriteInteger('System', 'SurfacePreviewOnScriptPointPosition', Ord(SurfacePreviewOnScriptPointPosition));
1029
1030   FIni.WriteString('System', 'BrowserExeName', FBrowserExeName);
1031
1032   Strs := TStringList.Create;
1033   try
1034     Strs.Text := ComponentToString(FReplacePresets);
1035     Strs.SaveToFile(ReplacePresetFileName);
1036   finally
1037     Strs.Free;
1038   end;
1039 end;
1040
1041 function TBottlePrefs.GetDefaultScript: String;
1042 begin
1043   Result := FDefaultScript.Text;
1044 end;
1045
1046 procedure TBottlePrefs.SetHUTagTo01Tag(const Value: boolean);
1047 begin
1048   FHUTagTo01Tag := Value;
1049 end;
1050
1051 procedure TBottlePrefs.SetWarnScopeChangeInSynchronize(
1052   const Value: boolean);
1053 begin
1054   FWarnScopeChangeInSynchronize := Value;
1055 end;
1056
1057 procedure TBottlePrefs.SetWarnYenTNotExist(const Value: boolean);
1058 begin
1059   FWarnYenTNotExist := Value;
1060 end;
1061
1062 procedure TBottlePrefs.SetNeedConfirmBeforeSend(const Value: boolean);
1063 begin
1064   FNeedConfirmBeforeSend := Value;
1065 end;
1066
1067 procedure TBottlePrefs.SetShowRuler(const Value: boolean);
1068 begin
1069   FShowRuler := Value;
1070 end;
1071
1072 procedure TBottlePrefs.SetHideGhosts(const Value: boolean);
1073 begin
1074   FHideGhosts := Value;
1075 end;
1076
1077 procedure TBottlePrefs.SetVisibleGhostsList(const Value: TStringList);
1078 begin
1079   FVisibleGhostsList.Assign(Value);
1080 end;
1081
1082 procedure TBottlePrefs.SetSurfacePreviewOnHint(const Value: boolean);
1083 begin
1084   FSurfacePreviewOnHint := Value;
1085 end;
1086
1087 procedure TBottlePrefs.SetSurfacePreviewOnScriptPoint(
1088   const Value: boolean);
1089 begin
1090   FSurfacePreviewOnScriptPoint := Value;
1091 end;
1092
1093 procedure TBottlePrefs.SetSurfacePreviewOnScriptPointPosition(
1094   const Value: TSurfacePreviewOnScriptPointPosition);
1095 begin
1096   FSurfacePreviewOnScriptPointPosition := Value;
1097 end;
1098
1099 procedure TBottlePrefs.SetNoExtraSSTPHeaders(const Value: boolean);
1100 begin
1101   FNoExtraSSTPHeaders := Value;
1102 end;
1103
1104 procedure TBottlePrefs.SetLogListPreviewStyle(
1105   const Value: TLogListPreviewStyle);
1106 begin
1107   FLogListPreviewStyle := Value;
1108 end;
1109
1110 procedure TBottlePrefs.SetEditorPreviewWindowPosition(const Value: TRect);
1111 begin
1112   FEditorPreviewWindowPosition := Value;
1113 end;
1114
1115 function TBottlePrefs.InScreen(ARect: TRect): boolean;
1116 var i: integer;
1117     dum: TRect;
1118 begin
1119   Result := false;
1120   for i := 0 to Screen.MonitorCount-1 do
1121   begin
1122     if IntersectRect(dum, ARect, Screen.Monitors[i].WorkareaRect) then
1123     begin
1124       Result := true;
1125       Exit;
1126     end;
1127   end;
1128 end;
1129
1130 procedure TBottlePrefs.SetAutoClip(const Value: boolean);
1131 begin
1132   FAutoClip := Value;
1133 end;
1134
1135 procedure TBottlePrefs.SetConfirmOnTabClose(const Value: boolean);
1136 begin
1137   FConfirmOnTabClose := Value;
1138 end;
1139
1140 procedure TBottlePrefs.SetReconnectWait(const Value: integer);
1141 begin
1142   FReconnectWait := Value;
1143   if Value < 6 then
1144     raise Exception.Create('Reconnect wait must be >=6');
1145 end;
1146
1147 procedure TBottlePrefs.SetPartialConfirmFormat(const Value: String);
1148 begin
1149   FPartialConfirmFormat := Value;
1150 end;
1151
1152 procedure TBottlePrefs.SetAutoPartialConfirm(const Value: boolean);
1153 begin
1154   FAutoPartialConfirm := Value;
1155 end;
1156
1157 procedure TBottlePrefs.SetPlayTimeParams(const Value: TSsPlayTimeParams);
1158 begin
1159   FPlayTimeParams.Assign(Value);
1160 end;
1161
1162 procedure TBottlePrefs.SetTabWidth(const Value: integer);
1163 begin
1164   FTabWidth := Value;
1165 end;
1166
1167 procedure TBottlePrefs.SetBrowserExeName(const Value: string);
1168 begin
1169   FBrowserExeName := Value;
1170 end;
1171
1172 { TChannelListItem }
1173
1174 procedure TChannelListItem.SetGhost(const Value: String);
1175 begin
1176   FGhost := Value;
1177 end;
1178
1179 procedure TChannelListItem.SetInfo(const Value: String);
1180 begin
1181   FInfo := Value;
1182 end;
1183
1184 procedure TChannelListItem.SetMembers(const Value: integer);
1185 begin
1186   FMembers := Value;
1187 end;
1188
1189 procedure TChannelListItem.SetName(const Value: String);
1190 begin
1191   FName := Value;
1192 end;
1193
1194 procedure TChannelListItem.SetNoPost(const Value: boolean);
1195 begin
1196   FNoPost := Value;
1197 end;
1198
1199 procedure TChannelListItem.SetWarnPost(const Value: boolean);
1200 begin
1201   FWarnPost := Value;
1202 end;
1203
1204 { TChannelList }
1205
1206 procedure TChannelList.Clear;
1207 var i: integer;
1208 begin
1209   for i := Self.Count-1 downto 0 do begin
1210     TChannelListItem(Self[i]).Free;
1211   end;
1212   inherited;
1213 end;
1214
1215 function TChannelList.GetChannel(Name: String): TChannelListItem;
1216 var i: integer;
1217 begin
1218   Result := nil;
1219   for i := 0 to Count-1 do
1220     if TChannelListItem(Self[i]).Name = Name then begin
1221       Result := TChannelListItem(Self[i]);
1222       Exit;
1223     end;
1224 end;
1225
1226 function TChannelList.GetChannelItem(Index: integer): TChannelListItem;
1227 begin
1228   Result := TChannelListItem(Self[Index]);
1229 end;
1230
1231 initialization
1232
1233 Classes.RegisterClass(TSsPlayTimeParams);
1234
1235 Pref := TBottlePrefs.Create;
1236 ChannelList := TChannelList.Create;
1237 JoinChannels := TStringList.Create;
1238
1239 finalization
1240
1241 Pref.Free;
1242 ChannelList.Clear;
1243 JoinChannels.Free;
1244 ChannelList.Free;
1245
1246 end.