Skip to content

Commit

Permalink
v1.5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
RetroDriven committed Nov 9, 2023
1 parent 3776ed1 commit 1e3b9fe
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 21 deletions.
14 changes: 7 additions & 7 deletions Forms/Main/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Forms/Main/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Pocket_Updater
{
public partial class Form1 : Form
{
private const string VERSION = "1.5.7";
private const string VERSION = "1.5.8";
private const string API_URL = "https://api.github.com/repos/RetroDriven/Pocket_Updater/releases";
private const string RELEASE_URL = "https://github.com/RetroDriven/Pocket_Updater/releases/latest";

Expand Down
6 changes: 6 additions & 0 deletions Lib/Updater/helpers/GlobalHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class GlobalHelper
public string SettingsPath { get; set; }
public string[] Blacklist { get; set; }
public List<Core>? Cores { get; set; }
public List<Core>? InstalledCores { get; set; }

private GlobalHelper()
{
Expand All @@ -33,4 +34,9 @@ public static GlobalHelper Instance
}
}
}

public Core? GetCore(string identifier)
{
return instance.Cores.Find(i => i.identifier == identifier);
}
}
8 changes: 8 additions & 0 deletions Lib/Updater/models/Analogue/AnalogueFramework.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Analogue;

public class Framework
{
public string target_product { get; set; }
public string version_required { get; set; }
public bool sleep_supported { get; set; }
}
3 changes: 1 addition & 2 deletions Pocket_Updater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Version>1.5.7</Version>
<Version>1.5.8</Version>
<RootNamespace>Pocket_Updater</RootNamespace>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
Expand Down Expand Up @@ -58,5 +58,4 @@
<PackageReference Include="Guna.UI2.WinForms" Version="2.0.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions lib/Updater/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public SettingsManager(string settingsPath, List<Core>? cores = null)
_settingsFile = file;

if(cores != null) {
_initializeCoreSettings(cores);
InitializeCoreSettings(cores);
}

SaveSettings();
}

