6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, SsParser, ExtCtrls, SppList, Logs,
11 TfrmTalkShow = class(TFrame)
14 ScrollBar: TScrollBar;
15 procedure PaintBoxPaint(Sender: TObject);
16 procedure ScrollBarChange(Sender: TObject);
17 procedure FrameResize(Sender: TObject);
18 procedure ScrollBarEnter(Sender: TObject);
23 FWholeHeight: integer;
25 FPrevControl: TWinControl;
26 procedure SetSsParser(const Value: TSsParser);
27 procedure SetPrevControl(const Value: TWinControl);
29 function DrawSingleTalk(VertPos: integer;
30 Sur0, Sur1: integer; Talk: String): integer;
31 function DrawSingleImage(X, Y, Surface: integer;
32 var Height: integer): integer;
33 function DrawSeparateLine(VertPos: integer): integer;
36 //
\82³
\82
\82ç
\83X
\83N
\83\8a\83v
\83g
\82Ì
\89ð
\90Í
\82É
\8eg
\82¤
\83p
\81[
\83T
37 property SsParser: TSsParser read FSsParser write SetSsParser;
38 //
\83X
\83N
\83\8d\81[
\83\8b\83o
\81[
\82ª
\83N
\83\8a\83b
\83N
\82³
\82ê
\82½
\8cã
\82Å
\83t
\83H
\81[
\83J
\83X
\82ð
\88Ú
\93®
\82·
\82é
\83R
\83\93\83g
\83\8d\81[
\83\8b
39 //
\83X
\83N
\83\8d\81[
\83\8b\83o
\81[
\8e©
\91Ì
\82ª
\83t
\83H
\81[
\83J
\83X
\82ð
\8e\9d\82Á
\82Ä
\82µ
\82Ü
\82í
\82È
\82¢
\82½
\82ß
\82Ì
\91[
\92u
40 property PrevControl: TWinControl read FPrevControl write SetPrevControl;
41 procedure View(ALog: TLogItem); overload;
42 procedure View(Script, Ghost: String); overload;
43 constructor Create(AOwner: TComponent); override;
44 destructor Destroy; override;
45 procedure SetPreviewFont(Font: TFont);
54 procedure TfrmTalkShow.SetSsParser(const Value: TSsParser);
59 procedure TfrmTalkShow.View(ALog: TLogItem);
61 if (ALog.Ghost = FGhost) and (ALog.Script = FScript) then
64 FScript := ALog.Script;
65 FWholeHeight := -1; //
\96¢
\92è
\8b`
69 procedure TfrmTalkShow.PaintBoxPaint(Sender: TObject);
70 var i, y, sur, sur0, sur1: integer;
71 UnyuTalking, InSync: boolean;
75 if FWholeHeight > 0 then // 2
\93x
\96Ú
\88È
\8d~
\82Ì
\95`
\89æ
\82Å
\82Í
76 if (i < FSsParser.Count) and
77 (StrToInt(FSsParser.Extra[i]) < ScrollBar.Position) then
79 y := StrToInt(FSsParser.Extra[i]) - ScrollBar.Position;
87 FBuffer.Canvas.Font.Color := Pref.TalkColorS;
88 y := y + DrawSingleTalk(y, sur0, sur1, Talk) + 5
89 end else if UnyuTalking then
91 FBuffer.Canvas.Font.Color := Pref.TalkColorU;
92 y := y + DrawSingleTalk(y, -1, sur1, Talk) + 5
94 FBuffer.Canvas.Font.Color := Pref.TalkColorH;
95 y := y + DrawSingleTalk(y, sur0, -1, Talk) + 5;
102 FBuffer.Width := PaintBox.Width;
103 FBuffer.Height := PaintBox.Height;
105 with FBuffer.Canvas do
107 Brush.Color := Pref.BgColor;
108 Brush.Style := bsSolid;
109 FillRect(Rect(0, 0, PaintBox.Width, PaintBox.Height));
110 Brush.Style := bsClear;
112 if FSsParser.InputString <> FScript then
116 LeaveEscape := false;
117 EscapeInvalidMeta := false;
118 InputString := FScript;
122 if FWholeHeight < 0 then // -1
\82Í
\96¢
\92è
\8b`
125 y := - ScrollBar.Position + 2;
126 sur0 := 0; //
\83X
\83R
\81[
\83v0
\91¤
\8f\89\8aú
\83T
\81[
\83t
\83B
\83X
127 sur1 := 10; //
\83X
\83R
\81[
\83v1
\91¤
\8f\89\8aú
\83T
\81[
\83t
\83B
\83X
129 UnyuTalking := false;
133 while i < FSsParser.Count do
135 case FSsParser.MarkUpType[i] of
138 if (FSsParser[i] = '\h') and UnyuTalking then
142 UnyuTalking := false;
143 end else if (FSsParser[i] = '\u') and not UnyuTalking then
148 end else if FSsParser[i] = '\_s' then
151 InSync := not InSync;
152 end else if (FSsParser.Match(FSsParser[i], '\s[%D]') > 0) or (FSsParser[i] = '\s[-1]') then
155 sur := StrToInt(FSsParser.GetParam(FSsParser[i], 1));
160 end else if UnyuTalking then
164 end else if FSsParser.Match(FSsParser[i], '\s%d') > 0 then
167 sur := Ord(FSsParser[i][3]) - Ord('0');
172 end else if UnyuTalking then
176 end else if FSsParser.Match(FSsParser[i], '\n') >= 2 then
179 Talk := Talk + #13#10;
180 end else if FSsParser[i] = '\c' then
183 y := y + DrawSeparateLine(y);
187 Talk := Talk + FSsParser[i];
189 if FWholeHeight < 0 then //
\8f\89\89ñ
\82Ì
\95`
\89æ
\82Å
\82Í
191 //
\8e©
\95ª
\82ª
\95`
\89æ
\82³
\82ê
\82½
\8cã
\82Ì
\88Ê
\92u
\82ð
\8bL
\89¯
\82µ
\82Ä
\82¨
\82
\81B
192 //
\8e\9f\89ñ
\88È
\8d~
\82Ì
\95`
\89æ
\82ª
\8d\82\91¬
\89»
\82³
\82ê
\82é
193 FSsParser.Extra[i] := IntToStr(y);
195 //
\95`
\89æ
\97Ì
\88æ
\82ª
\83E
\83B
\83\93\83h
\83E
\82Ì
\89º
\92[
\82ð
\89ß
\82¬
\82½
\82ç
196 //
\8fI
\97¹
\81A
\82½
\82¾
\82µ
\8f\89\89ñ
\95`
\89æ
\82¾
\82¯
\82Í
\91S
\91Ì
\82ð
\91\96\8d¸
197 if (y > ScrollBar.Position + PaintBox.Height) and
198 (FWholeHeight > 0) then
205 PaintBox.Canvas.Draw(0, 0, FBuffer);
207 if FWholeHeight = -1 then
209 if FScript <> '' then
211 ScrollBar.Position := 0;
212 if FWholeHeight > PaintBox.Height then
216 Max := FWholeHeight - PaintBox.Height;
219 LargeChange := PaintBox.Height;
220 SmallChange := PaintBox.Canvas.Font.Size;
221 // PageSize := Max * PaintBox.Height div FWholeHeight;
225 ScrollBar.Enabled := false;
230 function TfrmTalkShow.DrawSingleTalk(VertPos, Sur0, Sur1: integer;
231 Talk: String): integer;
236 Bmp := TBitmap.Create;
241 X := X + DrawSingleImage(X, VertPos, Sur0, BH) + 2;
243 X := X + DrawSingleImage(X, VertPos, Sur1, BH) + 2;
245 ARect := Rect(X + 10, VertPos, PaintBox.Width-5, VertPos+10000);
246 H := DrawTextEx(FBuffer.Canvas.Handle, PChar(Talk), -1, ARect,
247 DT_WORDBREAK or DT_NOPREFIX, nil);
258 procedure TfrmTalkShow.ScrollBarChange(Sender: TObject);
263 function TfrmTalkShow.DrawSingleImage(X, Y, Surface: integer;
264 var Height: integer): integer;
269 Exit; //
\83S
\81[
\83X
\83g
\82ª
\8ew
\92è
\82³
\82ê
\82Ä
\82¢
\82È
\82¢
\82È
\82ç
\95\
\8e¦
\82Å
\82«
\82È
\82¢
270 Bmp := TBitmap.Create;
272 if Spps.TryGetImage(FGhost, Surface, Bmp) then
275 FBuffer.Canvas.Draw(X, Y, Bmp);
276 if Bmp.Height > Height then
277 Height := Bmp.Height;
284 procedure TfrmTalkShow.FrameResize(Sender: TObject);
286 FWholeHeight := -1; //
\8d\82\82³
\82ª
\82í
\82©
\82ç
\82È
\82
\82È
\82é
289 procedure TfrmTalkShow.View(Script, Ghost: String);
291 if (Ghost = FGhost) and (Script = FScript) then
297 LeaveEscape := false;
298 EscapeInvalidMeta := false;
299 InputString := FScript;
301 FWholeHeight := -1; //
\96¢
\92è
\8b`
305 function TfrmTalkShow.DrawSeparateLine(VertPos: integer): integer;
307 with FBuffer.Canvas do
309 Pen.Color := Pref.TextColor;
312 LineTo(PaintBox.Width-5, VertPos);
317 constructor TfrmTalkShow.Create(AOwner: TComponent);
319 inherited Create(AOwner);
320 FBuffer := TBitmap.Create;
324 destructor TfrmTalkShow.Destroy;
330 procedure TfrmTalkShow.SetPreviewFont(Font: TFont);
332 FBuffer.Canvas.Font.Assign(Font);
335 procedure TfrmTalkShow.SetPrevControl(const Value: TWinControl);
337 FPrevControl := Value;
340 procedure TfrmTalkShow.ScrollBarEnter(Sender: TObject);
342 if PrevControl <> nil then
343 PrevControl.SetFocus;