UI HUGE UPDATE
This commit is contained in:
@@ -64,6 +64,7 @@ public class friendSystem : MonoBehaviour
|
||||
|
||||
[Header("text")]
|
||||
public Text defaultText;
|
||||
public Text onlineFriendsCountText;
|
||||
|
||||
[Header("sync")]
|
||||
[SerializeField] private float steamFriendResyncIntervalSeconds = 8f;
|
||||
@@ -88,8 +89,10 @@ public class friendSystem : MonoBehaviour
|
||||
private bool _dropdownInitialized;
|
||||
private bool _isRefreshing;
|
||||
private bool _lastRefreshFailed;
|
||||
private bool _hasResolvedFriendCounts;
|
||||
private Coroutine _resyncCoroutine;
|
||||
private bool _languageSubscribed;
|
||||
private bool _chatStateSubscribed;
|
||||
private static List<string> _startupSteamFriendIds = new List<string>();
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||
@@ -102,9 +105,12 @@ public class friendSystem : MonoBehaviour
|
||||
{
|
||||
LocalizationService.EnsureInitialized();
|
||||
ClearDisplayedFriends();
|
||||
_hasResolvedFriendCounts = false;
|
||||
SetDefaultText(DefaultStatusLoading);
|
||||
UpdateOnlineFriendsCountText();
|
||||
InitializeDropdown();
|
||||
SubscribeLanguageChanged();
|
||||
SubscribeChatStateChanged();
|
||||
|
||||
if (ArenaRoomService.Instance != null)
|
||||
{
|
||||
@@ -122,6 +128,7 @@ public class friendSystem : MonoBehaviour
|
||||
private void OnDisable()
|
||||
{
|
||||
UnsubscribeLanguageChanged();
|
||||
UnsubscribeChatStateChanged();
|
||||
if (ArenaRoomService.Instance != null)
|
||||
{
|
||||
ArenaRoomService.Instance.OnFriendsListChanged -= HandleFriendsListChanged;
|
||||
@@ -199,6 +206,7 @@ public class friendSystem : MonoBehaviour
|
||||
&& friendsTask.Result != null
|
||||
&& friendsTask.Result.success)
|
||||
{
|
||||
_hasResolvedFriendCounts = true;
|
||||
ReplaceGameFriends(friendsTask.Result.friends);
|
||||
}
|
||||
else
|
||||
@@ -266,6 +274,7 @@ public class friendSystem : MonoBehaviour
|
||||
private void HandleFriendsListChanged(IReadOnlyList<SocialFriendEntry> friends)
|
||||
{
|
||||
_lastRefreshFailed = false;
|
||||
_hasResolvedFriendCounts = true;
|
||||
RefreshSteamFriendCache();
|
||||
ReplaceGameFriends(friends);
|
||||
Render();
|
||||
@@ -428,6 +437,7 @@ public class friendSystem : MonoBehaviour
|
||||
if (friendsDisplayContent == null || friendCardPrefab == null)
|
||||
{
|
||||
SetDefaultText(DefaultStatusServiceUnavailable);
|
||||
UpdateOnlineFriendsCountText();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -467,6 +477,7 @@ public class friendSystem : MonoBehaviour
|
||||
}
|
||||
|
||||
UpdateDefaultTextState(target.Count);
|
||||
UpdateOnlineFriendsCountText();
|
||||
}
|
||||
|
||||
private void UpdateDefaultTextState(int visibleCount)
|
||||
@@ -496,6 +507,32 @@ public class friendSystem : MonoBehaviour
|
||||
defaultText.text = message ?? string.Empty;
|
||||
}
|
||||
|
||||
private void UpdateOnlineFriendsCountText()
|
||||
{
|
||||
if (onlineFriendsCountText == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_hasResolvedFriendCounts)
|
||||
{
|
||||
onlineFriendsCountText.text = "-/-";
|
||||
return;
|
||||
}
|
||||
|
||||
int totalCount = _mergedFriends.Count;
|
||||
int onlineCount = 0;
|
||||
foreach (FriendCardViewData friend in _mergedFriends.Values)
|
||||
{
|
||||
if (friend != null && friend.IsOnline)
|
||||
{
|
||||
onlineCount++;
|
||||
}
|
||||
}
|
||||
|
||||
onlineFriendsCountText.text = $"{onlineCount}/{totalCount}";
|
||||
}
|
||||
|
||||
private IEnumerable<FriendCardViewData> ApplyFilter(IEnumerable<FriendCardViewData> source)
|
||||
{
|
||||
FriendFilterType filter = GetSelectedFilter();
|
||||
@@ -571,6 +608,38 @@ public class friendSystem : MonoBehaviour
|
||||
globalChatSystem.OpenPrivateConversation(steamId);
|
||||
}
|
||||
|
||||
private void SubscribeChatStateChanged()
|
||||
{
|
||||
if (_chatStateSubscribed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
globalChatSystem.ActivePrivateConversationChanged += HandleActivePrivateConversationChanged;
|
||||
_chatStateSubscribed = true;
|
||||
}
|
||||
|
||||
private void UnsubscribeChatStateChanged()
|
||||
{
|
||||
if (!_chatStateSubscribed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
globalChatSystem.ActivePrivateConversationChanged -= HandleActivePrivateConversationChanged;
|
||||
_chatStateSubscribed = false;
|
||||
}
|
||||
|
||||
private void HandleActivePrivateConversationChanged(string _)
|
||||
{
|
||||
if (!isActiveAndEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Render();
|
||||
}
|
||||
|
||||
private void SubscribeLanguageChanged()
|
||||
{
|
||||
if (_languageSubscribed)
|
||||
|
||||
Reference in New Issue
Block a user