diff --git a/RemoteDownloaderPlugin/Gui/AddOrEditEmuProfileGui.cs b/RemoteDownloaderPlugin/Gui/AddOrEditEmuProfileGui.cs index 6ef8893..d8eee78 100644 --- a/RemoteDownloaderPlugin/Gui/AddOrEditEmuProfileGui.cs +++ b/RemoteDownloaderPlugin/Gui/AddOrEditEmuProfileGui.cs @@ -46,8 +46,35 @@ public void ShowGui() Form.FilePicker("Executable Path:", _path), Form.TextInput("CLI Args:", _args), Form.FolderPicker("Working Directory:", _workDir), - Form.Button("Cancel", _ => _app.HideForm(), "Save", Process) + }; + + if (_addOrUpdate) + { + formEntries.Add(Form.Button( "Remove", _ => { + EmuProfile? existingProfile = _instance.Storage.Data.EmuProfiles.FirstOrDefault(x => x.Platform == _platform); + + if (existingProfile == null) + { + return; + } + + _app.Show2ButtonTextPrompt($"Do you want to remove platform {existingProfile.Platform}?", "No", "Yes", + _ => _app.HideForm(), + _ => + { + _instance.Storage.Data.EmuProfiles.Remove(existingProfile); + _instance.Storage.Save(); + _app.ReloadGlobalCommands(); + _app.HideForm(); + }); + }, + "Cancel", _ => _app.HideForm(), "Save", Process)); + } + else + { + formEntries.Add(Form.Button("Cancel", _ => _app.HideForm(), "Save", Process)); + } if (!string.IsNullOrWhiteSpace(_error)) formEntries.Add(Form.TextBox(_error, fontWeight: "Bold")); diff --git a/RemoteDownloaderPlugin/Plugin.cs b/RemoteDownloaderPlugin/Plugin.cs index 1c6313e..fa52267 100644 --- a/RemoteDownloaderPlugin/Plugin.cs +++ b/RemoteDownloaderPlugin/Plugin.cs @@ -131,23 +131,14 @@ public List GetGlobalCommands() new Command("Reload", Reload), new Command(), new Command("Edit Index URL", () => new SettingsRemoteIndexGui(App, this).ShowGui()), - new Command("Add Emulation Profile", () => new AddOrEditEmuProfileGui(App, this).ShowGui()), - new Command("Edit Emulation Profile", + new Command("Emulation Profiles", Storage.Data.EmuProfiles.Select( - x => new Command($"Edit {x.Platform}", new AddOrEditEmuProfileGui(App, this, x).ShowGui)).ToList()), - new Command("Delete Emulation Profile", - Storage.Data.EmuProfiles.Select( - x => new Command($"Delete {x.Platform}", () => + x => new Command($"Edit {x.Platform}", new AddOrEditEmuProfileGui(App, this, x).ShowGui)) + .Concat(new List() { - App.Show2ButtonTextPrompt($"Do you want to remove platform {x.Platform}?", "Yes", "No", - _ => - { - Storage.Data.EmuProfiles.Remove(x); - Storage.Save(); - App.ReloadGlobalCommands(); - App.HideForm(); - }, _ => App.HideForm()); - })).ToList()), + new(), + new Command("Add Emulation Profile", () => new AddOrEditEmuProfileGui(App, this).ShowGui()), + }).ToList()), new Command("Hide Platforms", _platforms.Select(x => new Command(Storage.Data.HiddenRemotePlatforms.Contains(x) ? $"Show {x}" : $"Hide {x}", () => {