Compare commits

...

32 Commits

Author SHA1 Message Date
50308906eb Remove old SteamStorefrontAPI fork 2023-12-25 20:59:00 +01:00
956b5e6693 Use latest SteamStorefrontAPI version 2023-12-25 20:56:54 +01:00
d56e480286 Update submodule 2023-12-25 13:35:46 +01:00
5e2833e068 Overhaul Secrets implementation 2023-12-24 13:33:38 +01:00
dfd9f1a97b Try to use archived SteamDB page 2023-12-24 13:16:15 +01:00
cfb9be69f7 Add SteamDB link 2023-12-24 00:38:06 +01:00
95361440f6 Update to MvvmCross 8; Replace SteamfrontendAPI with fork to fix DLC issues; code refactoring 2023-12-23 22:55:26 +01:00
991f52e87e Minor changes 2023-12-23 20:51:30 +01:00
1c66ff2684 Update Nuget Packages (except MvvmCross) 2023-12-23 19:47:11 +01:00
80b704cecb Update to NET 8; Fix Secret class 2023-12-23 19:23:14 +01:00
23459ec794 Fixed exception throwing stuff idunno 2021-02-15 16:51:50 +01:00
0005f3d74b Set version to 2.1.7 2021-02-14 15:20:19 +01:00
67d289905c Throw exception if needed when trying to get DLCs. 2021-02-14 15:19:45 +01:00
3c736674ac Removed automatically getting list of DLCs when selecting DLL file and looking for AppID 2021-02-14 15:08:12 +01:00
8ade832b42 Error message is now displayed if CreamAPI cannot be downloaded.
Fixed incorrect logging syntax.
2021-02-14 15:04:38 +01:00
178b7427b8 Fixed crash when trying to get DLCs for certain games. 2021-01-15 17:00:38 +01:00
81bd241e26 Fixed crash when trying to get DLCs for certain games. 2021-01-15 16:59:47 +01:00
32410ca254 version 2.1.5 2021-01-14 17:10:53 +01:00
b14e8944c3 remove try catch clause in extract function 2021-01-13 13:06:28 +01:00
478d5196a6 Improved app start up
Fixed issues with extraction
2021-01-13 13:04:35 +01:00
8a4e601236 Try to get DLC name if missing and not using SteamDB 2021-01-05 12:30:34 +01:00
1d69b7b45a Add option to ignore unknown DLC from SteamDB.
Show amount of DLCs after getting list of DLCs successfully.
2021-01-04 16:14:10 +01:00
2cfb7dc654 Fixed issues with extraction (migration from SharpCompress to Squid-Box.SevenZipSharp) 2021-01-04 15:43:27 +01:00
af8110e475 Automatically get DLC when selecting the DLL.
Automatically get DLC when getting a valid Steam app.
2021-01-04 12:54:28 +01:00
721b5e8e7f Get list of DLC function now checks if entered app is actually of type "game" 2021-01-04 12:27:48 +01:00
d71144b1d6 Try to guess game name from path if config doesn't exist. 2021-01-01 17:03:46 +01:00
1042923249 Improved search performance
Pressing enter in the game name field now also starts a search.
2021-01-01 16:27:42 +01:00
201e122e8b Fixed app not launching properly 2021-01-01 14:53:02 +01:00
717960c6b5 Update README.md 2020-12-30 12:11:15 +01:00
a92d8c617c Update README.md 2020-12-30 12:09:57 +01:00
835163ca5e Fixed dlc list not using monospaced font 2020-12-29 12:42:39 +01:00
a5ca4ceb33 Fixed issues with language selection
Fixed game name field not resetting properly
2020-12-29 12:32:04 +01:00
29 changed files with 624 additions and 413 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "SteamStorefrontAPI"]
path = SteamStorefrontAPI
url = https://git.jeddunk.xyz/jeddunk/SteamStorefrontAPI.git

View File

