fix: 修复章节加载顺序错乱问题

This commit is contained in:
2026-04-28 17:33:16 +08:00
parent f224e8a2ac
commit 44f001361e
31 changed files with 23 additions and 77 deletions
+3 -31
View File
@@ -24,11 +24,7 @@ namespace AibisDream
cacheChapter = ParseChapterTitle(saveFilePath);
}
// 优先从 GameManager 获取全量章节并按 displayOrder 排序
var allChapters = GameManager.Instance?.GetAllSceneSos();
var sourceList = allChapters != null
? allChapters.OrderBy(so => so.displayOrder).ToList()
: ChapterData.chapterList;
var sourceList = GameManager.Instance.GetAllSceneSos();
// 拼接章节列表
var chapterList = sourceList
@@ -37,7 +33,7 @@ namespace AibisDream
{
chapterSo = chapterSo,
title = chapterSo.title,
chapter = chapterSo.chapter,
chapter = chapterSo.chapter,
desc = chapterSo.description,
pic = chapterSo.coverPic,
hasSaveFile = cacheChapter == chapterSo.name
@@ -89,43 +85,19 @@ namespace AibisDream
[GlobalData]
public class ChapterData
{
public readonly TalkSceneSO firstChapter;
public List<TalkSceneSO> chapterList;
public List<string> unlockedChapterList;
public ChapterData()
{
Directory.CreateDirectory(ConstRef.SaveFilePath);
firstChapter = GameManager.Instance.firstTalkSo;
LoadChapterList();
LoadUnlockChapters();
}
private void LoadChapterList()
{
var all = GameManager.Instance?.GetAllSceneSos();
if (all != null)
{
chapterList = all.OrderBy(so => so.displayOrder).ToList();
}
else
{
chapterList = new List<TalkSceneSO>();
var curChapter = firstChapter;
do
{
chapterList.Add(curChapter);
curChapter = curChapter.GetNextScene();
} while (curChapter != null && !chapterList.Contains(curChapter));
}
}
private void LoadUnlockChapters()
{
unlockedChapterList = File.Exists(ConstRef.ChapterProgressPath)
? JsonUtil.ReadBeanArray<string>(ConstRef.ChapterProgressPath).ToList()
: new List<string> { firstChapter.name };
: new List<string> { GameManager.Instance.firstTalkSo.name };
}
public void SaveUnloadChapters()