//loop through every core, and add any missing ones to the settings file
private void _initializeCoreSettings(List<Core> cores)
public void InitializeCoreSettings(List<Core> cores)
{
if(_settings.coreSettings == null) {
_settings.coreSettings = new Dictionary<string,CoreSettings>();
Expand Down
20 changes: 20 additions & 0 deletions lib/Updater/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class PocketCoreUpdater : Base
private bool _deleteSkippedCores = true;
private bool _useConsole = false;
private bool _renameJotegoCores = true;
private bool _jtBeta = false;

private Dictionary<string, string> _platformFiles = new Dictionary<string, string>();

Expand All @@ -51,10 +52,22 @@ public async Task Initialize()
LoadSettings();
await LoadPlatformFiles();
await LoadCores();
await RefreshInstalledCores();
await LoadArchive();
await LoadBlacklist();
}

private async Task RefreshInstalledCores()
{
var installedCores = new List<Core>();
foreach(Core c in GlobalHelper.Instance.Cores) {
if(c.isInstalled()) {
installedCores.Add(c);
}
}
GlobalHelper.Instance.InstalledCores = installedCores;
}

private async Task LoadPlatformFiles()
{
try {
Expand Down Expand Up @@ -97,6 +110,7 @@ private async Task LoadBlacklist()
public async Task LoadCores()
{
Factory.GetGlobals().Cores = await CoresService.GetCores();
Factory.GetGlobals().SettingsManager.InitializeCoreSettings(Factory.GetGlobals().Cores);
foreach(Core core in Factory.GetGlobals().Cores) {
core.StatusUpdated += updater_StatusUpdated; //attach handler to bubble event up
}
Expand Down Expand Up @@ -215,6 +229,10 @@ public async Task RunUpdates(string? id = null)
_DeleteCore(core);
continue;
}

if (core.requires_license && !_jtBeta) {
continue; //skip if you don't have the key
}

string name = core.identifier;
if(name == null) {
Expand Down Expand Up @@ -326,6 +344,7 @@ private async Task ExtractBetaKey()
string keyPath = Path.Combine(Factory.GetGlobals().UpdateDirectory, "betakeys");
string file = Path.Combine(Factory.GetGlobals().UpdateDirectory, "jtbeta.zip");
if(File.Exists(file)) {
_jtBeta = true;
_writeMessage("Extracting JT beta key...");
ZipFile.ExtractToDirectory(file, keyPath, true);
}
Expand Down Expand Up @@ -433,6 +452,7 @@ protected virtual void OnUpdateProcessComplete(UpdateProcessCompleteEventArgs e)
{
handler(this, e);
}
RefreshInstalledCores();
}

public async Task<string> UpdateFirmware()
Expand Down
2 changes: 2 additions & 0 deletions lib/Updater/models/Analogue/AnalogueCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ public class Core
{
public Metadata? metadata { get; set; }
public string? magic { get; set; }

public Framework? framework { get; set; }

}
30 changes: 21 additions & 9 deletions lib/Updater/models/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class Core : Base
public string? date_release { get; set; }
public string? version { get; set; }

public bool requires_license { get; set; } = false;

private const string ZIP_FILE_NAME = "core.zip";
public bool downloadAssets { get; set; } = Factory.GetGlobals().SettingsManager.GetConfig().download_assets;
public bool buildInstances { get; set; } = Factory.GetGlobals().SettingsManager.GetConfig().build_instance_jsons;
Expand Down Expand Up @@ -114,7 +116,7 @@ public void Uninstall()
return p["platform"];
}

public bool UpdatePlatform(string title)
public bool UpdatePlatform(string title, string category = null)
{
var config = this.getConfig();
if (config == null)
Expand All @@ -133,13 +135,23 @@ public bool UpdatePlatform(string title)
return false;
}

Dictionary<string, Platform> platform = new Dictionary<string, Platform>();
this.platform.name = title;
platform.Add("platform", this.platform);
string json = JsonSerializer.Serialize(platform);
if (platform.name != title || platform.category != category)
{

Dictionary<string, Platform> platform = new Dictionary<string, Platform>();
this.platform.name = title;
if (category != null)
{
this.platform.category = category;
}
platform.Add("platform", this.platform);
string json = JsonSerializer.Serialize(platform);

File.WriteAllText(dataFile, json);
Factory.GetGlobals().SettingsManager.GetConfig().preserve_platforms_folder = true;
Factory.GetGlobals().SettingsManager.SaveSettings();
}

File.WriteAllText(dataFile, json);

return true;
}

Expand Down Expand Up @@ -167,7 +179,7 @@ public async Task<Dictionary<string, List<string>>> DownloadAssets()
Analogue.DataJSON data = ReadDataJSON();
if(data.data.data_slots.Length > 0) {
foreach(Analogue.DataSlot slot in data.data.data_slots) {
if(slot.filename != null && !Factory.GetGlobals().Blacklist.Contains(slot.filename)) {
if(slot.filename != null && !slot.filename.EndsWith(".sav") && !Factory.GetGlobals().Blacklist.Contains(slot.filename)) {
string path = Path.Combine(UpdateDirectory, "Assets", info.metadata.platform_ids[0]);
if(slot.isCoreSpecific()) {
path = Path.Combine(path, this.identifier);
Expand Down Expand Up @@ -225,7 +237,7 @@ public async Task<Dictionary<string, List<string>>> DownloadAssets()
if(instance.instance.data_slots.Length > 0) {
string data_path = instance.instance.data_path;
foreach(Analogue.DataSlot slot in instance.instance.data_slots) {
if(!Factory.GetGlobals().Blacklist.Contains(slot.filename)) {
if(!Factory.GetGlobals().Blacklist.Contains(slot.filename) && !slot.filename.EndsWith(".sav")) {
string path = Path.Combine(UpdateDirectory, "Assets", info.metadata.platform_ids[0], "common", data_path, slot.filename);
if(File.Exists(path) && CheckCRC(path)) {
_writeMessage("Already installed: " + slot.filename);
Expand Down

0 comments on commit 1e3b9fe

Please sign in to comment.