diff --git a/Assets/Resources/Fgui/Main/Main_fui.bytes b/Assets/Resources/Fgui/Main/Main_fui.bytes index 26a80f03f..fc4cb8843 100644 Binary files a/Assets/Resources/Fgui/Main/Main_fui.bytes and b/Assets/Resources/Fgui/Main/Main_fui.bytes differ diff --git a/Assets/Scripts/UI/Bag/BagItem.cs b/Assets/Scripts/UI/Bag/BagItem.cs index 76d4d43cd..644b5bb47 100644 --- a/Assets/Scripts/UI/Bag/BagItem.cs +++ b/Assets/Scripts/UI/Bag/BagItem.cs @@ -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) diff --git a/Assets/Scripts/UI/Bag/BagPanel.cs b/Assets/Scripts/UI/Bag/BagPanel.cs index 18c0f2c5e..6e39cb2f2 100644 --- a/Assets/Scripts/UI/Bag/BagPanel.cs +++ b/Assets/Scripts/UI/Bag/BagPanel.cs @@ -37,6 +37,8 @@ namespace NBF ItemList.SetPanel(this); ItemList.SetData(tabItemList, true, true); + + BagSlotPanel.Show(); } private void OnUICanceled(string action) diff --git a/Assets/Scripts/UI/Bag/BagSlotItem.Designer.cs b/Assets/Scripts/UI/Bag/BagSlotItem.Designer.cs new file mode 100644 index 000000000..d2709da71 --- /dev/null +++ b/Assets/Scripts/UI/Bag/BagSlotItem.Designer.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/Bag/BagSlotItem.Designer.cs.meta b/Assets/Scripts/UI/Bag/BagSlotItem.Designer.cs.meta new file mode 100644 index 000000000..459aed913 --- /dev/null +++ b/Assets/Scripts/UI/Bag/BagSlotItem.Designer.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 6e8df720091e10e47a8068485beb5b1f \ No newline at end of file diff --git a/Assets/Scripts/UI/Bag/BagSlotItem.cs b/Assets/Scripts/UI/Bag/BagSlotItem.cs new file mode 100644 index 000000000..cbd01001f --- /dev/null +++ b/Assets/Scripts/UI/Bag/BagSlotItem.cs @@ -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; }); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/Bag/BagSlotItem.cs.meta b/Assets/Scripts/UI/Bag/BagSlotItem.cs.meta new file mode 100644 index 000000000..39732d0ad --- /dev/null +++ b/Assets/Scripts/UI/Bag/BagSlotItem.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: fbdf8a7405939fd4180c9480ff529c25 \ No newline at end of file diff --git a/Assets/Scripts/UI/Bag/BagSlotPanel.Designer.cs b/Assets/Scripts/UI/Bag/BagSlotPanel.Designer.cs new file mode 100644 index 000000000..a01dcb6bf --- /dev/null +++ b/Assets/Scripts/UI/Bag/BagSlotPanel.Designer.cs @@ -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 +{ + /// + 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(param); } + + public static void Hide(){ App.UI.HideUI(); } + + public static void Del(){ App.UI.DestroyUI(); } + + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/Bag/BagSlotPanel.Designer.cs.meta b/Assets/Scripts/UI/Bag/BagSlotPanel.Designer.cs.meta new file mode 100644 index 000000000..c00bf7565 --- /dev/null +++ b/Assets/Scripts/UI/Bag/BagSlotPanel.Designer.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: b20e20ff411c89e42a2bf35a499a5aed \ No newline at end of file diff --git a/Assets/Scripts/UI/Bag/BagSlotPanel.cs b/Assets/Scripts/UI/Bag/BagSlotPanel.cs new file mode 100644 index 000000000..1ae35bf40 --- /dev/null +++ b/Assets/Scripts/UI/Bag/BagSlotPanel.cs @@ -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 _items = new List(); + + protected override void OnInit() + { + // List.SetVirtual(); + } + + protected override void OnShow() + { + SetList(); + } + + private void SetList() + { + + + var role = App.Main.GetComponent(); + var roleBag = role.GetComponent(); + _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; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/Bag/BagSlotPanel.cs.meta b/Assets/Scripts/UI/Bag/BagSlotPanel.cs.meta new file mode 100644 index 000000000..a886ff440 --- /dev/null +++ b/Assets/Scripts/UI/Bag/BagSlotPanel.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 1d010d83455eca34ab24068d41400c1d \ No newline at end of file diff --git a/Assets/Scripts/UI/Binders/MainBinder.cs b/Assets/Scripts/UI/Binders/MainBinder.cs index c83a8b446..4bc8253aa 100644 --- a/Assets/Scripts/UI/Binders/MainBinder.cs +++ b/Assets/Scripts/UI/Binders/MainBinder.cs @@ -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)); } } diff --git a/FGUIProject/assets/Main/Bag/BagSlotItem.xml b/FGUIProject/assets/Main/Bag/BagSlotItem.xml new file mode 100644 index 000000000..59bc87c6d --- /dev/null +++ b/FGUIProject/assets/Main/Bag/BagSlotItem.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + +