mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Streamlined options and availability checks for limiters and fps sources
This commit is contained in:
@@ -79,19 +79,28 @@ namespace GHelper.AutoTDP
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int availableFS = 0;
|
return AvailablePowerLimiters().Count > 0 && AvailableFramerateSources().Count > 0;
|
||||||
int availablePL = 0;
|
}
|
||||||
|
|
||||||
//Requires RTSS to be installed
|
public static List<string> AvailableFramerateSources()
|
||||||
if (RTSSFramerateSource.IsAvailable()) availableFS++;
|
{
|
||||||
|
List<string> l = new List<string>();
|
||||||
|
|
||||||
//Intel MSR Limiter is available on Intel only
|
if (RTSSFramerateSource.IsAvailable()) l.Add("rtss");
|
||||||
if (IntelMSRPowerLimiter.IsAvailable()) availablePL++;
|
|
||||||
|
|
||||||
//ASUS ACPI Power limiter is available
|
return l;
|
||||||
if (ASUSACPIPowerLimiter.IsAvailable()) availablePL++;
|
}
|
||||||
|
|
||||||
return availablePL > 0 && availableFS > 0;
|
|
||||||
|
public static List<string> AvailablePowerLimiters()
|
||||||
|
{
|
||||||
|
List<string> l = new List<string>();
|
||||||
|
|
||||||
|
if (IntelMSRPowerLimiter.IsAvailable()) l.Add("intel_msr");
|
||||||
|
|
||||||
|
if (ASUSACPIPowerLimiter.IsAvailable()) l.Add("asus_acpi");
|
||||||
|
|
||||||
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
|
|||||||
@@ -2,11 +2,16 @@
|
|||||||
using GHelper.AutoTDP.PowerLimiter;
|
using GHelper.AutoTDP.PowerLimiter;
|
||||||
using GHelper.UI;
|
using GHelper.UI;
|
||||||
using Ryzen;
|
using Ryzen;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace GHelper.AutoTDP
|
namespace GHelper.AutoTDP
|
||||||
{
|
{
|
||||||
public partial class AutoTDPUI : RForm
|
public partial class AutoTDPUI : RForm
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private Dictionary<string, string> ModeTexts = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
|
||||||
private AutoTDPGameProfileUI? profileUI;
|
private AutoTDPGameProfileUI? profileUI;
|
||||||
public AutoTDPUI()
|
public AutoTDPUI()
|
||||||
{
|
{
|
||||||
@@ -14,6 +19,11 @@ namespace GHelper.AutoTDP
|
|||||||
|
|
||||||
InitTheme();
|
InitTheme();
|
||||||
|
|
||||||
|
|
||||||
|
ModeTexts.Add("intel_msr", "Intel MSR Power Limiter");
|
||||||
|
ModeTexts.Add("asus_acpi", "ASUS ACPI Power Limiter");
|
||||||
|
ModeTexts.Add("rtss", "Riva Tuner Statistics Server");
|
||||||
|
|
||||||
checkBoxEnabled.CheckedChanged += CheckBoxEnabled_CheckedChanged;
|
checkBoxEnabled.CheckedChanged += CheckBoxEnabled_CheckedChanged;
|
||||||
buttonAddGame.Click += ButtonAddGame_Click;
|
buttonAddGame.Click += ButtonAddGame_Click;
|
||||||
|
|
||||||
@@ -29,24 +39,13 @@ namespace GHelper.AutoTDP
|
|||||||
|
|
||||||
private void ComboBoxFPSSource_DropDownClosed(object? sender, EventArgs e)
|
private void ComboBoxFPSSource_DropDownClosed(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if ((comboBoxFPSSource.SelectedItem as string).StartsWith("Riva"))
|
AppConfig.Set("auto_tdp_fps_source", AutoTDPService.AvailableFramerateSources().ElementAt(comboBoxFPSSource.SelectedIndex));
|
||||||
{
|
|
||||||
AppConfig.Set("auto_tdp_fps_source", "rtss");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ComboBoxLimiter_DropDownClosed(object? sender, EventArgs e)
|
private void ComboBoxLimiter_DropDownClosed(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if ((comboBoxLimiter.SelectedItem as string).StartsWith("Intel"))
|
AppConfig.Set("auto_tdp_limiter", AutoTDPService.AvailablePowerLimiters().ElementAt(comboBoxLimiter.SelectedIndex));
|
||||||
{
|
|
||||||
AppConfig.Set("auto_tdp_limiter", "intel_msr");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ((comboBoxLimiter.SelectedItem as string).StartsWith("ASUS ACPI"))
|
|
||||||
{
|
|
||||||
AppConfig.Set("auto_tdp_limiter", "asus_acpi");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckBoxEnabled_CheckedChanged(object? sender, EventArgs e)
|
private void CheckBoxEnabled_CheckedChanged(object? sender, EventArgs e)
|
||||||
@@ -124,42 +123,42 @@ namespace GHelper.AutoTDP
|
|||||||
{
|
{
|
||||||
checkBoxEnabled.Checked = AppConfig.Get("auto_tdp_enabled", 0) == 1;
|
checkBoxEnabled.Checked = AppConfig.Get("auto_tdp_enabled", 0) == 1;
|
||||||
|
|
||||||
if (IntelMSRPowerLimiter.IsAvailable())
|
comboBoxLimiter.Items.Clear();
|
||||||
comboBoxLimiter.Items.Add("Intel MSR Power Limiter");
|
comboBoxFPSSource.Items.Clear();
|
||||||
|
|
||||||
|
foreach (string s in AutoTDPService.AvailablePowerLimiters())
|
||||||
comboBoxLimiter.Items.Add("ASUS ACPI Power Limiter");
|
|
||||||
|
|
||||||
string? limiter = AppConfig.GetString("auto_tdp_limiter");
|
|
||||||
|
|
||||||
if (comboBoxLimiter.Items.Count > 0 && limiter is null)
|
|
||||||
comboBoxLimiter.SelectedIndex = 0;
|
|
||||||
|
|
||||||
if (IntelMSRPowerLimiter.IsAvailable() && limiter is not null && limiter.Equals("intel_msr"))
|
|
||||||
{
|
{
|
||||||
comboBoxLimiter.SelectedIndex = 0;
|
comboBoxLimiter.Items.Add(ModeTexts[s]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (limiter is not null && limiter.Equals("asus_acpi") && ASUSACPIPowerLimiter.IsAvailable())
|
foreach (string s in AutoTDPService.AvailableFramerateSources())
|
||||||
{
|
{
|
||||||
comboBoxLimiter.SelectedIndex = IntelMSRPowerLimiter.IsAvailable() ? 1 : 0;
|
comboBoxFPSSource.Items.Add(ModeTexts[s]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string? limiter = AppConfig.GetString("auto_tdp_limiter", null);
|
||||||
if (RTSSFramerateSource.IsAvailable())
|
|
||||||
comboBoxFPSSource.Items.Add("Riva Tuner Statistics Server");
|
|
||||||
|
|
||||||
|
|
||||||
string? source = AppConfig.GetString("auto_tdp_fps_source", null);
|
string? source = AppConfig.GetString("auto_tdp_fps_source", null);
|
||||||
|
|
||||||
if (comboBoxFPSSource.Items.Count > 0 && source is null)
|
|
||||||
comboBoxFPSSource.SelectedIndex = 0;
|
|
||||||
|
|
||||||
if (source is not null && source.Equals("rtss"))
|
if (limiter is not null && AutoTDPService.AvailablePowerLimiters().Contains(limiter))
|
||||||
|
{
|
||||||
|
comboBoxLimiter.SelectedIndex = AutoTDPService.AvailablePowerLimiters().IndexOf(limiter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
comboBoxLimiter.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source is not null && AutoTDPService.AvailableFramerateSources().Contains(source))
|
||||||
|
{
|
||||||
|
comboBoxFPSSource.SelectedIndex = AutoTDPService.AvailableFramerateSources().IndexOf(source);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
comboBoxFPSSource.SelectedIndex = 0;
|
comboBoxFPSSource.SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user