主界面相关

This commit is contained in:
bob
2025-06-03 14:28:20 +08:00
parent 8ba78d5d1c
commit 9334999332
43 changed files with 534 additions and 14 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5592fb43d74d441cad5b1867e7e5b373
timeCreated: 1748922642

View File

@@ -0,0 +1,24 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址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 BagPanel
{
public GObject this[string aKey] => ContentPane.GetChild(aKey);
[AutoFind(Name = "back")]
public GImage back;
[AutoFind(Name = "Menu")]
public CommonMenu Menu;
[AutoFind(Name = "BottomMenu")]
public BottomMenu BottomMenu;
public override string[] GetDependPackages(){ return new string[] {"Common"}; }
}
}

View File

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

View File

@@ -0,0 +1,110 @@
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using UnityEngine;
using NBC;
namespace NBF
{
public partial class BagPanel : UIPanel
{
public override string UIPackName => "Main";
public override string UIResName => "BagPanel";
protected override void OnInit()
{
base.OnInit();
Menu.OnTabChange += ChangeTab;
}
protected override void OnShow()
{
InputManager.OnUICanceled += OnUICanceled;
UseBottomMenu();
}
private void OnUICanceled(string action)
{
if (action == InputDef.UI.SubPrev)
{
}
else if (action == InputDef.UI.SubNext)
{
}
else if (action == InputDef.UI.Up)
{
}
else if (action == InputDef.UI.Down)
{
}
}
private void ChangeTab(int index)
{
if (index < 0) return;
Log.Info($"Change tab index={index}");
}
private void UseBottomMenu()
{
BottomMenu.OnTab += () =>
{
var i = Random.Range(1, 13);
if (i < 3)
{
Notices.Success("离开晶科科技看就看");
}
else if (i < 6)
{
Notices.Warning("离开晶科科技看就看");
}
else if (i < 9)
{
Notices.Error("离开晶科科技看就看");
}
else if (i < 12)
{
Notices.Info("离开晶科科技看就看");
}
};
BottomMenu.OnBack += OnBack;
BottomMenu.OnEnter += OnApplySettings;
BottomMenu.Use();
}
private void OnApplySettings()
{
}
private void OnBack()
{
if (Settings.Instance.HaveNotAppleSettings())
{
MessageBox.Show("还有未保存的信息", (b) =>
{
if (b)
{
Hide();
}
});
}
else
{
Hide();
}
}
protected override void OnHide()
{
BottomMenu.OnBack -= OnBack;
// BottomMenu.OnTab -= OnResetSettings;
BottomMenu.OnEnter -= OnApplySettings;
BottomMenu.UnUse();
InputManager.OnUICanceled -= OnUICanceled;
}
protected override void OnDestroy()
{
base.OnDestroy();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 06f449f341e3a19438e38e1038fd25d5

View File

@@ -10,6 +10,9 @@ namespace NBF
{
UIObjectFactory.SetPackageItemExtension(SettingItem.URL, typeof(SettingItem));
UIObjectFactory.SetPackageItemExtension(IntroduceTag.URL, typeof(IntroduceTag));
UIObjectFactory.SetPackageItemExtension(HomeMainPage.URL, typeof(HomeMainPage));
UIObjectFactory.SetPackageItemExtension(HomeActivityPage.URL, typeof(HomeActivityPage));
UIObjectFactory.SetPackageItemExtension(HomeRankPage.URL, typeof(HomeRankPage));
UIObjectFactory.SetPackageItemExtension(HomeButtonGroups.URL, typeof(HomeButtonGroups));
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b5d30c3ef7804f5e9f690e364ef1afe9
timeCreated: 1748923189

View File

@@ -26,6 +26,10 @@ namespace NBF
{
UI.Inst.OpenUI<SettingPanel>();
}
else if (btn == BtnBag)
{
UI.Inst.OpenUI<BagPanel>();
}
}
}
}

View File

@@ -11,12 +11,10 @@ namespace NBF
public partial class HomePanel
{
public GObject this[string aKey] => ContentPane.GetChild(aKey);
[AutoFind(Name = "Pages")]
public GComponent Pages;
[AutoFind(Name = "Menu")]
public CommonMenu Menu;
[AutoFind(Name = "BottomMenu")]
public BottomMenu BottomMenu;
[AutoFind(Name = "OpGroup")]
public HomeButtonGroups OpGroup;
public override string[] GetDependPackages(){ return new string[] {"Common"}; }

View File

@@ -1,7 +1,10 @@
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using System.Collections.Generic;
using FairyGUI;
using UnityEngine;
using NBC;
using UIPanel = NBC.UIPanel;
namespace NBF
{
@@ -9,20 +12,80 @@ namespace NBF
{
public override string UIPackName => "Main";
public override string UIResName => "HomePanel";
private string[] PageNames = new[] { "HomeMainPage", "HomeActivityPage", "HomeRankPage" };
private List<HomePageBase> _pages = new List<HomePageBase>();
private HomePageBase _currentPage;
private List<TabListData> tabList = new List<TabListData>();
protected override void OnInit()
{
base.OnInit();
foreach (var group in PageNames)
{
var tab = new TabListData
{
Name = group
};
tabList.Add(tab);
}
Menu.OnTabChange += ChangeTab;
}
protected override void OnShow()
{
base.OnShow();
Menu.SetTabs(tabList);
ChangeTab(0);
}
#region Tab切换
private void ChangeTab(int index)
{
if (index < 0) return;
Log.Info($"Change tab index={index}");
foreach (var page in _pages)
{
page.Hide();
}
var nowPage = GetPage(index);
if (nowPage != null)
{
nowPage.Show();
_currentPage = nowPage;
}
}
private HomePageBase GetPage(int index)
{
var page = _pages.Find(t => t.Page == index);
if (page == null)
{
var pageName = PageNames[index];
var pageObject = UIPackage.CreateObject(UIPackName, pageName);
if (pageObject is HomePageBase homePage)
{
Pages.AddChild(homePage);
_pages.Add(homePage);
return homePage;
}
return null;
}
return page;
}
#endregion
protected override void OnHide()
{
base.OnHide();
}
protected override void OnDestroy()

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1f5d43fc98c14648867dc3b696917e65
timeCreated: 1748923139

View File

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

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5cee4ebc54c0f434f9443cee69971ab3

View File

@@ -0,0 +1,23 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class HomeActivityPage : HomePageBase
{
private void OnInited()
{
}
protected override void OnShow()
{
}
protected override void OnHide()
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 7341727571ae65c4bbc3ce2bd9a94e8b

View File

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

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 044cd5f648db2c94ea89ef77f1891ed4

View File

@@ -0,0 +1,64 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class HomeMainPage : HomePageBase
{
private void OnInited()
{
}
protected override void OnShow()
{
InputManager.OnUICanceled += OnUICanceled;
UseBottomMenu();
}
protected override void OnHide()
{
BottomMenu.OnBack -= OnBack;
BottomMenu.OnEnter -= OnApplySettings;
BottomMenu.UnUse();
InputManager.OnUICanceled -= OnUICanceled;
}
private void OnUICanceled(string action)
{
if (action == InputDef.UI.SubPrev)
{
}
else if (action == InputDef.UI.SubNext)
{
}
else if (action == InputDef.UI.Up)
{
}
else if (action == InputDef.UI.Down)
{
}
}
private void UseBottomMenu()
{
BottomMenu.OnBack += OnBack;
BottomMenu.OnEnter += OnApplySettings;
BottomMenu.Use();
}
private void OnApplySettings()
{
}
private void OnBack()
{
UI.Inst.HideUI<HomePanel>();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 648dd38953354c94a89c7c23d24abeb3

View File

@@ -0,0 +1,48 @@
using FairyGUI;
namespace NBF
{
public abstract class HomePageBase : GComponent
{
public int Page;
public void Show()
{
ShowAnimation();
OnShow();
}
public void Hide()
{
if (visible)
{
HideAnimation();
OnHide();
}
}
#region Anim
private void ShowAnimation()
{
visible = true;
alpha = 0;
GTween.Kill(this);
TweenFade(1, 0.5f);
}
private void HideAnimation()
{
GTween.Kill(this);
TweenFade(0, 0.2f).OnComplete(() =>
{
visible = false;
});
}
#endregion
protected abstract void OnShow();
protected abstract void OnHide();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fb0a4fb73e0c4eafa11ab8028331637b
timeCreated: 1748925820

View File

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

View File

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

View File

@@ -0,0 +1,25 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class HomeRankPage : HomePageBase
{
private void OnInited()
{
}
protected override void OnShow()
{
}
protected override void OnHide()
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 40506befb27a31a4786085ec5416efc7

View File

@@ -94,7 +94,6 @@ namespace NBF
}
};
BottomMenu.OnBack += OnBack;
// BottomMenu.OnTab += OnResetSettings;
BottomMenu.OnEnter += OnApplySettings;
BottomMenu.Use();
}