Added link to forum search

Added status bar
List of DLC is now monospaced
Fixed weird crash with search result window
This commit is contained in:
Jeddunk 2020-12-23 12:34:31 +01:00
parent 56e92924ed
commit 45f86ecc63
11 changed files with 1447 additions and 129 deletions

1236
Annotations/Annotations.cs Normal file

File diff suppressed because it is too large Load Diff

BIN
CourierPrime-Regular.ttf Normal file

Binary file not shown.

View File

@ -13,42 +13,58 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<wcl:WatermarkTextBox x:Name="DllPath" Watermark="Path to game's steam_api(64).dll..." Margin="10,11,55,0" TextWrapping="NoWrap" VerticalAlignment="Top" Padding="0" Grid.Row="0" IsReadOnly="True" IsReadOnlyCaretVisible="True" MouseDoubleClick="DllPath_MouseDoubleClick"/>
<Button x:Name="OpenFile" Content="&#xE1A5;" HorizontalAlignment="Right" Margin="0,10,10,0" VerticalAlignment="Top" FontFamily="Segoe UI Symbol" Width="40" Click="OpenFile_Click" ToolTip="Select DLL file." Grid.Row="0"/>
<Button Content="&#xE1A5;" HorizontalAlignment="Right" Margin="0,10,10,0" VerticalAlignment="Top" FontFamily="Segoe UI Symbol" Width="40" Click="OpenFile_Click" ToolTip="Select DLL file." Grid.Row="0"/>
<wcl:WatermarkTextBox x:Name="Game" Margin="10,10,180,0" Watermark="Game Name" TextWrapping="Wrap" VerticalAlignment="Top" Padding="0" Grid.Row="1"/>
<Button x:Name="Search" Content="&#xE11A;" HorizontalAlignment="Right" Margin="0,9,135,0" VerticalAlignment="Top" FontFamily="Segoe UI Symbol" Width="40" Click="Search_Click" ToolTip="Find AppID." Grid.Row="1"/>
<Button Content="&#xE11A;" HorizontalAlignment="Right" Margin="0,9,135,0" VerticalAlignment="Top" FontFamily="Segoe UI Symbol" Width="40" Click="Search_Click" ToolTip="Find AppID." Grid.Row="1"/>
<wcl:WatermarkTextBox x:Name="AppId" HorizontalAlignment="Right" Margin="0,10,10,0" Watermark="AppID" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Padding="0" Grid.Row="1" KeyUp="AppId_OnTextChanged" />
<ComboBox x:Name="Lang" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="120" Grid.Row="2"/>
<CheckBox x:Name="ForceOffline" Content="Force offline mode" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" ToolTip="offlinemode" Grid.Row="3"/>
<CheckBox x:Name="ExtraProtection" Content="Try to bypass game-specific protection" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" ToolTip="extraprotection" Grid.Row="4"/>
<Grid Margin="10,10,10,0" Grid.Row="5">
<TextBlock Grid.Row="2" Margin="10,10,10,0">
<Hyperlink NavigateUri="https://cs.rin.ru/forum/search.php" RequestNavigate="Hyperlink_RequestNavigate" >Search for cs.rin.ru thread</Hyperlink>
</TextBlock>
<ComboBox x:Name="Lang" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="120" Grid.Row="3"/>
<CheckBox x:Name="ForceOffline" Content="Force offline mode" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" ToolTip="offlinemode" Grid.Row="4"/>
<CheckBox x:Name="ExtraProtection" Content="Try to bypass game-specific protection" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" ToolTip="extraprotection" Grid.Row="5"/>
<Grid Margin="10,10,10,0" Grid.Row="6">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<GroupBox x:Name="DlcGroup" Header="DLC" Grid.Row="0" VerticalAlignment="Stretch">
<GroupBox Header="DLC" Grid.Row="0" VerticalAlignment="Stretch">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<CheckBox x:Name="UnlockAll" Content="Unlock all DLCs (if possible)" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" ToolTip="unlockall"/>
<CheckBox x:Name="SteamDb" Content="Additionally use SteamDB for DLCs" HorizontalAlignment="Left" Margin="10,30,0,0" VerticalAlignment="Top"/>
<wcl:WatermarkTextBox x:Name="ListOfDlcs" Margin="10,55,10,40" Watermark="List of DLCs...&#xA;0000 = DLC Name" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" Padding="0"/>
<Button x:Name="GetListOfDlcs" Content="Get DLCs for AppID" Margin="0,0,10,10" Height="19.96" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="108" Click="GetListOfDlc_Click"/>
<CheckBox x:Name="SteamDb" Content="Additionally use SteamDB for DLCs" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Grid.Row="1"/>
<wcl:WatermarkTextBox x:Name="ListOfDlcs" Margin="10,10,10,0" Watermark="List of DLCs...&#xA;0000 = DLC Name" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" Padding="0" FontFamily="./#Courier Prime" Grid.Row="2"/>
<Button Content="Get DLCs for AppID" Margin="0,10,10,10" Height="19.96" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="108" Click="GetListOfDlc_Click" Grid.Row="3"/>
</Grid>
</GroupBox>
<GroupBox x:Name="StatusGroup" Header="Status" Grid.Row="1" VerticalAlignment="Bottom">
<Grid IsEnabled="False">
<GroupBox Header="Status" Grid.Row="1" VerticalAlignment="Bottom">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<CheckBox x:Name="creamApiApplied" Content="CreamAPI DLL applied" Margin="10,10,0,10" Grid.Column="0" IsEnabled="False"/>
<CheckBox x:Name="configExists" Content="CreamAPI Config exists" Margin="10,10,0,10" Grid.Column="1"/>
<CheckBox x:Name="CreamApiApplied" Content="CreamAPI DLL applied" Margin="10,10,0,10" Grid.Column="0" IsEnabled="False"/>
<CheckBox x:Name="ConfigExists" Content="CreamAPI Config exists" Margin="10,10,0,10" Grid.Column="1" IsEnabled="False"/>
</Grid>
</GroupBox>
</Grid>
<Button x:Name="Save" Content="Save" Margin="0,10,55,10" HorizontalAlignment="Right" Width="40" Height="20" VerticalAlignment="Bottom" Click="Save_Click" Grid.Row="6"/>
<Button x:Name="Reset" Content="Reset" Margin="0,10,10,10" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="40" Click="Reset_Click" Grid.Row="6"/>
<Button Content="Save" Margin="0,10,55,10" HorizontalAlignment="Right" Width="40" Height="20" VerticalAlignment="Bottom" Click="Save_Click" Grid.Row="7"/>
<Button Content="Reset" Margin="0,10,10,10" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="40" Click="Reset_Click" Grid.Row="7"/>
<StatusBar Grid.Row="8">
<StatusBarItem Height="30" Margin="0,0,0,0">
<TextBlock x:Name="Status" Text=""/>
</StatusBarItem>
</StatusBar>
</Grid>
</Window>

