OSDN Git Service

Do not have TLogItem inside the frame instance
authornaru <bottle@mikage.to>
Sun, 20 Apr 2003 10:23:47 +0000 (10:23 +0000)
committernaru <bottle@mikage.to>
Sun, 20 Apr 2003 10:23:47 +0000 (10:23 +0000)
Fix: DT_NOPREFIX is not specified
Modified that \n tag breaks the line

bottleclient/TalkShowFrame.pas

index 6b201a4..a4fba76 100644 (file)
@@ -17,7 +17,8 @@ type
     procedure FrameResize(Sender: TObject);
   private
     FSsParser: TSsParser;
-    FLog: TLogItem;
+    FGhost: String;
+    FScript: String;
     FWholeHeight: integer;
     procedure SetSsParser(const Value: TSsParser);
   protected
@@ -28,7 +29,8 @@ type
   public
     { Public \90é\8c¾ }
     property SsParser: TSsParser read FSsParser write SetSsParser;
-    procedure View(ALog: TLogItem);
+    procedure View(ALog: TLogItem); overload;
+    procedure View(Script, Ghost: String); overload;
   end;
 
 implementation
@@ -44,15 +46,11 @@ end;
 
 procedure TfrmTalkShow.View(ALog: TLogItem);
 begin
-  if FLog <> nil then
-  begin
-    if (ALog.Ghost = FLog.Ghost) and (ALog.Script = FLog.Script) then
-      Exit
-    else
-      FreeAndNil(FLog);
-  end;
+  if (ALog.Ghost = FGhost) and (ALog.Script = FScript) then
+    Exit;
+  FGhost := ALog.Ghost;
+  FScript := ALog.Script;
   FSsParser.InputString := ALog.Script;
-  FLog := TLogItem.Create(ALog);
   FWholeHeight := -1; // \96¢\92è\8b`
   PaintBoxPaint(self);
 end;
@@ -89,6 +87,8 @@ begin
     FillRect(Rect(0, 0, PaintBox.Width, PaintBox.Height));
     Brush.Style := bsClear;
   end;
+  if FSsParser.InputString <> FScript then
+    FSsParser.InputString := FScript;
 
   if FWholeHeight < 0 then // -1\82Í\96¢\92è\8b`
     y := 2
@@ -102,11 +102,11 @@ begin
   //
   for i := 0 to FSsParser.Count-1 do
   begin
-    if (FSsParser[i] = '\h') and UnyuTalking then
+    if (FSsParser[i] = '\h') and UnyuTalking and not InSync then
     begin
       TalkEnd;
       UnyuTalking := false;
-    end else if (FSsParser[i] = '\u') and not UnyuTalking then
+    end else if (FSsParser[i] = '\u') and not UnyuTalking and not InSync then
     begin
       TalkEnd;
       UnyuTalking := true;
@@ -138,6 +138,9 @@ begin
         sur1 := sur
       else
         sur0 := sur;
+    end else if FSsParser.Match(FSsParser[i], '\n') > 2 then
+    begin
+      Talk := Talk + #13#10;
     end else if FSsParser.MarkUpType[i] in [mtStr, mtMeta] then
     begin
       Talk := Talk + FSsParser[i];
@@ -181,7 +184,7 @@ begin
 
     ARect := Rect(X + 10, VertPos, PaintBox.Width-5, VertPos+10000);
     H := DrawTextEx(PaintBox.Canvas.Handle, PChar(Talk), -1, ARect,
-      DT_WORDBREAK, nil);
+      DT_WORDBREAK or DT_NOPREFIX, nil);
 
     if H > BH then
       Result := H
@@ -204,7 +207,7 @@ begin
   Result := 0;
   Bmp := TBitmap.Create;
   try
-    if Spps.TryGetImage(FLog.Ghost, Surface, Bmp) then
+    if Spps.TryGetImage(FGhost, Surface, Bmp) then
     begin
       Result := Bmp.Width;
       PaintBox.Canvas.Draw(X, Y, Bmp);
@@ -221,4 +224,15 @@ begin
   FWholeHeight := -1; // \8d\82\82³\82ª\82í\82©\82ç\82È\82­\82È\82é
 end;
 
+procedure TfrmTalkShow.View(Script, Ghost: String);
+begin
+  if (Ghost = FGhost) and (Script = FScript) then
+    Exit;
+  FGhost := Ghost;
+  FScript := Script;
+  FSsParser.InputString := FScript;
+  FWholeHeight := -1; // \96¢\92è\8b`
+  PaintBoxPaint(self);
+end;
+
 end.