6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 ComCtrls, ToolWin, StdCtrls, ExtCtrls, SsParser, BottleDef, Menus,
8 Clipbrd, Logs, ShellAPI, Commctrl, DirectSstp, Contnrs, StrUtils,
9 TalkShowFrame, SppList, HtmlOutputConfig, HtmlOutputProgress,
10 SearchLog, IniFiles, BRegExp, RegexUtils;
13 //
\83\8d\83O
\82Ì
\95Û
\91¶
\95û
\96@
14 TSaveLogType = (stLog, stLogWithChannels, stText, stXML);
16 //
\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\83X
\83N
\83\8d\81[
\83\8b\95û
\8cü
17 TLVScrollDir = (lvScrollUp, lvScrollDown);
19 TfrmLog = class(TForm)
21 tbtnClear: TToolButton;
24 StatusBar: TStatusBar;
25 tbtnSaveLog: TToolButton;
26 PopupMenuPreview: TPopupMenu;
28 tbtnVoteMessage: TToolButton;
29 PopupMenuListView: TPopupMenu;
30 mnPopUpVoteMessage: TMenuItem;
31 SaveDialog: TSaveDialog;
34 mnPopUpCopyScript: TMenuItem;
35 PopupMenuSaveLog: TPopupMenu;
37 mnSaveLogChannel: TMenuItem;
38 mnSaveLogScript: TMenuItem;
39 mnSaveLogXML: TMenuItem;
40 ToolButton1: TToolButton;
42 mnPopUpAgreeMessage: TMenuItem;
43 tbtnAgreeMessage: TToolButton;
44 ToolButton2: TToolButton;
45 tbtnPreviewStyle: TToolButton;
46 PopupMenuPreviewStyle: TPopupMenu;
47 mnPreviewStyleConversation: TMenuItem;
48 mnPreviewStyleScript: TMenuItem;
49 mnPreviewStyleScriptWithLineBreak: TMenuItem;
51 tabBottleLog: TTabControl;
53 tbtnDownloadLog: TToolButton;
54 PopupMenuTab: TPopupMenu;
55 mnCloseTab: TMenuItem;
56 tbtnFindBottle: TToolButton;
57 tbtnOpenLog: TToolButton;
58 OpenDialog: TOpenDialog;
59 tbtnInsertCue: TToolButton;
60 mnInsertCue: TMenuItem;
61 PopupMenuListPreviewStyle: TPopupMenu;
62 mnListPreviewStyleNormal: TMenuItem;
63 mnListPreviewStyleTagStripped: TMenuItem;
64 tbtnListPreviewStyle: TToolButton;
65 mnListPreviewStyleNoColor: TMenuItem;
66 SsParserForTalkShow: TSsParser;
67 mnPreviewStyleConversationImage: TMenuItem;
68 pnlPreviewArea: TPanel;
69 TalkShowFrame: TfrmTalkShow;
71 tbtnSendEditor: TToolButton;
72 mnSendEditor: TMenuItem;
73 timScrollTimer: TTimer;
74 mnChangeTabName: TMenuItem;
77 mnDeleteLogItem: TMenuItem;
78 mnTabSaveXMLLog: TMenuItem;
79 mnSaveHTML: TMenuItem;
80 mnPopupCopyGhost: TMenuItem;
81 procedure tbtnClearClick(Sender: TObject);
82 procedure FormCreate(Sender: TObject);
83 procedure lvwLogChange(Sender: TObject; Item: TListItem;
85 procedure lvwLogDblClick(Sender: TObject);
86 procedure lvwLogKeyPress(Sender: TObject; var Key: Char);
87 procedure FormDestroy(Sender: TObject);
88 procedure lvwLogClick(Sender: TObject);
89 procedure mnSaveLogClick(Sender: TObject);
90 procedure lvwLogColumnClick(Sender: TObject; Column: TListColumn);
91 procedure mnPopUpCopyScriptClick(Sender: TObject);
92 procedure mnSaveLogChannelClick(Sender: TObject);
93 procedure mnSaveLogScriptClick(Sender: TObject);
94 procedure mnSaveLogXMLClick(Sender: TObject);
95 procedure lvwLogData(Sender: TObject; Item: TListItem);
96 procedure PopupMenuListViewPopup(Sender: TObject);
97 procedure lvwLogCustomDrawItem(Sender: TCustomListView;
98 Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
99 procedure PopupMenuPreviewStylePopup(Sender: TObject);
100 procedure mnPreviewStyleClick(Sender: TObject);
101 procedure tbtnPreviewStyleClick(Sender: TObject);
102 procedure tabBottleLogChange(Sender: TObject);
103 procedure tabBottleLogChanging(Sender: TObject;
104 var AllowChange: Boolean);
105 procedure tabBottleLogContextPopup(Sender: TObject; MousePos: TPoint;
106 var Handled: Boolean);
107 procedure mnCloseTabClick(Sender: TObject);
108 procedure tbtnFindBottleClick(Sender: TObject);
109 procedure tbtnOpenLogClick(Sender: TObject);
110 procedure tabBottleLogMouseDown(Sender: TObject; Button: TMouseButton;
111 Shift: TShiftState; X, Y: Integer);
112 procedure tabBottleLogDragOver(Sender, Source: TObject; X, Y: Integer;
113 State: TDragState; var Accept: Boolean);
114 procedure tabBottleLogDragDrop(Sender, Source: TObject; X, Y: Integer);
115 procedure tabBottleLogEndDrag(Sender, Target: TObject; X, Y: Integer);
116 procedure lvwLogDrawItem(Sender: TCustomListView; Item: TListItem;
117 Rect: TRect; State: TOwnerDrawState);
118 procedure mnListPreviewStyleClick(Sender: TObject);
119 procedure tbtnListPreviewStyleClick(Sender: TObject);
120 procedure PopupMenuListPreviewStylePopup(Sender: TObject);
121 procedure lvwLogDragOver(Sender, Source: TObject; X, Y: Integer;
122 State: TDragState; var Accept: Boolean);
123 procedure lvwLogDragDrop(Sender, Source: TObject; X, Y: Integer);
124 procedure timScrollTimerTimer(Sender: TObject);
125 procedure mnChangeTabNameClick(Sender: TObject);
126 procedure lvwLogStartDrag(Sender: TObject;
127 var DragObject: TDragObject);
128 procedure lvwLogEndDrag(Sender, Target: TObject; X, Y: Integer);
129 procedure mnTabSaveXMLLogClick(Sender: TObject);
130 procedure mnSaveHTMLClick(Sender: TObject);
131 procedure mnPopupCopyGhostClick(Sender: TObject);
134 FLastScript: String; //
\83X
\83N
\83\8a\83v
\83g
\8dÄ
\95`
\89æ
\97}
\90§
\97p
135 FBottleLogList: TObjectList;
137 FDragTabIndex: integer; //
\83^
\83u
\83h
\83\89\83b
\83O
\83h
\83\8d\83b
\83v
\8aÖ
\98A
138 FDragTabDest: integer; //
\83h
\83\8d\83b
\83v
\82·
\82é
\88Ê
\92u(
\82·
\82®
\89E
\82É
\82
\82é
\83^
\83u
\82Ì
\83C
\83\93\83f
\83b
\83N
\83X)
140 //
\83\8a\83X
\83g
\83r
\83\85\81[
\83h
\83\89\83b
\83O
\83h
\83\8d\83b
\83v
\8aÖ
\98A
141 FLVScrollDir: TLVScrollDir; //
\83X
\83N
\83\8d\81[
\83\8b\95û
\8cü
142 FLVDragDest: integer; //
\83h
\83\8d\83b
\83v
\82·
\82é
\88Ê
\92u(
\82·
\82®
\89º
\82É
\82
\82é
\83A
\83C
\83e
\83\80\82ÌIndex)
144 procedure UpdateScript(const Script: String);
145 procedure UpdateScriptConversationColor(const Script: String);
146 procedure UpdateScriptScript(const Script: String);
147 procedure mnURLClick(Sender: TObject);
148 procedure ExtractURLs(Script: String; Result: TStrings);
149 function GetDefaultFileName(const Name: String; const Ext: String): String;
150 function BottleLogTitled(const LogName: String): TBottleLogList;
151 procedure DrawSingleLineScript(LogItem: TLogItem; Rect: TRect;
153 procedure PreviewStyleChange;
154 procedure DrawListViewDragBorder(const Rect: TRect);
155 procedure DoSaveLogXML(Log: TBottleLogList);
156 procedure DoCloseTab(const Index: integer);
157 function DoSearchLog(Condition: TSearchCond): TBottleLogList;
158 procedure SearchLogIndivisual(Condition: TSearchCond;
159 LogList, Result: TBottleLogList; UntilIndex: integer = -1);
161 procedure CreateParams(var Params: TCreateParams); override;
164 function SelectedBottleLog: TBottleLogList;
165 property BottleLogList: TObjectList read FBottleLogList;
166 procedure AddCurrentScriptLog(const LogName, Script, Channel, MID, Ghost: String);
167 procedure AddCurrentSystemLog(const LogName, MessageString: String);
168 procedure VoteLog(const MID: String; const Vote: integer);
169 procedure AgreeLog(const MID: String; const Agree: integer);
170 procedure SetBottleState(const MID: String; State: TLogState);
171 procedure AllBottleOpened;
172 procedure LogLoaded(Sender: TObject);
173 procedure LogLoadFailure(Sender: TObject; const Message: String);
174 procedure LogLoadWork(Sender: TObject);
175 procedure HTMLOutputWork(Sender: TObject; const Count: integer;
176 var Canceled: boolean);
178 procedure UpdateWindow;
179 procedure SelAndFocusMessage(const MID: String);
182 TBottleLogDragObject = class(TDragControlObjectEx)
184 FBottleLogList: TBottleLogList;
186 procedure SetBottleLogList(const Value: TBottleLogList);
187 procedure SetLogItem(const Value: TLogItem);
189 function GetDragImages: TDragImageList; override;
191 property BottleLogList: TBottleLogList read FBottleLogList write SetBottleLogList;
192 property LogItem: TLogItem read FLogItem write SetLogItem;
218 procedure TfrmLog.AddCurrentScriptLog(const LogName, Script, Channel, MID, Ghost: String);
221 BottleLogTitled(LogName).AddScriptLog(Script, Channel, MID, Ghost);
222 if SelectedBottleLog <> BottleLogTitled(LogName) then Exit;
223 lvwLog.OnChange := nil; //
\83C
\83x
\83\93\83g
\94
\90¶(
\82¢
\82ë
\82¢
\82ë
\8dÄ
\95`
\89æ
\82ª
\8bN
\82«
\82é)
\82Ì
\97}
\90§
224 if lvwLog.Selected <> nil then Sel := lvwLog.Selected.Index else Sel := -1;
225 lvwLog.Items.Count := SelectedBottleLog.Count;
227 if Sel >= 0 then begin
228 lvwLog.Selected := lvwLog.Items[Sel + 1];
229 lvwLog.Selected.Focused := true;
231 if not lvwLog.Focused then
232 ListView_Scroll(lvwLog.Handle, 0, High(integer));
233 lvwLog.OnChange := lvwLogChange;
236 procedure TfrmLog.AddCurrentSystemLog(const LogName, MessageString: String);
239 BottleLogTitled(LogName).AddSystemLog(MessageString);
240 if SelectedBottleLog <> BottleLogTitled(LogName) then Exit;
241 lvwLog.OnChange := nil;
242 if lvwLog.Selected <> nil then Sel := lvwLog.Selected.Index else Sel := -1;
243 lvwLog.Items.Count := SelectedBottleLog.Count;
245 if Sel >= 0 then begin
246 lvwLog.Selected := lvwLog.Items[Sel + 1];
247 lvwLog.Selected.Focused := true;
249 if not lvwLog.Focused then
250 ListView_Scroll(lvwLog.Handle, 0, High(integer));
251 lvwLog.OnChange := lvwLogChange;
256 procedure TfrmLog.tbtnClearClick(Sender: TObject);
258 if SelectedBottleLog = nil then Exit;
259 DoCloseTab(tabBottleLog.TabIndex);
262 procedure TfrmLog.FormCreate(Sender: TObject);
265 FLVDragDest := -1; //
\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\83h
\83\89\83b
\83O
\92\86\82Å
\82Í
\82È
\82¢
266 FBottleLogList := TObjectList.Create;
268 SsParser.TagPattern.Assign(frmSender.SsParser.TagPattern);
269 SsParser.MetaPattern.Assign(frmSender.SsParser.MetaPattern);
271 with Pref.LogWindowPosition do begin
274 Self.Width := Right - Left + 1;
275 Self.Height := Bottom - Top + 1;
277 lvwLog.DoubleBuffered := true;
278 pnlPreviewArea.Height := Pref.LogWindowDividerPos;
281 while Token(Pref.LogWindowColumnWidth, ',', i) <> '' do begin
282 lvwLog.Columns[i].Width := StrToIntDef(Token(Pref.LogWindowColumnWidth, ',', i), 100);
286 SsParserForTalkShow.TagPattern.Assign(SsParser.TagPattern);
287 SsParserForTalkShow.MetaPattern.Assign(SsParser.MetaPattern);
288 SsParserForTalkShow.EscapeInvalidMeta := false;
289 SsParserForTalkShow.LeaveEscape := false;
290 TalkShowFrame.SsParser := self.SsParserForTalkShow;
292 TalkShowFrame.SetPreviewFont(edtScript.Font);
293 TalkShowFrame.PrevControl := lvwLog;
296 UpdateWindow; // Reset window color and enabled status of some buttons
299 procedure TfrmLog.FormDestroy(Sender: TObject);
304 for i := 0 to lvwLog.Columns.Count-1 do begin
305 if i > 0 then WidthStr := WidthStr + ',';
306 WidthStr := WidthStr + IntToStr(lvwLog.Column[i].Width);
308 Pref.LogWindowColumnWidth := WidthStr;
310 with Pref.LogWindowPosition do begin
313 Right := Self.Left + Self.Width - 1;
314 Bottom := Self.Top + Self.Height - 1;
316 Pref.LogWindowDividerPos := pnlPreviewArea.Height;
318 FreeAndNil(FBottleLogList);
321 procedure TfrmLog.lvwLogChange(Sender: TObject; Item: TListItem;
322 Change: TItemChange);
323 var Script, Text: String;
325 Selected, IsNormalBottle: boolean;
328 IsNormalBottle := false;
329 if SelectedBottleLog <> nil then begin
330 if Change = ctState then begin
332 if lvwLog.Selected <> nil then begin
334 StatusBar.Panels[0].Text := Format('%d/%d
\8c\8f', [lvwLog.Selected.Index+1,
335 SelectedBottleLog.Count]);
336 Log := SelectedBottleLog.Bottles[lvwLog.Selected.Index];
337 if (Log.LogType = ltBottle) and not frmSender.Connecting then begin
338 IsNormalBottle := true;
339 Script := Log.Script;
340 Text := Format('%d
\83o
\83C
\83g/%d
\95b -
\83_
\83u
\83\8b\83N
\83\8a\83b
\83N
\82Å
\8dÄ
\90¶',
341 [Length(Log.Script), frmSender.SsPlayTime.PlayTime(Log.Script) div 1000]);
342 StatusBar.Panels[1].Text := Text;
343 if Pref.LogWindowPreviewStyle = psImageConversation then
344 TalkShowFrame.View(Log)
346 UpdateScript(Script);
348 StatusBar.Panels[1].Text := '';
349 UpdateScript(''); //
\83\8d\83O
\83v
\83\8c\83r
\83\85\81[
\95\94\82ð
\83N
\83\8a\83A
352 StatusBar.Panels[0].Text := IntToStr(SelectedBottleLog.Count) + '
\8c\8f';
353 StatusBar.Panels[1].Text := '';
354 UpdateScript(Script); //
\83\8d\83O
\83v
\83\8c\83r
\83\85\81[
\95\94\83N
\83\8a\83A
357 tbtnSaveLog.Enabled := lvwLog.Items.Count > 0;
359 StatusBar.Panels[0].Text := '';
360 UpdateScript(''); //
\83\8d\83O
\83v
\83\8c\83r
\83\85\81[
\95\94\83N
\83\8a\83A
362 frmSender.actVoteMessage.Enabled := Selected and IsNormalBottle;
363 frmSender.actAgreeMessage.Enabled := Selected and IsNormalBottle;
364 frmSender.actSendToEditor.Enabled := Selected and IsNormalBottle;
365 frmSender.actInsertCue.Enabled := Selected;
366 frmSender.actDeleteLogItem.Enabled := Selected;
367 mnPopUpCopyScript.Enabled := Selected and IsNormalBottle;
368 mnPopupCopyGhost.Enabled := Selected and IsNormalBottle;
371 procedure TfrmLog.lvwLogDblClick(Sender: TObject);
372 var Script, ErrorMes: String;
373 Log, CueItem: TLogItem;
376 if lvwLog.Selected = nil then
378 Log := SelectedBottleLog.Bottles[lvwLog.Selected.Index];
379 if Log = nil then Exit;
380 if Log.LogType <> ltBottle then
382 Script := frmSender.ScriptTransForSSTP(Log.Script, ErrorMes);
383 if ErrorMes <> '' then
385 Res := MessageDlg('
\96â
\91è
\82Ì
\82 \82é
\83X
\83N
\83\8a\83v
\83g
\82Å
\82·
\81B
\8dÄ
\90¶
\82Å
\82«
\82Ü
\82¹
\82ñ
\81B'#13#10+
387 '
\8b
\90§
\93I
\82É
\8dÄ
\90¶
\82µ
\82Ü
\82·
\82©?'#13#10,
388 mtWarning, mbOkCancel, 0
390 if Res = mrCancel then
394 CueItem := TLogItem.Create(Log);
396 CueItem.Script := Script;
397 frmSender.BottleSstp.Unshift(CueItem);
403 procedure TfrmLog.UpdateScriptConversationColor(const Script: String);
406 UnyuTalking, Talked, InSynchronized: boolean;
409 frmSender.DoTrans(scr, [toConvertURL]);
410 SsParser.LeaveEscape := false;
411 SsParser.InputString := scr;
412 UnyuTalking := false;
413 Talked := false; //'\h\u\h\u'
\82Ì
\82æ
\82¤
\82È
\83X
\83N
\83\8a\83v
\83g
\82Å
\8bó
\82«
\8ds
\82ð
\8dì
\82ç
\82È
\82¢
\82½
\82ß
\82Ì
\91[
\92u
414 InSynchronized := false;
415 edtScript.Text := '';
416 edtScript.Color := Pref.BgColor;
417 for i := 0 to SsParser.Count-1 do begin
418 if (SsParser[i] = '\_s') and not InSynchronized then begin
419 InSynchronized := true;
421 edtScript.SelText := #13#10;
424 end else if (SsParser[i] = '\_s') and InSynchronized then begin
425 InSynchronized := false;
427 edtScript.SelText := #13#10;
431 if (SsParser[i] = '\u') and not UnyuTalking then begin
434 edtScript.SelText := #13#10;
438 if (SsParser[i] = '\h') and UnyuTalking then begin
439 UnyuTalking := false;
441 edtScript.SelText := #13#10;
445 if SsParser.MarkUpType[i] = mtStr then begin
446 if InSynchronized then
447 edtScript.SelAttributes.Color := Pref.TalkColorS
448 else if UnyuTalking then
449 edtScript.SelAttributes.Color := Pref.TalkColorU
451 edtScript.SelAttributes.Color := Pref.TalkColorH;
452 edtScript.SelText := SsParser[i];
455 if SsParser.MarkUpType[i] = mtMeta then begin
456 edtScript.SelAttributes.Color := Pref.MetaWordColor;
457 edtScript.SelText := SsParser[i];
463 procedure TfrmLog.lvwLogKeyPress(Sender: TObject; var Key: Char);
465 if Key = #13 then lvwLogDblClick(Sender);
468 procedure TfrmLog.CreateParams(var Params: TCreateParams);
471 Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
474 procedure TfrmLog.lvwLogClick(Sender: TObject);
476 //
\89E
\83N
\83\8a\83b
\83N
\82Å
\83\81\83j
\83\85\81[
\8fo
\82·
\82Æ
\82«
\82É
\94
\90¶
\82·
\82é
\95s
\8bï
\8d\87\91Î
\8dô
478 Selected := Selected;
481 procedure TfrmLog.lvwLogColumnClick(Sender: TObject; Column: TListColumn);
482 var SortType: TBottleLogSortType;
486 if SelectedBottleLog = nil then
488 if lvwLog.Selected <> nil then
489 SelectedMID := SelectedBottleLog.Bottles[lvwLog.Selected.Index].MID
493 SortColumn := Column.Index;
495 -1: SortType := stLogTime;
496 subChannel: SortType := stChannel;
497 subGhost: SortType := stGhost;
498 subVotes: SortType := stVote;
499 subAgrees: SortType := stAgree;
500 subScript: SortType := stScript;
502 SortType := stLogTime;
505 SelectedBottleLog.SortBottles(SortType);
507 if Length(SelectedMID) > 0 then
508 SelAndFocusMessage(SelectedMID);
512 procedure TfrmLog.mnPopUpCopyScriptClick(Sender: TObject);
517 Log := SelectedBottleLog.Bottles[frmLog.lvwLog.Selected.Index];
518 if Log = nil then Exit;
520 Clip.SetTextBuf(PChar(Log.Script));
523 procedure TfrmLog.SetBottleState(const MID: String; State: TLogState);
527 for i := 0 to FBottleLogList.Count-1 do begin
528 Bottle := (FBottleLogList[i] as TBottleLogList).Bottle(MID);
529 if Bottle <> nil then begin
530 Bottle.State := State;
531 lvwLog.OnChange := nil;
533 lvwLog.OnChange := lvwLogChange;
538 procedure TfrmLog.mnSaveLogClick(Sender: TObject);
540 if SelectedBottleLog = nil then Exit;
541 SaveDialog.FileName := GetDefaultFileName(SelectedBottleLog.Title, '.log');
542 SaveDialog.InitialDir := ExtractFileDir(Application.ExeName);
543 SaveDialog.DefaultExt := 'log';
544 SaveDialog.FilterIndex := 1;
545 if SaveDialog.Execute then
546 SelectedBottleLog.SaveToSstpLog(SaveDialog.FileName, false);
549 procedure TfrmLog.mnSaveLogChannelClick(Sender: TObject);
551 if SelectedBottleLog = nil then Exit;
552 SaveDialog.FileName := GetDefaultFileName(SelectedBottleLog.Title, '.log');
553 SaveDialog.InitialDir := ExtractFileDir(Application.ExeName);
554 SaveDialog.DefaultExt := 'log';
555 SaveDialog.FilterIndex := 1;
556 if SaveDialog.Execute then
557 SelectedBottleLog.SaveToSstpLog(SaveDialog.FileName, true);
560 procedure TfrmLog.mnSaveLogScriptClick(Sender: TObject);
562 if SelectedBottleLog = nil then Exit;
563 SaveDialog.FileName := GetDefaultFileName(SelectedBottleLog.Title, '.txt');
564 SaveDialog.InitialDir := ExtractFileDir(Application.ExeName);
565 SaveDialog.DefaultExt := 'txt';
566 SaveDialog.FilterIndex := 2;
567 if SaveDialog.Execute then
568 SelectedBottleLog.SaveToText(SaveDialog.FileName);
571 procedure TfrmLog.mnSaveLogXMLClick(Sender: TObject);
573 if SelectedBottleLog = nil then Exit;
574 DoSaveLogXML(SelectedBottleLog);
577 procedure TfrmLog.lvwLogData(Sender: TObject; Item: TListItem);
581 if Item = nil then Exit;
583 Log := SelectedBottleLog.Bottles[i];
585 Caption := FormatDateTime('yy/mm/dd hh:nn:ss', Log.LogTime);
587 SubItems.Add(Log.Channel);
588 SubItems.Add(Log.Ghost);
589 if Log.LogType = ltBottle then begin
590 if Log.Votes > 0 then
591 SubItems.Add(IntToStr(Log.Votes))
594 if Log.Agrees > 0 then
595 SubItems.Add(IntToStr(Log.Agrees))
599 //
\83V
\83X
\83e
\83\80\83\8d\83O
\82È
\82Ç
\82Í
\93\8a\95[
\81E
\93¯
\88Ó
\82ð
\95\
\8e¦
\82µ
\82È
\82¢
603 SubItems.Add(Log.Script);
605 if Log.LogType = ltBottle then begin
607 lsUnopened: ImageIndex := IconBottle;
608 lsPlaying: ImageIndex := IconPlaying;
609 lsOpened: ImageIndex := IconOpened;
612 ImageIndex := IconSystemLog;
616 procedure TfrmLog.UpdateWindow;
617 var EnabledFlag: boolean;
619 lvwLog.Color := Pref.BgColor;
620 lvwLog.Font.Color := Pref.TextColor;
621 if SelectedBottleLog <> nil then begin
622 Caption := '
\83\8d\83O - ' + SelectedBottleLog.Title;
623 StatusBar.Panels[0].Text := IntToStr(SelectedBottleLog.Count) + '
\8c\8f';
624 lvwLog.Items.Count := SelectedBottleLog.Count;
626 Caption := '
\83\8d\83O';
627 StatusBar.Panels[0].Text := '';
628 StatusBar.Panels[1].Text := '';
629 lvwLog.Items.Count := 0;
632 EnabledFlag := SelectedBottleLog <> nil;
633 tbtnClear.Enabled := EnabledFlag;
634 tbtnSaveLog.Enabled := EnabledFlag;
635 tbtnFindBottle.Enabled := EnabledFlag;
640 procedure TfrmLog.PopupMenuListViewPopup(Sender: TObject);
646 for i := mnJumpURL.Count-1 downto 0 do begin
647 mnJumpURL.Items[i].Free;
649 mnJumpURL.Enabled := false;
650 if lvwLog.Selected = nil then Exit;
651 Log := SelectedBottleLog.Bottles[lvwLog.Selected.Index];
652 if Log = nil then Exit;
653 Urls := TStringList.Create;
655 ExtractURLs(Log.Script, Urls);
656 for i := 0 to Urls.Count-1 do begin
657 Child := TMenuItem.Create(Self);
659 Caption := Format('(&%d) %s', [i+1, StringReplace(Urls[i], '&', '&&', [rfReplaceAll])]);
661 OnClick := mnURLClick;
662 AutoHotkeys := maManual;
663 mnJumpURL.Add(Child);
666 mnJumpURL.Enabled := Urls.Count > 0;
672 procedure TfrmLog.mnURLClick(Sender: TObject);
673 var LogItem: TLogItem;
679 if (lvwLog.Selected = nil) or (SelectedBottleLog = nil) then Exit;
680 LogItem := SelectedBottleLog[lvwLog.Selected.Index] as TLogItem;
681 Urls := TStringList.Create;
683 ExtractURLs(LogItem.Script, Urls);
684 URL := Urls[(Sender as TMenuItem).Tag];
685 if Pref.BrowserExeName='' then
687 ShellExecute(Handle, 'open', PChar(URL), nil, nil, SW_SHOW);
690 Command := Pref.BrowserExeName+' '+URL;
691 WinExec(PChar(Command), SW_SHOW);
699 procedure TfrmLog.ExtractURLs(Script: String; Result: TStrings);
700 var i, u, j: integer;
704 SsParser.InputString := Script;
705 SsParser.LeaveEscape := true;
706 for i := 0 to SsParser.Count-1 do begin
707 if (SsParser.Match(SsParser[i], '\URL%b') > 0)
708 and (SsParser.MarkUpType[i] = mtTag) then
710 for u := 7 downto 1 do begin
711 if (SsParser.Match(SsParser[i],
712 '\URL%b'+StringReplace(StringOfChar('-', u*2),
713 '-', '%b', [rfReplaceAll]))) > 0 then begin
714 for j := 1 to u do begin
715 s := SsParser.GetParam(SsParser[i], j*2);
716 if Pos('http://', s) > 0 then Result.Add(s);
721 if SsParser.Match(SsParser[i], '\URL%b%b') = 0 then begin //
\8aÈ
\88Õ
\94ÅURL
\95Ï
\8a·
722 //
\8aÈ
\88Õ
\8c`
\8e®\URL
\83^
\83O
\95Ï
\8a·
723 s := SsParser.GetParam(SsParser[i], 1);
724 if Pos('http://', s) > 0 then Result.Add(s);
730 procedure TfrmLog.SelAndFocusMessage(const MID: String);
734 for i := 0 to SelectedBottleLog.Count-1 do begin
735 Log := SelectedBottleLog.Items[i] as TLogItem;
736 if Log.MID = MID then begin
737 lvwLog.Items[i].Selected := true;
738 lvwLog.Items[i].Focused := true;
743 procedure TfrmLog.lvwLogCustomDrawItem(Sender: TCustomListView;
744 Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
749 procedure TfrmLog.UpdateScript(const Script: String);
751 if Script <> FLastScript then begin
752 if Pref.LogWindowPreviewStyle = psConversation then begin
753 UpdateScriptConversationColor(Script);
755 UpdateScriptScript(Script);
757 SendMessage(edtScript.Handle, EM_LINESCROLL, Low(integer), Low(integer)); //
\83X
\83N
\83\8d\81[
\83\8b\96ß
\82µ
758 FLastScript := Script;
762 procedure TfrmLog.PopupMenuPreviewStylePopup(Sender: TObject);
765 with PopupMenuPreviewStyle do
766 for i := 0 to Items.Count-1 do
767 Items[i].Checked := Items[i].Tag = Ord(Pref.LogWindowPreviewStyle)
770 procedure TfrmLog.mnPreviewStyleClick(Sender: TObject);
773 with PopupMenuPreviewStyle do
774 for i := 0 to Items.Count-1 do
775 Items[i].Checked := (Sender as TMenuItem).Tag = Items[i].Tag;
776 Pref.LogWindowPreviewStyle := TLogWindowPreviewStyle((Sender as TMenuItem).Tag);
779 lvwLogChange(self, lvwLog.Selected, ctState);
782 procedure TfrmLog.UpdateScriptScript(const Script: String);
784 UnyuTalking, InSynchronized: boolean;
787 edtScript.Color := Pref.BgColor;
788 SsParser.LeaveEscape := true;
789 SsParser.InputString := Script;
790 edtScript.Text := '';
791 edtScript.SelAttributes.Color := clWindowText;
792 UnyuTalking := false;
793 InSynchronized := false;
794 for i := 0 to SsParser.Count-1 do begin
795 case SsParser.MarkUpType[i] of
797 if InSynchronized then
798 edtScript.SelAttributes.Color := Pref.TalkColorS
799 else if UnyuTalking then
800 edtScript.SelAttributes.Color := Pref.TalkColorU
802 edtScript.SelAttributes.Color := Pref.TalkColorH;
805 edtScript.SelAttributes.Color := Pref.MarkUpColor;
806 if SsParser[i] = '\h' then
808 else if SsParser[i] = '\u' then
810 else if SsParser[i] = '\_s' then
811 InSynchronized := not InSynchronized;
813 mtMeta: edtScript.SelAttributes.Color := Pref.MetaWordColor;
814 mtTagErr: edtScript.SelAttributes.Color := Pref.MarkErrorColor;
816 edtScript.SelText := SsParser[i];
817 if (SsParser[i] = '\n') and (Pref.LogWindowPreviewStyle = psScriptWithLineBreak) then
818 edtScript.SelText := #13#10;
822 procedure TfrmLog.tbtnPreviewStyleClick(Sender: TObject);
825 sel := Ord(Pref.LogWindowPreviewStyle);
827 if sel > Ord(High(TLogWindowPreviewStyle)) then sel := 0;
828 Pref.LogWindowPreviewStyle := TLogWindowPreviewStyle(sel);
831 lvwLogChange(self, lvwLog.Selected, ctState);
834 function TfrmLog.SelectedBottleLog: TBottleLogList;
836 if tabBottleLog.TabIndex >= 0 then
837 Result := FBottleLogList.Items[tabBottleLog.TabIndex] as TBottleLogList
842 procedure TfrmLog.tabBottleLogChange(Sender: TObject);
844 // StatusBar
\82Ì
\8c\8f\90\94\95\
\8e¦
\82âListView.Items.Count
\82ð
\8dX
\90V
\82·
\82é
846 //
\83A
\83C
\83e
\83\80\82Ì
\91I
\91ð
\8fó
\91Ô
\82ð
\95\9c\8bA
\82·
\82é
847 with SelectedBottleLog do
848 if (SelectedIndex >= 0) and (Count > SelectedIndex) then
850 lvwLog.Items[SelectedIndex].Selected := true;
851 if lvwLog.Focused then lvwLog.Selected.Focused := true;
853 lvwLogChange(Self, nil, ctState);
856 procedure TfrmLog.LogLoaded(Sender: TObject);
858 if SelectedBottleLog = Sender then begin
863 procedure TfrmLog.UpdateTab;
866 cur := tabBottleLog.tabIndex;
867 tabBottleLog.Tabs.Clear;
868 for i := 0 to FBottleLogList.Count - 1 do begin
869 tabBottleLog.Tabs.Add((FBottleLogList[i] as TBottleLogList).Title);
871 if FBottleLogList.Count > 0 then begin
872 if cur < FBottleLogList.Count then
873 tabBottleLog.TabIndex := cur
875 tabBottleLog.TabIndex := FBottleLogList.Count-1;
879 procedure TfrmLog.LogLoadFailure(Sender: TObject; const Message: String);
882 ShowMessage(Message);
883 if Sender = SelectedBottleLog then UpdateWindow;
886 procedure TfrmLog.AgreeLog(const MID: String; const Agree: integer);
891 for i := 0 to FBottleLogList.Count - 1 do begin
892 if (FBottleLogList[i] as TBottleLogList).Bottle(MID) <> nil then begin
893 (FBottleLogList[i] as TBottleLogList).Bottle(MID).Agrees := Agree;
897 if flag then lvwLog.Invalidate;
900 procedure TfrmLog.VoteLog(const MID: String; const Vote: integer);
905 for i := 0 to FBottleLogList.Count - 1 do begin
906 if (FBottleLogList[i] as TBottleLogList).Bottle(MID) <> nil then begin
907 (FBottleLogList[i] as TBottleLogList).Bottle(MID).Votes := Vote;
911 if flag then lvwLog.Invalidate;
914 procedure TfrmLog.tabBottleLogChanging(Sender: TObject;
915 var AllowChange: Boolean);
917 //
\8c»
\8dÝ
\91I
\91ð
\82³
\82ê
\82Ä
\82¢
\82é
\83\8d\83O
\82Ì
\91I
\91ð
\8fó
\91Ô
\82ð
\95Û
\91¶
918 if SelectedBottleLog = nil then Exit;
919 if lvwLog.Selected <> nil then
920 SelectedBottleLog.SelectedIndex := lvwLog.Selected.Index
922 SelectedBottleLog.SelectedIndex := -1;
925 procedure TfrmLog.tabBottleLogContextPopup(Sender: TObject;
926 MousePos: TPoint; var Handled: Boolean);
928 with tabBottleLog do begin
929 Tag := IndexOfTabAt(MousePos.X, MousePos.Y);
930 if Tag < 0 then Handled := true;
934 procedure TfrmLog.mnCloseTabClick(Sender: TObject);
936 DoCloseTab(tabBottleLog.Tag);
939 procedure TfrmLog.tbtnFindBottleClick(Sender: TObject);
940 var ResultLog: TBottleLogList;
943 CList, GList: THashedStringList;
945 Application.CreateForm(TfrmSearchLog, frmSearchLog);
946 Cond := TSearchCond.Create(nil);
951 //
\8c»
\8dÝ
\83\8d\83O
\82É
\82 \82é
\83S
\81[
\83X
\83g
\82Æ
\83`
\83\83\83\93\83l
\83\8b\82Ì
\83\8a\83X
\83g
\82ð
\8eæ
\93¾
952 //
\8fd
\82½
\82¢
\82©
\82à??
953 CList := THashedStringList.Create;
954 GList := THashedStringList.Create;
956 for i := 0 to BottleLogList.Count-1 do
958 with BottleLogList[i] as TBottleLogList do
960 ExtractUniqueChannels(CList);
961 ExtractUniqueGhosts(GList);
966 ChannelList := CList;
975 Cond.Assign(Condition);
978 frmSearchLog.Release;
980 //
\8c\9f\8dõ
\8eÀ
\8ds
981 ResultLog := DoSearchLog(Cond);
982 //
\90V
\83^
\83u
\82ð
\8dì
\90¬
\82µ
\82Ä
\89æ
\96Ê
\8dX
\90V
983 BottleLogList.Add(ResultLog);
985 tabBottleLog.TabIndex := BottleLogList.Count-1;
992 procedure TfrmLog.tbtnOpenLogClick(Sender: TObject);
993 var BottleLog: TBottleLogList;
997 if OpenDialog.Execute then begin
998 for i := 0 to OpenDialog.Files.Count-1 do begin
999 BottleLog := TBottleLogList.Create(ExtractFileName(OpenDialog.Files[i]));
1003 OnLoaded := LogLoaded;
1004 OnLoadFailure := LogLoadFailure;
1005 OnLoadWork := LogLoadWork;
1006 BottleLog.LoadFromXMLFile(OpenDialog.Files[i]);
1008 Index := BottleLogList.Add(BottleLog); //
\8dÅ
\8cã
\82É
\8aJ
\82¢
\82½
\83\8d\83O
\82Ì
\88Ê
\92u
\82ð
\8bL
\89¯
1014 if Index >= 0 then tabBottleLog.TabIndex := Index;
1019 function TfrmLog.GetDefaultFileName(const Name, Ext: String): String;
1021 Result := StringReplace(Name, '/', '', [rfReplaceAll]);
1022 Result := StringReplace(Result, ' ', '', [rfReplaceAll]);
1023 Result := SafeFileName(Result);
1024 Result := ChangeFileExt(Result, Ext);
1027 function TfrmLog.BottleLogTitled(const LogName: String): TBottleLogList;
1030 for i := 0 to FBottleLogList.Count-1 do begin
1031 if (FBottleLogList[i] as TBottleLogList).Title = LogName then begin
1032 Result := (FBottleLogList[i] as TBottleLogList);
1036 //
\8c©
\82Â
\82©
\82ç
\82È
\82¢
\8fê
\8d\87
1037 Result := TBottleLogList.Create(LogName); //
\90V
\82µ
\82
\8dì
\82é
1038 FBottleLogList.Add(Result);
1040 if FBottleLogList.Count = 1 then tabBottleLog.TabIndex := 0;
1043 procedure TfrmLog.AllBottleOpened;
1045 Log: TBottleLogList;
1047 for i := 0 to FBottleLogList.Count-1 do begin
1048 Log := FBottleLogList[i] as TBottleLogList;
1049 for j := 0 to Log.Count-1 do begin
1050 Log.Bottles[j].State := lsOpened;
1055 procedure TfrmLog.tabBottleLogMouseDown(Sender: TObject;
1056 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
1059 with tabBottleLog do begin
1060 Index := IndexOfTabAt(X, Y);
1061 if Index = -1 then Exit; //
\83^
\83u
\82ª
\82È
\82¢
\82Ì
\82Å
\83h
\83\89\83b
\83O
\82Å
\82«
\82È
\82¢
1062 if Button = mbLeft then begin
1063 FDragTabIndex := Index; //
\83h
\83\89\83b
\83O
\82·
\82é
\83^
\83u
\82Ì
\83C
\83\93\83f
\83b
\83N
\83X
\82ð
\95Û
\91¶
1065 FDragTabDest := -1; //
\83h
\83\89\83b
\83O
\98g
\90ü
\95`
\89æ
\83t
\83\89\83O
\83N
\83\8a\83A
\82Ì
\82½
\82ß
1070 procedure TfrmLog.tabBottleLogDragOver(Sender, Source: TObject; X,
1071 Y: Integer; State: TDragState; var Accept: Boolean);
1072 var TargetRect: TRect;
1073 OldDest, Index: integer;
1076 //
\83^
\83u
\82Ì
\83h
\83\89\83b
\83O(
\83^
\83u
\82Ì
\8f\87\94Ô
\93ü
\82ê
\91Ö
\82¦)
\82Ü
\82½
\82Í
\81A
1077 //
\83\8d\83O
\83A
\83C
\83e
\83\80\82Ì
\83h
\83\89\83b
\83O(
\83\8d\83O
\82ð
\95Ê
\82Ì
\83^
\83u
\82É
\88Ú
\93®)
\82Ì
1078 //
\97¼
\95û
\82Ì
\83h
\83\89\83b
\83O
\82ð
\8eó
\82¯
\95t
\82¯
\82é
1080 if Source = tabBottleLog then
1082 //
\83^
\83u
\82Ì
\8f\87\94Ô
\93ü
\82ê
\91Ö
\82¦
\82Ì
\8fê
\8d\87
1084 with tabBottleLog do begin
1085 OldDest := FDragTabDest;
1086 FDragTabDest := IndexOfTabAt(X, Y);
1087 if FDragTabDest = -1 then begin
1088 Accept := false; //
\82±
\82Ì
\8fê
\8d\87\82Í
\83h
\83\8d\83b
\83v
\82ð
\94F
\82ß
\82È
\82¢
1091 with Canvas do begin
1095 if (OldDest <> FDragTabDest) and (OldDest >= 0) then begin
1096 //
\88È
\91O
\82Ì
\98g
\90ü
\8fÁ
\8b\8e
1097 TargetRect := TabRect(OldDest);
1098 with Canvas do begin
1099 Brush.Style := bsClear;
1100 Rectangle(TargetRect.Left, TargetRect.Top,
1101 TargetRect.Right, TargetRect.Bottom);
1104 if (OldDest <> FDragTabDest) then begin
1105 //
\90V
\82µ
\82¢
\98g
\90ü
\95`
\89æ
1106 TargetRect := TabRect(FDragTabDest);
1107 with Canvas do begin
1108 Brush.Style := bsClear;
1109 Rectangle(TargetRect.Left, TargetRect.Top,
1110 TargetRect.Right, TargetRect.Bottom);
1114 end else if Source is TBottleLogDragObject then
1116 //
\83\8d\83O
\8d\80\96Ú
\82Ì
\83h
\83\89\83b
\83O(
\83\8d\83O
\82ð
\95Ê
\82Ì
\83^
\83u
\82É
\88Ú
\93®
\82·
\82é)
\82Ì
\8fê
\8d\87
1117 Index := tabBottleLog.IndexOfTabAt(X, Y);
1118 if tabBottleLog.TabIndex <> Index then
1120 FLVDragDest := -1; //
\98g
\90ü
\82Í
\82Ü
\82¾
\95\
\8e¦
\82³
\82ê
\82È
\82¢
\82Í
\82¸
1121 //
\83^
\83u
\82ð
\90Ø
\91Ö
\82¦
\82é
1122 tabBottleLogChanging(Self, dummy);
1123 tabBottleLog.TabIndex := Index;
1129 procedure TfrmLog.tabBottleLogDragDrop(Sender, Source: TObject; X,
1131 var DestIndex: integer;
1133 with tabBottleLog do begin
1134 DestIndex := IndexOfTabAt(X, Y);
1135 Tabs.Move(FDragTabIndex, DestIndex);
1136 FBottleLogList.Move(FDragTabIndex, DestIndex);
1140 procedure TfrmLog.tabBottleLogEndDrag(Sender, Target: TObject; X,
1143 //
\8b
\90§
\93I
\82É
\83^
\83u
\82ð
\8dÄ
\95`
\89æ
\82³
\82¹
\82é
\81B
\98g
\90ü
\8fÁ
\82µ
\91Î
\8dô
1144 tabBottleLog.Tabs.BeginUpdate;
1145 tabBottleLog.Tabs.EndUpdate;
1148 procedure TfrmLog.LogLoadWork(Sender: TObject);
1150 if Sender = SelectedBottleLog then
1153 lvwLog.Items.Count := SelectedBottleLog.Count;
1157 procedure TfrmLog.lvwLogDrawItem(Sender: TCustomListView; Item: TListItem;
1158 Rect: TRect; State: TOwnerDrawState);
1165 DummyStr: TStringList;
1167 Bottle := SelectedBottleLog.Bottles[Item.Index];
1168 if Bottle.HasURL = huUndefined then
1170 DummyStr := TStringList.Create;
1172 ExtractURLs(Bottle.Script, DummyStr);
1173 if DummyStr.Count > 0 then
1174 Bottle.HasURL := huYes
1176 Bottle.HasURL := huNo;
1182 //
\94w
\8ci
\8fÁ
\8b\8e
1183 ListView_GetItemRect(lvwLog.Handle, Item.Index, DestRect, LVIR_BOUNDS);
1185 //
\94w
\8ci
\82Ì
\90F
\82Í
\91I
\91ð
\8fó
\91Ô
\81E
\91I
\91ð
\94ñ
\83A
\83N
\83e
\83B
\83u
\8fó
\91Ô
\81E
\92Ê
\8fí
\8fó
\91Ô
\82Ì3
\92Ê
\82è
1186 lvwLog.Canvas.Brush.Style := bsSolid;
1187 if Item.Selected then begin
1188 if lvwLog.Focused then
1189 lvwLog.Canvas.Brush.Color := clHighlight
1191 lvwLog.Canvas.Brush.Color := clBtnFace;
1193 lvwLog.Canvas.Brush.Color := Pref.BgColor;
1195 lvwLog.Canvas.FillRect(DestRect);
1196 lvwLog.Canvas.Brush.Style := bsClear;
1197 //
\83t
\83H
\81[
\83J
\83X
\82ª
\82 \82é
\8fê
\8d\87\82É
\82Í
\83t
\83H
\81[
\83J
\83X
\82Ì
\98g
\90ü
\82ð
\88ø
\82
1198 if Item.Focused and lvwLog.Focused then
1199 lvwLog.Canvas.DrawFocusRect(DestRect);
1201 //
\83h
\83\89\83b
\83O
\92\86\82È
\82ç
\98g
\90ü
\82ð
\95`
\89æ
\82·
\82é
1202 if FLVDragDest = Item.Index then
1204 DestRect := Item.DisplayRect(drBounds);
1205 DrawListViewDragBorder(DestRect);
1208 if Item.Selected then
1210 if lvwLog.Focused then
1211 lvwLog.Canvas.Font.Color := clHighlightText
1213 lvwLog.Canvas.Font.Color := clWindowText;
1215 lvwLog.Canvas.Font.Color := Pref.TextColor;
1216 lvwLog.Canvas.Refresh;
1218 //
\83L
\83\83\83v
\83V
\83\87\83\93(
\93ú
\95t)
1219 ListView_GetItemRect(lvwLog.Handle, Item.Index, DestRect, LVIR_LABEL);
1220 Inc(DestRect.Left, 2);
1221 Inc(DestRect.Top, 2);
1222 Dec(DestRect.Right, 2);
1223 DrawTextEx(lvwLog.Canvas.Handle, PChar(Item.Caption), -1, DestRect,
1224 DT_SINGLELINE or DT_RIGHT, nil);
1225 ListView_GetItemRect(lvwLog.Handle, Item.Index, DestRect, LVIR_ICON);
1226 Ico := TIcon.Create;
1228 lvwLog.SmallImages.GetIcon(Item.ImageIndex, Ico);
1229 lvwLog.Canvas.Draw(DestRect.Left, DestRect.Top, Ico);
1233 //
\83L
\83\83\83v
\83V
\83\87\83\93\82Å
\82à
\83X
\83N
\83\8a\83v
\83g
\82Å
\82à
\82È
\82¢
\82à
\82Ì
1234 for sub := 0 to Item.SubItems.Count-1 do
1236 if sub = SubScript then Continue;
1237 ListView_GetSubItemRect(lvwLog.Handle, Item.Index, sub + 1,
1238 LVIR_BOUNDS, @DestRect);
1239 if DestRect.Right - DestRect.Left <= 16 then
1241 //
\8b·
\82·
\82¬
\82é
\8fê
\8d\87\82Í
\95¶
\8e\9a\97ñ
\82ð
\95`
\89æ
\82µ
\82È
\82¢
\81B
1242 // 16
\82Æ
\82¢
\82¤
\90\94\8e\9a\82Í
\8eÀ
\91ª
\92l
\81B
\89½
\82©
\82Ì
\83o
\83O
\82Á
\82Û
1243 lvwLog.Canvas.FillRect(DestRect);
1246 Inc(DestRect.Left, 2);
1247 Inc(DestRect.Top, 2);
1248 Dec(DestRect.Right, 2);
1249 Ex := DT_NOPREFIX or DT_SINGLELINE or DT_END_ELLIPSIS;
1250 if lvwLog.Columns[sub+1].Alignment = taRightJustify then
1251 Ex := Ex or DT_RIGHT;
1252 DrawTextEx(lvwLog.Canvas.Handle, PChar(Item.SubItems[sub]), -1, DestRect,
1255 //
\83X
\83N
\83\8a\83v
\83g
1256 ListView_GetSubItemRect(lvwLog.Handle, Item.Index, SubScript + 1,
1257 LVIR_BOUNDS, @DestRect);
1258 Script := Item.SubItems[SubScript];
1259 DrawSingleLineScript(Bottle, DestRect, Item);
1263 procedure TfrmLog.DrawSingleLineScript(LogItem: TLogItem;
1264 Rect: TRect; Item: TListItem);
1267 UnyuTalking, Synchronized, Spaced: boolean;
1268 Mark: TSsMarkUpType;
1271 procedure ScopeChange;
1273 if (not Spaced) and (Pref.LogListPreviewStyle = psTagStripped) then
1280 Script := LogItem.Script;
1283 if LogItem.HasURL = huYes then
1285 Ico := TIcon.Create;
1287 lvwLog.SmallImages.GetIcon(IconURL, Ico);
1288 lvwLog.Canvas.Draw(Rect.Left + x, Rect.Top, Ico);
1295 if Pref.LogListPreviewStyle = psNoColor then
1300 DrawTextEx(lvwLog.Canvas.Handle, PChar(Script), -1, Rect,
1301 DT_SINGLELINE or DT_END_ELLIPSIS or DT_NOPREFIX, nil);
1305 SsParser.LeaveEscape := Pref.LogListPreviewStyle = psNormal;
1306 SsParser.InputString := Script;
1308 UnyuTalking := false;
1309 Synchronized := false;
1310 Spaced := true; //
\83^
\83O
\8fÈ
\97ª
\95\
\8e¦
\8e\9e\82É
\95s
\95K
\97v
\82É
\83X
\83R
\81[
\83v
\95Ï
\8a·
\8e\9e\82Ì
\83X
\83y
\81[
\83X
\82ð
\8bó
\82¯
\82È
\82¢
1311 //
\82½
\82ß
\82Ì
\83t
\83\89\83O
1312 for i := 0 to SsParser.Count - 1 do begin
1313 if SsParser[i] = '\h' then
1315 UnyuTalking := false;
1317 end else if SsParser[i] = '\u' then
1319 UnyuTalking := true;
1321 end else if SsParser[i] = '\_s' then
1323 Synchronized := not Synchronized;
1325 end else if (Pos('\n', SsParser[i]) = 1) or (SsParser[i] = '\c') then
1329 Mark := SsParser.MarkUpType[i];
1333 lvwLog.Canvas.Font.Color := Pref.MetaWordColor;
1337 if Pref.LogListPreviewStyle = psNormal then
1338 lvwLog.Canvas.Font.Color := Pref.MarkUpColor
1344 lvwLog.Canvas.Font.Color := Pref.MarkErrorColor;
1347 if Synchronized then
1348 lvwLog.Canvas.Font.Color := Pref.TalkColorS
1349 else if UnyuTalking then
1350 lvwLog.Canvas.Font.Color := Pref.TalkColorU
1352 lvwLog.Canvas.Font.Color := Pref.TalkColorH;
1355 if Item.Selected then
1357 if lvwLog.Focused then
1358 lvwLog.Canvas.Font.Color := clHighlightText
1360 lvwLog.Canvas.Font.Color := clWindowText;
1362 lvwLog.Canvas.Refresh;
1363 w := lvwLog.Canvas.TextWidth(SsParser[i]);
1364 lvwLog.Canvas.TextRect(Rect, Rect.Left + x, Rect.Top + 2, SsParser[i]);
1366 if Rect.Right - Rect.Left < x then Break;
1370 procedure TfrmLog.mnListPreviewStyleClick(Sender: TObject);
1373 with PopupMenuListPreviewStyle do
1374 for i := 0 to Items.Count-1 do
1375 Items[i].Checked := (Sender as TMenuItem).Tag = Items[i].Tag;
1376 Pref.LogListPreviewStyle := TLogListPreviewStyle((Sender as TMenuItem).Tag);
1380 procedure TfrmLog.tbtnListPreviewStyleClick(Sender: TObject);
1383 sel := Ord(Pref.LogListPreviewStyle);
1385 if sel > Ord(High(TLogListPreviewStyle)) then sel := 0;
1386 Pref.LogListPreviewStyle := TLogListPreviewStyle(sel);
1390 procedure TfrmLog.PopupMenuListPreviewStylePopup(Sender: TObject);
1393 with PopupMenuListPreviewStyle do
1394 for i := 0 to Items.Count-1 do
1395 Items[i].Checked := Items[i].Tag = Ord(Pref.LogListPreviewStyle)
1398 procedure TfrmLog.PreviewStyleChange;
1400 if Pref.LogWindowPreviewStyle = psImageConversation then
1402 if Spps.Count = 0 then
1403 ShowMessage('
\83T
\81[
\83t
\83B
\83X
\83v
\83\8c\83r
\83\85\81[
\97p
\83v
\83\89\83O
\83C
\83\93\82ª
\91¶
\8dÝ
\82µ
\82Ü
\82¹
\82ñ
\81B');
1404 edtScript.Visible := false;
1405 TalkShowFrame.Visible := true;
1408 edtScript.Visible := true;
1409 TalkShowFrame.Visible := false;
1413 procedure TfrmLog.lvwLogDragOver(Sender, Source: TObject; X, Y: Integer;
1414 State: TDragState; var Accept: Boolean);
1418 Rec: TRect; //
\83_
\83~
\81[
\81B
1421 //
\82Æ
\82è
\82 \82¦
\82¸
\8eó
\82¯
\95t
\82¯
\82é
\89Â
\94\
\90«
\82ª
\82 \82é
\82Ì
\82ÍTBottleLogDragObject
\82¾
\82¯
1422 if not (Source is TBottleLogDragObject) then
1425 Target := lvwLog.GetItemAt(X, Y);
1427 //
\82±
\82ê
\88È
\91O
\82É
\95`
\89æ
\82³
\82ê
\82Ä
\82¢
\82½
\98g
\82Ì
\83C
\83\93\83f
\83b
\83N
\83X
1428 OldDest := FLVDragDest;
1430 //
\83h
\83\8d\83b
\83v
\88Ê
\92u
\82É Item
\82ª
\82 \82ê
\82Î
\83h
\83\8d\83b
\83v
\82ð
\8b\96\89Â
\82·
\82é
1431 if Target <> nil then
1434 FLVDragDest := Target.Index;
1441 //
\88È
\91O
\82Ì
\98g
\90ü
\82ð
\8dí
\8f\9c
1442 if (OldDest > -1) and (FLVDragDest <> OldDest) then
1444 Rec := lvwLog.Items[OldDest].DisplayRect(drBounds);
1445 DrawListViewDragBorder(Rec);
1447 //
\83h
\83\89\83b
\83O
\90æ
\82Ì
\98g
\90ü
\82ð
\95`
\89æ
1448 if (Target <> nil) and (FLVDragDest <> OldDest) then
1450 Rec := Target.DisplayRect(drBounds);
1451 DrawListViewDragBorder(Rec);
1454 //
\83X
\83N
\83\8d\81[
\83\8b\8aÖ
\8cW
1455 if lvwLog.Items.Count > 0 then
1457 if (lvwLog.topItem <> nil) and (Y - lvwLog.TopItem.Top < 10) then
1459 FLVScrollDir := lvScrollDown;
1460 if not timScrollTimer.Enabled then
1461 timScrollTimer.Enabled := true;
1462 end else if (lvwLog.Height - Y) < 10 then
1464 FLVScrollDir := lvScrollUp;
1465 if not timScrollTimer.Enabled then
1466 timScrollTimer.Enabled := true;
1469 timScrollTimer.Enabled := false;
1471 timScrollTimer.Enabled := false;
1474 procedure TfrmLog.lvwLogDragDrop(Sender, Source: TObject; X, Y: Integer);
1476 TargetItem: integer;
1477 Src: TBottleLogDragObject;
1480 timScrollTimer.Enabled := false;
1482 if not (Source is TBottleLogDragObject) then
1484 Src := Source as TBottleLogDragObject;
1486 if lvwLog.GetItemAt(X, Y) <> nil then
1487 TargetItem := lvwLog.GetItemAt(X, Y).Index
1491 lvwLog.Items.BeginUpdate; //
\83h
\83\8d\83b
\83v
\92\86\82Í
\95\
\8e¦
\82ð
\97}
\8e~
\82·
\82é
\81@
\8fd
\97v
\81I
1493 //
\83h
\83\8d\83b
\83v
\88Ê
\92u
\82É Item
\82ð
\88Ú
\93®
\82·
\82é
1494 if (GetAsyncKeyState(VK_CONTROL) and $8000) > 0 then
1495 begin //
\83R
\83s
\81[
\88Ú
\93®
\82Ì
\8fê
\8d\87
1496 SrcLog := TLogItem.Create(Src.LogItem);
1497 end else //
\88Ú
\93®
\82¾
\82¯
\82·
\82é
\8fê
\8d\87
1499 SrcLog := Src.BottleLogList.Extract(Src.LogItem);
1501 if TargetItem >= 0 then
1503 //
\82·
\82Å
\82É
\91¶
\8dÝ
\82·
\82é
\83A
\83C
\83e
\83\80\82Ì
\8fã
\82É
\83h
\83\8d\83b
\83v
\82µ
\82½
\8fê
\8d\87
1504 SelectedBottleLog.Insert(TargetItem, SrcLog);
1507 // ListView
\82Ì
\97]
\94\92\82É
\83h
\83\8d\83b
\83v
\82µ
\82½
\8fê
\8d\87(Insert
\82Å
\82«
\82È
\82¢)
1508 TargetItem := SelectedBottleLog.Add(SrcLog);
1510 lvwLog.Items[TargetItem].Selected := true;
1511 lvwLog.Items[TargetItem].Focused := true;
1513 lvwLog.Items.EndUpdate;
1518 procedure TfrmLog.timScrollTimerTimer(Sender: TObject);
1520 ScrollHeight: Integer;
1522 //
\83X
\83N
\83\8d\81[
\83\8b\97Ê
\82ð
\8b\81\82ß
\82é
1524 if lvwLog.Items.Count > 2 then
1526 ScrollHeight := lvwLog.Items[1].Top - lvwLog.Items[0].Top;
1529 case FLVScrollDir of
1530 lvScrollUp: lvwLog.Scroll(0, ScrollHeight);
1531 lvSCrollDown: lvwLog.Scroll(0, -ScrollHeight);
1533 lvwLog.Invalidate; //
\8dÅ
\90V
\82Ì
\8fó
\91Ô
\82É
\8dÄ
\95`
\89æ
\82·
\82é
1537 procedure TfrmLog.mnChangeTabNameClick(Sender: TObject);
1540 Name := (FBottleLogList[tabBottleLog.Tag] as TBottleLogList).Title;
1541 InputQuery('
\96¼
\91O
\82Ì
\95Ï
\8dX', '
\90V
\82µ
\82¢
\83^
\83u
\82Ì
\96¼
\91O', Name);
1542 (FBottleLogList[tabBottleLog.Tag] as TBottleLogList).Title := Name;
1546 procedure TfrmLog.lvwLogStartDrag(Sender: TObject;
1547 var DragObject: TDragObject);
1548 var Drag: TBottleLogDragObject;
1550 //
\92Ê
\8fí
\82ÌListView
\97p
\82Ì
\83h
\83\89\83b
\83O
\83I
\83u
\83W
\83F
\83N
\83g
\82Í
1551 // OS
\82É
\82æ
\82Á
\82Ä
\82Í
\81A
\88Ú
\93®
\82·
\82é
\82Æ
\82«
\82É
\83A
\83C
\83e
\83\80\82Ì
\83C
\83\81\81[
\83W
\82ð
\94¼
\93§
\96¾
\82Å
\95`
\89æ
\82µ
\82Ä
\82µ
\82Ü
\82¤
\81B
1552 // TDragObject
\82©
\82ç
\92¼
\90Ú
\8cp
\8f³
\82µ
\82½
\82¾
\82¯
\82Ì
\82à
\82Ì(
\83C
\83\81\81[
\83W
\82ð
\8e\9d\82Á
\82Ä
\82¢
\82È
\82¢)
\82ð
\8eg
\82¤
\82Æ
1553 //
\94¼
\93§
\96¾
\83C
\83\81\81[
\83W
\82Ì
\95`
\89æ
\82Í
\97}
\90§
\82Å
\82«
\82é
\81B
1554 Drag := TBottleLogDragObject.Create(lvwLog);
1555 Drag.BottleLogList := SelectedBottleLog;
1556 Drag.LogItem := SelectedBottleLog.Bottles[lvwLog.Selected.Index];
1560 procedure TfrmLog.lvwLogEndDrag(Sender, Target: TObject; X, Y: Integer);
1562 //
\98g
\90ü
\8fÁ
\82µ
\97p
\82É
\8b
\90§
\93I
\82É
\8dÄ
\95`
\89æ
\82³
\82¹
\82é
1563 timScrollTimer.Enabled := false;
1568 procedure TfrmLog.DrawListViewDragBorder(const Rect: TRect);
1572 InflateRect(Rec, -1, -1);
1573 with lvwLog.Canvas do
1577 Brush.Style := bsClear;
1578 Refresh; //
\95K
\97v
1583 procedure TfrmLog.DoSaveLogXML(Log: TBottleLogList);
1585 SaveDialog.FileName := GetDefaultFileName(Log.Title, '.xml');
1586 SaveDialog.InitialDir := ExtractFileDir(Application.ExeName);
1587 SaveDialog.DefaultExt := 'xml';
1588 SaveDialog.FilterIndex := 3;
1589 if SaveDialog.Execute then
1590 Log.SaveToXmlFile(SaveDialog.FileName);
1593 procedure TfrmLog.DoCloseTab(const Index: integer);
1596 PrevSelection: TBottleLogList; //
\95Â
\82¶
\82½
\82Æ
\82«
\83^
\83u
\82ª
\82¸
\82ê
\82È
\82¢
\82æ
\82¤
\82É
\82·
\82é
\8f\88\97\9d\97p
1599 if Pref.ConfirmOnTabClose then
1601 Confirm := Format('
\83^
\83u"%s"
\82ð
\95Â
\82¶
\82Ü
\82·
\82©?', [(FBottleLogList[Index] as TBottleLogList).Title]);
1602 if MessageDlg(Confirm, mtConfirmation, mbOkCancel, 0) = mrCancel then
1605 PrevSelection := SelectedBottleLog;
1606 FBottleLogList.Delete(Index);
1608 //
\83^
\83u
\82¸
\82ê
\96h
\8e~
\8f\88\97\9d
1609 for i := 0 to FBottleLogList.Count-1 do
1610 if FBottleLogList[i] = PrevSelection then
1611 tabBottleLog.TabIndex := i;
1613 lvwLogChange(Self, nil, ctState);
1616 procedure TfrmLog.HTMLOutputWork(Sender: TObject; const Count: integer;
1617 var Canceled: boolean);
1619 frmHTMLOutputProgress.ProgressBar.Position := Count;
1620 Application.ProcessMessages;
1621 if frmHTMLOutputProgress.Canceled then
1625 function TfrmLog.DoSearchLog(Condition: TSearchCond): TBottleLogList;
1626 var i, UntilIndex: integer;
1628 Result := TBottleLogList.Create('
\8c\9f\8dõ
\8c\8b\89Ê');
1629 if Condition.SearchLogRange in [srSelectedLogList, srAboveSelectedLog] then
1631 if SelectedBottleLog = nil then
1633 ShowMessage('
\8c\9f\8dõ
\91Î
\8fÛ
\82ª
\82 \82è
\82Ü
\82¹
\82ñ');
1639 if Condition.SearchLogRange = srSelectedLogList then
1641 else if lvwLog.Selected = nil then
1644 UntilIndex := lvwLog.Selected.Index;
1645 SearchLogIndivisual(Condition, SelectedBottleLog, Result, UntilIndex);
1647 end else if Condition.SearchLogRange = srAllLogLists then
1649 for i := 0 to BottleLogList.Count-1 do
1651 SearchLogIndivisual(Condition, BottleLogList[i] as TBottleLogList,
1656 if Result.Count = 0 then
1657 Result.AddSystemLog('
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ
\82Å
\82µ
\82½
\81B');
1660 procedure TfrmLog.SearchLogIndivisual(Condition: TSearchCond; LogList,
1661 Result: TBottleLogList; UntilIndex: integer = -1);
1664 Bottle, New: TLogItem;
1667 // 1
\8cÂ
\82Ì
\83\8d\83O
\83^
\83u
\82É
\91Î
\82µ
\82Ä
\8c\9f\8dõ
\82ð
\82©
\82¯
\82é
\81BUntilIndex
\82Å
\94Í
\88Í
\8ew
\92è(
\8fÈ
\97ª
\8e\9e\82»
\82Ì
\83^
\83u
\91S
\91Ì)
1668 if UntilIndex >= 0 then
1671 Max := LogList.Count-1;
1672 for i := 0 to Max do
1674 //
\8fð
\8c\8f\94»
\92è
1675 Bottle := LogList.Bottles[i];
1676 if Bottle.LogType <> ltBottle then
1679 //
\83X
\83N
\83\8a\83v
\83g
\83p
\83^
\81[
\83\93\82Å
\89ð
\90Í
1680 if Condition.ScriptPattern <> '' then
1682 if Condition.ScriptRegExp then
1685 if not RegExp.Match(Condition.ScriptPattern, Bottle.Script) then
1689 Ok := false; //
\96
\82È
\90³
\8bK
\95\
\8c»
\82ð
\8fR
\82é
1693 if not AnsiContainsText(Bottle.Script, Condition.ScriptPattern) then
1697 //
\83`
\83\83\83\93\83l
\83\8b\96¼
\81A
\83S
\81[
\83X
\83g
\96¼
\81A
\93\8a\95[
\93¯
\88Ó
1698 if Condition.Channel <> '' then
1699 if not AnsiContainsText(Bottle.Channel, Condition.Channel) then
1701 if Condition.Ghost <> '' then
1702 if not AnsiContainsText(Bottle.Ghost, Condition.Ghost) then
1704 if Condition.MinVote > Bottle.Votes then
1706 if Condition.MinAgree > Bottle.Agrees then
1708 //
\8fð
\8c\8f\82É
\88ê
\92v
\82µ
\82½
\82à
\82Ì
\82ð
\8c\8b\89Ê
\83\8a\83X
\83g
\82É
\92Ç
\89Á
1711 New := TLogItem.Create(Bottle); //
\83R
\83s
\81[
\83R
\83\93\83X
\83g
\83\89\83N
\83^
1712 New.State := lsOpened;
1718 { TBottleLogDragObject }
1720 function TBottleLogDragObject.GetDragImages: TDragImageList;
1722 //
\92\86\93r
\94¼
\92[
\82È
\83h
\83\89\83b
\83O
\83C
\83\81\81[
\83W
\82ð
\95\
\8e¦
\82µ
\82È
\82¢
\82æ
\82¤
\82É
\82·
\82é
1726 procedure TBottleLogDragObject.SetBottleLogList(
1727 const Value: TBottleLogList);
1729 FBottleLogList := Value;
1732 procedure TBottleLogDragObject.SetLogItem(const Value: TLogItem);
1737 procedure TfrmLog.mnTabSaveXMLLogClick(Sender: TObject);
1739 DoSaveLogXML(FBottleLogList[tabBottleLog.Tag] as TBottleLogList);
1742 procedure TfrmLog.mnSaveHTMLClick(Sender: TObject);
1744 LogList, SB: TBottleLogList;
1746 Options: THTMLOutputOptions;
1748 SB := SelectedBottleLog;
1751 if SB.Count = 0 then
1753 Application.CreateForm(TfrmHTMLOutputConfig, frmHTMLOutputConfig);
1754 with frmHTMLOutputConfig do
1756 // Show HTML save option dialog
1759 LogList := TBottleLogList.Create('');
1763 for i := SB.Count-1 downto 0 do
1764 if SB.Bottles[i].LogType = ltBottle then
1765 LogList.Add(TLogItem.Create(SB.Bottles[i]));
1767 if SB.Bottles[lvwLog.Selected.Index].LogType = ltBottle then
1768 LogList.Add(TLogItem.Create(SB.Bottles[lvwLog.Selected.Index]))
1770 ShowMessage('
\82±
\82Ì
\83\81\83b
\83Z
\81[
\83W
\82Í
\95Û
\91¶
\82Å
\82«
\82Ü
\82¹
\82ñ');
1772 for i := lvwLog.Selected.Index downto 0 do
1773 if SB.Bottles[i].LogType = ltBottle then
1774 LogList.Add(TLogItem.Create(SB.Bottles[i]));
1776 Options.ImageDir := ImageDir;
1777 Options.UseColor := UseColor;
1778 Options.ImageType := ImageType;
1779 Application.CreateForm(TfrmHTMLOutputProgress, frmHTMLOutputProgress);
1781 frmHTMLOutputProgress.Show;
1782 LogList.OnHTMLOutputWork := HTMLOutputWork;
1783 LogList.SaveToHTML(FileName, Options, SsParser);
1785 frmHTMLOutputProgress.Release;
1795 procedure TfrmLog.mnPopupCopyGhostClick(Sender: TObject);
1800 Log := SelectedBottleLog.Bottles[frmLog.lvwLog.Selected.Index];
1801 if Log = nil then Exit;
1802 Clip := ClipBoard();
1803 Clip.SetTextBuf(PChar(Log.Ghost));