| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using BepInEx.Configuration;
- using PerformanceScope.Core;
- namespace PerformanceScope
- {
- /// <summary>
- /// 插件配置项定义。所有绑定项以静态属性暴露,供服务层直接读取。
- /// 配置界面由 BepInEx ConfigurationManager 提供(默认 F1,可在其配置中改键)。
- /// </summary>
- internal static class PluginConfig
- {
- private const string SectionGeneral = "1. 通用";
- private const string SectionResolution = "2. 镜内分辨率";
- public static ConfigEntry<bool> EnableMod { get; private set; }
- public static ConfigEntry<bool> EnableLogging { get; private set; }
- public static ConfigEntry<bool> VerboseLogging { get; private set; }
- public static ConfigEntry<OpticResolutionMode> Mode { get; private set; }
- public static ConfigEntry<float> ScreenHeightRatio { get; private set; }
- public static ConfigEntry<int> AbsolutePixels { get; private set; }
- public static ConfigEntry<bool> ApplyWhileScoped { get; private set; }
- /// <summary>绑定全部配置项并立即落盘,生成带注释的初始配置文件。</summary>
- public static void Init(ConfigFile config)
- {
- EnableMod = config.Bind(
- SectionGeneral,
- "启用模组",
- true,
- new ConfigDescription(
- "总开关。关闭后恢复游戏默认镜内分辨率。",
- null,
- new ConfigurationManagerAttributes { Order = 1 }));
- EnableLogging = config.Bind(
- SectionGeneral,
- "启用日志",
- false,
- new ConfigDescription(
- "输出本模组的常规/诊断/警告日志(错误日志始终输出)。",
- null,
- new ConfigurationManagerAttributes { Order = 2 }));
- VerboseLogging = config.Bind(
- SectionGeneral,
- "详细日志",
- false,
- new ConfigDescription(
- "在启用日志的基础上输出更详细的诊断信息。",
- null,
- new ConfigurationManagerAttributes { IsAdvanced = true, Order = 3 }));
- Mode = config.Bind(
- SectionResolution,
- "取值方式",
- // 默认不改变游戏行为;玩家显式选择后再生效(4K 下 0.7 反而会高于默认 1024)。
- OpticResolutionMode.GameDefault,
- new ConfigDescription(
- "游戏默认 / 屏幕高度比例 / 绝对像素。",
- // 枚举无需 AcceptableValueList(ConfigurationManager 会自动渲染为下拉框)
- null,
- new ConfigurationManagerAttributes { Order = 1 }));
- ScreenHeightRatio = config.Bind(
- SectionResolution,
- "屏幕高度比例",
- 0.5f,
- new ConfigDescription(
- "镜内边长 = round(屏幕高度 × 该值)。",
- new AcceptableValueRange<float>(ResolutionMath.MinRatio, ResolutionMath.MaxRatio),
- new ConfigurationManagerAttributes { ShowRangeAsPercent = true, Order = 2 }));
- AbsolutePixels = config.Bind(
- SectionResolution,
- "绝对像素",
- ResolutionMath.GameDefaultResolution,
- new ConfigDescription(
- "镜内方形 RenderTexture 的边长(像素)。",
- new AcceptableValueRange<int>(ResolutionMath.MinResolution, ResolutionMath.MaxResolution),
- new ConfigurationManagerAttributes { Order = 3 }));
- ApplyWhileScoped = config.Bind(
- SectionResolution,
- "瞄准中立即应用",
- true,
- new ConfigDescription(
- "关闭时,瞄准镜内期间的改动会推迟到退出镜内后应用,以避免画面闪烁。",
- null,
- new ConfigurationManagerAttributes { Order = 4 }));
- config.Save();
- }
- }
- }
|