Skip to content

Commit e6454c8

Browse files
committed
feat(presets): add local preset library and reviewed imports
Support scoped JSON/file/clipboard presets with difference previews, compatibility opt-in, verified batch configuration application and selective undo. Keep preset sharing local and preserve model inheritance and defaults-view behavior. Add store, production configuration and UI regression coverage plus multilingual controls and public preset documentation. Store 386, configuration 2644, layout 74840 and menu 75965 checks pass. Reuse matching Release/Debug builds; in-game preset interaction remains unverified. No version or release changes.
1 parent 39408f7 commit e6454c8

28 files changed

Lines changed: 5450 additions & 6 deletions

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ and four menu themes.
3838
| **Live diagnostics and reports** | Inspect NR activity, requested/resolved models, resources and GPU time when available; prepare optional diagnostics and a reviewed GitHub Issue draft. |
3939
| **Multilingual interface — 15 languages** | Let Auto follow ReShade or choose a language manually. Display depends on ReShade's loaded font; the guide lists languages and explains missing-glyph fallback. |
4040
| **Four interface themes** | Cyber Neon, Nexus Dark, Fluent Light and Midnight OLED change the menu's appearance, independently of image processing. |
41+
| **Local, shareable presets (development)** | Save quality or multi-pass looks to a shared local library, exchange JSON files or clipboard text, review differences, and apply or undo an import. Full backups require extra confirmation. See the [preset guide](docs/USER_GUIDE.md#en-presets); this feature is newer than the 0.1.0 release. |
4142

4243
Model-look controls steer what NR generates; result editing reshapes the change
4344
returned by each pass. Model choice, look inheritance and result inheritance are
@@ -241,6 +242,7 @@ NR Nexus 通过 [ReShade](https://reshade.me/) 为兼容游戏提供 NVIDIA DLSS
241242
| **实时诊断与报告** | 查看 NR 活动、请求/解析模型、资源及可用时的 GPU 时间,准备可选诊断与需用户检查提交的 Issue 草稿。 |
242243
| **15 种界面语言** | Auto 自动跟随 ReShade,也可手动选择。显示取决于 ReShade 已加载的字体,语言清单与缺字回退说明见指南。 |
243244
| **四套界面主题** | Cyber Neon、Nexus Dark、Fluent Light、Midnight OLED 只改变菜单视觉,不影响 NR 图像处理。 |
245+
| **本地共享预设(开发中)** | 将画质或叠层设置保存到共享本地库,通过 JSON 文件或剪贴板分享,预览差异后应用,并可撤销上次导入。完整备份需要额外确认。操作见[预设指南](docs/USER_GUIDE.md#zh-presets);此功能晚于 0.1.0 正式版。 |
244246

245247
模型外观控制 NR 生成什么,结果编辑则塑造每层模型已经返回的改变量。模型选择、外观继承、
246248
结果继承彼此独立,附加层既可沿用第 1 层,也可保留各自保存的编辑。介入点、工作分辨率和

‎dlssnr.hpp‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@
113113
#include "report_upload.hpp"
114114

115115
#include <nlohmann/json.hpp>
116+
#include "preset_store.hpp"
117+
#include "preset_fields.hpp"
116118

117119
#pragma comment(lib, "bcrypt.lib")
118120
#pragma comment(lib, "shell32.lib")
@@ -20163,14 +20165,18 @@ struct Setting {
2016320165
}
2016420166
present_sdr_restore_config_version.store(present_sdr_restore::CONFIG_VERSION, std::memory_order_relaxed);
2016520167
}
20168+
StoreLocked(value);
20169+
++present_restore_configuration.epoch;
20170+
}
20171+
// Caller owns the configuration lock; preset batches publish one epoch.
20172+
void StoreLocked(float value) const {
2016620173
if (f != nullptr) {
2016720174
f->store(value);
2016820175
} else if (u != nullptr) {
2016920176
u->store(static_cast<uint32_t>(std::lround(value)));
2017020177
} else {
2017120178
b->store(value != 0.f);
2017220179
}
20173-
++present_restore_configuration.epoch;
2017420180
}
2017520181
// Always to the global config file, as PersistConfig explains.
2017620182
void Persist() const {
@@ -23434,6 +23440,7 @@ static_assert(std::size(kResolutionPresets) == std::size(ui::text::kResolutionLa
2343423440
// i18n: end
2343523441
// The issue report (rc11): BeginIssueReport and the panel's steps.
2343623442
#include "report_flow.hpp"
23443+
#include "preset_runtime.hpp"
2343723444

2343823445
// ---- Faster (rc11): NR's cheaper settings, one click each ------------------
2343923446
// A player measured 57 fps with another NR add-on and 38 with this one, and
@@ -23660,6 +23667,7 @@ inline void DrawAbout() {
2366023667
// Developer view retains its flat settings and raw diagnostic controls.
2366123668
inline void DrawClassicLayout(reshade::api::effect_runtime* runtime, const ui::StatusCard& card) {
2366223669
const ui::PanelText& text = ui::kClassicText;
23670+
preset_ui::DrawEntry();
2366323671
// The hook point above every section: which insertion point the sections
2366423672
// steer is the first thing this view answers.
2366523673
DrawSectionHookPoint(text);
@@ -23738,6 +23746,7 @@ inline void DrawModernLayout(reshade::api::effect_runtime* runtime,
2373823746
}
2373923747
bool reset = false;
2374023748
if (ui_menu_page == 0) {
23749+
preset_ui::DrawEntry();
2374123750
ui::StyleScope columns_style;
2374223751
columns_style.Var(ImGuiStyleVar_CellPadding, ImVec2(ui::tokens::kCardPadding, 2.f));
2374323752
const int columns = (ImGui::GetContentRegionAvail().x >= ImGui::GetFontSize() * ui::tokens::kWideEm ? 2 : 1);
@@ -23799,6 +23808,7 @@ inline void DrawModernLayout(reshade::api::effect_runtime* runtime,
2379923808
ImGui::EndTable();
2380023809
}
2380123810
} else if (ui_menu_page == 1) {
23811+
preset_ui::DrawEntry(true);
2380223812
if (ui::SectionCaption(ui::text::kMenuPages[1], ui::text::kResetPerformance,
2380323813
!ui_defaults_view && AnyModified({kPerformanceSettings, kStackingSettings, kPassLookResultSettings}))) {
2380423814
ResetSettings({kPerformanceSettings, kStackingSettings, kPassLookResultSettings});
@@ -23815,6 +23825,7 @@ inline void DrawModernLayout(reshade::api::effect_runtime* runtime,
2381523825
DrawDiagnostics(verdict);
2381623826
DrawIssueReport();
2381723827
} else {
23828+
preset_ui::DrawEntry();
2381823829
char hotkeys[128];
2381923830
std::snprintf(hotkeys, sizeof(hotkeys), ui::Tr(ui::text::kHotkeysHint),
2382023831
VirtualKeyName(toggle_hotkey.load()).c_str(),
@@ -24231,6 +24242,10 @@ inline float SanitizeFloatKey(
2423124242
float lo,
2423224243
float hi,
2423324244
const char* key) {
24245+
if (const auto* rule = presets::FindRule(key); rule != nullptr && std::isfinite(rule->minimum)) {
24246+
lo = static_cast<float>(rule->minimum);
24247+
hi = static_cast<float>(rule->maximum);
24248+
}
2423424249
if (std::isfinite(value)) {
2423524250
const float clamped = std::clamp(value, lo, hi);
2423624251
if (clamped != value) {
@@ -24253,6 +24268,10 @@ inline uint32_t SanitizeEnumKey(
2425324268
uint32_t min_value,
2425424269
uint32_t max_value,
2425524270
const char* key) {
24271+
if (const auto* rule = presets::FindRule(key); rule != nullptr && std::isfinite(rule->minimum)) {
24272+
min_value = static_cast<uint32_t>(rule->minimum);
24273+
max_value = static_cast<uint32_t>(rule->maximum);
24274+
}
2425624275
if (value >= min_value && value <= max_value) return value;
2425724276
NoteIniIssue(key, std::to_string(value) + " (using " + std::to_string(fallback) + ")");
2425824277
if (!config_value_rejected_logged.exchange(true)) {

‎docs/PRESET_FORMAT.md‎

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# NR Nexus 预设格式
2+
3+
预设保存插件配置选择,不包含运行时 DLL、模型、游戏数据或测量结果。扩展名为 `.nrnexus.json`,内容为 UTF-8 JSON。例如:
4+
5+
```json
6+
{
7+
"format": "nr-nexus-preset",
8+
"schema_version": 1,
9+
"metadata": {"name": "Example", "description": "A shared look"},
10+
"scope": "quality",
11+
"settings": {"NRIntensity": 0.8, "NRStyle": 1, "NRAutoMask": true}
12+
}
13+
```
14+
15+
示例中的数值只是选择示例,不代表内置默认值。`metadata` 可省略;支持字符串 `name`、`author`、`description`、`source_game`、`created_with` 及字符串数组 `tags`。`created_with` 是来源说明,不代替 schema,也不指定要加载的 DLL。文件最多 256 KiB、嵌套最多 8 层、配置最多 512 项;具体字符串长度限制见 [存储实现](../preset_store.hpp)。
16+
17+
## 范围与字段规则
18+
19+
[preset_fields.hpp](../preset_fields.hpp) 是字段名称、分类和数值边界清单;键名区分大小写。`FieldRule::Category` 包含下表五类;`label` 为可交给现有翻译器的英文键,`group` 为显示分组,二者均不是持久化标识。`pass=0` 表示全局或全链,`1` 表示基础层,`2..4` 表示附加层。全局 `NRSkinIndependent` 影响所有层。
20+
21+
| `scope` | 包含内容 |
22+
| --- | --- |
23+
| `quality` | `QUALITY`:基础模型强度、模型、style/tone/structure/skin/mask/UI,以及基础层的全局 Look 结果 |
24+
| `quality-multipass` | 上述画质,加 `MULTIPASS`:`NRPasses`(含基础层的总数)以及当前启用层的模型、强度、Transfer/Color、steering、独立结果和两组继承开关 |
25+
| `full` | 所有非 `EXCLUDED` 字段,包括未启用层保存的独立值、`COMPATIBILITY` 和 `GENERAL`;仅已接入读取/应用入口的字段能够实际恢复 |
26+
27+
画质范围不包含其他 compatibility fixes、Hook/stage、分辨率、快捷键或 diagnostics。基础 `NRTransferStrength`/`NRColorStrength` 归 `QUALITY`,与附加层 `Transfer`/`Color` 形成完整的逐层选择;后者归 `MULTIPASS`。全链 `NRLookUpsample` 随分辨率归兼容组,不是逐层结果参数。当前没有独立 pass 分辨率或 stage,不能合成这类键。
28+
29+
| 画质字段 | loader 数值范围/类型 |
30+
| --- | --- |
31+
| `NRPreset` | 整数 `0..3`;保留历史 `3`,菜单不新增该选项;保存请求值,不替换为运行时回退值 |
32+
| `NRStyle` | 整数 `0..2` |
33+
| `NRIntensity`、`NRLocalTone`、`NRLocalStructure` | 数值 `0..2` |
34+
| `NRTransferStrength`、`NRColorStrength` | 数值 `0..1` |
35+
| `NRSkinStructure` | 数值 `-1..1`,包括 UI 滑条不显示的负值语义 |
36+
| `NRSkinIndependent`、`NRAutoMask`、`NRUICorrection` | boolean |
37+
| `NRLookMode`、`NRLookStabilizeDetail` | boolean |
38+
| `NRLookStrength`、`NRLookBrighten`、`NRLookDarken`、`NRLookColour`、`NRLookHue`、`NRLookMaxColour`、`NRLookShadows`、`NRLookMidtones`、`NRLookHighlights`、`NRLookTone`、`NRLookDetail` | 数值 `0..2` |
39+
| `NRLookMaxBrighten`、`NRLookMaxDarken` | 数值 `0..4` |
40+
| `NRLookHalo`、`NRLookHaloBrightSide` | 数值 `0..1` |
41+
| `NRLookDetailRadius` | 数值 `0.25..4` |
42+
| `NRLookStabilize`、`NRDetailStability` | 整数 `0..2` |
43+
| `NRLookStabilizeMs` | 数值 `10..250`,毫秒 |
44+
45+
`NRPasses` 是整数 `1..4`。每个 `NRPass{2,3,4}` 均展开同一组字段:
46+
47+
| 后缀 | loader 数值范围/类型 |
48+
| --- | --- |
49+
| `Preset` | 整数 `0..2`;`0` 继承主模型,与 steering/结果继承独立 |
50+
| `Intensity`、`LocalTone`、`Structure` | 数值 `0..2` |
51+
| `Transfer`、`Color` | 数值 `0..1` |
52+
| `Style` | 整数 `0..2` |
53+
| `Skin` | 数值 `-1..1` |
54+
| `FollowPass1`、`AutoMask`、`UICorrection`、`LookFollowPass1` | boolean;继承不删除保存的独立值 |
55+
| `LookMode` 至 `DetailStability` 的结果字段 | 与上表对应基础层字段同类型、同范围;没有逐层 `LookUpsample` |
56+
57+
## 完整备份分类
58+
59+
注册表内的兼容项归 `COMPATIBILITY`:Hook/Present 策略、共同分辨率和上采样、HDR codec/来源编码/白点/传递模式/归一化、Depth/MVec、chained history;基础 Transfer/Color 强度按上述规则归画质。其逐键范围以规则表及 [生产 loader](../dlssnr.hpp) 为准。`GENERAL` 包含 `NeuralUplift`、两个快捷键、截图格式/来源/布局/JPEG 质量/大小限制,以及 `NRGpuTimers`、`NRCostMeter`。
60+
61+
以下为 `LoadConfiguration` 在 Setting registry 之外读取的完整清单;不因缺少 `Setting` 而静默当作普通 float:
62+
63+
| 类别 | 字段 | 类型/合法域 |
64+
| --- | --- | --- |
65+
| `COMPATIBILITY` | `EnableHooks` | 整数 `0..2`:关闭、NGX + Streamline、NGX;loader 对其他非零值仍启用 NGX,预设仅接受已定义枚举 |
66+
| `COMPATIBILITY` | `DX11Source` | 字符串 `auto`、`native`、`foreign`、`off` |
67+
| `COMPATIBILITY` | `ForeignNr` | 字符串 `yield`、`observe` |
68+
| `COMPATIBILITY` | `DedupeMode`、`ListStateMode` | 整数 `0..1` |
69+
| `COMPATIBILITY` | `NRMaxWorksets` | 整数 `1..8` |
70+
| `COMPATIBILITY` | `NRWorksetFreePolicy`、`NRDisableRelease`、`NRVkStateRestore` | 整数 `0..1`,不能因只有两个值而改存 boolean |
71+
| `COMPATIBILITY` | `NRShutdownQuiesce`、`NRPresentBlockHudless` | boolean |
72+
| `COMPATIBILITY` | `NRPresentWhiteSource`、`NRPresentPreFgContract`、`NRAutoFgFallback` | 整数 `0..1` |
73+
| `COMPATIBILITY` | `NRPresentPreFg` | 整数 `0..3` |
74+
| `COMPATIBILITY` | `NRPresentMVecUnits`、`NROutputRect` | 整数 `0..2` |
75+
| `COMPATIBILITY` | `NRPresentHdrPedestalPolicy` | 整数 `0..2`;经 HDR policy 入口处理 |
76+
| `COMPATIBILITY` | `NRPresentRestoreScope` | 整数 `0..1`;经 scope 成对写入和回读验证入口处理 |
77+
| `GENERAL` | `NRCrashDump`、`UiWelcomed`、`UiIssueNotice` | boolean;后者控制 HUD 通知 |
78+
| `GENERAL` | `UiHudX`、`UiHudY` | 有限数值 `0..100`,百分比 |
79+
| `GENERAL` | `UiTheme` | 字符串,使用 `ui::kThemes` 的 slug;当前为 `cyber_neon`、`nexus_dark`、`fluent_light`、`midnight_oled` |
80+
| `GENERAL` | `UiLanguage` | 字符串 `auto` 或 `ui::kLanguages` 的语言码,不复制另一份语言枚举 |
81+
| `GENERAL` | `UiMode` | 字符串 `modern`、`classic` |
82+
| `EXCLUDED` | `NRDebugBypassHdrPedestal`、`NRNormTrace`、`NRScreenshotPlanes`、`NRTelemetrySeconds` | 会话诊断,原因见下表 |
83+
| `EXCLUDED` | `NRReportHost` | 网络/第三方上传信息,禁止预设携带 |
84+
| `EXCLUDED` | `NRPreUpscale`、`NRGlobalTone`、`NRSdrBlackRestore` | 旧键,原因见下表 |
85+
| `EXCLUDED` | `ConfigVersion`、`NRPresentSdrRestoreConfigVersion`、`NRPresentHdrPedestalConfigVersion`、`NRPresentRestoreScopeConfigVersion` | 配置 schema 标记,禁止直接导入 |
86+
87+
字符串规则的 `minimum`/`maximum` 为 NaN,表示不适用,不是数值范围。必须先走字符串适配器和枚举白名单;该 NaN 只属于 C++ 元数据,不能序列化到 JSON。加载旧 INI 时允许的未知字符串回退,不代表预设可接受任意字符串。
88+
89+
## 禁止导入与导出
90+
91+
`EXCLUDED` 即使出现在 full 中也不写入或应用。注册表中的 debug 也必须有规则,以区别“已知但禁用”与未知键。
92+
93+
| 字段/对象 | 原因 |
94+
| --- | --- |
95+
| `NRDebugBypassSdrRestore`、`NRDebugBypassHdrPedestal`、`NRDebugBypassHostLook`、`NRPresentModelUI`、`NRDebugGuideMode` | 临时诊断会改变正式处理行为;不能随分享配置传播 |
96+
| `NRDebugHdrCaptureMode`、`NRDebugCapturePlanes`、`NRScreenshotPlanes` | 临时捕获/阶段平面选择,可能产生诊断数据;前者是 UI-only Setting,不由 loader 读取 |
97+
| `NREditTrace`、`NRNormTrace`、`NRTelemetrySeconds` | 调试追踪/遥测输出,不属于可恢复画质 |
98+
| `NRPreUpscale` | 已由 `NRHookPoint` 替代,仅为旧配置迁移读取 |
99+
| `NRGlobalTone` | 已退役、无运行效果,仅读取以告知旧工具用户 |
100+
| `NRSdrBlackRestore` | 仍影响 Legacy/旧路径,但现有生产配置只读、无正式写入入口;不能绕过新 restore policy 约束。full 不保证无损复刻此旧值,需旧 INI 备份或明确的迁移支持 |
101+
| 四个 `*ConfigVersion`/`ConfigVersion` 标记 | 由当前迁移/策略持久化入口生成;不是用户调节值,也不能用导入文件的戳解除只读保护 |
102+
| `NRReportHost`、网络地址、上传目标/凭据/链接 | 不携带上传信息,也不因恢复预设触发网络操作 |
103+
| 路径、宿主配置、环境变量、未知或过时键 | 不属于此白名单;当前 loader 没有可备份的路径字段,不虚构 `NRRuntimePath` 等键 |
104+
105+
## 验证与接入约定
106+
107+
数值必须有限且在闭区间内。枚举和整数不接受小数、boolean 或字符串,不将非法枚举钳制成另一个有效选择;boolean 只接受 JSON `true`/`false`。注册项按现有 `Setting.f/u/b` 判断类型。INI loader 的有限 float 钳制和非法值回退是旧配置修复行为;导入预设应报告非法值,不静默修复后应用。
108+
109+
未知 `settings` 键可作为未应用数据保留并在预览中说明,不能按名称猜测类型或写入 INI;缺失字段保持当前值,不做重置或补默认。未知顶层字段/metadata、重复键、非法类型/数值及未来 `schema_version` 拒绝;未来游戏配置 schema 或只读策略不能被预设覆盖。预设 schema 与 INI `ConfigVersion` 独立。
110+
111+
真实默认只从现有 `Setting::fallback` 读取,当前值从 `Setting::Get()`/实际状态读取。不要用“Defaults view”临时显示的值冒充用户配置;未注册字段复用生产 loader 的现有常量、解析器和状态,不在规则表建立第二套默认值。尤其 `UiTheme` 的缺失值依赖新安装/已有配置分类,不能简单写死一种主题。
112+
113+
应用应复用现有 Store/Persist/SettingEffect 与配置锁、epoch 机制:模型选择与 feature 重建需保持同一 runtime turn;批量变更只触发所需的 history/host-history/recreate,不能逐行反复重建。`NeuralUplift` 启用、共同分辨率、语言和主题分别复用其现有入口;`UiTheme` 应同步主题选择及 `ui::SetTheme`,语言码用现有语言表与 `StoreUiLanguage`,布局写入 `UiMode`。
114+
115+
正式 `NRPresentSdrRestorePolicy`、HDR policy 和 scope 必须遵守各自的 writable/版本保护、锁及 scope 成对回读验证;导入内容不直接提供版本戳。scope 的“键缺失/继承”和 `EnableHooks` 等 attach 策略的“未显式配置”都有语义,完整备份不能把它们错误固化为显式选择。`EnableHooks`、`DX11Source`、`ForeignNr` 属启动期策略,恢复配置后应提示重启,不能声称钩子已热切换。
116+
117+
规则表本身只提供元数据,不实现上述适配器。主线必须为表内非注册字段提供类型、读取、验证、应用和持久化;未接入项应明确显示不支持,不能宣称 full 已完整恢复。完整备份仍只覆盖允许的插件设置,不保证跨游戏、API、SDR/HDR 或运行时版本兼容;建议在预览中明确显示兼容项和重启要求。

0 commit comments

Comments
 (0)