From e370009b18d9ef838c2ba1b40ba2e898c087dcd8 Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Sun, 13 Oct 2024 17:53:37 +0800 Subject: [PATCH] =?UTF-8?q?Fixed=20an=20issue=20where=20the=20UI=20would?= =?UTF-8?q?=20not=20refresh=20properly=20when=20placing=20a=20weapon=20in?= =?UTF-8?q?=20slot=201=20in=20the=20spell=20editor.=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=B0=86=E6=A7=BD=E4=BD=8D=E4=B8=BA1=E7=9A=84=E6=AD=A6?= =?UTF-8?q?=E5=99=A8=E6=94=BE=E5=88=B0=E6=B3=95=E6=9C=AF=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E4=B8=8AUI=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locals/Log.csv | 6 +++++- scripts/debug/LogCat.cs | 6 ++++++ .../inventory/ItemContainerDisplayTemplate.cs | 16 ++++++++++------ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/locals/Log.csv b/locals/Log.csv index f208247..9d1af99 100644 --- a/locals/Log.csv +++ b/locals/Log.csv @@ -107,4 +107,8 @@ log_projectile_generate_magic_is_null,没有装填可提供抛射体的法术。 log_projectile_scene_is_null,抛射体场景为空。,Projectile scene is empty.,射出体は空です。 log_projectile_is_null,抛射体为空。,Projectile scene is empty.,射出シーンは空です。 log_projectile_weapon_range,加载法术范围{0}顺序模式吗{1}上次发射法术时采用的索引{2}。,Load spell range {0} Sequential mode {1} Index used when the spell was last fired {2}.,スペル範囲{0}順序モードですか{1}前回スペルを送信した時のインデックス{2}。 -log_no_platform_detection_raycast_found,缺少必要的平台检测射线。,Lack of necessary platform detection rays.,放射線を検出するのに必要なプラットフォームが不足しています。 \ No newline at end of file +log_no_platform_detection_raycast_found,缺少必要的平台检测射线。,Lack of necessary platform detection rays.,放射線を検出するのに必要なプラットフォームが不足しています。 +log_hide_display_item,项目{0}被隐藏了。,Item {0} is hidden.,アイテム{0}は非表示にされます。 +log_add_display_item,添加项目{0}。,Add item {0}.,項目{0}を追加します。 +log_update_display_item,更新项目{0}。,Update item {0}.,更新項目{0}です。 +log_batch_update_data,批量更新数据开始为{0}结束为{1}.,Batch update data starts with {0} and ends with {1}.,一括更新データの開始を{0}、終了を{1}とします。 \ No newline at end of file diff --git a/scripts/debug/LogCat.cs b/scripts/debug/LogCat.cs index da378a0..8204383 100644 --- a/scripts/debug/LogCat.cs +++ b/scripts/debug/LogCat.cs @@ -16,6 +16,12 @@ public static class LogCat /// public const string Default = "Default"; public const string Debug = "Debug"; + + /// + /// ItemContainerDisplay + /// 项目容器显示器 + /// + public const string ItemContainerDisplay = "ItemContainerDisplay"; /// /// LookForWeaponProcessor diff --git a/scripts/inventory/ItemContainerDisplayTemplate.cs b/scripts/inventory/ItemContainerDisplayTemplate.cs index 57ffec5..9ccde31 100644 --- a/scripts/inventory/ItemContainerDisplayTemplate.cs +++ b/scripts/inventory/ItemContainerDisplayTemplate.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; +using ColdMint.scripts.debug; using ColdMint.scripts.map.events; namespace ColdMint.scripts.inventory; @@ -28,8 +29,10 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay { //Set empty items container to hide all ui. //设置空物品容器,隐藏全部ui。 - foreach (var itemDisplay in ItemDisplayList) + for (var i = 0; i < ItemDisplayList.Count; i++) { + var itemDisplay = ItemDisplayList[i]; + LogCat.LogWithFormat("hide_display_item", LogCat.LogLabel.ItemContainerDisplay, i); itemDisplay.Update(null); itemDisplay.HideSelf(); } @@ -40,13 +43,13 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay var totalCapacity = itemContainer.GetTotalCapacity(); var currentCapacity = ItemDisplayList.Count; var capacityDifference = totalCapacity - currentCapacity; - var adjustedEndIndex = totalCapacity; if (capacityDifference > 0) { //There are those that need to be added, and we create them. //有需要添加的,我们创建他们。 for (var i = 0; i < capacityDifference; i++) { + LogCat.LogWithFormat("add_display_item", LogCat.LogLabel.ItemContainerDisplay, i); AddItemDisplay(); } } @@ -54,10 +57,9 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay { //There are things that need to be hidden //有需要被隐藏的 - adjustedEndIndex += capacityDifference; - var loopEndIndex = currentCapacity + capacityDifference; - for (var i = currentCapacity - 1; i >= loopEndIndex; i--) + for (var i = currentCapacity - 1; i >= totalCapacity; i--) { + LogCat.LogWithFormat("hide_display_item", LogCat.LogLabel.ItemContainerDisplay, i); var itemDisplay = ItemDisplayList[i]; itemDisplay.Update(null); itemDisplay.HideSelf(); @@ -65,7 +67,7 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay } await Task.Yield(); - UpdateData(itemContainer, adjustedEndIndex); + UpdateData(itemContainer, totalCapacity); } private void OnItemDataChangeEvent(ItemDataChangeEvent itemDataChangeEvent) @@ -111,6 +113,7 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay /// private void UpdateData(IItemContainer itemContainer, int endIndex, int startIndex = 0) { + LogCat.LogWithFormat("batch_update_data", LogCat.LogLabel.ItemContainerDisplay, startIndex, endIndex); for (var i = startIndex; i < endIndex; i++) { UpdateDataForSingleLocation(itemContainer, i); @@ -125,6 +128,7 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay /// private void UpdateDataForSingleLocation(IItemContainer itemContainer, int index) { + LogCat.LogWithFormat("update_display_item", LogCat.LogLabel.ItemContainerDisplay, index); var itemDisplay = ItemDisplayList[index]; var item = itemContainer.GetItem(index); if (item == null)