Skip to content

Commit

Permalink
CommonHelpers: Show Missing RTSS button
Browse files Browse the repository at this point in the history
  • Loading branch information
ayufan committed Feb 8, 2023
1 parent 5cd873b commit d0c45a1
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 26 deletions.
6 changes: 1 addition & 5 deletions CommonHelpers/AntiCheatSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@ public bool AckAntiCheat(String title, String? message, String? footnote = null,
if (footnote is not null)
page.Footnote.Text += "\n" + footnote;

page.HelpRequest += delegate
{
try { System.Diagnostics.Process.Start("explorer.exe", HelpURL); }
catch { }
};
page.HelpRequest += delegate { Dependencies.OpenLink(HelpURL); };

var result = TaskDialog.ShowDialog(new Form { TopMost = true }, page, TaskDialogStartupLocation.CenterScreen);
if (result != continueButton)
Expand Down
13 changes: 7 additions & 6 deletions CommonHelpers/Dependencies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public static class Dependencies
"RTSSHooks64.dll"
};

private static string VCRuntimeURL = "https://aka.ms/vs/17/release/vc_redist.x64.exe";
private static string RTSSURL = "https://www.guru3d.com/files-details/rtss-rivatuner-statistics-server-download.html";
public static string SDTURL = "https://steam-deck-tools.ayufan.dev";
public static string VCRuntimeURL = "https://aka.ms/vs/17/release/vc_redist.x64.exe";
public static string RTSSURL = "https://www.guru3d.com/files-details/rtss-rivatuner-statistics-server-download.html";

public static void ValidateHidapi(string title)
{
Expand Down Expand Up @@ -107,7 +108,7 @@ private static bool EnsureDependency(string? title, string name, string[] dllNam
);

if (result == downloadButton)
ExecuteLink(url);
OpenLink(url);

return false;
}
Expand Down Expand Up @@ -136,7 +137,7 @@ private static void InstallDependency(string title, string name, string[] dllNam

if (result == downloadButton)
{
ExecuteLink(url);
OpenLink(url);
Environment.Exit(1);
}
else if (result == exitButton)
Expand Down Expand Up @@ -189,15 +190,15 @@ private static TaskDialogButton ShowDialog(string caption, string heading, strin

page.HelpRequest += delegate
{
try { ExecuteLink(url); }
try { OpenLink(url); }
catch { }
};
}

return TaskDialog.ShowDialog(new Form { TopMost = true }, page, TaskDialogStartupLocation.CenterScreen);
}

private static void ExecuteLink(string link)
public static void OpenLink(string link)
{
try { Process.Start("explorer.exe", link); }
catch { }
Expand Down
22 changes: 20 additions & 2 deletions CommonHelpers/OSDHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ public static bool IsOSDForeground(out int processId, out string processName)
return Applications.Instance.FindForeground(out processId, out processName);
}

public static bool IsLoaded
{
get
{
Applications.Instance.Refresh();
return Applications.Instance.IsLoaded;
}
}

public class Applications
{
public readonly static Applications Instance = new Applications();
Expand All @@ -45,6 +54,7 @@ public bool IsRecent
}

public IDictionary<int, Entry> IDs { get; private set; } = new Dictionary<int, Entry>();
public bool IsLoaded { get; private set; }

private const int FrameTimeoutMs = 5000;

Expand All @@ -60,8 +70,16 @@ public void Refresh()
var oldIDs = IDs;
var newIDs = new Dictionary<int, Entry>();

try { appEntries = OSD.GetAppEntries(AppFlags.MASK); }
catch { return; }
try
{
appEntries = OSD.GetAppEntries(AppFlags.MASK);
IsLoaded = true;
}
catch
{
IsLoaded = false;
return;
}

var now = DateTimeOffset.UtcNow;

Expand Down
2 changes: 1 addition & 1 deletion FanControl/FanControlForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private void toolStripMenuItemStartupOnBoot_Click(object sender, EventArgs e)

private void help_DoubleClick(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev");
Dependencies.OpenLink(Dependencies.SDTURL);
}

private void toolStripMenuItemAlwaysOnTop_Click(object sender, EventArgs e)
Expand Down
10 changes: 9 additions & 1 deletion PerformanceOverlay/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public Controller()
if (Instance.WantsRunOnStartup)
startupManager.Startup = true;

var notRunningRTSSItem = contextMenu.Items.Add("&RTSS is not running");
notRunningRTSSItem.Enabled = false;
contextMenu.Opening += delegate { notRunningRTSSItem.Visible = Dependencies.EnsureRTSS(null) && !OSDHelpers.IsLoaded; };

showItem = new ToolStripMenuItem("&Show OSD");
showItem.Click += ShowItem_Click;
showItem.Checked = Settings.Default.ShowOSD;
Expand Down Expand Up @@ -84,11 +88,15 @@ public Controller()
contextMenu.Items.Add(startupItem);
}

var missingRTSSItem = contextMenu.Items.Add("&Install missing RTSS");
missingRTSSItem.Click += delegate { Dependencies.OpenLink(Dependencies.RTSSURL); };
contextMenu.Opening += delegate { missingRTSSItem.Visible = !Dependencies.EnsureRTSS(null); };

