final touches

This commit is contained in:
pointfeev 2022-03-03 08:56:44 -05:00
parent 82150b8b95
commit bb3e035804
18 changed files with 67 additions and 32 deletions

View file

@ -1,6 +1,6 @@
using System.Windows.Forms;
namespace CreamInstaller.Forms.Components;
namespace CreamInstaller.Components;
internal class CustomForm : Form
{

View file

@ -2,7 +2,7 @@
using System.Drawing;
using System.Windows.Forms;
namespace CreamInstaller.Forms.Components;
namespace CreamInstaller.Components;
internal class CustomTreeView : TreeView
{

View file

@ -48,8 +48,8 @@
<PackageReference Include="Onova" Version="2.6.2" />
</ItemGroup>
<ItemGroup>
<Compile Update="Forms\MainForm.cs" />
<Compile Update="Forms\SelectForm.cs" />
<Compile Update="MainForm.cs" />
<Compile Update="SelectForm.cs" />
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>

View file

@ -2,7 +2,7 @@
using System.Drawing;
using System.Windows.Forms;
using CreamInstaller.Forms.Components;
using CreamInstaller.Components;
namespace CreamInstaller;

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
@ -13,12 +14,13 @@ namespace CreamInstaller.Epic;
internal static class EpicStore
{
internal static async Task<List<(string id, string name, string product, string icon, string developer)>> ParseDlcAppIds(string categoryNamespace)
internal static async Task<List<(string id, string name, string product, string icon, string developer)>> ParseDlcIds(string categoryNamespace)
{
List<(string id, string name, string product, string icon, string developer)> dlcIds = new();
Response response = await QueryGraphQL(categoryNamespace);
if (response is null)
return dlcIds;
try { File.WriteAllText(ProgramData.AppInfoPath + @$"\{categoryNamespace}.json", JsonConvert.SerializeObject(response, Formatting.Indented)); } catch { }
List<Element> elements = new(response.Data.Catalog.CatalogOffers.Elements);
elements.AddRange(response.Data.Catalog.SearchStore.Elements);
foreach (Element element in elements)

View file

@ -7,7 +7,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CreamInstaller.Forms.Components;
using CreamInstaller.Components;
using CreamInstaller.Resources;
using CreamInstaller.Utility;

View file

@ -2,7 +2,7 @@
using System;
using System.Windows.Forms;
using CreamInstaller.Forms.Components;
using CreamInstaller.Components;
namespace CreamInstaller
{

View file

@ -7,7 +7,7 @@ using System.Threading.Tasks;
using System.Web;
using System.Windows.Forms;
using CreamInstaller.Forms.Components;
using CreamInstaller.Components;
using CreamInstaller.Utility;
using HtmlAgilityPack;

View file

@ -1,7 +1,7 @@

using System.Windows.Forms;
using CreamInstaller.Forms.Components;
using CreamInstaller.Components;
namespace CreamInstaller
{

View file

@ -9,8 +9,8 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using CreamInstaller.Components;
using CreamInstaller.Epic;
using CreamInstaller.Forms.Components;
using CreamInstaller.Paradox;
using CreamInstaller.Resources;
using CreamInstaller.Steam;
@ -262,7 +262,7 @@ internal partial class SelectForm : CustomForm
if (Program.Canceled) return;
ConcurrentDictionary<string, (string name, string product, string icon, string developer)> dlc = new();
List<Task> dlcTasks = new();
List<(string id, string name, string product, string icon, string developer)> dlcIds = await EpicStore.ParseDlcAppIds(@namespace);
List<(string id, string name, string product, string icon, string developer)> dlcIds = await EpicStore.ParseDlcIds(@namespace);
if (dlcIds.Count > 0)
{
foreach ((string id, string name, string product, string icon, string developer) in dlcIds)
@ -384,6 +384,7 @@ internal partial class SelectForm : CustomForm
progressBar.Value = p;
};
await ProgramData.Setup();
if (Directory.Exists(SteamLibrary.InstallPath))
{
progressLabel.Text = $"Setting up SteamCMD . . . ";
@ -573,11 +574,18 @@ internal partial class SelectForm : CustomForm
}
nodeContextMenu.Items.Add(header);
string appInfo = $@"{SteamCMD.AppInfoPath}\{id}.vdf";
if (Directory.Exists(Directory.GetDirectoryRoot(appInfo)) && File.Exists(appInfo))
string appInfoEpic = $@"{SteamCMD.AppInfoPath}\{id}.json";
if (Directory.Exists(Directory.GetDirectoryRoot(appInfo)) && (File.Exists(appInfo) || File.Exists(appInfoEpic)))
{
nodeContextMenu.Items.Add(new ToolStripSeparator());
nodeContextMenu.Items.Add(new ToolStripMenuItem("Open AppInfo", Image("Notepad"),
new EventHandler((sender, e) => Diagnostics.OpenFileInNotepad(appInfo))));
new EventHandler((sender, e) =>
{
if (File.Exists(appInfo))
Diagnostics.OpenFileInNotepad(appInfo);
else
Diagnostics.OpenFileInNotepad(appInfoEpic);
})));
nodeContextMenu.Items.Add(new ToolStripMenuItem("Refresh AppInfo", Image("Command Prompt"),
new EventHandler((sender, e) =>
{
@ -586,6 +594,11 @@ internal partial class SelectForm : CustomForm
File.Delete(appInfo);
}
catch { }
try
{
File.Delete(appInfoEpic);
}
catch { }
OnLoad();
})));
}

View file

@ -8,9 +8,9 @@ using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using CreamInstaller.Resources;
using CreamInstaller.Utility;
using Gameloop.Vdf.Linq;
@ -19,10 +19,10 @@ namespace CreamInstaller.Steam;
internal static class SteamCMD
{
internal static readonly int ProcessLimit = 20;
internal static readonly Version MinimumAppInfoVersion = Version.Parse("2.4.0.0");
internal static readonly string DirectoryPathOld = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\CreamInstaller";
internal static readonly string DirectoryPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\CreamInstaller";
internal static string DirectoryPath => ProgramData.DirectoryPath;
internal static string AppInfoPath => ProgramData.AppInfoPath;
internal static readonly string FilePath = DirectoryPath + @"\steamcmd.exe";
private static readonly int[] locks = new int[ProcessLimit];
@ -67,18 +67,10 @@ internal static class SteamCMD
internal static readonly string ArchivePath = DirectoryPath + @"\steamcmd.zip";
internal static readonly string DllPath = DirectoryPath + @"\steamclient.dll";
internal static readonly string AppInfoPath = DirectoryPath + @"\appinfo";
internal static readonly string AppInfoVersionPath = AppInfoPath + @"\version.txt";
internal static async Task Setup(IProgress<int> progress = null)
{
await Cleanup();
if (Directory.Exists(DirectoryPathOld))
{
if (Directory.Exists(DirectoryPath)) Directory.Delete(DirectoryPath, true);
Directory.Move(DirectoryPathOld, DirectoryPath);
}
if (!Directory.Exists(DirectoryPath)) Directory.CreateDirectory(DirectoryPath);
if (!File.Exists(FilePath))
{
using (HttpClient httpClient = new())
@ -89,12 +81,6 @@ internal static class SteamCMD
ZipFile.ExtractToDirectory(ArchivePath, DirectoryPath);
File.Delete(ArchivePath);
}
if (!File.Exists(AppInfoVersionPath) || !Version.TryParse(File.ReadAllText(AppInfoVersionPath, Encoding.UTF8), out Version version) || version < MinimumAppInfoVersion)
{
if (Directory.Exists(AppInfoPath)) Directory.Delete(AppInfoPath, true);
Directory.CreateDirectory(AppInfoPath);
File.WriteAllText(AppInfoVersionPath, Application.ProductVersion, Encoding.UTF8);
}
if (!File.Exists(DllPath))
{
FileSystemWatcher watcher = new(DirectoryPath);

View file

@ -0,0 +1,34 @@
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CreamInstaller.Utility;
internal static class ProgramData
{
internal static readonly string DirectoryPathOld = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\CreamInstaller";
internal static readonly string DirectoryPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\CreamInstaller";
internal static readonly string AppInfoPath = DirectoryPath + @"\appinfo";
internal static readonly string AppInfoVersionPath = AppInfoPath + @"\version.txt";
internal static readonly Version MinimumAppInfoVersion = Version.Parse("2.4.0.0");
internal static async Task Setup() => await Task.Run(() =>
{
if (Directory.Exists(DirectoryPathOld))
{
if (Directory.Exists(DirectoryPath)) Directory.Delete(DirectoryPath, true);
Directory.Move(DirectoryPathOld, DirectoryPath);
}
if (!Directory.Exists(DirectoryPath)) Directory.CreateDirectory(DirectoryPath);
if (!File.Exists(AppInfoVersionPath) || !Version.TryParse(File.ReadAllText(AppInfoVersionPath, Encoding.UTF8), out Version version) || version < MinimumAppInfoVersion)
{
if (Directory.Exists(AppInfoPath)) Directory.Delete(AppInfoPath, true);
Directory.CreateDirectory(AppInfoPath);
File.WriteAllText(AppInfoVersionPath, Application.ProductVersion, Encoding.UTF8);
}
});
}