ui基本完毕,修了一大把的bug
This commit is contained in:
@@ -7,7 +7,7 @@ public class loadDlcListPrefab : MonoBehaviour
|
||||
{
|
||||
private static readonly bool VerboseLogs = false;
|
||||
private const string RuntimeInstalledColumnName = "Installed DLC";
|
||||
private const int DefaultFallbackDlcId = 66001;
|
||||
private const int DefaultFallbackDlcId = 66002;
|
||||
private const string DlcSelectedIndexPrefsKey = "dlc_selected_index";
|
||||
[System.Serializable]
|
||||
public class Column
|
||||
@@ -145,7 +145,19 @@ public class loadDlcListPrefab : MonoBehaviour
|
||||
}
|
||||
|
||||
SongSelectUI.ForceFirstSongOnNextRestore = forceFirstSong;
|
||||
targetButton.OnButtonClicked_ShowSongs();
|
||||
// Restore is read-only: applying the selection here (including the
|
||||
// fallback DLC) must not overwrite the user's genuine last choice.
|
||||
// Select() runs synchronously inside OnButtonClicked_ShowSongs, so the
|
||||
// suppression window only needs to span this call.
|
||||
dlcButton.SuppressSelectionPersist = true;
|
||||
try
|
||||
{
|
||||
targetButton.OnButtonClicked_ShowSongs();
|
||||
}
|
||||
finally
|
||||
{
|
||||
dlcButton.SuppressSelectionPersist = false;
|
||||
}
|
||||
|
||||
if (VerboseLogs)
|
||||
{
|
||||
@@ -164,6 +176,20 @@ public class loadDlcListPrefab : MonoBehaviour
|
||||
return null;
|
||||
}
|
||||
|
||||
// Prefer restoring by the saved DLC id, which is stable across
|
||||
// session-to-session ordering changes (e.g. runtime-installed DLCs).
|
||||
int savedDlcId = PlayerPrefs.GetInt(dlcButton.SelectedDlcIdKey, 0);
|
||||
if (savedDlcId > 0)
|
||||
{
|
||||
dlcButton savedById = FindButtonByDlcId(allButtons, savedDlcId);
|
||||
if (savedById != null && HasSavedSongSelection(savedById))
|
||||
{
|
||||
forceFirstSong = false;
|
||||
return savedById;
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to the saved positional index for legacy saves.
|
||||
int savedIndex = PlayerPrefs.GetInt(DlcSelectedIndexPrefsKey, 0);
|
||||
if (savedIndex >= 0 && savedIndex < allButtons.Length)
|
||||
{
|
||||
@@ -221,14 +247,12 @@ public class loadDlcListPrefab : MonoBehaviour
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only the songID key proves a genuine user click: SongButton.OnSongButtonClick
|
||||
// always writes it alongside the index. The index key alone is unreliable because
|
||||
// RestoreSelectedSongForCurrentDlc auto-writes it to 0 on mere display, so relying
|
||||
// on it would treat any browsed-but-not-selected DLC as "user selected".
|
||||
string songIdKey = SongButton.BuildSongSelectedIdPrefsKey(dlcKey);
|
||||
if (PlayerPrefs.HasKey(songIdKey) && PlayerPrefs.GetInt(songIdKey, 0) > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
string songIndexKey = SongButton.BuildSongSelectedIndexPrefsKey(dlcKey);
|
||||
return PlayerPrefs.HasKey(songIndexKey);
|
||||
return PlayerPrefs.HasKey(songIdKey) && PlayerPrefs.GetInt(songIdKey, 0) > 0;
|
||||
}
|
||||
|
||||
private string BuildDlcKey(dlcButton button)
|
||||
@@ -244,22 +268,8 @@ public class loadDlcListPrefab : MonoBehaviour
|
||||
|
||||
private int GetDlcId(dlcButton button)
|
||||
{
|
||||
if (button == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (button.dlcDataSO != null && button.dlcDataSO.dlcID > 0)
|
||||
{
|
||||
return button.dlcDataSO.dlcID;
|
||||
}
|
||||
|
||||
if (button.dlcID != null && int.TryParse(button.dlcID.text, out int parsedId))
|
||||
{
|
||||
return parsedId;
|
||||
}
|
||||
|
||||
return 0;
|
||||
// Delegate to the button's own resolver to keep id resolution in one place.
|
||||
return button != null ? button.ResolveOwnDlcId() : 0;
|
||||
}
|
||||
|
||||
private List<Column> BuildDisplayColumns()
|
||||
|
||||
Reference in New Issue
Block a user