menu
This commit is contained in:
@@ -52,8 +52,14 @@ namespace Ichni.Menu.UI
|
||||
{
|
||||
MenuManager.instance.songSelectionUIPage.selectedDifficulty = difficultyData;
|
||||
MenuManager.instance.songSelectionUIPage.songInfoUI.SetCharter(difficultyData.charterName);
|
||||
|
||||
if(container.selectedButton == this) return;
|
||||
MenuManager.instance.songSelectionUIPage.songInfoUI.SetBeatmapInfo(
|
||||
MenuManager.instance.songSelectionUIPage.selectedSave.beatmapSaves[difficultyData.difficultyIndex]);
|
||||
|
||||
if (container.selectedButton == this)
|
||||
{
|
||||
background.DOColor(difficultyData.color, 0.4f).SetEase(Ease.OutQuart).Play();
|
||||
return;
|
||||
}
|
||||
|
||||
MenuManager.instance.songSelectionUIPage.difficultySelectionContainer.selectedButton?.Deselect();
|
||||
MenuManager.instance.songSelectionUIPage.difficultySelectionContainer.selectedButton = this;
|
||||
|
||||
@@ -19,10 +19,16 @@ namespace Ichni.Menu.UI
|
||||
|
||||
private void EnterGame()
|
||||
{
|
||||
if (MenuManager.instance.songSelectionUIPage.songListController.selectedTab.isLocked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
InformationTransistor.instance.SetInformation(
|
||||
ChapterSelectionManager.instance.currentChapter,
|
||||
MenuManager.instance.songSelectionUIPage.selectedSong,
|
||||
MenuManager.instance.songSelectionUIPage.selectedDifficulty);
|
||||
MenuAudioManager.instance.audioContainer.PlaySoundFX("EnterToGame");
|
||||
MenuAudioManager.instance.audioContainer.StopEvent("PlayPreview");
|
||||
|
||||
DOTween.KillAll();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -13,6 +14,8 @@ namespace Ichni.Menu.UI
|
||||
public TMP_Text illustratorText;
|
||||
|
||||
public TMP_Text accuracyText;
|
||||
public Image fullComboMark;
|
||||
public Image allPerfectMark;
|
||||
|
||||
public void SetIllustration(Sprite cover, string illustratorName)
|
||||
{
|
||||
@@ -24,5 +27,17 @@ namespace Ichni.Menu.UI
|
||||
{
|
||||
charterNameText.text = charterName == string.Empty ? "Unknown Charter" : charterName;
|
||||
}
|
||||
|
||||
public void SetBeatmapInfo(BeatmapSave beatmapSave)
|
||||
{
|
||||
accuracyText.text = $"{beatmapSave.accuracy * 100:F2}%";
|
||||
|
||||
if (!beatmapSave.isAllPerfect)
|
||||
{
|
||||
fullComboMark.gameObject.SetActive(beatmapSave.isFullCombo);
|
||||
}
|
||||
|
||||
allPerfectMark.gameObject.SetActive(beatmapSave.isAllPerfect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
@@ -44,6 +45,8 @@ namespace Ichni.Menu.UI
|
||||
public float bottomBound = 0f;
|
||||
private Vector2 targetPosition; // 【新增】内容的目标位置
|
||||
private float targetX = 1500f;
|
||||
public bool isDuringSnap = false;
|
||||
public RectTransform closestTab;
|
||||
|
||||
void Start()
|
||||
{
|
||||
@@ -52,6 +55,27 @@ namespace Ichni.Menu.UI
|
||||
targetX = -1500f;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
RectTransform closestItem = closestTab;
|
||||
float cloesestY = Mathf.Infinity;
|
||||
foreach (RectTransform item in songItems)
|
||||
{
|
||||
float distance = Mathf.Abs(item.position.y - centerPoint.position.y);
|
||||
if (distance < cloesestY)
|
||||
{
|
||||
cloesestY = distance;
|
||||
closestItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
if (closestItem != null && closestTab != closestItem)
|
||||
{
|
||||
closestTab = closestItem;
|
||||
MenuAudioManager.instance.audioContainer.PlaySoundFX("SelectTab");
|
||||
}
|
||||
}
|
||||
|
||||
// 使用LateUpdate来处理所有位置更新,防止抖动
|
||||
void LateUpdate()
|
||||
{
|
||||
@@ -103,6 +127,8 @@ namespace Ichni.Menu.UI
|
||||
{
|
||||
StartCoroutine(SnapToItem(songItems[0], true));
|
||||
}
|
||||
|
||||
closestTab = songItems[0];
|
||||
}
|
||||
|
||||
public void GenerateSongTabs()
|
||||
@@ -189,12 +215,18 @@ namespace Ichni.Menu.UI
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator SnapCoroutine;
|
||||
|
||||
public IEnumerator SnapToTab(SongSelectionTab tab)
|
||||
{
|
||||
selectedTab?.SetSelection(false);
|
||||
selectedTab = null; // 清除当前选中的Tab
|
||||
|
||||
if(isDuringSnap && SnapCoroutine != null) StopCoroutine(SnapCoroutine);
|
||||
|
||||
yield return StartCoroutine(SnapToItem(tab.GetComponent<RectTransform>(), false));
|
||||
SnapCoroutine = SnapToItem(tab.GetComponent<RectTransform>(), false);
|
||||
|
||||
yield return StartCoroutine(SnapCoroutine);
|
||||
}
|
||||
|
||||
private IEnumerator SnapToItem(RectTransform targetItem, bool immediate)
|
||||
@@ -211,7 +243,7 @@ namespace Ichni.Menu.UI
|
||||
|
||||
SongItemData connectedSong = selectedTab.connectedSong;
|
||||
MenuManager.instance.songSelectionUIPage.selectedSong = connectedSong;
|
||||
|
||||
MenuManager.instance.songSelectionUIPage.selectedSave = GameSaveManager.instance.SongSaveModule.GetSongStatusSave(connectedSong.songName);
|
||||
|
||||
Vector3 closestItemLocalPos = viewport.InverseTransformPoint(targetItem.position);
|
||||
Vector3 centerPointLocalPos = viewport.InverseTransformPoint(centerPoint.position);
|
||||
@@ -229,6 +261,7 @@ namespace Ichni.Menu.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
isDuringSnap = true;
|
||||
// 动画模式:只更新Target,让LateUpdate中的Lerp来完成动画
|
||||
targetPosition = finalTargetPosition;
|
||||
|
||||
@@ -243,11 +276,13 @@ namespace Ichni.Menu.UI
|
||||
content.anchoredPosition = targetPosition;
|
||||
}
|
||||
|
||||
Debug.Log($"已对齐到: {targetItem.name}");
|
||||
selectedTab.SetPreview();
|
||||
Debug.Log($"已对齐到: {targetItem.GetComponent<SongSelectionTab>().songNameText.text}");
|
||||
|
||||
|
||||
SongSelectionManager.instance.SetPreview(connectedSong, selectedTab.isLocked);
|
||||
MenuManager.instance.songSelectionUIPage.difficultySelectionContainer.SetUp(connectedSong.difficultyDataList);
|
||||
MenuManager.instance.songSelectionUIPage.songInfoUI.SetIllustration(connectedSong.illustration, connectedSong.illustratorName);
|
||||
isDuringSnap = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ namespace Ichni.Menu.UI
|
||||
public partial class SongSelectionTab : MonoBehaviour
|
||||
{
|
||||
private SongListControllerUI songListController => MenuManager.instance.songSelectionUIPage.songListController;
|
||||
|
||||
public bool isLocked;
|
||||
|
||||
public SongItemData connectedSong;
|
||||
public TMP_Text songNameText;
|
||||
@@ -25,11 +27,15 @@ namespace Ichni.Menu.UI
|
||||
public RectTransform background;
|
||||
public Image selectedImage;
|
||||
public Image unselectedImage;
|
||||
public Image lockMark;
|
||||
|
||||
public void SetUpTab(SongItemData song)
|
||||
{
|
||||
connectedSong = song;
|
||||
songNameText.text = song.songName;
|
||||
|
||||
isLocked = !GameSaveManager.instance.SongSaveModule.CheckUnlock(song.unlockKey);
|
||||
lockMark.gameObject.SetActive(isLocked);
|
||||
|
||||
quickSwitchButton.onClick.AddListener(() =>
|
||||
{
|
||||
@@ -83,12 +89,5 @@ namespace Ichni.Menu.UI
|
||||
.Play();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPreview()
|
||||
{
|
||||
MenuAudioManager.instance.audioContainer.StopEvent("PlayPreview");
|
||||
MenuAudioManager.instance.audioContainer.SetSwitch(connectedSong.songSwitch);
|
||||
MenuAudioManager.instance.audioContainer.PostEvent("PlayPreview");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using Ichni.Menu;
|
||||
using Ichni.Menu.UI;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.UI;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
@@ -24,15 +25,11 @@ namespace Ichni.Menu.UI
|
||||
public DifficultySelectionContainer difficultySelectionContainer;
|
||||
public int currentSelectedDifficultyIndex;
|
||||
|
||||
public AK.Wwise.Switch defaultSwitch;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
MenuAudioManager.instance.audioContainer.SetSwitch(defaultSwitch);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
currentSelectedDifficultyIndex = 0;
|
||||
|
||||
Sequence framesSeq = DOTween.Sequence();
|
||||
@@ -49,5 +46,6 @@ namespace Ichni.Menu.UI
|
||||
{
|
||||
public SongItemData selectedSong;
|
||||
public DifficultyData selectedDifficulty;
|
||||
public SongStatusSave selectedSave;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user