Fixed an issue where the UI would not refresh properly when placing a weapon in slot 1 in the spell editor.

修复将槽位为1的武器放到法术编辑器上UI无法正常刷新的问题。
This commit is contained in:
Cold-Mint 2024-10-13 17:53:37 +08:00
parent 8bd7113153
commit e370009b18
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
3 changed files with 21 additions and 7 deletions

View File

@ -108,3 +108,7 @@ log_projectile_scene_is_null,抛射体场景为空。,Projectile scene is empty.
log_projectile_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_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.,放射線を検出するのに必要なプラットフォームが不足しています。 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}とします。
1 id zh en ja
108 log_projectile_is_null 抛射体为空。 Projectile scene is empty. 射出シーンは空です。
109 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}。
110 log_no_platform_detection_raycast_found 缺少必要的平台检测射线。 Lack of necessary platform detection rays. 放射線を検出するのに必要なプラットフォームが不足しています。
111 log_hide_display_item 项目{0}被隐藏了。 Item {0} is hidden. アイテム{0}は非表示にされます。
112 log_add_display_item 添加项目{0}。 Add item {0}. 項目{0}を追加します。
113 log_update_display_item 更新项目{0}。 Update item {0}. 更新項目{0}です。
114 log_batch_update_data 批量更新数据开始为{0}结束为{1}. Batch update data starts with {0} and ends with {1}. 一括更新データの開始を{0}、終了を{1}とします。

View File

@ -17,6 +17,12 @@ public static class LogCat
public const string Default = "Default"; public const string Default = "Default";
public const string Debug = "Debug"; public const string Debug = "Debug";
/// <summary>
/// <para>ItemContainerDisplay</para>
/// <para>项目容器显示器</para>
/// </summary>
public const string ItemContainerDisplay = "ItemContainerDisplay";
/// <summary> /// <summary>
/// <para>LookForWeaponProcessor</para> /// <para>LookForWeaponProcessor</para>
/// <para>查找武器处理器</para> /// <para>查找武器处理器</para>

View File

@ -1,6 +1,7 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using ColdMint.scripts.debug;
using ColdMint.scripts.map.events; using ColdMint.scripts.map.events;
namespace ColdMint.scripts.inventory; namespace ColdMint.scripts.inventory;
@ -28,8 +29,10 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay
{ {
//Set empty items container to hide all ui. //Set empty items container to hide all ui.
//设置空物品容器隐藏全部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.Update(null);
itemDisplay.HideSelf(); itemDisplay.HideSelf();
} }
@ -40,13 +43,13 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay
var totalCapacity = itemContainer.GetTotalCapacity(); var totalCapacity = itemContainer.GetTotalCapacity();
var currentCapacity = ItemDisplayList.Count; var currentCapacity = ItemDisplayList.Count;
var capacityDifference = totalCapacity - currentCapacity; var capacityDifference = totalCapacity - currentCapacity;
var adjustedEndIndex = totalCapacity;
if (capacityDifference > 0) if (capacityDifference > 0)
{ {
//There are those that need to be added, and we create them. //There are those that need to be added, and we create them.
//有需要添加的,我们创建他们。 //有需要添加的,我们创建他们。
for (var i = 0; i < capacityDifference; i++) for (var i = 0; i < capacityDifference; i++)
{ {
LogCat.LogWithFormat("add_display_item", LogCat.LogLabel.ItemContainerDisplay, i);
AddItemDisplay(); AddItemDisplay();
} }
} }
@ -54,10 +57,9 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay
{ {
//There are things that need to be hidden //There are things that need to be hidden
//有需要被隐藏的 //有需要被隐藏的
adjustedEndIndex += capacityDifference; for (var i = currentCapacity - 1; i >= totalCapacity; i--)
var loopEndIndex = currentCapacity + capacityDifference;
for (var i = currentCapacity - 1; i >= loopEndIndex; i--)
{ {
LogCat.LogWithFormat("hide_display_item", LogCat.LogLabel.ItemContainerDisplay, i);
var itemDisplay = ItemDisplayList[i]; var itemDisplay = ItemDisplayList[i];
itemDisplay.Update(null); itemDisplay.Update(null);
itemDisplay.HideSelf(); itemDisplay.HideSelf();
@ -65,7 +67,7 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay
} }
await Task.Yield(); await Task.Yield();
UpdateData(itemContainer, adjustedEndIndex); UpdateData(itemContainer, totalCapacity);
} }
private void OnItemDataChangeEvent(ItemDataChangeEvent itemDataChangeEvent) private void OnItemDataChangeEvent(ItemDataChangeEvent itemDataChangeEvent)
@ -111,6 +113,7 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay
/// </param> /// </param>
private void UpdateData(IItemContainer itemContainer, int endIndex, int startIndex = 0) 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++) for (var i = startIndex; i < endIndex; i++)
{ {
UpdateDataForSingleLocation(itemContainer, i); UpdateDataForSingleLocation(itemContainer, i);
@ -125,6 +128,7 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay
/// <param name="index"></param> /// <param name="index"></param>
private void UpdateDataForSingleLocation(IItemContainer itemContainer, int index) private void UpdateDataForSingleLocation(IItemContainer itemContainer, int index)
{ {
LogCat.LogWithFormat("update_display_item", LogCat.LogLabel.ItemContainerDisplay, index);
var itemDisplay = ItemDisplayList[index]; var itemDisplay = ItemDisplayList[index];
var item = itemContainer.GetItem(index); var item = itemContainer.GetItem(index);
if (item == null) if (item == null)