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;
12 //
\83\8d\83O
\82Ì
\95Û
\91¶
\95û
\96@
13 TSaveLogType = (stLog, stLogWithChannels, stText, stXML);
15 //
\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\83X
\83N
\83\8d\81[
\83\8b\95û
\8cü
16 TLVScrollDir = (lvScrollUp, lvScrollDown);
18 TfrmLog = class(TForm)
20 tbtnClear: TToolButton;
23 StatusBar: TStatusBar;
24 tbtnSaveLog: TToolButton;
25 PopupMenuPreview: TPopupMenu;
27 tbtnVoteMessage: TToolButton;
28 PopupMenuListView: TPopupMenu;
29 mnPopUpVoteMessage: TMenuItem;
30 SaveDialog: TSaveDialog;
33 mnPopUpCopyScript: TMenuItem;
34 PopupMenuSaveLog: TPopupMenu;
36 mnSaveLogChannel: TMenuItem;
37 mnSaveLogScript: TMenuItem;
38 mnSaveLogXML: TMenuItem;
39 ToolButton1: TToolButton;
41 mnPopUpAgreeMessage: TMenuItem;
42 tbtnAgreeMessage: TToolButton;
43 ToolButton2: TToolButton;
44 tbtnPreviewStyle: TToolButton;
45 PopupMenuPreviewStyle: TPopupMenu;
46 mnPreviewStyleConversation: TMenuItem;
47 mnPreviewStyleScript: TMenuItem;
48 mnPreviewStyleScriptWithLineBreak: TMenuItem;
50 tabBottleLog: TTabControl;
52 tbtnDownloadLog: TToolButton;
53 PopupMenuTab: TPopupMenu;
54 mnCloseTab: TMenuItem;
55 tbtnFindBottle: TToolButton;
56 tbtnOpenLog: TToolButton;
57 OpenDialog: TOpenDialog;
58 tbtnInsertCue: TToolButton;
59 mnInsertCue: TMenuItem;
60 PopupMenuListPreviewStyle: TPopupMenu;
61 mnListPreviewStyleNormal: TMenuItem;
62 mnListPreviewStyleTagStripped: TMenuItem;
63 tbtnListPreviewStyle: TToolButton;
64 mnListPreviewStyleNoColor: TMenuItem;
65 SsParserForTalkShow: TSsParser;
66 mnPreviewStyleConversationImage: TMenuItem;
67 pnlPreviewArea: TPanel;
68 TalkShowFrame: TfrmTalkShow;
70 tbtnSendEditor: TToolButton;
71 mnSendEditor: TMenuItem;
72 timScrollTimer: TTimer;
73 mnChangeTabName: TMenuItem;
76 mnDeleteLogItem: TMenuItem;
77 procedure tbtnClearClick(Sender: TObject);
78 procedure FormCreate(Sender: TObject);
79 procedure lvwLogChange(Sender: TObject; Item: TListItem;
81 procedure lvwLogDblClick(Sender: TObject);
82 procedure lvwLogKeyPress(Sender: TObject; var Key: Char);
83 procedure FormDestroy(Sender: TObject);
84 procedure lvwLogClick(Sender: TObject);
85 procedure mnSaveLogClick(Sender: TObject);
86 procedure lvwLogColumnClick(Sender: TObject; Column: TListColumn);
87 procedure mnPopUpCopyScriptClick(Sender: TObject);
88 procedure mnSaveLogChannelClick(Sender: TObject);
89 procedure mnSaveLogScriptClick(Sender: TObject);
90 procedure mnSaveLogXMLClick(Sender: TObject);
91 procedure lvwLogData(Sender: TObject; Item: TListItem);
92 procedure PopupMenuListViewPopup(Sender: TObject);
93 procedure lvwLogCustomDrawItem(Sender: TCustomListView;
94 Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
95 procedure PopupMenuPreviewStylePopup(Sender: TObject);
96 procedure mnPreviewStyleClick(Sender: TObject);
97 procedure tbtnPreviewStyleClick(Sender: TObject);
98 procedure tabBottleLogChange(Sender: TObject);
99 procedure tabBottleLogChanging(Sender: TObject;
100 var AllowChange: Boolean);
101 procedure tabBottleLogContextPopup(Sender: TObject; MousePos: TPoint;
102 var Handled: Boolean);
103 procedure mnCloseTabClick(Sender: TObject);
104 procedure tbtnFindBottleClick(Sender: TObject);
105 procedure tbtnOpenLogClick(Sender: TObject);
106 procedure tabBottleLogMouseDown(Sender: TObject; Button: TMouseButton;
107 Shift: TShiftState; X, Y: Integer);
108 procedure tabBottleLogDragOver(Sender, Source: TObject; X, Y: Integer;
109 State: TDragState; var Accept: Boolean);
110 procedure tabBottleLogDragDrop(Sender, Source: TObject; X, Y: Integer);
111 procedure tabBottleLogEndDrag(Sender, Target: TObject; X, Y: Integer);
112 procedure lvwLogDrawItem(Sender: TCustomListView; Item: TListItem;
113 Rect: TRect; State: TOwnerDrawState);
114 procedure mnListPreviewStyleClick(Sender: TObject);
115 procedure tbtnListPreviewStyleClick(Sender: TObject);
116 procedure PopupMenuListPreviewStylePopup(Sender: TObject);
117 procedure lvwLogDragOver(Sender, Source: TObject; X, Y: Integer;
118 State: TDragState; var Accept: Boolean);
119 procedure lvwLogDragDrop(Sender, Source: TObject; X, Y: Integer);
120 procedure timScrollTimerTimer(Sender: TObject);
121 procedure mnChangeTabNameClick(Sender: TObject);
122 procedure lvwLogStartDrag(Sender: TObject;
123 var DragObject: TDragObject);
124 procedure lvwLogEndDrag(Sender, Target: TObject; X, Y: Integer);
127 FLastScript: String; //
\83X
\83N
\83\8a\83v
\83g
\8dÄ
\95`
\89æ
\97}
\90§
\97p
128 FBottleLogList: TObjectList;
130 FDragTabIndex: integer; //
\83^
\83u
\83h
\83\89\83b
\83O
\83h
\83\8d\83b
\83v
\8aÖ
\98A
131 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)
133 //
\83\8a\83X
\83g
\83r
\83\85\81[
\83h
\83\89\83b
\83O
\83h
\83\8d\83b
\83v
\8aÖ
\98A
134 FLVScrollDir: TLVScrollDir; //
\83X
\83N
\83\8d\81[
\83\8b\95û
\8cü
135 FLVDragDest: integer; //
\83h
\83\8d\83b
\83v
\82·
\82é
\88Ê
\92u(
\82·
\82®
\89º
\82É
\82
\82é
\83A
\83C
\83e
\83\80\82ÌIndex)
137 procedure UpdateScript(const Script: String);
138 procedure UpdateScriptConversationColor(const Script: String);
139 procedure UpdateScriptScript(const Script: String);
140 procedure mnURLClick(Sender: TObject);
141 procedure ExtractURLs(Script: String; Result: TStrings);
142 function GetDefaultFileName(const Name: String; const Ext: String): String;
143 function BottleLogTitled(const LogName: String): TBottleLogList;
144 procedure DrawSingleLineScript(LogItem: TLogItem; Rect: TRect;
146 procedure PreviewStyleChange;
147 procedure DrawListViewDragBorder(const Rect: TRect);
149 procedure CreateParams(var Params: TCreateParams); override;
152 function SelectedBottleLog: TBottleLogList;
153 property BottleLogList: TObjectList read FBottleLogList;
154 procedure AddCurrentScriptLog(const LogName, Script, Channel, MID, Ghost: String);
155 procedure AddCurrentSystemLog(const LogName, MessageString: String);
156 procedure VoteLog(const MID: String; const Vote: integer);
157 procedure AgreeLog(const MID: String; const Agree: integer);
158 procedure SetBottleState(const MID: String; State: TLogState);
159 procedure AllBottleOpened;
160 procedure LogLoaded(Sender: TObject);
161 procedure LogLoadFailure(Sender: TObject; const Message: String);
162 procedure LogLoadWork(Sender: TObject);
164 procedure UpdateWindow;
165 procedure SelAndFocusMessage(const MID: String);
168 TBottleLogDragObject = class(TDragControlObjectEx)
170 FBottleLogList: TBottleLogList;
172 procedure SetBottleLogList(const Value: TBottleLogList);
173 procedure SetLogItem(const Value: TLogItem);
175 function GetDragImages: TDragImageList; override;
177 property BottleLogList: TBottleLogList read FBottleLogList write SetBottleLogList;
178 property LogItem: TLogItem read FLogItem write SetLogItem;
204 procedure TfrmLog.AddCurrentScriptLog(const LogName, Script, Channel, MID, Ghost: String);
207 BottleLogTitled(LogName).AddScriptLog(Script, Channel, MID, Ghost);
208 if SelectedBottleLog <> BottleLogTitled(LogName) then Exit;
209 lvwLog.OnChange := nil; //
\83C
\83x
\83\93\83g
\94
\90¶(
\82¢
\82ë
\82¢
\82ë
\8dÄ
\95`
\89æ
\82ª
\8bN
\82«
\82é)
\82Ì
\97}
\90§
210 if lvwLog.Selected <> nil then Sel := lvwLog.Selected.Index else Sel := -1;
211 lvwLog.Items.Count := SelectedBottleLog.Count;
213 if Sel >= 0 then begin
214 lvwLog.Selected := lvwLog.Items[Sel + 1];
215 lvwLog.Selected.Focused := true;
217 if not lvwLog.Focused then
218 ListView_Scroll(lvwLog.Handle, 0, High(integer));
219 lvwLog.OnChange := lvwLogChange;
222 procedure TfrmLog.AddCurrentSystemLog(const LogName, MessageString: String);
225 BottleLogTitled(LogName).AddSystemLog(MessageString);
226 if SelectedBottleLog <> BottleLogTitled(LogName) then Exit;
227 lvwLog.OnChange := nil;
228 if lvwLog.Selected <> nil then Sel := lvwLog.Selected.Index else Sel := -1;
229 lvwLog.Items.Count := SelectedBottleLog.Count;
231 if Sel >= 0 then begin
232 lvwLog.Selected := lvwLog.Items[Sel + 1];
233 lvwLog.Selected.Focused := true;
235 if not lvwLog.Focused then
236 ListView_Scroll(lvwLog.Handle, 0, High(integer));
237 lvwLog.OnChange := lvwLogChange;
242 procedure TfrmLog.tbtnClearClick(Sender: TObject);
244 if SelectedBottleLog = nil then Exit;
245 FBottleLogList.Delete(tabBottleLog.TabIndex);
246 tabBottleLog.TabIndex := 0;
249 lvwLogChange(Self, nil, ctState);
252 procedure TfrmLog.FormCreate(Sender: TObject);
255 FLVDragDest := -1; //
\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\83h
\83\89\83b
\83O
\92\86\82Å
\82Í
\82È
\82¢
256 FBottleLogList := TObjectList.Create;
258 SsParser.TagPattern.Assign(frmSender.SsParser.TagPattern);
259 SsParser.MetaPattern.Assign(frmSender.SsParser.MetaPattern);
261 with Pref.LogWindowPosition do begin
264 Self.Width := Right - Left + 1;
265 Self.Height := Bottom - Top + 1;
267 lvwLog.DoubleBuffered := true;
268 pnlPreviewArea.Height := Pref.LogWindowDividerPos;
271 while Token(Pref.LogWindowColumnWidth, ',', i) <> '' do begin
272 lvwLog.Columns[i].Width := StrToIntDef(Token(Pref.LogWindowColumnWidth, ',', i), 100);
276 SsParserForTalkShow.TagPattern.Assign(SsParser.TagPattern);
277 SsParserForTalkShow.MetaPattern.Assign(SsParser.MetaPattern);
278 SsParserForTalkShow.EscapeInvalidMeta := false;
279 SsParserForTalkShow.LeaveEscape := false;
280 TalkShowFrame.SsParser := self.SsParserForTalkShow;
282 TalkShowFrame.SetPreviewFont(edtScript.Font);
283 TalkShowFrame.PrevControl := lvwLog;
286 UpdateWindow; // Reset window color and enabled status of some buttons
289 procedure TfrmLog.FormDestroy(Sender: TObject);
294 for i := 0 to lvwLog.Columns.Count-1 do begin
295 if i > 0 then WidthStr := WidthStr + ',';
296 WidthStr := WidthStr + IntToStr(lvwLog.Column[i].Width);
298 Pref.LogWindowColumnWidth := WidthStr;
300 with Pref.LogWindowPosition do begin
303 Right := Self.Left + Self.Width - 1;
304 Bottom := Self.Top + Self.Height - 1;
306 Pref.LogWindowDividerPos := pnlPreviewArea.Height;
308 FreeAndNil(FBottleLogList);
311 procedure TfrmLog.lvwLogChange(Sender: TObject; Item: TListItem;
312 Change: TItemChange);
315 Selected, IsNormalBottle: boolean;
318 IsNormalBottle := false;
319 if SelectedBottleLog <> nil then begin
320 StatusBar.Panels[0].Text := IntToStr(SelectedBottleLog.Count) + '
\8c\8f';
321 if Change = ctState then begin
323 if lvwLog.Selected <> nil then begin
325 Log := SelectedBottleLog.Bottles[lvwLog.Selected.Index];
326 if (Log.LogType = ltBottle) and not frmSender.Connecting then begin
327 IsNormalBottle := true;
328 Script := Log.Script;
329 StatusBar.Panels[1].Text := Format('%d
\83o
\83C
\83g -
\83_
\83u
\83\8b\83N
\83\8a\83b
\83N
\82Å
\8dÄ
\90¶', [Length(Log.Script)]);
330 if Pref.LogWindowPreviewStyle = psImageConversation then
331 TalkShowFrame.View(Log)
333 UpdateScript(Script);
335 StatusBar.Panels[1].Text := '';
336 UpdateScript(''); //
\83\8d\83O
\83v
\83\8c\83r
\83\85\81[
\95\94\82ð
\83N
\83\8a\83A
339 StatusBar.Panels[1].Text := '';
340 UpdateScript(Script); //
\83\8d\83O
\83v
\83\8c\83r
\83\85\81[
\95\94\83N
\83\8a\83A
343 tbtnSaveLog.Enabled := lvwLog.Items.Count > 0;
345 StatusBar.Panels[0].Text := '';
346 UpdateScript(''); //
\83\8d\83O
\83v
\83\8c\83r
\83\85\81[
\95\94\83N
\83\8a\83A
348 frmSender.actVoteMessage.Enabled := Selected and IsNormalBottle;
349 frmSender.actAgreeMessage.Enabled := Selected and IsNormalBottle;
350 frmSender.actSendEditor.Enabled := Selected and IsNormalBottle;
351 frmSender.actInsertCue.Enabled := Selected;
352 frmSender.actDeleteLogItem.Enabled := Selected;
353 mnPopUpCopyScript.Enabled := Selected and IsNormalBottle;
356 procedure TfrmLog.lvwLogDblClick(Sender: TObject);
357 var Script, ErrorMes: String;
358 Log, CueItem: TLogItem;
361 if lvwLog.Selected = nil then
363 Log := SelectedBottleLog.Bottles[lvwLog.Selected.Index];
364 if Log = nil then Exit;
365 if Log.LogType <> ltBottle then
367 Script := frmSender.ScriptTransForSSTP(Log.Script, ErrorMes);
368 if ErrorMes <> '' then
370 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+
372 '
\8b
\90§
\93I
\82É
\8dÄ
\90¶
\82µ
\82Ü
\82·
\82©?'#13#10,
373 mtWarning, mbOkCancel, 0
375 if Res = mrCancel then
379 CueItem := TLogItem.Create(Log);
381 CueItem.Script := Script;
382 frmSender.BottleSstp.Unshift(CueItem);
388 procedure TfrmLog.UpdateScriptConversationColor(const Script: String);
391 UnyuTalking, Talked, InSynchronized: boolean;
394 frmSender.DoTrans(scr, [toConvertURL]);
395 SsParser.LeaveEscape := false;
396 SsParser.InputString := scr;
397 UnyuTalking := false;
398 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
399 InSynchronized := false;
400 edtScript.Text := '';
401 edtScript.Color := Pref.BgColor;
402 for i := 0 to SsParser.Count-1 do begin
403 if (SsParser[i] = '\_s') and not InSynchronized then begin
404 InSynchronized := true;
406 edtScript.SelText := #13#10;
409 end else if (SsParser[i] = '\_s') and InSynchronized then begin
410 InSynchronized := false;
412 edtScript.SelText := #13#10;
416 if (SsParser[i] = '\u') and not UnyuTalking then begin
419 edtScript.SelText := #13#10;
423 if (SsParser[i] = '\h') and UnyuTalking then begin
424 UnyuTalking := false;
426 edtScript.SelText := #13#10;
430 if SsParser.MarkUpType[i] = mtStr then begin
431 if InSynchronized then
432 edtScript.SelAttributes.Color := Pref.TalkColorS
433 else if UnyuTalking then
434 edtScript.SelAttributes.Color := Pref.TalkColorU
436 edtScript.SelAttributes.Color := Pref.TalkColorH;
437 edtScript.SelText := SsParser[i];
440 if SsParser.MarkUpType[i] = mtMeta then begin
441 edtScript.SelAttributes.Color := Pref.MetaWordColor;
442 edtScript.SelText := SsParser[i];
448 procedure TfrmLog.lvwLogKeyPress(Sender: TObject; var Key: Char);
450 if Key = #13 then lvwLogDblClick(Sender);
453 procedure TfrmLog.CreateParams(var Params: TCreateParams);
456 Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
459 procedure TfrmLog.lvwLogClick(Sender: TObject);
461 //
\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ô
463 Selected := Selected;
466 procedure TfrmLog.lvwLogColumnClick(Sender: TObject; Column: TListColumn);
467 var SortType: TBottleLogSortType;
471 if SelectedBottleLog = nil then
473 if lvwLog.Selected <> nil then
474 SelectedMID := SelectedBottleLog.Bottles[lvwLog.Selected.Index].MID
478 SortColumn := Column.Index;
480 -1: SortType := stLogTime;
481 subChannel: SortType := stChannel;
482 subGhost: SortType := stGhost;
483 subVotes: SortType := stVote;
484 subAgrees: SortType := stAgree;
485 subScript: SortType := stScript;
487 SortType := stLogTime;
490 SelectedBottleLog.SortBottles(SortType);
492 if Length(SelectedMID) > 0 then
493 SelAndFocusMessage(SelectedMID);
497 procedure TfrmLog.mnPopUpCopyScriptClick(Sender: TObject);
502 Log := SelectedBottleLog.Bottles[frmLog.lvwLog.Selected.Index];
503 if Log = nil then Exit;
505 Clip.SetTextBuf(PChar(Log.Script));
508 procedure TfrmLog.SetBottleState(const MID: String; State: TLogState);
512 for i := 0 to FBottleLogList.Count-1 do begin
513 Bottle := (FBottleLogList[i] as TBottleLogList).Bottle(MID);
514 if Bottle <> nil then begin
515 Bottle.State := State;
516 lvwLog.OnChange := nil;
518 lvwLog.OnChange := lvwLogChange;
523 procedure TfrmLog.mnSaveLogClick(Sender: TObject);
525 if SelectedBottleLog = nil then Exit;
526 SaveDialog.FileName := GetDefaultFileName(SelectedBottleLog.Title, '.log');
527 SaveDialog.InitialDir := ExtractFileDir(Application.ExeName);
528 SaveDialog.DefaultExt := 'log';
529 SaveDialog.FilterIndex := 1;
530 if SaveDialog.Execute then
531 SelectedBottleLog.SaveToSstpLog(SaveDialog.FileName, false);
534 procedure TfrmLog.mnSaveLogChannelClick(Sender: TObject);
536 if SelectedBottleLog = nil then Exit;
537 SaveDialog.FileName := GetDefaultFileName(SelectedBottleLog.Title, '.log');
538 SaveDialog.InitialDir := ExtractFileDir(Application.ExeName);
539 SaveDialog.DefaultExt := 'log';
540 SaveDialog.FilterIndex := 1;
541 if SaveDialog.Execute then
542 SelectedBottleLog.SaveToSstpLog(SaveDialog.FileName, true);
545 procedure TfrmLog.mnSaveLogScriptClick(Sender: TObject);
547 if SelectedBottleLog = nil then Exit;
548 SaveDialog.FileName := GetDefaultFileName(SelectedBottleLog.Title, '.txt');
549 SaveDialog.InitialDir := ExtractFileDir(Application.ExeName);
550 SaveDialog.DefaultExt := 'txt';
551 SaveDialog.FilterIndex := 2;
552 if SaveDialog.Execute then
553 SelectedBottleLog.SaveToText(SaveDialog.FileName);
556 procedure TfrmLog.mnSaveLogXMLClick(Sender: TObject);
558 if SelectedBottleLog = nil then Exit;
559 SaveDialog.FileName := GetDefaultFileName(SelectedBottleLog.Title, '.xml');
560 SaveDialog.InitialDir := ExtractFileDir(Application.ExeName);
561 SaveDialog.DefaultExt := 'xml';
562 SaveDialog.FilterIndex := 3;
563 if SaveDialog.Execute then
564 SelectedBottleLog.SaveToXmlFile(SaveDialog.FileName);
567 procedure TfrmLog.lvwLogData(Sender: TObject; Item: TListItem);
571 if Item = nil then Exit;
573 Log := SelectedBottleLog.Bottles[i];
575 Caption := FormatDateTime('yy/mm/dd hh:nn:ss', Log.LogTime);
577 SubItems.Add(Log.Channel);
578 SubItems.Add(Log.Ghost);
579 if Log.LogType = ltBottle then begin
580 if Log.Votes > 0 then
581 SubItems.Add(IntToStr(Log.Votes))
584 if Log.Agrees > 0 then
585 SubItems.Add(IntToStr(Log.Agrees))
589 //
\83V
\83X
\83e
\83\80\83\8d\83O
\82È
\82Ç
\82Í
\93\8a\95[
\81E
\93¯
\88Ó
\82ð
\95\
\8e¦
\82µ
\82È
\82¢
593 SubItems.Add(Log.Script);
595 if Log.LogType = ltBottle then begin
597 lsUnopened: ImageIndex := IconBottle;
598 lsPlaying: ImageIndex := IconPlaying;
599 lsOpened: ImageIndex := IconOpened;
602 ImageIndex := IconSystemLog;
606 procedure TfrmLog.UpdateWindow;
607 var EnabledFlag: boolean;
609 lvwLog.Color := Pref.BgColor;
610 lvwLog.Font.Color := Pref.TalkColorH;
611 if SelectedBottleLog <> nil then begin
612 Caption := '
\83\8d\83O - ' + SelectedBottleLog.Title;
613 StatusBar.Panels[0].Text := IntToStr(SelectedBottleLog.Count) + '
\8c\8f';
614 lvwLog.Items.Count := SelectedBottleLog.Count;
616 Caption := '
\83\8d\83O';
617 StatusBar.Panels[0].Text := '';
618 StatusBar.Panels[1].Text := '';
619 lvwLog.Items.Count := 0;
622 EnabledFlag := SelectedBottleLog <> nil;
623 tbtnClear.Enabled := EnabledFlag;
624 tbtnSaveLog.Enabled := EnabledFlag;
625 tbtnFindBottle.Enabled := EnabledFlag;
630 procedure TfrmLog.PopupMenuListViewPopup(Sender: TObject);
636 for i := mnJumpURL.Count-1 downto 0 do begin
637 mnJumpURL.Items[i].Free;
639 mnJumpURL.Enabled := false;
640 if lvwLog.Selected = nil then Exit;
641 Log := SelectedBottleLog.Bottles[lvwLog.Selected.Index];
642 if Log = nil then Exit;
643 Urls := TStringList.Create;
645 ExtractURLs(Log.Script, Urls);
646 for i := 0 to Urls.Count-1 do begin
647 Child := TMenuItem.Create(Self);
649 Caption := Format('(&%d) %s', [i+1, StringReplace(Urls[i], '&', '&&', [rfReplaceAll])]);
651 OnClick := mnURLClick;
652 AutoHotkeys := maManual;
653 mnJumpURL.Add(Child);
656 mnJumpURL.Enabled := Urls.Count > 0;
662 procedure TfrmLog.mnURLClick(Sender: TObject);
663 var LogItem: TLogItem;
667 if (lvwLog.Selected = nil) or (SelectedBottleLog = nil) then Exit;
668 LogItem := SelectedBottleLog[lvwLog.Selected.Index] as TLogItem;
669 Urls := TStringList.Create;
671 ExtractURLs(LogItem.Script, Urls);
672 URL := Urls[(Sender as TMenuItem).Tag];
673 ShellExecute(Handle, 'open', PChar(URL), nil, nil, SW_SHOW);
679 procedure TfrmLog.ExtractURLs(Script: String; Result: TStrings);
680 var i, u, j: integer;
684 SsParser.InputString := Script;
685 for i := 0 to SsParser.Count-1 do begin
686 if (SsParser.Match(SsParser[i], '\URL%b') > 0) then begin
687 for u := 7 downto 1 do begin
688 if (SsParser.Match(SsParser[i],
689 '\URL%b'+StringReplace(StringOfChar('-', u*2),
690 '-', '%b', [rfReplaceAll]))) > 0 then begin
691 for j := 1 to u do begin
692 s := SsParser.GetParam(SsParser[i], j*2);
693 if Pos('http://', s) > 0 then Result.Add(s);
698 if SsParser.Match(SsParser[i], '\URL%b%b') = 0 then begin //
\8aÈ
\88Õ
\94ÅURL
\95Ï
\8a·
699 //
\8aÈ
\88Õ
\8c`
\8e®\URL
\83^
\83O
\95Ï
\8a·
700 s := SsParser.GetParam(SsParser[i], 1);
701 if Pos('http://', s) > 0 then Result.Add(s);
707 procedure TfrmLog.SelAndFocusMessage(const MID: String);
711 for i := 0 to SelectedBottleLog.Count-1 do begin
712 Log := SelectedBottleLog.Items[i] as TLogItem;
713 if Log.MID = MID then begin
714 lvwLog.Items[i].Selected := true;
715 lvwLog.Items[i].Focused := true;
720 procedure TfrmLog.lvwLogCustomDrawItem(Sender: TCustomListView;
721 Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
726 procedure TfrmLog.UpdateScript(const Script: String);
728 if Script <> FLastScript then begin
729 if Pref.LogWindowPreviewStyle = psConversation then begin
730 UpdateScriptConversationColor(Script);
732 UpdateScriptScript(Script);
734 SendMessage(edtScript.Handle, EM_LINESCROLL, Low(integer), Low(integer)); //
\83X
\83N
\83\8d\81[
\83\8b\96ß
\82µ
735 FLastScript := Script;
739 procedure TfrmLog.PopupMenuPreviewStylePopup(Sender: TObject);
742 with PopupMenuPreviewStyle do
743 for i := 0 to Items.Count-1 do
744 Items[i].Checked := Items[i].Tag = Ord(Pref.LogWindowPreviewStyle)
747 procedure TfrmLog.mnPreviewStyleClick(Sender: TObject);
750 with PopupMenuPreviewStyle do
751 for i := 0 to Items.Count-1 do
752 Items[i].Checked := (Sender as TMenuItem).Tag = Items[i].Tag;
753 Pref.LogWindowPreviewStyle := TLogWindowPreviewStyle((Sender as TMenuItem).Tag);
756 lvwLogChange(self, lvwLog.Selected, ctState);
759 procedure TfrmLog.UpdateScriptScript(const Script: String);
761 UnyuTalking, InSynchronized: boolean;
764 edtScript.Color := Pref.BgColor;
765 SsParser.LeaveEscape := true;
766 SsParser.InputString := Script;
767 edtScript.Text := '';
768 edtScript.SelAttributes.Color := clWindowText;
769 UnyuTalking := false;
770 InSynchronized := false;
771 for i := 0 to SsParser.Count-1 do begin
772 case SsParser.MarkUpType[i] of
774 if InSynchronized then
775 edtScript.SelAttributes.Color := Pref.TalkColorS
776 else if UnyuTalking then
777 edtScript.SelAttributes.Color := Pref.TalkColorU
779 edtScript.SelAttributes.Color := Pref.TalkColorH;
782 edtScript.SelAttributes.Color := Pref.MarkUpColor;
783 if SsParser[i] = '\h' then
785 else if SsParser[i] = '\u' then
787 else if SsParser[i] = '\_s' then
788 InSynchronized := not InSynchronized;
790 mtMeta: edtScript.SelAttributes.Color := Pref.MetaWordColor;
791 mtTagErr: edtScript.SelAttributes.Color := Pref.MarkErrorColor;
793 edtScript.SelText := SsParser[i];
794 if (SsParser[i] = '\n') and (Pref.LogWindowPreviewStyle = psScriptWithLineBreak) then
795 edtScript.SelText := #13#10;
799 procedure TfrmLog.tbtnPreviewStyleClick(Sender: TObject);
802 sel := Ord(Pref.LogWindowPreviewStyle);
804 if sel > Ord(High(TLogWindowPreviewStyle)) then sel := 0;
805 Pref.LogWindowPreviewStyle := TLogWindowPreviewStyle(sel);
808 lvwLogChange(self, lvwLog.Selected, ctState);
811 function TfrmLog.SelectedBottleLog: TBottleLogList;
813 if tabBottleLog.TabIndex >= 0 then
814 Result := FBottleLogList.Items[tabBottleLog.TabIndex] as TBottleLogList
819 procedure TfrmLog.tabBottleLogChange(Sender: TObject);
821 // StatusBar
\82Ì
\8c\8f\90\94\95\
\8e¦
\82âListView.Items.Count
\82ð
\8dX
\90V
\82·
\82é
823 //
\83A
\83C
\83e
\83\80\82Ì
\91I
\91ð
\8fó
\91Ô
\82ð
\95\9c\8bA
\82·
\82é
824 with SelectedBottleLog do
825 if (SelectedIndex >= 0) and (Count > SelectedIndex) then
827 lvwLog.Items[SelectedIndex].Selected := true;
828 if lvwLog.Focused then lvwLog.Selected.Focused := true;
830 lvwLogChange(Self, nil, ctState);
833 procedure TfrmLog.LogLoaded(Sender: TObject);
835 if SelectedBottleLog = Sender then begin
840 procedure TfrmLog.UpdateTab;
843 cur := tabBottleLog.tabIndex;
844 tabBottleLog.Tabs.Clear;
845 for i := 0 to FBottleLogList.Count - 1 do begin
846 tabBottleLog.Tabs.Add((FBottleLogList[i] as TBottleLogList).Title);
848 if FBottleLogList.Count > 0 then begin
849 if cur < FBottleLogList.Count then
850 tabBottleLog.TabIndex := cur
852 tabBottleLog.TabIndex := FBottleLogList.Count-1;
856 procedure TfrmLog.LogLoadFailure(Sender: TObject; const Message: String);
859 ShowMessage(Message);
860 if Sender = SelectedBottleLog then UpdateWindow;
863 procedure TfrmLog.AgreeLog(const MID: String; const Agree: integer);
868 for i := 0 to FBottleLogList.Count - 1 do begin
869 if (FBottleLogList[i] as TBottleLogList).Bottle(MID) <> nil then begin
870 (FBottleLogList[i] as TBottleLogList).Bottle(MID).Agrees := Agree;
874 if flag then lvwLog.Invalidate;
877 procedure TfrmLog.VoteLog(const MID: String; const Vote: integer);
882 for i := 0 to FBottleLogList.Count - 1 do begin
883 if (FBottleLogList[i] as TBottleLogList).Bottle(MID) <> nil then begin
884 (FBottleLogList[i] as TBottleLogList).Bottle(MID).Votes := Vote;
888 if flag then lvwLog.Invalidate;
891 procedure TfrmLog.tabBottleLogChanging(Sender: TObject;
892 var AllowChange: Boolean);
894 //
\8c»
\8dÝ
\91I
\91ð
\82³
\82ê
\82Ä
\82¢
\82é
\83\8d\83O
\82Ì
\91I
\91ð
\8fó
\91Ô
\82ð
\95Û
\91¶
895 if SelectedBottleLog = nil then Exit;
896 if lvwLog.Selected <> nil then
897 SelectedBottleLog.SelectedIndex := lvwLog.Selected.Index
899 SelectedBottleLog.SelectedIndex := -1;
902 procedure TfrmLog.tabBottleLogContextPopup(Sender: TObject;
903 MousePos: TPoint; var Handled: Boolean);
905 with tabBottleLog do begin
906 Tag := IndexOfTabAt(MousePos.X, MousePos.Y);
907 if Tag < 0 then Handled := true;
911 procedure TfrmLog.mnCloseTabClick(Sender: TObject);
912 var PrevSelection: TBottleLogList; //
\95Â
\82¶
\82½
\82Æ
\82«
\83^
\83u
\82ª
\82¸
\82ê
\82È
\82¢
\82æ
\82¤
\82É
\82·
\82é
\8f\88\97\9d\97p
915 PrevSelection := SelectedBottleLog;
916 FBottleLogList.Delete(tabBottleLog.Tag);
918 //
\83^
\83u
\82¸
\82ê
\96h
\8e~
\8f\88\97\9d
919 for i := 0 to FBottleLogList.Count-1 do
920 if FBottleLogList[i] = PrevSelection then
921 tabBottleLog.TabIndex := i;
923 lvwLogChange(Self, nil, ctState);
926 procedure TfrmLog.tbtnFindBottleClick(Sender: TObject);
928 ResultLog: TBottleLogList;
929 Item1, Item2: TLogItem;
932 if SelectedBottleLog = nil then Exit;
933 if SelectedBottleLog.Count = 0 then begin
934 ShowMessage('
\8c\9f\8dõ
\91Î
\8fÛ
\82ª
\8bó
\82Å
\82·
\81B');
939 if InputQuery('
\83X
\83N
\83\8a\83v
\83g
\96{
\95¶
\82ð
\8c\9f\8dõ', '
\8c\9f\8dõ
\95¶
\8e\9a\97ñ', Query) then begin
940 if Query = '' then Exit;
941 ResultLog := TBottleLogList.Create('
\8c\9f\8dõ
\8c\8b\89Ê');
942 for i := 0 to SelectedBottleLog.Count-1 do begin
943 Item1 := SelectedBottleLog.Items[i] as TLogItem;
944 if AnsiContainsText(Item1.Script, Query) and (Item1.LogType = ltBottle) then begin
945 matched := matched + 1;
946 Item2 := TLogItem.Create(ltBottle, Item1.MID, Item1.Channel,
947 Item1.Script, Item1.Ghost, Item1.LogTime);
948 Item2.State := lsOpened;
949 Item2.Votes := Item1.Votes;
950 Item2.Agrees := Item1.Agrees;
951 ResultLog.Add(Item2);
955 ResultLog.AddSystemLog('
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ
\82Å
\82µ
\82½');
956 BottleLogList.Add(ResultLog);
958 tabBottleLog.TabIndex := BottleLogList.Count-1;
963 procedure TfrmLog.tbtnOpenLogClick(Sender: TObject);
964 var BottleLog: TBottleLogList;
968 if OpenDialog.Execute then begin
969 for i := 0 to OpenDialog.Files.Count-1 do begin
970 BottleLog := TBottleLogList.Create(ExtractFileName(OpenDialog.Files[i]));
974 OnLoaded := LogLoaded;
975 OnLoadFailure := LogLoadFailure;
976 OnLoadWork := LogLoadWork;
977 BottleLog.LoadFromXMLFile(OpenDialog.Files[i]);
979 Index := BottleLogList.Add(BottleLog); //
\8dÅ
\8cã
\82É
\8aJ
\82¢
\82½
\83\8d\83O
\82Ì
\88Ê
\92u
\82ð
\8bL
\89¯
985 if Index >= 0 then tabBottleLog.TabIndex := Index;
990 function TfrmLog.GetDefaultFileName(const Name, Ext: String): String;
992 Result := StringReplace(Name, '/', '', [rfReplaceAll]);
993 Result := StringReplace(Result, ' ', '', [rfReplaceAll]);
994 Result := ChangeFileExt(Result, Ext);
997 function TfrmLog.BottleLogTitled(const LogName: String): TBottleLogList;
1000 for i := 0 to FBottleLogList.Count-1 do begin
1001 if (FBottleLogList[i] as TBottleLogList).Title = LogName then begin
1002 Result := (FBottleLogList[i] as TBottleLogList);
1006 //
\8c©
\82Â
\82©
\82ç
\82È
\82¢
\8fê
\8d\87
1007 Result := TBottleLogList.Create(LogName); //
\90V
\82µ
\82
\8dì
\82é
1008 FBottleLogList.Add(Result);
1010 if FBottleLogList.Count = 1 then tabBottleLog.TabIndex := 0;
1013 procedure TfrmLog.AllBottleOpened;
1015 Log: TBottleLogList;
1017 for i := 0 to FBottleLogList.Count-1 do begin
1018 Log := FBottleLogList[i] as TBottleLogList;
1019 for j := 0 to Log.Count-1 do begin
1020 Log.Bottles[j].State := lsOpened;
1025 procedure TfrmLog.tabBottleLogMouseDown(Sender: TObject;
1026 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
1029 with tabBottleLog do begin
1030 Index := IndexOfTabAt(X, Y);
1031 if Index = -1 then Exit; //
\83^
\83u
\82ª
\82È
\82¢
\82Ì
\82Å
\83h
\83\89\83b
\83O
\82Å
\82«
\82È
\82¢
1032 if Button = mbLeft then begin
1033 FDragTabIndex := Index; //
\83h
\83\89\83b
\83O
\82·
\82é
\83^
\83u
\82Ì
\83C
\83\93\83f
\83b
\83N
\83X
\82ð
\95Û
\91¶
1035 FDragTabDest := -1; //
\83h
\83\89\83b
\83O
\98g
\90ü
\95`
\89æ
\83t
\83\89\83O
\83N
\83\8a\83A
\82Ì
\82½
\82ß
1040 procedure TfrmLog.tabBottleLogDragOver(Sender, Source: TObject; X,
1041 Y: Integer; State: TDragState; var Accept: Boolean);
1042 var TargetRect: TRect;
1043 OldDest, Index: integer;
1046 //
\83^
\83u
\82Ì
\83h
\83\89\83b
\83O(
\83^
\83u
\82Ì
\8f\87\94Ô
\93ü
\82ê
\91Ö
\82¦)
\82Ü
\82½
\82Í
\81A
1047 //
\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Ì
1048 //
\97¼
\95û
\82Ì
\83h
\83\89\83b
\83O
\82ð
\8eó
\82¯
\95t
\82¯
\82é
1050 if Source = tabBottleLog then
1052 //
\83^
\83u
\82Ì
\8f\87\94Ô
\93ü
\82ê
\91Ö
\82¦
\82Ì
\8fê
\8d\87
1054 with tabBottleLog do begin
1055 OldDest := FDragTabDest;
1056 FDragTabDest := IndexOfTabAt(X, Y);
1057 if FDragTabDest = -1 then begin
1058 Accept := false; //
\82±
\82Ì
\8fê
\8d\87\82Í
\83h
\83\8d\83b
\83v
\82ð
\94F
\82ß
\82È
\82¢
1061 with Canvas do begin
1065 if (OldDest <> FDragTabDest) and (OldDest >= 0) then begin
1066 //
\88È
\91O
\82Ì
\98g
\90ü
\8fÁ
\8b\8e
1067 TargetRect := TabRect(OldDest);
1068 with Canvas do begin
1069 Brush.Style := bsClear;
1070 Rectangle(TargetRect.Left, TargetRect.Top,
1071 TargetRect.Right, TargetRect.Bottom);
1074 if (OldDest <> FDragTabDest) then begin
1075 //
\90V
\82µ
\82¢
\98g
\90ü
\95`
\89æ
1076 TargetRect := TabRect(FDragTabDest);
1077 with Canvas do begin
1078 Brush.Style := bsClear;
1079 Rectangle(TargetRect.Left, TargetRect.Top,
1080 TargetRect.Right, TargetRect.Bottom);
1084 end else if Source is TBottleLogDragObject then
1086 //
\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
1087 Index := tabBottleLog.IndexOfTabAt(X, Y);
1088 if tabBottleLog.TabIndex <> Index then
1090 FLVDragDest := -1; //
\98g
\90ü
\82Í
\82Ü
\82¾
\95\
\8e¦
\82³
\82ê
\82È
\82¢
\82Í
\82¸
1091 //
\83^
\83u
\82ð
\90Ø
\91Ö
\82¦
\82é
1092 tabBottleLogChanging(Self, dummy);
1093 tabBottleLog.TabIndex := Index;
1099 procedure TfrmLog.tabBottleLogDragDrop(Sender, Source: TObject; X,
1101 var DestIndex: integer;
1103 with tabBottleLog do begin
1104 DestIndex := IndexOfTabAt(X, Y);
1105 Tabs.Move(FDragTabIndex, DestIndex);
1106 FBottleLogList.Move(FDragTabIndex, DestIndex);
1110 procedure TfrmLog.tabBottleLogEndDrag(Sender, Target: TObject; X,
1113 //
\8b
\90§
\93I
\82É
\83^
\83u
\82ð
\8dÄ
\95`
\89æ
\82³
\82¹
\82é
\81B
\98g
\90ü
\8fÁ
\82µ
\91Î
\8dô
1114 tabBottleLog.Tabs.BeginUpdate;
1115 tabBottleLog.Tabs.EndUpdate;
1118 procedure TfrmLog.LogLoadWork(Sender: TObject);
1120 if Sender = SelectedBottleLog then lvwLog.Invalidate;
1123 procedure TfrmLog.lvwLogDrawItem(Sender: TCustomListView; Item: TListItem;
1124 Rect: TRect; State: TOwnerDrawState);
1131 DummyStr: TStringList;
1133 Bottle := SelectedBottleLog.Bottles[Item.Index];
1134 if Bottle.HasURL = huUndefined then
1136 DummyStr := TStringList.Create;
1138 ExtractURLs(Bottle.Script, DummyStr);
1139 if DummyStr.Count > 0 then
1140 Bottle.HasURL := huYes
1142 Bottle.HasURL := huNo;
1148 //
\94w
\8ci
\8fÁ
\8b\8e
1149 ListView_GetItemRect(lvwLog.Handle, Item.Index, DestRect, LVIR_BOUNDS);
1151 //
\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è
1152 lvwLog.Canvas.Brush.Style := bsSolid;
1153 if Item.Selected then begin
1154 if lvwLog.Focused then
1155 lvwLog.Canvas.Brush.Color := clHighlight
1157 lvwLog.Canvas.Brush.Color := clBtnFace;
1159 lvwLog.Canvas.Brush.Color := Pref.BgColor;
1161 lvwLog.Canvas.FillRect(DestRect);
1162 lvwLog.Canvas.Brush.Style := bsClear;
1163 //
\83t
\83H
\81[
\83J
\83X
\82ª
\82 \82é
\8fê
\8d\87\82É
\82Í
\83t
\83H
\81[
\83J
\83X
\82Ì
\98g
\90ü
\82ð
\88ø
\82
1164 if Item.Focused and lvwLog.Focused then
1165 lvwLog.Canvas.DrawFocusRect(DestRect);
1167 //
\83h
\83\89\83b
\83O
\92\86\82È
\82ç
\98g
\90ü
\82ð
\95`
\89æ
\82·
\82é
1168 if FLVDragDest = Item.Index then
1170 DestRect := Item.DisplayRect(drBounds);
1171 DrawListViewDragBorder(DestRect);
1174 if Item.Selected then
1176 if lvwLog.Focused then
1177 lvwLog.Canvas.Font.Color := clHighlightText
1179 lvwLog.Canvas.Font.Color := clWindowText;
1181 lvwLog.Canvas.Font.Color := Pref.TalkColorH;
1182 lvwLog.Canvas.Refresh;
1184 //
\83L
\83\83\83v
\83V
\83\87\83\93(
\93ú
\95t)
1185 ListView_GetItemRect(lvwLog.Handle, Item.Index, DestRect, LVIR_LABEL);
1186 Inc(DestRect.Left, 2);
1187 Inc(DestRect.Top, 2);
1188 Dec(DestRect.Right, 2);
1189 DrawTextEx(lvwLog.Canvas.Handle, PChar(Item.Caption), -1, DestRect,
1190 DT_SINGLELINE or DT_END_ELLIPSIS, nil);
1191 ListView_GetItemRect(lvwLog.Handle, Item.Index, DestRect, LVIR_ICON);
1192 Ico := TIcon.Create;
1194 lvwLog.SmallImages.GetIcon(Item.ImageIndex, Ico);
1195 lvwLog.Canvas.Draw(DestRect.Left, DestRect.Top, Ico);
1199 //
\83L
\83\83\83v
\83V
\83\87\83\93\82Å
\82à
\83X
\83N
\83\8a\83v
\83g
\82Å
\82à
\82È
\82¢
\82à
\82Ì
1200 for sub := 0 to Item.SubItems.Count-1 do
1202 if sub = SubScript then Continue;
1203 ListView_GetSubItemRect(lvwLog.Handle, Item.Index, sub + 1,
1204 LVIR_BOUNDS, @DestRect);
1205 Inc(DestRect.Left, 2);
1206 Inc(DestRect.Top, 2);
1207 Dec(DestRect.Right, 2);
1208 Ex := DT_NOPREFIX or DT_SINGLELINE or DT_END_ELLIPSIS;
1209 if lvwLog.Columns[sub+1].Alignment = taRightJustify then
1210 Ex := Ex or DT_RIGHT;
1211 DrawTextEx(lvwLog.Canvas.Handle, PChar(Item.SubItems[sub]), -1, DestRect,
1214 //
\83X
\83N
\83\8a\83v
\83g
1215 ListView_GetSubItemRect(lvwLog.Handle, Item.Index, SubScript + 1,
1216 LVIR_BOUNDS, @DestRect);
1217 Script := Item.SubItems[SubScript];
1218 DrawSingleLineScript(Bottle, DestRect, Item);
1222 procedure TfrmLog.DrawSingleLineScript(LogItem: TLogItem;
1223 Rect: TRect; Item: TListItem);
1226 UnyuTalking, Synchronized, Spaced: boolean;
1227 Mark: TSsMarkUpType;
1230 procedure ScopeChange;
1232 if (not Spaced) and (Pref.LogListPreviewStyle = psTagStripped) then
1239 Script := LogItem.Script;
1242 if LogItem.HasURL = huYes then
1244 Ico := TIcon.Create;
1246 lvwLog.SmallImages.GetIcon(IconURL, Ico);
1247 lvwLog.Canvas.Draw(Rect.Left + x, Rect.Top, Ico);
1254 if Pref.LogListPreviewStyle = psNoColor then
1259 DrawTextEx(lvwLog.Canvas.Handle, PChar(Script), -1, Rect,
1260 DT_SINGLELINE or DT_END_ELLIPSIS or DT_NOPREFIX, nil);
1264 SsParser.LeaveEscape := Pref.LogListPreviewStyle = psNormal;
1265 SsParser.InputString := Script;
1267 UnyuTalking := false;
1268 Synchronized := false;
1269 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¢
1270 //
\82½
\82ß
\82Ì
\83t
\83\89\83O
1271 for i := 0 to SsParser.Count - 1 do begin
1272 if SsParser[i] = '\h' then
1274 UnyuTalking := false;
1276 end else if SsParser[i] = '\u' then
1278 UnyuTalking := true;
1280 end else if SsParser[i] = '\_s' then
1282 Synchronized := not Synchronized;
1284 end else if (Pos('\n', SsParser[i]) = 1) or (SsParser[i] = '\c') then
1288 Mark := SsParser.MarkUpType[i];
1292 lvwLog.Canvas.Font.Color := Pref.MetaWordColor;
1296 if Pref.LogListPreviewStyle = psNormal then
1297 lvwLog.Canvas.Font.Color := Pref.MarkUpColor
1303 lvwLog.Canvas.Font.Color := Pref.MarkErrorColor;
1306 if Synchronized then
1307 lvwLog.Canvas.Font.Color := Pref.TalkColorS
1308 else if UnyuTalking then
1309 lvwLog.Canvas.Font.Color := Pref.TalkColorU
1311 lvwLog.Canvas.Font.Color := Pref.TalkColorH;
1314 if Item.Selected then
1316 if lvwLog.Focused then
1317 lvwLog.Canvas.Font.Color := clHighlightText
1319 lvwLog.Canvas.Font.Color := clWindowText;
1321 lvwLog.Canvas.Refresh;
1322 w := lvwLog.Canvas.TextWidth(SsParser[i]);
1323 lvwLog.Canvas.TextRect(Rect, Rect.Left + x, Rect.Top + 2, SsParser[i]);
1325 if Rect.Right - Rect.Left < x then Break;
1329 procedure TfrmLog.mnListPreviewStyleClick(Sender: TObject);
1332 with PopupMenuListPreviewStyle do
1333 for i := 0 to Items.Count-1 do
1334 Items[i].Checked := (Sender as TMenuItem).Tag = Items[i].Tag;
1335 Pref.LogListPreviewStyle := TLogListPreviewStyle((Sender as TMenuItem).Tag);
1339 procedure TfrmLog.tbtnListPreviewStyleClick(Sender: TObject);
1342 sel := Ord(Pref.LogListPreviewStyle);
1344 if sel > Ord(High(TLogListPreviewStyle)) then sel := 0;
1345 Pref.LogListPreviewStyle := TLogListPreviewStyle(sel);
1349 procedure TfrmLog.PopupMenuListPreviewStylePopup(Sender: TObject);
1352 with PopupMenuListPreviewStyle do
1353 for i := 0 to Items.Count-1 do
1354 Items[i].Checked := Items[i].Tag = Ord(Pref.LogListPreviewStyle)
1357 procedure TfrmLog.PreviewStyleChange;
1359 if Pref.LogWindowPreviewStyle = psImageConversation then
1361 if Spps.Count = 0 then
1362 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');
1363 edtScript.Visible := false;
1364 TalkShowFrame.Visible := true;
1367 edtScript.Visible := true;
1368 TalkShowFrame.Visible := false;
1372 procedure TfrmLog.lvwLogDragOver(Sender, Source: TObject; X, Y: Integer;
1373 State: TDragState; var Accept: Boolean);
1377 Rec: TRect; //
\83_
\83~
\81[
\81B
1380 //
\82Æ
\82è
\82 \82¦
\82¸
\8eó
\82¯
\95t
\82¯
\82é
\89Â
\94\
\90«
\82ª
\82 \82é
\82Ì
\82ÍTBottleLogDragObject
\82¾
\82¯
1381 if not (Source is TBottleLogDragObject) then
1384 Target := lvwLog.GetItemAt(X, Y);
1386 //
\82±
\82ê
\88È
\91O
\82É
\95`
\89æ
\82³
\82ê
\82Ä
\82¢
\82½
\98g
\82Ì
\83C
\83\93\83f
\83b
\83N
\83X
1387 OldDest := FLVDragDest;
1389 //
\83h
\83\8d\83b
\83v
\88Ê
\92u
\82É Item
\82ª
\82 \82ê
\82Î
\83h
\83\8d\83b
\83v
\82ð
\8b\96\89Â
\82·
\82é
1390 if Target <> nil then
1393 FLVDragDest := Target.Index;
1400 //
\88È
\91O
\82Ì
\98g
\90ü
\82ð
\8dí
\8f\9c
1401 if (OldDest > -1) and (FLVDragDest <> OldDest) then
1403 Rec := lvwLog.Items[OldDest].DisplayRect(drBounds);
1404 DrawListViewDragBorder(Rec);
1406 //
\83h
\83\89\83b
\83O
\90æ
\82Ì
\98g
\90ü
\82ð
\95`
\89æ
1407 if (Target <> nil) and (FLVDragDest <> OldDest) then
1409 Rec := Target.DisplayRect(drBounds);
1410 DrawListViewDragBorder(Rec);
1413 //
\83X
\83N
\83\8d\81[
\83\8b\8aÖ
\8cW
1414 if lvwLog.Items.Count > 0 then
1416 if (lvwLog.topItem <> nil) and (Y - lvwLog.TopItem.Top < 10) then
1418 FLVScrollDir := lvScrollDown;
1419 if not timScrollTimer.Enabled then
1420 timScrollTimer.Enabled := true;
1421 end else if (lvwLog.Height - Y) < 10 then
1423 FLVScrollDir := lvScrollUp;
1424 if not timScrollTimer.Enabled then
1425 timScrollTimer.Enabled := true;
1428 timScrollTimer.Enabled := false;
1430 timScrollTimer.Enabled := false;
1433 procedure TfrmLog.lvwLogDragDrop(Sender, Source: TObject; X, Y: Integer);
1435 TargetItem: integer;
1436 Src: TBottleLogDragObject;
1439 timScrollTimer.Enabled := false;
1441 if not (Source is TBottleLogDragObject) then
1443 Src := Source as TBottleLogDragObject;
1445 if lvwLog.GetItemAt(X, Y) <> nil then
1446 TargetItem := lvwLog.GetItemAt(X, Y).Index
1450 lvwLog.Items.BeginUpdate; //
\83h
\83\8d\83b
\83v
\92\86\82Í
\95\
\8e¦
\82ð
\97}
\8e~
\82·
\82é
\81@
\8fd
\97v
\81I
1452 //
\83h
\83\8d\83b
\83v
\88Ê
\92u
\82É Item
\82ð
\88Ú
\93®
\82·
\82é
1453 SrcLog := Src.BottleLogList.Extract(Src.LogItem);
1454 if TargetItem >= 0 then
1456 //
\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
1457 SelectedBottleLog.Insert(TargetItem, SrcLog);
1460 // ListView
\82Ì
\97]
\94\92\82É
\83h
\83\8d\83b
\83v
\82µ
\82½
\8fê
\8d\87(Insert
\82Å
\82«
\82È
\82¢)
1461 TargetItem := SelectedBottleLog.Add(SrcLog);
1463 lvwLog.Items[TargetItem].Selected := true;
1464 lvwLog.Items[TargetItem].Focused := true;
1466 lvwLog.Items.EndUpdate;
1471 procedure TfrmLog.timScrollTimerTimer(Sender: TObject);
1473 ScrollHeight: Integer;
1475 //
\83X
\83N
\83\8d\81[
\83\8b\97Ê
\82ð
\8b\81\82ß
\82é
1477 if lvwLog.Items.Count > 2 then
1479 ScrollHeight := lvwLog.Items[1].Top - lvwLog.Items[0].Top;
1482 case FLVScrollDir of
1483 lvScrollUp: lvwLog.Scroll(0, ScrollHeight);
1484 lvSCrollDown: lvwLog.Scroll(0, -ScrollHeight);
1486 lvwLog.Invalidate; //
\8dÅ
\90V
\82Ì
\8fó
\91Ô
\82É
\8dÄ
\95`
\89æ
\82·
\82é
1490 procedure TfrmLog.mnChangeTabNameClick(Sender: TObject);
1493 Name := (FBottleLogList[tabBottleLog.Tag] as TBottleLogList).Title;
1494 InputQuery('
\96¼
\91O
\82Ì
\95Ï
\8dX', '
\90V
\82µ
\82¢
\83^
\83u
\82Ì
\96¼
\91O', Name);
1495 (FBottleLogList[tabBottleLog.Tag] as TBottleLogList).Title := Name;
1499 procedure TfrmLog.lvwLogStartDrag(Sender: TObject;
1500 var DragObject: TDragObject);
1501 var Drag: TBottleLogDragObject;
1503 //
\92Ê
\8fí
\82ÌListView
\97p
\82Ì
\83h
\83\89\83b
\83O
\83I
\83u
\83W
\83F
\83N
\83g
\82Í
1504 // 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
1505 // 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Æ
1506 //
\94¼
\93§
\96¾
\83C
\83\81\81[
\83W
\82Ì
\95`
\89æ
\82Í
\97}
\90§
\82Å
\82«
\82é
\81B
1507 Drag := TBottleLogDragObject.Create(lvwLog);
1508 Drag.BottleLogList := SelectedBottleLog;
1509 Drag.LogItem := SelectedBottleLog.Bottles[lvwLog.Selected.Index];
1513 procedure TfrmLog.lvwLogEndDrag(Sender, Target: TObject; X, Y: Integer);
1515 //
\98g
\90ü
\8fÁ
\82µ
\97p
\82É
\8b
\90§
\93I
\82É
\8dÄ
\95`
\89æ
\82³
\82¹
\82é
1516 timScrollTimer.Enabled := false;
1521 procedure TfrmLog.DrawListViewDragBorder(const Rect: TRect);
1525 InflateRect(Rec, -1, -1);
1526 with lvwLog.Canvas do
1530 Brush.Style := bsClear;
1531 Refresh; //
\95K
\97v
1536 { TBottleLogDragObject }
1538 function TBottleLogDragObject.GetDragImages: TDragImageList;
1540 //
\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é
1544 procedure TBottleLogDragObject.SetBottleLogList(
1545 const Value: TBottleLogList);
1547 FBottleLogList := Value;
1550 procedure TBottleLogDragObject.SetLogItem(const Value: TLogItem);