mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-23 03:04:29 +08:00
- 将音频和图形设置从 IResettable, IVersioned 迁移到 ISettingsData 接口 - 添加数据位置接口 IDataLocation 和数据位置提供者接口 IDataLocationProvider - 修改数据仓库实现,使用数据位置替代类型进行数据操作 - 更新数据仓库的加载、保存、删除和存在检查方法以使用数据位置参数 - 重命名 IPersistentApplyAbleSettings 为 IResetApplyAbleSettings 并更新其实现 - 创建 ISettingsData 接口整合设置数据的基础功能 - 更新设置模型实现,统一管理设置数据的生命周期和应用器 - 添加版本化数据接口 IVersionedData 和可从源加载接口 ILoadableFrom - 实现数据位置到存储键的扩展方法 - 更新数据事件类型以使用数据位置信息 - 重构设置模型的数据加载、保存和应用逻辑 - [skip ci]
53 lines
1.6 KiB
C#
53 lines
1.6 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();
|
|
}
|
|
} |