mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
修复循环列表主动GetItemByIndex和GetItemList的问题
修复循环列表主动GetItemByIndex和GetItemList的问题
This commit is contained in:
@@ -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);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GameLogic
|
||||
@@ -17,7 +18,7 @@ namespace GameLogic
|
||||
/// <summary>
|
||||
/// Item字典
|
||||
/// </summary>
|
||||
private Dictionary<int, TItem> m_itemCache = new Dictionary<int, TItem>();
|
||||
private GameFrameworkDictionary<int, TItem> m_itemCache = new GameFrameworkDictionary<int, TItem>();
|
||||
|
||||
/// <summary>
|
||||
/// 计算偏差后的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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取Item。
|
||||
/// </summary>
|
||||
/// <param name="index">索引。</param>
|
||||
/// <returns>TItem。</returns>
|
||||
public TItem GetItemByIndex(int index)
|
||||
{
|
||||
return m_itemCache.GetValueByIndex(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ namespace GameLogic
|
||||
{
|
||||
public LoopListView LoopRectView { private set; get; }
|
||||
|
||||
private Dictionary<int, T> m_itemCache = new Dictionary<int, T>();
|
||||
private GameFrameworkDictionary<int, T> m_itemCache = new GameFrameworkDictionary<int, T>();
|
||||
|
||||
public override void BindMemberProperty()
|
||||
{
|
||||
@@ -71,9 +71,8 @@ namespace GameLogic
|
||||
List<T> list = new List<T>();
|
||||
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
|
||||
/// <summary>
|
||||
/// 获取Item。
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="index">索引。</param>
|
||||
/// <returns>TItem。</returns>
|
||||
public T GetItemByIndex(int index)
|
||||
{
|
||||
return m_itemCache[index];
|
||||
return m_itemCache.GetValueByIndex(index);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GameLogic
|
||||
@@ -16,8 +17,9 @@ namespace GameLogic
|
||||
|
||||
/// <summary>
|
||||
/// Item字典
|
||||
/// <remarks>Key => GameObjectHashCode | Value => TItem.</remarks>
|
||||
/// </summary>
|
||||
private Dictionary<int, TItem> m_itemCache = new Dictionary<int, TItem>();
|
||||
private GameFrameworkDictionary<int, TItem> m_itemCache = new GameFrameworkDictionary<int, TItem>();
|
||||
|
||||
/// <summary>
|
||||
/// 计算偏差后的ItemList
|
||||
@@ -159,7 +161,10 @@ namespace GameLogic
|
||||
public List<TItem> 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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取Item。
|
||||
/// </summary>
|
||||
/// <param name="index">索引。</param>
|
||||
/// <returns>TItem。</returns>
|
||||
public TItem GetItemByIndex(int index)
|
||||
{
|
||||
return m_itemCache.GetValueByIndex(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user