View File

@ -1,9 +1,11 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using auto_creamapi.Model;
using auto_creamapi.POCOs;
using auto_creamapi.Utils;
using Microsoft.Win32;
@ -28,6 +30,7 @@ namespace auto_creamapi
_cacheModel.Languages.ForEach(x => Lang.Items.Add(x));
Lang.SelectedItem = DefaultLangSelection;
SteamDb.IsChecked = true;
Status.Text = "Ready.";
}
/// <summary>
@ -40,6 +43,7 @@ namespace auto_creamapi
var app = _cacheModel.GetAppByName(Game.Text);
if (app != null)
{
Game.Text = app.Name;
AppId.Text = app.AppId.ToString();
}
else
@ -67,6 +71,7 @@ namespace auto_creamapi
private void MyOpenFile()
{
Status.Text = "Waiting for file...";
var dialog = new OpenFileDialog
{
Filter = "SteamAPI DLL|steam_api.dll;steam_api64.dll|" +
@ -87,6 +92,7 @@ namespace auto_creamapi
_dllModel.TargetPath = dirPath;
_dllModel.CheckExistence();
CheckExistance();
Status.Text = "Ready.";
}
}
}
@ -98,23 +104,39 @@ namespace auto_creamapi
/// <param name="e"></param>
private async void GetListOfDlc_Click(object sender, RoutedEventArgs e)
{
Status.Text = "Trying to get DLC...";
if (int.TryParse(AppId.Text, out var appId))
{
if (appId > 0)
{
var app = new POCOs.App() {AppId = appId, Name = Game.Text};
var listOfDlc = await _cacheModel.GetListOfDlc(app,
var app = new SteamApp() {AppId = appId, Name = Game.Text};
var task = _cacheModel.GetListOfDlc(app,
SteamDb.IsChecked != null && (bool) SteamDb.IsChecked);
var listOfDlc = await task;
var result = "";
listOfDlc.Sort((app1, app2) => app1.AppId.CompareTo(app2.AppId));
listOfDlc.ForEach(x => result += $"{x.AppId}={x.Name}\n");
ListOfDlcs.Text = result;
if (task.IsCompletedSuccessfully)
{
listOfDlc.Sort((app1, app2) => app1.AppId.CompareTo(app2.AppId));
listOfDlc.ForEach(x => result += $"{x.AppId}={x.Name}\n");
ListOfDlcs.Text = result;
Status.Text = $"Got DLC for AppID {appId}";
}
else
{
Status.Text = $"Could not get DLC for AppID {appId}";
}
}
else
{
Status.Text = $"Could not get DLC for AppID {appId}";
MyLogger.Log.Error($"GetListOfDlc: Invalid AppID {appId}");
}
}
else
{
Status.Text = $"Could not get DLC: Invalid AppID {appId}";
MyLogger.Log.Error($"GetListOfDlc: Invalid AppID {appId}");
}
}
/// <summary>
@ -124,6 +146,7 @@ namespace auto_creamapi
/// <param name="e"></param>
private void Save_Click(object sender, RoutedEventArgs e)
{
Status.Text = "Saving...";
_configModel.SetConfigData(
Convert.ToInt32(AppId.Text),
Lang.SelectedItem.ToString(),
@ -135,6 +158,7 @@ namespace auto_creamapi
_configModel.SaveFile();
_dllModel.Save();
CheckExistance();
Status.Text = "Saving successful.";
}
/// <summary>
@ -144,8 +168,10 @@ namespace auto_creamapi
/// <param name="e"></param>
private void Reset_Click(object sender, RoutedEventArgs e)
{
Status.Text = "Resetting...";
ResetFormData();
CheckExistance();
Status.Text = "Resetting successful.";
}
/// <summary>
@ -171,11 +197,15 @@ namespace auto_creamapi
}
else
{
Game.Text = "";
AppId.Text = "";
MyLogger.Log.Error($"No app found for ID {appId}");
}
}
else
{
Game.Text = "";
AppId.Text = "";
MyLogger.Log.Error($"SetNameById: Invalid AppID {appId}");
}
}
@ -204,9 +234,43 @@ namespace auto_creamapi
private void CheckExistance()
{
CreamApiApplied.IsChecked = _dllModel.CreamApiApplied();
ConfigExists.IsChecked = _configModel.ConfigExists();
}
creamApiApplied.IsChecked = _dllModel.CreamApiApplied();
configExists.IsChecked = _configModel.ConfigExists();
private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
{
// for .NET Core you need to add UseShellExecute = true
// see https://docs.microsoft.com/dotnet/api/system.diagnostics.processstartinfo.useshellexecute#property-value
// UseShellExecute = true;
Status.Text = "Opening URL...";
if (int.TryParse(AppId.Text, out var appId))
{
if (appId > 0)
{
var searchTerm = appId;//$"{Game.Text.Replace(" ", "+")}+{appId}";
var destinationUrl =
"https://cs.rin.ru/forum/search.php?keywords=" +
searchTerm +
"&terms=any&fid[]=10&sf=firstpost&sr=topics&submit=Search";
var uri = new Uri(destinationUrl);
var process = new ProcessStartInfo(uri.AbsoluteUri)
{
UseShellExecute = true
};
Process.Start(process);
}
else
{
MyLogger.Log.Error($"OpenURL: Invalid AppID {appId}");
Status.Text = $"Could not open URL: Invalid AppID {appId}";
}
}
else
{
MyLogger.Log.Error($"OpenURL: Invalid AppID {appId}");
Status.Text = $"Could not open URL: Invalid AppID {appId}";
}
}
}
}

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.Json;
@ -11,7 +10,6 @@ using AngleSharp.Html.Parser;
using auto_creamapi.POCOs;
using auto_creamapi.Utils;
using NinjaNye.SearchExtensions;
using NinjaNye.SearchExtensions.Models;
using SteamStorefrontAPI;
namespace auto_creamapi.Model
@ -23,7 +21,7 @@ namespace auto_creamapi.Model
private const string UserAgent =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " +
"Chrome/87.0.4280.88 Safari/537.36";
private static List<POCOs.App> _cache = new List<POCOs.App>();
private static List<SteamApp> _cache = new List<SteamApp>();
public readonly List<string> Languages = new List<string>(new[]
{
@ -97,7 +95,7 @@ namespace auto_creamapi.Model
MyLogger.Log.Information("Loaded cache into memory!");
}
public EnumerableStringSearch<POCOs.App> GetListOfAppsByName(string name)
public EnumerableStringSearch<SteamApp> GetListOfAppsByName(string name)
{
var listOfAppsByName = _cache.Search(x => x.Name)
.SetCulture(StringComparison.OrdinalIgnoreCase)
@ -105,7 +103,7 @@ namespace auto_creamapi.Model
return listOfAppsByName;
}
public POCOs.App GetAppByName(string name)
public SteamApp GetAppByName(string name)
{
MyLogger.Log.Information($"Trying to get app {name}");
var app = _cache.Find(x => x.Name.ToLower().Equals(name.ToLower()));
@ -113,7 +111,7 @@ namespace auto_creamapi.Model
return app;
}
public POCOs.App GetAppById(int appid)
public SteamApp GetAppById(int appid)
{
MyLogger.Log.Information($"Trying to get app with ID {appid}");
var app = _cache.Find(x => x.AppId.Equals(appid));
@ -121,18 +119,18 @@ namespace auto_creamapi.Model
return app;
}
public async Task<List<POCOs.App>> GetListOfDlc(POCOs.App app, bool useSteamDb)
public async Task<List<SteamApp>> GetListOfDlc(SteamApp steamApp, bool useSteamDb)
{
MyLogger.Log.Information("Get DLC");
var dlcList = new List<POCOs.App>();
if (app != null)
var dlcList = new List<SteamApp>();
if (steamApp != null)
{
var task = AppDetails.GetAsync(app.AppId);
var steamApp = await task;
steamApp?.DLC.ForEach(x =>
var task = AppDetails.GetAsync(steamApp.AppId);
var steamAppDetails = await task;
steamAppDetails?.DLC.ForEach(x =>
{
var result = _cache.Find(y => y.AppId.Equals(x)) ??
new POCOs.App {AppId = x, Name = $"Unknown DLC {x}"};
new SteamApp {AppId = x, Name = $"Unknown DLC {x}"};
dlcList.Add(result);
});
@ -145,7 +143,7 @@ namespace auto_creamapi.Model
// Add missing to DLC list
if (useSteamDb)
{
var steamDbUri = new Uri($"https://steamdb.info/app/{app.AppId}/dlc/");
var steamDbUri = new Uri($"https://steamdb.info/app/{steamApp.AppId}/dlc/");
/* var handler = new ClearanceHandler();
@ -185,7 +183,7 @@ namespace auto_creamapi.Model
dlcName = query3[1].Text().Replace("\n", "").Trim();
}
var dlcApp = new POCOs.App {AppId = Convert.ToInt32(dlcId), Name = dlcName};
var dlcApp = new SteamApp {AppId = Convert.ToInt32(dlcId), Name = dlcName};
var i = dlcList.FindIndex(x => x.CompareId(dlcApp));
if (i > -1)
{
@ -207,7 +205,7 @@ namespace auto_creamapi.Model
}
else
{
MyLogger.Log.Error($"Could not find game: {app}");
MyLogger.Log.Error($"Could not find game: {steamApp}");
}
return dlcList;

View File

@ -9,23 +9,23 @@ using IniParser.Model;
namespace auto_creamapi.Model
{
public class CreamConfig
{
public int AppId { get; set; }
public string Language { get; set; }
public bool UnlockAll { get; set; }
public bool ExtraProtection { get; set; }
public bool ForceOffline { get; set; }
public Dictionary<int, string> DlcList { get; }
public CreamConfig()
{
DlcList = new Dictionary<int, string>();
}
}
public sealed class CreamConfigModel
{
// ReSharper disable once MemberCanBePrivate.Global
public struct CreamConfig
{
public int AppId;
public string Language;
public bool UnlockAll;
public bool ExtraProtection;
public bool ForceOffline;
public Dictionary<int, string> DlcList;
}
private CreamConfig _config;
public CreamConfig Config => _config;
public CreamConfig Config { get; }
private static readonly Lazy<CreamConfigModel> Lazy =
new Lazy<CreamConfigModel>(() => new CreamConfigModel());
@ -38,8 +38,8 @@ namespace auto_creamapi.Model
private CreamConfigModel()
{
_config.DlcList = new Dictionary<int, string>();
SetConfigData();
Config = new CreamConfig();
ResetConfigData();
}
public void ReadFile(string configFilePath)
@ -50,23 +50,23 @@ namespace auto_creamapi.Model
var parser = new FileIniDataParser();
var data = parser.ReadFile(_configFilePath, Encoding.UTF8);
SetConfigData(); // clear previous config data
_config.AppId = Convert.ToInt32(data["steam"]["appid"]);
_config.Language = data["steam"]["language"];
_config.UnlockAll = Convert.ToBoolean(data["steam"]["unlockall"]);
_config.ExtraProtection = Convert.ToBoolean(data["steam"]["extraprotection"]);
_config.ForceOffline = Convert.ToBoolean(data["steam"]["forceoffline"]);
ResetConfigData(); // clear previous config data
Config.AppId = Convert.ToInt32(data["steam"]["appid"]);
Config.Language = data["steam"]["language"];
Config.UnlockAll = Convert.ToBoolean(data["steam"]["unlockall"]);
Config.ExtraProtection = Convert.ToBoolean(data["steam"]["extraprotection"]);
Config.ForceOffline = Convert.ToBoolean(data["steam"]["forceoffline"]);
var dlcCollection = data["dlc"];
foreach (var item in dlcCollection)
{
_config.DlcList.Add(int.Parse(item.KeyName), item.Value);
Config.DlcList.Add(int.Parse(item.KeyName), item.Value);
}
}
else
{
MyLogger.Log.Information($"Config file does not exist @ {configFilePath}, skipping...");
SetConfigData();
ResetConfigData();
}
}
@ -75,14 +75,14 @@ namespace auto_creamapi.Model
var parser = new FileIniDataParser();
var data = new IniData();
data["steam"]["appid"] = _config.AppId.ToString();
data["steam"]["language"] = _config.Language;
data["steam"]["unlockall"] = _config.UnlockAll.ToString();
data["steam"]["extraprotection"] = _config.ExtraProtection.ToString();
data["steam"]["forceoffline"] = _config.ForceOffline.ToString();
data["steam"]["appid"] = Config.AppId.ToString();
data["steam"]["language"] = Config.Language;
data["steam"]["unlockall"] = Config.UnlockAll.ToString();
data["steam"]["extraprotection"] = Config.ExtraProtection.ToString();
data["steam"]["forceoffline"] = Config.ForceOffline.ToString();
data.Sections.AddSection("dlc");
foreach (var (key, value) in _config.DlcList)
foreach (var (key, value) in Config.DlcList)
{
data["dlc"].AddKey(key.ToString(), value);
}
@ -90,14 +90,14 @@ namespace auto_creamapi.Model
parser.WriteFile(_configFilePath, data, Encoding.UTF8);
}
public void SetConfigData()
private void ResetConfigData()
{
_config.AppId = 0;
_config.Language = "";
_config.UnlockAll = false;
_config.ExtraProtection = false;
_config.ForceOffline = false;
_config.DlcList.Clear();
Config.AppId = 0;
Config.Language = "";
Config.UnlockAll = false;
Config.ExtraProtection = false;
Config.ForceOffline = false;
Config.DlcList.Clear();
}
public void SetConfigData(int appId,
@ -107,12 +107,11 @@ namespace auto_creamapi.Model
bool forceOffline,
string dlcList)
{
_config.AppId = appId;
_config.Language = language;
_config.UnlockAll = unlockAll;
_config.ExtraProtection = extraProtection;
_config.ForceOffline = forceOffline;
Config.AppId = appId;
Config.Language = language;
Config.UnlockAll = unlockAll;
Config.ExtraProtection = extraProtection;
Config.ForceOffline = forceOffline;
SetDlcFromString(dlcList);
}
@ -134,7 +133,7 @@ namespace auto_creamapi.Model
private void SetDlcFromString(string dlcList)
{
_config.DlcList.Clear();
Config.DlcList.Clear();
var expression = new Regex(@"(?<id>.*) *= *(?<name>.*)");
using var reader = new StringReader(dlcList);
string line;
@ -143,7 +142,7 @@ namespace auto_creamapi.Model
var match = expression.Match(line);
if (match.Success)
{
_config.DlcList.Add(int.Parse(match.Groups["id"].Value), match.Groups["name"].Value);
Config.DlcList.Add(int.Parse(match.Groups["id"].Value), match.Groups["name"].Value);
}
}
}
@ -157,15 +156,15 @@ namespace auto_creamapi.Model
public override string ToString()
{
var str = $"INI file: {_configFilePath}, " +
$"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)
$"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)
{
foreach (var (key, value) in _config.DlcList)
foreach (var (key, value) in Config.DlcList)
{
str += $" {key}={value},\n";
}

View File

@ -16,28 +16,30 @@ using HttpProgress;
namespace auto_creamapi.Model
{
public class CreamDllModel
internal class CreamDll
{
private struct CreamDll
public readonly string Filename;
public readonly string OrigFilename;
public readonly string Hash;
public CreamDll(string filename, string origFilename)
{
public readonly string Filename;
public readonly string OrigFilename;
public readonly string Hash;
Filename = filename;
OrigFilename = origFilename;
Hash = "";
public CreamDll(string filename, string origFilename)
using var md5 = MD5.Create();
if (File.Exists(Filename))
{
Filename = filename;
OrigFilename = origFilename;
Hash = "";
using var md5 = MD5.Create();
using var stream = File.OpenRead(Filename);
Hash = BitConverter
.ToString(md5.ComputeHash(stream))
.Replace("-", string.Empty);
}
}
}
public class CreamDllModel
{
private static readonly Lazy<CreamDllModel> Lazy =
new Lazy<CreamDllModel>(() => new CreamDllModel());

View File

@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
namespace auto_creamapi.POCOs
{
public class App
public class SteamApp
{
[JsonPropertyName("appid")]
public int AppId { get; set; }
@ -16,21 +16,21 @@ namespace auto_creamapi.POCOs
return $"AppId: {AppId}, Name: {Name}";
}
public bool CompareId(App app)
public bool CompareId(SteamApp steamApp)
{
return AppId.Equals(app.AppId);
return AppId.Equals(steamApp.AppId);
}
}
public class Applist
public class AppList
{
[JsonPropertyName("apps")]
public List<App> Apps { get; set; }
public List<SteamApp> Apps { get; set; }
}
public class SteamApps
{
[JsonPropertyName("applist")]
public Applist AppList { get; set; }
public AppList AppList { get; set; }
}
}

View File

@ -13,7 +13,7 @@
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Content="Select a game..." HorizontalAlignment="Left" Margin="0,0,0,10" VerticalAlignment="Top"/>
<DataGrid Name="DgApps" Grid.Row="1" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single" d:DataContext="{d:DesignInstance poco:App}" MouseDoubleClick="DgApps_OnMouseDoubleClick">
<DataGrid Name="DgApps" Grid.Row="1" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single" d:DataContext="{d:DesignInstance poco:SteamApp}" MouseDoubleClick="DgApps_OnMouseDoubleClick">
<DataGrid.Columns>
<DataGridTextColumn Header="AppID" Binding="{Binding AppId}"></DataGridTextColumn>
<DataGridTextColumn Header="Game Name" Binding="{Binding Name}"></DataGridTextColumn>

View File

@ -11,6 +11,7 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using auto_creamapi.POCOs;
using auto_creamapi.Utils;
using NinjaNye.SearchExtensions;
using NinjaNye.SearchExtensions.Models;
@ -22,7 +23,7 @@ namespace auto_creamapi
/// </summary>
public partial class SearchResultWindow
{
public SearchResultWindow(IEnumerable<POCOs.App> list)
public SearchResultWindow(IEnumerable<SteamApp> list)
{
InitializeComponent();
DgApps.ItemsSource = list;
@ -47,10 +48,13 @@ namespace auto_creamapi
{
if (Application.Current.MainWindow is MainWindow currentMainWindow)
{
var app = (POCOs.App) DgApps.SelectedItem;
MyLogger.Log.Information($"Successfully got app {app}");
currentMainWindow.Game.Text = app.Name;
currentMainWindow.AppId.Text = app.AppId.ToString();
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

@ -22,19 +22,18 @@
<ItemGroup>
<Page Include="App.xaml" />
<Page Remove="ConsoleApp1\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="ConsoleApp1\**" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Remove="ConsoleApp1\**" />
</ItemGroup>
<ItemGroup>
<None Remove="ConsoleApp1\**" />
<Content Include="README.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="COPYING">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="CourierPrime-Regular.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>