diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UIListBase.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UIListBase.cs
index c3ca2042..8a9773a5 100644
--- a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UIListBase.cs
+++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UIListBase.cs
@@ -277,7 +277,7 @@ namespace GameLogic
item.SetSelected(false);
}
- item = GetItem(m_selectIndex) as IListSelectItem;
+ item = GetItem(selectIndex) as IListSelectItem;
if (item != null)
{
item.SetSelected(true);
diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UILoopGridWidget.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UILoopGridWidget.cs
index 423b9de7..381dd406 100644
--- a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UILoopGridWidget.cs
+++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UILoopGridWidget.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using TEngine;
using UnityEngine;
namespace GameLogic
@@ -17,7 +18,7 @@ namespace GameLogic
///
/// Item字典
///
- private Dictionary m_itemCache = new Dictionary();
+ private GameFrameworkDictionary m_itemCache = new GameFrameworkDictionary();
///
/// 计算偏差后的ItemList
@@ -163,9 +164,19 @@ namespace GameLogic
m_items.Clear();
for (int i = 0; i < m_itemCache.Count; i++)
{
- m_items.Add(m_itemCache[i]);
+ m_items.Add(m_itemCache.GetValueByIndex(i));
}
return m_items;
}
+
+ ///
+ /// 获取Item。
+ ///
+ /// 索引。
+ /// TItem。
+ public TItem GetItemByIndex(int index)
+ {
+ return m_itemCache.GetValueByIndex(index);
+ }
}
}
diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UILoopListViewWidget.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UILoopListViewWidget.cs
index e2c1f3ae..c20af44d 100644
--- a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UILoopListViewWidget.cs
+++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UILoopListViewWidget.cs
@@ -8,7 +8,7 @@ namespace GameLogic
{
public LoopListView LoopRectView { private set; get; }
- private Dictionary m_itemCache = new Dictionary();
+ private GameFrameworkDictionary m_itemCache = new GameFrameworkDictionary();
public override void BindMemberProperty()
{
@@ -71,9 +71,8 @@ namespace GameLogic
List list = new List();
for (int i = 0; i < m_itemCache.Count; i++)
{
- list.Add(m_itemCache[i]);
+ list.Add(m_itemCache.GetValueByIndex(i));
}
-
return list;
}
@@ -85,11 +84,11 @@ namespace GameLogic
///
/// 获取Item。
///
- ///
- ///
+ /// 索引。
+ /// TItem。
public T GetItemByIndex(int index)
{
- return m_itemCache[index];
+ return m_itemCache.GetValueByIndex(index);
}
}
}
\ No newline at end of file
diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UILoopListWidget.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UILoopListWidget.cs
index a3e29c34..db7bea3e 100644
--- a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UILoopListWidget.cs
+++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/UI/Widget/UILoopListWidget.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using TEngine;
using UnityEngine;
namespace GameLogic
@@ -16,8 +17,9 @@ namespace GameLogic
///
/// Item字典
+ /// Key => GameObjectHashCode | Value => TItem.
///
- private Dictionary m_itemCache = new Dictionary();
+ private GameFrameworkDictionary m_itemCache = new GameFrameworkDictionary();
///
/// 计算偏差后的ItemList
@@ -159,7 +161,10 @@ namespace GameLogic
public List GetItemList()
{
m_items.Clear();
- m_items.AddRange(m_itemCache.Values);
+ for (int i = 0; i < m_itemCache.Count; i++)
+ {
+ m_items.Add(m_itemCache.GetValueByIndex(i));
+ }
return m_items;
}
@@ -171,5 +176,15 @@ namespace GameLogic
{
return LoopRectView.GetItemStartIndex();
}
+
+ ///
+ /// 获取Item。
+ ///
+ /// 索引。
+ /// TItem。
+ public TItem GetItemByIndex(int index)
+ {
+ return m_itemCache.GetValueByIndex(index);
+ }
}
}
diff --git a/UnityProject/Assets/TEngine/Runtime/Core/DataStruct/GameFrameworkDictionary.cs b/UnityProject/Assets/TEngine/Runtime/Core/DataStruct/GameFrameworkDictionary.cs
new file mode 100644
index 00000000..cb5e8a03
--- /dev/null
+++ b/UnityProject/Assets/TEngine/Runtime/Core/DataStruct/GameFrameworkDictionary.cs
@@ -0,0 +1,120 @@
+using System.Collections.Generic;
+
+namespace TEngine
+{
+ ///
+ /// 游戏框架字典类。
+ ///
+ /// 指定字典Key的元素类型。
+ /// 指定字典Value的元素类型。
+ public class GameFrameworkDictionary
+ {
+ protected readonly List KeyList = new List();
+ protected readonly Dictionary Dictionary = new Dictionary();
+
+ ///
+ /// 存储键的列表。
+ ///
+ public List Keys => KeyList;
+
+ ///
+ /// 存储字典实例。
+ ///
+ public int Count => KeyList.Count;
+
+ ///
+ /// 通过KEY的数组下标获取元素。
+ ///
+ /// 下标。
+ /// TValue。
+ public TValue GetValueByIndex(int index)
+ {
+ return Dictionary[KeyList[index]];
+ }
+
+ ///
+ /// 通过KEY的数组下标设置元素。
+ ///
+ /// 下标。
+ /// TValue。
+ public void SetValue(int index, TValue item)
+ {
+ Dictionary[KeyList[index]] = item;
+ }
+
+ ///
+ /// 字典索引器。
+ ///
+ /// TKey。
+ public TValue this[TKey key]
+ {
+ get => Dictionary[key];
+ set
+ {
+ if (!ContainsKey(key))
+ {
+ Add(key, value);
+ }
+ else
+ {
+ Dictionary[key] = value;
+ }
+ }
+ }
+
+ /// Removes all keys and values from the .
+ public void Clear()
+ {
+ KeyList.Clear();
+ Dictionary.Clear();
+ }
+
+ /// Adds the specified key and value to the dictionary.
+ /// The key of the element to add.
+ /// The value of the element to add. The value can be for reference types.
+ public virtual void Add(TKey key, TValue item)
+ {
+ KeyList.Add(key);
+ Dictionary.Add(key, item);
+ }
+
+ /// Gets the value associated with the specified key.
+ /// The key of the value to get.
+ /// When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the parameter. This parameter is passed uninitialized.
+ public bool TryGetValue(TKey key, out TValue value)
+ {
+ return Dictionary.TryGetValue(key, out value);
+ }
+
+ /// Determines whether the contains the specified key.
+ /// The key to locate in the
+ public bool ContainsKey(TKey key)
+ {
+ return Dictionary.ContainsKey(key);
+ }
+
+ public TKey GetKey(int index)
+ {
+ return KeyList[index];
+ }
+
+ public bool Remove(TKey key)
+ {
+ return KeyList.Remove(key) && Dictionary.Remove(key);
+ }
+ }
+
+ ///
+ /// 游戏框架顺序字典类。
+ ///
+ /// 指定字典Key的元素类型。
+ /// 指定字典Value的元素类型。
+ public class GameFrameworkSortedDictionary : GameFrameworkDictionary
+ {
+ public override void Add(TKey key, TValue item)
+ {
+ base.Add(key, item);
+ KeyList.Sort();
+ }
+ }
+}
\ No newline at end of file
diff --git a/UnityProject/Assets/TEngine/Runtime/Core/DataStruct/GameFrameworkDictionary.cs.meta b/UnityProject/Assets/TEngine/Runtime/Core/DataStruct/GameFrameworkDictionary.cs.meta
new file mode 100644
index 00000000..74d41812
--- /dev/null
+++ b/UnityProject/Assets/TEngine/Runtime/Core/DataStruct/GameFrameworkDictionary.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 3df785fede30420dbfa6acb2ff48c166
+timeCreated: 1698296076
\ No newline at end of file