From 9d7132b94d1dabdad81262e4ef3e58eef0c00a08 Mon Sep 17 00:00:00 2001 From: eugene-hong <58686228+eugene-doobu@users.noreply.github.com> Date: Wed, 8 Jan 2025 19:45:00 +0900 Subject: [PATCH 1/2] fix update assets --- .../_Scripts/UI/Widget/StageInformation.cs | 17 ++++++++- .../Assets/_Scripts/UI/Widget/WorldMap.cs | 38 ++++++++----------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/nekoyume/Assets/_Scripts/UI/Widget/StageInformation.cs b/nekoyume/Assets/_Scripts/UI/Widget/StageInformation.cs index cc7f9b423d0..1733236ac6f 100644 --- a/nekoyume/Assets/_Scripts/UI/Widget/StageInformation.cs +++ b/nekoyume/Assets/_Scripts/UI/Widget/StageInformation.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using Cysharp.Threading.Tasks; using Nekoyume.ApiClient; using Nekoyume.Battle; using Nekoyume.EnumType; @@ -73,6 +74,16 @@ protected override void Awake() CloseWidget = OnClickClose; } + protected override void OnDisable() + { + base.OnDisable(); + var worldMap = Find(); + if (worldMap.gameObject.activeSelf) + { + worldMap.UpdateAssets(); + } + } + public override void Initialize() { base.Initialize(); @@ -126,11 +137,13 @@ private void RefreshSeasonPassCourageAmount(bool isEventDungeon = false) var expAmount = 0; if (isEventDungeon) { - expAmount = seasonPassServiceManager.ExpPointAmount(SeasonPassServiceClient.PassType.CouragePass, SeasonPassServiceClient.ActionType.event_dungeon); + expAmount = seasonPassServiceManager.ExpPointAmount(SeasonPassServiceClient.PassType.CouragePass, + SeasonPassServiceClient.ActionType.event_dungeon); } else { - expAmount = seasonPassServiceManager.ExpPointAmount(SeasonPassServiceClient.PassType.CouragePass, SeasonPassServiceClient.ActionType.hack_and_slash); + expAmount = seasonPassServiceManager.ExpPointAmount(SeasonPassServiceClient.PassType.CouragePass, + SeasonPassServiceClient.ActionType.hack_and_slash); } seasonPassCourageAmount.text = $"+{expAmount}"; } diff --git a/nekoyume/Assets/_Scripts/UI/Widget/WorldMap.cs b/nekoyume/Assets/_Scripts/UI/Widget/WorldMap.cs index 25c499a5423..a1dcda14067 100644 --- a/nekoyume/Assets/_Scripts/UI/Widget/WorldMap.cs +++ b/nekoyume/Assets/_Scripts/UI/Widget/WorldMap.cs @@ -161,7 +161,7 @@ public override void Initialize() public void Show(WorldInformation worldInformation, bool blockWorldUnlockPopup = false) { - SubscribeAtShow(); + UpdateAssets(); HasNotification = false; SetWorldInformation(worldInformation); @@ -180,22 +180,15 @@ public void Show(WorldInformation worldInformation, bool blockWorldUnlockPopup = public void Show(int worldId, int stageId, bool showWorld, bool callByShow = false) { - SubscribeAtShow(); + UpdateAssets(); ShowWorld(worldId, stageId, showWorld, callByShow); Show(true); Find().Show(); } - private void SubscribeAtShow() + public void UpdateAssets(bool isForceSetBattle = false) { _disposablesAtShow.DisposeAllAndClear(); - OnDisableStaticObservable - .Where(widget => widget is StageInformation) - .DelayFrame(1) - .Where(_ => gameObject.activeSelf) - .Subscribe(_ => SubscribeAtShow()) - .AddTo(_disposablesAtShow); - TextMeshProUGUI eventDungeonRemainingTimeText = null; RxProps.EventScheduleRowForDungeon.Subscribe(value => { foreach (var eventDungeonObject in eventDungeonObjects) @@ -204,7 +197,7 @@ private void SubscribeAtShow() eventDungeonObject.remainingTimeObject.SetActive(false); } - if (value is null) + if (isForceSetBattle || value is null) { Find() .UpdateAssets(HeaderMenuStatic.AssetVisibleState.Battle); @@ -221,15 +214,17 @@ private void SubscribeAtShow() eventDungeonObject.button.HasNotification.Value = true; eventDungeonObject.button.Unlock(); eventDungeonObject.remainingTimeObject.SetActive(true); - eventDungeonRemainingTimeText = eventDungeonObject.remainingTimeText; + + if (eventDungeonObject.remainingTimeText == null) + { + return; + } + + RxProps.EventDungeonRemainingTimeText + .SubscribeTo(eventDungeonObject.remainingTimeText) + .AddTo(_disposablesAtShow); } }).AddTo(_disposablesAtShow); - if (eventDungeonRemainingTimeText != null) - { - RxProps.EventDungeonRemainingTimeText - .SubscribeTo(eventDungeonRemainingTimeText) - .AddTo(_disposablesAtShow); - } } public override void Close(bool ignoreCloseAnimation = false) @@ -343,7 +338,6 @@ private void ShowWorld( SharedViewModel.IsWorldShown.SetValueAndForceNotify(showWorld); } - SubscribeAtShow(); TableSheets.Instance.WorldSheet.TryGetValue( worldId, @@ -354,7 +348,7 @@ private void ShowWorld( var stageInfo = Find(); stageInfo.Show(SharedViewModel, worldRow, StageType.HackAndSlash); UpdateNotificationInfo(); - Find().UpdateAssets(HeaderMenuStatic.AssetVisibleState.Battle); + UpdateAssets(true); Find().Show(); } @@ -372,8 +366,6 @@ public void ShowEventDungeonStage( SharedViewModel.IsWorldShown.SetValueAndForceNotify(showWorld); } - SubscribeAtShow(); - Show(true); var openedStageId = RxProps.EventDungeonInfo.Value is null || @@ -391,7 +383,7 @@ RxProps.EventDungeonInfo.Value is null || openedStageId, openedStageId); StageIdToNotify = openedStageId; - Find().UpdateAssets(HeaderMenuStatic.AssetVisibleState.EventDungeon); + UpdateAssets(); Find().Show(); } From 2da9a2f16110ef3a5a4ebc4c292458da5d5609b4 Mon Sep 17 00:00:00 2001 From: eugene-hong <58686228+eugene-doobu@users.noreply.github.com> Date: Wed, 8 Jan 2025 20:00:40 +0900 Subject: [PATCH 2/2] remove redundant function call --- nekoyume/Assets/_Scripts/UI/Widget/WorldMap.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/nekoyume/Assets/_Scripts/UI/Widget/WorldMap.cs b/nekoyume/Assets/_Scripts/UI/Widget/WorldMap.cs index a1dcda14067..7b009c6425b 100644 --- a/nekoyume/Assets/_Scripts/UI/Widget/WorldMap.cs +++ b/nekoyume/Assets/_Scripts/UI/Widget/WorldMap.cs @@ -180,7 +180,6 @@ public void Show(WorldInformation worldInformation, bool blockWorldUnlockPopup = public void Show(int worldId, int stageId, bool showWorld, bool callByShow = false) { - UpdateAssets(); ShowWorld(worldId, stageId, showWorld, callByShow); Show(true); Find().Show();