var checkForUpdatesItem = contextMenu.Items.Add("&Check for Updates");
checkForUpdatesItem.Click += delegate { Instance.RunUpdater(TitleWithVersion, true); };

var helpItem = contextMenu.Items.Add("&Help");
helpItem.Click += delegate { System.Diagnostics.Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev"); };
helpItem.Click += delegate { Dependencies.OpenLink(Dependencies.SDTURL); };

contextMenu.Items.Add(new ToolStripSeparator());

Expand Down
10 changes: 9 additions & 1 deletion PowerControl/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public Controller()

var contextMenu = new System.Windows.Forms.ContextMenuStrip(components);

var notRunningRTSSItem = contextMenu.Items.Add("&RTSS is not running");
notRunningRTSSItem.Enabled = false;
contextMenu.Opening += delegate { notRunningRTSSItem.Visible = Dependencies.EnsureRTSS(null) && !OSDHelpers.IsLoaded; };

rootMenu.Init();
rootMenu.Visible = false;
rootMenu.Update();
Expand All @@ -77,11 +81,15 @@ public Controller()
contextMenu.Items.Add(startupItem);
}

var missingRTSSItem = contextMenu.Items.Add("&Install missing RTSS");
missingRTSSItem.Click += delegate { Dependencies.OpenLink(Dependencies.RTSSURL); };
contextMenu.Opening += delegate { missingRTSSItem.Visible = !Dependencies.EnsureRTSS(null); };

var checkForUpdatesItem = contextMenu.Items.Add("&Check for Updates");
checkForUpdatesItem.Click += delegate { Instance.RunUpdater(TitleWithVersion, true); };

var helpItem = contextMenu.Items.Add("&Help");
helpItem.Click += delegate { System.Diagnostics.Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev"); };
helpItem.Click += delegate { Dependencies.OpenLink(Dependencies.SDTURL); };
contextMenu.Items.Add(new ToolStripSeparator());

var exitItem = contextMenu.Items.Add("&Exit");
Expand Down
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

## 0.6.x

- All: Show `Missing RTSS` button to install RTSS
- PowerControl: Retain FPS Limit (proportion) on refresh rate change
- PowerControl: Support RTSS in custom folder
- SteamController: Fix Steam Big Picture detection for non-english
Expand Down
16 changes: 6 additions & 10 deletions SteamController/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public Controller()
settingsItem.Click += Settings_Click;

var shortcutsItem = contextMenu.Items.Add("&Shortcuts");
shortcutsItem.Click += delegate { Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev/shortcuts.html"); };
shortcutsItem.Click += delegate { Dependencies.OpenLink(Dependencies.SDTURL + "/shortcuts.html"); };

contextMenu.Items.Add(new ToolStripSeparator());

Expand All @@ -149,7 +149,7 @@ public Controller()
checkForUpdatesItem.Click += delegate { Instance.RunUpdater(TitleWithVersion, true); };

var helpItem = contextMenu.Items.Add("&Help");
helpItem.Click += delegate { Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev"); };
helpItem.Click += delegate { Dependencies.OpenLink(Dependencies.SDTURL); };

contextMenu.Items.Add(new ToolStripSeparator());

Expand Down Expand Up @@ -338,11 +338,7 @@ public void SetupSteam(bool always)
page.Footnote.Text += "Close Steam before confirming as otherwise Steam will be forcefully closed.";
page.Footnote.Icon = TaskDialogIcon.Warning;

page.HelpRequest += delegate
{
try { System.Diagnostics.Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev/steam-controller"); }
catch { }
};
page.HelpRequest += delegate { Dependencies.OpenLink(Dependencies.SDTURL + "/steam-controller"); };

var result = TaskDialog.ShowDialog(new Form { TopMost = true }, page, TaskDialogStartupLocation.CenterScreen);
if (result != continueButton)
Expand Down Expand Up @@ -414,7 +410,7 @@ private void Settings_Click(object? sender, EventArgs e)
Dock = DockStyle.Top,
Font = new Font("Segoe UI", 9F, FontStyle.Bold | FontStyle.Underline),
ForeColor = SystemColors.HotTrack,
Text = "https://steam-deck-tools.ayufan.dev",
Text = Dependencies.SDTURL,
TextAlign = ContentAlignment.MiddleCenter
};

Expand All @@ -432,8 +428,8 @@ private void Settings_Click(object? sender, EventArgs e)
Height = 100
};

helpLabel.Click += delegate { Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev"); };
donateLabel.Click += delegate { Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev/#help-this-project"); };
helpLabel.Click += delegate { Dependencies.OpenLink(Dependencies.SDTURL); };
donateLabel.Click += delegate { Dependencies.OpenLink(Dependencies.SDTURL + "/#help-this-project"); };
propertyGrid.ExpandAllGridItems();

form.Controls.Add(propertyGrid);
Expand Down

0 comments on commit d0c45a1

Please sign in to comment.