UI HUGE UPDATE
This commit is contained in:
@@ -27,6 +27,10 @@ public class friendCardPrefab : MonoBehaviour
|
||||
[Header("offline heibai")]
|
||||
[SerializeField] private Material offline_material;
|
||||
|
||||
[Header("currently chatting")]
|
||||
[SerializeField] private Sprite chattingSprite;
|
||||
[SerializeField] private Sprite normalSprite;
|
||||
|
||||
private Material _profileBorderMaterial;
|
||||
private Material _friendProfileMaterial;
|
||||
private Coroutine _avatarLoadRoutine;
|
||||
@@ -39,11 +43,20 @@ public class friendCardPrefab : MonoBehaviour
|
||||
private Action<string> _openDetails;
|
||||
private Action<string> _openPrivateConversation;
|
||||
private bool _bindingToggle;
|
||||
private Sprite _defaultProfileBorderSprite;
|
||||
private bool _subscribedToChatState;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_profileBorderMaterial = profileBorder != null ? profileBorder.material : null;
|
||||
_friendProfileMaterial = friendProfile != null ? friendProfile.material : null;
|
||||
_defaultProfileBorderSprite = profileBorder != null ? profileBorder.sprite : null;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
SubscribeChatState();
|
||||
RefreshChattingVisual();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
@@ -55,6 +68,12 @@ public class friendCardPrefab : MonoBehaviour
|
||||
}
|
||||
|
||||
ReleaseRuntimeAvatarResources();
|
||||
UnsubscribeChatState();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
UnsubscribeChatState();
|
||||
}
|
||||
|
||||
public void Bind(FriendCardViewData data, Action<string, bool> onStarChanged, Action<string> onOpenDetails, Action<string> onOpenPrivateConversation)
|
||||
@@ -102,6 +121,8 @@ public class friendCardPrefab : MonoBehaviour
|
||||
StopCoroutine(_avatarLoadRoutine);
|
||||
}
|
||||
_avatarLoadRoutine = StartCoroutine(LoadAvatarRoutine(data));
|
||||
|
||||
RefreshChattingVisual();
|
||||
}
|
||||
|
||||
private void HandleStarToggleChanged(bool isOn)
|
||||
@@ -143,6 +164,53 @@ public class friendCardPrefab : MonoBehaviour
|
||||
{
|
||||
friendProfile.material = profileMaterial;
|
||||
}
|
||||
|
||||
RefreshChattingVisual();
|
||||
}
|
||||
|
||||
private void SubscribeChatState()
|
||||
{
|
||||
if (_subscribedToChatState)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
globalChatSystem.ActivePrivateConversationChanged += HandleActivePrivateConversationChanged;
|
||||
_subscribedToChatState = true;
|
||||
}
|
||||
|
||||
private void UnsubscribeChatState()
|
||||
{
|
||||
if (!_subscribedToChatState)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
globalChatSystem.ActivePrivateConversationChanged -= HandleActivePrivateConversationChanged;
|
||||
_subscribedToChatState = false;
|
||||
}
|
||||
|
||||
private void HandleActivePrivateConversationChanged(string _)
|
||||
{
|
||||
RefreshChattingVisual();
|
||||
}
|
||||
|
||||
private void RefreshChattingVisual()
|
||||
{
|
||||
if (profileBorder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool isCurrentPrivateTarget = globalChatSystem.IsViewingPrivateConversation(_steamId);
|
||||
Sprite targetSprite = isCurrentPrivateTarget
|
||||
? (chattingSprite != null ? chattingSprite : normalSprite)
|
||||
: (normalSprite != null ? normalSprite : _defaultProfileBorderSprite);
|
||||
|
||||
if (targetSprite != null)
|
||||
{
|
||||
profileBorder.sprite = targetSprite;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator LoadAvatarRoutine(FriendCardViewData data)
|
||||
|
||||
Reference in New Issue
Block a user