- Fixed steam store query caching
- Improved the context menu display for app infos
- Fixed selection form exception handling
This commit is contained in:
pointfeev 2022-03-08 22:41:41 -05:00
parent 509033c8c9
commit 47c99e5e89
4 changed files with 253 additions and 233 deletions

View file

@ -5,7 +5,7 @@
<UseWindowsForms>True</UseWindowsForms> <UseWindowsForms>True</UseWindowsForms>
<ApplicationIcon>Resources\ini.ico</ApplicationIcon> <ApplicationIcon>Resources\ini.ico</ApplicationIcon>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract> <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<Version>3.2.2.2</Version> <Version>3.2.2.3</Version>
<PackageIcon>Resources\ini.ico</PackageIcon> <PackageIcon>Resources\ini.ico</PackageIcon>
<PackageLicenseFile>LICENSE</PackageLicenseFile> <PackageLicenseFile>LICENSE</PackageLicenseFile>
<Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright> <Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright>

View file

@ -32,13 +32,20 @@ internal static class EpicStore
{ {
response = JsonConvert.DeserializeObject<Response>(File.ReadAllText(cacheFile)); response = JsonConvert.DeserializeObject<Response>(File.ReadAllText(cacheFile));
} }
catch { } catch
{
File.Delete(cacheFile);
}
if (response is null) return dlcIds; if (response is null) return dlcIds;
try try
{ {
File.WriteAllText(cacheFile, JsonConvert.SerializeObject(response, Formatting.Indented)); File.WriteAllText(cacheFile, JsonConvert.SerializeObject(response, Formatting.Indented));
} }
catch { } catch //(Exception e)
{
//using DialogForm dialogForm = new(null);
//dialogForm.Show(SystemIcons.Error, "Unsuccessful serialization of query for category namespace " + categoryNamespace + ":\n\n" + e.ToString(), "FUCK");
}
List<Element> searchStore = new(response.Data.Catalog.SearchStore.Elements); List<Element> searchStore = new(response.Data.Catalog.SearchStore.Elements);
foreach (Element element in searchStore) foreach (Element element in searchStore)
{ {

View file

@ -386,9 +386,6 @@ internal partial class SelectForm : CustomForm
} }
private async void OnLoad() private async void OnLoad()
{
retry:
try
{ {
Program.Canceled = false; Program.Canceled = false;
blockedGamesCheckBox.Enabled = false; blockedGamesCheckBox.Enabled = false;
@ -442,12 +439,6 @@ internal partial class SelectForm : CustomForm
blockedGamesCheckBox.Enabled = true; blockedGamesCheckBox.Enabled = true;
blockProtectedHelpButton.Enabled = true; blockProtectedHelpButton.Enabled = true;
} }
catch (Exception e)
{
if (ExceptionHandler.OutputException(e)) goto retry;
Close();
}
}
private void OnTreeViewNodeCheckedChanged(object sender, TreeViewEventArgs e) private void OnTreeViewNodeCheckedChanged(object sender, TreeViewEventArgs e)
{ {
@ -548,6 +539,9 @@ internal partial class SelectForm : CustomForm
} }
private void OnLoad(object sender, EventArgs _) private void OnLoad(object sender, EventArgs _)
{
retry:
try
{ {
HideProgressBar(); HideProgressBar();
selectionTreeView.TreeViewNodeSorter = new TreeNodeSorter(); selectionTreeView.TreeViewNodeSorter = new TreeNodeSorter();
@ -579,16 +573,19 @@ internal partial class SelectForm : CustomForm
string appInfoJSON = $@"{SteamCMD.AppInfoPath}\{id}.json"; string appInfoJSON = $@"{SteamCMD.AppInfoPath}\{id}.json";
if (Directory.Exists(Directory.GetDirectoryRoot(appInfoVDF)) && (File.Exists(appInfoVDF) || File.Exists(appInfoJSON))) if (Directory.Exists(Directory.GetDirectoryRoot(appInfoVDF)) && (File.Exists(appInfoVDF) || File.Exists(appInfoJSON)))
{ {
contextMenuStrip.Items.Add(new ToolStripSeparator()); List<ContextMenuItem> queries = new();
contextMenuStrip.Items.Add(new ContextMenuItem("Open AppInfo", "Notepad",
new EventHandler((sender, e) =>
{
if (File.Exists(appInfoJSON)) if (File.Exists(appInfoJSON))
Diagnostics.OpenFileInNotepad(appInfoJSON); queries.Add(new ContextMenuItem((selection is null || selection.IsSteam) ? "Open Steam Store Query" : "Open Epic GraphQL Query", "Notepad",
else if (File.Exists(appInfoVDF)) new EventHandler((sender, e) => Diagnostics.OpenFileInNotepad(appInfoJSON))));
Diagnostics.OpenFileInNotepad(appInfoVDF); if (File.Exists(appInfoVDF))
}))); queries.Add(new ContextMenuItem("Open SteamCMD Query", "Notepad",
contextMenuStrip.Items.Add(new ContextMenuItem("Refresh AppInfo", "Command Prompt", new EventHandler((sender, e) => Diagnostics.OpenFileInNotepad(appInfoVDF))));
if (queries.Any())
{
contextMenuStrip.Items.Add(new ToolStripSeparator());
foreach (ContextMenuItem query in queries)
contextMenuStrip.Items.Add(query);
contextMenuStrip.Items.Add(new ContextMenuItem("Refresh Queries", "Command Prompt",
new EventHandler((sender, e) => new EventHandler((sender, e) =>
{ {
try try
@ -604,6 +601,7 @@ internal partial class SelectForm : CustomForm
OnLoad(); OnLoad();
}))); })));
} }
}
if (selection is not null) if (selection is not null)
{ {
if (id == "ParadoxLauncher") if (id == "ParadoxLauncher")
@ -729,6 +727,12 @@ internal partial class SelectForm : CustomForm
}; };
OnLoad(); OnLoad();
} }
catch (Exception e)
{
if (ExceptionHandler.OutputException(e)) goto retry;
Close();
}
}
private void OnAccept(bool uninstall = false) private void OnAccept(bool uninstall = false)
{ {

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -44,17 +43,24 @@ internal static class SteamStore
try try
{ {
AppData data = JsonConvert.DeserializeObject<AppDetails>(app.Value.ToString()).data; AppData data = JsonConvert.DeserializeObject<AppDetails>(app.Value.ToString()).data;
if (data is not null)
{
try try
{ {
File.WriteAllText(cacheFile, JsonConvert.SerializeObject(data, Formatting.Indented)); File.WriteAllText(cacheFile, JsonConvert.SerializeObject(data, Formatting.Indented));
} }
catch { } catch //(Exception e)
{
//using DialogForm dialogForm = new(null);
//dialogForm.Show(SystemIcons.Error, "Unsuccessful serialization of query for appid " + appId + ":\n\n" + e.ToString(), "FUCK");
}
return data; return data;
} }
catch (Exception e) }
catch //(Exception e)
{ {
using DialogForm dialogForm = new(null); //using DialogForm dialogForm = new(null);
dialogForm.Show(SystemIcons.Error, "Unsuccessful deserialization of query for appid " + appId + ":\n\n" + e.ToString(), "FUCK"); //dialogForm.Show(SystemIcons.Error, "Unsuccessful deserialization of query for appid " + appId + ":\n\n" + e.ToString(), "FUCK");
} }
} }
} }
@ -65,7 +71,10 @@ internal static class SteamStore
{ {
return JsonConvert.DeserializeObject<AppData>(File.ReadAllText(cacheFile)); return JsonConvert.DeserializeObject<AppData>(File.ReadAllText(cacheFile));
} }
catch { } catch
{
File.Delete(cacheFile);
}
} }
return null; return null;
} }