Line endings: LF everywhere
.gitattributes forces LF (CRLF only for .bat/.cmd), core.autocrlf is off; files that differed only by CRLF are normalized.
This commit is contained in:
1 parent
bd55716349
commit
b5ad858c5e
51 files changed
+1781
-1751
No files matched your search
@@ -0,0 +1,30 @@
|
|||||||
|
# Line endings: LF everywhere, on every OS, whatever core.autocrlf says.
|
||||||
|
* text=auto eol=lf
|
||||||
|
|
||||||
|
# cmd.exe misreads labels and goto in LF batch files, so they stay CRLF.
|
||||||
|
*.bat text eol=crlf
|
||||||
|
*.cmd text eol=crlf
|
||||||
|
|
||||||
|
# Binaries: never converted, never diffed as text.
|
||||||
|
*.png binary
|
||||||
|
*.jpg binary
|
||||||
|
*.jpeg binary
|
||||||
|
*.webp binary
|
||||||
|
*.svg text
|
||||||
|
*.ogg binary
|
||||||
|
*.wav binary
|
||||||
|
*.mp3 binary
|
||||||
|
*.ttf binary
|
||||||
|
*.otf binary
|
||||||
|
*.woff binary
|
||||||
|
*.woff2 binary
|
||||||
|
*.dll binary
|
||||||
|
*.so binary
|
||||||
|
*.dylib binary
|
||||||
|
*.pdb binary
|
||||||
|
*.exe binary
|
||||||
|
*.zip binary
|
||||||
|
*.pck binary
|
||||||
|
*.moc3 binary
|
||||||
|
*.res binary
|
||||||
|
*.scn binary
|
||||||
+37
-37
@@ -1,37 +1,37 @@
|
|||||||
# Godot 4.x
|
# Godot 4.x
|
||||||
.godot/
|
.godot/
|
||||||
.idea/
|
.idea/
|
||||||
sdk/
|
sdk/
|
||||||
bin/
|
bin/
|
||||||
obj/
|
obj/
|
||||||
|
|
||||||
#ai
|
#ai
|
||||||
.omo/
|
.omo/
|
||||||
.opencode/
|
.opencode/
|
||||||
|
|
||||||
gen/
|
gen/
|
||||||
obj/
|
obj/
|
||||||
bin/
|
bin/
|
||||||
|
|
||||||
*.tres~
|
*.tres~
|
||||||
*.tscn~
|
*.tscn~
|
||||||
|
|
||||||
# GDScript LSP
|
# GDScript LSP
|
||||||
.godot/
|
.godot/
|
||||||
|
|
||||||
# Export
|
# Export
|
||||||
*.exe
|
*.exe
|
||||||
*.dmg
|
*.dmg
|
||||||
*.apk
|
*.apk
|
||||||
*.aab
|
*.aab
|
||||||
*.pck
|
*.pck
|
||||||
*.zip
|
*.zip
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
# OS
|
# OS
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
# Editor
|
# Editor
|
||||||
*.import
|
*.import
|
||||||
*.godot.uid
|
*.godot.uid
|
||||||
@@ -1,78 +1,78 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Mods.Dialog.Scenarios;
|
using Cthangover.Mods.Dialog.Scenarios;
|
||||||
using Cthangover.Core.Utils;
|
using Cthangover.Core.Utils;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
using Cthangover.Core.UI.Event;
|
using Cthangover.Core.UI.Event;
|
||||||
using Cthangover.Core.UI.Executable;
|
using Cthangover.Core.UI.Executable;
|
||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registry of <see cref="IScenarioCommandStrategy"/> implementations,
|
/// Registry of <see cref="IScenarioCommandStrategy"/> implementations,
|
||||||
/// indexed by their <see cref="IScenarioCommandStrategy.Command"/> name.
|
/// indexed by their <see cref="IScenarioCommandStrategy.Command"/> name.
|
||||||
/// It discovers nothing itself: <see cref="ScenarioCommandStrategyConsumer"/>
|
/// It discovers nothing itself: <see cref="ScenarioCommandStrategyConsumer"/>
|
||||||
/// delivers the strategies of every mod as the kernel registers its
|
/// delivers the strategies of every mod as the kernel registers its
|
||||||
/// assembly and takes them back when the mod unloads, so the table never
|
/// assembly and takes them back when the mod unloads, so the table never
|
||||||
/// holds a strategy of a dead assembly (which would pin it and keep running
|
/// holds a strategy of a dead assembly (which would pin it and keep running
|
||||||
/// its old code after a hot reload).
|
/// its old code after a hot reload).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ScenarioCommandStrategyFactory
|
public static class ScenarioCommandStrategyFactory
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<string, IScenarioCommandStrategy> Strategies = new();
|
private static readonly Dictionary<string, IScenarioCommandStrategy> Strategies = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up the <see cref="IScenarioCommandStrategy"/> registered for <paramref name="command"/>.
|
/// Looks up the <see cref="IScenarioCommandStrategy"/> registered for <paramref name="command"/>.
|
||||||
/// Returns <c>null</c> if no strategy exists for the given command name.
|
/// Returns <c>null</c> if no strategy exists for the given command name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IScenarioCommandStrategy Get(string command)
|
public static IScenarioCommandStrategy Get(string command)
|
||||||
{
|
{
|
||||||
Strategies.TryGetValue(command, out var strategy);
|
Strategies.TryGetValue(command, out var strategy);
|
||||||
return strategy;
|
return strategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enumerates all registered DSL command names (lowercase).
|
/// Enumerates all registered DSL command names (lowercase).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IEnumerable<string> GetAllCommandNames()
|
public static IEnumerable<string> GetAllCommandNames()
|
||||||
{
|
{
|
||||||
return Strategies.Keys;
|
return Strategies.Keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the <see cref="ICommandReferenceMetadata"/> for a command if its
|
/// Returns the <see cref="ICommandReferenceMetadata"/> for a command if its
|
||||||
/// strategy implements that interface, or <c>null</c> otherwise. Used by the
|
/// strategy implements that interface, or <c>null</c> otherwise. Used by the
|
||||||
/// build pipeline to collect asset dependencies from scenario scripts.
|
/// build pipeline to collect asset dependencies from scenario scripts.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static ICommandReferenceMetadata GetReferenceMetadata(string command)
|
public static ICommandReferenceMetadata GetReferenceMetadata(string command)
|
||||||
{
|
{
|
||||||
if (Strategies.TryGetValue(command, out var strategy) && strategy is ICommandReferenceMetadata meta)
|
if (Strategies.TryGetValue(command, out var strategy) && strategy is ICommandReferenceMetadata meta)
|
||||||
return meta;
|
return meta;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers a strategy under its command name. The first strategy of a
|
/// Registers a strategy under its command name. The first strategy of a
|
||||||
/// command wins: a mod cannot silently take over a built-in command.
|
/// command wins: a mod cannot silently take over a built-in command.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Register(IScenarioCommandStrategy strategy)
|
public static void Register(IScenarioCommandStrategy strategy)
|
||||||
{
|
{
|
||||||
if (strategy != null && !Strategies.ContainsKey(strategy.Command))
|
if (strategy != null && !Strategies.ContainsKey(strategy.Command))
|
||||||
Strategies[strategy.Command] = strategy;
|
Strategies[strategy.Command] = strategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes <paramref name="strategy"/> (its mod is being unloaded). A
|
/// Removes <paramref name="strategy"/> (its mod is being unloaded). A
|
||||||
/// command owned by another strategy instance is left alone.
|
/// command owned by another strategy instance is left alone.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Unregister(IScenarioCommandStrategy strategy)
|
public static void Unregister(IScenarioCommandStrategy strategy)
|
||||||
{
|
{
|
||||||
if (strategy != null && Strategies.TryGetValue(strategy.Command, out var registered) && registered == strategy)
|
if (strategy != null && Strategies.TryGetValue(strategy.Command, out var registered) && registered == strategy)
|
||||||
Strategies.Remove(strategy.Command);
|
Strategies.Remove(strategy.Command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,40 +1,40 @@
|
|||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Classifies the type of resource that the first positional argument of a
|
/// Classifies the type of resource that the first positional argument of a
|
||||||
/// scenario command refers to. Used for dependency tracking — the build tool
|
/// scenario command refers to. Used for dependency tracking — the build tool
|
||||||
/// can scan commands by their <see cref="ICommandReferenceMetadata"/> to
|
/// can scan commands by their <see cref="ICommandReferenceMetadata"/> to
|
||||||
/// discover which assets (backgrounds, scenes, music, etc.) are referenced
|
/// discover which assets (backgrounds, scenes, music, etc.) are referenced
|
||||||
/// and need to be packed into the final build.
|
/// and need to be packed into the final build.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum PositionalReferenceKind
|
public enum PositionalReferenceKind
|
||||||
{
|
{
|
||||||
/// <summary>No resource reference in the first positional argument.</summary>
|
/// <summary>No resource reference in the first positional argument.</summary>
|
||||||
None,
|
None,
|
||||||
/// <summary>A background image resource path.</summary>
|
/// <summary>A background image resource path.</summary>
|
||||||
Background,
|
Background,
|
||||||
/// <summary>A scene resource path (for scene switching).</summary>
|
/// <summary>A scene resource path (for scene switching).</summary>
|
||||||
Scene,
|
Scene,
|
||||||
/// <summary>A music/audio resource path.</summary>
|
/// <summary>A music/audio resource path.</summary>
|
||||||
Music,
|
Music,
|
||||||
/// <summary>A sound effect resource path.</summary>
|
/// <summary>A sound effect resource path.</summary>
|
||||||
Sound,
|
Sound,
|
||||||
/// <summary>An effect/shader resource path.</summary>
|
/// <summary>An effect/shader resource path.</summary>
|
||||||
Effect,
|
Effect,
|
||||||
/// <summary>An interactive action definition ID.</summary>
|
/// <summary>An interactive action definition ID.</summary>
|
||||||
Action
|
Action
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Optional interface for command strategies whose first positional argument
|
/// Optional interface for command strategies whose first positional argument
|
||||||
/// references an external resource. Strategies implementing this interface
|
/// references an external resource. Strategies implementing this interface
|
||||||
/// are inspected by the build pipeline to collect asset dependencies.
|
/// are inspected by the build pipeline to collect asset dependencies.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ICommandReferenceMetadata
|
public interface ICommandReferenceMetadata
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The kind of resource referenced by the first positional argument of this command.
|
/// The kind of resource referenced by the first positional argument of this command.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
PositionalReferenceKind Positional0Kind { get; }
|
PositionalReferenceKind Positional0Kind { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,31 +9,31 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Strategy interface for handling a single DSL command type in scenario scripts.
|
/// Strategy interface for handling a single DSL command type in scenario scripts.
|
||||||
/// Each command word (e.g. <c>text</c>, <c>music</c>, <c>goto</c>) maps to one
|
/// Each command word (e.g. <c>text</c>, <c>music</c>, <c>goto</c>) maps to one
|
||||||
/// strategy implementation. The <see cref="ScenarioCommandStrategyFactory"/>
|
/// strategy implementation. The <see cref="ScenarioCommandStrategyFactory"/>
|
||||||
/// auto-discovers all implementations via reflection and dispatches commands
|
/// auto-discovers all implementations via reflection and dispatches commands
|
||||||
/// to the matching strategy during parsing.
|
/// to the matching strategy during parsing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IScenarioCommandStrategy
|
public interface IScenarioCommandStrategy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The lowercase DSL command word this strategy handles (e.g. <c>"text"</c>, <c>"music"</c>).
|
/// The lowercase DSL command word this strategy handles (e.g. <c>"text"</c>, <c>"music"</c>).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string Command { get; }
|
string Command { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes the command by appending one or more dialog actions to <paramref name="dlg"/>.
|
/// Executes the command by appending one or more dialog actions to <paramref name="dlg"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dlg">The dialog queue to push actions onto.</param>
|
/// <param name="dlg">The dialog queue to push actions onto.</param>
|
||||||
/// <param name="positional">Unnamed tokens following the command word in order.</param>
|
/// <param name="positional">Unnamed tokens following the command word in order.</param>
|
||||||
/// <param name="named">Key-value pairs parsed from <c>name=value</c> tokens (keys are lowercased).</param>
|
/// <param name="named">Key-value pairs parsed from <c>name=value</c> tokens (keys are lowercased).</param>
|
||||||
/// <param name="arrowTarget">The target label following a <c>-></c> arrow token, if present.</param>
|
/// <param name="arrowTarget">The target label following a <c>-></c> arrow token, if present.</param>
|
||||||
/// <param name="locale">Optional localization provider for resolving <c>key=</c> lookups.</param>
|
/// <param name="locale">Optional localization provider for resolving <c>key=</c> lookups.</param>
|
||||||
void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale);
|
void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,39 +9,39 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>action</c> DSL command. Triggers a named interactive action
|
/// Handles the <c>action</c> DSL command. Triggers a named interactive action
|
||||||
/// (defined in the action system) and forwards any extra named parameters as
|
/// (defined in the action system) and forwards any extra named parameters as
|
||||||
/// context variables via <see cref="DialogQueue.Set"/>.
|
/// context variables via <see cref="DialogQueue.Set"/>.
|
||||||
/// Implements <see cref="ICommandReferenceMetadata"/> to signal that the
|
/// Implements <see cref="ICommandReferenceMetadata"/> to signal that the
|
||||||
/// first positional argument is an <see cref="PositionalReferenceKind.Action"/> reference.
|
/// first positional argument is an <see cref="PositionalReferenceKind.Action"/> reference.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionCommandStrategy : IScenarioCommandStrategy, ICommandReferenceMetadata, IScenarioCommandSpec
|
public class ActionCommandStrategy : IScenarioCommandStrategy, ICommandReferenceMetadata, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "action";
|
public string Command => "action";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public PositionalReferenceKind Positional0Kind => PositionalReferenceKind.Action;
|
public PositionalReferenceKind Positional0Kind => PositionalReferenceKind.Action;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MinPositional => 1;
|
public int MinPositional => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
var actionName = positional.Count > 0 ? positional[0] : "";
|
var actionName = positional.Count > 0 ? positional[0] : "";
|
||||||
|
|
||||||
foreach (var kv in named)
|
foreach (var kv in named)
|
||||||
{
|
{
|
||||||
if (kv.Key is "name" or "key") continue;
|
if (kv.Key is "name" or "key") continue;
|
||||||
dlg.Set(kv.Key, kv.Value);
|
dlg.Set(kv.Key, kv.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
dlg.Action(actionName);
|
dlg.Action(actionName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -10,55 +10,55 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>animation</c> DSL command. Supports two modes:
|
/// Handles the <c>animation</c> DSL command. Supports two modes:
|
||||||
/// (a) multiple sprites via <c>sprites=</c> named parameter, or
|
/// (a) multiple sprites via <c>sprites=</c> named parameter, or
|
||||||
/// (b) a single sprite base with <c>start</c>, <c>count</c>, <c>speed</c>, and <c>loop</c> controls.
|
/// (b) a single sprite base with <c>start</c>, <c>count</c>, <c>speed</c>, and <c>loop</c> controls.
|
||||||
/// Delegates to <see cref="DialogQueue.Animation"/>.
|
/// Delegates to <see cref="DialogQueue.Animation"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AnimationCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class AnimationCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "animation";
|
public string Command => "animation";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MinArguments => 1;
|
public int MinArguments => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IReadOnlyList<string> AllowedNamed => new[] { "sprites", "speed", "loop", "start", "count" };
|
public IReadOnlyList<string> AllowedNamed => new[] { "sprites", "speed", "loop", "start", "count" };
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
if (named.TryGetValue("sprites", out var spritesStr))
|
if (named.TryGetValue("sprites", out var spritesStr))
|
||||||
{
|
{
|
||||||
var sprites = new List<string>(spritesStr.Split(','));
|
var sprites = new List<string>(spritesStr.Split(','));
|
||||||
var speed = named.TryGetValue("speed", out var sp) ? ParseFloat(sp) : 1f;
|
var speed = named.TryGetValue("speed", out var sp) ? ParseFloat(sp) : 1f;
|
||||||
var loop = !named.TryGetValue("loop", out var lp) || lp == "true";
|
var loop = !named.TryGetValue("loop", out var lp) || lp == "true";
|
||||||
dlg.Animation(sprites, speed, 1f, loop);
|
dlg.Animation(sprites, speed, 1f, loop);
|
||||||
}
|
}
|
||||||
else if (positional.Count > 0)
|
else if (positional.Count > 0)
|
||||||
{
|
{
|
||||||
var sprite = positional[0];
|
var sprite = positional[0];
|
||||||
var start = named.TryGetValue("start", out var st) ? ParseInt(st) : 0;
|
var start = named.TryGetValue("start", out var st) ? ParseInt(st) : 0;
|
||||||
var count = named.TryGetValue("count", out var cn) ? ParseInt(cn) : 1;
|
var count = named.TryGetValue("count", out var cn) ? ParseInt(cn) : 1;
|
||||||
var speed = named.TryGetValue("speed", out var sp) ? ParseFloat(sp) : 1f;
|
var speed = named.TryGetValue("speed", out var sp) ? ParseFloat(sp) : 1f;
|
||||||
var loop = !named.TryGetValue("loop", out var lp) || lp == "true";
|
var loop = !named.TryGetValue("loop", out var lp) || lp == "true";
|
||||||
dlg.Animation(sprite, start, count, speed, 1f, loop);
|
dlg.Animation(sprite, start, count, speed, 1f, loop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float ParseFloat(string s)
|
private static float ParseFloat(string s)
|
||||||
{
|
{
|
||||||
return float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var v) ? v : 0f;
|
return float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var v) ? v : 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int ParseInt(string s)
|
private static int ParseInt(string s)
|
||||||
{
|
{
|
||||||
return int.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out var v) ? v : 0;
|
return int.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out var v) ? v : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -10,47 +10,47 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>background_color</c> DSL command. Sets the dialog scene's
|
/// Handles the <c>background_color</c> DSL command. Sets the dialog scene's
|
||||||
/// background color from a named color string (e.g. <c>black</c>, <c>red</c>)
|
/// background color from a named color string (e.g. <c>black</c>, <c>red</c>)
|
||||||
/// or an HTML hex color (e.g. <c>#FF0000</c>). Delegates to <see cref="DialogQueue.BackgroundColor"/>.
|
/// or an HTML hex color (e.g. <c>#FF0000</c>). Delegates to <see cref="DialogQueue.BackgroundColor"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class BackgroundColorCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class BackgroundColorCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "background_color";
|
public string Command => "background_color";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MinPositional => 1;
|
public int MinPositional => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
if (positional.Count > 0)
|
if (positional.Count > 0)
|
||||||
dlg.BackgroundColor(ColorFromString(positional[0]));
|
dlg.BackgroundColor(ColorFromString(positional[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Color ColorFromString(string s)
|
private static Color ColorFromString(string s)
|
||||||
{
|
{
|
||||||
if (s.StartsWith('#'))
|
if (s.StartsWith('#'))
|
||||||
return Color.FromHtml(s.Substring(1));
|
return Color.FromHtml(s.Substring(1));
|
||||||
|
|
||||||
var named = s.ToLowerInvariant() switch
|
var named = s.ToLowerInvariant() switch
|
||||||
{
|
{
|
||||||
"black" => Colors.Black,
|
"black" => Colors.Black,
|
||||||
"white" => Colors.White,
|
"white" => Colors.White,
|
||||||
"red" => Colors.Red,
|
"red" => Colors.Red,
|
||||||
"green" => Colors.Green,
|
"green" => Colors.Green,
|
||||||
"blue" => Colors.Blue,
|
"blue" => Colors.Blue,
|
||||||
"yellow" => Colors.Yellow,
|
"yellow" => Colors.Yellow,
|
||||||
"gray" or "grey" => Colors.Gray,
|
"gray" or "grey" => Colors.Gray,
|
||||||
_ => Colors.Black,
|
_ => Colors.Black,
|
||||||
};
|
};
|
||||||
return named;
|
return named;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,30 +9,30 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>background</c> DSL command. Sets the dialog scene background
|
/// Handles the <c>background</c> DSL command. Sets the dialog scene background
|
||||||
/// image from a resource path. Implements <see cref="ICommandReferenceMetadata"/>
|
/// image from a resource path. Implements <see cref="ICommandReferenceMetadata"/>
|
||||||
/// with <see cref="PositionalReferenceKind.Background"/> so the build pipeline
|
/// with <see cref="PositionalReferenceKind.Background"/> so the build pipeline
|
||||||
/// can track referenced background assets.
|
/// can track referenced background assets.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class BackgroundCommandStrategy : IScenarioCommandStrategy, ICommandReferenceMetadata, IScenarioCommandSpec
|
public class BackgroundCommandStrategy : IScenarioCommandStrategy, ICommandReferenceMetadata, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "background";
|
public string Command => "background";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public PositionalReferenceKind Positional0Kind => PositionalReferenceKind.Background;
|
public PositionalReferenceKind Positional0Kind => PositionalReferenceKind.Background;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MinPositional => 1;
|
public int MinPositional => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
dlg.Background(positional.Count > 0 ? positional[0] : "");
|
dlg.Background(positional.Count > 0 ? positional[0] : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Mods.Dialog.Action.Impls;
|
using Cthangover.Mods.Dialog.Action.Impls;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -11,38 +11,38 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>background_show_hide</c> DSL command. Animates the background
|
/// Handles the <c>background_show_hide</c> DSL command. Animates the background
|
||||||
/// in (<c>show</c>) or out (<c>hide</c>) with configurable <c>duration</c> and
|
/// in (<c>show</c>) or out (<c>hide</c>) with configurable <c>duration</c> and
|
||||||
/// <c>wait</c> flag. Delegates to <see cref="DialogQueue.BackgroundShowHide"/>.
|
/// <c>wait</c> flag. Delegates to <see cref="DialogQueue.BackgroundShowHide"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class BackgroundShowHideCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class BackgroundShowHideCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "background_show_hide";
|
public string Command => "background_show_hide";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IReadOnlyList<string> AllowedNamed => new[] { "duration", "wait" };
|
public IReadOnlyList<string> AllowedNamed => new[] { "duration", "wait" };
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
var typeStr = positional.Count > 0 ? positional[0] : "show";
|
var typeStr = positional.Count > 0 ? positional[0] : "show";
|
||||||
var type = typeStr.ToLowerInvariant() == "show"
|
var type = typeStr.ToLowerInvariant() == "show"
|
||||||
? BackgroundActionType.Show
|
? BackgroundActionType.Show
|
||||||
: BackgroundActionType.Hide;
|
: BackgroundActionType.Hide;
|
||||||
var duration = named.TryGetValue("duration", out var dur) ? ParseFloat(dur) : 1f;
|
var duration = named.TryGetValue("duration", out var dur) ? ParseFloat(dur) : 1f;
|
||||||
var wait = named.TryGetValue("wait", out var w) && w == "true";
|
var wait = named.TryGetValue("wait", out var w) && w == "true";
|
||||||
dlg.BackgroundShowHide(type, duration, wait);
|
dlg.BackgroundShowHide(type, duration, wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float ParseFloat(string s)
|
private static float ParseFloat(string s)
|
||||||
{
|
{
|
||||||
return float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var v) ? v : 0f;
|
return float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var v) ? v : 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -10,49 +10,49 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>delay</c> DSL command. Pauses dialog execution for a
|
/// Handles the <c>delay</c> DSL command. Pauses dialog execution for a
|
||||||
/// number of seconds, optionally displaying a text label during the pause.
|
/// number of seconds, optionally displaying a text label during the pause.
|
||||||
/// If the <c>hidden</c> flag is set, the delay runs without visible text.
|
/// If the <c>hidden</c> flag is set, the delay runs without visible text.
|
||||||
/// Supports localization via the <c>key=</c> named parameter.
|
/// Supports localization via the <c>key=</c> named parameter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DelayCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class DelayCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "delay";
|
public string Command => "delay";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 2;
|
public int MaxPositional => 2;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IReadOnlyList<string> AllowedNamed => new[] { "key", "hidden" };
|
public IReadOnlyList<string> AllowedNamed => new[] { "key", "hidden" };
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
var time = positional.Count > 0 ? ParseFloat(positional[0]) : 1f;
|
var time = positional.Count > 0 ? ParseFloat(positional[0]) : 1f;
|
||||||
var hidden = positional.Count > 1 && positional[1] == "hidden"
|
var hidden = positional.Count > 1 && positional[1] == "hidden"
|
||||||
|| named.TryGetValue("hidden", out var h) && h == "true";
|
|| named.TryGetValue("hidden", out var h) && h == "true";
|
||||||
var showText = hidden ? null
|
var showText = hidden ? null
|
||||||
: positional.Count > 1 ? positional[1]
|
: positional.Count > 1 ? positional[1]
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (named.TryGetValue("key", out var key) && locale != null && showText != null)
|
if (named.TryGetValue("key", out var key) && locale != null && showText != null)
|
||||||
{
|
{
|
||||||
var loc = locale.Get(key);
|
var loc = locale.Get(key);
|
||||||
if (loc != null) showText = loc;
|
if (loc != null) showText = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showText != null)
|
if (showText != null)
|
||||||
dlg.Delay(time, showText);
|
dlg.Delay(time, showText);
|
||||||
else
|
else
|
||||||
dlg.Delay(time, hidden);
|
dlg.Delay(time, hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float ParseFloat(string s)
|
private static float ParseFloat(string s)
|
||||||
{
|
{
|
||||||
return float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var v) ? v : 0f;
|
return float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var v) ? v : 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,30 +9,30 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>effect</c> DSL command. Applies a named visual effect/shader
|
/// Handles the <c>effect</c> DSL command. Applies a named visual effect/shader
|
||||||
/// to the scene. Implements <see cref="ICommandReferenceMetadata"/> with
|
/// to the scene. Implements <see cref="ICommandReferenceMetadata"/> with
|
||||||
/// <see cref="PositionalReferenceKind.Effect"/> for build-time dependency tracking.
|
/// <see cref="PositionalReferenceKind.Effect"/> for build-time dependency tracking.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EffectCommandStrategy : IScenarioCommandStrategy, ICommandReferenceMetadata, IScenarioCommandSpec
|
public class EffectCommandStrategy : IScenarioCommandStrategy, ICommandReferenceMetadata, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "effect";
|
public string Command => "effect";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public PositionalReferenceKind Positional0Kind => PositionalReferenceKind.Effect;
|
public PositionalReferenceKind Positional0Kind => PositionalReferenceKind.Effect;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MinPositional => 1;
|
public int MinPositional => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
if (positional.Count > 0)
|
if (positional.Count > 0)
|
||||||
dlg.Effect(positional[0]);
|
dlg.Effect(positional[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,26 +9,26 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>empty</c> DSL command. Queues a no-op placeholder action
|
/// Handles the <c>empty</c> DSL command. Queues a no-op placeholder action
|
||||||
/// (<see cref="ActionEmpty"/>) that is skipped instantly — the DSL-level label
|
/// (<see cref="ActionEmpty"/>) that is skipped instantly — the DSL-level label
|
||||||
/// mechanism (<c>:label</c> via <see cref="DialogQueue.Point"/>) is built on the
|
/// mechanism (<c>:label</c> via <see cref="DialogQueue.Point"/>) is built on the
|
||||||
/// same action type, and a bare <c>empty</c> line works as a placeholder marker.
|
/// same action type, and a bare <c>empty</c> line works as a placeholder marker.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EmptyCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class EmptyCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "empty";
|
public string Command => "empty";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 0;
|
public int MaxPositional => 0;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
dlg.Empty();
|
dlg.Empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,25 +9,25 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>end</c> DSL command. Marks the end of the dialog sequence,
|
/// Handles the <c>end</c> DSL command. Marks the end of the dialog sequence,
|
||||||
/// terminating execution of the current scenario. Typically used at the final
|
/// terminating execution of the current scenario. Typically used at the final
|
||||||
/// line of a scenario script to signal the dialog engine to close or transition.
|
/// line of a scenario script to signal the dialog engine to close or transition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EndCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class EndCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "end";
|
public string Command => "end";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 0;
|
public int MaxPositional => 0;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
dlg.End();
|
dlg.End();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,27 +9,27 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>foreground</c> DSL command. Places a foreground overlay
|
/// Handles the <c>foreground</c> DSL command. Places a foreground overlay
|
||||||
/// image on top of the scene (above background and characters). The first
|
/// image on top of the scene (above background and characters). The first
|
||||||
/// positional argument specifies the resource path to the image asset.
|
/// positional argument specifies the resource path to the image asset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ForegroundCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class ForegroundCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "foreground";
|
public string Command => "foreground";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MinPositional => 1;
|
public int MinPositional => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
dlg.Foreground(positional.Count > 0 ? positional[0] : "");
|
dlg.Foreground(positional.Count > 0 ? positional[0] : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,35 +9,35 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>goto</c> DSL command. Jumps execution to a labeled anchor
|
/// Handles the <c>goto</c> DSL command. Jumps execution to a labeled anchor
|
||||||
/// point (<c>:labelname</c>) in the scenario script. Supports two forms:
|
/// point (<c>:labelname</c>) in the scenario script. Supports two forms:
|
||||||
/// <c>goto target_name</c> via <c>target=</c> named parameter, or
|
/// <c>goto target_name</c> via <c>target=</c> named parameter, or
|
||||||
/// <c>goto -> target_name</c> via the arrow target syntax.
|
/// <c>goto -> target_name</c> via the arrow target syntax.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GotoCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class GotoCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "goto";
|
public string Command => "goto";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MinArguments => 1;
|
public int MinArguments => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 0;
|
public int MaxPositional => 0;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IReadOnlyList<string> AllowedNamed => new[] { "target" };
|
public IReadOnlyList<string> AllowedNamed => new[] { "target" };
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string JumpTargetNamedKey => "target";
|
public string JumpTargetNamedKey => "target";
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(arrowTarget))
|
if (!string.IsNullOrEmpty(arrowTarget))
|
||||||
dlg.GoTo(arrowTarget);
|
dlg.GoTo(arrowTarget);
|
||||||
else if (named.TryGetValue("target", out var target))
|
else if (named.TryGetValue("target", out var target))
|
||||||
dlg.GoTo(target);
|
dlg.GoTo(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,25 +9,25 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>hide_dialog</c> DSL command. Hides the dialog UI panel
|
/// Handles the <c>hide_dialog</c> DSL command. Hides the dialog UI panel
|
||||||
/// (text box, avatars, and UI chrome) from the screen. The inverse of
|
/// (text box, avatars, and UI chrome) from the screen. The inverse of
|
||||||
/// <see cref="ShowDialogCommandStrategy"/>.
|
/// <see cref="ShowDialogCommandStrategy"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class HideDialogCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class HideDialogCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "hide_dialog";
|
public string Command => "hide_dialog";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 0;
|
public int MaxPositional => 0;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
dlg.HideDialog();
|
dlg.HideDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,29 +9,29 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios.Impls
|
namespace Cthangover.Mods.Dialog.Scenarios.Impls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>light_set</c> DSL command. Passes a JSON string that
|
/// Handles the <c>light_set</c> DSL command. Passes a JSON string that
|
||||||
/// describes lighting configuration to the dialog engine via
|
/// describes lighting configuration to the dialog engine via
|
||||||
/// <see cref="DialogQueue.LightSet"/>. The JSON structure is forwarded
|
/// <see cref="DialogQueue.LightSet"/>. The JSON structure is forwarded
|
||||||
/// as-is to the rendering layer for point-light setup.
|
/// as-is to the rendering layer for point-light setup.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class LightSetCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class LightSetCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "light_set";
|
public string Command => "light_set";
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional,
|
public void Execute(DialogQueue dlg, List<string> positional,
|
||||||
Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
var json = positional.Count > 0 ? positional[0] : null;
|
var json = positional.Count > 0 ? positional[0] : null;
|
||||||
dlg.LightSet(json);
|
dlg.LightSet(json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,26 +9,26 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>light_use_time</c> DSL command. Toggles whether the
|
/// Handles the <c>light_use_time</c> DSL command. Toggles whether the
|
||||||
/// scene lighting should be driven by the simulated time-of-day system.
|
/// scene lighting should be driven by the simulated time-of-day system.
|
||||||
/// Passes a boolean flag to <see cref="DialogQueue.LightUseTime"/>.
|
/// Passes a boolean flag to <see cref="DialogQueue.LightUseTime"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class LightUseTimeCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class LightUseTimeCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "light_use_time";
|
public string Command => "light_use_time";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
var val = positional.Count > 0 ? positional[0] : "true";
|
var val = positional.Count > 0 ? positional[0] : "true";
|
||||||
dlg.LightUseTime(val == "true");
|
dlg.LightUseTime(val == "true");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,31 +9,31 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>music</c> DSL command. Starts playing a background music
|
/// Handles the <c>music</c> DSL command. Starts playing a background music
|
||||||
/// track from the given resource path. Implements <see cref="ICommandReferenceMetadata"/>
|
/// track from the given resource path. Implements <see cref="ICommandReferenceMetadata"/>
|
||||||
/// with <see cref="PositionalReferenceKind.Music"/> so the build pipeline
|
/// with <see cref="PositionalReferenceKind.Music"/> so the build pipeline
|
||||||
/// can track referenced audio assets.
|
/// can track referenced audio assets.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MusicCommandStrategy : IScenarioCommandStrategy, ICommandReferenceMetadata, IScenarioCommandSpec
|
public class MusicCommandStrategy : IScenarioCommandStrategy, ICommandReferenceMetadata, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "music";
|
public string Command => "music";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public PositionalReferenceKind Positional0Kind => PositionalReferenceKind.Music;
|
public PositionalReferenceKind Positional0Kind => PositionalReferenceKind.Music;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MinPositional => 1;
|
public int MinPositional => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
if (positional.Count > 0)
|
if (positional.Count > 0)
|
||||||
dlg.Music(positional[0]);
|
dlg.Music(positional[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,25 +9,25 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>music_pause</c> DSL command. Pauses the currently
|
/// Handles the <c>music_pause</c> DSL command. Pauses the currently
|
||||||
/// playing background music stream. Playback can be resumed later with
|
/// playing background music stream. Playback can be resumed later with
|
||||||
/// <see cref="MusicPlayCommandStrategy"/>.
|
/// <see cref="MusicPlayCommandStrategy"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MusicPauseCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class MusicPauseCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "music_pause";
|
public string Command => "music_pause";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 0;
|
public int MaxPositional => 0;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
dlg.MusicPause();
|
dlg.MusicPause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,24 +9,24 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>music_play</c> DSL command. Resumes the currently
|
/// Handles the <c>music_play</c> DSL command. Resumes the currently
|
||||||
/// paused background music stream. Has no effect if music is already playing.
|
/// paused background music stream. Has no effect if music is already playing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MusicPlayCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class MusicPlayCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "music_play";
|
public string Command => "music_play";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 0;
|
public int MaxPositional => 0;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
dlg.MusicPlay();
|
dlg.MusicPlay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Mods.Dialog.Action;
|
using Cthangover.Mods.Dialog.Action;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -10,45 +10,45 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>ptext</c> DSL command. A "plain text" variant of
|
/// Handles the <c>ptext</c> DSL command. A "plain text" variant of
|
||||||
/// <see cref="TextCommandStrategy"/> that skips speaker attribution
|
/// <see cref="TextCommandStrategy"/> that skips speaker attribution
|
||||||
/// but still supports <c>first</c>/<c>second</c> avatar faces and
|
/// but still supports <c>first</c>/<c>second</c> avatar faces and
|
||||||
/// <c>hide_color</c> and <c>wait</c> behavior flags. Text content
|
/// <c>hide_color</c> and <c>wait</c> behavior flags. Text content
|
||||||
/// can be provided directly or resolved via a <c>key=</c> localization key.
|
/// can be provided directly or resolved via a <c>key=</c> localization key.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PTextCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class PTextCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "ptext";
|
public string Command => "ptext";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MinArguments => 1;
|
public int MinArguments => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IReadOnlyList<string> AllowedNamed => new[] { "key", "first", "second", "hide_color", "wait" };
|
public IReadOnlyList<string> AllowedNamed => new[] { "key", "first", "second", "hide_color", "wait" };
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
var textVal = positional.Count > 0 ? positional[0] : "";
|
var textVal = positional.Count > 0 ? positional[0] : "";
|
||||||
if (named.TryGetValue("key", out var key) && locale != null)
|
if (named.TryGetValue("key", out var key) && locale != null)
|
||||||
{
|
{
|
||||||
var loc = locale.Get(key);
|
var loc = locale.Get(key);
|
||||||
if (loc != null) textVal = loc;
|
if (loc != null) textVal = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
var first = named.TryGetValue("first", out var f) ? f : null;
|
var first = named.TryGetValue("first", out var f) ? f : null;
|
||||||
var second = named.TryGetValue("second", out var s) ? s : null;
|
var second = named.TryGetValue("second", out var s) ? s : null;
|
||||||
var hideColor = named.TryGetValue("hide_color", out var hc) && hc == "true";
|
var hideColor = named.TryGetValue("hide_color", out var hc) && hc == "true";
|
||||||
|
|
||||||
var action = dlg.PText(textVal, first, second, hideColor);
|
var action = dlg.PText(textVal, first, second, hideColor);
|
||||||
|
|
||||||
if (named.TryGetValue("wait", out var wait) && wait == "false")
|
if (named.TryGetValue("wait", out var wait) && wait == "false")
|
||||||
action.WaitType = WaitType.NoWait;
|
action.WaitType = WaitType.NoWait;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,31 +9,31 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>set</c> DSL command. Stores an arbitrary key-value pair
|
/// Handles the <c>set</c> DSL command. Stores an arbitrary key-value pair
|
||||||
/// into the dialog session's variable state via <see cref="DialogQueue.Set"/>.
|
/// into the dialog session's variable state via <see cref="DialogQueue.Set"/>.
|
||||||
/// Values are read back later through <c>${var}</c> substitution in
|
/// Values are read back later through <c>${var}</c> substitution in
|
||||||
/// <c>ptext</c> lines and via <see cref="Cthangover.Core.Actions.IActionContext.GetParam"/>
|
/// <c>ptext</c> lines and via <see cref="Cthangover.Core.Actions.IActionContext.GetParam"/>
|
||||||
/// in scenario actions.
|
/// in scenario actions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SetCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class SetCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "set";
|
public string Command => "set";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MinPositional => 2;
|
public int MinPositional => 2;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 2;
|
public int MaxPositional => 2;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
var name = positional.Count > 0 ? positional[0] : "";
|
var name = positional.Count > 0 ? positional[0] : "";
|
||||||
var value = positional.Count > 1 ? positional[1] : "";
|
var value = positional.Count > 1 ? positional[1] : "";
|
||||||
dlg.Set(name, value);
|
dlg.Set(name, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,25 +9,25 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>show_dialog</c> DSL command. Makes the dialog UI panel
|
/// Handles the <c>show_dialog</c> DSL command. Makes the dialog UI panel
|
||||||
/// (text box, avatars, and UI chrome) visible on screen. The inverse of
|
/// (text box, avatars, and UI chrome) visible on screen. The inverse of
|
||||||
/// <see cref="HideDialogCommandStrategy"/>.
|
/// <see cref="HideDialogCommandStrategy"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ShowDialogCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class ShowDialogCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "show_dialog";
|
public string Command => "show_dialog";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 0;
|
public int MaxPositional => 0;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
dlg.ShowDialog();
|
dlg.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,31 +9,31 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>sound</c> DSL command. Plays a one-shot sound effect
|
/// Handles the <c>sound</c> DSL command. Plays a one-shot sound effect
|
||||||
/// from the given resource path. Implements <see cref="ICommandReferenceMetadata"/>
|
/// from the given resource path. Implements <see cref="ICommandReferenceMetadata"/>
|
||||||
/// with <see cref="PositionalReferenceKind.Sound"/> so the build pipeline
|
/// with <see cref="PositionalReferenceKind.Sound"/> so the build pipeline
|
||||||
/// can track referenced audio assets.
|
/// can track referenced audio assets.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SoundCommandStrategy : IScenarioCommandStrategy, ICommandReferenceMetadata, IScenarioCommandSpec
|
public class SoundCommandStrategy : IScenarioCommandStrategy, ICommandReferenceMetadata, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "sound";
|
public string Command => "sound";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public PositionalReferenceKind Positional0Kind => PositionalReferenceKind.Sound;
|
public PositionalReferenceKind Positional0Kind => PositionalReferenceKind.Sound;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MinPositional => 1;
|
public int MinPositional => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
if (positional.Count > 0)
|
if (positional.Count > 0)
|
||||||
dlg.Sound(positional[0]);
|
dlg.Sound(positional[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -10,41 +10,41 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>switch_scene</c> DSL command. Transitions to a new Godot
|
/// Handles the <c>switch_scene</c> DSL command. Transitions to a new Godot
|
||||||
/// scene (PackedScene) with configurable transition <c>speed</c> and an
|
/// scene (PackedScene) with configurable transition <c>speed</c> and an
|
||||||
/// optional <c>hidden</c> mode that shows only the scene background during
|
/// optional <c>hidden</c> mode that shows only the scene background during
|
||||||
/// the transition. Implements <see cref="ICommandReferenceMetadata"/> with
|
/// the transition. Implements <see cref="ICommandReferenceMetadata"/> with
|
||||||
/// <see cref="PositionalReferenceKind.Scene"/> for build-time dependency tracking.
|
/// <see cref="PositionalReferenceKind.Scene"/> for build-time dependency tracking.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SwitchSceneCommandStrategy : IScenarioCommandStrategy, ICommandReferenceMetadata, IScenarioCommandSpec
|
public class SwitchSceneCommandStrategy : IScenarioCommandStrategy, ICommandReferenceMetadata, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "switch_scene";
|
public string Command => "switch_scene";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public PositionalReferenceKind Positional0Kind => PositionalReferenceKind.Scene;
|
public PositionalReferenceKind Positional0Kind => PositionalReferenceKind.Scene;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MinPositional => 1;
|
public int MinPositional => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IReadOnlyList<string> AllowedNamed => new[] { "speed", "hidden" };
|
public IReadOnlyList<string> AllowedNamed => new[] { "speed", "hidden" };
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
var scene = positional.Count > 0 ? positional[0] : "";
|
var scene = positional.Count > 0 ? positional[0] : "";
|
||||||
var speed = named.TryGetValue("speed", out var sp) ? ParseFloat(sp) : 4f;
|
var speed = named.TryGetValue("speed", out var sp) ? ParseFloat(sp) : 4f;
|
||||||
var hidden = named.TryGetValue("hidden", out var h) && h == "true";
|
var hidden = named.TryGetValue("hidden", out var h) && h == "true";
|
||||||
dlg.SwitchScene(scene, speed, hidden);
|
dlg.SwitchScene(scene, speed, hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float ParseFloat(string s)
|
private static float ParseFloat(string s)
|
||||||
{
|
{
|
||||||
return float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var v) ? v : 0f;
|
return float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var v) ? v : 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Mods.Dialog.Action;
|
using Cthangover.Mods.Dialog.Action;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -10,45 +10,45 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>text</c> DSL command, the primary dialog display instruction.
|
/// Handles the <c>text</c> DSL command, the primary dialog display instruction.
|
||||||
/// Shows character text with optional <c>first</c>/<c>second</c> speaker
|
/// Shows character text with optional <c>first</c>/<c>second</c> speaker
|
||||||
/// avatar faces, <c>hide_color</c> tint suppression, and a <c>wait</c> flag
|
/// avatar faces, <c>hide_color</c> tint suppression, and a <c>wait</c> flag
|
||||||
/// that controls whether the dialog waits for user input before continuing.
|
/// that controls whether the dialog waits for user input before continuing.
|
||||||
/// Text can be literal or resolved from a <c>key=</c> localization entry.
|
/// Text can be literal or resolved from a <c>key=</c> localization entry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TextCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class TextCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "text";
|
public string Command => "text";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MinArguments => 1;
|
public int MinArguments => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IReadOnlyList<string> AllowedNamed => new[] { "key", "first", "second", "hide_color", "wait" };
|
public IReadOnlyList<string> AllowedNamed => new[] { "key", "first", "second", "hide_color", "wait" };
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
var textVal = positional.Count > 0 ? positional[0] : "";
|
var textVal = positional.Count > 0 ? positional[0] : "";
|
||||||
if (named.TryGetValue("key", out var key) && locale != null)
|
if (named.TryGetValue("key", out var key) && locale != null)
|
||||||
{
|
{
|
||||||
var loc = locale.Get(key);
|
var loc = locale.Get(key);
|
||||||
if (loc != null) textVal = loc;
|
if (loc != null) textVal = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
var first = named.TryGetValue("first", out var f) ? f : null;
|
var first = named.TryGetValue("first", out var f) ? f : null;
|
||||||
var second = named.TryGetValue("second", out var s) ? s : null;
|
var second = named.TryGetValue("second", out var s) ? s : null;
|
||||||
var hideColor = named.TryGetValue("hide_color", out var hc) && hc == "true";
|
var hideColor = named.TryGetValue("hide_color", out var hc) && hc == "true";
|
||||||
|
|
||||||
var action = dlg.Text(textVal, first, second, hideColor);
|
var action = dlg.Text(textVal, first, second, hideColor);
|
||||||
|
|
||||||
if (named.TryGetValue("wait", out var wait) && wait == "false")
|
if (named.TryGetValue("wait", out var wait) && wait == "false")
|
||||||
action.WaitType = WaitType.NoWait;
|
action.WaitType = WaitType.NoWait;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -9,37 +9,37 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <c>title</c> DSL command. Displays a centered title/caption
|
/// Handles the <c>title</c> DSL command. Displays a centered title/caption
|
||||||
/// text on screen, typically used for chapter headings or location labels.
|
/// text on screen, typically used for chapter headings or location labels.
|
||||||
/// Text can be literal or resolved from a <c>key=</c> localization entry.
|
/// Text can be literal or resolved from a <c>key=</c> localization entry.
|
||||||
/// Silently does nothing if no text value is provided or resolved.
|
/// Silently does nothing if no text value is provided or resolved.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TitleCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
public class TitleCommandStrategy : IScenarioCommandStrategy, IScenarioCommandSpec
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Command => "title";
|
public string Command => "title";
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MinArguments => 1;
|
public int MinArguments => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int MaxPositional => 1;
|
public int MaxPositional => 1;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IReadOnlyList<string> AllowedNamed => new[] { "key" };
|
public IReadOnlyList<string> AllowedNamed => new[] { "key" };
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
public void Execute(DialogQueue dlg, List<string> positional, Dictionary<string, string> named, string arrowTarget, ILocalizationProvider locale)
|
||||||
{
|
{
|
||||||
var textVal = positional.Count > 0 ? positional[0] : null;
|
var textVal = positional.Count > 0 ? positional[0] : null;
|
||||||
if (named.TryGetValue("key", out var key) && locale != null)
|
if (named.TryGetValue("key", out var key) && locale != null)
|
||||||
{
|
{
|
||||||
var loc = locale.Get(key);
|
var loc = locale.Get(key);
|
||||||
if (loc != null) textVal = loc;
|
if (loc != null) textVal = loc;
|
||||||
}
|
}
|
||||||
if (textVal != null)
|
if (textVal != null)
|
||||||
dlg.Title(textVal);
|
dlg.Title(textVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Core.Mods;
|
using Cthangover.Core.Mods;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Mods.Dialog.Action;
|
using Cthangover.Mods.Dialog.Action;
|
||||||
using Cthangover.Mods.Dialog.Action.Impls;
|
using Cthangover.Mods.Dialog.Action.Impls;
|
||||||
using Cthangover.Core.Utils;
|
using Cthangover.Core.Utils;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -15,60 +15,60 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts scenario DSL text or files into <see cref="DialogQueue"/> instances.
|
/// Converts scenario DSL text or files into <see cref="DialogQueue"/> instances.
|
||||||
/// Wraps <see cref="ScenarioParser"/> with a configurable <see cref="ILocalizationProvider"/>
|
/// Wraps <see cref="ScenarioParser"/> with a configurable <see cref="ILocalizationProvider"/>
|
||||||
/// that defaults to <see cref="GodotTranslationProvider.Instance"/> when none is supplied.
|
/// that defaults to <see cref="GodotTranslationProvider.Instance"/> when none is supplied.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ScenarioConverter
|
public class ScenarioConverter
|
||||||
{
|
{
|
||||||
private readonly ILocalizationProvider locale;
|
private readonly ILocalizationProvider locale;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a converter with an optional localization provider.
|
/// Creates a converter with an optional localization provider.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="locale">Localization provider for <c>key=</c> text lookups. Defaults to Godot translations.</param>
|
/// <param name="locale">Localization provider for <c>key=</c> text lookups. Defaults to Godot translations.</param>
|
||||||
public ScenarioConverter(ILocalizationProvider locale = null)
|
public ScenarioConverter(ILocalizationProvider locale = null)
|
||||||
{
|
{
|
||||||
this.locale = locale ?? GodotTranslationProvider.Instance;
|
this.locale = locale ?? GodotTranslationProvider.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parses raw scenario script text into a dialog queue using the configured locale.
|
/// Parses raw scenario script text into a dialog queue using the configured locale.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DialogQueue Convert(string text)
|
public DialogQueue Convert(string text)
|
||||||
{
|
{
|
||||||
return ScenarioParser.Parse(text, locale);
|
return ScenarioParser.Parse(text, locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reads a scenario file from disk and parses it into a dialog queue.
|
/// Reads a scenario file from disk and parses it into a dialog queue.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">Filesystem path to the <c>.scenario</c> file.</param>
|
/// <param name="path">Filesystem path to the <c>.scenario</c> file.</param>
|
||||||
/// <returns>The parsed <see cref="DialogQueue"/>, or <c>null</c> if the file could not be opened.</returns>
|
/// <returns>The parsed <see cref="DialogQueue"/>, or <c>null</c> if the file could not be opened.</returns>
|
||||||
public DialogQueue ConvertFile(string path)
|
public DialogQueue ConvertFile(string path)
|
||||||
{
|
{
|
||||||
foreach (var kvp in ModRegistry.Instance.Mods)
|
foreach (var kvp in ModRegistry.Instance.Mods)
|
||||||
{
|
{
|
||||||
var text = kvp.Value.FileProvider.ReadFileText(path);
|
var text = kvp.Value.FileProvider.ReadFileText(path);
|
||||||
if (text != null)
|
if (text != null)
|
||||||
return Convert(text);
|
return Convert(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
var file = FileAccess.Open(path, FileAccess.ModeFlags.Read);
|
var file = FileAccess.Open(path, FileAccess.ModeFlags.Read);
|
||||||
if (file == null)
|
if (file == null)
|
||||||
{
|
{
|
||||||
GameLogger.Log("CONVERTER", $"Failed to open '{path}'", LogLevel.Error);
|
GameLogger.Log("CONVERTER", $"Failed to open '{path}'", LogLevel.Error);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileText = file.GetAsText();
|
var fileText = file.GetAsText();
|
||||||
file.Close();
|
file.Close();
|
||||||
|
|
||||||
return Convert(fileText);
|
return Convert(fileText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Cthangover.Core.Localization;
|
using Cthangover.Core.Localization;
|
||||||
using Cthangover.Mods.Dialog;
|
using Cthangover.Mods.Dialog;
|
||||||
using Cthangover.Core.Utils;
|
using Cthangover.Core.Utils;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -10,45 +10,45 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Scenarios
|
namespace Cthangover.Mods.Dialog.Scenarios
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads a <c>.scenario</c> file from disk, reads its text content, and
|
/// Loads a <c>.scenario</c> file from disk, reads its text content, and
|
||||||
/// parses it via <see cref="ScenarioParser.Parse"/> into a <see cref="DialogQueue"/>.
|
/// parses it via <see cref="ScenarioParser.Parse"/> into a <see cref="DialogQueue"/>.
|
||||||
/// Uses <see cref="GodotTranslationProvider.Instance"/> as the default localization source.
|
/// Uses <see cref="GodotTranslationProvider.Instance"/> as the default localization source.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ScenarioLoader
|
public static class ScenarioLoader
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads and parses a scenario file using the default Godot translation provider.
|
/// Loads and parses a scenario file using the default Godot translation provider.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">Filesystem path to the <c>.scenario</c> file.</param>
|
/// <param name="path">Filesystem path to the <c>.scenario</c> file.</param>
|
||||||
/// <returns>The parsed <see cref="DialogQueue"/>, or <c>null</c> if the file could not be opened.</returns>
|
/// <returns>The parsed <see cref="DialogQueue"/>, or <c>null</c> if the file could not be opened.</returns>
|
||||||
public static DialogQueue Load(string path)
|
public static DialogQueue Load(string path)
|
||||||
{
|
{
|
||||||
return Load(path, GodotTranslationProvider.Instance);
|
return Load(path, GodotTranslationProvider.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads and parses a scenario file with a custom localization provider for text lookups.
|
/// Loads and parses a scenario file with a custom localization provider for text lookups.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">Filesystem path to the <c>.scenario</c> file.</param>
|
/// <param name="path">Filesystem path to the <c>.scenario</c> file.</param>
|
||||||
/// <param name="provider">Localization provider to resolve <c>key=</c> references during parsing.</param>
|
/// <param name="provider">Localization provider to resolve <c>key=</c> references during parsing.</param>
|
||||||
/// <returns>The parsed <see cref="DialogQueue"/>, or <c>null</c> if the file could not be opened.</returns>
|
/// <returns>The parsed <see cref="DialogQueue"/>, or <c>null</c> if the file could not be opened.</returns>
|
||||||
public static DialogQueue Load(string path, ILocalizationProvider provider)
|
public static DialogQueue Load(string path, ILocalizationProvider provider)
|
||||||
{
|
{
|
||||||
var file = FileAccess.Open(path, FileAccess.ModeFlags.Read);
|
var file = FileAccess.Open(path, FileAccess.ModeFlags.Read);
|
||||||
if (file == null)
|
if (file == null)
|
||||||
{
|
{
|
||||||
GameLogger.Log("SCENE", $"ScenarioLoader: failed to open '{path}'", LogLevel.Error);
|
GameLogger.Log("SCENE", $"ScenarioLoader: failed to open '{path}'", LogLevel.Error);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var text = file.GetAsText();
|
var text = file.GetAsText();
|
||||||
file.Close();
|
file.Close();
|
||||||
|
|
||||||
return ScenarioParser.Parse(text, provider);
|
return ScenarioParser.Parse(text, provider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
namespace Cthangover.Mods.Dialog.Action
|
namespace Cthangover.Mods.Dialog.Action
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// High-level action category discriminator. Currently minimal (Text, End)
|
/// High-level action category discriminator. Currently minimal (Text, End)
|
||||||
/// — may expand as additional action families are added.
|
/// — may expand as additional action families are added.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum ActionType
|
public enum ActionType
|
||||||
{
|
{
|
||||||
/// <summary>A dialog text display action that pauses for click input.</summary>
|
/// <summary>A dialog text display action that pauses for click input.</summary>
|
||||||
Text,
|
Text,
|
||||||
/// <summary>Terminates the dialog queue.</summary>
|
/// <summary>Terminates the dialog queue.</summary>
|
||||||
End
|
End
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
namespace Cthangover.Mods.Dialog.Action
|
namespace Cthangover.Mods.Dialog.Action
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Controls when an action's Construct() fires. OnStartQueue — construct
|
/// Controls when an action's Construct() fires. OnStartQueue — construct
|
||||||
/// when the dialog queue is first loaded (good for preloading); OnStartAction —
|
/// when the dialog queue is first loaded (good for preloading); OnStartAction —
|
||||||
/// lazy-construct just before the action runs (saves resources for unreached
|
/// lazy-construct just before the action runs (saves resources for unreached
|
||||||
/// branches). Default for most actions is OnStartAction.
|
/// branches). Default for most actions is OnStartAction.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum ConstructType
|
public enum ConstructType
|
||||||
{
|
{
|
||||||
/// <summary>Construct when the dialog queue is first loaded. Useful for actions that need to preload resources.</summary>
|
/// <summary>Construct when the dialog queue is first loaded. Useful for actions that need to preload resources.</summary>
|
||||||
OnStartQueue,
|
OnStartQueue,
|
||||||
/// <summary>Construct lazily just before the action runs. Default for most actions — saves resources for unreached branches.</summary>
|
/// <summary>Construct lazily just before the action runs. Default for most actions — saves resources for unreached branches.</summary>
|
||||||
OnStartAction
|
OnStartAction
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
namespace Cthangover.Mods.Dialog.Action
|
namespace Cthangover.Mods.Dialog.Action
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Controls when an action's Destruct() fires. OnEndAction — immediately after
|
/// Controls when an action's Destruct() fires. OnEndAction — immediately after
|
||||||
/// the action advances (typical for most commands). OnDelayed — deferred until
|
/// the action advances (typical for most commands). OnDelayed — deferred until
|
||||||
/// specifically cleaned up (for visual state that must persist across actions).
|
/// specifically cleaned up (for visual state that must persist across actions).
|
||||||
/// OnEndQueue — destruct when the entire dialog queue finishes (for resources
|
/// OnEndQueue — destruct when the entire dialog queue finishes (for resources
|
||||||
/// that must survive the whole dialog but not beyond).
|
/// that must survive the whole dialog but not beyond).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum DestructType
|
public enum DestructType
|
||||||
{
|
{
|
||||||
/// <summary>Destruct immediately when the action is advanced past. Default for most commands.</summary>
|
/// <summary>Destruct immediately when the action is advanced past. Default for most commands.</summary>
|
||||||
OnEndAction,
|
OnEndAction,
|
||||||
/// <summary>Destruct is deferred — must be manually triggered or triggered via <see cref="ActionCommand.DelayedDestruct"/>.</summary>
|
/// <summary>Destruct is deferred — must be manually triggered or triggered via <see cref="ActionCommand.DelayedDestruct"/>.</summary>
|
||||||
OnDelayed,
|
OnDelayed,
|
||||||
/// <summary>Destruct when the entire dialog queue finishes. Use for resources that must survive the whole dialog but not beyond.</summary>
|
/// <summary>Destruct when the entire dialog queue finishes. Use for resources that must survive the whole dialog but not beyond.</summary>
|
||||||
OnEndQueue,
|
OnEndQueue,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
namespace Cthangover.Mods.Dialog.Action
|
namespace Cthangover.Mods.Dialog.Action
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Minimal destructible contract — anything in the dialog runtime's object list
|
/// Minimal destructible contract — anything in the dialog runtime's object list
|
||||||
/// that must be cleaned up when a dialog ends.
|
/// that must be cleaned up when a dialog ends.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IActionDestruct
|
public interface IActionDestruct
|
||||||
{
|
{
|
||||||
/// <summary>Called to release resources, disconnect signals, and mark the object as finished. Must be idempotent.</summary>
|
/// <summary>Called to release resources, disconnect signals, and mark the object as finished. Must be idempotent.</summary>
|
||||||
void Destruct();
|
void Destruct();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,81 +1,81 @@
|
|||||||
using Cthangover.Core.Factories.Impls;
|
using Cthangover.Core.Factories.Impls;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Mods.Dialog.Action;
|
using Cthangover.Mods.Dialog.Action;
|
||||||
using Cthangover.Mods.Time;
|
using Cthangover.Mods.Time;
|
||||||
using Cthangover.Mods.Interface.View;
|
using Cthangover.Mods.Interface.View;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
using Cthangover.Core.UI.Event;
|
using Cthangover.Core.UI.Event;
|
||||||
using Cthangover.Core.UI.Executable;
|
using Cthangover.Core.UI.Executable;
|
||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Action.Impls
|
namespace Cthangover.Mods.Dialog.Action.Impls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the scene background on the ViewBox, including depth and albedo maps
|
/// Sets the scene background on the ViewBox, including depth and albedo maps
|
||||||
/// for the lighting system. Resolves textures through BackgroundFactory on
|
/// for the lighting system. Resolves textures through BackgroundFactory on
|
||||||
/// construction (OnStartQueue) — depth and albedo are loaded from the same
|
/// construction (OnStartQueue) — depth and albedo are loaded from the same
|
||||||
/// sprite ID with "_depth" / "_albedo" suffixes. Kills any in-progress
|
/// sprite ID with "_depth" / "_albedo" suffixes. Kills any in-progress
|
||||||
/// background transition before setting the new texture. Textures are nulled
|
/// background transition before setting the new texture. Textures are nulled
|
||||||
/// after application to prevent stale reuse across dialog restarts.
|
/// after application to prevent stale reuse across dialog restarts.
|
||||||
/// Sets SceneContextNode.LastBackgroundID so the scene manager can restore
|
/// Sets SceneContextNode.LastBackgroundID so the scene manager can restore
|
||||||
/// the correct background on scene revisit.
|
/// the correct background on scene revisit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionBackground : ActionCommand
|
public class ActionBackground : ActionCommand
|
||||||
{
|
{
|
||||||
/// <summary>Sprite resource ID resolved through <see cref="BackgroundFactory"/> on construction. Also loads depth (_depth) and albedo (_albedo) variants.</summary>
|
/// <summary>Sprite resource ID resolved through <see cref="BackgroundFactory"/> on construction. Also loads depth (_depth) and albedo (_albedo) variants.</summary>
|
||||||
public string SpriteID { get; set; }
|
public string SpriteID { get; set; }
|
||||||
/// <summary>Direct texture override. When non-null, bypasses factory resolution. Set to null after application to prevent stale reuse.</summary>
|
/// <summary>Direct texture override. When non-null, bypasses factory resolution. Set to null after application to prevent stale reuse.</summary>
|
||||||
public Texture2D Texture { get; set; }
|
public Texture2D Texture { get; set; }
|
||||||
/// <summary>Depth map for the lighting system, loaded from <see cref="SpriteID"/> + "_depth".</summary>
|
/// <summary>Depth map for the lighting system, loaded from <see cref="SpriteID"/> + "_depth".</summary>
|
||||||
public Texture2D DepthTexture { get; set; }
|
public Texture2D DepthTexture { get; set; }
|
||||||
/// <summary>Albedo color map for the lighting system, loaded from <see cref="SpriteID"/> + "_albedo".</summary>
|
/// <summary>Albedo color map for the lighting system, loaded from <see cref="SpriteID"/> + "_albedo".</summary>
|
||||||
public Texture2D AlbedoTexture { get; set; }
|
public Texture2D AlbedoTexture { get; set; }
|
||||||
|
|
||||||
/// <summary>Preloads textures when the dialog queue is first created, resolving SpriteID through the factory.</summary>
|
/// <summary>Preloads textures when the dialog queue is first created, resolving SpriteID through the factory.</summary>
|
||||||
public override ConstructType ConstructType { get; set; } = ConstructType.OnStartQueue;
|
public override ConstructType ConstructType { get; set; } = ConstructType.OnStartQueue;
|
||||||
/// <summary>Background is set imperatively — the dialog continues immediately.</summary>
|
/// <summary>Background is set imperatively — the dialog continues immediately.</summary>
|
||||||
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
||||||
|
|
||||||
/// <summary>Resolves <see cref="SpriteID"/> plus its <c>_depth</c>/<c>_albedo</c> variants through the background factory.</summary>
|
/// <summary>Resolves <see cref="SpriteID"/> plus its <c>_depth</c>/<c>_albedo</c> variants through the background factory.</summary>
|
||||||
public override void DoConstruct()
|
public override void DoConstruct()
|
||||||
{
|
{
|
||||||
base.DoConstruct();
|
base.DoConstruct();
|
||||||
if (Texture == null && !string.IsNullOrEmpty(SpriteID))
|
if (Texture == null && !string.IsNullOrEmpty(SpriteID))
|
||||||
Texture = BackgroundFactory.Instance.Get(SpriteID);
|
Texture = BackgroundFactory.Instance.Get(SpriteID);
|
||||||
if (!string.IsNullOrEmpty(SpriteID))
|
if (!string.IsNullOrEmpty(SpriteID))
|
||||||
{
|
{
|
||||||
DepthTexture = BackgroundFactory.Instance.Get(SpriteID + "_depth");
|
DepthTexture = BackgroundFactory.Instance.Get(SpriteID + "_depth");
|
||||||
AlbedoTexture = BackgroundFactory.Instance.Get(SpriteID + "_albedo");
|
AlbedoTexture = BackgroundFactory.Instance.Get(SpriteID + "_albedo");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies the background to the ViewBox, kills any in-flight background
|
/// Applies the background to the ViewBox, kills any in-flight background
|
||||||
/// transition and feeds the depth/albedo maps to the light controller.
|
/// transition and feeds the depth/albedo maps to the light controller.
|
||||||
/// Consumed textures are nulled so a reused action cannot re-apply stale data.
|
/// Consumed textures are nulled so a reused action cannot re-apply stale data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override void DoRun(DialogRuntime runtime)
|
public override void DoRun(DialogRuntime runtime)
|
||||||
{
|
{
|
||||||
if (Texture == null)
|
if (Texture == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SceneContextNode.LastBackgroundID = SpriteID;
|
SceneContextNode.LastBackgroundID = SpriteID;
|
||||||
|
|
||||||
var viewBox = Scene.Find<ViewBox>("ViewBox");
|
var viewBox = Scene.Find<ViewBox>("ViewBox");
|
||||||
viewBox?.KillTransitionTween();
|
viewBox?.KillTransitionTween();
|
||||||
viewBox?.SetBackgroundTexture(Texture);
|
viewBox?.SetBackgroundTexture(Texture);
|
||||||
|
|
||||||
var controller = UiLightController.Instance;
|
var controller = UiLightController.Instance;
|
||||||
controller?.SetupDepthMap(DepthTexture);
|
controller?.SetupDepthMap(DepthTexture);
|
||||||
controller?.SetupAlbedoMap(AlbedoTexture);
|
controller?.SetupAlbedoMap(AlbedoTexture);
|
||||||
|
|
||||||
Texture = null;
|
Texture = null;
|
||||||
DepthTexture = null;
|
DepthTexture = null;
|
||||||
AlbedoTexture = null;
|
AlbedoTexture = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using Cthangover.Mods.Dialog.Action;
|
using Cthangover.Mods.Dialog.Action;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -8,26 +8,26 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Action.Impls
|
namespace Cthangover.Mods.Dialog.Action.Impls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the background tint color. DoRun is currently a no-op — the Color
|
/// Sets the background tint color. DoRun is currently a no-op — the Color
|
||||||
/// property is stored for external systems to read. Likely intended as a
|
/// property is stored for external systems to read. Likely intended as a
|
||||||
/// declarative instruction consumed by a background-rendering node rather
|
/// declarative instruction consumed by a background-rendering node rather
|
||||||
/// than applied imperatively.
|
/// than applied imperatively.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionBackgroundColor : ActionCommand
|
public class ActionBackgroundColor : ActionCommand
|
||||||
{
|
{
|
||||||
/// <summary>Target tint color. Stored declaratively — consumed by background-rendering nodes rather than applied imperatively here.</summary>
|
/// <summary>Target tint color. Stored declaratively — consumed by background-rendering nodes rather than applied imperatively here.</summary>
|
||||||
public Color Color { get; set; } = Colors.Black;
|
public Color Color { get; set; } = Colors.Black;
|
||||||
|
|
||||||
/// <summary>Imperative — the dialog continues immediately after this action is processed.</summary>
|
/// <summary>Imperative — the dialog continues immediately after this action is processed.</summary>
|
||||||
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
||||||
|
|
||||||
/// <summary>Deliberate no-op: the tint is declarative data for background-rendering nodes, not applied here.</summary>
|
/// <summary>Deliberate no-op: the tint is declarative data for background-rendering nodes, not applied here.</summary>
|
||||||
public override void DoRun(DialogRuntime runtime)
|
public override void DoRun(DialogRuntime runtime)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using Cthangover.Mods.Dialog.Action;
|
using Cthangover.Mods.Dialog.Action;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -8,49 +8,49 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Action.Impls
|
namespace Cthangover.Mods.Dialog.Action.Impls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Waits for a fixed duration. When HiddenMode is true, hides the dialog
|
/// Waits for a fixed duration. When HiddenMode is true, hides the dialog
|
||||||
/// body for the duration (for dramatic pauses or cutscene beats). ShowText,
|
/// body for the duration (for dramatic pauses or cutscene beats). ShowText,
|
||||||
/// if set, displays a temporary message during the wait. DoDestruct is a
|
/// if set, displays a temporary message during the wait. DoDestruct is a
|
||||||
/// no-op because body visibility is implicitly restored on next Show.
|
/// no-op because body visibility is implicitly restored on next Show.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionDelay : ActionCommand
|
public class ActionDelay : ActionCommand
|
||||||
{
|
{
|
||||||
/// <summary>When true, hides the dialog body for the duration of the wait (dramatic pauses, cutscene beats).</summary>
|
/// <summary>When true, hides the dialog body for the duration of the wait (dramatic pauses, cutscene beats).</summary>
|
||||||
public bool HiddenMode { get; set; }
|
public bool HiddenMode { get; set; }
|
||||||
/// <summary>Optional temporary text displayed while waiting. Set to null to keep the current dialog text.</summary>
|
/// <summary>Optional temporary text displayed while waiting. Set to null to keep the current dialog text.</summary>
|
||||||
public string ShowText { get; set; }
|
public string ShowText { get; set; }
|
||||||
|
|
||||||
/// <summary>Pauses the dialog until <see cref="WaitTime"/> elapses.</summary>
|
/// <summary>Pauses the dialog until <see cref="WaitTime"/> elapses.</summary>
|
||||||
public override WaitType WaitType { get; set; } = WaitType.WaitTime;
|
public override WaitType WaitType { get; set; } = WaitType.WaitTime;
|
||||||
/// <summary>Duration of the pause in seconds. Default 1.0.</summary>
|
/// <summary>Duration of the pause in seconds. Default 1.0.</summary>
|
||||||
public override float WaitTime { get; set; } = 1f;
|
public override float WaitTime { get; set; } = 1f;
|
||||||
|
|
||||||
/// <summary>Shows the optional <see cref="ShowText"/> and, in <see cref="HiddenMode"/>, hides the dialog body for the pause duration.</summary>
|
/// <summary>Shows the optional <see cref="ShowText"/> and, in <see cref="HiddenMode"/>, hides the dialog body for the pause duration.</summary>
|
||||||
public override void DoRun(DialogRuntime runtime)
|
public override void DoRun(DialogRuntime runtime)
|
||||||
{
|
{
|
||||||
var dialogBox = runtime.DialogBox;
|
var dialogBox = runtime.DialogBox;
|
||||||
if (dialogBox == null)
|
if (dialogBox == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ShowText != null)
|
if (ShowText != null)
|
||||||
dialogBox.SetText(ShowText);
|
dialogBox.SetText(ShowText);
|
||||||
|
|
||||||
if (HiddenMode)
|
if (HiddenMode)
|
||||||
dialogBox.Body.SetDeferred("visible", false);
|
dialogBox.Body.SetDeferred("visible", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>No-op: the dialog body hidden by <see cref="HiddenMode"/> is restored implicitly by the next show.</summary>
|
/// <summary>No-op: the dialog body hidden by <see cref="HiddenMode"/> is restored implicitly by the next show.</summary>
|
||||||
public override void DoDestruct()
|
public override void DoDestruct()
|
||||||
{
|
{
|
||||||
base.DoDestruct();
|
base.DoDestruct();
|
||||||
if (HiddenMode)
|
if (HiddenMode)
|
||||||
{
|
{
|
||||||
// Body restored on next Show
|
// Body restored on next Show
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using Cthangover.Mods.Dialog.Action;
|
using Cthangover.Mods.Dialog.Action;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -8,22 +8,22 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Action.Impls
|
namespace Cthangover.Mods.Dialog.Action.Impls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// No-op placeholder action. Used as a labeled jump target (Point) for GoTo
|
/// No-op placeholder action. Used as a labeled jump target (Point) for GoTo
|
||||||
/// commands — provides an addressable marker in the dialog sequence without
|
/// commands — provides an addressable marker in the dialog sequence without
|
||||||
/// any visible effect. NoWait so the dialog skips through labels instantly.
|
/// any visible effect. NoWait so the dialog skips through labels instantly.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionEmpty : ActionCommand
|
public class ActionEmpty : ActionCommand
|
||||||
{
|
{
|
||||||
/// <summary>Label actions skip immediately so the dialog doesn't pause on markers.</summary>
|
/// <summary>Label actions skip immediately so the dialog doesn't pause on markers.</summary>
|
||||||
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
||||||
|
|
||||||
/// <summary>No-op: the action exists only to carry the jump-target ID.</summary>
|
/// <summary>No-op: the action exists only to carry the jump-target ID.</summary>
|
||||||
public override void DoRun(DialogRuntime runtime)
|
public override void DoRun(DialogRuntime runtime)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using Cthangover.Mods.Dialog.Action;
|
using Cthangover.Mods.Dialog.Action;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -8,23 +8,23 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Action.Impls
|
namespace Cthangover.Mods.Dialog.Action.Impls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Terminates the dialog queue immediately. Calls Runtime.End() which
|
/// Terminates the dialog queue immediately. Calls Runtime.End() which
|
||||||
/// destructs all remaining actions, processes the cleanup queue, hides
|
/// destructs all remaining actions, processes the cleanup queue, hides
|
||||||
/// the dialog box, and fires the dialog-end event.
|
/// the dialog box, and fires the dialog-end event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionEnd : ActionCommand
|
public class ActionEnd : ActionCommand
|
||||||
{
|
{
|
||||||
/// <summary>Ends the dialog queue immediately — no pause, no return.</summary>
|
/// <summary>Ends the dialog queue immediately — no pause, no return.</summary>
|
||||||
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
||||||
|
|
||||||
/// <summary>Terminates the queue via <see cref="DialogRuntime.End"/> — destructs remainders, runs cleanup, hides the box, fires the end event.</summary>
|
/// <summary>Terminates the queue via <see cref="DialogRuntime.End"/> — destructs remainders, runs cleanup, hides the box, fires the end event.</summary>
|
||||||
public override void DoRun(DialogRuntime runtime)
|
public override void DoRun(DialogRuntime runtime)
|
||||||
{
|
{
|
||||||
runtime.End();
|
runtime.End();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using Cthangover.Mods.Dialog.Action;
|
using Cthangover.Mods.Dialog.Action;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -8,26 +8,26 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Action.Impls
|
namespace Cthangover.Mods.Dialog.Action.Impls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unconditional jump to a labeled action in the dialog queue. NoWait so
|
/// Unconditional jump to a labeled action in the dialog queue. NoWait so
|
||||||
/// the jump happens transparently. The target is resolved by action ID
|
/// the jump happens transparently. The target is resolved by action ID
|
||||||
/// (set via ActionCommand.SetID or the Point()/Empty() fluent methods).
|
/// (set via ActionCommand.SetID or the Point()/Empty() fluent methods).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionGoTo : ActionCommand
|
public class ActionGoTo : ActionCommand
|
||||||
{
|
{
|
||||||
/// <summary>Target action ID to jump to. Resolved by linear search through the dialog queue.</summary>
|
/// <summary>Target action ID to jump to. Resolved by linear search through the dialog queue.</summary>
|
||||||
public string GoTo { get; set; }
|
public string GoTo { get; set; }
|
||||||
|
|
||||||
/// <summary>Jump happens transparently — the dialog continues from the target without pausing.</summary>
|
/// <summary>Jump happens transparently — the dialog continues from the target without pausing.</summary>
|
||||||
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
||||||
|
|
||||||
/// <summary>Jumps the queue index to the action whose ID matches <see cref="GoTo"/>.</summary>
|
/// <summary>Jumps the queue index to the action whose ID matches <see cref="GoTo"/>.</summary>
|
||||||
public override void DoRun(DialogRuntime runtime)
|
public override void DoRun(DialogRuntime runtime)
|
||||||
{
|
{
|
||||||
runtime.TryGoTo(GoTo);
|
runtime.TryGoTo(GoTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,24 @@
|
|||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Action.Impls
|
namespace Cthangover.Mods.Dialog.Action.Impls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hides the dialog box. Used in cutscenes where UI chrome should be
|
/// Hides the dialog box. Used in cutscenes where UI chrome should be
|
||||||
/// temporarily hidden while animations or background transitions play.
|
/// temporarily hidden while animations or background transitions play.
|
||||||
/// Paired with ActionShowDialog to restore visibility.
|
/// Paired with ActionShowDialog to restore visibility.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionHideDialog : ActionCommand
|
public class ActionHideDialog : ActionCommand
|
||||||
{
|
{
|
||||||
/// <summary>Hides the dialog immediately — the queue continues without pause.</summary>
|
/// <summary>Hides the dialog immediately — the queue continues without pause.</summary>
|
||||||
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
||||||
|
|
||||||
/// <summary>Hides the dialog box chrome while keeping the queue running.</summary>
|
/// <summary>Hides the dialog box chrome while keeping the queue running.</summary>
|
||||||
public override void DoRun(DialogRuntime runtime)
|
public override void DoRun(DialogRuntime runtime)
|
||||||
{
|
{
|
||||||
var dialogBox = runtime.DialogBox;
|
var dialogBox = runtime.DialogBox;
|
||||||
if (dialogBox == null)
|
if (dialogBox == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dialogBox.Visible = false;
|
dialogBox.Visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,40 +1,40 @@
|
|||||||
using Cthangover.Mods.Time;
|
using Cthangover.Mods.Time;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
using Cthangover.Core.UI.Event;
|
using Cthangover.Core.UI.Event;
|
||||||
using Cthangover.Core.UI.Executable;
|
using Cthangover.Core.UI.Executable;
|
||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Action.Impls
|
namespace Cthangover.Mods.Dialog.Action.Impls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies static lights from a JSON string to the UiLightController.
|
/// Applies static lights from a JSON string to the UiLightController.
|
||||||
/// An empty or null string clears all static lights. The JSON is deserialized
|
/// An empty or null string clears all static lights. The JSON is deserialized
|
||||||
/// into LightDef objects with viewport-relative coordinates, which are then
|
/// into LightDef objects with viewport-relative coordinates, which are then
|
||||||
/// converted to pixel positions. Supports up to 10 static lights plus the
|
/// converted to pixel positions. Supports up to 10 static lights plus the
|
||||||
/// player's dynamic lamp.
|
/// player's dynamic lamp.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionLightSet : ActionCommand
|
public class ActionLightSet : ActionCommand
|
||||||
{
|
{
|
||||||
/// <summary>JSON string defining static light positions and properties. Empty or null clears all static lights.</summary>
|
/// <summary>JSON string defining static light positions and properties. Empty or null clears all static lights.</summary>
|
||||||
public string LightsJson { get; set; }
|
public string LightsJson { get; set; }
|
||||||
|
|
||||||
/// <summary>Lights are set imperatively — the dialog continues immediately.</summary>
|
/// <summary>Lights are set imperatively — the dialog continues immediately.</summary>
|
||||||
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
||||||
|
|
||||||
/// <summary>Clears static lights when <see cref="LightsJson"/> is empty, otherwise parses and applies the light definitions to the scene's <see cref="UiLightController"/>.</summary>
|
/// <summary>Clears static lights when <see cref="LightsJson"/> is empty, otherwise parses and applies the light definitions to the scene's <see cref="UiLightController"/>.</summary>
|
||||||
public override void DoRun(DialogRuntime runtime)
|
public override void DoRun(DialogRuntime runtime)
|
||||||
{
|
{
|
||||||
var controller = Scene.Find<UiLightController>("Lights");
|
var controller = Scene.Find<UiLightController>("Lights");
|
||||||
if (controller == null)
|
if (controller == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(LightsJson))
|
if (string.IsNullOrEmpty(LightsJson))
|
||||||
controller.ClearStaticLights();
|
controller.ClearStaticLights();
|
||||||
else
|
else
|
||||||
controller.SetStaticLights(LightsJson);
|
controller.SetStaticLights(LightsJson);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,33 +1,33 @@
|
|||||||
using Cthangover.Mods.Dialog.Action;
|
using Cthangover.Mods.Dialog.Action;
|
||||||
using Cthangover.Mods.Time;
|
using Cthangover.Mods.Time;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
using Cthangover.Core.UI.Event;
|
using Cthangover.Core.UI.Event;
|
||||||
using Cthangover.Core.UI.Executable;
|
using Cthangover.Core.UI.Executable;
|
||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Action.Impls
|
namespace Cthangover.Mods.Dialog.Action.Impls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Toggles the light controller's time-of-day mode. When UseTime is false,
|
/// Toggles the light controller's time-of-day mode. When UseTime is false,
|
||||||
/// static lighting is used; when true, lighting responds to the in-game clock.
|
/// static lighting is used; when true, lighting responds to the in-game clock.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionLightUseTime : ActionCommand
|
public class ActionLightUseTime : ActionCommand
|
||||||
{
|
{
|
||||||
/// <summary>True = lights respond to in-game time of day; false = static lighting mode.</summary>
|
/// <summary>True = lights respond to in-game time of day; false = static lighting mode.</summary>
|
||||||
public bool UseTime { get; set; } = true;
|
public bool UseTime { get; set; } = true;
|
||||||
|
|
||||||
/// <summary>Time mode toggle is instant — the dialog continues without pause.</summary>
|
/// <summary>Time mode toggle is instant — the dialog continues without pause.</summary>
|
||||||
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
||||||
|
|
||||||
/// <summary>Switches the scene's <see cref="UiLightController"/> between time-of-day lighting and static lights.</summary>
|
/// <summary>Switches the scene's <see cref="UiLightController"/> between time-of-day lighting and static lights.</summary>
|
||||||
public override void DoRun(DialogRuntime runtime)
|
public override void DoRun(DialogRuntime runtime)
|
||||||
{
|
{
|
||||||
var controller = Scene.Find<UiLightController>("Lights");
|
var controller = Scene.Find<UiLightController>("Lights");
|
||||||
if (controller != null)
|
if (controller != null)
|
||||||
controller.IsUseLight = UseTime;
|
controller.IsUseLight = UseTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,37 +1,37 @@
|
|||||||
using Cthangover.Core.Audio;
|
using Cthangover.Core.Audio;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
using Cthangover.Core.UI.Event;
|
using Cthangover.Core.UI.Event;
|
||||||
using Cthangover.Core.UI.Executable;
|
using Cthangover.Core.UI.Executable;
|
||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Action.Impls
|
namespace Cthangover.Mods.Dialog.Action.Impls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts background music playback via IAudioService. Uses MusicType.Ambient
|
/// Starts background music playback via IAudioService. Uses MusicType.Ambient
|
||||||
/// so the music layer is treated as atmospheric background rather than UI
|
/// so the music layer is treated as atmospheric background rather than UI
|
||||||
/// feedback. If the same music track is already playing, the audio service handles
|
/// feedback. If the same music track is already playing, the audio service handles
|
||||||
/// deduplication.
|
/// deduplication.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionMusic : ActionCommand
|
public class ActionMusic : ActionCommand
|
||||||
{
|
{
|
||||||
/// <summary>Music track identifier resolved through the audio system. Empty strings are silently ignored.</summary>
|
/// <summary>Music track identifier resolved through the audio system. Empty strings are silently ignored.</summary>
|
||||||
public string Music { get; set; }
|
public string Music { get; set; }
|
||||||
|
|
||||||
/// <summary>Music starts playing in the background — the dialog continues immediately.</summary>
|
/// <summary>Music starts playing in the background — the dialog continues immediately.</summary>
|
||||||
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
||||||
|
|
||||||
/// <summary>Starts the named track as ambient background music through <see cref="IAudioService"/>; empty names are ignored.</summary>
|
/// <summary>Starts the named track as ambient background music through <see cref="IAudioService"/>; empty names are ignored.</summary>
|
||||||
public override void DoRun(DialogRuntime runtime)
|
public override void DoRun(DialogRuntime runtime)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(Music))
|
if (string.IsNullOrEmpty(Music))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var audioService = Scene.Find<Node>("AudioService") as IAudioService;
|
var audioService = Scene.Find<Node>("AudioService") as IAudioService;
|
||||||
audioService?.PlayMusic(Music, MusicType.Ambient);
|
audioService?.PlayMusic(Music, MusicType.Ambient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,29 +1,29 @@
|
|||||||
using Cthangover.Core.Audio;
|
using Cthangover.Core.Audio;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
using Cthangover.Core.UI.Event;
|
using Cthangover.Core.UI.Event;
|
||||||
using Cthangover.Core.UI.Executable;
|
using Cthangover.Core.UI.Executable;
|
||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Action.Impls
|
namespace Cthangover.Mods.Dialog.Action.Impls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Pauses background music playback via IAudioService without stopping the
|
/// Pauses background music playback via IAudioService without stopping the
|
||||||
/// track. Can be resumed with ActionMusicPlay.
|
/// track. Can be resumed with ActionMusicPlay.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionMusicPause : ActionCommand
|
public class ActionMusicPause : ActionCommand
|
||||||
{
|
{
|
||||||
/// <summary>Pause is instant — the dialog continues without waiting for audio acknowledgment.</summary>
|
/// <summary>Pause is instant — the dialog continues without waiting for audio acknowledgment.</summary>
|
||||||
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
||||||
|
|
||||||
/// <summary>Pauses the current music track without stopping it, so <see cref="ActionMusicPlay"/> can resume it.</summary>
|
/// <summary>Pauses the current music track without stopping it, so <see cref="ActionMusicPlay"/> can resume it.</summary>
|
||||||
public override void DoRun(DialogRuntime runtime)
|
public override void DoRun(DialogRuntime runtime)
|
||||||
{
|
{
|
||||||
var audioService = Scene.Find<Node>("AudioService") as IAudioService;
|
var audioService = Scene.Find<Node>("AudioService") as IAudioService;
|
||||||
audioService?.PauseMusic(true);
|
audioService?.PauseMusic(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,28 +1,28 @@
|
|||||||
using Cthangover.Core.Audio;
|
using Cthangover.Core.Audio;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
using Cthangover.Core.UI.Event;
|
using Cthangover.Core.UI.Event;
|
||||||
using Cthangover.Core.UI.Executable;
|
using Cthangover.Core.UI.Executable;
|
||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Action.Impls
|
namespace Cthangover.Mods.Dialog.Action.Impls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resumes paused background music. Paired with ActionMusicPause.
|
/// Resumes paused background music. Paired with ActionMusicPause.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionMusicPlay : ActionCommand
|
public class ActionMusicPlay : ActionCommand
|
||||||
{
|
{
|
||||||
/// <summary>Resume is instant — the dialog continues without waiting for audio.</summary>
|
/// <summary>Resume is instant — the dialog continues without waiting for audio.</summary>
|
||||||
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
||||||
|
|
||||||
/// <summary>Resumes music paused by <see cref="ActionMusicPause"/>.</summary>
|
/// <summary>Resumes music paused by <see cref="ActionMusicPause"/>.</summary>
|
||||||
public override void DoRun(DialogRuntime runtime)
|
public override void DoRun(DialogRuntime runtime)
|
||||||
{
|
{
|
||||||
var audioService = Scene.Find<Node>("AudioService") as IAudioService;
|
var audioService = Scene.Find<Node>("AudioService") as IAudioService;
|
||||||
audioService?.PauseMusic(false);
|
audioService?.PauseMusic(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using Cthangover.Core.Utils;
|
using Cthangover.Core.Utils;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
@@ -7,33 +7,33 @@ using Cthangover.Core.UI.Executable;
|
|||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog.Action.Impls
|
namespace Cthangover.Mods.Dialog.Action.Impls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes an arbitrary Action delegate inside the dialog queue.
|
/// Executes an arbitrary Action delegate inside the dialog queue.
|
||||||
/// Allows imperative code injection (e.g. quest state changes, UI toggles)
|
/// Allows imperative code injection (e.g. quest state changes, UI toggles)
|
||||||
/// without creating a dedicated action class. NoWait so the queue advances
|
/// without creating a dedicated action class. NoWait so the queue advances
|
||||||
/// immediately after the delegate returns.
|
/// immediately after the delegate returns.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionRun : ActionCommand
|
public class ActionRun : ActionCommand
|
||||||
{
|
{
|
||||||
/// <summary>Arbitrary delegate executed during dialog sequencing. Null delegates are logged and skipped.</summary>
|
/// <summary>Arbitrary delegate executed during dialog sequencing. Null delegates are logged and skipped.</summary>
|
||||||
public System.Action Executable { get; set; }
|
public System.Action Executable { get; set; }
|
||||||
|
|
||||||
/// <summary>The delegate runs and the dialog advances — no pausing.</summary>
|
/// <summary>The delegate runs and the dialog advances — no pausing.</summary>
|
||||||
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
public override WaitType WaitType { get; set; } = WaitType.NoWait;
|
||||||
|
|
||||||
/// <summary>Invokes <see cref="Executable"/>; a null delegate is logged and skipped so the queue keeps flowing.</summary>
|
/// <summary>Invokes <see cref="Executable"/>; a null delegate is logged and skipped so the queue keeps flowing.</summary>
|
||||||
public override void DoRun(DialogRuntime runtime)
|
public override void DoRun(DialogRuntime runtime)
|
||||||
{
|
{
|
||||||
if (Executable == null)
|
if (Executable == null)
|
||||||
{
|
{
|
||||||
GameLogger.Log("DIALOG", "ActionRun: Executable delegate is null", LogLevel.Error);
|
GameLogger.Log("DIALOG", "ActionRun: Executable delegate is null", LogLevel.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Executable();
|
Executable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,24 @@
|
|||||||
namespace Cthangover.Mods.Dialog.Action
|
namespace Cthangover.Mods.Dialog.Action
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines how the DialogRuntime advances past this action. NoWait chains
|
/// Determines how the DialogRuntime advances past this action. NoWait chains
|
||||||
/// immediately to the next action (for imperative commands). WaitClick pauses
|
/// immediately to the next action (for imperative commands). WaitClick pauses
|
||||||
/// until user input (click/key). WaitSelect pauses for variant selection.
|
/// until user input (click/key). WaitSelect pauses for variant selection.
|
||||||
/// WaitTime pauses for a fixed duration. WaitEvent pauses until an external
|
/// WaitTime pauses for a fixed duration. WaitEvent pauses until an external
|
||||||
/// event marks the action as destructed.
|
/// event marks the action as destructed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum WaitType
|
public enum WaitType
|
||||||
{
|
{
|
||||||
/// <summary>Don't wait — the runtime advances to the next action immediately in the same Run call.</summary>
|
/// <summary>Don't wait — the runtime advances to the next action immediately in the same Run call.</summary>
|
||||||
NoWait,
|
NoWait,
|
||||||
/// <summary>Pause until the player clicks or presses the accept key. Used by dialog text actions.</summary>
|
/// <summary>Pause until the player clicks or presses the accept key. Used by dialog text actions.</summary>
|
||||||
WaitClick,
|
WaitClick,
|
||||||
/// <summary>Pause until the player selects a choice variant. Used by choice menus.</summary>
|
/// <summary>Pause until the player selects a choice variant. Used by choice menus.</summary>
|
||||||
WaitSelect,
|
WaitSelect,
|
||||||
/// <summary>Pause for a fixed duration in seconds (<see cref="ActionCommand.WaitTime"/>).</summary>
|
/// <summary>Pause for a fixed duration in seconds (<see cref="ActionCommand.WaitTime"/>).</summary>
|
||||||
WaitTime,
|
WaitTime,
|
||||||
/// <summary>Pause until an external event marks the action as destructed (<see cref="ActionCommand.IsDestructed"/>).</summary>
|
/// <summary>Pause until an external event marks the action as destructed (<see cref="ActionCommand.IsDestructed"/>).</summary>
|
||||||
WaitEvent,
|
WaitEvent,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+70
-70
@@ -1,70 +1,70 @@
|
|||||||
using Cthangover.Mods.Interface.Base.Lists;
|
using Cthangover.Mods.Interface.Base.Lists;
|
||||||
using Cthangover.Mods.Dialog.Action.Impls;
|
using Cthangover.Mods.Dialog.Action.Impls;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Cthangover.Core.UI;
|
using Cthangover.Core.UI;
|
||||||
using Cthangover.Core.UI.Dialog;
|
using Cthangover.Core.UI.Dialog;
|
||||||
using Cthangover.Core.UI.Event;
|
using Cthangover.Core.UI.Event;
|
||||||
using Cthangover.Core.UI.Executable;
|
using Cthangover.Core.UI.Executable;
|
||||||
using Cthangover.Core.Scenarios;
|
using Cthangover.Core.Scenarios;
|
||||||
using Cthangover.Core.Scenes;
|
using Cthangover.Core.Scenes;
|
||||||
using Cthangover.Core.Interactive;
|
using Cthangover.Core.Interactive;
|
||||||
|
|
||||||
namespace Cthangover.Mods.Dialog
|
namespace Cthangover.Mods.Dialog
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Renders a single dialog choice option. Walks up the scene tree in OnReady
|
/// Renders a single dialog choice option. Walks up the scene tree in OnReady
|
||||||
/// to find the nearest IDialogBox parent — this avoids coupling to a specific
|
/// to find the nearest IDialogBox parent — this avoids coupling to a specific
|
||||||
/// dialog implementation and lets answer items work regardless of nesting depth.
|
/// dialog implementation and lets answer items work regardless of nesting depth.
|
||||||
/// On click, calls SelectVariant on the found dialog box, passing the bound
|
/// On click, calls SelectVariant on the found dialog box, passing the bound
|
||||||
/// SelectVariant model (which carries the GoTo target and display text).
|
/// SelectVariant model (which carries the GoTo target and display text).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class AnswerItem : ListItem<SelectVariant>
|
public partial class AnswerItem : ListItem<SelectVariant>
|
||||||
{
|
{
|
||||||
|
|
||||||
[Export] private Label textField;
|
[Export] private Label textField;
|
||||||
|
|
||||||
private DialogBox dialogBox;
|
private DialogBox dialogBox;
|
||||||
|
|
||||||
/// <summary>Binds the choice button from the answer_item scene prefab and finds the owning dialog box by walking up the tree, so items work at any nesting depth.</summary>
|
/// <summary>Binds the choice button from the answer_item scene prefab and finds the owning dialog box by walking up the tree, so items work at any nesting depth.</summary>
|
||||||
protected override void OnReady()
|
protected override void OnReady()
|
||||||
{
|
{
|
||||||
textField ??= GetNode<Label>("Button/TextLabel");
|
textField ??= GetNode<Label>("Button/TextLabel");
|
||||||
|
|
||||||
var btn = GetNode<Button>("Button");
|
var btn = GetNode<Button>("Button");
|
||||||
if (btn != null)
|
if (btn != null)
|
||||||
btn.Pressed += OnClick;
|
btn.Pressed += OnClick;
|
||||||
|
|
||||||
if (dialogBox == null)
|
if (dialogBox == null)
|
||||||
{
|
{
|
||||||
var parent = GetParent();
|
var parent = GetParent();
|
||||||
while (parent != null)
|
while (parent != null)
|
||||||
{
|
{
|
||||||
if (parent is DialogBox db)
|
if (parent is DialogBox db)
|
||||||
{
|
{
|
||||||
dialogBox = db;
|
dialogBox = db;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
parent = parent.GetParent();
|
parent = parent.GetParent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Binds the variant model and sets the button label text to <see cref="SelectVariant.Text"/>.</summary>
|
/// <summary>Binds the variant model and sets the button label text to <see cref="SelectVariant.Text"/>.</summary>
|
||||||
public override void Construct(SelectVariant variant)
|
public override void Construct(SelectVariant variant)
|
||||||
{
|
{
|
||||||
base.Construct(variant);
|
base.Construct(variant);
|
||||||
textField.Text = variant.Text;
|
textField.Text = variant.Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick()
|
private void OnClick()
|
||||||
{
|
{
|
||||||
dialogBox?.SelectVariant(Model);
|
dialogBox?.SelectVariant(Model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Required by <see cref="IListItem{TModel}"/>. Intentionally empty — the parent AnswerBox handles cleanup.</summary>
|
/// <summary>Required by <see cref="IListItem{TModel}"/>. Intentionally empty — the parent AnswerBox handles cleanup.</summary>
|
||||||
public override void Destruct()
|
public override void Destruct()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,27 +1,27 @@
|
|||||||
namespace Cthangover.Mods.Dialog.Executable
|
namespace Cthangover.Mods.Dialog.Executable
|
||||||
{
|
{
|
||||||
using Cthangover.Core.UI.Executable;
|
using Cthangover.Core.UI.Executable;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Simplest IEventObject implementation: carries an ID and self-destructs
|
/// Simplest IEventObject implementation: carries an ID and self-destructs
|
||||||
/// via QueueFree when Destruct() is called. Used as a base for scene objects
|
/// via QueueFree when Destruct() is called. Used as a base for scene objects
|
||||||
/// that must be tracked by the event system for cleanup.
|
/// that must be tracked by the event system for cleanup.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class IdentifiableEventObjectBehaviour : Godot.Node, IEventObject
|
public partial class IdentifiableEventObjectBehaviour : Godot.Node, IEventObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Identifier for this event object. Set externally to allow the event
|
/// Identifier for this event object. Set externally to allow the event
|
||||||
/// tracking system to locate and manage this instance.
|
/// tracking system to locate and manage this instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ID { get; private set; }
|
public string ID { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Signals cleanup by calling <c>QueueFree</c> to remove this node from
|
/// Signals cleanup by calling <c>QueueFree</c> to remove this node from
|
||||||
/// the scene tree and release resources.
|
/// the scene tree and release resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Destruct()
|
public void Destruct()
|
||||||
{
|
{
|
||||||
QueueFree();
|
QueueFree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user