UI换了很多,spine主视觉停用
This commit is contained in:
@@ -40,21 +40,21 @@ public sealed class FriendCardViewData
|
||||
|
||||
public class friendSystem : MonoBehaviour
|
||||
{
|
||||
private const string LabelAllFriends = "全部好友";
|
||||
private const string LabelOnlineFriends = "在线好友";
|
||||
private const string LabelStarredFriends = "星标好友";
|
||||
private const string LabelOfflineFriends = "离线好友";
|
||||
private const string LabelGameFriends = "游戏好友";
|
||||
private const string LabelSteamFriends = "Steam好友";
|
||||
private const string StatusOnline = "在线";
|
||||
private const string StatusOffline = "离线";
|
||||
private const string StatusPlaying = "游戏中";
|
||||
private const string StatusInRoom = "房间中";
|
||||
private const string NoticeFriendDetailsNotReady = "好友详情面板尚未接入";
|
||||
private const string NoticePrivateChatNotReady = "私聊面板尚未接入";
|
||||
private const string DefaultStatusLoading = "正在拉取好友信息...";
|
||||
private const string DefaultStatusEmpty = "你当前没有好友";
|
||||
private const string DefaultStatusServiceUnavailable = "无法访问服务";
|
||||
private static string LabelAllFriends => LocalizationService.Get("friends.filter.all", "全部好友");
|
||||
private static string LabelOnlineFriends => LocalizationService.Get("friends.filter.online", "在线好友");
|
||||
private static string LabelStarredFriends => LocalizationService.Get("friends.filter.starred", "星标好友");
|
||||
private static string LabelOfflineFriends => LocalizationService.Get("friends.filter.offline", "离线好友");
|
||||
private static string LabelGameFriends => LocalizationService.Get("friends.filter.game", "游戏好友");
|
||||
private static string LabelSteamFriends => LocalizationService.Get("friends.filter.steam", "Steam好友");
|
||||
private static string StatusOnline => LocalizationService.Get("friends.status.online", "在线");
|
||||
private static string StatusOffline => LocalizationService.Get("friends.status.offline", "离线");
|
||||
private static string StatusPlaying => LocalizationService.Get("friends.status.playing", "游戏中");
|
||||
private static string StatusInRoom => LocalizationService.Get("friends.status.in_room", "房间中");
|
||||
private static string NoticeFriendDetailsNotReady => LocalizationService.Get("friends.notice.details_not_ready", "好友详情面板尚未接入");
|
||||
private static string NoticePrivateChatNotReady => LocalizationService.Get("friends.notice.private_chat_not_ready", "私聊面板尚未接入");
|
||||
private static string DefaultStatusLoading => LocalizationService.Get("friends.default.loading", "正在拉取好友信息...");
|
||||
private static string DefaultStatusEmpty => LocalizationService.Get("friends.default.empty", "你当前没有好友");
|
||||
private static string DefaultStatusServiceUnavailable => LocalizationService.Get("friends.default.service_unavailable", "无法访问服务");
|
||||
|
||||
public GameObject friendCardPrefab;
|
||||
public Transform friendsDisplayContent;
|
||||
@@ -74,21 +74,22 @@ public class friendSystem : MonoBehaviour
|
||||
new Dictionary<string, FriendCardViewData>(StringComparer.Ordinal);
|
||||
private readonly Dictionary<string, GameObject> _spawnedCards =
|
||||
new Dictionary<string, GameObject>(StringComparer.Ordinal);
|
||||
private readonly List<(FriendFilterType filter, string label)> _filters =
|
||||
new List<(FriendFilterType filter, string label)>
|
||||
private readonly List<FriendFilterType> _filters =
|
||||
new List<FriendFilterType>
|
||||
{
|
||||
(FriendFilterType.All, LabelAllFriends),
|
||||
(FriendFilterType.Online, LabelOnlineFriends),
|
||||
(FriendFilterType.Starred, LabelStarredFriends),
|
||||
(FriendFilterType.Offline, LabelOfflineFriends),
|
||||
(FriendFilterType.GameFriends, LabelGameFriends),
|
||||
(FriendFilterType.SteamFriends, LabelSteamFriends)
|
||||
FriendFilterType.All,
|
||||
FriendFilterType.Online,
|
||||
FriendFilterType.Starred,
|
||||
FriendFilterType.Offline,
|
||||
FriendFilterType.GameFriends,
|
||||
FriendFilterType.SteamFriends
|
||||
};
|
||||
|
||||
private bool _dropdownInitialized;
|
||||
private bool _isRefreshing;
|
||||
private bool _lastRefreshFailed;
|
||||
private Coroutine _resyncCoroutine;
|
||||
private bool _languageSubscribed;
|
||||
private static List<string> _startupSteamFriendIds = new List<string>();
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||
@@ -99,9 +100,11 @@ public class friendSystem : MonoBehaviour
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
LocalizationService.EnsureInitialized();
|
||||
ClearDisplayedFriends();
|
||||
SetDefaultText(DefaultStatusLoading);
|
||||
InitializeDropdown();
|
||||
SubscribeLanguageChanged();
|
||||
|
||||
if (ArenaRoomService.Instance != null)
|
||||
{
|
||||
@@ -118,6 +121,7 @@ public class friendSystem : MonoBehaviour
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
UnsubscribeLanguageChanged();
|
||||
if (ArenaRoomService.Instance != null)
|
||||
{
|
||||
ArenaRoomService.Instance.OnFriendsListChanged -= HandleFriendsListChanged;
|
||||
@@ -244,13 +248,11 @@ public class friendSystem : MonoBehaviour
|
||||
}
|
||||
|
||||
friendsDisplayDropdown.onValueChanged.RemoveListener(HandleFilterChanged);
|
||||
if (!_dropdownInitialized)
|
||||
{
|
||||
friendsDisplayDropdown.ClearOptions();
|
||||
friendsDisplayDropdown.AddOptions(_filters.Select(item => item.label).ToList());
|
||||
friendsDisplayDropdown.value = 0;
|
||||
_dropdownInitialized = true;
|
||||
}
|
||||
int selectedValue = Mathf.Clamp(friendsDisplayDropdown.value, 0, Mathf.Max(0, _filters.Count - 1));
|
||||
friendsDisplayDropdown.ClearOptions();
|
||||
friendsDisplayDropdown.AddOptions(_filters.Select(GetFilterLabel).ToList());
|
||||
friendsDisplayDropdown.value = selectedValue;
|
||||
_dropdownInitialized = true;
|
||||
|
||||
friendsDisplayDropdown.onValueChanged.AddListener(HandleFilterChanged);
|
||||
friendsDisplayDropdown.RefreshShownValue();
|
||||
@@ -523,7 +525,7 @@ public class friendSystem : MonoBehaviour
|
||||
return FriendFilterType.All;
|
||||
}
|
||||
|
||||
return _filters[friendsDisplayDropdown.value].filter;
|
||||
return _filters[friendsDisplayDropdown.value];
|
||||
}
|
||||
|
||||
private void HandleStarChanged(string steamId, bool isOn)
|
||||
@@ -569,6 +571,58 @@ public class friendSystem : MonoBehaviour
|
||||
globalChatSystem.OpenPrivateConversation(steamId);
|
||||
}
|
||||
|
||||
private void SubscribeLanguageChanged()
|
||||
{
|
||||
if (_languageSubscribed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LocalizationService.LanguageChanged += HandleLanguageChanged;
|
||||
_languageSubscribed = true;
|
||||
}
|
||||
|
||||
private void UnsubscribeLanguageChanged()
|
||||
{
|
||||
if (!_languageSubscribed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LocalizationService.LanguageChanged -= HandleLanguageChanged;
|
||||
_languageSubscribed = false;
|
||||
}
|
||||
|
||||
private void HandleLanguageChanged(string _)
|
||||
{
|
||||
if (!isActiveAndEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
InitializeDropdown();
|
||||
Render();
|
||||
}
|
||||
|
||||
private static string GetFilterLabel(FriendFilterType filter)
|
||||
{
|
||||
switch (filter)
|
||||
{
|
||||
case FriendFilterType.Online:
|
||||
return LabelOnlineFriends;
|
||||
case FriendFilterType.Starred:
|
||||
return LabelStarredFriends;
|
||||
case FriendFilterType.Offline:
|
||||
return LabelOfflineFriends;
|
||||
case FriendFilterType.GameFriends:
|
||||
return LabelGameFriends;
|
||||
case FriendFilterType.SteamFriends:
|
||||
return LabelSteamFriends;
|
||||
default:
|
||||
return LabelAllFriends;
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetSortBucket(FriendCardViewData friend)
|
||||
{
|
||||
if (friend == null)
|
||||
|
||||
Reference in New Issue
Block a user