This commit is contained in:
CortexCore
2023-11-30 00:27:34 +08:00
parent 7712c80804
commit 337840ebb3
30 changed files with 787 additions and 62 deletions

View File

@@ -5,18 +5,16 @@ using Microsoft.Extensions.DependencyInjection;
namespace BITKit;
public partial class UXApplicationService : EntityComponent
public partial class UXApplicationService : EntityBehaviour
{
[Export] private Label currentVersionLabel;
[Export] private Label latestVersionLabel;
[Export] private Button downloadLatestButton;
[Inject]
private IApplicationService _service;
public override void OnAwake()
{
_service = Entity.ServiceProvider.GetRequiredService<IApplicationService>();
downloadLatestButton.Hide();
downloadLatestButton.Pressed += () =>

View File

@@ -1,5 +1,6 @@
using Godot;
using System;
using Cysharp.Threading.Tasks;
namespace BITKit.UX;
@@ -17,17 +18,39 @@ public partial class UXPanel : Control, IUXPanel
public bool AllowInput => allowInput;
private string _index;
public bool IsEntered { get; set; }
public virtual void Entry()
{
Show();
//OnEntry();
}
public UniTask EntryAsync()
{
return UniTask.CompletedTask;
}
public void Entered()
{
}
public virtual void Exit()
{
Hide();
//OnExit();
}
public UniTask ExitAsync()
{
return UniTask.CompletedTask;
}
public void Exited()
{
}
public event Action OnEntry;
public event Action OnExit;
@@ -55,4 +78,9 @@ public partial class UXPanel : Control, IUXPanel
UXService.UnRegister(this);
IsValid = false;
}
public void OnUpdate(float deltaTime)
{
throw new NotImplementedException();
}
}

View File

@@ -13,6 +13,6 @@ public partial class UXProfiler : Node
if (fpsLabel is not null)
fpsLabel.Text = $"FPS: {Engine.GetFramesPerSecond()}";
if (resolutionLabel is not null)
resolutionLabel.Text = $"Resolution: {windowSize.X}x{windowSize.Y}";
resolutionLabel.Text = $"{windowSize.X}x{windowSize.Y}";
}
}

View File

@@ -0,0 +1,36 @@
using Godot;
using System;
namespace BITKit.UX.Settings;
public partial class UXSettings : Node
{
[Export] private Slider uiScaleSlider;
[Export] private Slider renderResolutionSlider;
[Export] private CheckBox fullScreenCheckBox;
public override void _Ready()
{
base._Ready();
uiScaleSlider.ValueChanged += SetUIScale;
renderResolutionSlider.ValueChanged += SetRenderResolution;
fullScreenCheckBox.Toggled += SetFullScreen;
}
private void SetFullScreen(bool toggledon)
{
DisplayServer.WindowSetMode(toggledon ? DisplayServer.WindowMode.Fullscreen:DisplayServer.WindowMode.Minimized);
BIT4Log.Log<UXSettings>($"设置全屏为{toggledon}");
}
public void SetUIScale(double scale)
{
//GetViewport().Scaling3DScale =(float) scale;
BIT4Log.Log<UXSettings>($"设置UI缩放比例为{scale}");
}
public void SetRenderResolution(double scale)
{
GetViewport().Scaling3DScale = (float)scale;
BIT4Log.Log<UXSettings>($"设置渲染分辨率比例为{scale}");
}
}