1
This commit is contained in:
@@ -36,9 +36,9 @@ namespace BITKit
|
|||||||
}
|
}
|
||||||
public static class Time
|
public static class Time
|
||||||
{
|
{
|
||||||
public static float ElapsedTime { get; internal set; }
|
public static float ElapsedTime { get; set; }
|
||||||
public static float DeltaTime { get; internal set; }
|
public static float DeltaTime { get; set; }
|
||||||
public static double TimeAsDouble { get; internal set; }
|
public static double TimeAsDouble { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
|
@@ -8,12 +8,20 @@
|
|||||||
{
|
{
|
||||||
if (info.CanWrite is false) continue;
|
if (info.CanWrite is false) continue;
|
||||||
var targetInfo = target.GetType().GetProperty(info.Name, ReflectionHelper.Flags);
|
var targetInfo = target.GetType().GetProperty(info.Name, ReflectionHelper.Flags);
|
||||||
targetInfo?.SetValue(target, info.GetValue(source));
|
var value = info.GetValue(source);
|
||||||
|
if (value is not null)
|
||||||
|
{
|
||||||
|
targetInfo?.SetValue(target,value );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
foreach (var info in source.GetType().GetFields(ReflectionHelper.Flags))
|
foreach (var info in source.GetType().GetFields(ReflectionHelper.Flags))
|
||||||
{
|
{
|
||||||
var targetInfo = target.GetType().GetField(info.Name, ReflectionHelper.Flags);
|
var targetInfo = target.GetType().GetField(info.Name, ReflectionHelper.Flags);
|
||||||
targetInfo?.SetValue(target, info.GetValue(source));
|
var value = info.GetValue(source);
|
||||||
|
if (value is not null)
|
||||||
|
{
|
||||||
|
targetInfo?.SetValue(target, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,6 @@ namespace BITKit
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await currentElement.ExitAsync();
|
await currentElement.ExitAsync();
|
||||||
currentElement.Exited();
|
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
@@ -104,6 +103,7 @@ namespace BITKit
|
|||||||
{
|
{
|
||||||
BIT4Log.LogException(e);
|
BIT4Log.LogException(e);
|
||||||
}
|
}
|
||||||
|
currentElement.Exited();
|
||||||
currentElement.IsEntered = false;
|
currentElement.IsEntered = false;
|
||||||
OnExit?.Invoke(currentElement);
|
OnExit?.Invoke(currentElement);
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,7 @@ namespace BITKit.Net
|
|||||||
public event Action OnStopServer;
|
public event Action OnStopServer;
|
||||||
private readonly KcpServer server;
|
private readonly KcpServer server;
|
||||||
private readonly GenericEvent _events = new();
|
private readonly GenericEvent _events = new();
|
||||||
|
private bool _isStarted;
|
||||||
private readonly Timer _timer = new(100)
|
private readonly Timer _timer = new(100)
|
||||||
{
|
{
|
||||||
AutoReset = true
|
AutoReset = true
|
||||||
@@ -85,6 +86,11 @@ namespace BITKit.Net
|
|||||||
_now = DateTime.UtcNow;
|
_now = DateTime.UtcNow;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (_isStarted && IsRunningServer is false)
|
||||||
|
{
|
||||||
|
StartServer(_port);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var id in Connections.Keys.ToArray())
|
foreach (var id in Connections.Keys.ToArray())
|
||||||
{
|
{
|
||||||
server.Send(id,_heartBeat , KcpChannel.Unreliable);
|
server.Send(id,_heartBeat , KcpChannel.Unreliable);
|
||||||
@@ -133,9 +139,10 @@ namespace BITKit.Net
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ushort _port;
|
||||||
public void StartServer(ushort port = 27014)
|
public void StartServer(ushort port = 27014)
|
||||||
{
|
{
|
||||||
|
_port = port;
|
||||||
if (IsRunningServer is false)
|
if (IsRunningServer is false)
|
||||||
{
|
{
|
||||||
if (TickRate > 0)
|
if (TickRate > 0)
|
||||||
@@ -146,6 +153,7 @@ namespace BITKit.Net
|
|||||||
OnStartServer?.Invoke();
|
OnStartServer?.Invoke();
|
||||||
server.Start(port);
|
server.Start(port);
|
||||||
_timer.Start();
|
_timer.Start();
|
||||||
|
_isStarted = true;
|
||||||
BIT4Log.Log<KCPNetServer>($"已启动KCP服务器:{port}");
|
BIT4Log.Log<KCPNetServer>($"已启动KCP服务器:{port}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -158,6 +166,7 @@ namespace BITKit.Net
|
|||||||
{
|
{
|
||||||
if (IsRunningServer)
|
if (IsRunningServer)
|
||||||
{
|
{
|
||||||
|
_isStarted = false;
|
||||||
server.Stop();
|
server.Stop();
|
||||||
OnStopServer?.Invoke();
|
OnStopServer?.Invoke();
|
||||||
_timer.Stop();
|
_timer.Stop();
|
||||||
|
@@ -196,17 +196,13 @@ namespace BITKit
|
|||||||
//需要下载的文件总数和总大小
|
//需要下载的文件总数和总大小
|
||||||
int totalDownloadCount = downloader.TotalDownloadCount;
|
int totalDownloadCount = downloader.TotalDownloadCount;
|
||||||
long totalDownloadBytes = downloader.TotalDownloadBytes;
|
long totalDownloadBytes = downloader.TotalDownloadBytes;
|
||||||
|
downloader.OnDownloadProgressCallback = (totalDownloadCount, currentDownloadCount, totalDownloadBytes, currentDownloadBytes) =>
|
||||||
downloader.OnDownloadProgressCallback = (downloadedCount, downloadedBytes, downloadCount, downloadBytes) =>
|
|
||||||
{
|
{
|
||||||
|
BIT4Log.Log<BITFramework>($"{totalDownloadCount},{currentDownloadCount},{totalDownloadBytes},{currentDownloadBytes}");
|
||||||
//下载进度
|
//下载进度
|
||||||
float progress = (float)downloadedBytes / downloadBytes;
|
float progress = (float)currentDownloadBytes / totalDownloadBytes;
|
||||||
//下载速度
|
|
||||||
float speed = 1;
|
|
||||||
//剩余时间
|
|
||||||
float remainTime = (downloadCount - downloadedCount) / speed;
|
|
||||||
_setProgressValue?.Invoke(progress);
|
_setProgressValue?.Invoke(progress);
|
||||||
_setProgressLabel?.Invoke($"下载速度:{speed}KB/s,剩余时间:{remainTime}s");
|
_setProgressLabel?.Invoke($"{currentDownloadBytes}/{totalDownloadBytes}");
|
||||||
};
|
};
|
||||||
downloader.OnDownloadErrorCallback=(fileName,error) =>
|
downloader.OnDownloadErrorCallback=(fileName,error) =>
|
||||||
{
|
{
|
||||||
|
@@ -40,6 +40,18 @@ namespace BITKit.UX
|
|||||||
public new class UxmlFactory : UxmlFactory<TabBar, UxmlTraits> { }
|
public new class UxmlFactory : UxmlFactory<TabBar, UxmlTraits> { }
|
||||||
// These are USS class names for the control overall and the label.
|
// These are USS class names for the control overall and the label.
|
||||||
|
|
||||||
|
public TabBar()
|
||||||
|
{
|
||||||
|
RegisterCallback<AttachToPanelEvent>(UpdateI);
|
||||||
|
RegisterCallback<DetachFromPanelEvent>(UpdateI);
|
||||||
|
RegisterCallback<GeometryChangedEvent>(UpdateI);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateI(object _)
|
||||||
|
{
|
||||||
|
CurrentTab = _currentTab;
|
||||||
|
}
|
||||||
|
|
||||||
public event Action<int> OnTabChanged;
|
public event Action<int> OnTabChanged;
|
||||||
|
|
||||||
private Button[] _buttons = Array.Empty<Button>();
|
private Button[] _buttons = Array.Empty<Button>();
|
||||||
|
@@ -73,15 +73,20 @@ namespace BITKit.UX
|
|||||||
{
|
{
|
||||||
_externalTabBar.OnTabChanged -= EntryTab;
|
_externalTabBar.OnTabChanged -= EntryTab;
|
||||||
}
|
}
|
||||||
if (panel?.visualTree != null)
|
if (parent is not null)
|
||||||
{
|
{
|
||||||
_externalTabBar = panel.visualTree.Q<TabBar>(value);
|
_externalTabBar = parent.Q<TabBar>(value);
|
||||||
if (_externalTabBar is not null)
|
if (_externalTabBar is not null)
|
||||||
{
|
{
|
||||||
_externalTabBar.OnTabChanged += EntryTab;
|
_externalTabBar.OnTabChanged += EntryTab;
|
||||||
}
|
}
|
||||||
|
viewDataKey=_externalTabBar is null ? $"找到了:{value}" :$"未找到:{value}";
|
||||||
}
|
}
|
||||||
viewDataKey=_externalTabBar is null ? "找到了TabBar" :"未找到Tab";
|
else
|
||||||
|
{
|
||||||
|
viewDataKey = $"{value} is null";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private readonly VisualElement _container;
|
private readonly VisualElement _container;
|
||||||
@@ -104,12 +109,24 @@ namespace BITKit.UX
|
|||||||
}
|
}
|
||||||
public void EntryTab(int index)
|
public void EntryTab(int index)
|
||||||
{
|
{
|
||||||
|
if(index == -1)return;
|
||||||
|
var isCatched = false;
|
||||||
foreach (var x in _container.Children())
|
foreach (var x in _container.Children())
|
||||||
{
|
{
|
||||||
x.SetActive(false);
|
x.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_container.Children().TryGetElementAt(index, out var element))
|
if (_container.Children().TryGetElementAt(index, out var element))
|
||||||
|
{
|
||||||
|
isCatched = true;
|
||||||
element.SetActive(true);
|
element.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index is -1 && isCatched is false && this.childCount>0)
|
||||||
|
{
|
||||||
|
this.Children().First().SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
OnTabChanged?.Invoke(index);
|
OnTabChanged?.Invoke(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -177,13 +177,12 @@ namespace BITKit.UX
|
|||||||
{
|
{
|
||||||
await UniTask.NextFrame(cancellationToken);
|
await UniTask.NextFrame(cancellationToken);
|
||||||
}
|
}
|
||||||
OnExit?.Invoke();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IEntryElement.Exited()
|
void IEntryElement.Exited()
|
||||||
{
|
{
|
||||||
document.rootVisualElement.SetActive(false);
|
document.rootVisualElement.SetActive(false);
|
||||||
isActive = false;
|
isActive = false;
|
||||||
|
OnExit?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public event Action OnEntry;
|
public event Action OnEntry;
|
||||||
|
@@ -412,3 +412,6 @@ Foldout Toggle Label {
|
|||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wechat {
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user