update dependencies
This commit is contained in:
parent
23162d090e
commit
6518361824
@ -8,12 +8,12 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AngleSharp" Version="0.14.0" />
|
<PackageReference Include="AngleSharp" Version="0.16.1" />
|
||||||
<PackageReference Include="MvvmCross" Version="7.1.2" />
|
<PackageReference Include="MvvmCross" Version="8.0.2" />
|
||||||
<PackageReference Include="NinjaNye.SearchExtensions" Version="3.0.1" />
|
<PackageReference Include="NinjaNye.SearchExtensions" Version="3.0.1" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
|
||||||
<PackageReference Include="sqlite-net-pcl" Version="1.7.335" />
|
<PackageReference Include="SharpCompress" Version="0.31.0" />
|
||||||
<PackageReference Include="SteamStorefrontAPI.NETStandard" Version="1.0.0" />
|
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using GoldbergGUI.Core.Models;
|
using GoldbergGUI.Core.Models;
|
||||||
using GoldbergGUI.Core.Utils;
|
using GoldbergGUI.Core.Utils;
|
||||||
using MvvmCross.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -18,7 +18,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
// does file copy stuff
|
// does file copy stuff
|
||||||
public interface IGoldbergService
|
public interface IGoldbergService
|
||||||
{
|
{
|
||||||
public Task<GoldbergGlobalConfiguration> Initialize(IMvxLog log);
|
public Task<GoldbergGlobalConfiguration> Initialize(ILogger<IGoldbergService> log);
|
||||||
public Task<GoldbergConfiguration> Read(string path);
|
public Task<GoldbergConfiguration> Read(string path);
|
||||||
public Task Save(string path, GoldbergConfiguration configuration);
|
public Task Save(string path, GoldbergConfiguration configuration);
|
||||||
public Task<GoldbergGlobalConfiguration> GetGlobalSettings();
|
public Task<GoldbergGlobalConfiguration> GetGlobalSettings();
|
||||||
@ -32,7 +32,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
// ReSharper disable once ClassNeverInstantiated.Global
|
// ReSharper disable once ClassNeverInstantiated.Global
|
||||||
public class GoldbergService : IGoldbergService
|
public class GoldbergService : IGoldbergService
|
||||||
{
|
{
|
||||||
private IMvxLog _log;
|
private ILogger<IGoldbergService> _log;
|
||||||
private const string DefaultAccountName = "Mr_Goldberg";
|
private const string DefaultAccountName = "Mr_Goldberg";
|
||||||
private const long DefaultSteamId = 76561197960287930;
|
private const long DefaultSteamId = 76561197960287930;
|
||||||
private const string DefaultLanguage = "english";
|
private const string DefaultLanguage = "english";
|
||||||
@ -82,7 +82,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
|
|
||||||
// Call Download
|
// Call Download
|
||||||
// Get global settings
|
// Get global settings
|
||||||
public async Task<GoldbergGlobalConfiguration> Initialize(IMvxLog log)
|
public async Task<GoldbergGlobalConfiguration> Initialize(ILogger<IGoldbergService> log)
|
||||||
{
|
{
|
||||||
_log = log;
|
_log = log;
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
|
|
||||||
public async Task<GoldbergGlobalConfiguration> GetGlobalSettings()
|
public async Task<GoldbergGlobalConfiguration> GetGlobalSettings()
|
||||||
{
|
{
|
||||||
_log.Info("Getting global settings...");
|
_log.LogInformation("Getting global settings...");
|
||||||
var accountName = DefaultAccountName;
|
var accountName = DefaultAccountName;
|
||||||
var steamId = DefaultSteamId;
|
var steamId = DefaultSteamId;
|
||||||
var language = DefaultLanguage;
|
var language = DefaultLanguage;
|
||||||
@ -110,7 +110,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
!long.TryParse(File.ReadLines(_userSteamIdPath).First().Trim(), out steamId) &&
|
!long.TryParse(File.ReadLines(_userSteamIdPath).First().Trim(), out steamId) &&
|
||||||
steamId < 76561197960265729 && steamId > 76561202255233023)
|
steamId < 76561197960265729 && steamId > 76561202255233023)
|
||||||
{
|
{
|
||||||
_log.Error("Invalid User Steam ID! Using default Steam ID...");
|
_log.LogError("Invalid User Steam ID! Using default Steam ID...");
|
||||||
steamId = DefaultSteamId;
|
steamId = DefaultSteamId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
customBroadcastIps.AddRange(
|
customBroadcastIps.AddRange(
|
||||||
File.ReadLines(_customBroadcastIpsPath).Select(line => line.Trim()));
|
File.ReadLines(_customBroadcastIpsPath).Select(line => line.Trim()));
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
_log.Info("Got global settings.");
|
_log.LogInformation("Got global settings.");
|
||||||
return new GoldbergGlobalConfiguration
|
return new GoldbergGlobalConfiguration
|
||||||
{
|
{
|
||||||
AccountName = accountName,
|
AccountName = accountName,
|
||||||
@ -135,18 +135,18 @@ namespace GoldbergGUI.Core.Services
|
|||||||
var userSteamId = c.UserSteamId;
|
var userSteamId = c.UserSteamId;
|
||||||
var language = c.Language;
|
var language = c.Language;
|
||||||
var customBroadcastIps = c.CustomBroadcastIps;
|
var customBroadcastIps = c.CustomBroadcastIps;
|
||||||
_log.Info("Setting global settings...");
|
_log.LogInformation("Setting global settings...");
|
||||||
// Account Name
|
// Account Name
|
||||||
if (!string.IsNullOrEmpty(accountName))
|
if (!string.IsNullOrEmpty(accountName))
|
||||||
{
|
{
|
||||||
_log.Info("Setting account name...");
|
_log.LogInformation("Setting account name...");
|
||||||
if (!File.Exists(_accountNamePath))
|
if (!File.Exists(_accountNamePath))
|
||||||
await File.Create(_accountNamePath).DisposeAsync().ConfigureAwait(false);
|
await File.Create(_accountNamePath).DisposeAsync().ConfigureAwait(false);
|
||||||
await File.WriteAllTextAsync(_accountNamePath, accountName).ConfigureAwait(false);
|
await File.WriteAllTextAsync(_accountNamePath, accountName).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Info("Invalid account name! Skipping...");
|
_log.LogInformation("Invalid account name! Skipping...");
|
||||||
if (!File.Exists(_accountNamePath))
|
if (!File.Exists(_accountNamePath))
|
||||||
await File.Create(_accountNamePath).DisposeAsync().ConfigureAwait(false);
|
await File.Create(_accountNamePath).DisposeAsync().ConfigureAwait(false);
|
||||||
await File.WriteAllTextAsync(_accountNamePath, DefaultAccountName).ConfigureAwait(false);
|
await File.WriteAllTextAsync(_accountNamePath, DefaultAccountName).ConfigureAwait(false);
|
||||||
@ -155,14 +155,14 @@ namespace GoldbergGUI.Core.Services
|
|||||||
// User SteamID
|
// User SteamID
|
||||||
if (userSteamId >= 76561197960265729 && userSteamId <= 76561202255233023)
|
if (userSteamId >= 76561197960265729 && userSteamId <= 76561202255233023)
|
||||||
{
|
{
|
||||||
_log.Info("Setting user Steam ID...");
|
_log.LogInformation("Setting user Steam ID...");
|
||||||
if (!File.Exists(_userSteamIdPath))
|
if (!File.Exists(_userSteamIdPath))
|
||||||
await File.Create(_userSteamIdPath).DisposeAsync().ConfigureAwait(false);
|
await File.Create(_userSteamIdPath).DisposeAsync().ConfigureAwait(false);
|
||||||
await File.WriteAllTextAsync(_userSteamIdPath, userSteamId.ToString()).ConfigureAwait(false);
|
await File.WriteAllTextAsync(_userSteamIdPath, userSteamId.ToString()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Info("Invalid user Steam ID! Skipping...");
|
_log.LogInformation("Invalid user Steam ID! Skipping...");
|
||||||
if (!File.Exists(_userSteamIdPath))
|
if (!File.Exists(_userSteamIdPath))
|
||||||
await File.Create(_userSteamIdPath).DisposeAsync().ConfigureAwait(false);
|
await File.Create(_userSteamIdPath).DisposeAsync().ConfigureAwait(false);
|
||||||
await File.WriteAllTextAsync(_userSteamIdPath, DefaultSteamId.ToString()).ConfigureAwait(false);
|
await File.WriteAllTextAsync(_userSteamIdPath, DefaultSteamId.ToString()).ConfigureAwait(false);
|
||||||
@ -171,14 +171,14 @@ namespace GoldbergGUI.Core.Services
|
|||||||
// Language
|
// Language
|
||||||
if (!string.IsNullOrEmpty(language))
|
if (!string.IsNullOrEmpty(language))
|
||||||
{
|
{
|
||||||
_log.Info("Setting language...");
|
_log.LogInformation("Setting language...");
|
||||||
if (!File.Exists(_languagePath))
|
if (!File.Exists(_languagePath))
|
||||||
await File.Create(_languagePath).DisposeAsync().ConfigureAwait(false);
|
await File.Create(_languagePath).DisposeAsync().ConfigureAwait(false);
|
||||||
await File.WriteAllTextAsync(_languagePath, language).ConfigureAwait(false);
|
await File.WriteAllTextAsync(_languagePath, language).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Info("Invalid language! Skipping...");
|
_log.LogInformation("Invalid language! Skipping...");
|
||||||
if (!File.Exists(_languagePath))
|
if (!File.Exists(_languagePath))
|
||||||
await File.Create(_languagePath).DisposeAsync().ConfigureAwait(false);
|
await File.Create(_languagePath).DisposeAsync().ConfigureAwait(false);
|
||||||
await File.WriteAllTextAsync(_languagePath, DefaultLanguage).ConfigureAwait(false);
|
await File.WriteAllTextAsync(_languagePath, DefaultLanguage).ConfigureAwait(false);
|
||||||
@ -187,7 +187,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
// Custom Broadcast IPs
|
// Custom Broadcast IPs
|
||||||
if (customBroadcastIps != null && customBroadcastIps.Count > 0)
|
if (customBroadcastIps != null && customBroadcastIps.Count > 0)
|
||||||
{
|
{
|
||||||
_log.Info("Setting custom broadcast IPs...");
|
_log.LogInformation("Setting custom broadcast IPs...");
|
||||||
var result =
|
var result =
|
||||||
customBroadcastIps.Aggregate("", (current, address) => $"{current}{address}\n");
|
customBroadcastIps.Aggregate("", (current, address) => $"{current}{address}\n");
|
||||||
if (!File.Exists(_customBroadcastIpsPath))
|
if (!File.Exists(_customBroadcastIpsPath))
|
||||||
@ -196,50 +196,50 @@ namespace GoldbergGUI.Core.Services
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Info("Empty list of custom broadcast IPs! Skipping...");
|
_log.LogInformation("Empty list of custom broadcast IPs! Skipping...");
|
||||||
await Task.Run(() => File.Delete(_customBroadcastIpsPath)).ConfigureAwait(false);
|
await Task.Run(() => File.Delete(_customBroadcastIpsPath)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
_log.Info("Setting global configuration finished.");
|
_log.LogInformation("Setting global configuration finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If first time, call GenerateInterfaces
|
// If first time, call GenerateInterfaces
|
||||||
// else try to read config
|
// else try to read config
|
||||||
public async Task<GoldbergConfiguration> Read(string path)
|
public async Task<GoldbergConfiguration> Read(string path)
|
||||||
{
|
{
|
||||||
_log.Info("Reading configuration...");
|
_log.LogInformation("Reading configuration...");
|
||||||
var appId = -1;
|
var appId = -1;
|
||||||
var achievementList = new List<Achievement>();
|
var achievementList = new List<Achievement>();
|
||||||
var dlcList = new List<DlcApp>();
|
var dlcList = new List<DlcApp>();
|
||||||
var steamAppidTxt = Path.Combine(path, "steam_appid.txt");
|
var steamAppidTxt = Path.Combine(path, "steam_appid.txt");
|
||||||
if (File.Exists(steamAppidTxt))
|
if (File.Exists(steamAppidTxt))
|
||||||
{
|
{
|
||||||
_log.Info("Getting AppID...");
|
_log.LogInformation("Getting AppID...");
|
||||||
await Task.Run(() => int.TryParse(File.ReadLines(steamAppidTxt).First().Trim(), out appId))
|
await Task.Run(() => int.TryParse(File.ReadLines(steamAppidTxt).First().Trim(), out appId))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Info(@"""steam_appid.txt"" missing! Skipping...");
|
_log.LogInformation(@"""steam_appid.txt"" missing! Skipping...");
|
||||||
}
|
}
|
||||||
|
|
||||||
var achievementJson = Path.Combine(path, "steam_settings", "achievements.json");
|
var achievementJson = Path.Combine(path, "steam_settings", "achievements.json");
|
||||||
if (File.Exists(achievementJson))
|
if (File.Exists(achievementJson))
|
||||||
{
|
{
|
||||||
_log.Info("Getting achievements...");
|
_log.LogInformation("Getting achievements...");
|
||||||
var json = await File.ReadAllTextAsync(achievementJson)
|
var json = await File.ReadAllTextAsync(achievementJson)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
achievementList = System.Text.Json.JsonSerializer.Deserialize<List<Achievement>>(json);
|
achievementList = System.Text.Json.JsonSerializer.Deserialize<List<Achievement>>(json);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Info(@"""steam_settings/achievements.json"" missing! Skipping...");
|
_log.LogInformation(@"""steam_settings/achievements.json"" missing! Skipping...");
|
||||||
}
|
}
|
||||||
|
|
||||||
var dlcTxt = Path.Combine(path, "steam_settings", "DLC.txt");
|
var dlcTxt = Path.Combine(path, "steam_settings", "DLC.txt");
|
||||||
var appPathTxt = Path.Combine(path, "steam_settings", "app_paths.txt");
|
var appPathTxt = Path.Combine(path, "steam_settings", "app_paths.txt");
|
||||||
if (File.Exists(dlcTxt))
|
if (File.Exists(dlcTxt))
|
||||||
{
|
{
|
||||||
_log.Info("Getting DLCs...");
|
_log.LogInformation("Getting DLCs...");
|
||||||
var readAllLinesAsync = await File.ReadAllLinesAsync(dlcTxt).ConfigureAwait(false);
|
var readAllLinesAsync = await File.ReadAllLinesAsync(dlcTxt).ConfigureAwait(false);
|
||||||
var expression = new Regex(@"(?<id>.*) *= *(?<name>.*)");
|
var expression = new Regex(@"(?<id>.*) *= *(?<name>.*)");
|
||||||
// ReSharper disable once LoopCanBeConvertedToQuery
|
// ReSharper disable once LoopCanBeConvertedToQuery
|
||||||
@ -271,7 +271,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Info(@"""steam_settings/DLC.txt"" missing! Skipping...");
|
_log.LogInformation(@"""steam_settings/DLC.txt"" missing! Skipping...");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GoldbergConfiguration
|
return new GoldbergConfiguration
|
||||||
@ -291,9 +291,9 @@ namespace GoldbergGUI.Core.Services
|
|||||||
// Save configuration files
|
// Save configuration files
|
||||||
public async Task Save(string path, GoldbergConfiguration c)
|
public async Task Save(string path, GoldbergConfiguration c)
|
||||||
{
|
{
|
||||||
_log.Info("Saving configuration...");
|
_log.LogInformation("Saving configuration...");
|
||||||
// DLL setup
|
// DLL setup
|
||||||
_log.Info("Running DLL setup...");
|
_log.LogInformation("Running DLL setup...");
|
||||||
const string x86Name = "steam_api";
|
const string x86Name = "steam_api";
|
||||||
const string x64Name = "steam_api64";
|
const string x64Name = "steam_api64";
|
||||||
if (File.Exists(Path.Combine(path, $"{x86Name}.dll")))
|
if (File.Exists(Path.Combine(path, $"{x86Name}.dll")))
|
||||||
@ -305,10 +305,10 @@ namespace GoldbergGUI.Core.Services
|
|||||||
{
|
{
|
||||||
CopyDllFiles(path, x64Name);
|
CopyDllFiles(path, x64Name);
|
||||||
}
|
}
|
||||||
_log.Info("DLL setup finished!");
|
_log.LogInformation("DLL setup finished!");
|
||||||
|
|
||||||
// Create steam_settings folder if missing
|
// Create steam_settings folder if missing
|
||||||
_log.Info("Saving settings...");
|
_log.LogInformation("Saving settings...");
|
||||||
if (!Directory.Exists(Path.Combine(path, "steam_settings")))
|
if (!Directory.Exists(Path.Combine(path, "steam_settings")))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.Combine(path, "steam_settings"));
|
Directory.CreateDirectory(Path.Combine(path, "steam_settings"));
|
||||||
@ -321,7 +321,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
// Achievements + Images
|
// Achievements + Images
|
||||||
if (c.Achievements.Count > 0)
|
if (c.Achievements.Count > 0)
|
||||||
{
|
{
|
||||||
_log.Info("Downloading images...");
|
_log.LogInformation("Downloading images...");
|
||||||
var imagePath = Path.Combine(path, "steam_settings", "images");
|
var imagePath = Path.Combine(path, "steam_settings", "images");
|
||||||
Directory.CreateDirectory(imagePath);
|
Directory.CreateDirectory(imagePath);
|
||||||
|
|
||||||
@ -335,7 +335,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
achievement.IconGray = $"images/{Path.GetFileName(achievement.IconGray)}";
|
achievement.IconGray = $"images/{Path.GetFileName(achievement.IconGray)}";
|
||||||
}
|
}
|
||||||
|
|
||||||
_log.Info("Saving achievements...");
|
_log.LogInformation("Saving achievements...");
|
||||||
|
|
||||||
var achievementJson = System.Text.Json.JsonSerializer.Serialize(
|
var achievementJson = System.Text.Json.JsonSerializer.Serialize(
|
||||||
c.Achievements,
|
c.Achievements,
|
||||||
@ -347,11 +347,11 @@ namespace GoldbergGUI.Core.Services
|
|||||||
await File.WriteAllTextAsync(Path.Combine(path, "steam_settings", "achievements.json"), achievementJson)
|
await File.WriteAllTextAsync(Path.Combine(path, "steam_settings", "achievements.json"), achievementJson)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
_log.Info("Finished saving achievements.");
|
_log.LogInformation("Finished saving achievements.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Info("No achievements set! Removing achievement files...");
|
_log.LogInformation("No achievements set! Removing achievement files...");
|
||||||
var imagePath = Path.Combine(path, "steam_settings", "images");
|
var imagePath = Path.Combine(path, "steam_settings", "images");
|
||||||
if (Directory.Exists(imagePath))
|
if (Directory.Exists(imagePath))
|
||||||
{
|
{
|
||||||
@ -362,13 +362,13 @@ namespace GoldbergGUI.Core.Services
|
|||||||
{
|
{
|
||||||
File.Delete(achievementPath);
|
File.Delete(achievementPath);
|
||||||
}
|
}
|
||||||
_log.Info("Removed achievement files.");
|
_log.LogInformation("Removed achievement files.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// DLC + App path
|
// DLC + App path
|
||||||
if (c.DlcList.Count > 0)
|
if (c.DlcList.Count > 0)
|
||||||
{
|
{
|
||||||
_log.Info("Saving DLC settings...");
|
_log.LogInformation("Saving DLC settings...");
|
||||||
var dlcContent = "";
|
var dlcContent = "";
|
||||||
//var depotContent = "";
|
//var depotContent = "";
|
||||||
var appPathContent = "";
|
var appPathContent = "";
|
||||||
@ -399,54 +399,54 @@ namespace GoldbergGUI.Core.Services
|
|||||||
if (File.Exists(Path.Combine(path, "steam_settings", "app_paths.txt")))
|
if (File.Exists(Path.Combine(path, "steam_settings", "app_paths.txt")))
|
||||||
File.Delete(Path.Combine(path, "steam_settings", "app_paths.txt"));
|
File.Delete(Path.Combine(path, "steam_settings", "app_paths.txt"));
|
||||||
}
|
}
|
||||||
_log.Info("Saved DLC settings.");
|
_log.LogInformation("Saved DLC settings.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Info("No DLC set! Removing DLC configuration files...");
|
_log.LogInformation("No DLC set! Removing DLC configuration files...");
|
||||||
if (File.Exists(Path.Combine(path, "steam_settings", "DLC.txt")))
|
if (File.Exists(Path.Combine(path, "steam_settings", "DLC.txt")))
|
||||||
File.Delete(Path.Combine(path, "steam_settings", "DLC.txt"));
|
File.Delete(Path.Combine(path, "steam_settings", "DLC.txt"));
|
||||||
if (File.Exists(Path.Combine(path, "steam_settings", "app_paths.txt")))
|
if (File.Exists(Path.Combine(path, "steam_settings", "app_paths.txt")))
|
||||||
File.Delete(Path.Combine(path, "steam_settings", "app_paths.txt"));
|
File.Delete(Path.Combine(path, "steam_settings", "app_paths.txt"));
|
||||||
_log.Info("Removed DLC configuration files.");
|
_log.LogInformation("Removed DLC configuration files.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Offline
|
// Offline
|
||||||
if (c.Offline)
|
if (c.Offline)
|
||||||
{
|
{
|
||||||
_log.Info("Create offline.txt");
|
_log.LogInformation("Create offline.txt");
|
||||||
await File.Create(Path.Combine(path, "steam_settings", "offline.txt")).DisposeAsync()
|
await File.Create(Path.Combine(path, "steam_settings", "offline.txt")).DisposeAsync()
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Info("Delete offline.txt if it exists");
|
_log.LogInformation("Delete offline.txt if it exists");
|
||||||
File.Delete(Path.Combine(path, "steam_settings", "offline.txt"));
|
File.Delete(Path.Combine(path, "steam_settings", "offline.txt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable Networking
|
// Disable Networking
|
||||||
if (c.DisableNetworking)
|
if (c.DisableNetworking)
|
||||||
{
|
{
|
||||||
_log.Info("Create disable_networking.txt");
|
_log.LogInformation("Create disable_networking.txt");
|
||||||
await File.Create(Path.Combine(path, "steam_settings", "disable_networking.txt")).DisposeAsync()
|
await File.Create(Path.Combine(path, "steam_settings", "disable_networking.txt")).DisposeAsync()
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Info("Delete disable_networking.txt if it exists");
|
_log.LogInformation("Delete disable_networking.txt if it exists");
|
||||||
File.Delete(Path.Combine(path, "steam_settings", "disable_networking.txt"));
|
File.Delete(Path.Combine(path, "steam_settings", "disable_networking.txt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable Overlay
|
// Disable Overlay
|
||||||
if (c.DisableOverlay)
|
if (c.DisableOverlay)
|
||||||
{
|
{
|
||||||
_log.Info("Create disable_overlay.txt");
|
_log.LogInformation("Create disable_overlay.txt");
|
||||||
await File.Create(Path.Combine(path, "steam_settings", "disable_overlay.txt")).DisposeAsync()
|
await File.Create(Path.Combine(path, "steam_settings", "disable_overlay.txt")).DisposeAsync()
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Info("Delete disable_overlay.txt if it exists");
|
_log.LogInformation("Delete disable_overlay.txt if it exists");
|
||||||
File.Delete(Path.Combine(path, "steam_settings", "disable_overlay.txt"));
|
File.Delete(Path.Combine(path, "steam_settings", "disable_overlay.txt"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -460,7 +460,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
|
|
||||||
if (!File.Exists(originalDll))
|
if (!File.Exists(originalDll))
|
||||||
{
|
{
|
||||||
_log.Info("Back up original Steam API DLL...");
|
_log.LogInformation("Back up original Steam API DLL...");
|
||||||
File.Move(steamApiDll, originalDll);
|
File.Move(steamApiDll, originalDll);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -469,7 +469,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
File.SetAttributes(guiBackup, FileAttributes.Hidden);
|
File.SetAttributes(guiBackup, FileAttributes.Hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
_log.Info("Copy Goldberg DLL to target path...");
|
_log.LogInformation("Copy Goldberg DLL to target path...");
|
||||||
File.Copy(goldbergDll, steamApiDll);
|
File.Copy(goldbergDll, steamApiDll);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,7 +477,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
{
|
{
|
||||||
var steamSettingsDirExists = Directory.Exists(Path.Combine(path, "steam_settings"));
|
var steamSettingsDirExists = Directory.Exists(Path.Combine(path, "steam_settings"));
|
||||||
var steamAppIdTxtExists = File.Exists(Path.Combine(path, "steam_appid.txt"));
|
var steamAppIdTxtExists = File.Exists(Path.Combine(path, "steam_appid.txt"));
|
||||||
_log.Debug($"Goldberg applied? {(steamSettingsDirExists && steamAppIdTxtExists).ToString()}");
|
_log.LogDebug($"Goldberg applied? {steamSettingsDirExists && steamAppIdTxtExists}");
|
||||||
return steamSettingsDirExists && steamAppIdTxtExists;
|
return steamSettingsDirExists && steamAppIdTxtExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,7 +486,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
// Get webpage
|
// Get webpage
|
||||||
// Get job id, compare with local if exists, save it if false or missing
|
// Get job id, compare with local if exists, save it if false or missing
|
||||||
// Get latest archive if mismatch, call Extract
|
// Get latest archive if mismatch, call Extract
|
||||||
_log.Info("Initializing download...");
|
_log.LogInformation("Initializing download...");
|
||||||
if (!Directory.Exists(_goldbergPath)) Directory.CreateDirectory(_goldbergPath);
|
if (!Directory.Exists(_goldbergPath)) Directory.CreateDirectory(_goldbergPath);
|
||||||
var client = new HttpClient();
|
var client = new HttpClient();
|
||||||
var response = await client.GetAsync(GoldbergUrl).ConfigureAwait(false);
|
var response = await client.GetAsync(GoldbergUrl).ConfigureAwait(false);
|
||||||
@ -499,23 +499,23 @@ namespace GoldbergGUI.Core.Services
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_log.Info("Check if update is needed...");
|
_log.LogInformation("Check if update is needed...");
|
||||||
var jobIdLocal = Convert.ToInt32(File.ReadLines(jobIdPath).First().Trim());
|
var jobIdLocal = Convert.ToInt32(File.ReadLines(jobIdPath).First().Trim());
|
||||||
var jobIdRemote = Convert.ToInt32(match.Groups["jobid"].Value);
|
var jobIdRemote = Convert.ToInt32(match.Groups["jobid"].Value);
|
||||||
_log.Debug($"job_id: local {jobIdLocal}; remote {jobIdRemote}");
|
_log.LogDebug($"job_id: local {jobIdLocal}; remote {jobIdRemote}");
|
||||||
if (jobIdLocal.Equals(jobIdRemote))
|
if (jobIdLocal.Equals(jobIdRemote))
|
||||||
{
|
{
|
||||||
_log.Info("Latest Goldberg emulator is already available! Skipping...");
|
_log.LogInformation("Latest Goldberg emulator is already available! Skipping...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
_log.Error("An error occured, local Goldberg setup might be broken!");
|
_log.LogError("An error occured, local Goldberg setup might be broken!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_log.Info("Starting download...");
|
_log.LogInformation("Starting download...");
|
||||||
await StartDownload(match.Value).ConfigureAwait(false);
|
await StartDownload(match.Value).ConfigureAwait(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -525,7 +525,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var client = new HttpClient();
|
var client = new HttpClient();
|
||||||
_log.Debug(downloadUrl);
|
_log.LogDebug(downloadUrl);
|
||||||
await using var fileStream = File.OpenWrite(_goldbergZipPath);
|
await using var fileStream = File.OpenWrite(_goldbergZipPath);
|
||||||
//client.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead)
|
//client.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead)
|
||||||
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Head, downloadUrl);
|
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Head, downloadUrl);
|
||||||
@ -539,7 +539,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
// Environment.Exit(128);
|
// Environment.Exit(128);
|
||||||
if (contentLength == fileLength)
|
if (contentLength == fileLength)
|
||||||
{
|
{
|
||||||
_log.Info("Download finished!");
|
_log.LogInformation("Download finished!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -550,7 +550,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ShowErrorMessage();
|
ShowErrorMessage();
|
||||||
_log.Error(e.ToString);
|
_log.LogError(e.ToString());
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -560,7 +560,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
private async Task Extract(string archivePath)
|
private async Task Extract(string archivePath)
|
||||||
{
|
{
|
||||||
var errorOccured = false;
|
var errorOccured = false;
|
||||||
_log.Debug("Start extraction...");
|
_log.LogDebug("Start extraction...");
|
||||||
Directory.Delete(_goldbergPath, true);
|
Directory.Delete(_goldbergPath, true);
|
||||||
Directory.CreateDirectory(_goldbergPath);
|
Directory.CreateDirectory(_goldbergPath);
|
||||||
using (var archive = await Task.Run(() => ZipFile.OpenRead(archivePath)).ConfigureAwait(false))
|
using (var archive = await Task.Run(() => ZipFile.OpenRead(archivePath)).ConfigureAwait(false))
|
||||||
@ -584,8 +584,8 @@ namespace GoldbergGUI.Core.Services
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
errorOccured = true;
|
errorOccured = true;
|
||||||
_log.Error($"Error while trying to extract {entry.FullName}");
|
_log.LogError($"Error while trying to extract {entry.FullName}");
|
||||||
_log.Error(e.ToString);
|
_log.LogError(e.ToString());
|
||||||
}
|
}
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -594,9 +594,9 @@ namespace GoldbergGUI.Core.Services
|
|||||||
if (errorOccured)
|
if (errorOccured)
|
||||||
{
|
{
|
||||||
ShowErrorMessage();
|
ShowErrorMessage();
|
||||||
_log.Warn("Error occured while extraction! Please setup Goldberg manually");
|
_log.LogWarning("Error occured while extraction! Please setup Goldberg manually");
|
||||||
}
|
}
|
||||||
_log.Info("Extraction was successful!");
|
_log.LogInformation("Extraction was successful!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowErrorMessage()
|
private void ShowErrorMessage()
|
||||||
@ -615,7 +615,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
// (maybe) check DLL date first
|
// (maybe) check DLL date first
|
||||||
public async Task GenerateInterfacesFile(string filePath)
|
public async Task GenerateInterfacesFile(string filePath)
|
||||||
{
|
{
|
||||||
_log.Debug($"GenerateInterfacesFile {filePath}");
|
_log.LogDebug($"GenerateInterfacesFile {filePath}");
|
||||||
//throw new NotImplementedException();
|
//throw new NotImplementedException();
|
||||||
// Get DLL content
|
// Get DLL content
|
||||||
var result = new HashSet<string>();
|
var result = new HashSet<string>();
|
||||||
@ -694,7 +694,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
}
|
}
|
||||||
else if (imageUrl.StartsWith("images/"))
|
else if (imageUrl.StartsWith("images/"))
|
||||||
{
|
{
|
||||||
_log.Warn($"Previously downloaded image '{imageUrl}' is now missing!");
|
_log.LogWarning($"Previously downloaded image '{imageUrl}' is now missing!");
|
||||||
}
|
}
|
||||||
|
|
||||||
var wc = new System.Net.WebClient();
|
var wc = new System.Net.WebClient();
|
||||||
|
@ -2,7 +2,7 @@ using AngleSharp.Dom;
|
|||||||
using AngleSharp.Html.Parser;
|
using AngleSharp.Html.Parser;
|
||||||
using GoldbergGUI.Core.Models;
|
using GoldbergGUI.Core.Models;
|
||||||
using GoldbergGUI.Core.Utils;
|
using GoldbergGUI.Core.Utils;
|
||||||
using MvvmCross.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using NinjaNye.SearchExtensions;
|
using NinjaNye.SearchExtensions;
|
||||||
using SQLite;
|
using SQLite;
|
||||||
using SteamStorefrontAPI;
|
using SteamStorefrontAPI;
|
||||||
@ -19,7 +19,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
// gets info from steam api
|
// gets info from steam api
|
||||||
public interface ISteamService
|
public interface ISteamService
|
||||||
{
|
{
|
||||||
public Task Initialize(IMvxLog log);
|
public Task Initialize(ILogger<ISteamService> log);
|
||||||
public Task<IEnumerable<SteamApp>> GetListOfAppsByName(string name);
|
public Task<IEnumerable<SteamApp>> GetListOfAppsByName(string name);
|
||||||
public Task<SteamApp> GetAppByName(string name);
|
public Task<SteamApp> GetAppByName(string name);
|
||||||
public Task<SteamApp> GetAppById(int appid);
|
public Task<SteamApp> GetAppById(int appid);
|
||||||
@ -84,11 +84,11 @@ namespace GoldbergGUI.Core.Services
|
|||||||
private const string Database = "steamapps.cache";
|
private const string Database = "steamapps.cache";
|
||||||
private const string GameSchemaUrl = "https://api.steampowered.com/ISteamUserStats/GetSchemaForGame/v2/";
|
private const string GameSchemaUrl = "https://api.steampowered.com/ISteamUserStats/GetSchemaForGame/v2/";
|
||||||
|
|
||||||
private IMvxLog _log;
|
private ILogger<ISteamService> _log;
|
||||||
|
|
||||||
private SQLiteAsyncConnection _db;
|
private SQLiteAsyncConnection _db;
|
||||||
|
|
||||||
public async Task Initialize(IMvxLog log)
|
public async Task Initialize(ILogger<ISteamService> log)
|
||||||
{
|
{
|
||||||
static SteamApps DeserializeSteamApps(Type type, string cacheString)
|
static SteamApps DeserializeSteamApps(Type type, string cacheString)
|
||||||
{
|
{
|
||||||
@ -101,7 +101,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
_db = new SQLiteAsyncConnection(Database);
|
_db = new SQLiteAsyncConnection(Database);
|
||||||
//_db.CreateTable<SteamApp>();
|
//_db.CreateTable<SteamApp>();
|
||||||
await _db.CreateTableAsync<SteamApp>()
|
await _db.CreateTableAsync<SteamApp>()
|
||||||
//.ContinueWith(x => _log.Debug("Table success!"))
|
//.ContinueWith(x => _log.LogDebug("Table success!"))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var countAsync = await _db.Table<SteamApp>().CountAsync().ConfigureAwait(false);
|
var countAsync = await _db.Table<SteamApp>().CountAsync().ConfigureAwait(false);
|
||||||
@ -109,7 +109,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
{
|
{
|
||||||
foreach (var (appType, steamCache) in _caches)
|
foreach (var (appType, steamCache) in _caches)
|
||||||
{
|
{
|
||||||
_log.Info($"Updating cache ({appType})...");
|
_log.LogInformation($"Updating cache ({appType})...");
|
||||||
bool haveMoreResults;
|
bool haveMoreResults;
|
||||||
long lastAppId = 0;
|
long lastAppId = 0;
|
||||||
var client = new HttpClient();
|
var client = new HttpClient();
|
||||||
@ -152,21 +152,21 @@ namespace GoldbergGUI.Core.Services
|
|||||||
|
|
||||||
public async Task<SteamApp> GetAppByName(string name)
|
public async Task<SteamApp> GetAppByName(string name)
|
||||||
{
|
{
|
||||||
_log.Info($"Trying to get app {name}");
|
_log.LogInformation($"Trying to get app {name}");
|
||||||
var comparableName = PrepareStringToCompare(name);
|
var comparableName = PrepareStringToCompare(name);
|
||||||
var app = await _db.Table<SteamApp>()
|
var app = await _db.Table<SteamApp>()
|
||||||
.FirstOrDefaultAsync(x => x.AppType == AppTypeGame && x.ComparableName.Equals(comparableName))
|
.FirstOrDefaultAsync(x => x.AppType == AppTypeGame && x.ComparableName.Equals(comparableName))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
if (app != null) _log.Info($"Successfully got app {app}");
|
if (app != null) _log.LogInformation($"Successfully got app {app}");
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SteamApp> GetAppById(int appid)
|
public async Task<SteamApp> GetAppById(int appid)
|
||||||
{
|
{
|
||||||
_log.Info($"Trying to get app with ID {appid}");
|
_log.LogInformation($"Trying to get app with ID {appid}");
|
||||||
var app = await _db.Table<SteamApp>().Where(x => x.AppType == AppTypeGame)
|
var app = await _db.Table<SteamApp>().Where(x => x.AppType == AppTypeGame)
|
||||||
.FirstOrDefaultAsync(x => x.AppId.Equals(appid)).ConfigureAwait(false);
|
.FirstOrDefaultAsync(x => x.AppId.Equals(appid)).ConfigureAwait(false);
|
||||||
if (app != null) _log.Info($"Successfully got app {app}");
|
if (app != null) _log.LogInformation($"Successfully got app {app}");
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
return achievementList;
|
return achievementList;
|
||||||
}
|
}
|
||||||
|
|
||||||
_log.Info($"Getting achievements for App {steamApp}");
|
_log.LogInformation($"Getting achievements for App {steamApp}");
|
||||||
|
|
||||||
var client = new HttpClient();
|
var client = new HttpClient();
|
||||||
client.DefaultRequestHeaders.UserAgent.ParseAdd(UserAgent);
|
client.DefaultRequestHeaders.UserAgent.ParseAdd(UserAgent);
|
||||||
@ -201,7 +201,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
var dlcList = new List<DlcApp>();
|
var dlcList = new List<DlcApp>();
|
||||||
if (steamApp != null)
|
if (steamApp != null)
|
||||||
{
|
{
|
||||||
_log.Info($"Get DLC for App {steamApp}");
|
_log.LogInformation($"Get DLC for App {steamApp}");
|
||||||
var task = AppDetails.GetAsync(steamApp.AppId);
|
var task = AppDetails.GetAsync(steamApp.AppId);
|
||||||
var steamAppDetails = await task.ConfigureAwait(true);
|
var steamAppDetails = await task.ConfigureAwait(true);
|
||||||
if (steamAppDetails.Type == AppTypeGame)
|
if (steamAppDetails.Type == AppTypeGame)
|
||||||
@ -212,10 +212,10 @@ namespace GoldbergGUI.Core.Services
|
|||||||
.FirstOrDefaultAsync(y => y.AppId.Equals(x)).ConfigureAwait(true)
|
.FirstOrDefaultAsync(y => y.AppId.Equals(x)).ConfigureAwait(true)
|
||||||
?? new SteamApp() { AppId = x, Name = $"Unknown DLC {x}", ComparableName = $"unknownDlc{x}", AppType = AppTypeDlc };
|
?? new SteamApp() { AppId = x, Name = $"Unknown DLC {x}", ComparableName = $"unknownDlc{x}", AppType = AppTypeDlc };
|
||||||
dlcList.Add(new DlcApp(result));
|
dlcList.Add(new DlcApp(result));
|
||||||
_log.Debug($"{result.AppId}={result.Name}");
|
_log.LogDebug($"{result.AppId}={result.Name}");
|
||||||
});
|
});
|
||||||
|
|
||||||
_log.Info("Got DLC successfully...");
|
_log.LogInformation("Got DLC successfully...");
|
||||||
|
|
||||||
// Get DLC from SteamDB
|
// Get DLC from SteamDB
|
||||||
// Get Cloudflare cookie (not implemented)
|
// Get Cloudflare cookie (not implemented)
|
||||||
@ -232,15 +232,15 @@ namespace GoldbergGUI.Core.Services
|
|||||||
var client = new HttpClient();
|
var client = new HttpClient();
|
||||||
client.DefaultRequestHeaders.UserAgent.ParseAdd(UserAgent);
|
client.DefaultRequestHeaders.UserAgent.ParseAdd(UserAgent);
|
||||||
|
|
||||||
_log.Info($"Get SteamDB App {steamApp}");
|
_log.LogInformation($"Get SteamDB App {steamApp}");
|
||||||
var httpCall = client.GetAsync(steamDbUri);
|
var httpCall = client.GetAsync(steamDbUri);
|
||||||
var response = await httpCall.ConfigureAwait(false);
|
var response = await httpCall.ConfigureAwait(false);
|
||||||
_log.Debug(httpCall.Status.ToString());
|
_log.LogDebug(httpCall.Status.ToString());
|
||||||
_log.Debug(response.EnsureSuccessStatusCode().ToString());
|
_log.LogDebug(response.EnsureSuccessStatusCode().ToString());
|
||||||
|
|
||||||
var readAsStringAsync = response.Content.ReadAsStringAsync();
|
var readAsStringAsync = response.Content.ReadAsStringAsync();
|
||||||
var responseBody = await readAsStringAsync.ConfigureAwait(false);
|
var responseBody = await readAsStringAsync.ConfigureAwait(false);
|
||||||
_log.Debug(readAsStringAsync.Status.ToString());
|
_log.LogDebug(readAsStringAsync.Status.ToString());
|
||||||
|
|
||||||
var parser = new HtmlParser();
|
var parser = new HtmlParser();
|
||||||
var doc = parser.ParseDocument(responseBody);
|
var doc = parser.ParseDocument(responseBody);
|
||||||
@ -248,7 +248,7 @@ namespace GoldbergGUI.Core.Services
|
|||||||
var query1 = doc.QuerySelector("#dlc");
|
var query1 = doc.QuerySelector("#dlc");
|
||||||
if (query1 != null)
|
if (query1 != null)
|
||||||
{
|
{
|
||||||
_log.Info("Got list of DLC from SteamDB.");
|
_log.LogInformation("Got list of DLC from SteamDB.");
|
||||||
var query2 = query1.QuerySelectorAll(".app");
|
var query2 = query1.QuerySelectorAll(".app");
|
||||||
foreach (var element in query2)
|
foreach (var element in query2)
|
||||||
{
|
{
|
||||||
@ -269,28 +269,28 @@ namespace GoldbergGUI.Core.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dlcList.ForEach(x => _log.Debug($"{x.AppId}={x.Name}"));
|
dlcList.ForEach(x => _log.LogDebug($"{x.AppId}={x.Name}"));
|
||||||
_log.Info("Got DLC from SteamDB successfully...");
|
_log.LogInformation("Got DLC from SteamDB successfully...");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Error("Could not get DLC from SteamDB!");
|
_log.LogError("Could not get DLC from SteamDB!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
_log.Error("Could not get DLC from SteamDB! Skipping...");
|
_log.LogError("Could not get DLC from SteamDB! Skipping...");
|
||||||
_log.Error(e.ToString);
|
_log.LogError(e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Error("Could not get DLC: Steam App is not of type \"game\"");
|
_log.LogError("Could not get DLC: Steam App is not of type \"game\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Error("Could not get DLC: Invalid Steam App");
|
_log.LogError("Could not get DLC: Invalid Steam App");
|
||||||
}
|
}
|
||||||
|
|
||||||
return dlcList;
|
return dlcList;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using GoldbergGUI.Core.Models;
|
using GoldbergGUI.Core.Models;
|
||||||
using GoldbergGUI.Core.Services;
|
using GoldbergGUI.Core.Services;
|
||||||
using GoldbergGUI.Core.Utils;
|
using GoldbergGUI.Core.Utils;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using MvvmCross.Commands;
|
using MvvmCross.Commands;
|
||||||
using MvvmCross.Logging;
|
|
||||||
using MvvmCross.Navigation;
|
using MvvmCross.Navigation;
|
||||||
using MvvmCross.ViewModels;
|
using MvvmCross.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
@ -42,20 +42,20 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
|
|
||||||
private readonly ISteamService _steam;
|
private readonly ISteamService _steam;
|
||||||
private readonly IGoldbergService _goldberg;
|
private readonly IGoldbergService _goldberg;
|
||||||
private readonly IMvxLog _log;
|
private readonly ILogger<MainViewModel> _log;
|
||||||
private bool _mainWindowEnabled;
|
private bool _mainWindowEnabled;
|
||||||
private bool _goldbergApplied;
|
private bool _goldbergApplied;
|
||||||
private ObservableCollection<string> _steamLanguages;
|
private ObservableCollection<string> _steamLanguages;
|
||||||
private string _selectedLanguage;
|
private string _selectedLanguage;
|
||||||
private readonly IMvxLogProvider _logProvider;
|
private readonly ILoggerFactory _logProvider;
|
||||||
|
|
||||||
public MainViewModel(ISteamService steam, IGoldbergService goldberg, IMvxLogProvider logProvider,
|
public MainViewModel(ISteamService steam, IGoldbergService goldberg, ILoggerFactory logProvider,
|
||||||
IMvxNavigationService navigationService) : base(logProvider, navigationService)
|
IMvxNavigationService navigationService) : base(logProvider, navigationService)
|
||||||
{
|
{
|
||||||
_steam = steam;
|
_steam = steam;
|
||||||
_goldberg = goldberg;
|
_goldberg = goldberg;
|
||||||
_logProvider = logProvider;
|
_logProvider = logProvider;
|
||||||
_log = logProvider.GetLogFor<MainViewModel>();
|
_log = logProvider.CreateLogger<MainViewModel>();
|
||||||
_navigationService = navigationService;
|
_navigationService = navigationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,9 +71,9 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
{
|
{
|
||||||
SteamLanguages = new ObservableCollection<string>(_goldberg.Languages());
|
SteamLanguages = new ObservableCollection<string>(_goldberg.Languages());
|
||||||
ResetForm();
|
ResetForm();
|
||||||
await _steam.Initialize(_logProvider.GetLogFor<SteamService>()).ConfigureAwait(false);
|
await _steam.Initialize(_logProvider.CreateLogger<SteamService>()).ConfigureAwait(false);
|
||||||
var globalConfiguration =
|
var globalConfiguration =
|
||||||
await _goldberg.Initialize(_logProvider.GetLogFor<GoldbergService>()).ConfigureAwait(false);
|
await _goldberg.Initialize(_logProvider.CreateLogger<GoldbergService>()).ConfigureAwait(false);
|
||||||
AccountName = globalConfiguration.AccountName;
|
AccountName = globalConfiguration.AccountName;
|
||||||
SteamId = globalConfiguration.UserSteamId;
|
SteamId = globalConfiguration.UserSteamId;
|
||||||
SelectedLanguage = globalConfiguration.Language;
|
SelectedLanguage = globalConfiguration.Language;
|
||||||
@ -81,7 +81,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e);
|
Console.WriteLine(e);
|
||||||
_log.Error(e.Message);
|
_log.LogError(e.Message);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
var value = !DllPath.Contains("Path to game's steam_api(64).dll");
|
var value = !DllPath.Contains("Path to game's steam_api(64).dll");
|
||||||
if (!value) _log.Warn("No DLL selected! Skipping...");
|
if (!value) _log.LogWarning("No DLL selected! Skipping...");
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -296,7 +296,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
if (dialog.ShowDialog() != true)
|
if (dialog.ShowDialog() != true)
|
||||||
{
|
{
|
||||||
MainWindowEnabled = true;
|
MainWindowEnabled = true;
|
||||||
_log.Warn("File selection canceled.");
|
_log.LogWarning("File selection canceled.");
|
||||||
StatusText = "No file selected! Ready.";
|
StatusText = "No file selected! Ready.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
|
|
||||||
if (GameName.Contains("Game name..."))
|
if (GameName.Contains("Game name..."))
|
||||||
{
|
{
|
||||||
_log.Error("No game name entered!");
|
_log.LogError("No game name entered!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
{
|
{
|
||||||
if (AppId <= 0)
|
if (AppId <= 0)
|
||||||
{
|
{
|
||||||
_log.Error("Invalid Steam App!");
|
_log.LogError("Invalid Steam App!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
{
|
{
|
||||||
if (AppId <= 0)
|
if (AppId <= 0)
|
||||||
{
|
{
|
||||||
_log.Error("Invalid Steam App!");
|
_log.LogError("Invalid Steam App!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,7 +412,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
{
|
{
|
||||||
if (AppId <= 0)
|
if (AppId <= 0)
|
||||||
{
|
{
|
||||||
_log.Error("Invalid Steam App!");
|
_log.LogError("Invalid Steam App!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,7 +437,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
|
|
||||||
private async Task SaveConfig()
|
private async Task SaveConfig()
|
||||||
{
|
{
|
||||||
_log.Info("Saving global settings...");
|
_log.LogInformation("Saving global settings...");
|
||||||
var globalConfiguration = new GoldbergGlobalConfiguration
|
var globalConfiguration = new GoldbergGlobalConfiguration
|
||||||
{
|
{
|
||||||
AccountName = AccountName,
|
AccountName = AccountName,
|
||||||
@ -447,7 +447,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
await _goldberg.SetGlobalSettings(globalConfiguration).ConfigureAwait(false);
|
await _goldberg.SetGlobalSettings(globalConfiguration).ConfigureAwait(false);
|
||||||
if (!DllSelected) return;
|
if (!DllSelected) return;
|
||||||
|
|
||||||
_log.Info("Saving Goldberg settings...");
|
_log.LogInformation("Saving Goldberg settings...");
|
||||||
if (!GetDllPathDir(out var dirPath)) return;
|
if (!GetDllPathDir(out var dirPath)) return;
|
||||||
MainWindowEnabled = false;
|
MainWindowEnabled = false;
|
||||||
StatusText = "Saving...";
|
StatusText = "Saving...";
|
||||||
@ -476,7 +476,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
SelectedLanguage = globalConfiguration.Language;
|
SelectedLanguage = globalConfiguration.Language;
|
||||||
if (!DllSelected) return;
|
if (!DllSelected) return;
|
||||||
|
|
||||||
_log.Info("Reset form...");
|
_log.LogInformation("Reset form...");
|
||||||
MainWindowEnabled = false;
|
MainWindowEnabled = false;
|
||||||
StatusText = "Resetting...";
|
StatusText = "Resetting...";
|
||||||
await ReadConfig().ConfigureAwait(false);
|
await ReadConfig().ConfigureAwait(false);
|
||||||
@ -490,7 +490,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
{
|
{
|
||||||
if (!DllSelected) return;
|
if (!DllSelected) return;
|
||||||
|
|
||||||
_log.Info("Generate steam_interfaces.txt...");
|
_log.LogInformation("Generate steam_interfaces.txt...");
|
||||||
MainWindowEnabled = false;
|
MainWindowEnabled = false;
|
||||||
StatusText = @"Generating ""steam_interfaces.txt"".";
|
StatusText = @"Generating ""steam_interfaces.txt"".";
|
||||||
GetDllPathDir(out var dirPath);
|
GetDllPathDir(out var dirPath);
|
||||||
@ -508,10 +508,10 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
public IMvxCommand PasteDlcCommand => new MvxCommand(() =>
|
public IMvxCommand PasteDlcCommand => new MvxCommand(() =>
|
||||||
{
|
{
|
||||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return;
|
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return;
|
||||||
_log.Info("Trying to paste DLC list...");
|
_log.LogInformation("Trying to paste DLC list...");
|
||||||
if (!(Clipboard.ContainsText(TextDataFormat.UnicodeText) || Clipboard.ContainsText(TextDataFormat.Text)))
|
if (!(Clipboard.ContainsText(TextDataFormat.UnicodeText) || Clipboard.ContainsText(TextDataFormat.Text)))
|
||||||
{
|
{
|
||||||
_log.Warn("Invalid DLC list!");
|
_log.LogWarning("Invalid DLC list!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -604,7 +604,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
dirPath = Path.GetDirectoryName(DllPath);
|
dirPath = Path.GetDirectoryName(DllPath);
|
||||||
if (dirPath != null) return true;
|
if (dirPath != null) return true;
|
||||||
|
|
||||||
_log.Error($"Invalid directory for {DllPath}.");
|
_log.LogError($"Invalid directory for {DllPath}.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using GoldbergGUI.Core.Models;
|
using GoldbergGUI.Core.Models;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using MvvmCross.Commands;
|
using MvvmCross.Commands;
|
||||||
using MvvmCross.Logging;
|
|
||||||
using MvvmCross.Navigation;
|
using MvvmCross.Navigation;
|
||||||
using MvvmCross.ViewModels;
|
using MvvmCross.ViewModels;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -11,13 +11,13 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
public class SearchResultViewModel : MvxNavigationViewModel<IEnumerable<SteamApp>>, IMvxViewModel<IEnumerable<SteamApp>, SteamApp>
|
public class SearchResultViewModel : MvxNavigationViewModel<IEnumerable<SteamApp>>, IMvxViewModel<IEnumerable<SteamApp>, SteamApp>
|
||||||
{
|
{
|
||||||
private readonly IMvxNavigationService _navigationService;
|
private readonly IMvxNavigationService _navigationService;
|
||||||
private readonly IMvxLog _log;
|
private readonly ILogger<SearchResultViewModel> _log;
|
||||||
private IEnumerable<SteamApp> _apps;
|
private IEnumerable<SteamApp> _apps;
|
||||||
|
|
||||||
public SearchResultViewModel(IMvxLogProvider logProvider, IMvxNavigationService navigationService) :
|
public SearchResultViewModel(ILoggerFactory logProvider, IMvxNavigationService navigationService) :
|
||||||
base(logProvider, navigationService)
|
base(logProvider, navigationService)
|
||||||
{
|
{
|
||||||
_log = logProvider.GetLogFor(typeof(SearchResultViewModel));
|
_log = logProvider.CreateLogger<SearchResultViewModel>();//.GetLogFor(typeof(SearchResultViewModel));
|
||||||
_navigationService = navigationService;
|
_navigationService = navigationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ namespace GoldbergGUI.Core.ViewModels
|
|||||||
{
|
{
|
||||||
if (Selected != null)
|
if (Selected != null)
|
||||||
{
|
{
|
||||||
_log.Info($"Successfully got app {Selected}");
|
_log.LogInformation($"Successfully got app {Selected}");
|
||||||
await _navigationService.Close(this, Selected).ConfigureAwait(false);
|
await _navigationService.Close(this, Selected).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,11 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MvvmCross.Platforms.Wpf" Version="7.1.2" />
|
<PackageReference Include="MvvmCross.Platforms.Wpf" Version="8.0.2" />
|
||||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
<PackageReference Include="Serilog" Version="2.11.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
|
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
using MvvmCross.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using MvvmCross.Platforms.Wpf.Core;
|
using MvvmCross.Platforms.Wpf.Core;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
using Serilog.Extensions.Logging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace GoldbergGUI.WPF
|
namespace GoldbergGUI.WPF
|
||||||
{
|
{
|
||||||
public class Setup : MvxWpfSetup<Core.App>
|
public class Setup : MvxWpfSetup<Core.App>
|
||||||
{
|
{
|
||||||
public override MvxLogProviderType GetDefaultLogProviderType() => MvxLogProviderType.Serilog;
|
protected override ILoggerProvider CreateLogProvider()
|
||||||
|
{
|
||||||
protected override IMvxLogProvider CreateLogProvider()
|
return new SerilogLoggerProvider();
|
||||||
|
}
|
||||||
|
protected override ILoggerFactory CreateLogFactory()
|
||||||
{
|
{
|
||||||
var logPath = Path.Combine(Directory.GetCurrentDirectory(), "goldberg_.log");
|
var logPath = Path.Combine(Directory.GetCurrentDirectory(), "goldberg_.log");
|
||||||
Log.Logger = new LoggerConfiguration()
|
Log.Logger = new LoggerConfiguration()
|
||||||
@ -17,7 +20,7 @@ namespace GoldbergGUI.WPF
|
|||||||
.WriteTo.Console()
|
.WriteTo.Console()
|
||||||
.WriteTo.File(logPath, rollingInterval: RollingInterval.Day)
|
.WriteTo.File(logPath, rollingInterval: RollingInterval.Day)
|
||||||
.CreateLogger();
|
.CreateLogger();
|
||||||
return base.CreateLogProvider();
|
return new SerilogLoggerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user