mirror of
https://github.com/MathiasLui/CSGO-Projects.git
synced 2025-05-06 22:01:18 +00:00
Hopefully fix new SteamLibrary
* Fix value between 0 and 1 being shown as percentage, this is now multiplied by 100 * If CS:GO is not found, it will also return from the function as not to execute the background worker causing an exception * Using the new libraryfolders.vdf instead of the legacy config.vdf to fetch all libraryfolders. This is controllable via the new preprocessor directive NEWLIBRARYLOCATION
This commit is contained in:
parent
986762688a
commit
74be8dafc3
3 changed files with 49 additions and 2 deletions
|
@ -99,6 +99,7 @@ namespace Damage_Calculator
|
||||||
{
|
{
|
||||||
MessageBox.Show("Make sure you have installed CS:GO and Steam correctly.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show("Make sure you have installed CS:GO and Steam correctly.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
this.Close();
|
this.Close();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bgWorker.DoWork += BgWorker_DoWork;
|
bgWorker.DoWork += BgWorker_DoWork;
|
||||||
|
@ -1460,7 +1461,7 @@ namespace Damage_Calculator
|
||||||
this.txtWeaponBaseDamagePerMinute.Text = this.selectedWeapon.FireRate < 0 ? "?" : (this.selectedWeapon.BaseDamage * this.selectedWeapon.FireRate).ToString(CultureInfo.InvariantCulture);
|
this.txtWeaponBaseDamagePerMinute.Text = this.selectedWeapon.FireRate < 0 ? "?" : (this.selectedWeapon.BaseDamage * this.selectedWeapon.FireRate).ToString(CultureInfo.InvariantCulture);
|
||||||
this.txtWeaponFireRate.Text = this.selectedWeapon.FireRate.ToString(CultureInfo.InvariantCulture);
|
this.txtWeaponFireRate.Text = this.selectedWeapon.FireRate.ToString(CultureInfo.InvariantCulture);
|
||||||
this.txtWeaponArmorPenetration.Text = this.selectedWeapon.ArmorPenetration.ToString(CultureInfo.InvariantCulture) + " %";
|
this.txtWeaponArmorPenetration.Text = this.selectedWeapon.ArmorPenetration.ToString(CultureInfo.InvariantCulture) + " %";
|
||||||
this.txtWeaponDamageDropoff.Text = Math.Round(1d - this.selectedWeapon.DamageDropoff, 2).ToString(CultureInfo.InvariantCulture) + " %";
|
this.txtWeaponDamageDropoff.Text = (Math.Round(1d - this.selectedWeapon.DamageDropoff, 2) * 100).ToString(CultureInfo.InvariantCulture) + " %";
|
||||||
this.txtWeaponMaxRange.Text = this.selectedWeapon.MaxBulletRange.ToString(CultureInfo.InvariantCulture);
|
this.txtWeaponMaxRange.Text = this.selectedWeapon.MaxBulletRange.ToString(CultureInfo.InvariantCulture);
|
||||||
this.txtWeaponHeadshotModifier.Text = this.selectedWeapon.DamageType != DamageType.Shock ? this.selectedWeapon.HeadshotModifier.ToString(CultureInfo.InvariantCulture) : placeholderText;
|
this.txtWeaponHeadshotModifier.Text = this.selectedWeapon.DamageType != DamageType.Shock ? this.selectedWeapon.HeadshotModifier.ToString(CultureInfo.InvariantCulture) : placeholderText;
|
||||||
this.txtWeaponRunningSpeed.Text = this.selectedWeapon.RunningSpeed.ToString();
|
this.txtWeaponRunningSpeed.Text = this.selectedWeapon.RunningSpeed.ToString();
|
||||||
|
|
|
@ -94,6 +94,33 @@ namespace SteamShared
|
||||||
if (this.steamPath == null)
|
if (this.steamPath == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
// Usually the config.vdf had "BaseInstallFolder_" entries,
|
||||||
|
// now it seems that these entries don't exist anymore with reinstalls, and maybe they're not up-to-date anyways?
|
||||||
|
// Now we try reading the "libraryfolders.vdf", which now also contains the default library location
|
||||||
|
#if NEWLIBRARYLOCATION
|
||||||
|
string configFilePath = Path.Combine(this.steamPath, "config", "libraryfolders.vdf");
|
||||||
|
if (!File.Exists(configFilePath))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Fetch all libraries from the config
|
||||||
|
var configFile = new VDFFile(configFilePath);
|
||||||
|
IEnumerable<string>? foundSteamLibraries = configFile["libraryfolders"]?.Children.Select(c => c["path"]?.Value)!;
|
||||||
|
|
||||||
|
var allLibraries = new List<SteamLibrary>();
|
||||||
|
|
||||||
|
if (foundSteamLibraries?.Any() != true)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string foundLib in foundSteamLibraries!)
|
||||||
|
{
|
||||||
|
// All paths in the file are escaped
|
||||||
|
allLibraries.Add(new SteamLibrary(foundLib.Replace("\\\\", "\\")));
|
||||||
|
}
|
||||||
|
|
||||||
|
return allLibraries;
|
||||||
|
#else
|
||||||
string configFilePath = Path.Combine(this.steamPath, "config\\config.vdf");
|
string configFilePath = Path.Combine(this.steamPath, "config\\config.vdf");
|
||||||
if (!File.Exists(configFilePath))
|
if (!File.Exists(configFilePath))
|
||||||
return null;
|
return null;
|
||||||
|
@ -104,12 +131,15 @@ namespace SteamShared
|
||||||
|
|
||||||
// List libraries plus default Steam directory, because that's the default library
|
// List libraries plus default Steam directory, because that's the default library
|
||||||
var allLibraries = new List<SteamLibrary> { new SteamLibrary(this.steamPath) };
|
var allLibraries = new List<SteamLibrary> { new SteamLibrary(this.steamPath) };
|
||||||
foreach(string addLib in additionalSteamLibraries!)
|
|
||||||
|
foreach (string addLib in additionalSteamLibraries!)
|
||||||
{
|
{
|
||||||
|
// All paths in the file are escaped
|
||||||
allLibraries.Add(new SteamLibrary(addLib.Replace("\\\\", "\\")));
|
allLibraries.Add(new SteamLibrary(addLib.Replace("\\\\", "\\")));
|
||||||
}
|
}
|
||||||
|
|
||||||
return allLibraries;
|
return allLibraries;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SteamGame>? GetInstalledGames()
|
public List<SteamGame>? GetInstalledGames()
|
||||||
|
|
|
@ -7,6 +7,22 @@
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
<DefineConstants>$(DefineConstants)TRACE;NEWLIBRARYLOCATION</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
|
<DefineConstants>$(DefineConstants)TRACE;NEWLIBRARYLOCATION</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<DefineConstants>$(DefineConstants)TRACE;NEWLIBRARYLOCATION</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<DefineConstants>$(DefineConstants)TRACE;NEWLIBRARYLOCATION</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<RuntimeHostConfigurationOption Include="System.Globalization.UseNls" Value="true" />
|
<RuntimeHostConfigurationOption Include="System.Globalization.UseNls" Value="true" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
Loading…
Add table
Reference in a new issue