完成快速选中相关内容
This commit is contained in:
Binary file not shown.
@@ -34,6 +34,8 @@ namespace NBF.Fishing2
|
||||
}
|
||||
}
|
||||
|
||||
#region 获取物品列表
|
||||
|
||||
public List<ItemInfo> GetItemsByType(ItemType itemType)
|
||||
{
|
||||
return Items.Where(item => item.ItemType == itemType).ToList();
|
||||
@@ -62,6 +64,33 @@ namespace NBF.Fishing2
|
||||
return dic;
|
||||
}
|
||||
|
||||
public List<object> GetItemListData(params ItemType[] itemTypes)
|
||||
{
|
||||
var dic = GetItemsByType();
|
||||
|
||||
if (itemTypes == null || itemTypes.Length == 0)
|
||||
{
|
||||
itemTypes = new ItemType[] { ItemType.Rod, ItemType.Bobber, ItemType.Reel };
|
||||
}
|
||||
|
||||
List<object> items = new List<object>();
|
||||
|
||||
foreach (var (type, list) in dic)
|
||||
{
|
||||
if (!itemTypes.Contains(type)) continue;
|
||||
var typeItem = new ClassifyListTitleData()
|
||||
{
|
||||
Title = type.ToString()
|
||||
};
|
||||
items.Add(typeItem);
|
||||
items.AddRange(list);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public List<ItemInfo> GetBindItems(long itemId)
|
||||
{
|
||||
List<ItemInfo> ret = new List<ItemInfo>();
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace NBF
|
||||
UIConfig.verticalScrollBar = "ui://6hgkvlauoomej";
|
||||
UIConfig.defaultFont = "AlibabaPuHuiTi-3-Medium";
|
||||
App.UI.SetUILanguage<UILangeageConfig>();
|
||||
UIConfig.modalLayerColor = new Color(0, 0, 0, 0.9f);
|
||||
UIConfig.modalLayerColor = new Color(0, 0, 0, 0.99f);
|
||||
AddUIPackages();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace NBF
|
||||
private void OnInited()
|
||||
{
|
||||
onDragStart.Add(DragStart);
|
||||
// Oncl
|
||||
}
|
||||
|
||||
|
||||
|
||||
4
Assets/Scripts/UI/Bag/BagSelectPanel.Designer.cs
generated
4
Assets/Scripts/UI/Bag/BagSelectPanel.Designer.cs
generated
@@ -18,12 +18,12 @@ namespace NBF
|
||||
public GImage back;
|
||||
[AutoFind(Name = "box")]
|
||||
public GImage box;
|
||||
[AutoFind(Name = "List")]
|
||||
public GList List;
|
||||
[AutoFind(Name = "BtnCancel")]
|
||||
public BtnTitleInputControl BtnCancel;
|
||||
[AutoFind(Name = "BtnConfirm")]
|
||||
public BtnTitleInputControl BtnConfirm;
|
||||
[AutoFind(Name = "List")]
|
||||
public ClassifyList List;
|
||||
public override string[] GetDependPackages(){ return new string[] {"Common"}; }
|
||||
|
||||
public static void Show(object param = null){ App.UI.OpenUI<BagSelectPanel>(param); }
|
||||
|
||||
@@ -15,26 +15,46 @@ namespace NBF
|
||||
{
|
||||
//context.data
|
||||
private static Action<long> _selectCallBack;
|
||||
private static ItemType _itemType;
|
||||
private List<ItemInfo> _items;
|
||||
|
||||
public static void Show(ItemType itemType, Action<long> callBack)
|
||||
// private static ItemType _itemType;
|
||||
private static readonly List<ItemType> _itemTypes = new List<ItemType>();
|
||||
private long _selectedId;
|
||||
// private List<ItemInfo> _items;
|
||||
|
||||
// public static void Show(ItemType itemType, Action<long> callBack)
|
||||
// {
|
||||
// Show(new[] { itemType }, callBack);
|
||||
// }
|
||||
|
||||
public static void Show(Action<long> callBack, params ItemType[] itemTypes)
|
||||
{
|
||||
_itemType = itemType;
|
||||
_itemTypes.Clear();
|
||||
_itemTypes.AddRange(itemTypes);
|
||||
_selectCallBack = callBack;
|
||||
// List
|
||||
Show();
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
IsModal = true;
|
||||
this.AutoAddClick(OnClick);
|
||||
List.OnDoubleClickItem += OnDoubleClickItem;
|
||||
List.OnClickItem += OnClickItem;
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
{
|
||||
_selectedId = 0;
|
||||
SetList();
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
List.OnClickItem -= OnClickItem;
|
||||
List.OnDoubleClickItem -= OnDoubleClickItem;
|
||||
}
|
||||
|
||||
private void OnClick(GComponent btn)
|
||||
{
|
||||
if (btn == BtnCancel)
|
||||
@@ -43,12 +63,29 @@ namespace NBF
|
||||
}
|
||||
else if (btn == BtnConfirm)
|
||||
{
|
||||
var selectIndex = List.selectedIndex;
|
||||
if (selectIndex >= 0)
|
||||
if (_selectedId > 0)
|
||||
{
|
||||
var itemData = _items[selectIndex];
|
||||
_selectCallBack?.Invoke(itemData.Id);
|
||||
_selectCallBack?.Invoke(_selectedId);
|
||||
}
|
||||
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClickItem(object item)
|
||||
{
|
||||
if (item is BagItem bagItem)
|
||||
{
|
||||
_selectedId = bagItem.ItemInfo.Id;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDoubleClickItem(object item)
|
||||
{
|
||||
if (item is BagItem bagItem)
|
||||
{
|
||||
_selectedId = bagItem.ItemInfo.Id;
|
||||
_selectCallBack?.Invoke(bagItem.ItemInfo.Id);
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
@@ -57,24 +94,9 @@ namespace NBF
|
||||
{
|
||||
var role = App.Main.GetComponent<Role>();
|
||||
var roleBag = role.GetComponent<RoleBag>();
|
||||
|
||||
_items = roleBag.GetItemsByType(_itemType);
|
||||
|
||||
List.RemoveChildrenToPool();
|
||||
List.defaultItem = BagItem.URL;
|
||||
List.itemRenderer = OnRenderItem;
|
||||
List.selectionMode = ListSelectionMode.Single;
|
||||
|
||||
List.numItems = _items.Count;
|
||||
}
|
||||
|
||||
void OnRenderItem(int index, GObject obj)
|
||||
{
|
||||
var itemData = _items[index];
|
||||
if (obj is BagItem bagItem)
|
||||
{
|
||||
bagItem.SetData(itemData);
|
||||
}
|
||||
|
||||
List<object> items = roleBag.GetItemListData();
|
||||
List.SetListData(items);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ namespace NBF
|
||||
private void OnRemove(EventContext context)
|
||||
{
|
||||
context.PreventDefault();
|
||||
context.StopPropagation();
|
||||
OnChangeSlot?.Invoke(Index, 0);
|
||||
}
|
||||
|
||||
|
||||
2
Assets/Scripts/UI/Bag/BagSlotPanel.Designer.cs
generated
2
Assets/Scripts/UI/Bag/BagSlotPanel.Designer.cs
generated
@@ -19,7 +19,7 @@ namespace NBF
|
||||
[AutoFind(Name = "SlotTitle")]
|
||||
public GComponent SlotTitle;
|
||||
[AutoFind(Name = "List")]
|
||||
public GList List;
|
||||
public ClassifyList List;
|
||||
[AutoFind(Name = "SlotList")]
|
||||
public GList SlotList;
|
||||
[AutoFind(Name = "SlotSeparator")]
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace NBF
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
SlotList.onClickItem.Add(OnClickSlotItem);
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
@@ -41,26 +42,31 @@ namespace NBF
|
||||
}
|
||||
}
|
||||
|
||||
List.RemoveChildrenToPool();
|
||||
List.itemRenderer = OnRenderItem;
|
||||
|
||||
List.numItems = _items.Count;
|
||||
}
|
||||
|
||||
void OnRenderItem(int index, GObject obj)
|
||||
{
|
||||
var itemData = _items[index];
|
||||
if (obj is BagItem bagItem)
|
||||
List<object> items = _roleBag.GetItemListData();
|
||||
List.SetListData(items);
|
||||
var children = List.List.GetChildren();
|
||||
foreach (var gObject in children)
|
||||
{
|
||||
bagItem.SetData(itemData);
|
||||
bagItem.draggable = true;
|
||||
gObject.draggable = true;
|
||||
}
|
||||
}
|
||||
|
||||
// void OnRenderItem(int index, GObject obj)
|
||||
// {
|
||||
// var itemData = _items[index];
|
||||
// if (obj is BagItem bagItem)
|
||||
// {
|
||||
// bagItem.SetData(itemData);
|
||||
// bagItem.draggable = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
#region 快速选择列表
|
||||
|
||||
private int _lastSelectedItem;
|
||||
|
||||
private void SetSlotList()
|
||||
{
|
||||
SlotList.RemoveChildrenToPool();
|
||||
@@ -86,6 +92,21 @@ namespace NBF
|
||||
// SlotList.RefreshVirtualList();
|
||||
}
|
||||
|
||||
private void OnClickSlotItem(EventContext context)
|
||||
{
|
||||
if (context.data is BagSlotItem bagSlotItem)
|
||||
{
|
||||
_lastSelectedItem = bagSlotItem.Index;
|
||||
BagSelectPanel.Show(SelectCallback, ItemType.Rod, ItemType.Bobber, ItemType.Reel);
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectCallback(long selectId)
|
||||
{
|
||||
if (selectId < 1) return;
|
||||
_roleBag.SetSlot(_lastSelectedItem, selectId).OnCompleted(OnChangeSlotItemDone);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private bool CanShow(ItemInfo itemInfo)
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace NBF
|
||||
{
|
||||
if (context.data is not BagGearItem item) return;
|
||||
_lastSelectedItem = item;
|
||||
BagSelectPanel.Show(item.BindData.Type, SelectCallback);
|
||||
BagSelectPanel.Show(SelectCallback, item.BindData.Type);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace NBF
|
||||
private readonly List<object> _listData = new List<object>();
|
||||
|
||||
public event Action<object> OnClickItem;
|
||||
public event Action<object> OnDoubleClickItem;
|
||||
|
||||
private int _columnsCount;
|
||||
|
||||
@@ -98,6 +99,10 @@ namespace NBF
|
||||
void OnClickListItem(EventContext context)
|
||||
{
|
||||
OnClickItem?.Invoke(context.data);
|
||||
if (context.inputEvent.isDoubleClick)
|
||||
{
|
||||
OnDoubleClickItem?.Invoke(context.data);
|
||||
}
|
||||
}
|
||||
|
||||
void OnRenderItem(int index, GObject obj)
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<component size="1920,1080">
|
||||
<displayList>
|
||||
<component id="n7_uiwj" name="n7" src="8hy8la" fileName="Com/Back/Back1.xml" pkg="6hgkvlau" xy="0,0">
|
||||
<relation target="" sidePair="width-width,height-height"/>
|
||||
</component>
|
||||
<image id="n3_uiwj" name="back" src="kryob" fileName="Images/Square.png" pkg="6hgkvlau" xy="348,102" size="1224,820" color="#08101b">
|
||||
<relation target="" sidePair="center-center,middle-middle"/>
|
||||
</image>
|
||||
@@ -13,18 +10,6 @@
|
||||
<image id="n1_uiwj" name="n1" src="kryob" fileName="Images/Square.png" pkg="6hgkvlau" xy="349,829" size="1222,2" alpha="0.3" color="#8bf3ff">
|
||||
<relation target="n2_uiwj" sidePair="center-center,bottom-bottom"/>
|
||||
</image>
|
||||
<list id="n0_uiwj" name="List" xy="357,112" size="1205,705" layout="flow_hz" overflow="scroll" lineGap="20" colGap="20" defaultItem="ui://hxr7rc7puq3a1h" autoClearItems="true">
|
||||
<relation target="n2_uiwj" sidePair="center-center,middle-middle"/>
|
||||
<item/>
|
||||
<item/>
|
||||
<item/>
|
||||
<item/>
|
||||
<item/>
|
||||
<item/>
|
||||
<item/>
|
||||
<item/>
|
||||
<item/>
|
||||
</list>
|
||||
<component id="n5_uiwj" name="BtnCancel" src="r03uj0" fileName="Com/Buttons/BtnTitleInputControl.xml" pkg="6hgkvlau" xy="717,859" size="85,32">
|
||||
<relation target="" sidePair="center-center,middle-middle"/>
|
||||
<Button title="退出" icon="ui://6hgkvlau9mf1jw"/>
|
||||
@@ -33,5 +18,6 @@
|
||||
<relation target="" sidePair="center-center,middle-middle"/>
|
||||
<Button title="继续"/>
|
||||
</component>
|
||||
<component id="n8_uiwj" name="List" src="drkwh1" fileName="Com/ClassifyList.xml" pkg="6hgkvlau" xy="359,115" size="1197,703"/>
|
||||
</displayList>
|
||||
</component>
|
||||
@@ -7,10 +7,9 @@
|
||||
<component id="n6_uiwj" name="SlotTitle" src="r6aumd" fileName="Com/CommonTitle.xml" pkg="6hgkvlau" xy="0,0">
|
||||
<relation target="" sidePair="width-width,top-top"/>
|
||||
</component>
|
||||
<list id="n7_uiwj" name="List" xy="37,111" size="1846,775" layout="flow_hz" selectionMode="none" overflow="scroll" scrollBarFlags="4" scrollBarRes="ui://6hgkvlauoomej," clipSoftness="10,10" lineGap="20" colGap="20" defaultItem="ui://hxr7rc7puq3a1h" autoClearItems="true" foldInvisibleItems="true">
|
||||
<component id="n7_uiwj" name="List" src="drkwh1" fileName="Com/ClassifyList.xml" pkg="6hgkvlau" xy="37,111" size="1846,775">
|
||||
<relation target="" sidePair="width-width,height-height"/>
|
||||
<item url="ui://hxr7rc7poome9"/>
|
||||
</list>
|
||||
</component>
|
||||
<list id="n13_uiwj" name="SlotList" xy="38,901" size="1831,153" layout="row" overflow="hidden" lineGap="8" colGap="40" defaultItem="ui://hxr7rc7puiwj1t" align="center" autoClearItems="true">
|
||||
<item/>
|
||||
<item/>
|
||||
|
||||
Reference in New Issue
Block a user