Add support for Studio without automatic detection

This commit is contained in:
Jakob 2021-05-08 17:29:21 +02:00
parent 71cdd9ab92
commit 29e65e6f0a
7 changed files with 84 additions and 14 deletions

View file

@ -6,11 +6,10 @@ namespace EnvyUpdate
{
class Debug
{
readonly static string debugFilePath = GlobalVars.exepath + "debug.txt";
public static int LoadFakeIDs(string idType)
{
/*
* Usage: Supply /debug flag to exe. Imitates a GTX 1080ti on Win10 x64 non-dch.
* Usage: Supply /debug flag to exe. Imitates a GTX 1080ti on Win10 x64 non-dch Game Ready Driver.
*/
switch (idType)
{
@ -22,6 +21,8 @@ namespace EnvyUpdate
return 57;
case "dtcid":
return 0;
case "dtid":
return 1;
default:
return -1;
}

View file

@ -7,19 +7,23 @@
xmlns:p="clr-namespace:EnvyUpdate.Properties"
xmlns:tb="http://www.hardcodet.net/taskbar"
mc:Ignorable="d"
Title="EnvyUpdate" Height="160" Width="290" Icon="icon.ico" StateChanged="Window_StateChanged" Closing="Window_Closing" ResizeMode="CanMinimize">
Title="EnvyUpdate" Height="250" Width="300" Icon="icon.ico" StateChanged="Window_StateChanged" Closing="Window_Closing" ResizeMode="CanMinimize">
<Grid Margin="0,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="17*"/>
<RowDefinition Height="86*"/>
</Grid.RowDefinitions>
<tb:TaskbarIcon IconSource="/icon.ico" ToolTipText="EnvyUpdate" TrayLeftMouseDown="TaskbarIcon_TrayLeftMouseDown" Grid.RowSpan="3" />
<TextBlock HorizontalAlignment="Left" Margin="10,19,0,0" TextWrapping="Wrap" FontWeight="Bold" Width="151" Height="16" VerticalAlignment="Top" Grid.Row="1"><Run Text="{x:Static p:Resources.ui_localdriver}"/></TextBlock>
<TextBlock x:Name="textblockGPU" HorizontalAlignment="Right" Margin="0,19,10,0" TextWrapping="Wrap" Text="&lt;none&gt;" Width="106" Height="16" VerticalAlignment="Top" TextAlignment="Right" Grid.Row="1"/>
<TextBlock HorizontalAlignment="Left" Margin="10,81,0,0" TextWrapping="Wrap" FontWeight="Bold" Width="140" Height="16" VerticalAlignment="Top" Grid.Row="1"><Run Text="{x:Static p:Resources.ui_localdriver}"/></TextBlock>
<TextBlock x:Name="textblockGPU" HorizontalAlignment="Right" Margin="0,81,10,0" TextWrapping="Wrap" Text="&lt;none&gt;" Width="134" Height="16" VerticalAlignment="Top" TextAlignment="Right" Grid.Row="1"/>
<Button x:Name="buttonHelp" Content="..." Margin="0,12,10,0" Click="buttonHelp_Click" HorizontalAlignment="Right" Width="20" Height="20" VerticalAlignment="Top" Grid.RowSpan="2"/>
<TextBlock Margin="10,40,0,0" TextWrapping="Wrap" FontWeight="Bold" Grid.Row="1" HorizontalAlignment="Left" Width="151" Height="16" VerticalAlignment="Top"><Run Text="{x:Static p:Resources.ui_onlinedriver}"/></TextBlock>
<TextBlock x:Name="textblockOnline" HorizontalAlignment="Right" Margin="0,40,10,0" TextWrapping="Wrap" Text="&lt;none&gt;" Width="106" Grid.Row="1" Height="16" VerticalAlignment="Top" TextAlignment="Right"/>
<Button x:Name="buttonDL" Content="⟱" Margin="0,0,10,10" FontSize="20" Click="buttonDL_Click" Foreground="White" Background="#FF3CDA00" Visibility="Hidden" Grid.Row="1" HorizontalAlignment="Right" Width="30" Height="30" VerticalAlignment="Bottom"/>
<TextBlock Margin="10,102,0,0" TextWrapping="Wrap" FontWeight="Bold" Grid.Row="1" HorizontalAlignment="Left" Width="140" Height="16" VerticalAlignment="Top"><Run Text="{x:Static p:Resources.ui_onlinedriver}"/></TextBlock>
<TextBlock x:Name="textblockOnline" HorizontalAlignment="Right" Margin="0,102,10,0" TextWrapping="Wrap" Text="&lt;none&gt;" Width="134" Grid.Row="1" Height="16" VerticalAlignment="Top" TextAlignment="Right"/>
<Button x:Name="buttonDL" Content="⟱" Margin="10,130,10,10" FontSize="20" Click="buttonDL_Click" Foreground="White" Background="#FF3CDA00" Grid.Row="1" IsEnabled="False"/>
<TextBlock x:Name="textblockGPUName" Margin="10,14,35,0" TextWrapping="Wrap" Text="GPU..." Height="16" VerticalAlignment="Top" TextAlignment="Center" Grid.RowSpan="2" FontWeight="Bold"/>
<TextBlock HorizontalAlignment="Left" Margin="10,19,0,0" TextWrapping="Wrap" FontWeight="Bold" Width="140" Height="16" VerticalAlignment="Top" Grid.Row="1" Text="{x:Static p:Resources.ui_localdriver_type}"/>
<TextBlock x:Name="textblockLocalType" HorizontalAlignment="Right" Margin="0,19,10,0" TextWrapping="Wrap" Width="134" Height="16" VerticalAlignment="Top" TextAlignment="Right" Grid.Row="1"><Run Text="&lt;none&gt;"/><LineBreak/><Run/></TextBlock>
<RadioButton x:Name="radioGRD" Content="Game Ready Driver" HorizontalAlignment="Left" Margin="10,40,0,0" Grid.Row="1" VerticalAlignment="Top" IsChecked="True" Checked="radioGRD_Checked"/>
<RadioButton x:Name="radioSD" Content="Studio Driver" HorizontalAlignment="Left" Margin="10,60,0,0" Grid.Row="1" VerticalAlignment="Top" Checked="radioSD_Checked"/>
</Grid>
</Window>

View file

@ -46,6 +46,11 @@ namespace EnvyUpdate
GlobalVars.isMobile = Util.IsMobile();
if (Util.IsDCH())
textblockLocalType.Text = "DCH";
else
textblockLocalType.Text = "Standard";
string locDriv = Util.GetLocDriv();
if (locDriv != null)
{
@ -95,8 +100,12 @@ namespace EnvyUpdate
int pfid = 0;
int osid = 0;
int dtcid = 0;
int dtid = 0;
//int langid;
if (File.Exists(GlobalVars.exepath + "sd.envy"))
radioSD.IsChecked = true;
// This little bool check is necessary for debug mode on systems without an Nvidia GPU.
if (!isDebug)
{
@ -104,6 +113,7 @@ namespace EnvyUpdate
pfid = Util.GetIDs("pfid");
osid = Util.GetIDs("osid");
dtcid = Util.GetDTCID();
//dtid = Util.GetDTID();
}
else
{
@ -111,27 +121,38 @@ namespace EnvyUpdate
pfid = Debug.LoadFakeIDs("pfid");
osid = Debug.LoadFakeIDs("osid");
dtcid = Debug.LoadFakeIDs("dtcid");
dtid = Debug.LoadFakeIDs("dtid");
localDriv = Debug.LocalDriv();
textblockGPU.Text = localDriv;
textblockGPUName.Text = Debug.GPUname();
}
gpuURL = "http://www.nvidia.com/Download/processDriver.aspx?psid=" + psid.ToString() + "&pfid=" + pfid.ToString() + "&osid=" + osid.ToString() + "&dtcid=" + dtcid.ToString(); // + "&lid=" + langid.ToString();
//Temporary Studio Driver override logic
try
{
if (radioSD.IsChecked == true)
dtid = 18;
else
dtid = 1;
}
catch (NullReferenceException)
{ }
gpuURL = "http://www.nvidia.com/Download/processDriver.aspx?psid=" + psid.ToString() + "&pfid=" + pfid.ToString() + "&osid=" + osid.ToString() + "&dtcid=" + dtcid.ToString() + "&dtid=" + dtid.ToString(); // + "&lid=" + langid.ToString();
WebClient c = new WebClient();
gpuURL = c.DownloadString(gpuURL);
string pContent = c.DownloadString(gpuURL);
var pattern = @"\d{3}\.\d{2}&nbsp";
var pattern = @"Windows\/\d{3}\.\d{2}";
Regex rgx = new Regex(pattern);
var matches = rgx.Matches(pContent);
onlineDriv = Convert.ToString(matches[0]);
onlineDriv = onlineDriv.Remove(onlineDriv.Length - 5);
onlineDriv = Regex.Replace(Convert.ToString(matches[0]), "Windows/", "");
textblockOnline.Text = onlineDriv;
c.Dispose();
if (float.Parse(localDriv) < float.Parse(onlineDriv))
{
textblockOnline.Foreground = Brushes.Red;
buttonDL.Visibility = Visibility.Visible;
buttonDL.IsEnabled = true;
Notify.ShowDrivUpdatePopup();
}
else
@ -191,5 +212,23 @@ namespace EnvyUpdate
else
e.Cancel = true;
}
private void radioGRD_Checked(object sender, RoutedEventArgs e)
{
if (File.Exists(GlobalVars.exepath + "sd.envy"))
{
File.Delete(GlobalVars.exepath + "sd.envy");
Load();
}
}
private void radioSD_Checked(object sender, RoutedEventArgs e)
{
if (!File.Exists(GlobalVars.exepath + "sd.envy"))
{
File.Create(GlobalVars.exepath + "sd.envy").Close();
Load();
}
}
}
}

View file

@ -177,6 +177,15 @@ namespace EnvyUpdate.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Local driver type:.
/// </summary>
public static string ui_localdriver_type {
get {
return ResourceManager.GetString("ui_localdriver_type", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Online driver version:.
/// </summary>

View file

@ -156,6 +156,9 @@
<data name="ui_localdriver" xml:space="preserve">
<value>Lokale Treiberversion:</value>
</data>
<data name="ui_localdriver_type" xml:space="preserve">
<value>Lokaler Treibertyp:</value>
</data>
<data name="ui_onlinedriver" xml:space="preserve">
<value>Online Treiberversion:</value>
</data>

View file

@ -156,6 +156,9 @@
<data name="ui_localdriver" xml:space="preserve">
<value>Local driver version:</value>
</data>
<data name="ui_localdriver_type" xml:space="preserve">
<value>Local driver type:</value>
</data>
<data name="ui_onlinedriver" xml:space="preserve">
<value>Online driver version:</value>
</data>

View file

@ -336,7 +336,7 @@ namespace EnvyUpdate
}
catch (Exception ex)
{
if (ex.InnerException is NullReferenceException)
if (ex.Message == "Object reference not set to an instance of an object." || ex.InnerException is NullReferenceException)
{
// Assume no DCH driver is installed if key is not found.
return false;
@ -369,5 +369,16 @@ namespace EnvyUpdate
}
return dtcid;
}
public static int GetDTID()
{
/*
* 1 = Game Ready Driver (GRD)
* 18 = Studio Driver (SD)
*/
//TODO: find way to differentiate between driver types
return 1;
}
}
}