17 private const int SpeakerHeight = 30;
18 private const int ContinueIndicatorWidth = 28;
19 private const int ContinueIndicatorHeight = 22;
20 private const int ContentInset = 10;
22 private string _speaker;
24 private bool _continueIndicatorVisible =
true;
46 string? nickname =
null)
50 ValidateBounds(bounds).Location,
53 ArgumentNullException.ThrowIfNull(view);
55 _speaker = speaker ??
string.Empty;
56 _text = text ??
string.Empty;
58 Panel = CreatePanel(renderSurfaceHost, view, bounds);
63 GetSpeakerBounds(bounds),
69 GetBodyBounds(bounds),
72 ContinueIndicator = CreateContinueIndicator(renderSurfaceHost, view, GetContinueBounds(bounds));
79 CompleteInitialization();
97 string? nickname =
null)
101 ValidateBounds(bounds).Location,
104 ArgumentNullException.ThrowIfNull(sceneLayer);
106 _speaker = speaker ??
string.Empty;
107 _text = text ??
string.Empty;
109 Panel = CreatePanel(renderSurfaceHost, sceneLayer, bounds);
114 GetSpeakerBounds(bounds),
120 GetBodyBounds(bounds),
123 ContinueIndicator = CreateContinueIndicator(renderSurfaceHost, sceneLayer, GetContinueBounds(bounds));
130 CompleteInitialization();
202 _speaker = speaker ??
string.Empty;
214 _text = text ??
string.Empty;
226 _continueIndicatorVisible = visible;
227 ContinueIndicator.Visible = visible;
239 SpeakerText.SetColors(speakerColor, SKColors.Transparent);
240 BodyText.SetColors(bodyColor, SKColors.Transparent);
253 .SetBorderColor(border);
266 Panel.ZOrder = zOrder;
267 SpeakerText.ZOrder = zOrder + 1;
268 BodyText.ZOrder = zOrder + 1;
269 ContinueIndicator.ZOrder = zOrder + 2;
288 ContinueIndicator.Visible = _continueIndicatorVisible;
294 base.OnPointerClick(args);
306 base.OnKeyboardInput(args);
318 private void CompleteInitialization()
330 return ConfigurePanel(
347 return ConfigurePanel(
372 private static TextBlock CreateSpeakerText(
373 RenderSurfaceHostBase host,
378 return ConfigureSpeakerText(
new TextBlock(host, view, bounds), speaker);
381 private static TextBlock CreateSpeakerText(
382 RenderSurfaceHostBase host,
387 return ConfigureSpeakerText(
392 worldBounds: bounds),
396 private static TextBlock ConfigureSpeakerText(TextBlock textBlock,
string speaker)
398 return textBlock.
SetText(speaker)
399 .
SetFont(SKTypeface.Default, 17f, minSize: 11f)
400 .
SetColors(
new SKColor(255, 224, 145), SKColors.Transparent)
401 .
SetAlignment(SKTextAlign.Left, TextBlock.VerticalAlign.Center)
406 private static TextBlock CreateBodyText(
407 RenderSurfaceHostBase host,
412 return ConfigureBodyText(
new TextBlock(host, view, bounds), text);
415 private static TextBlock CreateBodyText(
416 RenderSurfaceHostBase host,
421 return ConfigureBodyText(
426 worldBounds: bounds),
430 private static TextBlock ConfigureBodyText(TextBlock textBlock,
string text)
433 .
SetFont(SKTypeface.Default, 16f, minSize: 10f)
434 .
SetColors(SKColors.White, SKColors.Transparent)
435 .
SetAlignment(SKTextAlign.Left, TextBlock.VerticalAlign.Top)
440 private static TextBlock CreateContinueIndicator(
441 RenderSurfaceHostBase host,
445 return ConfigureContinueIndicator(
new TextBlock(host, view, bounds));
448 private static TextBlock CreateContinueIndicator(
449 RenderSurfaceHostBase host,
453 return ConfigureContinueIndicator(
458 worldBounds: bounds));
461 private static TextBlock ConfigureContinueIndicator(TextBlock textBlock)
464 .
SetFont(SKTypeface.Default, 14f, minSize: 9f)
465 .
SetColors(SKColors.White, SKColors.Transparent)
466 .
SetAlignment(SKTextAlign.Center, TextBlock.VerticalAlign.Center)
470 private static Rectangle GetSpeakerBounds(Rectangle bounds)
473 bounds.X + ContentInset,
475 Math.Max(1, bounds.Width - ContentInset * 2),
479 private static Rectangle GetBodyBounds(Rectangle bounds)
481 int top = bounds.Y + SpeakerHeight + 4;
482 int bottom = bounds.Bottom - ContinueIndicatorHeight - 4;
485 bounds.X + ContentInset,
487 Math.Max(1, bounds.Width - ContentInset * 2),
488 Math.Max(1, bottom - top));
491 private static Rectangle GetContinueBounds(Rectangle bounds)
494 bounds.Right - ContentInset - ContinueIndicatorWidth,
495 bounds.Bottom - ContinueIndicatorHeight - 4,
496 ContinueIndicatorWidth,
497 ContinueIndicatorHeight);
500 private static Rectangle ValidateBounds(Rectangle bounds)
502 if (bounds.Width < 120 || bounds.Height < SpeakerHeight + ContinueIndicatorHeight + 24)
503 throw new ArgumentOutOfRangeException(nameof(bounds), bounds,
"Conversation-box bounds are too small.");
SceneLayer? SceneLayer
Gets the scene layer shared by all children in scene-layer mode.
View? View
Gets the view shared by all children in view mode.
virtual DirectComposite Add(IDirectCompositeChild child, bool keepCurrentOffset=true, Vector2? explicitLocalOffsetPx=null)
Adds a composite-compatible direct drawable as a child.
DirectDrawingMode Mode
Gets the coordinate mode shared by the composite and its children.
Renders a configurable rectangle with support for fill, border, rounded corners, dash patterns,...
DirectRectangle SetFilled(bool isFilled)
Sets whether the rectangle interior is filled with the base color (or pattern).
DirectRectangle SetBorderColor(Color color)
Sets a distinct border (stroke) color, independent of the fill color.
DirectRectangle SetStrokeWidth(float width)
Sets the width (thickness) of the rectangle's stroke (outline) in pixels.
DirectRectangle SetCornerRadius(float radius)
Sets the radius for rounded corners in pixels.
A retained-mode text drawable with wrapping, multi-line ( ) support, horizontal/vertical alignment,...
TextBlock SetFont(SKTypeface typeface, float size, float? minSize=null)
Sets the font face and size (and optional minimum size for auto-shrink).
TextBlock EnableWrapping(bool enable=true)
Enables or disables word wrapping when laying out paragraphs.
TextBlock SetAlignment(SKTextAlign h, VerticalAlign v)
Sets the horizontal and vertical alignment used when drawing the laid-out lines within the bounds.
TextBlock SetPadding(float horizontal, float vertical)
Sets symmetric horizontal and vertical padding and invalidates cached layout.
TextBlock SetColors(SKColor fg, SKColor bg)
Sets the foreground (text) and background colors using Skia colors.
TextBlock SetText(string text)
Sets the current text content and rebuilds layout as needed. If no reveal animation is active,...
Represents a base class for hosting a render surface, providing functionality for managing rendering ...
Represents a rendered view of a scene, combining a camera position with a viewport configuration to c...
Represents a single layer within a Scene, containing a grid of tiles and supporting various coordinat...
@ Rectangle
Particles are spawned uniformly within a rectangular area. This is the default distribution.
DirectDrawingMode
Specifies where direct drawing operations are applied within the rendering pipeline.
@ View
Performs direct drawing at the view level using screen-space coordinates.