Skip to content

Commit b9dc2bb

Browse files
committed
ConfigTool: font changes, add choices for Override settings, fix DPI scaling
also fixed issue with older edit columns seeming to stick around after listview was cleared & reloaded
1 parent 7d8ffd3 commit b9dc2bb

File tree

5 files changed

+140
-52
lines changed

5 files changed

+140
-52
lines changed

ConfigTool/ListViewEx.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,16 @@ private void ShowTextBox(Point location, Size sz)
383383
}
384384
}
385385

386+
public void Unfocus()
387+
{
388+
OnMouseUp(null);
389+
}
390+
391+
public void ClearEditCells()
392+
{
393+
this.customCells.Clear();
394+
}
395+
386396
protected override void OnColumnWidthChanging(ColumnWidthChangingEventArgs e)
387397
{
388398
base.OnColumnWidthChanging(e);

ConfigTool/Main.Designer.cs

Lines changed: 23 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ConfigTool/Main.cs

Lines changed: 100 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,45 @@
22
using System.Collections.Generic;
33
using System.ComponentModel;
44
using System.IO;
5+
using System.Linq;
56
using System.Reflection;
67
using System.Windows.Forms;
78

89
namespace DLSSTweaks.ConfigTool
910
{
1011
public partial class Main : Form
1112
{
13+
public static string FirstCharToUpper(string input)
14+
{
15+
switch (input)
16+
{
17+
case null: throw new ArgumentNullException(nameof(input));
18+
case "": throw new ArgumentException($"{nameof(input)} cannot be empty", nameof(input));
19+
default: return input[0].ToString().ToUpper() + input.Substring(1);
20+
}
21+
}
22+
1223
Dictionary<string, string> dllOverrides = new Dictionary<string, string>();
1324

1425
string DefaultFormTitle = "DLSSTweaks"; // will be updated to actual text after InitializeComponent
1526

1627
static string IniFilename = "dlsstweaks.ini";
1728

1829
static string DefaultDescText = "Welcome to DLSSTweaks ConfigTool!\r\n\r\nSelect any setting to view a description of it here, or click on the value for the setting to edit it.\r\n\r\nIf you just want to force DLAA, simply edit the ForceDLAA value above and then save the file.";
19-
30+
static string UltraQualityText = "UltraQuality: allows setting the ratio for the 'UltraQuality' level.\r\n\r\nNot every game allows using this level, some may only expose it as an option once this has been set to non-zero.\r\nA very small number might also already show an UltraQuality level, which this setting should be able to customize.\r\n(the number of games that work with this is very small unfortunately)\r\n\r\nSet to 0 to leave this as DLSS default.";
2031
static string HoverLoadText = "Reload the DLSSTweaks.ini from the same folder as ConfigTool.";
2132
static string HoverSaveText = "Writes out the changed settings to DLSSTweaks.ini.";
2233
static string HoverAddDLLOverrideText = "DLL override: allows overriding the path that a game will load a DLL from, simply pick the new DLL you wish to override with.\r\n\r\nThis can be useful if you're prevented from editing the game files for some reason.\r\n\r\neg. with Rockstar Game Launcher, you can't easily update nvngx_dlss.dll without RGL reverting it, but by using this you can make the game load DLSS from a completely different path which RGL can't override.";
2334

35+
static string[] BooleanKeys = new[] { "ForceDLAA", "DisableDevWatermark", "VerboseLogging", "Enable", "DisableIniMonitoring", "OverrideAppId" };
36+
static string[] OverrideKeys = new[] { "OverrideAutoExposure", "OverrideDlssHud" };
37+
static string[] OverrideValues = new[] { "Force disable", "Default", "Force enable" }; // -1, 0, 1
38+
2439
public void IniRead()
2540
{
2641
lvSettings.Items.Clear();
2742
lvSettings.Groups.Clear();
43+
lvSettings.ClearEditCells();
2844

2945
string[] lines = null;
3046

@@ -49,6 +65,60 @@ public void IniRead()
4965

5066
var groups = new Dictionary<string, ListViewGroup>();
5167

68+
bool isUltraQualityAdded = false;
69+
70+
void AddSetting(string section, string key, string value, string comment)
71+
{
72+
ListViewGroup group = null;
73+
if (!groups.TryGetValue(section, out group))
74+
{
75+
group = new ListViewGroup(section);
76+
groups.Add(section, group);
77+
lvSettings.Groups.Add(group);
78+
}
79+
80+
bool isBooleanKey = BooleanKeys.Contains(key);
81+
bool isOverrideKey = OverrideKeys.Contains(key);
82+
if (isBooleanKey)
83+
value = FirstCharToUpper(value);
84+
else
85+
{
86+
if (isOverrideKey)
87+
{
88+
if (value == "-1")
89+
value = OverrideValues[0];
90+
else if(value == "0")
91+
value = OverrideValues[1];
92+
else
93+
value = OverrideValues[2];
94+
}
95+
}
96+
97+
var listViewItem = new ListViewItem();
98+
listViewItem.Text = key;
99+
listViewItem.Tag = comment;
100+
listViewItem.Group = group;
101+
listViewItem.SubItems.Add(value);
102+
lvSettings.Items.Add(listViewItem);
103+
104+
var row = lvSettings.Items.Count - 1;
105+
106+
if (isBooleanKey)
107+
lvSettings.AddComboBoxCell(row, 1, new string[] { "False", "True" });
108+
else
109+
{
110+
if (isOverrideKey)
111+
lvSettings.AddComboBoxCell(row, 1, OverrideValues);
112+
else
113+
{
114+
if (section == "DLSSPresets")
115+
lvSettings.AddComboBoxCell(row, 1, new string[] { "Default", "A", "B", "C", "D", "F" });
116+
else
117+
lvSettings.AddEditableCell(row, 1);
118+
}
119+
}
120+
}
121+
52122
foreach (var line in lines)
53123
{
54124
var trimmed = line.TrimStart(' ').TrimEnd(' ').TrimStart('\t').TrimEnd('\t');
@@ -66,6 +136,13 @@ public void IniRead()
66136
if (trimmed.StartsWith("[") && trimmed.EndsWith("]"))
67137
{
68138
state_comment = "";
139+
140+
// If we're changing from DLSSQualityLevels section to new section, and haven't added UltraQuality...
141+
if (state_section == "DLSSQualityLevels" && !isUltraQualityAdded)
142+
{
143+
AddSetting("DLSSQualityLevels", "UltraQuality", "0", UltraQualityText);
144+
}
145+
69146
state_section = trimmed.Substring(1, trimmed.Length - 2);
70147
continue;
71148
}
@@ -76,18 +153,6 @@ public void IniRead()
76153
var key = trimmed.Substring(0, seperator).TrimStart(' ').TrimEnd(' ').TrimStart('\t').TrimEnd('\t');
77154
var value = trimmed.Substring(seperator + 1).TrimStart(' ').TrimEnd(' ').TrimStart('\t').TrimEnd('\t');
78155

79-
bool isBooleanValue = value.ToLower() == "true" || value.ToLower() == "false";
80-
if (isBooleanValue)
81-
value = value.ToLower();
82-
83-
ListViewGroup group = null;
84-
if (!groups.TryGetValue(state_section, out group))
85-
{
86-
group = new ListViewGroup(state_section);
87-
groups.Add(state_section, group);
88-
lvSettings.Groups.Add(group);
89-
}
90-
91156
if (state_section == "DLLPathOverrides")
92157
state_comment = "DLLPathOverrides: allows overriding the path that a DLL will be loaded from based on the filename of it\r\n\r\nDelete/clear the path to remove this override.";
93158

@@ -97,6 +162,9 @@ public void IniRead()
97162
comment_DLSSQualityLevels = state_comment;
98163
else
99164
state_comment = comment_DLSSQualityLevels;
165+
166+
if (key == "UltraQuality")
167+
state_comment = UltraQualityText;
100168
}
101169

102170
if (state_section == "DLSSPresets")
@@ -107,24 +175,10 @@ public void IniRead()
107175
state_comment = comment_DLSSPresets;
108176
}
109177

110-
var listViewItem = new ListViewItem();
111-
listViewItem.Text = key;
112-
listViewItem.Tag = state_comment;
113-
listViewItem.Group = group;
114-
listViewItem.SubItems.Add(value);
115-
lvSettings.Items.Add(listViewItem);
178+
AddSetting(state_section, key, value, state_comment);
116179

117-
var row = lvSettings.Items.Count - 1;
118-
119-
if (isBooleanValue)
120-
lvSettings.AddComboBoxCell(row, 1, new string[] { "true", "false" });
121-
else
122-
{
123-
if (state_section == "DLSSPresets")
124-
lvSettings.AddComboBoxCell(row, 1, new string[] { "Default", "A", "B", "C", "D", "F" });
125-
else
126-
lvSettings.AddEditableCell(row, 1);
127-
}
180+
if (state_section == "DLSSQualityLevels" && key == "UltraQuality")
181+
isUltraQualityAdded = true;
128182

129183
state_comment = "";
130184
}
@@ -141,6 +195,18 @@ void IniWrite()
141195
var key = item.Text;
142196
var value = item.SubItems[1].Text;
143197

198+
if (OverrideKeys.Contains(key))
199+
{
200+
if (value == OverrideValues[0])
201+
value = "-1";
202+
else if (value == OverrideValues[1])
203+
value = "0";
204+
else
205+
value = "1";
206+
}
207+
else if (BooleanKeys.Contains(key))
208+
value = value.ToLower();
209+
144210
file[section][key] = value;
145211
}
146212

@@ -158,6 +224,7 @@ void IniWrite()
158224
public Main()
159225
{
160226
InitializeComponent();
227+
AutoScaleMode = AutoScaleMode.Dpi;
161228
lvSettings.ValueChanged += lvSettings_ValueChanged;
162229

163230
this.Text += $" v{Assembly.GetExecutingAssembly().GetName().Version}";
@@ -196,16 +263,19 @@ private void lvSettings_SelectedIndexChanged(object sender, EventArgs e)
196263

197264
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
198265
{
266+
lvSettings.Unfocus();
199267
IniWrite();
200268
}
201269

202270
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
203271
{
272+
lvSettings.Unfocus();
204273
IniRead();
205274
}
206275

207276
private void addDLLOverrideToolStripMenuItem_Click(object sender, EventArgs e)
208277
{
278+
lvSettings.Unfocus();
209279
var ofd = new OpenFileDialog();
210280
ofd.Title = "Select the new DLL that you want to override with";
211281
ofd.Filter = "DLL Files (*.dll)|*.dll|All Files (*.*)|*.*";

ConfigTool/Program.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ namespace DLSSTweaks.ConfigTool
66
{
77
internal static class Program
88
{
9+
[System.Runtime.InteropServices.DllImport("user32.dll")]
10+
private static extern bool SetProcessDPIAware();
11+
912
/// <summary>
1013
/// The main entry point for the application.
1114
/// </summary>
@@ -17,9 +20,11 @@ static void Main()
1720
return Assembly.Load(Properties.Resources.PeanutButter_INI);
1821
return null;
1922
};
23+
if (Environment.OSVersion.Version.Major >= 6)
24+
SetProcessDPIAware();
2025

2126
Application.EnableVisualStyles();
22-
Application.SetCompatibleTextRenderingDefault(false);
27+
Application.SetCompatibleTextRenderingDefault(true);
2328
Application.Run(new Main());
2429
}
2530
}

dlsstweaks.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ OverrideAutoExposure = 0
5454
; - Set to 0 to disable softening/sharpening (will leave any DoSharpening DLSS flag in place though, which may still affect image)
5555
; - Set to "disable" to completely force the sharpening flag to be disabled (this will prevent changing OverrideSharpening during gameplay)
5656
; - Set to "ignore" (or comment out the line) to prevent this override from applying, leaving the value at whatever game sets for it
57-
OverrideSharpening = ignore
57+
OverrideSharpening = Ignore
5858

5959
; OverrideDlssHud: allows force enabling/disabling the DLSS debug display HUD overlay
6060
; The HUD will display on bottom left of screen in-game when enabled, though some titles may draw effects on top of it

0 commit comments

Comments
 (0)