剧情+对话完善
This commit is contained in:
@@ -23,31 +23,18 @@ namespace Ichni.Story.YarnFunctions
|
||||
[YarnCommand("unlock_song")]
|
||||
public static void UnlockSong(string songUnlockKey)
|
||||
{
|
||||
if (!TryGrantUnlockKey(songUnlockKey, out bool wasNewlyGranted) || !wasNewlyGranted)
|
||||
ExecuteAfterDialogueCommit(() =>
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 将歌曲提示加入对话结束队列。弹窗本地化将由后续 Localization 阶段替换,
|
||||
// 这里不参与内容是否解锁的授权判断。
|
||||
if (StoryDialogueController.instance != null)
|
||||
{
|
||||
StoryDialogueController.instance.dialogueEndActions.Add(() =>
|
||||
if (!TryGrantUnlockKey(songUnlockKey, out bool wasNewlyGranted) || !wasNewlyGranted)
|
||||
{
|
||||
if (MessageUIPage.instance != null)
|
||||
{
|
||||
MessageUIPage.instance.ShowUnlockMessage(songUnlockKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("[StoryTreeCommands] 弹窗失败:场景中未找到 StoryMessageBoxUIPage 实例!");
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("[StoryTreeCommands] 弹窗队列注册失败:未找到 StoryDialogueController 实例!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (MessageUIPage.instance != null)
|
||||
MessageUIPage.instance.ShowUnlockMessage(songUnlockKey);
|
||||
else
|
||||
Debug.LogError("[StoryTreeCommands] 弹窗失败:场景中未找到 StoryMessageBoxUIPage 实例!");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -59,7 +46,9 @@ namespace Ichni.Story.YarnFunctions
|
||||
[YarnCommand("grant_unlock")]
|
||||
public static void GrantUnlock(string unlockKey)
|
||||
{
|
||||
TryGrantUnlockKey(unlockKey, out _);
|
||||
// 全局解锁不属于 ChapterStorySave,Timeline 回滚永远不会撤销已提交的 Key;
|
||||
// 但在当前对话尚未正常结束前,也不能因 Back 而提前写入。
|
||||
ExecuteAfterDialogueCommit(() => TryGrantUnlockKey(unlockKey, out _));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -76,12 +65,34 @@ namespace Ichni.Story.YarnFunctions
|
||||
string translatedTitle = GetTranslatedText(tableName, titleKey);
|
||||
string translatedContent = GetTranslatedText(tableName, contentKey);
|
||||
Debug.Log($"[StoryTreeCommands] 准备在对话结束后显示自定义弹窗:标题='{translatedTitle}',内容='{translatedContent}'");
|
||||
StoryDialogueController.instance.dialogueEndActions.Add(() =>
|
||||
ExecuteAfterDialogueCommit(() =>
|
||||
{
|
||||
MessageUIPage.instance.ShowCustomMessage(translatedTitle, translatedContent);
|
||||
if (MessageUIPage.instance != null)
|
||||
MessageUIPage.instance.ShowCustomMessage(translatedTitle, translatedContent);
|
||||
else
|
||||
Debug.LogError("[StoryTreeCommands] 无法显示自定义弹窗:未找到 MessageUIPage 实例。");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在 TextBlock 事务活跃时延后执行全局副作用;无活动事务时立即执行。
|
||||
/// 这样 Yarn 命令可以在对话和未来的非对话入口共用,同时保持 Back/失败时不落盘的事务边界。
|
||||
/// </summary>
|
||||
private static void ExecuteAfterDialogueCommit(System.Action action)
|
||||
{
|
||||
if (action == null)
|
||||
return;
|
||||
|
||||
StoryDialogueController controller = StoryDialogueController.instance;
|
||||
if (controller != null)
|
||||
{
|
||||
controller.ExecuteAfterDialogueCommit(action.Invoke);
|
||||
return;
|
||||
}
|
||||
|
||||
action.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 所有 Yarn 解锁命令共用的授予入口。它负责模块存在性检查、重复授予的幂等处理及立即 ES3 保存。
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user