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> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<FileVersion>0.1.0</FileVersion> <FileVersion>0.2.0</FileVersion>
<AssemblyVersion>0.1.0</AssemblyVersion>
<Company>Jeddunk</Company> <Company>Jeddunk</Company>
</PropertyGroup> </PropertyGroup>

View File

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

View File

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

View File

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