using Cthangover.Core.Factories;
using Cthangover.Core.UI;
using Cthangover.Mods.Interface.Base.Lists;
using Cthangover.Core.UI.Dialog;
using Cthangover.Core.UI.Event;
using Cthangover.Core.UI.Executable;
using Cthangover.Core.Scenarios;
using Cthangover.Core.Scenes;
using Cthangover.Core.Interactive;
namespace Cthangover.Mods.Dialog.Action.Impls
{
///
/// The primary dialog text display action. Sets the text and both avatar slots
/// (left/right) on the DialogBox. WaitType is WaitClick so the dialog pauses
/// for player input before advancing. Avatars are resolved through
/// IAvatarProvider by string ID; a null/empty avatar hides that slot. When
/// UseProcessText is true, runtime variables (${var}) are substituted before display.
///
public class ActionText : ActionCommand
{
/// The dialog text to display. Supports ${var} substitution when is true.
public string Text { get; set; }
/// Left avatar sprite ID resolved through . Null or empty hides the slot.
public string FirstAvatar { get; set; }
/// Right avatar sprite ID resolved through . Null or empty hides the slot.
public string SecondAvatar { get; set; }
/// When true, the avatar is rendered in shader-based silhouette/hidden-color mode.
public bool HideColor { get; set; }
/// When true, runtime variable substitution (${var}) is applied to before display.
public bool UseProcessText { get; set; }
/// Pauses for player click/key input — the dialog waits for user acknowledgment.
public override WaitType WaitType { get; set; } = WaitType.WaitClick;
/// Sets the dialog text (optionally variable-substituted) and both avatar slots, then waits for the player's click.
public override void DoRun(DialogRuntime runtime)
{
var dialogBox = runtime.DialogBox;
if (dialogBox == null)
return;
var processedText = UseProcessText ? runtime.ProcessText(Text) : Text;
dialogBox.SetText(processedText);
dialogBox.SetFirstAvatar(AvatarProviderRegistry.Get(FirstAvatar), HideColor);
dialogBox.SetSecondAvatar(AvatarProviderRegistry.Get(SecondAvatar), HideColor);
}
}
}