Skip to content

Commit

Permalink
Remote: Improve Emulation Profile UX
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Jun 9, 2024
1 parent 6dc5e86 commit 0cfbd15
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
29 changes: 28 additions & 1 deletion RemoteDownloaderPlugin/Gui/AddOrEditEmuProfileGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
21 changes: 6 additions & 15 deletions RemoteDownloaderPlugin/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,14 @@ public List<Command> 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<Command>()
{
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}", () =>
{
Expand Down

0 comments on commit 0cfbd15

Please sign in to comment.