@ -1,10 +1,8 @@
# Auto-CreamAPI 2 # Auto-CreamAPI 2
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/H2H4330U3)
Set your game automatically up for use with CreamAPI. Set your game automatically up for use with CreamAPI.
[![](https://jeddunk.xyz/jetbrains-small.png)](https://www.jetbrains.com/?from=Auto-CreamAPI)
[Made with software provided by JetBrains s.r.o.](https://www.jetbrains.com/?from=Auto-CreamAPI)
## Features ## Features
* Setup CreamAPIs DLLs and configuration file automatically. * Setup CreamAPIs DLLs and configuration file automatically.
* Find the AppID by providing the games name without having to look it up manually. * Find the AppID by providing the games name without having to look it up manually.
@ -12,11 +10,9 @@ Set your game automatically up for use with CreamAPI.
* Set flags like "offline mode" and "extra protection" and select a language from a list. * Set flags like "offline mode" and "extra protection" and select a language from a list.
## Installation ## Installation
Download the latest release and extract it into any folder (e.g. `%USERPROFILE%\Desktop\auto-creamapi`). Download the latest release and extract it into any folder (e.g. `%USERPROFILE%\Desktop\auto-creamapi`).
## Usage ## Usage
* Double-click `auto-creamapi.exe` to open the application. (When starting it for the first time, it might take a few * Double-click `auto-creamapi.exe` to open the application. (When starting it for the first time, it might take a few
seconds since it needs to cache a list of games available on the Steam Store and download the latest CreamAPI DLL files.) seconds since it needs to cache a list of games available on the Steam Store and download the latest CreamAPI DLL files.)
* Click on the *Open File* button on the top right and select the *steam_api.dll* or *steam_api64.dll* * Click on the *Open File* button on the top right and select the *steam_api.dll* or *steam_api64.dll*
@ -29,9 +25,13 @@ Download the latest release and extract it into any folder (e.g. `%USERPROFILE%\
* Click on *"Save"*. * Click on *"Save"*.
## License ## License
Auto-CreamAPI itself is licensed under the GNU General Public License v3.0 Auto-CreamAPI itself is licensed under the GNU General Public License v3.0
CreamAPI © 2016-2019, deadmau5. All Rights Reserved. CreamAPI © 2016-2020, deadmau5. All Rights Reserved.
*Dependencies will be listed ASAP.* *Dependencies will be listed ASAP.*
## Software used
[![](https://jeddunk.xyz/jetbrains-small.png)](https://www.jetbrains.com/?from=Auto-CreamAPI)
[Made with software provided by JetBrains s.r.o.](https://www.jetbrains.com/?from=Auto-CreamAPI)

View File

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 17
VisualStudioVersion = 16.0.30413.136 VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "auto-creamapi", "auto-creamapi\auto-creamapi.csproj", "{26060B32-199E-4366-8FDE-6B1E10E0EF62}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "auto-creamapi", "auto-creamapi\auto-creamapi.csproj", "{26060B32-199E-4366-8FDE-6B1E10E0EF62}"
EndProject EndProject

View File

@ -10,7 +10,7 @@ namespace auto_creamapi
{ {
protected override void RegisterSetup() protected override void RegisterSetup()
{ {
this.RegisterSetupType<MvxWpfSetup<Core.App>>(); this.RegisterSetupType<Setup>();
} }
} }
} }

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
@ -19,6 +20,7 @@ namespace auto_creamapi.Converters
protected override string Convert(ObservableCollection<SteamApp> value, Type targetType, object parameter, protected override string Convert(ObservableCollection<SteamApp> value, Type targetType, object parameter,
CultureInfo culture) CultureInfo culture)
{ {
if (value == null) return "";
MyLogger.Log.Debug("ListOfDLcToStringConverter: Convert"); MyLogger.Log.Debug("ListOfDLcToStringConverter: Convert");
var dlcListToString = DlcListToString(value); var dlcListToString = DlcListToString(value);
return dlcListToString.GetType() == targetType ? dlcListToString : ""; return dlcListToString.GetType() == targetType ? dlcListToString : "";
@ -29,30 +31,32 @@ namespace auto_creamapi.Converters
{ {
MyLogger.Log.Debug("ListOfDLcToStringConverter: ConvertBack"); MyLogger.Log.Debug("ListOfDLcToStringConverter: ConvertBack");
var stringToDlcList = StringToDlcList(value); var stringToDlcList = StringToDlcList(value);
return stringToDlcList.GetType() == targetType ? stringToDlcList : new ObservableCollection<SteamApp>(); return stringToDlcList.GetType() == targetType ? stringToDlcList : [];
} }
private static ObservableCollection<SteamApp> StringToDlcList(string value) private static ObservableCollection<SteamApp> StringToDlcList(string value)
{ {
var result = new ObservableCollection<SteamApp>(); var result = new ObservableCollection<SteamApp>();
var expression = new Regex(@"(?<id>.*) *= *(?<name>.*)"); var expression = new Regex("(?<id>.*) *= *(?<name>.*)");
using var reader = new StringReader(value); using var reader = new StringReader(value);
string line; string line;
while ((line = reader.ReadLine()) != null) while ((line = reader.ReadLine()) != null)
{ {
var match = expression.Match(line); var match = expression.Match(line);
if (match.Success) if (match.Success)
{
result.Add(new SteamApp result.Add(new SteamApp
{ {
AppId = int.Parse(match.Groups["id"].Value), AppId = int.Parse(match.Groups["id"].Value),
Name = match.Groups["name"].Value Name = match.Groups["name"].Value
}); });
}
} }
return result; return result;
} }
private static string DlcListToString(ObservableCollection<SteamApp> value) private static string DlcListToString(IEnumerable<SteamApp> value)
{ {
var result = ""; var result = "";
//value.ForEach(x => result += $"{x}\n"); //value.ForEach(x => result += $"{x}\n");

View File

@ -4,7 +4,7 @@ using MvvmCross.ViewModels;
namespace auto_creamapi.Core namespace auto_creamapi.Core
{ {
public class App : MvxApplication public class MainApplication : MvxApplication
{ {
public override void Initialize() public override void Initialize()
{ {

View File

@ -6,6 +6,6 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" mc:Ignorable="d"
Title="Auto-CreamAPI 2" MinWidth="420" MinHeight="600" Width="420" Height="600"> Title="Auto-CreamAPI 2" MinWidth="420" MinHeight="640" Width="560" Height="720">
<Grid /> <Grid />
</views:MvxWindow> </views:MvxWindow>

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace auto_creamapi.Models namespace auto_creamapi.Models
{ {
@ -15,6 +16,20 @@ namespace auto_creamapi.Models
public bool ExtraProtection { get; set; } public bool ExtraProtection { get; set; }
public bool ForceOffline { get; set; } public bool ForceOffline { get; set; }
public List<SteamApp> DlcList { get; set; } public List<SteamApp> DlcList { get; set; }
public override string ToString()
{
var value = $"AppID: {AppId}\n" +
$"Language: {Language}\n" +
$"UnlockAll: {UnlockAll}\n" +
$"ExtraProtection: {ExtraProtection}\n" +
$"ForceOffline: {ForceOffline}\n" +
$"DLC ({DlcList.Count}):\n[\n";
if (DlcList.Count > 0)
value = DlcList.Aggregate(value, (current, x) => current + $" {x.AppId}={x.Name},\n");
value += "]";
return value;
}
} }
public sealed class CreamConfigModel public sealed class CreamConfigModel

View File

@ -1,24 +1,36 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using auto_creamapi.Utils;
namespace auto_creamapi.Models namespace auto_creamapi.Models
{ {
public class SteamApp public class SteamApp
{ {
private string _name;
private string _comparableName;
[JsonPropertyName("appid")] public int AppId { get; set; } [JsonPropertyName("appid")] public int AppId { get; set; }
[JsonPropertyName("name")] public string Name { get; set; } [JsonPropertyName("name")]
public string Name
{
get => _name;
set
{
_name = value;
_comparableName = Regex.Replace(value, Misc.SpecialCharsRegex, "").ToLower();
}
}
public bool CompareName(string value)
{
return _comparableName.Equals(value);
}
public override string ToString() public override string ToString()
{ {
//return $"AppId: {AppId}, Name: {Name}";
return $"{AppId}={Name}"; return $"{AppId}={Name}";
} }
public bool CompareId(SteamApp steamApp)
{
return AppId.Equals(steamApp.AppId);
}
} }
public class AppList public class AppList

View File

@ -1,10 +1,8 @@
# Auto-CreamAPI 2 # Auto-CreamAPI 2
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/H2H4330U3)
Set your game automatically up for use with CreamAPI. Set your game automatically up for use with CreamAPI.
[![](https://jeddunk.xyz/jetbrains-small.png)](https://www.jetbrains.com/?from=Auto-CreamAPI)
[Made with software provided by JetBrains s.r.o.](https://www.jetbrains.com/?from=Auto-CreamAPI)
## Features ## Features
* Setup CreamAPIs DLLs and configuration file automatically. * Setup CreamAPIs DLLs and configuration file automatically.
* Find the AppID by providing the games name without having to look it up manually. * Find the AppID by providing the games name without having to look it up manually.
@ -12,11 +10,9 @@ Set your game automatically up for use with CreamAPI.
* Set flags like "offline mode" and "extra protection" and select a language from a list. * Set flags like "offline mode" and "extra protection" and select a language from a list.
## Installation ## Installation
Download the latest release and extract it into any folder (e.g. `%USERPROFILE%\Desktop\auto-creamapi`). Download the latest release and extract it into any folder (e.g. `%USERPROFILE%\Desktop\auto-creamapi`).
## Usage ## Usage
* Double-click `auto-creamapi.exe` to open the application. (When starting it for the first time, it might take a few * Double-click `auto-creamapi.exe` to open the application. (When starting it for the first time, it might take a few
seconds since it needs to cache a list of games available on the Steam Store and download the latest CreamAPI DLL files.) seconds since it needs to cache a list of games available on the Steam Store and download the latest CreamAPI DLL files.)
* Click on the *Open File* button on the top right and select the *steam_api.dll* or *steam_api64.dll* * Click on the *Open File* button on the top right and select the *steam_api.dll* or *steam_api64.dll*
@ -29,9 +25,13 @@ Download the latest release and extract it into any folder (e.g. `%USERPROFILE%\
* Click on *"Save"*. * Click on *"Save"*.
## License ## License
Auto-CreamAPI itself is licensed under the GNU General Public License v3.0 Auto-CreamAPI itself is licensed under the GNU General Public License v3.0
CreamAPI © 2016-2019, deadmau5. All Rights Reserved. CreamAPI © 2016-2020, deadmau5. All Rights Reserved.
*Dependencies will be listed ASAP.* *Dependencies will be listed ASAP.*
## Software used
[![](https://jeddunk.xyz/jetbrains-small.png)](https://www.jetbrains.com/?from=Auto-CreamAPI)
[Made with software provided by JetBrains s.r.o.](https://www.jetbrains.com/?from=Auto-CreamAPI)

View File

@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
@ -17,15 +19,13 @@ namespace auto_creamapi.Services
{ {
public interface ICacheService public interface ICacheService
{ {
public List<string> Languages { get; }
public Task Initialize(); public Task Initialize();
//public Task UpdateCache(); //public Task UpdateCache();
public IEnumerable<SteamApp> GetListOfAppsByName(string name); public IEnumerable<SteamApp> GetListOfAppsByName(string name);
public SteamApp GetAppByName(string name); public SteamApp GetAppByName(string name);
public SteamApp GetAppById(int appid); public SteamApp GetAppById(int appid);
public Task<List<SteamApp>> GetListOfDlc(SteamApp steamApp, bool useSteamDb); public Task<List<SteamApp>> GetListOfDlc(SteamApp steamApp, bool useSteamDb, bool ignoreUnknown);
} }
public class CacheService : ICacheService public class CacheService : ICacheService
@ -33,31 +33,7 @@ namespace auto_creamapi.Services
private const string CachePath = "steamapps.json"; private const string CachePath = "steamapps.json";
private const string SteamUri = "https://api.steampowered.com/ISteamApps/GetAppList/v2/"; private const string SteamUri = "https://api.steampowered.com/ISteamApps/GetAppList/v2/";
private const string UserAgent = private HashSet<SteamApp> _cache = [];
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " +
"Chrome/87.0.4280.88 Safari/537.36";
private const string SpecialCharsRegex = "[^0-9a-zA-Z]+";
private List<SteamApp> _cache = new List<SteamApp>();
/*private static readonly Lazy<CacheService> Lazy =
new Lazy<CacheService>(() => new CacheService());
public static CacheService Instance => Lazy.Value;*/
public CacheService()
{
Languages = Misc.DefaultLanguages;
}
/*public async void Initialize()
{
//Languages = _defaultLanguages;
await UpdateCache();
}*/
public List<string> Languages { get; }
public async Task Initialize() public async Task Initialize()
{ {
@ -66,17 +42,7 @@ namespace auto_creamapi.Services
string cacheString; string cacheString;
if (updateNeeded) if (updateNeeded)
{ {
MyLogger.Log.Information("Getting content from API..."); cacheString = await UpdateCache().ConfigureAwait(false);
var client = new HttpClient();
var httpCall = client.GetAsync(SteamUri);
var response = await httpCall;
var readAsStringAsync = response.Content.ReadAsStringAsync();
var responseBody = await readAsStringAsync;
MyLogger.Log.Information("Got content from API successfully. Writing to file...");
await File.WriteAllTextAsync(CachePath, responseBody, Encoding.UTF8);
cacheString = responseBody;
MyLogger.Log.Information("Cache written to file successfully.");
} }
else else
{ {
@ -84,12 +50,27 @@ namespace auto_creamapi.Services
// ReSharper disable once MethodHasAsyncOverload // ReSharper disable once MethodHasAsyncOverload
cacheString = File.ReadAllText(CachePath); cacheString = File.ReadAllText(CachePath);
} }
var steamApps = JsonSerializer.Deserialize<SteamApps>(cacheString); var steamApps = JsonSerializer.Deserialize<SteamApps>(cacheString);
_cache = steamApps.AppList.Apps; _cache = new HashSet<SteamApp>(steamApps.AppList.Apps);
MyLogger.Log.Information("Loaded cache into memory!"); MyLogger.Log.Information("Loaded cache into memory!");
} }
private static async Task<string> UpdateCache()
{
MyLogger.Log.Information("Getting content from API...");
var client = new HttpClient();
var httpCall = client.GetAsync(SteamUri);
var response = await httpCall.ConfigureAwait(false);
var readAsStringAsync = response.Content.ReadAsStringAsync();
var responseBody = await readAsStringAsync.ConfigureAwait(false);
MyLogger.Log.Information("Got content from API successfully. Writing to file...");
await File.WriteAllTextAsync(CachePath, responseBody, Encoding.UTF8).ConfigureAwait(false);
var cacheString = responseBody;
MyLogger.Log.Information("Cache written to file successfully.");
return cacheString;
}
public IEnumerable<SteamApp> GetListOfAppsByName(string name) public IEnumerable<SteamApp> GetListOfAppsByName(string name)
{ {
var listOfAppsByName = _cache.Search(x => x.Name) var listOfAppsByName = _cache.Search(x => x.Name)
@ -100,107 +81,149 @@ namespace auto_creamapi.Services
public SteamApp GetAppByName(string name) public SteamApp GetAppByName(string name)
{ {
MyLogger.Log.Information($"Trying to get app {name}"); MyLogger.Log.Information("Trying to get app {Name}", name);
var app = _cache.Find(x => var comparableName = Regex.Replace(name, Misc.SpecialCharsRegex, "").ToLower();
Regex.Replace(x.Name, SpecialCharsRegex, "").ToLower() var app = _cache.FirstOrDefault(x => x.CompareName(comparableName));
.Equals(Regex.Replace(name, SpecialCharsRegex, "").ToLower())); if (app != null) MyLogger.Log.Information("Successfully got app {App}", app);
if (app != null) MyLogger.Log.Information($"Successfully got app {app}");
return app; return app;
} }
public SteamApp GetAppById(int appid) public SteamApp GetAppById(int appid)
{ {
MyLogger.Log.Information($"Trying to get app with ID {appid}"); MyLogger.Log.Information("Trying to get app with ID {AppId}", appid);
var app = _cache.Find(x => x.AppId.Equals(appid)); var app = _cache.FirstOrDefault(x => x.AppId.Equals(appid));
if (app != null) MyLogger.Log.Information($"Successfully got app {app}"); if (app != null) MyLogger.Log.Information("Successfully got app {App}", app);
return app; return app;
} }
public async Task<List<SteamApp>> GetListOfDlc(SteamApp steamApp, bool useSteamDb) public async Task<List<SteamApp>> GetListOfDlc(SteamApp steamApp, bool useSteamDb, bool ignoreUnknown)
{ {
MyLogger.Log.Information("Get DLC"); MyLogger.Log.Debug("Start: GetListOfDlc");
var dlcList = new List<SteamApp>(); var dlcList = new List<SteamApp>();
if (steamApp != null) try
{ {
var task = AppDetails.GetAsync(steamApp.AppId); if (steamApp != null)
var steamAppDetails = await task;
steamAppDetails?.DLC.ForEach(x =>
{ {
var result = _cache.Find(y => y.AppId.Equals(x)) ?? var steamAppDetails = await AppDetails.GetAsync(steamApp.AppId).ConfigureAwait(false);
new SteamApp {AppId = x, Name = $"Unknown DLC {x}"}; if (steamAppDetails != null)
dlcList.Add(result);
});
dlcList.ForEach(x => MyLogger.Log.Debug($"{x.AppId}={x.Name}"));
MyLogger.Log.Information("Got DLC successfully...");
// Get DLC from SteamDB
// Get Cloudflare cookie
// Scrape and parse HTML page
// Add missing to DLC list
if (useSteamDb)
{
var steamDbUri = new Uri($"https://steamdb.info/app/{steamApp.AppId}/dlc/");
/* var handler = new ClearanceHandler();
var client = new HttpClient(handler);
var content = client.GetStringAsync(steamDbUri).Result;
MyLogger.Log.Debug(content); */
var client = new HttpClient();
client.DefaultRequestHeaders.UserAgent.ParseAdd(UserAgent);
MyLogger.Log.Information("Get SteamDB App");
var httpCall = client.GetAsync(steamDbUri);
var response = await httpCall;
MyLogger.Log.Debug(httpCall.Status.ToString());
MyLogger.Log.Debug(response.EnsureSuccessStatusCode().ToString());
var readAsStringAsync = response.Content.ReadAsStringAsync();
var responseBody = await readAsStringAsync;
MyLogger.Log.Debug(readAsStringAsync.Status.ToString());
var parser = new HtmlParser();
var doc = parser.ParseDocument(responseBody);
// Console.WriteLine(doc.DocumentElement.OuterHtml);
var query1 = doc.QuerySelector("#dlc");
if (query1 != null)
{ {
var query2 = query1.QuerySelectorAll(".app"); MyLogger.Log.Debug("Type for Steam App {Name}: \"{Type}\"", steamApp.Name,
foreach (var element in query2) steamAppDetails.Type);
if (steamAppDetails.Type == "game" || steamAppDetails.Type == "demo")
{ {
var dlcId = element.GetAttribute("data-appid"); steamAppDetails.DLC.ForEach(x =>
var dlcName = $"Unknown DLC {dlcId}";
var query3 = element.QuerySelectorAll("td");
if (query3 != null) dlcName = query3[1].Text().Replace("\n", "").Trim();
var dlcApp = new SteamApp {AppId = Convert.ToInt32(dlcId), Name = dlcName};
var i = dlcList.FindIndex(x => x.CompareId(dlcApp));
if (i > -1)
{ {
if (dlcList[i].Name.Contains("Unknown DLC")) dlcList[i] = dlcApp; var result = _cache.FirstOrDefault(y => y.AppId.Equals(x));
if (result == null) return;
var dlcDetails = AppDetails.GetAsync(x).Result;
dlcList.Add(dlcDetails != null
? new SteamApp { AppId = dlcDetails.SteamAppId, Name = dlcDetails.Name }
: new SteamApp { AppId = x, Name = $"Unknown DLC {x}" });
});
dlcList.ForEach(x => MyLogger.Log.Debug("{AppId}={Name}", x.AppId, x.Name));
MyLogger.Log.Information("Got DLC successfully...");
// Return if Steam DB is deactivated
if (!useSteamDb) return dlcList;
string steamDbUrl = $"https://steamdb.info/app/{steamApp.AppId}/dlc/";
var client = new HttpClient();
string archiveJson = await client.GetStringAsync($"https://archive.org/wayback/available?url={steamDbUrl}");
var archiveResult = JsonSerializer.Deserialize<AvailableArchive>(archiveJson);
if (archiveResult == null || archiveResult.ArchivedSnapshots.Closest?.Status != "200")
{
return dlcList;
}
//language=regex
const string pattern = @"^(https?:\/\/web\.archive\.org\/web\/\d+)(\/.+)$";
const string substitution = "$1id_$2";
const RegexOptions options = RegexOptions.Multiline;
Regex regex = new(pattern, options);
string newUrl = regex.Replace(archiveResult.ArchivedSnapshots.Closest.Url, substitution);
//client.DefaultRequestHeaders.UserAgent.ParseAdd(UserAgent);
MyLogger.Log.Information("Get SteamDB App");
var httpCall = client.GetAsync(newUrl);
var response = await httpCall.ConfigureAwait(false);
MyLogger.Log.Debug("{Status}", httpCall.Status.ToString());
MyLogger.Log.Debug("{Boolean}", response.IsSuccessStatusCode.ToString());
response.EnsureSuccessStatusCode();
var readAsStringAsync = response.Content.ReadAsStringAsync();
var responseBody = await readAsStringAsync.ConfigureAwait(false);
MyLogger.Log.Debug("{Status}", readAsStringAsync.Status.ToString());
var parser = new HtmlParser();
var doc = parser.ParseDocument(responseBody);
// Console.WriteLine(doc.DocumentElement.OuterHtml);
var query1 = doc.QuerySelector("#dlc");
if (query1 != null)
{
var query2 = query1.QuerySelectorAll(".app");
foreach (var element in query2)
{
var dlcId = element.GetAttribute("data-appid");
var query3 = element.QuerySelectorAll("td");
var dlcName = query3 == null
? $"Unknown DLC {dlcId}"
: query3[1].Text().Replace("\n", "").Trim();
if (ignoreUnknown && dlcName.Contains("SteamDB Unknown App"))
{
MyLogger.Log.Information("Skipping SteamDB Unknown App {DlcId}", dlcId);
}
else
{
var dlcApp = new SteamApp { AppId = Convert.ToInt32(dlcId), Name = dlcName };
var i = dlcList.FindIndex(x => x.AppId.Equals(dlcApp.AppId));
if (i > -1)
{
if (dlcList[i].Name.Contains("Unknown DLC")) dlcList[i] = dlcApp;
}
else
{
dlcList.Add(dlcApp);
}
}
}
dlcList.ForEach(x => MyLogger.Log.Debug("{AppId}={Name}", x.AppId, x.Name));
MyLogger.Log.Information("Got DLC from SteamDB successfully...");
} }
else else
{ {
dlcList.Add(dlcApp); MyLogger.Log.Error("Could not get DLC from SteamDB!");
} }
} }
else
dlcList.ForEach(x => MyLogger.Log.Debug($"{x.AppId}={x.Name}")); {
MyLogger.Log.Information("Got DLC from SteamDB successfully..."); MyLogger.Log.Error("Could not get DLC: Steam App is not of type: \"Game\"");
}
} }
else else
{ {
MyLogger.Log.Error("Could not get DLC from SteamDB1"); MyLogger.Log.Error("Could not get DLC: Could not get Steam App details");
} }
} }
else
{
MyLogger.Log.Error("Could not get DLC: Invalid Steam App");
}
//return dlcList;
} }
else catch (Exception e)
{ {
MyLogger.Log.Error("Could not get DLC: Invalid Steam App"); MyLogger.Log.Error("Could not get DLC!");
MyLogger.Log.Debug(e.Demystify(), "Exception thrown!");
} }
return dlcList; return dlcList;

View File

@ -38,7 +38,7 @@ namespace auto_creamapi.Services
bool unlockAll, bool unlockAll,
bool extraProtection, bool extraProtection,
bool forceOffline, bool forceOffline,
ObservableCollection<SteamApp> dlcList); IEnumerable<SteamApp> dlcList);
public bool ConfigExists(); public bool ConfigExists();
} }
@ -47,7 +47,7 @@ namespace auto_creamapi.Services
{ {
private string _configFilePath; private string _configFilePath;
public CreamConfig Config { get; set; } public CreamConfig Config { get; private set; }
public void Initialize() public void Initialize()
{ {
@ -65,7 +65,7 @@ namespace auto_creamapi.Services
_configFilePath = configFilePath; _configFilePath = configFilePath;
if (File.Exists(configFilePath)) if (File.Exists(configFilePath))
{ {
MyLogger.Log.Information($"Config file found @ {configFilePath}, parsing..."); MyLogger.Log.Information("Config file found @ {ConfigFilePath}, parsing...", configFilePath);
var parser = new FileIniDataParser(); var parser = new FileIniDataParser();
var data = parser.ReadFile(_configFilePath, Encoding.UTF8); var data = parser.ReadFile(_configFilePath, Encoding.UTF8);
@ -83,7 +83,7 @@ namespace auto_creamapi.Services
} }
else else
{ {
MyLogger.Log.Information($"Config file does not exist @ {configFilePath}, skipping..."); MyLogger.Log.Information("Config file does not exist @ {ConfigFilePath}, skipping...", configFilePath);
ResetConfigData(); ResetConfigData();
} }
} }
@ -144,7 +144,7 @@ namespace auto_creamapi.Services
bool unlockAll, bool unlockAll,
bool extraProtection, bool extraProtection,
bool forceOffline, bool forceOffline,
ObservableCollection<SteamApp> dlcList) IEnumerable<SteamApp> dlcList)
{ {
Config.AppId = appId; Config.AppId = appId;
Config.Language = language; Config.Language = language;
@ -162,7 +162,7 @@ namespace auto_creamapi.Services
private void ResetConfigData() private void ResetConfigData()
{ {
Config.AppId = -1; Config.AppId = -1;
Config.Language = ""; Config.Language = Misc.DefaultLanguageSelection;
Config.UnlockAll = false; Config.UnlockAll = false;
Config.ExtraProtection = false; Config.ExtraProtection = false;
Config.ForceOffline = false; Config.ForceOffline = false;
@ -191,21 +191,7 @@ namespace auto_creamapi.Services
public override string ToString() public override string ToString()
{ {
var str = $"INI file: {_configFilePath}, " + var str = $"INI file: {_configFilePath}\n{Config}";
$"AppID: {Config.AppId}, " +
$"Language: {Config.Language}, " +
$"UnlockAll: {Config.UnlockAll}, " +
$"ExtraProtection: {Config.ExtraProtection}, " +
$"ForceOffline: {Config.ForceOffline}, " +
$"DLC ({Config.DlcList.Count}):\n[\n";
if (Config.DlcList.Count > 0)
str = Config.DlcList.Aggregate(str, (current, x) => current + $" {x.AppId}={x.Name},\n");
/*foreach (var (key, value) in Config.DlcList)
{
str += $" {key}={value},\n";
}*/
str += "]";
return str; return str;
} }

View File

@ -15,6 +15,7 @@ namespace auto_creamapi.Services
public void Save(); public void Save();
public void CheckIfDllExistsAtTarget(); public void CheckIfDllExistsAtTarget();
public bool CreamApiApplied(); public bool CreamApiApplied();
public bool CreamApiApplied(string arch);
} }
public class CreamDllService : ICreamDllService public class CreamDllService : ICreamDllService
@ -23,7 +24,7 @@ namespace auto_creamapi.Services
private const string X64Arch = "x64"; private const string X64Arch = "x64";
private static readonly string HashPath = Path.Combine(Directory.GetCurrentDirectory(), "cream_api.md5"); private static readonly string HashPath = Path.Combine(Directory.GetCurrentDirectory(), "cream_api.md5");
private readonly Dictionary<string, CreamDll> _creamDlls = new Dictionary<string, CreamDll>(); private Dictionary<string, CreamDll> _creamDlls;
private bool _x64Exists; private bool _x64Exists;
private bool _x86Exists; private bool _x86Exists;
@ -33,9 +34,11 @@ namespace auto_creamapi.Services
public async Task Initialize() public async Task Initialize()
{ {
MyLogger.Log.Debug("CreamDllService: Initialize begin"); MyLogger.Log.Debug("CreamDllService: Initialize begin");
_creamDlls = new Dictionary<string, CreamDll>
_creamDlls.Add(X86Arch, new CreamDll("steam_api.dll", "steam_api_o.dll")); {
_creamDlls.Add(X64Arch, new CreamDll("steam_api64.dll", "steam_api64_o.dll")); {X86Arch, new CreamDll("steam_api.dll", "steam_api_o.dll")},
{X64Arch, new CreamDll("steam_api64.dll", "steam_api64_o.dll")}
};
if (!File.Exists(HashPath)) if (!File.Exists(HashPath))
{ {
@ -45,7 +48,7 @@ namespace auto_creamapi.Services
{ {
$"{_creamDlls[X86Arch].Hash} {_creamDlls[X86Arch].Filename}", $"{_creamDlls[X86Arch].Hash} {_creamDlls[X86Arch].Filename}",
$"{_creamDlls[X64Arch].Hash} {_creamDlls[X64Arch].Filename}" $"{_creamDlls[X64Arch].Hash} {_creamDlls[X64Arch].Filename}"
}); }).ConfigureAwait(false);
} }
MyLogger.Log.Debug("CreamDllService: Initialize end"); MyLogger.Log.Debug("CreamDllService: Initialize end");
@ -59,12 +62,12 @@ namespace auto_creamapi.Services
public void CheckIfDllExistsAtTarget() public void CheckIfDllExistsAtTarget()
{ {
var x86file = Path.Combine(TargetPath, "steam_api.dll"); var x86File = Path.Combine(TargetPath, "steam_api.dll");
var x64file = Path.Combine(TargetPath, "steam_api64.dll"); var x64File = Path.Combine(TargetPath, "steam_api64.dll");
_x86Exists = File.Exists(x86file); _x86Exists = File.Exists(x86File);
_x64Exists = File.Exists(x64file); _x64Exists = File.Exists(x64File);
if (_x86Exists) MyLogger.Log.Information($"x86 SteamAPI DLL found: {x86file}"); if (_x86Exists) MyLogger.Log.Information("x86 SteamAPI DLL found: {X}", x86File);
if (_x64Exists) MyLogger.Log.Information($"x64 SteamAPI DLL found: {x64file}"); if (_x64Exists) MyLogger.Log.Information("x64 SteamAPI DLL found: {X}", x64File);
} }
public bool CreamApiApplied() public bool CreamApiApplied()
@ -80,7 +83,7 @@ namespace auto_creamapi.Services
var targetSteamApiDll = Path.Combine(TargetPath, _creamDlls[arch].Filename); var targetSteamApiDll = Path.Combine(TargetPath, _creamDlls[arch].Filename);
var targetSteamApiOrigDll = Path.Combine(TargetPath, _creamDlls[arch].OrigFilename); var targetSteamApiOrigDll = Path.Combine(TargetPath, _creamDlls[arch].OrigFilename);
var targetSteamApiDllBackup = Path.Combine(TargetPath, $"{_creamDlls[arch].Filename}.backup"); var targetSteamApiDllBackup = Path.Combine(TargetPath, $"{_creamDlls[arch].Filename}.backup");
MyLogger.Log.Information($"Setting up CreamAPI DLL @ {TargetPath} (arch :{arch})"); MyLogger.Log.Information("Setting up CreamAPI DLL @ {TargetPath} (arch :{Arch})", TargetPath, arch);
// Create backup of steam_api.dll // Create backup of steam_api.dll
File.Copy(targetSteamApiDll, targetSteamApiDllBackup, true); File.Copy(targetSteamApiDll, targetSteamApiDllBackup, true);
// Check if steam_api_o.dll already exists // Check if steam_api_o.dll already exists
@ -98,18 +101,15 @@ namespace auto_creamapi.Services
return a & b; return a & b;
} }
private string GetHash(string filename) private static string GetHash(string filename)
{ {
if (File.Exists(filename)) if (!File.Exists(filename)) return "";
{ using var md5 = MD5.Create();
using var md5 = MD5.Create(); using var stream = File.OpenRead(filename);
using var stream = File.OpenRead(filename); return BitConverter
return BitConverter .ToString(md5.ComputeHash(stream))
.ToString(md5.ComputeHash(stream)) .Replace("-", string.Empty);
.Replace("-", string.Empty);
}
return "";
} }
} }
} }

View File

@ -10,27 +10,20 @@ using auto_creamapi.Messenger;
using auto_creamapi.Utils; using auto_creamapi.Utils;
using HttpProgress; using HttpProgress;
using MvvmCross.Plugin.Messenger; using MvvmCross.Plugin.Messenger;
using SharpCompress.Archives; using SevenZip;
using SharpCompress.Common;
using SharpCompress.Readers;
namespace auto_creamapi.Services namespace auto_creamapi.Services
{ {
public interface IDownloadCreamApiService public interface IDownloadCreamApiService
{ {
/*public void Initialize();
public Task InitializeAsync();*/
public Task<string> Download(string username, string password); public Task<string> Download(string username, string password);
public void Extract(string filename); public Task Extract(string filename);
} }
public class DownloadCreamApiService : IDownloadCreamApiService public class DownloadCreamApiService : IDownloadCreamApiService
{ {
private const string ArchivePassword = "cs.rin.ru"; private const string ArchivePassword = "cs.rin.ru";
//private string _filename;
private readonly IMvxMessenger _messenger; private readonly IMvxMessenger _messenger;
//private DownloadWindow _wnd;
public DownloadCreamApiService(IMvxMessenger messenger) public DownloadCreamApiService(IMvxMessenger messenger)
{ {
@ -43,6 +36,8 @@ namespace auto_creamapi.Services
var container = new CookieContainer(); var container = new CookieContainer();
var handler = new HttpClientHandler {CookieContainer = container}; var handler = new HttpClientHandler {CookieContainer = container};
var client = new HttpClient(handler); var client = new HttpClient(handler);
client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0) " +
"Gecko/20100101 Firefox/86.0");
var formContent = new FormUrlEncodedContent(new[] var formContent = new FormUrlEncodedContent(new[]
{ {
new KeyValuePair<string, string>("username", username), new KeyValuePair<string, string>("username", username),
@ -51,23 +46,26 @@ namespace auto_creamapi.Services
new KeyValuePair<string, string>("login", "login") new KeyValuePair<string, string>("login", "login")
}); });
MyLogger.Log.Debug("Download: post login"); MyLogger.Log.Debug("Download: post login");
var response1 = await client.PostAsync("https://cs.rin.ru/forum/ucp.php?mode=login", formContent); var response1 = await client.PostAsync("https://cs.rin.ru/forum/ucp.php?mode=login", formContent)
MyLogger.Log.Debug($"Login Status Code: {response1.EnsureSuccessStatusCode().StatusCode.ToString()}"); .ConfigureAwait(false);
MyLogger.Log.Debug("Login Status Code: {StatusCode}",
response1.EnsureSuccessStatusCode().StatusCode);
var cookie = container.GetCookies(new Uri("https://cs.rin.ru/forum/ucp.php?mode=login")) var cookie = container.GetCookies(new Uri("https://cs.rin.ru/forum/ucp.php?mode=login"))
.FirstOrDefault(c => c.Name.Contains("_sid")); .FirstOrDefault(c => c.Name.Contains("_sid"));
MyLogger.Log.Debug($"Login Cookie: {cookie}"); MyLogger.Log.Debug("Login Cookie: {Cookie}", cookie);
var response2 = await client.GetAsync("https://cs.rin.ru/forum/viewtopic.php?t=70576"); var response2 = await client.GetAsync("https://cs.rin.ru/forum/viewtopic.php?t=70576")
MyLogger.Log.Debug( .ConfigureAwait(false);
$"Download Page Status Code: {response2.EnsureSuccessStatusCode().StatusCode.ToString()}"); MyLogger.Log.Debug("Download Page Status Code: {StatusCode}",
response2.EnsureSuccessStatusCode().StatusCode);
var content = response2.Content.ReadAsStringAsync(); var content = response2.Content.ReadAsStringAsync();
var contentResult = await content; var contentResult = await content.ConfigureAwait(false);
var expression = var expression =
new Regex(".*<a href=\"\\.(?<url>\\/download\\/file\\.php\\?id=.*)\">(?<filename>.*)<\\/a>.*"); new Regex(".*<a href=\"\\.(?<url>\\/download\\/file\\.php\\?id=.*)\">(?<filename>.*)<\\/a>.*");
using var reader = new StringReader(contentResult); using var reader = new StringReader(contentResult);
string line; string line;
var archiveFileList = new Dictionary<string, string>(); var archiveFileList = new Dictionary<string, string>();
while ((line = await reader.ReadLineAsync()) != null) while ((line = await reader.ReadLineAsync().ConfigureAwait(false)) != null)
{ {
var match = expression.Match(line); var match = expression.Match(line);
// ReSharper disable once InvertIf // ReSharper disable once InvertIf
@ -75,16 +73,15 @@ namespace auto_creamapi.Services
{ {
archiveFileList.Add(match.Groups["filename"].Value, archiveFileList.Add(match.Groups["filename"].Value,
$"https://cs.rin.ru/forum{match.Groups["url"].Value}"); $"https://cs.rin.ru/forum{match.Groups["url"].Value}");
MyLogger.Log.Debug(archiveFileList.LastOrDefault().Key); MyLogger.Log.Debug("{X}", archiveFileList.LastOrDefault().Key);
} }
} }
MyLogger.Log.Debug("Choosing first element from list..."); MyLogger.Log.Debug("Choosing first element from list...");
var (filename, url) = archiveFileList.FirstOrDefault(); var (filename, url) = archiveFileList.FirstOrDefault();
//filename = filename;
if (File.Exists(filename)) if (File.Exists(filename))
{ {
MyLogger.Log.Information($"{filename} already exists, skipping download..."); MyLogger.Log.Information("{Filename} already exists, skipping download...", filename);
return filename; return filename;
} }
@ -93,33 +90,53 @@ namespace auto_creamapi.Services
x => _messenger.Publish(new ProgressMessage(this, "Downloading...", filename, x))); x => _messenger.Publish(new ProgressMessage(this, "Downloading...", filename, x)));
await using var fileStream = File.OpenWrite(filename); await using var fileStream = File.OpenWrite(filename);
var task = client.GetAsync(url, fileStream, progress); var task = client.GetAsync(url, fileStream, progress);
var response = await task; await task.ConfigureAwait(false);
if (task.IsCompletedSuccessfully) if (task.IsCompletedSuccessfully)
_messenger.Publish(new ProgressMessage(this, "Downloading...", filename, 1.0)); _messenger.Publish(new ProgressMessage(this, "Downloading...", filename, 1.0));
MyLogger.Log.Information("Download done."); MyLogger.Log.Information("Download done.");
return filename; return filename;
} }
public void Extract(string filename) public async Task Extract(string filename)
{ {
MyLogger.Log.Debug("Extract"); MyLogger.Log.Debug("Extract");
MyLogger.Log.Information($@"Start extraction of ""{filename}""..."); var cwd = Directory.GetCurrentDirectory();
var options = new ReaderOptions {Password = ArchivePassword}; const string nonlogBuild = "nonlog_build";
var archive = ArchiveFactory.Open(filename, options); const string steamApi64Dll = "steam_api64.dll";
var expression1 = new Regex(@"nonlog_build\\steam_api(?:64)?\.dll"); const string steamApiDll = "steam_api.dll";
MyLogger.Log.Information(@"Start extraction of ""{Filename}""...", filename);
var nonlogBuildPath = Path.Combine(cwd, nonlogBuild);
if (Directory.Exists(nonlogBuildPath))
Directory.Delete(nonlogBuildPath, true);
_messenger.Publish(new ProgressMessage(this, "Extracting...", filename, 1.0)); _messenger.Publish(new ProgressMessage(this, "Extracting...", filename, 1.0));
foreach (var entry in archive.Entries) SevenZipBase.SetLibraryPath(Path.Combine(cwd, "resources/7z.dll"));
// ReSharper disable once InvertIf using (var extractor =
if (!entry.IsDirectory && expression1.IsMatch(entry.Key)) new SevenZipExtractor(filename, ArchivePassword, InArchiveFormat.Rar)
{ {PreserveDirectoryStructure = false})
MyLogger.Log.Debug(entry.Key); {
entry.WriteToDirectory(Directory.GetCurrentDirectory(), new ExtractionOptions await extractor.ExtractFilesAsync(
{ cwd,
ExtractFullPath = false, $@"{nonlogBuild}\{steamApi64Dll}",
Overwrite = true $@"{nonlogBuild}\{steamApiDll}"
}); ).ConfigureAwait(false);
} }
if (File.Exists(Path.Combine(nonlogBuildPath, steamApi64Dll)))
File.Move(
Path.Combine(cwd, nonlogBuild, steamApi64Dll),
Path.Combine(cwd, steamApi64Dll),
true
);
if (File.Exists(Path.Combine(nonlogBuildPath, steamApiDll)))
File.Move(
Path.Combine(nonlogBuildPath, steamApiDll),
Path.Combine(cwd, steamApiDll),
true
);
if (Directory.Exists(nonlogBuildPath))
Directory.Delete(nonlogBuildPath, true);
MyLogger.Log.Information("Extraction done!"); MyLogger.Log.Information("Extraction done!");
} }
} }

29
auto-creamapi/Setup.cs Normal file
View File

@ -0,0 +1,29 @@
using auto_creamapi.Core;
using auto_creamapi.Utils;
using Microsoft.Extensions.Logging;
using MvvmCross.Platforms.Wpf.Core;
using Serilog;
using Serilog.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace auto_creamapi
{
public class Setup : MvxWpfSetup<MainApplication>
{
protected override ILoggerFactory CreateLogFactory()
{
Log.Logger = MyLogger.Log;
return new SerilogLoggerFactory();
}
protected override ILoggerProvider CreateLogProvider()
{
return new SerilogLoggerProvider();
}
}
}

View File

@ -0,0 +1,35 @@
using System.Text.Json.Serialization;
namespace auto_creamapi.Utils
{
public class AvailableArchive
{
[JsonPropertyName("url")]
public string Url { get; set; }
[JsonPropertyName("archived_snapshots")]
public ArchivedSnapshot ArchivedSnapshots { get; set; }
}
public class ArchivedSnapshot
{
[JsonPropertyName("closest")]
public Closest Closest { get; set; }
}
public class Closest
{
[JsonPropertyName("status")]
public string Status { get; set; }
[JsonPropertyName("available")]
public bool Available { get; set; }
[JsonPropertyName("url")]
public string Url { get; set; }
[JsonPropertyName("timestamp")]
public string Timestamp { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace auto_creamapi.Utils
{
public interface ISecrets
{
public string ForumUsername();
public string ForumPassword();
}
}

View File

@ -1,10 +1,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace auto_creamapi.Utils namespace auto_creamapi.Utils
{ {
public class Misc public static class Misc
{ {
public static readonly List<string> DefaultLanguages = new List<string>(new[] public const string SpecialCharsRegex = "[^0-9a-zA-Z]+";
public const string DefaultLanguageSelection = "english";
public static readonly ObservableCollection<string> DefaultLanguages = new(new[]
{ {
"arabic", "arabic",
"bulgarian", "bulgarian",

View File

@ -1,12 +1,14 @@
using Serilog; using Serilog;
using Serilog.Core; using Serilog.Core;
using Serilog.Exceptions;
namespace auto_creamapi.Utils namespace auto_creamapi.Utils
{ {
public class MyLogger public static class MyLogger
{ {
public static readonly Logger Log = new LoggerConfiguration() public static readonly Logger Log = new LoggerConfiguration()
.MinimumLevel.Debug() .MinimumLevel.Debug()
.Enrich.WithExceptionDetails()
.WriteTo.Console() .WriteTo.Console()
.WriteTo.File("autocreamapi.log", rollingInterval: RollingInterval.Day) .WriteTo.File("autocreamapi.log", rollingInterval: RollingInterval.Day)
.CreateLogger(); .CreateLogger();

View File

@ -1,14 +0,0 @@
namespace auto_creamapi.Utils
{
/// <summary>
/// To use this:
/// Rename file Secrets.EXAMPLE.cs to Secrets.cs
/// Rename class Secrets_REMOVETHIS to Secrets
/// Enter the relevant info below
/// </summary>
public class Secrets_REMOVETHIS
{
public const string Username = "Enter username here";
public const string Password = "Enter password here";
}
}

View File

@ -1,8 +1,10 @@
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows;
using auto_creamapi.Messenger; using auto_creamapi.Messenger;
using auto_creamapi.Services; using auto_creamapi.Services;
using auto_creamapi.Utils; using auto_creamapi.Utils;
using MvvmCross.Logging; using Microsoft.Extensions.Logging;
using MvvmCross.Navigation; using MvvmCross.Navigation;
using MvvmCross.Plugin.Messenger; using MvvmCross.Plugin.Messenger;
using MvvmCross.ViewModels; using MvvmCross.ViewModels;
@ -14,18 +16,22 @@ namespace auto_creamapi.ViewModels
private readonly IDownloadCreamApiService _download; private readonly IDownloadCreamApiService _download;
private readonly IMvxNavigationService _navigationService; private readonly IMvxNavigationService _navigationService;
private readonly MvxSubscriptionToken _token; private readonly MvxSubscriptionToken _token;
private readonly ILogger<DownloadViewModel> _logger;
private string _filename; private string _filename;
private string _info; private string _info;
private double _progress; private double _progress;
public DownloadViewModel(IMvxLogProvider logProvider, IMvxNavigationService navigationService, private readonly Secrets _secrets = new();
IDownloadCreamApiService download, IMvxMessenger messenger) : base(logProvider, navigationService)
public DownloadViewModel(ILoggerFactory loggerFactory, IMvxNavigationService navigationService,
IDownloadCreamApiService download, IMvxMessenger messenger) : base(loggerFactory, navigationService)
{ {
_navigationService = navigationService; _navigationService = navigationService;
_logger = loggerFactory.CreateLogger<DownloadViewModel>();
_download = download; _download = download;
_token = messenger.Subscribe<ProgressMessage>(OnProgressMessage); _token = messenger.Subscribe<ProgressMessage>(OnProgressMessage);
MyLogger.Log.Debug(messenger.CountSubscriptionsFor<ProgressMessage>().ToString()); _logger.LogDebug("{Count}", messenger.CountSubscriptionsFor<ProgressMessage>());
} }
public string InfoLabel public string InfoLabel
@ -61,24 +67,38 @@ namespace auto_creamapi.ViewModels
public string ProgressPercent => _progress.ToString("P2"); public string ProgressPercent => _progress.ToString("P2");
public override async Task Initialize() public override void Prepare()
{ {
await base.Initialize();
InfoLabel = "Please wait..."; InfoLabel = "Please wait...";
FilenameLabel = ""; FilenameLabel = "";
Progress = 0.0; Progress = 0.0;
var download = _download.Download(Secrets.ForumUsername, Secrets.ForumPassword); }
var filename = await download;
/*var extract = _download.Extract(filename); public override async Task Initialize()
await extract;*/ {
await Task.Run(() => _download.Extract(filename)); try
_token.Dispose(); {
await _navigationService.Close(this); await base.Initialize().ConfigureAwait(false);
var download = _download.Download(_secrets.ForumUsername(), _secrets.ForumPassword());
var filename = await download.ConfigureAwait(false);
var extract = _download.Extract(filename);
await extract.ConfigureAwait(false);
_token.Dispose();
await _navigationService.Close(this).ConfigureAwait(false);
}
catch (Exception e)
{
MessageBox.Show("Could not download CreamAPI!\nPlease add CreamAPI DLLs manually!\nShutting down...",
"Error", MessageBoxButton.OK, MessageBoxImage.Error);
_token.Dispose();
await _navigationService.Close(this).ConfigureAwait(false);
Console.WriteLine(e);
throw;
}
} }
private void OnProgressMessage(ProgressMessage obj) private void OnProgressMessage(ProgressMessage obj)
{ {
//MyLogger.Log.Debug($"{obj.Filename}: {obj.BytesTransferred}");
InfoLabel = obj.Info; InfoLabel = obj.Info;
FilenameLabel = obj.Filename; FilenameLabel = obj.Filename;
Progress = obj.PercentComplete; Progress = obj.PercentComplete;

View File

@ -7,6 +7,7 @@ using System.Threading.Tasks;
using auto_creamapi.Models; using auto_creamapi.Models;
using auto_creamapi.Services; using auto_creamapi.Services;
using auto_creamapi.Utils; using auto_creamapi.Utils;
using Microsoft.Extensions.Logging;
using Microsoft.Win32; using Microsoft.Win32;
using MvvmCross.Commands; using MvvmCross.Commands;
using MvvmCross.Navigation; using MvvmCross.Navigation;
@ -16,10 +17,10 @@ namespace auto_creamapi.ViewModels
{ {
public class MainViewModel : MvxViewModel public class MainViewModel : MvxViewModel
{ {
private const string DefaultLanguageSelection = "english";
private readonly ICacheService _cache; private readonly ICacheService _cache;
private readonly ICreamConfigService _config; private readonly ICreamConfigService _config;
private readonly ILogger<MainViewModel> _logger;
private readonly ICreamDllService _dll; private readonly ICreamDllService _dll;
private readonly IMvxNavigationService _navigationService; private readonly IMvxNavigationService _navigationService;
private int _appId; private int _appId;
@ -27,7 +28,7 @@ namespace auto_creamapi.ViewModels
private ObservableCollection<SteamApp> _dlcs; private ObservableCollection<SteamApp> _dlcs;
private bool _dllApplied; private bool _dllApplied;
private string _dllPath; private string _dllPath;
private bool _extraprotection; private bool _extraProtection;
private string _gameName; private string _gameName;
private string _lang; private string _lang;
private ObservableCollection<string> _languages; private ObservableCollection<string> _languages;
@ -36,26 +37,46 @@ namespace auto_creamapi.ViewModels
private bool _mainWindowEnabled; private bool _mainWindowEnabled;
private bool _offline; private bool _offline;
private string _status; private string _status;
private bool _unlockall; private bool _unlockAll;
private bool _useSteamDb; private bool _useSteamDb;
private bool _ignoreUnknown;
//private const string DlcRegexPattern = @"(?<id>.*) *= *(?<name>.*)"; //private const string DlcRegexPattern = @"(?<id>.*) *= *(?<name>.*)";
public MainViewModel(ICacheService cache, ICreamConfigService config, ICreamDllService dll, public MainViewModel(ICacheService cache, ICreamConfigService config, ICreamDllService dll,
IMvxNavigationService navigationService) IMvxNavigationService navigationService, ILoggerFactory loggerFactory)
{ {
_navigationService = navigationService; _navigationService = navigationService;
_logger = loggerFactory.CreateLogger<MainViewModel>();
_cache = cache; _cache = cache;
_config = config; _config = config;
_dll = dll; _dll = dll;
//_download = download; //_download = download;
} }
public override async void Prepare()
{
base.Prepare();
_config.Initialize();
var tasks = new List<Task> { _cache.Initialize() };
if (!File.Exists("steam_api.dll") | !File.Exists("steam_api64.dll"))
tasks.Add(_navigationService.Navigate<DownloadViewModel>());
//tasks.Add(_navigationService.Navigate<DownloadViewModel>());
tasks.Add(_dll.Initialize());
await Task.WhenAll(tasks).ConfigureAwait(false);
Languages = new ObservableCollection<string>(Misc.DefaultLanguages);
ResetForm();
UseSteamDb = true;
MainWindowEnabled = true;
Status = "Ready.";
}
// // COMMANDS // // // // COMMANDS // //
public IMvxCommand OpenFileCommand => new MvxCommand(OpenFile); public IMvxCommand OpenFileCommand => new MvxAsyncCommand(OpenFile);
public IMvxCommand SearchCommand => new MvxAsyncCommand(async () => await Search()); //Command(Search); public IMvxCommand SearchCommand => new MvxAsyncCommand(async () => await Search().ConfigureAwait(false)); //Command(Search);
public IMvxCommand GetListOfDlcCommand => new MvxAsyncCommand(GetListOfDlc); public IMvxCommand GetListOfDlcCommand => new MvxAsyncCommand(GetListOfDlc);
@ -65,6 +86,8 @@ namespace auto_creamapi.ViewModels
public IMvxCommand GoToForumThreadCommand => new MvxCommand(GoToForumThread); public IMvxCommand GoToForumThreadCommand => new MvxCommand(GoToForumThread);
public IMvxCommand GoToSteamdbCommand => new MvxCommand(GoToSteamdb);
// // ATTRIBUTES // // // // ATTRIBUTES // //
public bool MainWindowEnabled public bool MainWindowEnabled
@ -94,7 +117,6 @@ namespace auto_creamapi.ViewModels
{ {
_gameName = value; _gameName = value;
RaisePropertyChanged(() => GameName); RaisePropertyChanged(() => GameName);
//MyLogger.Log.Debug($"GameName: {value}");
} }
} }
@ -105,7 +127,7 @@ namespace auto_creamapi.ViewModels
{ {
_appId = value; _appId = value;
RaisePropertyChanged(() => AppId); RaisePropertyChanged(() => AppId);
if (value > 0) SetNameById(); SetNameById();
} }
} }
@ -116,7 +138,6 @@ namespace auto_creamapi.ViewModels
{ {
_lang = value; _lang = value;
RaisePropertyChanged(() => Lang); RaisePropertyChanged(() => Lang);
//MyLogger.Log.Debug($"Lang: {value}");
} }
} }
@ -130,23 +151,23 @@ namespace auto_creamapi.ViewModels
} }
} }
public bool Extraprotection public bool ExtraProtection
{ {
get => _extraprotection; get => _extraProtection;
set set
{ {
_extraprotection = value; _extraProtection = value;
RaisePropertyChanged(() => Extraprotection); RaisePropertyChanged(() => ExtraProtection);
} }
} }
public bool Unlockall public bool UnlockAll
{ {
get => _unlockall; get => _unlockAll;
set set
{ {
_unlockall = value; _unlockAll = value;
RaisePropertyChanged(() => Unlockall); RaisePropertyChanged(() => UnlockAll);
} }
} }
@ -210,28 +231,17 @@ namespace auto_creamapi.ViewModels
} }
} }
public override async Task Initialize() public bool IgnoreUnknown
{ {
_config.Initialize(); get => _ignoreUnknown;
/*await base.Initialize(); set
await _cache.Initialize(); {
if (!File.Exists("steam_api.dll") | !File.Exists("steam_api64.dll")) _ignoreUnknown = value;
await _navigationService.Navigate<DownloadViewModel>(); RaisePropertyChanged(() => IgnoreUnknown);
await _dll.Initialize();*/ }
var tasks = new List<Task> {base.Initialize(), _cache.Initialize()};
if (!File.Exists("steam_api.dll") | !File.Exists("steam_api64.dll"))
tasks.Add(_navigationService.Navigate<DownloadViewModel>());
tasks.Add(_dll.Initialize());
await Task.WhenAll(tasks);
Languages = new ObservableCollection<string>(_cache.Languages);
ResetForm();
Lang = DefaultLanguageSelection;
UseSteamDb = true;
MainWindowEnabled = true;
Status = "Ready.";
} }
private void OpenFile() private async Task OpenFile()
{ {
Status = "Waiting for file..."; Status = "Waiting for file...";
var dialog = new OpenFileDialog var dialog = new OpenFileDialog
@ -252,7 +262,22 @@ namespace auto_creamapi.ViewModels
ResetForm(); ResetForm();
_dll.TargetPath = dirPath; _dll.TargetPath = dirPath;
_dll.CheckIfDllExistsAtTarget(); _dll.CheckIfDllExistsAtTarget();
CheckExistence(); CheckSetupStatus();
if (!ConfigExists)
{
var separator = Path.DirectorySeparatorChar;
var strings = new List<string>(dirPath.Split(separator));
var index = strings.Contains("common") ? strings.FindIndex(x => x.Equals("common")) + 1 : -1;
if (index == -1)
index = strings.Contains("steamapps")
? strings.FindIndex(x => x.Equals("steamapps")) + 2
: -1;
var s = index > -1 ? strings[index] : null;
if (s != null) GameName = s;
await Search().ConfigureAwait(false);
// await GetListOfDlc().ConfigureAwait(false);
}
Status = "Ready."; Status = "Ready.";
} }
} }
@ -274,9 +299,10 @@ namespace auto_creamapi.ViewModels
} }
else else
{ {
MainWindowEnabled = false;
var navigate = _navigationService.Navigate<SearchResultViewModel, IEnumerable<SteamApp>, SteamApp>( var navigate = _navigationService.Navigate<SearchResultViewModel, IEnumerable<SteamApp>, SteamApp>(
_cache.GetListOfAppsByName(GameName)); _cache.GetListOfAppsByName(GameName));
await navigate; await navigate.ConfigureAwait(false);
var navigateResult = navigate.Result; var navigateResult = navigate.Result;
if (navigateResult != null) if (navigateResult != null)
{ {
@ -284,27 +310,31 @@ namespace auto_creamapi.ViewModels
AppId = navigateResult.AppId; AppId = navigateResult.AppId;
} }
} }
// await GetListOfDlc().ConfigureAwait(false);
} }
else else
{ {
MyLogger.Log.Warning("Empty game name, cannot initiate search!"); _logger.LogWarning("Empty game name, cannot initiate search!");
} }
MainWindowEnabled = true;
} }
private async Task GetListOfDlc() private async Task GetListOfDlc()
{ {
Status = "Trying to get DLC..."; Status = "Trying to get DLC, please wait...";
if (AppId > 0) if (AppId > 0)
{ {
var app = new SteamApp {AppId = AppId, Name = GameName}; var app = new SteamApp { AppId = AppId, Name = GameName };
var task = _cache.GetListOfDlc(app, UseSteamDb); var task = _cache.GetListOfDlc(app, UseSteamDb, IgnoreUnknown);
MainWindowEnabled = false; MainWindowEnabled = false;
var listOfDlc = await task; var listOfDlc = await task.ConfigureAwait(false);
if (task.IsCompletedSuccessfully) if (task.IsCompletedSuccessfully)
{ {
listOfDlc.Sort((app1, app2) => app1.AppId.CompareTo(app2.AppId)); listOfDlc.Sort((app1, app2) => app1.AppId.CompareTo(app2.AppId));
Dlcs = new ObservableCollection<SteamApp>(listOfDlc); Dlcs = new ObservableCollection<SteamApp>(listOfDlc);
Status = $"Got DLC for AppID {AppId}"; Status = $"Got DLC for AppID {AppId} (Count: {Dlcs.Count})";
} }
else else
{ {
@ -316,7 +346,7 @@ namespace auto_creamapi.ViewModels
else else
{ {
Status = $"Could not get DLC for AppID {AppId}"; Status = $"Could not get DLC for AppID {AppId}";
MyLogger.Log.Error($"GetListOfDlc: Invalid AppID {AppId}"); _logger.LogError("GetListOfDlc: Invalid AppID {AppId}", AppId);
} }
} }
@ -326,14 +356,14 @@ namespace auto_creamapi.ViewModels
_config.SetConfigData( _config.SetConfigData(
AppId, AppId,
Lang, Lang,
Unlockall, UnlockAll,
Extraprotection, ExtraProtection,
Offline, Offline,
Dlcs Dlcs
); );
_config.SaveFile(); _config.SaveFile();
_dll.Save(); _dll.Save();
CheckExistence(); CheckSetupStatus();
Status = "Saving successful."; Status = "Saving successful.";
} }
@ -341,8 +371,8 @@ namespace auto_creamapi.ViewModels
{ {
AppId = _config.Config.AppId; AppId = _config.Config.AppId;
Lang = _config.Config.Language; Lang = _config.Config.Language;
Unlockall = _config.Config.UnlockAll; UnlockAll = _config.Config.UnlockAll;
Extraprotection = _config.Config.ExtraProtection; ExtraProtection = _config.Config.ExtraProtection;
Offline = _config.Config.ForceOffline; Offline = _config.Config.ForceOffline;
Dlcs = new ObservableCollection<SteamApp>(_config.Config.DlcList); Dlcs = new ObservableCollection<SteamApp>(_config.Config.DlcList);
Status = "Changes have been reset."; Status = "Changes have been reset.";
@ -355,9 +385,7 @@ namespace auto_creamapi.ViewModels
{ {
var searchTerm = AppId; //$"{GameName.Replace(" ", "+")}+{appId}"; var searchTerm = AppId; //$"{GameName.Replace(" ", "+")}+{appId}";
var destinationUrl = var destinationUrl =
"https://cs.rin.ru/forum/search.php?keywords=" + $"https://cs.rin.ru/forum/search.php?keywords={searchTerm}&terms=any&fid[]=10&sf=firstpost&sr=topics&submit=Search";
searchTerm +
"&terms=any&fid[]=10&sf=firstpost&sr=topics&submit=Search";
var uri = new Uri(destinationUrl); var uri = new Uri(destinationUrl);
var process = new ProcessStartInfo(uri.AbsoluteUri) var process = new ProcessStartInfo(uri.AbsoluteUri)
{ {
@ -367,12 +395,34 @@ namespace auto_creamapi.ViewModels
} }
else else
{ {
MyLogger.Log.Error($"OpenURL: Invalid AppID {AppId}"); _logger.LogError("OpenURL: Invalid AppID {AppId}", AppId);
Status = $"Could not open URL: Invalid AppID {AppId}"; Status = $"Could not open URL: Invalid AppID {AppId}";
} }
} }
private void CheckExistence() private void GoToSteamdb()
{
Status = "Opening URL...";
if (AppId > 0)
{
var searchTerm = AppId; //$"{GameName.Replace(" ", "+")}+{appId}";
var destinationUrl =
$"https://steamdb.info/app/{searchTerm}/dlc/";
var uri = new Uri(destinationUrl);
var process = new ProcessStartInfo(uri.AbsoluteUri)
{
UseShellExecute = true
};
Process.Start(process);
}
else
{
_logger.LogError("OpenURL: Invalid AppID {AppId}", AppId);
Status = $"Could not open URL: Invalid AppID {AppId}";
}
}
private void CheckSetupStatus()
{ {
DllApplied = _dll.CreamApiApplied(); DllApplied = _dll.CreamApiApplied();
ConfigExists = _config.ConfigExists(); ConfigExists = _config.ConfigExists();
@ -380,8 +430,12 @@ namespace auto_creamapi.ViewModels
private void SetNameById() private void SetNameById()
{ {
var appById = _cache.GetAppById(_appId); if (_appId > 0)
GameName = appById != null ? appById.Name : ""; {
var appById = _cache.GetAppById(_appId);
GameName = appById != null ? appById.Name : "";
}
else GameName = "";
} }
} }
} }

View File

@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using auto_creamapi.Models; using auto_creamapi.Models;
using auto_creamapi.Utils; using auto_creamapi.Utils;
using Microsoft.Extensions.Logging;
using MvvmCross.Commands; using MvvmCross.Commands;
using MvvmCross.Logging; using MvvmCross.Logging;
using MvvmCross.Navigation; using MvvmCross.Navigation;
@ -13,16 +14,18 @@ namespace auto_creamapi.ViewModels
IMvxViewModel<IEnumerable<SteamApp>, SteamApp> IMvxViewModel<IEnumerable<SteamApp>, SteamApp>
{ {
private readonly IMvxNavigationService _navigationService; private readonly IMvxNavigationService _navigationService;
private readonly ILogger<SearchResultViewModel> _logger;
private IEnumerable<SteamApp> _steamApps; private IEnumerable<SteamApp> _steamApps;
/*public override async Task Initialize() /*public override async Task Initialize()
{ {
await base.Initialize(); await base.Initialize();
}*/ }*/
public SearchResultViewModel(IMvxLogProvider logProvider, IMvxNavigationService navigationService) : base( public SearchResultViewModel(ILoggerFactory loggerFactory, IMvxNavigationService navigationService) : base(
logProvider, navigationService) loggerFactory, navigationService)
{ {
_navigationService = navigationService; _navigationService = navigationService;
_logger = loggerFactory.CreateLogger<SearchResultViewModel>();
} }
public IEnumerable<SteamApp> Apps public IEnumerable<SteamApp> Apps
@ -55,9 +58,11 @@ namespace auto_creamapi.ViewModels
public override void ViewDestroy(bool viewFinishing = true) public override void ViewDestroy(bool viewFinishing = true)
{ {
if (viewFinishing && CloseCompletionSource != null && !CloseCompletionSource.Task.IsCompleted && if (viewFinishing && CloseCompletionSource?.Task.IsCompleted == false &&
!CloseCompletionSource.Task.IsFaulted) !CloseCompletionSource.Task.IsFaulted)
{
CloseCompletionSource?.TrySetCanceled(); CloseCompletionSource?.TrySetCanceled();
}
base.ViewDestroy(viewFinishing); base.ViewDestroy(viewFinishing);
} }
@ -66,8 +71,8 @@ namespace auto_creamapi.ViewModels
{ {
if (Selected != null) if (Selected != null)
{ {
MyLogger.Log.Information($"Successfully got app {Selected}"); _logger.LogInformation("Successfully got app {Selected}", Selected);
await _navigationService.Close(this, Selected); await _navigationService.Close(this, Selected).ConfigureAwait(false);
} }
} }

View File

@ -1,3 +1,4 @@
<!-- ReSharper disable once UnusedType.Global -->
<views:MvxWpfView <views:MvxWpfView
xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf" xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf"
x:Class="auto_creamapi.Views.MainView" x:Class="auto_creamapi.Views.MainView"
@ -9,7 +10,8 @@
xmlns:vm="clr-namespace:auto_creamapi.ViewModels" xmlns:vm="clr-namespace:auto_creamapi.ViewModels"
d:DataContext="{d:DesignInstance Type=vm:MainViewModel}" d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"
xmlns:converters="clr-namespace:auto_creamapi.Converters" xmlns:converters="clr-namespace:auto_creamapi.Converters"
mc:Ignorable="d"> mc:Ignorable="d"
d:DesignHeight="720" d:DesignWidth="560">
<views:MvxWpfView.Resources> <views:MvxWpfView.Resources>
<converters:ListOfDLcToStringNativeConverter x:Key="DlcConv" /> <converters:ListOfDLcToStringNativeConverter x:Key="DlcConv" />
</views:MvxWpfView.Resources> </views:MvxWpfView.Resources>
@ -25,36 +27,54 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<wcl:WatermarkTextBox x:Name="DllPath" Text="{Binding DllPath}" Watermark="Path to game's steam_api(64).dll..." <wcl:WatermarkTextBox Text="{Binding DllPath}" Watermark="Path to game's steam_api(64).dll..."
Margin="10,11,55,0" TextWrapping="NoWrap" VerticalAlignment="Top" Padding="0" Margin="10,10,55,0" TextWrapping="NoWrap" VerticalAlignment="Top" Padding="0"
Grid.Row="0" IsReadOnly="True" IsReadOnlyCaretVisible="True"> Grid.Row="0" IsReadOnly="True" IsReadOnlyCaretVisible="True">
<!--MouseDoubleClick="{Binding Path=OpenFileCommand}"--> <!--MouseDoubleClick="{Binding Path=OpenFileCommand}"-->
<wcl:WatermarkTextBox.InputBindings> <wcl:WatermarkTextBox.InputBindings>
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding OpenFileCommand}" /> <MouseBinding
Gesture="LeftDoubleClick"
Command="{Binding OpenFileCommand}" />
</wcl:WatermarkTextBox.InputBindings> </wcl:WatermarkTextBox.InputBindings>
</wcl:WatermarkTextBox> </wcl:WatermarkTextBox>
<Button Content="&#xE1A5;" HorizontalAlignment="Right" Margin="0,10,10,0" VerticalAlignment="Top" <Button Content="&#xE1A5;" HorizontalAlignment="Right" Margin="0,10,10,0" VerticalAlignment="Top"
FontFamily="Segoe UI Symbol" Width="40" Command="{Binding OpenFileCommand}" ToolTip="Select DLL file." FontFamily="Segoe UI Symbol" Width="40" Command="{Binding OpenFileCommand}" ToolTip="Select DLL file."
Grid.Row="0" /> Grid.Row="0" />
<wcl:WatermarkTextBox Text="{Binding GameName, Mode=TwoWay}" x:Name="Game" Margin="10,10,180,0" <wcl:WatermarkTextBox Text="{Binding GameName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Margin="10,10,180,0"
Watermark="Game Name" TextWrapping="Wrap" VerticalAlignment="Top" Padding="0" Watermark="Game Name" TextWrapping="Wrap" VerticalAlignment="Top" Padding="0"
Grid.Row="1" /> Grid.Row="1">
<wcl:WatermarkTextBox.InputBindings>
<KeyBinding
Key="Enter"
Command="{Binding SearchCommand}" />
</wcl:WatermarkTextBox.InputBindings>
</wcl:WatermarkTextBox>
<Button Content="&#xE11A;" HorizontalAlignment="Right" Margin="0,9,135,0" VerticalAlignment="Top" <Button Content="&#xE11A;" HorizontalAlignment="Right" Margin="0,9,135,0" VerticalAlignment="Top"
FontFamily="Segoe UI Symbol" Width="40" Command="{Binding SearchCommand}" ToolTip="Find AppID." FontFamily="Segoe UI Symbol" Width="40" Command="{Binding SearchCommand}" ToolTip="Find AppID."
Grid.Row="1" /> Grid.Row="1" />
<wcl:WatermarkTextBox Text="{Binding AppId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" x:Name="AppId" <wcl:WatermarkTextBox Text="{Binding AppId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Right" Margin="0,10,10,0" Watermark="AppID" TextWrapping="Wrap" HorizontalAlignment="Right" Margin="0,10,10,0" Watermark="AppID" TextWrapping="Wrap"
VerticalAlignment="Top" Width="120" Padding="0" Grid.Row="1" /> VerticalAlignment="Top" Width="120" Padding="0" Grid.Row="1" />
<TextBlock Grid.Row="2" Margin="10,10,10,0"> <Grid Grid.Row="2" Margin="10,10,0,0">
<Hyperlink Command="{Binding GoToForumThreadCommand}">Search for cs.rin.ru thread</Hyperlink> <Grid.ColumnDefinitions>
</TextBlock> <ColumnDefinition Width="Auto"/>
<ComboBox x:Name="Lang" ItemsSource="{Binding Path=Languages}" SelectedItem="{Binding Path=Lang, Mode=TwoWay}" <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Margin="0,0,10,0">
<Hyperlink Command="{Binding GoToForumThreadCommand}">Search for cs.rin.ru thread...</Hyperlink>
</TextBlock>
<TextBlock Grid.Column="1" Margin="0,0,0,0">
<Hyperlink Command="{Binding GoToSteamdbCommand}">Open SteamDB DLC page...</Hyperlink>
</TextBlock>
</Grid>
<ComboBox ItemsSource="{Binding Path=Languages}" SelectedItem="{Binding Path=Lang, Mode=TwoWay}"
HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="120" Grid.Row="3" /> HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="120" Grid.Row="3" />
<CheckBox x:Name="ForceOffline" Content="Force offline mode" IsChecked="{Binding Offline, Mode=TwoWay}" <CheckBox Content="Force offline mode" IsChecked="{Binding Offline, Mode=TwoWay}"
HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" ToolTip="offlinemode" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" ToolTip="offlinemode"
Grid.Row="4" /> Grid.Row="4" />
<CheckBox x:Name="ExtraProtection" Content="Try to bypass game-specific protection" <CheckBox Content="Try to bypass game-specific protection"
IsChecked="{Binding Extraprotection, Mode=TwoWay}" HorizontalAlignment="Left" Margin="10,10,0,0" IsChecked="{Binding ExtraProtection, Mode=TwoWay}" HorizontalAlignment="Left" Margin="10,10,0,0"
VerticalAlignment="Top" ToolTip="extraprotection" Grid.Row="5" /> VerticalAlignment="Top" ToolTip="extraprotection" Grid.Row="5" />
<Grid Margin="10,10,10,0" Grid.Row="6"> <Grid Margin="10,10,10,0" Grid.Row="6">
<Grid.RowDefinitions> <Grid.RowDefinitions>
@ -64,38 +84,42 @@
<GroupBox Header="DLC" Grid.Row="0" VerticalAlignment="Stretch"> <GroupBox Header="DLC" Grid.Row="0" VerticalAlignment="Stretch">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<CheckBox x:Name="UnlockAll" Content="Unlock all DLCs (if possible)" <CheckBox Content="Unlock all DLCs (if possible)"
IsChecked="{Binding Unlockall, Mode=TwoWay}" HorizontalAlignment="Left" IsChecked="{Binding UnlockAll, Mode=TwoWay}" HorizontalAlignment="Left"
Margin="10,10,0,0" VerticalAlignment="Top" ToolTip="unlockall" /> Margin="10,10,0,0" VerticalAlignment="Top" ToolTip="unlockall" />
<CheckBox x:Name="SteamDb" Content="Additionally use SteamDB for DLCs" <CheckBox Content="Additionally use SteamDB for DLCs"
IsChecked="{Binding UseSteamDb, Mode=TwoWay}" HorizontalAlignment="Left" IsChecked="{Binding UseSteamDb, Mode=TwoWay}" HorizontalAlignment="Left"
Margin="10,10,0,0" VerticalAlignment="Top" Grid.Row="1" /> Margin="10,10,0,0" VerticalAlignment="Top" Grid.Row="1" />
<CheckBox Content="Ignore unknown DLC from SteamDB" IsEnabled="{Binding UseSteamDb}"
IsChecked="{Binding IgnoreUnknown, Mode=TwoWay}" HorizontalAlignment="Left"
Margin="10,10,0,0" VerticalAlignment="Top" Grid.Row="2" />
<!-- Text="{Binding Dlcs, Converter={StaticResource DlcConv}, Mode=TwoWay}"--> <!-- Text="{Binding Dlcs, Converter={StaticResource DlcConv}, Mode=TwoWay}"-->
<!-- Text="{Binding DlcsString, Mode=TwoWay}"--> <!-- Text="{Binding DlcsString, Mode=TwoWay}"-->
<wcl:WatermarkTextBox x:Name="ListOfDlcs" <wcl:WatermarkTextBox
Text="{Binding Dlcs, Converter={StaticResource DlcConv}, Mode=TwoWay}" Text="{Binding Dlcs, Converter={StaticResource DlcConv}, Mode=TwoWay}"
Margin="10,10,10,0" Watermark="List of DLCs...&#xA;0000 = DLC Name" Margin="10,10,10,0" Watermark="List of DLCs...&#xA;0000 = DLC Name"
TextWrapping="Wrap" AcceptsReturn="True" TextWrapping="Wrap" AcceptsReturn="True"
VerticalScrollBarVisibility="Visible" Padding="0" VerticalScrollBarVisibility="Visible" Padding="5,5,5,5"
FontFamily="./#Courier Prime" Grid.Row="2" /> FontFamily="../resources/#Courier Prime" Grid.Row="3" />
<Button Content="Get DLCs for AppID" Margin="0,10,10,10" Height="19.96" HorizontalAlignment="Right" <Button Content="Get DLCs for AppID" Margin="0,10,10,10" Height="19.96" HorizontalAlignment="Right"
VerticalAlignment="Bottom" Width="108" Command="{Binding GetListOfDlcCommand}" Grid.Row="3" /> VerticalAlignment="Bottom" Width="108" Command="{Binding GetListOfDlcCommand}" Grid.Row="4" />
</Grid> </Grid>
</GroupBox> </GroupBox>
<GroupBox Header="Status" Grid.Row="1" VerticalAlignment="Bottom" IsEnabled="False"> <GroupBox Header="Status" Grid.Row="1" VerticalAlignment="Bottom" IsEnabled="False" Margin="0,10,0,0">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<CheckBox x:Name="CreamApiApplied" Content="CreamAPI DLL applied" Margin="10,10,0,10" <CheckBox Content="CreamAPI DLL applied" Margin="10,10,0,10"
Grid.Column="0" IsChecked="{Binding DllApplied, Mode=TwoWay}" /> Grid.Column="0" IsChecked="{Binding DllApplied, Mode=TwoWay}" />
<CheckBox x:Name="ConfigExists" Content="CreamAPI Config exists" Margin="10,10,0,10" <CheckBox Content="CreamAPI Config exists" Margin="10,10,0,10"
Grid.Column="1" IsChecked="{Binding ConfigExists, Mode=TwoWay}" /> Grid.Column="1" IsChecked="{Binding ConfigExists, Mode=TwoWay}" />
</Grid> </Grid>
</GroupBox> </GroupBox>
@ -106,7 +130,7 @@
VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="40" Grid.Row="7" /> VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="40" Grid.Row="7" />
<StatusBar Grid.Row="8"> <StatusBar Grid.Row="8">
<StatusBarItem Height="30" Margin="0,0,0,0"> <StatusBarItem Height="30" Margin="0,0,0,0">
<TextBlock x:Name="Status" Text="{Binding Status, Mode=TwoWay}" /> <TextBlock Text="{Binding Status, Mode=TwoWay}" />
</StatusBarItem> </StatusBarItem>
</StatusBar> </StatusBar>
</Grid> </Grid>

View File

@ -3,6 +3,7 @@ using MvvmCross.Platforms.Wpf.Presenters.Attributes;
namespace auto_creamapi.Views namespace auto_creamapi.Views
{ {
[MvxContentPresentation(WindowIdentifier = nameof(MainView), StackNavigation = false)] [MvxContentPresentation(WindowIdentifier = nameof(MainView), StackNavigation = false)]
// ReSharper disable once UnusedType.Global
public partial class MainView public partial class MainView
{ {
public MainView() public MainView()

View File

@ -11,38 +11,6 @@ namespace auto_creamapi.Views
public SearchResultView() public SearchResultView()
{ {
InitializeComponent(); InitializeComponent();
//DgApps.ItemsSource = list;
} }
/*private void OK_OnClick(object sender, RoutedEventArgs e)
{
GetSelectedApp();
}
private void DgApps_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
GetSelectedApp();
}
private void Cancel_OnClick(object sender, RoutedEventArgs e)
{
Close();
}
private void GetSelectedApp()
{
if (Application.Current.MainWindow is MainWindow currentMainWindow)
{
var app = (SteamApp) DgApps.SelectedItem;
if (app != null)
{
MyLogger.Log.Information($"Successfully got app {app}");
//currentMainWindow.Game.Text = app.Name;
//currentMainWindow.AppId.Text = app.AppId.ToString();
}
}
Close();
}*/
} }
} }

View File

@ -1,42 +1,58 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net8.0-windows</TargetFramework>
<RootNamespace>auto_creamapi</RootNamespace> <RootNamespace>auto_creamapi</RootNamespace>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
</PropertyGroup> <PackageVersion>2.2.0</PackageVersion>
<Title>auto-creamapi</Title>
<Authors>Jeddunk</Authors>
<Company>jeddunk.xyz</Company>
<AssemblyVersion>2.2.0</AssemblyVersion>
<FileVersion>2.2.0</FileVersion>
</PropertyGroup>
<ItemGroup> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<PackageReference Include="AngleSharp" Version="0.14.0" /> <DebugType>none</DebugType>
<PackageReference Include="bloomtom.HttpProgress" Version="2.3.2" /> </PropertyGroup>
<PackageReference Include="Dirkster.WatermarkControlsLib" Version="1.1.0" />
<PackageReference Include="ini-parser-netstandard" Version="2.5.2" />
<PackageReference Include="MvvmCross" Version="7.1.2" />
<PackageReference Include="MvvmCross.Platforms.Wpf" Version="7.1.2" />
<PackageReference Include="MvvmCross.Plugin.Messenger" Version="7.1.2" />
<PackageReference Include="NinjaNye.SearchExtensions" Version="3.0.1" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="SharpCompress" Version="0.26.0" />
<PackageReference Include="SteamStorefrontAPI.NETStandard" Version="1.0.0" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="App.xaml" /> <PackageReference Include="AngleSharp" Version="1.0.7" />
</ItemGroup> <PackageReference Include="Ben.Demystifier" Version="0.4.1" />
<PackageReference Include="bloomtom.HttpProgress" Version="2.3.2" />
<ItemGroup> <PackageReference Include="Dirkster.WatermarkControlsLib" Version="1.1.0" />
<Content Include="README.md"> <PackageReference Include="ini-parser-netstandard" Version="2.5.2" />
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <PackageReference Include="MvvmCross" Version="8.0.2" />
</Content> <PackageReference Include="MvvmCross.Platforms.Wpf" Version="8.0.2" />
<Content Include="COPYING"> <PackageReference Include="MvvmCross.Plugin.Messenger" Version="8.0.2" />
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <PackageReference Include="NinjaNye.SearchExtensions" Version="3.0.1" />
</Content> <PackageReference Include="Serilog" Version="3.1.1" />
<Content Include="CourierPrime-Regular.ttf"> <PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
</Content> <PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
</ItemGroup> <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Squid-Box.SevenZipSharp" Version="1.6.1.23" />
<PackageReference Include="SteamStorefrontAPI" Version="2.0.1.421" />
</ItemGroup>
<ItemGroup>
<Page Include="App.xaml" />
</ItemGroup>
<ItemGroup>
<Content Include="README.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="COPYING">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="resources\CourierPrime-Regular.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="resources\7z.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project> </Project>

Binary file not shown.