剧情+对话完善
This commit is contained in:
@@ -9,7 +9,6 @@ namespace Ichni.UI
|
||||
{
|
||||
public RectTransform chapterContainer;
|
||||
public HorizontalLayoutGroup containerLayoutGroup;
|
||||
public Button settingsButton;
|
||||
public GameObject chapterSelectionUIPrefab;
|
||||
|
||||
protected override void Awake()
|
||||
@@ -18,11 +17,6 @@ namespace Ichni.UI
|
||||
|
||||
fadeInStartAction = Initialize;
|
||||
|
||||
settingsButton.onClick.AddListener(() =>
|
||||
{
|
||||
FadeOut();
|
||||
MenuManager.instance.settingsUIPage.FadeIn();
|
||||
});
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
@@ -41,4 +35,4 @@ namespace Ichni.UI
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
54
Assets/Scripts/UI/Settings/SettingsButton.cs
Normal file
54
Assets/Scripts/UI/Settings/SettingsButton.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using Ichni.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Menu
|
||||
{
|
||||
/// <summary>
|
||||
/// 可挂载在任意菜单页面上的通用设置入口。
|
||||
/// <para>按钮默认从父级自动查找 <see cref="UIPageBase"/> 作为来源页面;如按钮不在页面层级之下,
|
||||
/// 可在 Inspector 中手动指定 sourcePage。点击后由 SettingsUIPage 记录来源,因此返回时会回到正确页面。</para>
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Button))]
|
||||
public class SettingsButton : MonoBehaviour
|
||||
{
|
||||
[SerializeField, Tooltip("打开设置页前需要隐藏的来源页面。留空时自动从父级寻找 UIPageBase。")]
|
||||
private UIPageBase sourcePage;
|
||||
|
||||
private Button _button;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_button = GetComponent<Button>();
|
||||
if (sourcePage == null)
|
||||
sourcePage = GetComponentInParent<UIPageBase>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_button.onClick.AddListener(OpenSettings);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_button.onClick.RemoveListener(OpenSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开全局 SettingsUIPage。设置页引用未配置时仅输出警告,保留当前页面,避免点击后丢失界面。
|
||||
/// </summary>
|
||||
private void OpenSettings()
|
||||
{
|
||||
SettingsUIPage settingsPage = MenuManager.instance != null
|
||||
? MenuManager.instance.settingsUIPage
|
||||
: null;
|
||||
if (settingsPage == null)
|
||||
{
|
||||
Debug.LogWarning("[SettingsButton] SettingsUIPage 未配置,无法打开设置页。", this);
|
||||
return;
|
||||
}
|
||||
|
||||
settingsPage.OpenFrom(sourcePage);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Settings/SettingsButton.cs.meta
Normal file
11
Assets/Scripts/UI/Settings/SettingsButton.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fad765e8a5d4c47a434e22e06254b7e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -10,6 +10,10 @@ namespace Ichni.Menu
|
||||
public Button backButton;
|
||||
public SettingsWindowController settingsWindowController;
|
||||
public OffsetEditor offsetEditor;
|
||||
|
||||
// 设置页不再假定只能从章节选择页进入。该引用只保存本次打开设置时的来源,
|
||||
// 不需要写入存档;关闭设置页后即清空。
|
||||
private UIPageBase _returnPage;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
@@ -19,8 +23,20 @@ namespace Ichni.Menu
|
||||
{
|
||||
FadeOut();
|
||||
SettingsManager.instance.SaveGameSettings();
|
||||
MenuManager.instance.chapterSelectionUIPage.FadeIn();
|
||||
(_returnPage ?? MenuManager.instance.chapterSelectionUIPage)?.FadeIn();
|
||||
_returnPage = null;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 由独立的 <see cref="SettingsButton"/> 调用,记录打开设置页的来源并切换页面。
|
||||
/// 这样章节选择页、剧情页及未来其它页面都可复用同一个设置按钮逻辑。
|
||||
/// </summary>
|
||||
public void OpenFrom(UIPageBase sourcePage)
|
||||
{
|
||||
_returnPage = sourcePage;
|
||||
sourcePage?.FadeOut();
|
||||
FadeIn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,19 @@ namespace Ichni.Menu
|
||||
public bool isDuringSnap = false;
|
||||
public RectTransform closestTab;
|
||||
|
||||
// 仅供 Story SongBlock 在“下一次初始化列表”时指定初始歌曲;不写入章节缓存,
|
||||
// 以免剧情入口覆盖玩家平时在该章节记录的歌曲/难度选择。
|
||||
private SongItemData _initialSongSelectionOverride;
|
||||
|
||||
/// <summary>
|
||||
/// 请求下一次 <see cref="InitializeList"/> 自动选中指定歌曲。
|
||||
/// 此请求是一次性的:无论目标是否仍存在,初始化完成后都会清除。
|
||||
/// </summary>
|
||||
public void RequestInitialSongSelection(SongItemData song)
|
||||
{
|
||||
_initialSongSelectionOverride = song;
|
||||
}
|
||||
|
||||
public void InitializeList()
|
||||
{
|
||||
// FadeOut 通常已经清理过旧 Tab,但这里仍保持幂等,防止重复初始化时残留旧引用或重复 UI。
|
||||
@@ -66,6 +79,7 @@ namespace Ichni.Menu
|
||||
MenuManager.instance.songSelectionUIPage.selectedSong = null;
|
||||
MenuManager.instance.songSelectionUIPage.selectedSave = null;
|
||||
MenuManager.instance.songSelectionUIPage.difficultySelectionContainer.SetUp(null);
|
||||
_initialSongSelectionOverride = null;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -106,6 +120,32 @@ namespace Ichni.Menu
|
||||
menuInformationRecorder.SetRecordForChapter(currentChapter, resolvedSong, preferredDifficultyIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// Story SongBlock 的目标歌曲优先于常规章节缓存,但只影响本次页面打开。
|
||||
// 先比对对象引用,再按稳定 songName 兼容热更新或重建后的 SongItemData 实例。
|
||||
if (_initialSongSelectionOverride != null)
|
||||
{
|
||||
int overrideIndex = songItems.FindIndex(item => item != null &&
|
||||
item.GetComponent<SongSelectionTab>()?.connectedSong == _initialSongSelectionOverride);
|
||||
|
||||
if (overrideIndex < 0 && !string.IsNullOrEmpty(_initialSongSelectionOverride.songName))
|
||||
{
|
||||
overrideIndex = songItems.FindIndex(item => item != null &&
|
||||
item.GetComponent<SongSelectionTab>()?.connectedSong?.songName ==
|
||||
_initialSongSelectionOverride.songName);
|
||||
}
|
||||
|
||||
if (overrideIndex >= 0)
|
||||
{
|
||||
songIndex = overrideIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[SongListControllerUI] 请求自动选中的歌曲 '{_initialSongSelectionOverride.songName}' 不在当前章节列表中,已保留常规缓存选择。");
|
||||
}
|
||||
|
||||
_initialSongSelectionOverride = null;
|
||||
}
|
||||
|
||||
StartCoroutine(SnapToItem(songItems[songIndex], true));
|
||||
closestTab = songItems[songIndex];
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using DG.Tweening;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.Story;
|
||||
using Ichni.UI;
|
||||
using SLSUtilities.WwiseAssistance;
|
||||
using UnityEngine.Events;
|
||||
@@ -46,8 +47,13 @@ namespace Ichni.Menu
|
||||
backButton.onClick.AddListener(() =>
|
||||
{
|
||||
FadeOut();
|
||||
MenuManager.instance.chapterSelectionUIPage.FadeIn();
|
||||
SongSelectionManager.instance.StopPreviewSong();
|
||||
|
||||
// 仅当本次选曲由剧情 SongBlock 发起时返回剧情页;普通选曲保持原有的章节选择返回逻辑。
|
||||
if (StoryManager.instance != null && StoryManager.instance.TryReturnFromSongSelection())
|
||||
StoryManager.instance.storyUIPage.FadeIn();
|
||||
else
|
||||
MenuManager.instance.chapterSelectionUIPage.FadeIn();
|
||||
});
|
||||
|
||||
songInfoUI.SetUp();
|
||||
|
||||
Reference in New Issue
Block a user