主界面添加,许多bug修复。祝贺黑盒1如期开始

This commit is contained in:
FloatGaming
2026-03-02 04:34:13 +08:00
parent e11cc1da7a
commit 3c1d263ef1
308 changed files with 59216 additions and 32756 deletions
@@ -251,6 +251,7 @@ GameObject:
- component: {fileID: 4974503315116154840}
- component: {fileID: 3426324857204153236}
- component: {fileID: 7779480480503833965}
- component: {fileID: 7759717739552689643}
m_Layer: 5
m_Name: Button
m_TagString: Untagged
@@ -416,6 +417,18 @@ MonoBehaviour:
minAlpha: 0
maxAlpha: 0.25
blinkDuration: 2
--- !u!114 &7759717739552689643
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1198053886828452625}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76ce63b908338a84c8a3aa071b90c46b, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1369053455477687453
GameObject:
m_ObjectHideFlags: 0
@@ -246,6 +246,7 @@ GameObject:
- component: {fileID: 5644906588518313876}
- component: {fileID: 2110413507685129963}
- component: {fileID: 3083670225148312207}
- component: {fileID: 3050609759665738948}
m_Layer: 5
m_Name: dlcButton
m_TagString: Untagged
@@ -384,6 +385,18 @@ MonoBehaviour:
- {fileID: 0}
editorSearchFolder: Assets/Resources/dlc_dlcIndex
runtimeResourcesFolder: Resources/dlc_dlcIndex
--- !u!114 &3050609759665738948
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3483744570565719852}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76ce63b908338a84c8a3aa071b90c46b, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &6759998237426852132
GameObject:
m_ObjectHideFlags: 0
+202 -20
View File
@@ -9,6 +9,18 @@ using Bansonic;
public class selected_songInfo : MonoBehaviour
{
[Header("Music Controls")]
public Button playpausebutton;
public Button stopbutton;
public Text currentTime;
public Text maxtime;
public Slider playbarSlider;
public Sprite playSprite;
public Sprite pauseSprite;
public AudioSource preListenAS;
private bool isDraggingSlider = false;
public Image t_songCoverImage;
public Image btm_songCoverImage;
[Header("Inspector")]
@@ -233,6 +245,8 @@ public class selected_songInfo : MonoBehaviour
ApplyDoNotShowAgainVisual();
ResolveDifficultyIdDisplayTexts();
InitializeMusicControls();
// register listeners here to ensure binding even if Start wasn't called yet
if (enterDetailPageButton != null)
{
@@ -262,6 +276,9 @@ public class selected_songInfo : MonoBehaviour
void OnDisable()
{
LogVerbose("selected_songInfo.OnDisable called");
UnbindMusicControls();
if (enterDetailPageButton != null)
{
enterDetailPageButton.onClick.RemoveListener(OnEnterDetailPageClicked);
@@ -348,6 +365,178 @@ public class selected_songInfo : MonoBehaviour
LogVerbose($"selected_songInfo.Start: SongDataHolder.SelectedSongData is {(SongDataHolder.SelectedSongData == null ? "NULL" : SongDataHolder.SelectedSongData.songName)}");
}
void Update()
{
UpdateMusicPlaybackProgress();
if (Input.GetKeyDown(KeyCode.F1))
{
Debug.LogWarning("selected_songInfo.DebugTrigger: F1 pressed - dumping diagnostic info");
Debug.LogWarning($"GameObject activeInHierarchy={gameObject.activeInHierarchy}, enabled={enabled}");
Debug.LogWarning($"quickEnter_gamePlay assigned={(quickEnter_gamePlay == null ? "NULL" : "ASSIGNED")}");
Debug.LogWarning($"enterDetailPageButton assigned={(enterDetailPageButton == null ? "NULL" : "ASSIGNED")}");
Debug.LogWarning($"blackMaskImage assigned={(blackMaskImage == null ? "NULL" : "ASSIGNED")}");
Debug.LogWarning($"SongDataHolder.SelectedSongData={(SongDataHolder.SelectedSongData == null ? "NULL" : SongDataHolder.SelectedSongData.songName)}");
var allButtons = UnityEngine.Object.FindObjectsByType<SongButton>(FindObjectsInactive.Exclude, FindObjectsSortMode.InstanceID);
Debug.LogWarning($"Found {allButtons.Length} SongButton instances in scene");
for (int i = 0; i < allButtons.Length; i++)
{
var sb = allButtons[i];
if (sb == null) continue;
Debug.LogWarning($" [{i}] name={sb.name} active={sb.gameObject.activeInHierarchy}");
}
}
}
private void InitializeMusicControls()
{
if (playpausebutton != null)
{
playpausebutton.onClick.RemoveListener(TogglePlayPause);
playpausebutton.onClick.AddListener(TogglePlayPause);
}
if (stopbutton != null)
{
stopbutton.onClick.RemoveListener(StopPlayback);
stopbutton.onClick.AddListener(StopPlayback);
}
if (playbarSlider != null)
{
playbarSlider.onValueChanged.RemoveListener(OnSliderValueChanged);
playbarSlider.onValueChanged.AddListener(OnSliderValueChanged);
}
}
private void UnbindMusicControls()
{
if (playpausebutton != null)
{
playpausebutton.onClick.RemoveListener(TogglePlayPause);
}
if (stopbutton != null)
{
stopbutton.onClick.RemoveListener(StopPlayback);
}
if (playbarSlider != null)
{
playbarSlider.onValueChanged.RemoveListener(OnSliderValueChanged);
}
}
private void TogglePlayPause()
{
if (preListenAS == null) return;
if (preListenAS.isPlaying)
{
preListenAS.Pause();
UpdatePlayPauseButtonSprite(false);
// 试听暂停,恢复全局音乐
FadeGlobalMusic(true);
}
else
{
if (preListenAS.clip != null)
{
preListenAS.Play();
UpdatePlayPauseButtonSprite(true);
// 试听开始,淡出全局音乐
FadeGlobalMusic(false);
}
else
{
// 鲁棒性处理:显示错误提示
gNotice.error.display("暂无预览文件");
}
}
}
private void StopPlayback()
{
if (preListenAS == null) return;
preListenAS.Stop();
preListenAS.time = 0;
UpdatePlayPauseButtonSprite(false);
UpdateMusicUI(0, preListenAS.clip != null ? preListenAS.clip.length : 0);
// 试听停止,恢复全局音乐
FadeGlobalMusic(true);
}
private void FadeGlobalMusic(bool fadeIn)
{
if (Music_Mgr.Singleton != null && Music_Mgr.Singleton.AudioSource != null)
{
float targetVolume = fadeIn ? 1f : 0f;
Music_Mgr.Singleton.AudioSource.DOFade(targetVolume, 0.5f).SetUpdate(true);
}
}
private void OnSliderValueChanged(float value)
{
if (preListenAS == null || preListenAS.clip == null) return;
// 只有当用户手动拖动时才改变播放时间
// 这里可以通过 Input.GetMouseButton(0) 简单判断是否在拖拽
if (Input.GetMouseButton(0))
{
float targetTime = value * preListenAS.clip.length;
preListenAS.time = targetTime;
}
}
private void UpdateMusicPlaybackProgress()
{
if (preListenAS == null || preListenAS.clip == null || !preListenAS.isPlaying) return;
// 如果用户没在拖动,则自动更新进度条
if (!Input.GetMouseButton(0))
{
UpdateMusicUI(preListenAS.time, preListenAS.clip.length);
}
}
private void UpdateMusicUI(float currentTimeVal, float maxTimeVal)
{
if (playbarSlider != null && maxTimeVal > 0)
{
playbarSlider.value = currentTimeVal / maxTimeVal;
}
if (currentTime != null)
{
currentTime.text = FormatTime(currentTimeVal);
}
if (maxtime != null)
{
maxtime.text = FormatTime(maxTimeVal);
}
}
private void UpdatePlayPauseButtonSprite(bool isPlaying)
{
if (playpausebutton == null) return;
Image btnImg = playpausebutton.GetComponent<Image>();
if (btnImg == null) return;
if (isPlaying)
{
if (pauseSprite != null) btnImg.sprite = pauseSprite;
}
else
{
if (playSprite != null) btnImg.sprite = playSprite;
}
}
private string FormatTime(float seconds)
{
int min = Mathf.FloorToInt(seconds / 60);
int sec = Mathf.FloorToInt(seconds % 60);
return string.Format("{0:00}:{1:00}", min, sec);
}
public void UpdateSelectedSongDisplay()
{
if (SongDataHolder.SelectedSongData != null)
@@ -376,6 +565,16 @@ public class selected_songInfo : MonoBehaviour
songNameText.text = song.songName;
}
// 更新预览音频
if (preListenAS != null)
{
preListenAS.Stop();
preListenAS.clip = song.audio_previewAudio;
preListenAS.time = 0;
UpdatePlayPauseButtonSprite(false);
UpdateMusicUI(0, preListenAS.clip != null ? preListenAS.clip.length : 0);
}
// set difficulty button backgrounds according to currently selected difficulty in the song SO
SetDifficultyButtonBackground(song.thisLevel_selectedDifficultyID);
@@ -923,6 +1122,7 @@ public class selected_songInfo : MonoBehaviour
private void OnQuickEnterClicked()
{
/* 暂时注释编队不足时的弹出逻辑
int teamCount = GetTeamMemberCount();
bool needTeamWarning = teamCount < 5;
@@ -935,6 +1135,7 @@ public class selected_songInfo : MonoBehaviour
return;
}
}
*/
BeginQuickEnterInternal();
}
@@ -1420,26 +1621,7 @@ public class selected_songInfo : MonoBehaviour
}
// Debug helper: press F1 at runtime to print diagnostic state to Console (warnings)
void Update()
{
if (Input.GetKeyDown(KeyCode.F1))
{
Debug.LogWarning("selected_songInfo.DebugTrigger: F1 pressed - dumping diagnostic info");
Debug.LogWarning($"GameObject activeInHierarchy={gameObject.activeInHierarchy}, enabled={enabled}");
Debug.LogWarning($"quickEnter_gamePlay assigned={(quickEnter_gamePlay==null?"NULL":"ASSIGNED")}");
Debug.LogWarning($"enterDetailPageButton assigned={(enterDetailPageButton==null?"NULL":"ASSIGNED")}");
Debug.LogWarning($"blackMaskImage assigned={(blackMaskImage==null?"NULL":"ASSIGNED")}");
Debug.LogWarning($"SongDataHolder.SelectedSongData={(SongDataHolder.SelectedSongData==null?"NULL":SongDataHolder.SelectedSongData.songName)}");
var allButtons = UnityEngine.Object.FindObjectsByType<SongButton>(FindObjectsInactive.Exclude, FindObjectsSortMode.InstanceID);
Debug.LogWarning($"Found {allButtons.Length} SongButton instances in scene");
for (int i = 0; i < allButtons.Length; i++)
{
var sb = allButtons[i];
if (sb == null) continue;
Debug.LogWarning($" [{i}] name={sb.name} active={sb.gameObject.activeInHierarchy}");
}
}
}
// Removed duplicate Update() here - consolidated into L365
// Helper to centralize PauseManager pause request so selected_songInfo reuses PauseManager implementation
private bool pauseRequested = false;