Skip to content

Commit

Permalink
Add Nvidia settings contingency & update About view
Browse files Browse the repository at this point in the history
  • Loading branch information
eksime committed Jun 29, 2022
1 parent 0b4a729 commit 8cfc947
Show file tree
Hide file tree
Showing 14 changed files with 603 additions and 93 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "thirdparty/nvidiaProfileInspector"]
path = thirdparty/nvidiaProfileInspector
url = https://github.com/Orbmu2k/nvidiaProfileInspector.git
14 changes: 10 additions & 4 deletions Blish HUD.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.452
# Visual Studio Version 17
VisualStudioVersion = 17.1.32407.343
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blish HUD", "Blish HUD\Blish HUD.csproj", "{AA22EEFD-87BC-46BA-A9EC-493B7985C82F}"
EndProject
Expand All @@ -11,6 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Resources.Designer.t4 = Resources.Designer.t4
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nspector", "nspector\nspector.csproj", "{51CEA931-296F-4A96-A3CF-28691A90BFCB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All @@ -21,13 +23,17 @@ Global
{AA22EEFD-87BC-46BA-A9EC-493B7985C82F}.Debug|x64.Build.0 = Debug|x64
{AA22EEFD-87BC-46BA-A9EC-493B7985C82F}.Release|x64.ActiveCfg = Release|x64
{AA22EEFD-87BC-46BA-A9EC-493B7985C82F}.Release|x64.Build.0 = Release|x64
{51CEA931-296F-4A96-A3CF-28691A90BFCB}.Debug|x64.ActiveCfg = Debug|Any CPU
{51CEA931-296F-4A96-A3CF-28691A90BFCB}.Debug|x64.Build.0 = Debug|Any CPU
{51CEA931-296F-4A96-A3CF-28691A90BFCB}.Release|x64.ActiveCfg = Release|Any CPU
{51CEA931-296F-4A96-A3CF-28691A90BFCB}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BCD3C4BD-915D-4622-A220-D39D18A327D9}
RESX_AutoCreateNewLanguageFiles = True
RESX_ConfirmAddLanguageFile = True
RESX_AutoCreateNewLanguageFiles = True
SolutionGuid = {BCD3C4BD-915D-4622-A220-D39D18A327D9}
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions Blish HUD/Blish HUD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@
<TrimmerRootAssembly Include="Microsoft.Xna.Framework.Content.ContentTypeReader" Visible="false" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\nspector\nspector.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="AsyncClipboardService" Version="[1.7.1]" />
<PackageReference Include="DynamicLanguageRuntime" Version="1.2.2" PrivateAssets="all" />
Expand Down Expand Up @@ -281,5 +285,15 @@
<Content Update="$(ProjectDir)Content\bin\**" Pack="False" />
</ItemGroup>
</Target>

<Target Name="CombineLicenses" BeforeTargets="BeforeBuild">
<ItemGroup>
<LicenseFiles Include="..\LICENSE" Name="Blish HUD" />
<LicenseFiles Include="..\thirdparty\nvidiaProfileInspector\LICENSE" Name="nvidiaProfileInspector" />

<LicenseFileLines Include="%0d%0a%0d%0a%(LicenseFiles.Name)%0d%0a%0d%0a$([System.IO.File]::ReadAllText(%(LicenseFiles.Identity)))" />
</ItemGroup>

<WriteLinesToFile File="$(BaseIntermediateOutputPath)\ThirdPartySoftware.txt" Lines="@(LicenseFileLines)" Overwrite="true" />
</Target>
</Project>
25 changes: 25 additions & 0 deletions Blish HUD/GameServices/Debug/Contingency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using System.ComponentModel;

