拖动物品到快速使用

This commit is contained in:
2025-11-17 00:06:20 +08:00
parent f33fa8bcc5
commit d18c32211c
17 changed files with 211 additions and 0 deletions

View File

@@ -14,6 +14,12 @@ namespace NBF
private void OnInited()
{
draggable = true;
onDragStart.Add(context =>
{
context.PreventDefault();
DragDropManager.inst.StartDrag(this, this.icon, this.icon, (int)context.data);
});
}
public virtual void SetData(ItemInfo itemInfo)

View File

@@ -37,6 +37,8 @@ namespace NBF
ItemList.SetPanel(this);
ItemList.SetData(tabItemList, true, true);
BagSlotPanel.Show();
}
private void OnUICanceled(string action)

View File

@@ -0,0 +1,31 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class BagSlotItem
{
public const string URL = "ui://hxr7rc7puiwj1t";
public GImage back;
public GTextField TextIndex;
public GTextField TextCount;
public GImage Quality;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
back = (GImage)GetChild("back");
TextIndex = (GTextField)GetChild("TextIndex");
TextCount = (GTextField)GetChild("TextCount");
Quality = (GImage)GetChild("Quality");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6e8df720091e10e47a8068485beb5b1f

View File

@@ -0,0 +1,16 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class BagSlotItem : GButton
{
private void OnInited()
{
onDrop.Add(context => { this.icon = (string)context.data; });
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fbdf8a7405939fd4180c9480ff529c25

View File

@@ -0,0 +1,36 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
using System.Collections.Generic;
namespace NBF
{
/// <summary> </summary>
public partial class BagSlotPanel
{
public GObject this[string aKey] => ContentPane.GetChild(aKey);
public override string UIPackName => "Main";
public override string UIResName => "BagSlotPanel";
[AutoFind(Name = "back")]
public GLabel back;
[AutoFind(Name = "SlotTitle")]
public GComponent SlotTitle;
[AutoFind(Name = "List")]
public GList List;
[AutoFind(Name = "SlotList")]
public GList SlotList;
[AutoFind(Name = "SlotSeparator")]
public GImage SlotSeparator;
public override string[] GetDependPackages(){ return new string[] {"Common"}; }
public static void Show(object param = null){ App.UI.OpenUI<BagSlotPanel>(param); }
public static void Hide(){ App.UI.HideUI<BagSlotPanel>(); }
public static void Del(){ App.UI.DestroyUI<BagSlotPanel>(); }
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b20e20ff411c89e42a2bf35a499a5aed

View File

@@ -0,0 +1,67 @@
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using System.Collections.Generic;
using FairyGUI;
using Fantasy;
using UnityEngine;
using NBC;
using NBF.Fishing2;
using UIPanel = NBC.UIPanel;
namespace NBF
{
public partial class BagSlotPanel : UIPanel
{
private List<ItemInfo> _items = new List<ItemInfo>();
protected override void OnInit()
{
// List.SetVirtual();
}
protected override void OnShow()
{
SetList();
}
private void SetList()
{
var role = App.Main.GetComponent<Role>();
var roleBag = role.GetComponent<RoleBag>();
_items.Clear();
foreach (var roleBagItem in roleBag.Items)
{
if (CanShow(roleBagItem))
{
_items.Add(roleBagItem);
}
}
List.RemoveChildrenToPool();
List.itemRenderer = OnRenderItem;
List.numItems = _items.Count;
}
void OnRenderItem(int index, GObject obj)
{
var itemData = _items[index];
if (obj is BagItem bagItem)
{
bagItem.SetData(itemData);
}
}
private bool CanShow(ItemInfo itemInfo)
{
if (itemInfo.ItemType == ItemType.Rod)
{
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1d010d83455eca34ab24068d41400c1d

View File

@@ -24,6 +24,7 @@ namespace NBF
UIObjectFactory.SetPackageItemExtension(ItemBasicInfoTag.URL, typeof(ItemBasicInfoTag));
UIObjectFactory.SetPackageItemExtension(ItemGearInfoTag.URL, typeof(ItemGearInfoTag));
UIObjectFactory.SetPackageItemExtension(ShopGearItem.URL, typeof(ShopGearItem));
UIObjectFactory.SetPackageItemExtension(BagSlotItem.URL, typeof(BagSlotItem));
UIObjectFactory.SetPackageItemExtension(BagItem.URL, typeof(BagItem));
}
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<component size="150,150" extention="Button">
<displayList>
<image id="n8_uiwj" name="back" src="kryob" fileName="Images/Square.png" pkg="6hgkvlau" xy="0,0" size="150,150" alpha="0.2" color="#5c748b"/>
<loader id="n10_uiwj" name="icon" xy="21,18" size="110,110" align="center" vAlign="middle" fill="scale" shrinkOnly="true" clearOnPublish="true">
<relation target="" sidePair="center-center,top-top"/>
</loader>
<text id="n9_uiwj" name="TextIndex" xy="5,5" size="19,35" fontSize="25" color="#ffffff" text="1"/>
<text id="n11_uiwj" name="TextCount" xy="98,111" pivot="1,1" size="44,33" fontSize="23" color="#ffffff" align="right" text="999"/>
<image id="n12_uiwj" name="Quality" src="kryob" fileName="Images/Square.png" pkg="6hgkvlau" xy="0,148" size="150,2" color="#ff6c00"/>
</displayList>
<Button/>
</component>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<component size="1920,1080">
<displayList>
<component id="n0_lvql" name="back" src="xd2fmf" fileName="Com/Back/Back2.xml" pkg="6hgkvlau" xy="0,0" size="1920,1080">
<relation target="" sidePair="width-width,height-height"/>
</component>
<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="multiple" overflow="hidden" scrollBarRes="ui://6hgkvlauoomej," clipSoftness="10,10" lineGap="20" colGap="20" defaultItem="ui://hxr7rc7puq3a1h" autoClearItems="true" foldInvisibleItems="true">
<relation target="" sidePair="width-width,height-height"/>
<item url="ui://hxr7rc7poome9"/>
</list>
<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">
<item/>
<item/>
<item/>
<item/>
<item/>
<item/>
<item/>
</list>
<image id="n14_uiwj" name="SlotSeparator" src="kryob" fileName="Images/Square.png" pkg="6hgkvlau" xy="36,891" pivot="0.5,0.5" size="1846,1" alpha="0.5" color="#5c748b">
<relation target="" sidePair="width-width,center-center,bottom-bottom"/>
</image>
</displayList>
</component>

View File

@@ -87,6 +87,8 @@
<image id="r03uq" name="20250521222909_1.jpg" path="/Shop/x效果图/"/>
<component id="fcfg8" name="FishingShopPanel.xml" path="/Shop/" exported="true"/>
<component id="uiwj1s" name="BagSelectPanel.xml" path="/Bag/" exported="true"/>
<component id="uiwj1t" name="BagSlotItem.xml" path="/Bag/" exported="true"/>
<component id="uiwj1u" name="BagSlotPanel.xml" path="/Bag/" exported="true"/>
</resources>
<publish name="" path="../Assets/Resources/Fgui/Main" packageCount="2" genCode="true"/>
</packageDescription>

View File

@@ -0,0 +1 @@
{"url":"ui://hxr7rc7puiwj1t","name":"BagSlotItem","scriptType":"component","isCustomName":false,"customName":"","annotation":"","member":{}}

View File

@@ -0,0 +1 @@
{"url":"ui://hxr7rc7puiwj1u","name":"BagSlotPanel","scriptType":"panel","isCustomName":false,"customName":"","annotation":"","member":{}}