Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to download the GameBoy Palettes & Pocket Library Images #251

Merged
merged 5 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 45 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,50 +90,56 @@ Checks for missing required assets for each core you have selected (mainly arcad

```

menu (Default Verb) Interactive Main Menu
-p, --path Absolute path to install location
-s, --skip-update Go straight to the menu, without looking for an update
menu Interactive Main Menu (Default Verb)
-p, --path Absolute path to install location
-s, --skip-update Go straight to the menu, without looking for an update

fund List sponsor links. Lists all if no core is provided
-c, --core The core to check funding links for
fund List sponsor links. Lists all if no core is provided
-c, --core The core to check funding links for

update Run update all. (Can be configured via the settings menu)
-p, --path Absolute path to install location
-c, --core The core you want to update. Runs for all otherwise
-f, --platformsfolder Preserve the Platforms folder, so customizations aren't overwritten by updates.
-r, --clean Clean install. Remove all existing core files, and force a fresh re-install
update Run update all. (Can be configured via the settings menu)
-p, --path Absolute path to install location
-c, --core The core you want to update. Runs for all otherwise
-f, --platformsfolder Preserve the Platforms folder, so customizations aren't overwritten by updates.
-r, --clean Clean install. Remove all existing core files, and force a fresh re-install

uninstall Delete a core
-p, --path Absolute path to install location
-c, --core The core you want to uninstall. Required
-a, --assets Delete the core specific Assets folder. ex: Assets/{platform}/{corename}

assets Run the asset downloader
-p, --path Absolute path to install location
-c, --core The core you want to download assets for.

firmware Check for Pocket firmware updates
-p, --path Absolute path to install location

images Download image packs
-p, --path Absolute path to install location
-o, --owner Image pack repo username
-i, --imagepack Github repo name for image pack
-v, --variant The optional variant

instancegenerator Run the instance JSON generator
-p, --path Absolute path to install location

backup-saves Compress and backup Saves & Memories directories
-p, --path Absolute path to install location
-l, --location Absolute path to backup location. Required
-s, --save Save settings to the config file for use during 'Update All'

update-self Check for updates to pupdate
uninstall Delete a core
-p, --path Absolute path to install location
-c, --core The core you want to uninstall. Required
-a, --assets Delete the core specific Assets folder. ex: Assets/{platform}/{corename}

assets Run the asset downloader
-p, --path Absolute path to install location
-c, --core The core you want to download assets for.

firmware Check for Pocket firmware updates
-p, --path Absolute path to install location

images Download image packs
-p, --path Absolute path to install location
-o, --owner Image pack repo username
-i, --imagepack Github repo name for image pack
-v, --variant The optional variant

instance-generator Run the instance JSON generator for PC Engine CD
-p, --path Absolute path to install location

backup-saves Compress and backup Saves & Memories directories
-p, --path Absolute path to install location
-l, --location Absolute path to backup location. Required
-s, --save Save settings to the config file for use during 'Update All'

gameboy-palettes Run the instance JSON generator
-p, --path Absolute path to install location

pocket-library-images Run the instance JSON generator
-p, --path Absolute path to install location

update-self Check for updates to pupdate

help Display more information on a specific command.
help Display more information on a specific command.

version Display version information.
version Display version information.

```

Expand Down
69 changes: 46 additions & 23 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ private static async Task Main(string[] args)

parser.ParseArguments<MenuOptions, FundOptions, UpdateOptions,
AssetsOptions, FirmwareOptions, ImagesOptions, InstanceGeneratorOptions,
UpdateSelfOptions, UninstallOptions, BackupSavesOptions>(args)
UpdateSelfOptions, UninstallOptions, BackupSavesOptions, GameBoyPalettesOptions,
PocketLibraryImagesOptions>(args)
.WithParsed<UpdateSelfOptions>(_ => { selfUpdate = true; })
.WithParsed<FundOptions>(o =>
{
Expand Down Expand Up @@ -169,6 +170,18 @@ private static async Task Main(string[] args)
backupSaves_Path = o.BackupPath;
backupSaves_SaveConfig = o.Save;
})
.WithParsed<GameBoyPalettesOptions>(o =>
{
verb = "gameboy-palettes";
CLI_MODE = true;
path = o.InstallPath;
})
.WithParsed<PocketLibraryImagesOptions>(o =>
{
verb = "pocket-library-images";
CLI_MODE = true;
path = o.InstallPath;
})
.WithNotParsed(e =>
{
if (e.IsHelp())
Expand Down Expand Up @@ -349,35 +362,45 @@ private static async Task Main(string[] args)

await pack.Install(path);
}
else if (verb == "uninstall")
else switch (verb)
{
if (GlobalHelper.GetCore(coreName) == null)
{
Console.WriteLine("Unknown core");
}
else
{
case "uninstall" when GlobalHelper.GetCore(coreName) == null:
Console.WriteLine($"Unknown core '{coreName}'");
break;

case "uninstall":
coreUpdater.DeleteCore(GlobalHelper.GetCore(coreName), true, nuke);
}
}
else if (verb == "backup-saves")
{
AssetsService.BackupSaves(path, backupSaves_Path);
AssetsService.BackupMemories(path, backupSaves_Path);
break;

if (backupSaves_SaveConfig)
case "backup-saves":
{
var config = GlobalHelper.SettingsManager.GetConfig();
AssetsService.BackupSaves(path, backupSaves_Path);
AssetsService.BackupMemories(path, backupSaves_Path);

if (backupSaves_SaveConfig)
{
var config = GlobalHelper.SettingsManager.GetConfig();

config.backup_saves = true;
config.backup_saves_location = backupSaves_Path;
config.backup_saves = true;
config.backup_saves_location = backupSaves_Path;

GlobalHelper.SettingsManager.SaveSettings();
GlobalHelper.SettingsManager.SaveSettings();
}

break;
}
}
else
{
DisplayMenuNew(path, coreUpdater);

case "gameboy-palettes":
await DownloadGameBoyPalettes(path);
break;

case "pocket-library-images":
await DownloadPockLibraryImages(path);
break;

default:
DisplayMenuNew(path, coreUpdater);
break;
}
}
catch (Exception e)
Expand Down
10 changes: 10 additions & 0 deletions src/options/GameBoyPalettesOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using CommandLine;

namespace Pannella.Options;

[Verb("gameboy-palettes", HelpText = "Downloads and installs the GameBoy Palettes")]
public class GameBoyPalettesOptions
{
[Option('p', "path", HelpText = "Absolute path to install location", Required = false)]
public string InstallPath { get; set; }
}
2 changes: 1 addition & 1 deletion src/options/InstanceGeneratorOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Pannella.Options;

[Verb("instancegenerator", HelpText = "Run the instance JSON generator")]
[Verb("instance-generator", aliases: new[] { "instancegenerator" }, HelpText = "Run the instance JSON generator for PC Engine CD" )]
public class InstanceGeneratorOptions
{
[Option('p', "path", HelpText = "Absolute path to install location", Required = false)]
Expand Down
11 changes: 11 additions & 0 deletions src/options/PocketLibraryImagesOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using CommandLine;

namespace Pannella.Options
{
[Verb("pocket-library-images", HelpText = "Downloads and installs the Pocket Library Images")]
public class PocketLibraryImagesOptions
{
[Option('p', "path", HelpText = "Absolute path to install location", Required = false)]
public string InstallPath { get; set; }
}
}
45 changes: 45 additions & 0 deletions src/partials/Program.GameBoyPalettes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.IO.Compression;
using Pannella.Helpers;
using Pannella.Models.Github;
using Pannella.Services;
using File = System.IO.File;

namespace Pannella;

internal partial class Program
{
private static async Task DownloadGameBoyPalettes(string directory)
{
Release release = await GithubApiService.GetLatestRelease("davewongillies", "openfpga-palettes");
Asset asset = release.assets.FirstOrDefault(a => a.name.EndsWith(".zip"));

if (asset != null)
{
string localFile = Path.Combine(directory, asset.name);
string extractPath = Path.Combine(directory, "temp");

try
{
Console.WriteLine($"Downloading asset '{asset.name}'...");
await HttpHelper.Instance.DownloadFileAsync(asset.browser_download_url, localFile);
Console.WriteLine("Download complete.");
Console.WriteLine("Installing...");

if (Directory.Exists(extractPath))
Directory.Delete(extractPath, true);

ZipFile.ExtractToDirectory(localFile, extractPath);
File.Delete(localFile);
Util.CopyDirectory(extractPath, directory, true, true);

Directory.Delete(extractPath, true);
Console.WriteLine("Complete.");
}
catch (Exception ex)
{
Console.WriteLine("Something happened while trying to install the asset files...");
Console.WriteLine(ex);
}
}
}
}
85 changes: 45 additions & 40 deletions src/partials/Program.HelpText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,54 @@ internal partial class Program
{
private const string HELP_TEXT =
@"Usage:
menu Interactive Main Menu (Default Verb)
-p, --path Absolute path to install location
-s, --skip-update Go straight to the menu, without looking for an update
menu Interactive Main Menu (Default Verb)
-p, --path Absolute path to install location
-s, --skip-update Go straight to the menu, without looking for an update

fund List sponsor links. Lists all if no core is provided
-c, --core The core to check funding links for
fund List sponsor links. Lists all if no core is provided
-c, --core The core to check funding links for

update Run update all. (Can be configured via the settings menu)
-p, --path Absolute path to install location
-c, --core The core you want to update. Runs for all otherwise
-f, --platformsfolder Preserve the Platforms folder, so customizations aren't overwritten by updates.
-r, --clean Clean install. Remove all existing core files, and force a fresh re-install
update Run update all. (Can be configured via the settings menu)
-p, --path Absolute path to install location
-c, --core The core you want to update. Runs for all otherwise
-f, --platformsfolder Preserve the Platforms folder, so customizations aren't overwritten by updates.
-r, --clean Clean install. Remove all existing core files, and force a fresh re-install

uninstall Delete a core
-p, --path Absolute path to install location
-c, --core The core you want to uninstall. Required
-a, --assets Delete the core specific Assets folder. ex: Assets/{platform}/{corename}

assets Run the asset downloader
-p, --path Absolute path to install location
-c, --core The core you want to download assets for.

firmware Check for Pocket firmware updates
-p, --path Absolute path to install location

images Download image packs
-p, --path Absolute path to install location
-o, --owner Image pack repo username
-i, --imagepack Github repo name for image pack
-v, --variant The optional variant

instancegenerator Run the instance JSON generator
-p, --path Absolute path to install location

backup-saves Compress and backup Saves & Memories directories
-p, --path Absolute path to install location
-l, --location Absolute path to backup location. Required
-s, --save Save settings to the config file for use during 'Update All'

update-self Check for updates to pupdate
uninstall Delete a core
-p, --path Absolute path to install location
-c, --core The core you want to uninstall. Required
-a, --assets Delete the core specific Assets folder. ex: Assets/{platform}/{corename}

assets Run the asset downloader
-p, --path Absolute path to install location
-c, --core The core you want to download assets for.

firmware Check for Pocket firmware updates
-p, --path Absolute path to install location

images Download image packs
-p, --path Absolute path to install location
-o, --owner Image pack repo username
-i, --imagepack Github repo name for image pack
-v, --variant The optional variant

instance-generator Run the instance JSON generator for PC Engine CD
-p, --path Absolute path to install location

backup-saves Compress and backup Saves & Memories directories
-p, --path Absolute path to install location
-l, --location Absolute path to backup location. Required
-s, --save Save settings to the config file for use during 'Update All'

gameboy-palettes Run the instance JSON generator
-p, --path Absolute path to install location

pocket-library-images Run the instance JSON generator
-p, --path Absolute path to install location

update-self Check for updates to pupdate

help Display more information on a specific command.
help Display more information on a specific command.

version Display version information.
";
version Display version information.";
}
10 changes: 10 additions & 0 deletions src/partials/Program.Menus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ private static void DisplayMenuNew(string path, PocketCoreUpdater coreUpdater)
{
await ImagePackSelector(path);
})
.Add("Download Pocket Library Images", async _ =>
{
await DownloadPockLibraryImages(path);
Pause();
})
.Add("Download GameBoy Palettes", async _ =>
{
await DownloadGameBoyPalettes(path);
Pause();
})
.Add("Generate Instance JSON Files (PC Engine CD)", () =>
{
RunInstanceGenerator(coreUpdater);
Expand Down
Loading
Loading