namespace Blish_HUD.Debug {
public static class Contingency {
Expand All @@ -12,6 +13,10 @@ public static class Contingency {
private static readonly HashSet<string> _contingency = new HashSet<string>();

private static void NotifyContingency(string key, string title, string description, string url, params (TaskDialogButton Button, Func<Task> OnClick)[] extraActions) {
NotifyContingency(key, title, description, null, url, extraActions);
}

private static void NotifyContingency(string key, string title, string description, string expandedDescription, string url, params (TaskDialogButton Button, Func<Task> OnClick)[] extraActions) {
if (_contingency.Contains(key)) {
return;
}
Expand All @@ -30,6 +35,7 @@ private static void NotifyContingency(string key, string title, string descripti
WindowTitle = title,
MainIcon = TaskDialogIcon.Warning,
MainInstruction = description,
Content = expandedDescription,
FooterIcon = TaskDialogIcon.Information,
EnableHyperlinks = true,
Footer = string.Format(Strings.GameServices.Debug.ContingencyMessages.GenericUrl_Footer, url, DISCORD_JOIN_URL),
Expand All @@ -54,6 +60,16 @@ private static void NotifyContingency(string key, string title, string descripti
notifDiag.ShowDialog();
}

private static Task OpenNvidaControlPanel() {
try {
Process.Start(Environment.ExpandEnvironmentVariables("%programfiles%\\NVIDIA Corporation\\Control Panel Client\\nvcplui.exe"));
} catch (Win32Exception) {
Process.Start("explorer.exe", "shell:AppsFolder\\NVIDIACorp.NVIDIAControlPanel_56jybvy8sckqj!NVIDIACorp.NVIDIAControlPanel");
}

return Task.CompletedTask;
}

private static void NotifDiag_HyperlinkClicked(object sender, HyperlinkClickedEventArgs e) {
Process.Start(e.Href);
}
Expand Down Expand Up @@ -86,6 +102,15 @@ internal static void NotifyCfaBlocking(string path) {
"https://link.blishhud.com/cfablocking");
}

internal static void NotifyNvidiaSettings(string description) {
NotifyContingency(nameof(NotifyNvidiaSettings),
Strings.GameServices.Debug.ContingencyMessages.NvidiaSettings_Title,
Strings.GameServices.Debug.ContingencyMessages.NvidiaSettings_Description,
description,
"https://link.blishhud.com/nvidiasettings",
(new TaskDialogButton(Strings.GameServices.Debug.ContingencyMessages.NvidiaSettings_OpenControlPanelAction), OpenNvidaControlPanel));
}

public static void NotifyFileSaveAccessDenied(string path, string actionDescription, bool promptPortableMode = false) {
// TODO: If promptPortabelMode is true, add a new button to the diag that allows the user to enable portable mode as a work around.
NotifyContingency(nameof(NotifyFileSaveAccessDenied),
Expand Down
51 changes: 51 additions & 0 deletions Blish HUD/GameServices/Debug/ContingencyChecks.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Win32;
using nspector.Common;
using nspector.Common.CustomSettings;
using nspector.Common.Meta;
using nspector.Native.NvApi.DriverSettings;

namespace Blish_HUD.Debug {
internal static class ContingencyChecks {
Expand All @@ -10,6 +19,7 @@ public static void RunAll() {
CheckArcDps11Injected();
CheckMinTls12();
CheckControlledFolderAccessBlocking();
CheckNvidiaControlPanelSettings();
}

/// <summary>
Expand Down Expand Up @@ -60,5 +70,46 @@ private static void CheckControlledFolderAccessBlocking() {
}
}

private static void CheckNvidiaControlPanelSettings() {
try {
CustomSettingNames customSettingNames = CustomSettingNames.FactoryLoadFromString(nspector.Properties.Resources.CustomSettingNames);
CustomSettingNames referenceSettingNames = CustomSettingNames.FactoryLoadFromString(nspector.Properties.Resources.ReferenceSettingNames);

DrsSettingsMetaService metaService = new DrsSettingsMetaService(customSettingNames, referenceSettingNames);
DrsDecrypterService decrypterService = new DrsDecrypterService(metaService);
DrsScannerService scannerService = new DrsScannerService(metaService, decrypterService);
DrsSettingsService settingService = new DrsSettingsService(metaService, decrypterService);

// this might be nicer as a resource or a config file?
Dictionary<ESetting, HashSet<uint>> forbiddenValues = new Dictionary<ESetting, HashSet<uint>>() {
[ESetting.MAXWELL_B_SAMPLE_INTERLEAVE_ID] = new HashSet<uint>() { 1 }
};

// stored using forward slashes for some reason
string exePath = Application.ExecutablePath.Replace('\\', '/');
string blishProfileName = scannerService.FindProfilesUsingApplication(exePath);

List<string> errors = new List<string>();
foreach (KeyValuePair<ESetting, HashSet<uint>> pair in forbiddenValues) {
SettingMeta settingMeta = metaService.GetSettingMeta((uint)pair.Key);
uint value = settingService.GetDwordValueFromProfile(blishProfileName, (uint)pair.Key);

if (pair.Value.Contains(value)) {
SettingValue<uint> settingValue = settingMeta.DwordValues.FirstOrDefault(val => val.Value == value);
string val = settingValue?.ValueName != null ? settingValue.ValueName : value.ToString();

errors.Add($"'{settingMeta.SettingName}' = '{val}'");
}
}

if (errors.Any()) {
Contingency.NotifyNvidiaSettings(string.Join(Environment.NewLine, errors));
}

} catch (Exception) {
// we don't really care if we error here - usually means a non-nvidia system,
// in which case the check is useless anyway.
}
}
}
}
90 changes: 63 additions & 27 deletions Blish HUD/GameServices/Overlay/UI/Views/AboutView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,25 @@ protected override void Build(Container buildPanel) {
Parent = buildPanel
};

var gw2CopyrightStatement = new Label() {
Font = GameService.Content.DefaultFont16,
Text = string.Format(Strings.GameServices.OverlayService.AboutAnetNotice, DateTime.Now.Year),
AutoSizeHeight = true,
Width = buildPanel.Width,
StrokeText = true,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Top,
Parent = buildPanel
var infoPanel = new Panel() {
Width = buildPanel.Width,
Height = 32,
Bottom = buildPanel.Bottom,
Parent = buildPanel
};

gw2CopyrightStatement.Location = new Point(0, buildPanel.Height - gw2CopyrightStatement.Height - 64);
var aboutPanel = new Panel() {
ShowBorder = true,
Width = buildPanel.Width,
Height = buildPanel.Height - infoPanel.Height,
Parent = buildPanel,
CanScroll = true,
};

var lovePanel = new Panel() {
Size = new Point(buildPanel.Width - 128, 128),
Left = 64,
Top = gw2CopyrightStatement.Top - 128 - 12,
Parent = buildPanel
Size = new Point(aboutPanel.Width - 128, 128),
Left = (aboutPanel.Width / 2) - ((aboutPanel.Width - 128) / 3),
Parent = aboutPanel
};

var heart = new Image(AsyncTexture2D.FromAssetId(156127)) {
Expand All @@ -54,31 +55,66 @@ protected override void Build(Container buildPanel) {
Parent = lovePanel
};

var gw2CopyrightStatement = new Label() {
Font = GameService.Content.DefaultFont16,
Text = string.Format(Strings.GameServices.OverlayService.AboutAnetNotice, DateTime.Now.Year),
AutoSizeHeight = true,
Width = aboutPanel.Width,
Top = lovePanel.Bottom,
StrokeText = true,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Top,
Parent = aboutPanel
};

var thirdPartySoftwareHeading = new Label() {
Font = GameService.Content.DefaultFont16,
Text = Strings.GameServices.OverlayService.AboutThirdPartySoftwareHeading,
Top = gw2CopyrightStatement.Bottom + 64,
Width = aboutPanel.Width,
StrokeText = true,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Top,
Parent = aboutPanel,
};

var thirdPartySoftwareStatement = new Label() {
Font = GameService.Content.DefaultFont14,
Text = Strings.GameServices.OverlayService.AboutThirdPartySoftware,
AutoSizeHeight = true,
Top = thirdPartySoftwareHeading.Bottom + 32,
Width = aboutPanel.Width,
Left = 24,
StrokeText = false,
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Top,
Parent = aboutPanel,
};

var version = new Label() {
AutoSizeHeight = true,
AutoSizeWidth = true,
Text = $"{Strings.Common.BlishHUD} v{Program.OverlayVersion.BaseAndPrerelease()}",
BasicTooltipText = $"v{Program.OverlayVersion}",
Font = GameService.Content.DefaultFont14,
StrokeText = true,
ClipsBounds = false,
Parent = buildPanel
AutoSizeHeight = true,
Width = infoPanel.Width,
Text = $"{Strings.Common.BlishHUD} v{Program.OverlayVersion.BaseAndPrerelease()}",
BasicTooltipText = $"v{Program.OverlayVersion}",
Font = GameService.Content.DefaultFont14,
HorizontalAlignment = HorizontalAlignment.Right,
StrokeText = true,
ClipsBounds = false,
Parent = infoPanel
};

version.Location = new Point(buildPanel.Width - version.Width + 8, buildPanel.Height - version.Height);
//version.Location = new Point(infoPanel.Width - version.Width + 8, infoPanel.Height - version.Height);

var mumbleConnection = new ViewContainer() {
Size = new Point(128, 20),
Left = 8,
Bottom = version.Bottom,
Parent = buildPanel
Parent = infoPanel
};

var arcdpsBridgeConnection = new ViewContainer() {
Size = new Point(128, 20),
Bottom = version.Bottom,
Left = mumbleConnection.Right,
Parent = buildPanel
Parent = infoPanel
};

mumbleConnection.Show(new ConnectionStatusView().WithPresenter(new ConnectionStatusPresenter(() => Strings.GameServices.OverlayService.ConnectionStatus_Mumble_Name,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8cfc947

Please sign in to comment.