Add basic update check, show notice in titlebar when newer release available

Check can be disabled by creating DisableUpdateCheck.txt in NVPI folder.

Also added PS_CONST_FOLDING_GPU setting (thanks to Guzz at guru3d)
This commit is contained in:
emoose
2025-07-29 22:12:46 +01:00
parent 8ac48c2928
commit 7b917d9b11
5 changed files with 123 additions and 5 deletions

View File

@@ -0,0 +1,74 @@
using System;
using System.IO;
using System.Net.Http;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace nspector.Common.Helper
{
public static class GithubVersionHelper
{
// Check latest release info (ignores pre-release versions)
private const string _repoUrl = "https://api.github.com/repos/Orbmu2k/nvidiaProfileInspector/releases/latest";
public static async Task<bool> IsUpdateAvailableAsync()
{
try
{
// Allow disabling update check in case user doesn't want us to access internet, or just wants to stick to a certain version
if (File.Exists(Path.Combine(AppContext.BaseDirectory, "DisableUpdateCheck.txt")))
return false;
var currentVersion = Assembly.GetExecutingAssembly().GetName().Version;
using var httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromSeconds(10);
httpClient.DefaultRequestHeaders.Add("User-Agent", "nvidiaProfileInspector/" + currentVersion.ToString());
var response = await httpClient.GetAsync(_repoUrl);
if (!response.IsSuccessStatusCode)
return false;
var content = await response.Content.ReadAsStringAsync();
var tagName = ExtractJsonString(content, "tag_name");
if (string.IsNullOrEmpty(tagName))
return false;
var versionString = tagName.TrimStart('v').Trim();
if (Version.TryParse(versionString, out Version latestVersion))
{
return latestVersion > currentVersion;
}
return false;
}
catch
{
return false;
}
}
private static string ExtractJsonString(string json, string fieldName)
{
var pattern = $"\"{fieldName}\"\\s*:\\s*\"([^\"\\\\]*(\\\\.[^\"\\\\]*)*)\"";
var match = Regex.Match(json, pattern);
if (match.Success)
{
var value = match.Groups[1].Value;
value = value.Replace("\\\"", "\"");
value = value.Replace("\\\\", "\\");
value = value.Replace("\\n", "\n");
value = value.Replace("\\r", "\r");
value = value.Replace("\\t", "\t");
return value;
}
return null;
}
}
}

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- NOTE: 3D Vision settings will be hidden from NVPI when using driver later than 425.31, CTRL+ALT+D can be used to unhide if needed. -->
<!-- NOTE: 3D Vision settings will be hidden from NVPI on drivers later than 425.31, CTRL+ALT+D can be used to unhide if needed. -->
<CustomSettingNames>
<Settings>
<CustomSetting>
@@ -6410,6 +6410,23 @@
</SettingValues>
<SettingMasks/>
</CustomSetting>
<CustomSetting>
<UserfriendlyName>PS_CONST_FOLDING_GPU (0x006D6197)</UserfriendlyName>
<HexSettingID>0x006D6197</HexSettingID>
<Description/>
<GroupName>8 - Extra</GroupName>
<SettingValues>
<CustomSettingValue>
<UserfriendlyName>0</UserfriendlyName>
<HexValue>0x00000000</HexValue>
</CustomSettingValue>
<CustomSettingValue>
<UserfriendlyName>PS_CONST_FOLDING_GPU_OFF</UserfriendlyName>
<HexValue>0xA2B53761</HexValue>
</CustomSettingValue>
</SettingValues>
<SettingMasks/>
</CustomSetting>
<CustomSetting>
<UserfriendlyName>Antialiasing - Transparency Multisampling - Setting</UserfriendlyName>
<HexSettingID>0x0043ED70</HexSettingID>

View File

@@ -515,6 +515,7 @@
this.lvSettings.TabIndex = 2;
this.lvSettings.UseCompatibleStateImageBehavior = false;
this.lvSettings.View = System.Windows.Forms.View.Details;
this.lvSettings.GroupStateChanged += new System.EventHandler<nspector.GroupStateChangedEventArgs>(this.lvSettings_GroupStateChanged);
this.lvSettings.ColumnWidthChanging += new System.Windows.Forms.ColumnWidthChangingEventHandler(this.lvSettings_ColumnWidthChanging);
this.lvSettings.SelectedIndexChanged += new System.EventHandler(this.lvSettings_SelectedIndexChanged);
this.lvSettings.DoubleClick += new System.EventHandler(this.lvSettings_DoubleClick);

View File

@@ -40,6 +40,8 @@ namespace nspector
public string _CurrentProfile = "";
private bool _isUpdateAvailable = false;
private bool isDevMode = false;
private Dictionary<string, bool> _groupCollapsedStates = new();
@@ -515,7 +517,7 @@ namespace nspector
private void SetTitleVersion()
{
var numberFormat = new NumberFormatInfo() { NumberDecimalSeparator = "." };
var version = Assembly.GetExecutingAssembly().GetName().Version;
var version = Assembly.GetExecutingAssembly().GetName().Version.ToString() + (_isUpdateAvailable ? " (update available on GitHub)" : "");
var fileVersionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
var externalCsn = DrsServiceLocator.IsExternalCustomSettings ? " - CSN OVERRIDE!" : "";
Text = $"{Application.ProductName} {version} - Geforce {DrsSettingsServiceBase.DriverVersion.ToString("#.00", numberFormat)} - Profile Settings - {fileVersionInfo.LegalCopyright}{externalCsn}";
@@ -542,6 +544,8 @@ namespace nspector
{
_skipScan = skipScan;
InitializeComponent();
lblApplications.Text = "";
InitTaskbarList();
SetupDropFilesNative();
SetupToolbar();
@@ -550,8 +554,6 @@ namespace nspector
tscbShowCustomSettingNamesOnly.Checked = showCsnOnly;
Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
lvSettings.GroupStateChanged += lvSettings_GroupStateChanged;
LoadGroupStates(Path.Combine(AppContext.BaseDirectory, "HiddenGroups.ini"));
}
@@ -666,7 +668,7 @@ namespace nspector
tsbModifiedProfiles.Enabled = true;
}
private void frmDrvSettings_Load(object sender, EventArgs e)
private async void frmDrvSettings_Load(object sender, EventArgs e)
{
SetupLayout();
SetTitleVersion();
@@ -681,6 +683,28 @@ namespace nspector
tssbRemoveApplication.Enabled = false;
InitResetValueTooltip();
await CheckForUpdatesAsync();
}
private async Task CheckForUpdatesAsync()
{
_isUpdateAvailable = false;
try
{
bool updateAvailable = await GithubVersionHelper.IsUpdateAvailableAsync();
if (updateAvailable)
{
_isUpdateAvailable = true;
SetTitleVersion();
}
}
catch
{
// Ignore update check failures
}
}
private void InitResetValueTooltip()

View File

@@ -123,6 +123,7 @@
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
@@ -136,6 +137,7 @@
<Compile Include="Common\DrsSettingsMetaService.cs" />
<Compile Include="Common\DrsUtil.cs" />
<Compile Include="Common\Helper\DropDownMenuScrollWheelHandler.cs" />
<Compile Include="Common\Helper\GithubVersionHelper.cs" />
<Compile Include="Common\Helper\ListViewGroupSorter.cs" />
<Compile Include="Common\Helper\ShortcutResolver.cs" />
<Compile Include="Common\Helper\SteamAppResolver.cs" />