mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 新增 Godot 场景行为基类和具体实现(Node2D、Node3D、Control、通用场景行为) - 添加场景行为工厂类,支持根据节点类型自动创建合适的行为实例 - 实现 Godot 场景工厂类,用于创建场景实例并集成场景注册表 - 添加 Godot 路径扩展方法,支持判断用户数据路径和资源路径 - 优化数据仓库和设置事件类的初始化方法,添加 XML 文档注释 - 修改场景切换管道中的日志记录逻辑,避免空引用异常 - 更新 Godot 日志记录器和日志工厂的文档注释 - 为设置相关类添加数据对象和类型属性的文档说明 - 移除加载进度处理器类,精简场景切换流程
65 lines
2.0 KiB
C#
65 lines
2.0 KiB
C#
using GFramework.Game.Abstractions.setting;
|
|
using GFramework.Game.Abstractions.setting.data;
|
|
using Godot;
|
|
|
|
namespace GFramework.Godot.setting;
|
|
|
|
/// <summary>
|
|
/// Godot图形设置应用器
|
|
/// </summary>
|
|
/// <param name="model">设置模型接口</param>
|
|
public class GodotGraphicsSettings(ISettingsModel model) : IResetApplyAbleSettings
|
|
{
|
|
/// <summary>
|
|
/// 应用图形设置到Godot引擎
|
|
/// </summary>
|
|
/// <returns>异步任务</returns>
|
|
public async Task Apply()
|
|
{
|
|
var settings = model.GetData<GraphicsSettings>();
|
|
// 创建分辨率向量
|
|
var size = new Vector2I(settings.ResolutionWidth, settings.ResolutionHeight);
|
|
|
|
// 设置窗口边框状态
|
|
DisplayServer.WindowSetFlag(DisplayServer.WindowFlags.Borderless, settings.Fullscreen);
|
|
|
|
// 设置窗口模式(全屏或窗口化)
|
|
DisplayServer.WindowSetMode(
|
|
settings.Fullscreen
|
|
? DisplayServer.WindowMode.ExclusiveFullscreen
|
|
: DisplayServer.WindowMode.Windowed
|
|
);
|
|
|
|
// 非全屏模式下设置窗口大小和居中位置
|
|
if (!settings.Fullscreen)
|
|
{
|
|
DisplayServer.WindowSetSize(size);
|
|
var screen = DisplayServer.GetPrimaryScreen();
|
|
var screenSize = DisplayServer.ScreenGetSize(screen);
|
|
var pos = (screenSize - size) / 2;
|
|
DisplayServer.WindowSetPosition(pos);
|
|
}
|
|
|
|
await Task.CompletedTask;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 重置图形设置
|
|
/// </summary>
|
|
public void Reset()
|
|
{
|
|
model.GetData<GraphicsSettings>().Reset();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取图形设置的数据对象。
|
|
/// 该属性提供对图形设置数据的只读访问。
|
|
/// </summary>
|
|
public ISettingsData Data { get; } = model.GetData<GraphicsSettings>();
|
|
|
|
/// <summary>
|
|
/// 获取图形设置数据的类型。
|
|
/// 该属性返回图形设置数据的具体类型信息。
|
|
/// </summary>
|
|
public Type DataType { get; } = typeof(GraphicsSettings);
|
|
} |