首次提交

This commit is contained in:
Bob.Song
2026-03-05 18:07:55 +08:00
commit e125bb869e
4534 changed files with 563920 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
using NBC;
namespace NBF
{
public static class Loading
{
// /// <summary>
// /// 显示loading
// /// </summary>
// /// <param name="task">加载任务链</param>
// /// <param name="style">样式</param>
// /// <param name="startProgress">开始进度</param>
// public static void Show(NTask task = null, int style = 0, int startProgress = 0)
// {
// if (task != null)
// {
// //如果传入了任务进度
// LoadingPanel.LoadingTask.Add(task);
// }
// else
// {
// var waitTask = new LoadingWaitTask<LoadingPanel>();
// waitTask.Run(DefRunner.Scheduler);
// LoadingPanel.LoadingTask.Add(waitTask);
// }
//
// var panel = UI.Inst.GetUI<LoadingPanel>();
// if (panel is not { IsShowing: true })
// {
// LoadingPanel.Show(new LoadingShowParam(style, startProgress));
// }
// }
//
// public static void Hide()
// {
// LoadingPanel.LoadingTask.TryEnd();
// }
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 80dbf01ca4c94d14a5d5309c66bb30e9
timeCreated: 1742568101

View File

@@ -0,0 +1,32 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址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 LoadingPanel
{
public GObject this[string aKey] => ContentPane.GetChild(aKey);
public override string UIPackName => "Load";
public override string UIResName => "LoadingPanel";
[AutoFind(Name = "back")]
public GLoader back;
[AutoFind(Name = "Progress")]
public GProgressBar Progress;
[AutoFind(Name = "TextLoading")]
public GTextField TextLoading;
public override string[] GetDependPackages(){ return new string[] {}; }
public static void Show(object param = null){ UI.Inst.OpenUI<LoadingPanel>(param); }
public static void Hide(){ UI.Inst.HideUI<LoadingPanel>(); }
public static void Del(){ UI.Inst.DestroyUI<LoadingPanel>(); }
}
}

View File

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

View File

@@ -0,0 +1,65 @@
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using Fantasy.Event;
using UnityEngine;
using NBC;
namespace NBF
{
public struct LoadingShowParam
{
public int Style;
public int StartProgress;
public LoadingShowParam(int style, int startProgress)
{
StartProgress = startProgress;
Style = style;
}
}
public class OnLoadingProgressEvent : EventSystem<LoadingProgress>
{
protected override void Handler(LoadingProgress self)
{
LoadingPanel.SetProgress(self.Progress);
}
}
public partial class LoadingPanel : UIPanel
{
public static readonly LoadingTask<LoadingPanel> LoadingTask = new();
private static LoadingPanel _loadingPanel;
public static void SetProgress(float progress)
{
if (_loadingPanel != null)
{
_loadingPanel.Progress.value = progress * 100;
}
}
protected override void OnInit()
{
ContentPane.sortingOrder = UIDef.UIOrder.Loading;
_loadingPanel = this;
Progress.max = 100;
}
protected override void OnShow()
{
base.OnShow();
Progress.value = 100;
}
protected override void OnHide()
{
base.OnHide();
}
protected override void OnDestroy()
{
base.OnDestroy();
}
}
}

View File

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

View File

@@ -0,0 +1,146 @@
using System.Collections.Generic;
using System.Linq;
using NBC;
using UnityEngine;
namespace NBF
{
/// <summary>
/// loading进度任务
/// </summary>
public class LoadingTask<T> where T : UIPanel
{
public static readonly string LoadingTips = "Loading...";
private NTask _currentTask;
private readonly List<NTask> _tasks = new();
private StepType _step = StepType.Idle;
private float _time = 0;
public float Progress => _currentTask?.Progress ?? 0;
public string Info => _currentTask != null ? _currentTask.Info : LoadingTips;
public int Count => _tasks.Count;
public LoadingTask()
{
Game.OnUpdate += OnUpdate;
}
enum StepType
{
Idle,
Run,
FinishWait,
Done
}
public void Reset()
{
_time = 0;
_tasks.Clear();
_currentTask = null;
}
public void TryEnd()
{
foreach (var task in _tasks)
{
if (task is LoadingWaitTask<T> waitTask)
{
waitTask.End();
}
}
}
public void ForceEnd()
{
_step = StepType.Done;
// StatusChange?.Invoke();
}
public void Add(NTask task)
{
if (_currentTask == null)
{
if (_tasks.Count < 1)
{
Reset();
_step = StepType.Idle;
}
_currentTask = task;
}
_tasks.Add(task);
if (_currentTask is LoadingWaitTask<T> && _tasks.Count > 1)
{
//如果当前是wait
foreach (var t in _tasks.Where(t => t is not LoadingWaitTask<T>))
{
_currentTask = t;
break;
}
}
}
protected void OnUpdate()
{
if (_step == StepType.Done)
{
return;
}
// var st = TaskStatus.Running;
var dongCount = 0;
foreach (var task in _tasks)
{
if (task.Status >= NTaskStatus.Success)
{
dongCount++;
}
}
_step = dongCount >= _tasks.Count ? StepType.FinishWait : StepType.Run;
if (_step == StepType.FinishWait)
{
_time += Time.deltaTime;
if (_tasks.Count > 0)
{
_step = StepType.Run;
}
if (_time >= 0.3f)
{
End();
}
}
}
private void End()
{
_step = StepType.Done;
UI.Inst.HideUI<T>();
// Game.Main.TimerComponent.Unity.OnceTimer()
Timer.FrameOnce(1, this, _ => { Reset(); });
}
}
public class LoadingWaitTask<T> : NTask where T : UIPanel
{
protected override void OnStart()
{
Info = LoadingTask<T>.LoadingTips;
}
public void End()
{
Finish();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 16294c138e124ab29b42cd96259cfdb4
timeCreated: 1742568093