ui基本完毕,修了一大把的bug
This commit is contained in:
@@ -16,6 +16,8 @@ class UI_Panel_Character : MonoBehaviour
|
||||
{
|
||||
[SerializeField] float anim_Time = 0.5f;
|
||||
[SerializeField, Range(0f, 1f)] float illustrationFadeStartAlpha = 0.25f;
|
||||
[SerializeField] float illustrationBgTargetXOffset = 0f;
|
||||
[SerializeField] float illustrationBgTargetYOffset = 0f;
|
||||
float Anim_Speed => 1f / anim_Time;
|
||||
|
||||
[SerializeField] List<Animator> ui_Anim;
|
||||
@@ -287,6 +289,8 @@ class UI_Panel_Character : MonoBehaviour
|
||||
Vector2 targetPosBG = hasCachedPositions
|
||||
? originalIllustrationBGPos
|
||||
: Image_Character_Illustration_BG.rectTransform.anchoredPosition;
|
||||
targetPosBG.x += illustrationBgTargetXOffset;
|
||||
targetPosBG.y += illustrationBgTargetYOffset;
|
||||
Image_Character_Illustration_BG.sprite = data.ally_hero_HD_image;
|
||||
|
||||
float startXBG = targetPosBG.x - 200;
|
||||
|
||||
@@ -9,11 +9,18 @@ using Bansonic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
public class UI_Panel_Mail : MonoBehaviour
|
||||
{
|
||||
public static event Action OnUnreadStateChanged;
|
||||
private static readonly Dictionary<string, Sprite> ServerMailImageCache = new Dictionary<string, Sprite>(StringComparer.Ordinal);
|
||||
private static readonly HashSet<string> ServerMailImageLoadsInFlight = new HashSet<string>(StringComparer.Ordinal);
|
||||
#if UNITY_EDITOR
|
||||
private const string DefaultCoinRewardIconPath = "Assets/__UI_NEW/hallway/icon.90.90/icon_coin.png";
|
||||
private const string DefaultMaterialRewardIconPath = "Assets/__UI_NEW/hallway/icon.90.90/icon_piece.png";
|
||||
#endif
|
||||
|
||||
//1234567890
|
||||
[SerializeField] float anim_Time = 0.5f;
|
||||
@@ -31,6 +38,10 @@ public class UI_Panel_Mail : MonoBehaviour
|
||||
[Header("rewards objects")]
|
||||
public GameObject rewardSlotPrefab;
|
||||
[SerializeField] Transform content_Reward_Slot;
|
||||
[Header("reward fallback icons")]
|
||||
[SerializeField] private Sprite playerExpRewardIcon;
|
||||
[SerializeField] private Sprite coinRewardIcon;
|
||||
[SerializeField] private Sprite materialRewardIcon;
|
||||
|
||||
[Header("texts")]
|
||||
public Text thisMail_title;
|
||||
@@ -47,11 +58,12 @@ public class UI_Panel_Mail : MonoBehaviour
|
||||
|
||||
[Header("buttons")]
|
||||
public Button receive_this_mail;
|
||||
public Button backButton;
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
CloseMailPanel();
|
||||
}
|
||||
}
|
||||
void Start()
|
||||
@@ -60,12 +72,14 @@ public class UI_Panel_Mail : MonoBehaviour
|
||||
{
|
||||
item.speed = Anim_Speed;
|
||||
}
|
||||
MailRewardGrantService.ConfigureBasicRewardIcons(playerExpRewardIcon, coinRewardIcon, materialRewardIcon);
|
||||
BindTopLevelButtons();
|
||||
InitializeMailSource();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
MailRewardGrantService.ConfigureBasicRewardIcons(playerExpRewardIcon, coinRewardIcon, materialRewardIcon);
|
||||
InitializeMailSource();
|
||||
}
|
||||
|
||||
@@ -74,6 +88,48 @@ public class UI_Panel_Mail : MonoBehaviour
|
||||
UnsubscribeMailService();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnValidate()
|
||||
{
|
||||
TryAssignDefaultRewardIcons();
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
TryAssignDefaultRewardIcons();
|
||||
}
|
||||
|
||||
private void TryAssignDefaultRewardIcons()
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
if (coinRewardIcon == null)
|
||||
{
|
||||
Sprite coinIcon = AssetDatabase.LoadAssetAtPath<Sprite>(DefaultCoinRewardIconPath);
|
||||
if (coinIcon != null)
|
||||
{
|
||||
coinRewardIcon = coinIcon;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (materialRewardIcon == null)
|
||||
{
|
||||
Sprite materialIcon = AssetDatabase.LoadAssetAtPath<Sprite>(DefaultMaterialRewardIconPath);
|
||||
if (materialIcon != null)
|
||||
{
|
||||
materialRewardIcon = materialIcon;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed && !Application.isPlaying)
|
||||
{
|
||||
EditorUtility.SetDirty(this);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void InitializeMailSource()
|
||||
{
|
||||
if (!isActiveAndEnabled)
|
||||
@@ -445,14 +501,18 @@ public class UI_Panel_Mail : MonoBehaviour
|
||||
|
||||
void BindTopLevelButtons()
|
||||
{
|
||||
if (receive_this_mail == null)
|
||||
if (receive_this_mail != null)
|
||||
{
|
||||
return;
|
||||
receive_this_mail.onClick.RemoveListener(HandleReceiveCurrentMailClicked);
|
||||
receive_this_mail.onClick.AddListener(HandleReceiveCurrentMailClicked);
|
||||
RefreshReceiveButton();
|
||||
}
|
||||
|
||||
receive_this_mail.onClick.RemoveListener(HandleReceiveCurrentMailClicked);
|
||||
receive_this_mail.onClick.AddListener(HandleReceiveCurrentMailClicked);
|
||||
RefreshReceiveButton();
|
||||
if (backButton != null)
|
||||
{
|
||||
backButton.onClick.RemoveListener(HandleBackButtonClicked);
|
||||
backButton.onClick.AddListener(HandleBackButtonClicked);
|
||||
}
|
||||
}
|
||||
|
||||
void HandleReceiveCurrentMailClicked()
|
||||
@@ -465,6 +525,16 @@ public class UI_Panel_Mail : MonoBehaviour
|
||||
OnMailReceived(selectedSlot, selectedMailData);
|
||||
}
|
||||
|
||||
void HandleBackButtonClicked()
|
||||
{
|
||||
CloseMailPanel();
|
||||
}
|
||||
|
||||
void CloseMailPanel()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
void RefreshReceiveButton()
|
||||
{
|
||||
if (receive_this_mail == null)
|
||||
@@ -1282,6 +1352,27 @@ public static class MailRewardGrantService
|
||||
private static readonly Dictionary<int, storeItemSO> StoreItemsById = new Dictionary<int, storeItemSO>();
|
||||
private static readonly Dictionary<string, storeItemSO> StoreItemsByName = new Dictionary<string, storeItemSO>(StringComparer.OrdinalIgnoreCase);
|
||||
private static bool _assetsLoaded;
|
||||
private static Sprite _playerExpRewardIcon;
|
||||
private static Sprite _coinRewardIcon;
|
||||
private static Sprite _materialRewardIcon;
|
||||
|
||||
public static void ConfigureBasicRewardIcons(Sprite playerExpIcon, Sprite coinIcon, Sprite materialIcon)
|
||||
{
|
||||
if (playerExpIcon != null)
|
||||
{
|
||||
_playerExpRewardIcon = playerExpIcon;
|
||||
}
|
||||
|
||||
if (coinIcon != null)
|
||||
{
|
||||
_coinRewardIcon = coinIcon;
|
||||
}
|
||||
|
||||
if (materialIcon != null)
|
||||
{
|
||||
_materialRewardIcon = materialIcon;
|
||||
}
|
||||
}
|
||||
|
||||
public static void PopulateRewardDisplay(mail_so.rewardItem reward)
|
||||
{
|
||||
@@ -1296,15 +1387,15 @@ public static class MailRewardGrantService
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(reward.rewardName))
|
||||
if (ShouldOverrideRewardDisplayName(reward, resolved))
|
||||
{
|
||||
reward.rewardName = resolved.DisplayName;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(reward.reward_description))
|
||||
if (ShouldOverrideRewardDescription(reward, resolved))
|
||||
{
|
||||
reward.reward_description = resolved.Description;
|
||||
}
|
||||
if (reward.reward_image == null)
|
||||
if (resolved.Icon != null)
|
||||
{
|
||||
reward.reward_image = resolved.Icon;
|
||||
}
|
||||
@@ -1585,13 +1676,13 @@ public static class MailRewardGrantService
|
||||
switch (reward.reward_Type)
|
||||
{
|
||||
case mail_so.reward_type.exp_user:
|
||||
resolved = CreateBasicResolved(ResolvedKind.PlayerExp, amount, rewardName, reward.reward_image, reward.reward_description, reward, "\u73a9\u5bb6\u7ecf\u9a8c");
|
||||
resolved = CreateBasicResolved(ResolvedKind.PlayerExp, amount, rewardName, reward.reward_image != null ? reward.reward_image : _playerExpRewardIcon, reward.reward_description, reward, "\u73a9\u5bb6\u7ecf\u9a8c");
|
||||
return true;
|
||||
case mail_so.reward_type.money:
|
||||
resolved = CreateBasicResolved(ResolvedKind.Coins, amount, rewardName, reward.reward_image, reward.reward_description, reward, "\u91d1\u5e01");
|
||||
resolved = CreateBasicResolved(ResolvedKind.Coins, amount, rewardName, reward.reward_image != null ? reward.reward_image : _coinRewardIcon, reward.reward_description, reward, "\u91d1\u5e01");
|
||||
return true;
|
||||
case mail_so.reward_type.metarial:
|
||||
resolved = CreateBasicResolved(ResolvedKind.Material, amount, rewardName, reward.reward_image, reward.reward_description, reward, "\u8bb0\u5fc6\u788e\u7247");
|
||||
resolved = CreateBasicResolved(ResolvedKind.Material, amount, rewardName, reward.reward_image != null ? reward.reward_image : _materialRewardIcon, reward.reward_description, reward, "\u8bb0\u5fc6\u788e\u7247");
|
||||
return true;
|
||||
case mail_so.reward_type.expBottles_allies:
|
||||
if (TryResolveExpBottle(reward, rewardKey, rewardName, amount, out resolved))
|
||||
@@ -1644,6 +1735,44 @@ public static class MailRewardGrantService
|
||||
};
|
||||
}
|
||||
|
||||
private static bool ShouldOverrideRewardDisplayName(mail_so.rewardItem reward, ResolvedReward resolved)
|
||||
{
|
||||
if (reward == null || resolved == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (resolved.Kind)
|
||||
{
|
||||
case ResolvedKind.ExpBottle:
|
||||
case ResolvedKind.GrowthMaterial:
|
||||
case ResolvedKind.EquipmentConsumable:
|
||||
case ResolvedKind.StoreItem:
|
||||
return !string.IsNullOrWhiteSpace(resolved.DisplayName);
|
||||
default:
|
||||
return string.IsNullOrWhiteSpace(reward.rewardName) && !string.IsNullOrWhiteSpace(resolved.DisplayName);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ShouldOverrideRewardDescription(mail_so.rewardItem reward, ResolvedReward resolved)
|
||||
{
|
||||
if (reward == null || resolved == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (resolved.Kind)
|
||||
{
|
||||
case ResolvedKind.ExpBottle:
|
||||
case ResolvedKind.GrowthMaterial:
|
||||
case ResolvedKind.EquipmentConsumable:
|
||||
case ResolvedKind.StoreItem:
|
||||
return !string.IsNullOrWhiteSpace(resolved.Description);
|
||||
default:
|
||||
return string.IsNullOrWhiteSpace(reward.reward_description) && !string.IsNullOrWhiteSpace(resolved.Description);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryResolveByRewardKey(mail_so.rewardItem reward, string rewardKey, string rewardName, int amount, out ResolvedReward resolved)
|
||||
{
|
||||
if (TryResolveExpBottle(reward, rewardKey, rewardName, amount, out resolved))
|
||||
|
||||
@@ -1502,6 +1502,7 @@ RectTransform:
|
||||
- {fileID: 4507029859229390628}
|
||||
- {fileID: 3166511394318740470}
|
||||
- {fileID: 4201371652593379150}
|
||||
- {fileID: 7304390476110563193}
|
||||
m_Father: {fileID: 4008714089197239054}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
@@ -3837,6 +3838,41 @@ MonoBehaviour:
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &3000813276228866063
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7304390476110563193}
|
||||
m_Layer: 5
|
||||
m_Name: putSettingsPrefabHere
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &7304390476110563193
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3000813276228866063}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 5634981615641515618}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: -504.3711}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &3004460849469971855
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4101,7 +4137,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -28, y: 1.3}
|
||||
m_SizeDelta: {x: 53, y: 47}
|
||||
m_SizeDelta: {x: 90, y: 90}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &5184938500494465621
|
||||
CanvasRenderer:
|
||||
@@ -4125,13 +4161,13 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastTarget: 0
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 8139719423079072813, guid: 16f0765cc15fce04f828ecd44d1dbf91, type: 3}
|
||||
m_Sprite: {fileID: 21300000, guid: 16f0765cc15fce04f828ecd44d1dbf91, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
@@ -5862,7 +5898,9 @@ MonoBehaviour:
|
||||
playerCoins_legacy: {fileID: 7376147910533281946}
|
||||
player_mmrFragment: {fileID: 1718535194614905540}
|
||||
player_rks: {fileID: 3469340257331446344}
|
||||
rksProgressImage: {fileID: 4240146692151177402}
|
||||
putPrefabsHere: {fileID: 6773918330215714056}
|
||||
putSettingsPrefabHere: {fileID: 3000813276228866063}
|
||||
settings_launch: {fileID: 865676738076373517}
|
||||
userInfo_launch: {fileID: 1502937460034745443}
|
||||
store_launch: {fileID: 5472029888669800656}
|
||||
@@ -6106,7 +6144,7 @@ MonoBehaviour:
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 0
|
||||
m_FillAmount: 0.457
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
@@ -8854,7 +8892,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -0.000041962, y: -0.000047684}
|
||||
m_SizeDelta: {x: 52, y: 49}
|
||||
m_SizeDelta: {x: 90, y: 90}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &5175879897170093321
|
||||
CanvasRenderer:
|
||||
@@ -8878,13 +8916,13 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastTarget: 0
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 6309817061271938796, guid: 6fd4dd33d986d824d95f7b01579acc4d, type: 3}
|
||||
m_Sprite: {fileID: 21300000, guid: 6fd4dd33d986d824d95f7b01579acc4d, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
|
||||
@@ -23,8 +23,10 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
public Text playerCoins_legacy;
|
||||
public Text player_mmrFragment;
|
||||
public Text player_rks;
|
||||
public Image rksProgressImage;
|
||||
[Header("put prefabs here")]
|
||||
public GameObject putPrefabsHere;
|
||||
public GameObject putSettingsPrefabHere;
|
||||
[Header("son buttons")]
|
||||
public Button settings_launch;
|
||||
public Button userInfo_launch;
|
||||
@@ -154,7 +156,9 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
PlayerRksService.OnRksChanged += HandleRksChanged;
|
||||
UpdatePlayerCoinsLegacyText(PlayerEconomyLedger.EnsureInstance().GetCoins());
|
||||
UpdatePlayerMmrFragmentText(PlayerEconomyLedger.EnsureInstance().GetMaterial());
|
||||
UpdatePlayerRksText(PlayerRksService.GetBestOverallRks(player_SO));
|
||||
float currentRks = PlayerRksService.GetBestOverallRks(player_SO);
|
||||
UpdatePlayerRksText(currentRks);
|
||||
UpdateRksProgressImage(currentRks);
|
||||
|
||||
if (button_Music == null)
|
||||
{
|
||||
@@ -223,7 +227,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
}
|
||||
|
||||
// Pre-instantiate settings prefab and keep it inactive, ensuring only one exists
|
||||
if (settings_prefab != null && putPrefabsHere != null)
|
||||
if (settings_prefab != null && GetSettingsParentTransform() != null)
|
||||
{
|
||||
// Try to find existing one in scene first
|
||||
if (settingsInstance == null)
|
||||
@@ -237,7 +241,8 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
if (settingsInstance == null)
|
||||
{
|
||||
settingsInstance = Instantiate(settings_prefab, putPrefabsHere.transform);
|
||||
settingsInstance = Instantiate(settings_prefab, GetSettingsParentTransform());
|
||||
AttachManagedPanelVisibilityRelay(settingsInstance, true);
|
||||
EnsureSettingsEnterAnimator(settingsInstance);
|
||||
EnsureSettingsLastSibling();
|
||||
settingsInstance.SetActive(false);
|
||||
@@ -261,8 +266,9 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
// ensure it's parented correctly under putPrefabsHere
|
||||
settingsInstance.transform.SetParent(putPrefabsHere.transform, false);
|
||||
// ensure it's parented correctly beside putPrefabsHere
|
||||
settingsInstance.transform.SetParent(GetSettingsParentTransform(), false);
|
||||
AttachManagedPanelVisibilityRelay(settingsInstance, true);
|
||||
EnsureSettingsLastSibling();
|
||||
EnsureSettingsEnterAnimator(settingsInstance);
|
||||
settingsInstance.SetActive(false);
|
||||
@@ -283,60 +289,106 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
if (userInfoInstance == null)
|
||||
{
|
||||
userInfoInstance = Instantiate(userInfo_prefab, putPrefabsHere.transform);
|
||||
AttachManagedPanelVisibilityRelay(userInfoInstance, false);
|
||||
userInfoInstance.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
userInfoInstance.transform.SetParent(putPrefabsHere.transform, false);
|
||||
AttachManagedPanelVisibilityRelay(userInfoInstance, false);
|
||||
userInfoInstance.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
lastSettingsVisibilityState = IsSettingsPanelVisible;
|
||||
lastOverlayPanelsVisibilityState = AreOverlayPanelsVisible();
|
||||
CurrentOverlayPanelsVisible = lastOverlayPanelsVisibilityState;
|
||||
SyncManagedPanelVisibilityState(true);
|
||||
}
|
||||
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if(Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
//ToggleSettingsPrefab();
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
private void OnTransformChildrenChanged()
|
||||
{
|
||||
if (!IsUiUiSceneActive())
|
||||
{
|
||||
if (CurrentSettingsVisible)
|
||||
{
|
||||
BroadcastSettingsVisibility(false);
|
||||
}
|
||||
if (CurrentOverlayPanelsVisible)
|
||||
{
|
||||
lastOverlayPanelsVisibilityState = false;
|
||||
CurrentOverlayPanelsVisible = false;
|
||||
GlobalOverlayPanelVisibilityChanged?.Invoke(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool visible = IsSettingsPanelVisible;
|
||||
if (visible != lastSettingsVisibilityState)
|
||||
topNavigationGeometryDirty = true;
|
||||
EnsureTopNavigationFront();
|
||||
}
|
||||
|
||||
internal void NotifyManagedPanelVisibilityChanged(bool includesSettingsPanel)
|
||||
{
|
||||
if (!ReferenceEquals(activeInstance, this))
|
||||
{
|
||||
BroadcastSettingsVisibility(visible);
|
||||
return;
|
||||
}
|
||||
|
||||
bool overlayVisible = AreOverlayPanelsVisible();
|
||||
if (overlayVisible != lastOverlayPanelsVisibilityState)
|
||||
if (!IsUiUiSceneActive())
|
||||
{
|
||||
lastOverlayPanelsVisibilityState = overlayVisible;
|
||||
CurrentOverlayPanelsVisible = overlayVisible;
|
||||
GlobalOverlayPanelVisibilityChanged?.Invoke(overlayVisible);
|
||||
SetSettingsVisibilityState(false);
|
||||
SetOverlayPanelsVisibilityState(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (includesSettingsPanel)
|
||||
{
|
||||
SetSettingsVisibilityState(IsSettingsPanelVisible);
|
||||
}
|
||||
|
||||
SetOverlayPanelsVisibilityState(AreOverlayPanelsVisible());
|
||||
}
|
||||
|
||||
private void SyncManagedPanelVisibilityState(bool forceNotify)
|
||||
{
|
||||
if (!IsUiUiSceneActive())
|
||||
{
|
||||
SetSettingsVisibilityState(false, forceNotify);
|
||||
SetOverlayPanelsVisibilityState(false, forceNotify);
|
||||
return;
|
||||
}
|
||||
|
||||
SetSettingsVisibilityState(IsSettingsPanelVisible, forceNotify);
|
||||
SetOverlayPanelsVisibilityState(AreOverlayPanelsVisible(), forceNotify);
|
||||
}
|
||||
|
||||
private void AttachManagedPanelVisibilityRelay(GameObject panel, bool includesSettingsPanel)
|
||||
{
|
||||
if (panel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
btmandtopPanelVisibilityRelay relay = panel.GetComponent<btmandtopPanelVisibilityRelay>();
|
||||
if (relay == null)
|
||||
{
|
||||
relay = panel.AddComponent<btmandtopPanelVisibilityRelay>();
|
||||
}
|
||||
|
||||
relay.Initialize(this, includesSettingsPanel);
|
||||
}
|
||||
|
||||
private void SetSettingsVisibilityState(bool visible, bool forceNotify = false)
|
||||
{
|
||||
lastSettingsVisibilityState = visible;
|
||||
if (!forceNotify && CurrentSettingsVisible == visible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentSettingsVisible = visible;
|
||||
SettingsVisibilityChanged?.Invoke(visible);
|
||||
GlobalSettingsVisibilityChanged?.Invoke(visible);
|
||||
}
|
||||
|
||||
private void SetOverlayPanelsVisibilityState(bool visible, bool forceNotify = false)
|
||||
{
|
||||
lastOverlayPanelsVisibilityState = visible;
|
||||
if (!forceNotify && CurrentOverlayPanelsVisible == visible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentOverlayPanelsVisible = visible;
|
||||
GlobalOverlayPanelVisibilityChanged?.Invoke(visible);
|
||||
topNavigationGeometryDirty = true;
|
||||
EnsureTopNavigationFront();
|
||||
}
|
||||
|
||||
@@ -554,6 +606,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
private void HandleRksChanged(float rksAmount)
|
||||
{
|
||||
UpdatePlayerRksText(rksAmount);
|
||||
UpdateRksProgressImage(rksAmount);
|
||||
}
|
||||
|
||||
private void InitializeMailRedPot()
|
||||
@@ -644,6 +697,16 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateRksProgressImage(float rksAmount)
|
||||
{
|
||||
if (rksProgressImage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rksProgressImage.fillAmount = Mathf.Clamp01(Mathf.InverseLerp(0f, 100f, rksAmount));
|
||||
}
|
||||
|
||||
private Text FindLegacyTextByLiteral(string literal)
|
||||
{
|
||||
if (string.IsNullOrEmpty(literal))
|
||||
@@ -802,12 +865,13 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
private void ToggleSettingsPrefab()
|
||||
{
|
||||
if (settings_prefab == null || putPrefabsHere == null) return;
|
||||
if (settings_prefab == null || GetSettingsParentTransform() == null) return;
|
||||
|
||||
// If we don't have an instance (it may have been destroyed), instantiate one
|
||||
if (settingsInstance == null)
|
||||
{
|
||||
settingsInstance = Instantiate(settings_prefab, putPrefabsHere.transform);
|
||||
settingsInstance = Instantiate(settings_prefab, GetSettingsParentTransform());
|
||||
AttachManagedPanelVisibilityRelay(settingsInstance, true);
|
||||
EnsureSettingsEnterAnimator(settingsInstance);
|
||||
EnsureSettingsLastSibling();
|
||||
|
||||
@@ -830,22 +894,20 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
settingsInstance.SetActive(true);
|
||||
EnsureSettingsLastSibling();
|
||||
BroadcastSettingsVisibility(true);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
RegisterManagedPanel(settingsInstance, () =>
|
||||
{
|
||||
if (settingsInstance != null)
|
||||
{
|
||||
settingsInstance.SetActive(false);
|
||||
BroadcastSettingsVisibility(false);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
}
|
||||
});
|
||||
NotifyManagedPanelVisibilityChanged(true);
|
||||
return;
|
||||
}
|
||||
|
||||
AttachManagedPanelVisibilityRelay(settingsInstance, true);
|
||||
EnsureSettingsEnterAnimator(settingsInstance);
|
||||
settingsInstance.transform.SetParent(putPrefabsHere.transform, false);
|
||||
settingsInstance.transform.SetParent(GetSettingsParentTransform(), false);
|
||||
EnsureSettingsLastSibling();
|
||||
|
||||
// Toggle active state
|
||||
@@ -859,13 +921,10 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
if (settingsInstance != null)
|
||||
{
|
||||
settingsInstance.SetActive(false);
|
||||
BroadcastSettingsVisibility(false);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
}
|
||||
});
|
||||
}
|
||||
BroadcastSettingsVisibility(settingsInstance.activeSelf);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
NotifyManagedPanelVisibilityChanged(true);
|
||||
}
|
||||
|
||||
public bool IsSettingsPanelVisible
|
||||
@@ -889,16 +948,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
private void BroadcastSettingsVisibility(bool visible)
|
||||
{
|
||||
lastSettingsVisibilityState = visible;
|
||||
if (CurrentSettingsVisible == visible)
|
||||
{
|
||||
SettingsVisibilityChanged?.Invoke(visible);
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentSettingsVisible = visible;
|
||||
SettingsVisibilityChanged?.Invoke(visible);
|
||||
GlobalSettingsVisibilityChanged?.Invoke(visible);
|
||||
SetSettingsVisibilityState(visible);
|
||||
}
|
||||
|
||||
private bool IsUiUiSceneActive()
|
||||
@@ -921,12 +971,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
private void BroadcastOverlayPanelsVisibility()
|
||||
{
|
||||
bool visible = AreOverlayPanelsVisible();
|
||||
lastOverlayPanelsVisibilityState = visible;
|
||||
CurrentOverlayPanelsVisible = visible;
|
||||
GlobalOverlayPanelVisibilityChanged?.Invoke(visible);
|
||||
topNavigationGeometryDirty = true;
|
||||
EnsureTopNavigationFront();
|
||||
SetOverlayPanelsVisibilityState(AreOverlayPanelsVisible());
|
||||
}
|
||||
|
||||
private void RegisterManagedPanel(GameObject panel, System.Action closeAction)
|
||||
@@ -1071,6 +1116,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
instance.SetActive(true);
|
||||
}
|
||||
|
||||
AttachManagedPanelVisibilityRelay(instance, false);
|
||||
TryAssignCanvasCamera(instance);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
EnsureTopNavigationFront();
|
||||
@@ -1079,15 +1125,31 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
private void EnsureSettingsLastSibling()
|
||||
{
|
||||
if (settingsInstance == null || putPrefabsHere == null)
|
||||
if (settingsInstance == null || GetSettingsParentTransform() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
settingsInstance.transform.SetParent(putPrefabsHere.transform, false);
|
||||
settingsInstance.transform.SetParent(GetSettingsParentTransform(), false);
|
||||
settingsInstance.transform.SetAsLastSibling();
|
||||
}
|
||||
|
||||
private Transform GetSettingsParentTransform()
|
||||
{
|
||||
if (putSettingsPrefabHere != null)
|
||||
{
|
||||
return putSettingsPrefabHere.transform;
|
||||
}
|
||||
|
||||
if (putPrefabsHere == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Transform siblingParent = putPrefabsHere.transform.parent;
|
||||
return siblingParent != null ? siblingParent : putPrefabsHere.transform;
|
||||
}
|
||||
|
||||
private void CloseInfoPanels(GameObject keep)
|
||||
{
|
||||
CloseInstance(ref userInfoInstance, keep);
|
||||
@@ -1147,7 +1209,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
{
|
||||
if (activeInstance != null)
|
||||
{
|
||||
activeInstance.BroadcastOverlayPanelsVisibility();
|
||||
activeInstance.SyncManagedPanelVisibilityState(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1387,6 +1449,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
{
|
||||
activeInstance.topNavigationGeometryDirty = true;
|
||||
activeInstance.EnsureTopNavigationFront();
|
||||
activeInstance.SyncManagedPanelVisibilityState(true);
|
||||
activeInstance.ScheduleDeferredUiRefresh();
|
||||
}
|
||||
}
|
||||
@@ -1587,3 +1650,31 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class btmandtopPanelVisibilityRelay : MonoBehaviour
|
||||
{
|
||||
private btmandtopController owner;
|
||||
private bool includesSettingsPanel;
|
||||
|
||||
public void Initialize(btmandtopController controller, bool isSettingsPanel)
|
||||
{
|
||||
owner = controller;
|
||||
includesSettingsPanel = isSettingsPanel;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (owner != null)
|
||||
{
|
||||
owner.NotifyManagedPanelVisibilityChanged(includesSettingsPanel);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (owner != null)
|
||||
{
|
||||
owner.NotifyManagedPanelVisibilityChanged(includesSettingsPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user