dialogs.py

No documentation

class DialogBox

Description

RPG-style dialog box with multiple display styles and text animations.
Supports typewriter effect, fade-in, and character-by-character display.

Attributes
_properties: Dict[str, Dict[str, Any]] = {**UIElement._properties, 'style': {'name': 'style', 'key': 'style', 'type': str, 'editable': True, 'description': 'Visual style: "default", "rpg", "pokemon", "modern".', 'options': ['default', 'rpg', 'pokemon', 'modern']}, 'text': {'name': 'text', 'key': 'text', 'type': str, 'editable': True, 'description': 'The dialog text content.'}, 'speaker_name': {'name': 'speaker name', 'key': 'speaker_name', 'type': str, 'editable': True, 'description': 'Name of the speaker displayed above the box.'}, 'animation_type': {'name': 'animation type', 'key': 'animation_type', 'type': str, 'editable': True, 'description': 'Type of text animation: "typewriter".'}, 'animation_speed': {'name': 'animation speed', 'key': 'animation_speed', 'type': int, 'editable': True, 'description': 'Characters per second for typewriter effect.'}}
Methods
def __init__(self: Any, x: int, y: int, width: int, height: int, style: Literal['default', 'rpg', 'pokemon', 'modern'] = 'default', theme: Optional[ThemeType] = None, element_id: Optional[str] = None) -> None
Initialize a dialog box.

Args:
   x: X coordinate (before anchor).
   y: Y coordinate (before anchor).
   width: Width of dialog box.
   height: Height of dialog box.
   style: Visual style ("default", "rpg", "pokemon", "modern").
   theme: Theme to apply.
   element_id: Custom element ID.
def _get_init_args(self: Any) -> Dict[str, Any]
No documentation
def set_text(self: Any, text: str, speaker_name: str = '', instant: bool = False) -> None
Set the dialog text and start animation.

Args:
   text: The full text to display.
   speaker_name: Name of the speaker (shown above box).
   instant: If True, show all text immediately without animation.
def set_animation(self: Any, animation_type: str, speed: int = 30) -> None
Configure text animation.

Args:
   animation_type: Currently only "typewriter" is supported.
   speed: Characters per second.
def skip_animation(self: Any) -> None
Immediately finish the text animation and mark as complete.
def advance(self: Any) -> bool
Advance the dialog (skip animation or move to next dialog).
Returns True if the dialog is still active, False if it should be closed.
def set_on_complete(self: Any, callback: Callable[[], None]) -> None
Register a callback called when text animation finishes.
def set_on_advance(self: Any, callback: Callable[[], None]) -> None
Register a callback called when the user advances to the next dialog (after completion).
def update(self: Any, dt: float, inputState: InputState) -> None
No documentation
def render(self: Any, renderer: Renderer) -> None
No documentation
def _render_wrapped_text(self: Any, renderer: Renderer, x: int, y: int, width: int, height: int, theme: Any) -> None
No documentation
Back to Ui Module