GFramework/GFramework.Godot/setting/GodotGraphicsSettings.cs
GwWuYou 807dbc482e feat(setting): 添加设置管理系统和Godot平台实现
- 实现了SettingsModel用于管理应用程序设置部分
- 创建了SettingsSystem用于应用各种设置配置
- 添加了AudioSettings和GraphicsSettings基础设置类
- 定义了ISettingsModel、ISettingsSystem等核心接口
- 实现了GodotAudioApplier用于应用音频设置到Godot音频系统
- 创建了GodotGraphicsSettings用于管理游戏图形显示设置
- 添加了GodotFileStorage特化文件存储实现
- 实现了Godot路径扩展方法IsUserPath、IsResPath、IsGodotPath
- 添加了AudioBusMap音频总线映射配置类
2026-01-12 21:07:27 +08:00

43 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using GFramework.Game.Abstractions.setting;
using Godot;
namespace GFramework.Godot.setting;
/// <summary>
/// Godot图形设置类继承自GraphicsSettings并实现IApplyAbleSettings接口
/// 用于管理游戏的图形显示设置,包括分辨率、全屏模式等
/// </summary>
public class GodotGraphicsSettings : GraphicsSettings, IApplyAbleSettings
{
/// <summary>
/// 异步应用当前图形设置到游戏窗口
/// 该方法会根据设置的分辨率、全屏状态等参数调整Godot窗口的显示属性
/// </summary>
/// <returns>表示异步操作的任务</returns>
public async Task Apply()
{
var size = new Vector2I(ResolutionWidth, ResolutionHeight);
// 直接调用DisplayServer API不使用异步或延迟
// 1. 设置边框标志
DisplayServer.WindowSetFlag(DisplayServer.WindowFlags.Borderless, Fullscreen);
// 2. 设置窗口模式
DisplayServer.WindowSetMode(
Fullscreen ? DisplayServer.WindowMode.ExclusiveFullscreen : DisplayServer.WindowMode.Windowed
);
// 3. 窗口化下设置尺寸和位置
if (!Fullscreen)
{
DisplayServer.WindowSetSize(size);
// 居中窗口
var screen = DisplayServer.GetPrimaryScreen();
var screenSize = DisplayServer.ScreenGetSize(screen);
var pos = (screenSize - size) / 2;
DisplayServer.WindowSetPosition(pos);
}
await Task.CompletedTask;
}
}