Fixed saving/loading app_paths.txt

This commit is contained in:
Jeddunk 2021-04-29 16:44:37 +02:00
parent 0c1c1226fb
commit 0be8f4ad8c
4 changed files with 23 additions and 15 deletions

View File

@ -2,8 +2,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<FileVersion>0.1.0</FileVersion>
<AssemblyVersion>0.1.0</AssemblyVersion>
<FileVersion>0.2.0</FileVersion>
<Company>Jeddunk</Company>
</PropertyGroup>

View File

@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable UnusedMember.Global
namespace GoldbergGUI.Core.Models
{
@ -67,8 +69,6 @@ namespace GoldbergGUI.Core.Models
public class DlcApp : SteamApp
{
//public int? DepotId { get; set; }
//public string DepotName { get; set; }
/// <summary>
/// Path to DLC (relative to Steam API DLL) (optional)
/// </summary>
@ -100,7 +100,7 @@ namespace GoldbergGUI.Core.Models
public string Description { get; set; }
/// <summary>
/// Human readable name, as shown on webpage, game libary, overlay, etc.
/// Human readable name, as shown on webpage, game library, overlay, etc.
/// </summary>
[JsonPropertyName("displayName")]
public string DisplayName { get; set; }
@ -120,6 +120,7 @@ namespace GoldbergGUI.Core.Models
/// <summary>
/// Path to icon when locked (grayed out).
/// </summary>
// ReSharper disable once StringLiteralTypo
[JsonPropertyName("icongray")]
public string IconGray { get; set; }
@ -188,9 +189,10 @@ namespace GoldbergGUI.Core.Models
// [JsonConverter(typeof(FluffyParseStringConverter))]
public long DropMaxPerWindow { get; set; }
// ReSharper disable once StringLiteralTypo
[JsonPropertyName("workshopid")]
// [JsonConverter(typeof(FluffyParseStringConverter))]
public long Workshopid { get; set; }
public long WorkshopId { get; set; }
[JsonPropertyName("tw_unique_to_own")]
// [JsonConverter(typeof(PurpleParseStringConverter))]

View File

@ -243,14 +243,15 @@ namespace GoldbergGUI.Core.Services
// ReSharper disable once InvertIf
if (File.Exists(appPathTxt))
{
var appPathAllLinesAsync = await File.ReadAllLinesAsync(dlcTxt).ConfigureAwait(false);
var appPathAllLinesAsync = await File.ReadAllLinesAsync(appPathTxt).ConfigureAwait(false);
var appPathExpression = new Regex(@"(?<id>.*) *= *(?<appPath>.*)");
foreach (var line in appPathAllLinesAsync)
{
var match = appPathExpression.Match(line);
if (match.Success)
dlcList[Convert.ToInt32(match.Groups["id"].Value)].AppPath =
match.Groups["appPath"].Value;
if (!match.Success) continue;
var i = dlcList.FindIndex(x =>
x.AppId.Equals(Convert.ToInt32(match.Groups["id"].Value)));
dlcList[i].AppPath = match.Groups["appPath"].Value;
}
}
}
@ -313,22 +314,29 @@ namespace GoldbergGUI.Core.Services
{
dlcContent += $"{x}\n";
//depotContent += $"{x.DepotId}\n";
appPathContent += $"{x.AppId}={x.AppPath}\n";
if (!string.IsNullOrEmpty(x.AppPath))
appPathContent += $"{x.AppId}={x.AppPath}\n";
});
await File.WriteAllTextAsync(Path.Combine(path, "steam_settings", "DLC.txt"), dlcContent)
.ConfigureAwait(false);
/*if (!string.Equals(depotContent, ""))
/*if (!string.IsNullOrEmpty(depotContent))
{
await File.WriteAllTextAsync(Path.Combine(path, "steam_settings", "depots.txt"), depotContent)
.ConfigureAwait(false);
}*/
if (!string.Equals(appPathContent, ""))
if (!string.IsNullOrEmpty(appPathContent))
{
await File.WriteAllTextAsync(Path.Combine(path, "steam_settings", "app_paths.txt"), appPathContent)
.ConfigureAwait(false);
}
else
{
if (File.Exists(Path.Combine(path, "steam_settings", "app_paths.txt")))
File.Delete(Path.Combine(path, "steam_settings", "app_paths.txt"));
}
_log.Info("Saved DLC settings.");
}
else

View File

@ -4,8 +4,7 @@
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<FileVersion>0.1.0</FileVersion>
<AssemblyVersion>0.1.0</AssemblyVersion>
<FileVersion>0.2.0</FileVersion>
<Company>Jeddunk</Company>
</PropertyGroup>