From 2f8e7555b50497c77c2d1c5ba5ab385e2c5ca824 Mon Sep 17 00:00:00 2001 From: suchmememanyskill <38142618+suchmememanyskill@users.noreply.github.com> Date: Wed, 12 Jun 2024 21:46:59 +0200 Subject: [PATCH] Split up form classes --- Launcher/Extensions/FormEntryExtensions.cs | 42 +++--- .../Forms/FormTemplates/ButtonList.axaml.cs | 6 +- .../FormTemplates/ClickableLinkBox.axaml.cs | 4 +- .../Forms/FormTemplates/Dropdown.axaml.cs | 2 +- .../Forms/FormTemplates/FilePicker.axaml.cs | 2 +- .../FormTemplates/HorizontalPanel.axaml.cs | 4 +- .../Forms/FormTemplates/ImageView.axaml.cs | 8 +- Launcher/Launcher/CustomBootProfileGUI.cs | 21 ++- LauncherGamePlugin/Forms/Form.cs | 23 +-- LauncherGamePlugin/Forms/FormEntry.cs | 141 +++++++++++++++--- .../Extensions/LegendaryGameForm.cs | 18 +-- .../Service/LegendaryEOSOverlay.cs | 6 +- LocalGames/Gui/AddOrEditGameGui.cs | 18 +-- LocalGames/Gui/AddOrEditGenerationRules.cs | 2 +- SteamGridDbMiddleware/Gui/OnImageEdit.cs | 2 +- 15 files changed, 201 insertions(+), 98 deletions(-) diff --git a/Launcher/Extensions/FormEntryExtensions.cs b/Launcher/Extensions/FormEntryExtensions.cs index 342f80c..6daf775 100644 --- a/Launcher/Extensions/FormEntryExtensions.cs +++ b/Launcher/Extensions/FormEntryExtensions.cs @@ -11,29 +11,29 @@ public static class FormEntryExtensions { public static UserControl ToTemplatedControl(this FormEntry formEntry) { - switch (formEntry.Type) + switch (formEntry) { - case FormEntryType.TextInput: - return new TextInput(formEntry); - case FormEntryType.TextBox: - return new TextBox(formEntry); - case FormEntryType.Toggle: - return new Toggle(formEntry); - case FormEntryType.FilePicker: - case FormEntryType.FolderPicker: + case TextInputElement textInputElement: + return new TextInput(textInputElement); + case TextBoxElement textBoxElement: + return new TextBox(textBoxElement); + case ToggleElement toggleElement: + return new Toggle(toggleElement); + case FilePickerElement: + case FolderPickerElement: return new FilePicker(formEntry); - case FormEntryType.ClickableLinkBox: - return new ClickableLinkBox(formEntry); - case FormEntryType.ButtonList: - return new ButtonList(formEntry); - case FormEntryType.Dropdown: - return new Dropdown(formEntry); - case FormEntryType.Separator: - return new Separator(formEntry); - case FormEntryType.Image: - return new ImageView(formEntry); - case FormEntryType.HorizontalPanel: - return new HorizontalPanel(formEntry); + case ClickableLinkBoxElement clickableLinkBoxElement: + return new ClickableLinkBox(clickableLinkBoxElement); + case ButtonListElement buttonListElement: + return new ButtonList(buttonListElement); + case DropdownElement dropdownElement: + return new Dropdown(dropdownElement); + case SeperatorElement separatorElement: + return new Separator(separatorElement); + case ImageElement imageElement: + return new ImageView(imageElement); + case HorizontalPanelElement horizontalPanelElement: + return new HorizontalPanel(horizontalPanelElement); default: throw new NotImplementedException(); } diff --git a/Launcher/Forms/FormTemplates/ButtonList.axaml.cs b/Launcher/Forms/FormTemplates/ButtonList.axaml.cs index e7b81ba..27b78b1 100644 --- a/Launcher/Forms/FormTemplates/ButtonList.axaml.cs +++ b/Launcher/Forms/FormTemplates/ButtonList.axaml.cs @@ -7,18 +7,18 @@ namespace Launcher.Forms.FormTemplates; public partial class ButtonList : UserControl { - private FormEntry _formEntry; + private ButtonListElement _formEntry; public ButtonList() { InitializeComponent(); } - public ButtonList(FormEntry formEntry) : this() + public ButtonList(ButtonListElement formEntry) : this() { _formEntry = formEntry; - foreach (var x in _formEntry.ButtonList) + foreach (var x in _formEntry.Buttons) { Button b = new(); b.Content = x.Name; diff --git a/Launcher/Forms/FormTemplates/ClickableLinkBox.axaml.cs b/Launcher/Forms/FormTemplates/ClickableLinkBox.axaml.cs index 0981e36..5c98751 100644 --- a/Launcher/Forms/FormTemplates/ClickableLinkBox.axaml.cs +++ b/Launcher/Forms/FormTemplates/ClickableLinkBox.axaml.cs @@ -9,14 +9,14 @@ namespace Launcher.Forms.FormTemplates; public partial class ClickableLinkBox : UserControl { - private FormEntry _formEntry; + private ClickableLinkBoxElement _formEntry; public ClickableLinkBox() { InitializeComponent(); } - public ClickableLinkBox(FormEntry formEntry) : this() + public ClickableLinkBox(ClickableLinkBoxElement formEntry) : this() { _formEntry = formEntry; Button.Content = formEntry.Name; diff --git a/Launcher/Forms/FormTemplates/Dropdown.axaml.cs b/Launcher/Forms/FormTemplates/Dropdown.axaml.cs index e094f39..3ad011d 100644 --- a/Launcher/Forms/FormTemplates/Dropdown.axaml.cs +++ b/Launcher/Forms/FormTemplates/Dropdown.axaml.cs @@ -11,7 +11,7 @@ public Dropdown() InitializeComponent(); } - public Dropdown(FormEntry formEntry) : this() + public Dropdown(DropdownElement formEntry) : this() { ComboBox.ItemsSource = formEntry.DropdownOptions; Label.Content = formEntry.Name; diff --git a/Launcher/Forms/FormTemplates/FilePicker.axaml.cs b/Launcher/Forms/FormTemplates/FilePicker.axaml.cs index 69258bd..ff4979a 100644 --- a/Launcher/Forms/FormTemplates/FilePicker.axaml.cs +++ b/Launcher/Forms/FormTemplates/FilePicker.axaml.cs @@ -34,7 +34,7 @@ private void Update() public async void OnBrowse() { - if (_formEntry.Type == FormEntryType.FilePicker) + if (_formEntry is FilePickerElement) { OpenFileDialog dialog = new(); dialog.AllowMultiple = false; diff --git a/Launcher/Forms/FormTemplates/HorizontalPanel.axaml.cs b/Launcher/Forms/FormTemplates/HorizontalPanel.axaml.cs index d0cf156..1c7cb77 100644 --- a/Launcher/Forms/FormTemplates/HorizontalPanel.axaml.cs +++ b/Launcher/Forms/FormTemplates/HorizontalPanel.axaml.cs @@ -13,12 +13,12 @@ public HorizontalPanel() InitializeComponent(); } - public HorizontalPanel(FormEntry formEntry) : this() + public HorizontalPanel(HorizontalPanelElement formEntry) : this() { Core.HorizontalAlignment = formEntry.Alignment.ToAvaloniaAlignment(); StackPanel.Spacing = int.Parse(formEntry.Value); - foreach (var entry in formEntry.HorizontalPanel) + foreach (var entry in formEntry.Entries) { StackPanel.Children.Add(entry.ToTemplatedControl()); } diff --git a/Launcher/Forms/FormTemplates/ImageView.axaml.cs b/Launcher/Forms/FormTemplates/ImageView.axaml.cs index a51d631..2d5e123 100644 --- a/Launcher/Forms/FormTemplates/ImageView.axaml.cs +++ b/Launcher/Forms/FormTemplates/ImageView.axaml.cs @@ -10,14 +10,14 @@ namespace Launcher.Forms.FormTemplates; public partial class ImageView : UserControl { - private FormEntry _formEntry; + private ImageElement _formEntry; public ImageView() { InitializeComponent(); } - public ImageView(FormEntry formEntry) : this() + public ImageView(ImageElement formEntry) : this() { _formEntry = formEntry; @@ -28,8 +28,8 @@ public ImageView(FormEntry formEntry) : this() else Label.Content = formEntry.Name; - if (formEntry.LinkClick != null) - StackPanel.PointerPressed += (sender, args) => formEntry.LinkClick(formEntry); + if (formEntry.Click != null) + StackPanel.PointerPressed += (sender, args) => formEntry.Click(formEntry); SetImage(); } diff --git a/Launcher/Launcher/CustomBootProfileGUI.cs b/Launcher/Launcher/CustomBootProfileGUI.cs index b268ebd..7fd65c7 100644 --- a/Launcher/Launcher/CustomBootProfileGUI.cs +++ b/Launcher/Launcher/CustomBootProfileGUI.cs @@ -29,16 +29,15 @@ public void CreateProfileForm(string warnMessage = "") List entries = new() { - new(FormEntryType.TextBox, $"{createOrEdit} a custom app wrapper", "Bold", alignment: FormAlignment.Center), - new(FormEntryType.TextInput, "Name:", _profile.Name), - new(FormEntryType.TextInput, "Executable:", _profile.Executable), - new(FormEntryType.TextInput, "Args:", _profile.Args), - new (FormEntryType.TextBox, "Template replaces:\n- {EXEC}: Gets replaced with the executable\n- {ARGS}: Gets replaced with the arguments passed to the executable\n- {WORKDIR}: Gets replaced with the working directory of the executable"), - new(FormEntryType.TextInput, "Environment:", _profile.EnviromentVariables), - new(FormEntryType.Dropdown, "Target Executable:", - _profile.CompatibleExecutable == Platform.Windows ? "Windows" : "Linux", - dropdownOptions: new() {"Windows", "Linux"}), - new (FormEntryType.Toggle, "Escape special characters (Linux only)", _profile.EscapeReplaceables ? "1" : "0"), + Form.TextBox($"{createOrEdit} a custom app wrapper", FormAlignment.Center, "Bold"), + Form.TextInput("Name:", _profile.Name), + Form.TextInput("Executable:", _profile.Executable), + Form.TextInput("Args:", _profile.Args), + Form.TextBox("Template replaces:\n- {EXEC}: Gets replaced with the executable\n- {ARGS}: Gets replaced with the arguments passed to the executable\n- {WORKDIR}: Gets replaced with the working directory of the executable"), + Form.TextInput("Environment:", _profile.EnviromentVariables), + Form.Dropdown("Target Executable:", + dropdownOptions: new() {"Windows", "Linux"}, _profile.CompatibleExecutable == Platform.Windows ? "Windows" : "Linux"), + Form.Toggle("Escape special characters (Linux only)", _profile.EscapeReplaceables), Form.Button("Back", _ => _app.HideForm(), "Save", x => { _app.HideForm(); @@ -47,7 +46,7 @@ public void CreateProfileForm(string warnMessage = "") }; if (warnMessage != "") - entries.Add(new(FormEntryType.TextBox, warnMessage, "Bold", alignment: FormAlignment.Center)); + entries.Add(Form.TextBox(warnMessage, alignment: FormAlignment.Center, "Bold")); _app.ShowForm(new(entries)); } diff --git a/LauncherGamePlugin/Forms/Form.cs b/LauncherGamePlugin/Forms/Form.cs index 177686e..260117b 100644 --- a/LauncherGamePlugin/Forms/Form.cs +++ b/LauncherGamePlugin/Forms/Form.cs @@ -45,30 +45,31 @@ public static Form CreateDismissibleTextPrompt(string text, IApp app) }); } - public static FormEntry TextInput(string label, string value = "") => new(FormEntryType.TextInput, label, value); + public static FormEntry TextInput(string label, string value = "") + => new TextInputElement(label, value); public static FormEntry TextBox(string text, FormAlignment alignment = FormAlignment.Default, string fontWeight = "") - => new(FormEntryType.TextBox, text, fontWeight, alignment: alignment); + => new TextBoxElement(text, fontWeight, alignment: alignment); public static FormEntry ClickableLinkBox(string text, Action
action, FormAlignment alignment = FormAlignment.Default, string fontWeight = "") - => new(FormEntryType.ClickableLinkBox, text, alignment: alignment, linkClick: x => action(x.ContainingForm), value: fontWeight); + => new ClickableLinkBoxElement(text, alignment: alignment, linkClick: x => action(x.ContainingForm), value: fontWeight); public static FormEntry Toggle(string label, bool value, FormAlignment alignment = FormAlignment.Default, bool enabled = true) - => new(FormEntryType.Toggle, label, value ? "1" : "0", alignment: alignment, enabled: enabled); + => new ToggleElement(label, value ? "1" : "0", alignment: alignment, enabled: enabled); public static FormEntry FilePicker(string label, string value = "") - => new(FormEntryType.FilePicker, label, value); + => new FilePickerElement(label, value); public static FormEntry FolderPicker(string label, string value = "") - => new(FormEntryType.FolderPicker, label, value); + => new FolderPickerElement(label, value); public static FormEntry Dropdown(string label, List dropdownOptions, string value = "") - => new(FormEntryType.Dropdown, label, value, dropdownOptions: dropdownOptions); + => new DropdownElement(label, value, dropdownOptions: dropdownOptions); public static FormEntry ButtonList(List buttons, FormAlignment alignment = FormAlignment.Default) - => new(FormEntryType.ButtonList, buttonList: buttons, alignment: alignment); + => new ButtonListElement(buttons: buttons, alignment: alignment); public static FormEntry Button(string label, Action action, FormAlignment alignment = FormAlignment.Default) => ButtonList(new() {new(label, action)}, alignment); @@ -80,13 +81,13 @@ public static FormEntry Button(string label1, Action action1, string label => ButtonList(new() {new(label1, action1), new(label2, action2), new(label3, action3)}, alignment); public static FormEntry Image(string label, Func> image, Action? onClick = null, FormAlignment alignment = FormAlignment.Default) - => new(FormEntryType.Image, label, image: image, alignment: alignment, linkClick: x => onClick?.Invoke(x.ContainingForm)); + => new ImageElement(label, getImage: image, alignment: alignment, click: x => onClick?.Invoke(x.ContainingForm)); public static FormEntry Horizontal(List entries, int spacing = 5, FormAlignment alignment = FormAlignment.Default) - => new(FormEntryType.HorizontalPanel, horizontalPanel: entries, value: spacing.ToString(), alignment: alignment); + => new HorizontalPanelElement(entries: entries, value: spacing.ToString(), alignment: alignment); public static FormEntry Separator(int height = 1) - => new(FormEntryType.Separator, value: height.ToString()); + => new SeperatorElement(value: height.ToString()); } public static class FormExtensions diff --git a/LauncherGamePlugin/Forms/FormEntry.cs b/LauncherGamePlugin/Forms/FormEntry.cs index 5199daa..5b6bf66 100644 --- a/LauncherGamePlugin/Forms/FormEntry.cs +++ b/LauncherGamePlugin/Forms/FormEntry.cs @@ -35,37 +35,140 @@ public ButtonEntry(string name, Action action) } } -public class FormEntry +public class TextInputElement : FormEntry +{ + public TextInputElement(string name = "", string value = "", FormAlignment alignment = FormAlignment.Default, + bool enabled = true) : base(name, value, alignment, enabled) + { + + } +} + +public class TextBoxElement : FormEntry +{ + public TextBoxElement(string name = "", string fontWeight = "", FormAlignment alignment = FormAlignment.Default, + bool enabled = true) : base(name, fontWeight, alignment, enabled) + { + + } +} + +public class ClickableLinkBoxElement : FormEntry +{ + public Action LinkClick { get; set; } + + public ClickableLinkBoxElement(string name = "", string value = "", Action linkClick = null, FormAlignment alignment = FormAlignment.Default, + bool enabled = true) + : base(name, value, alignment, enabled) + { + LinkClick = linkClick; + } +} + +public class ToggleElement : FormEntry +{ + public ToggleElement(string name = "", string value = "", FormAlignment alignment = FormAlignment.Default, + bool enabled = true) : base(name, value, alignment, enabled) + { + + } +} + +public class FilePickerElement : FormEntry +{ + public FilePickerElement(string name = "", string value = "", FormAlignment alignment = FormAlignment.Default, + bool enabled = true) : base(name, value, alignment, enabled) + { + + } +} + +public class FolderPickerElement : FormEntry +{ + public FolderPickerElement(string name = "", string value = "", FormAlignment alignment = FormAlignment.Default, + bool enabled = true) : base(name, value, alignment, enabled) + { + + } +} + +public class DropdownElement : FormEntry +{ + public List DropdownOptions { get; set; } + + public DropdownElement(string name = "", string value = "", List dropdownOptions = null, FormAlignment alignment = FormAlignment.Default, + bool enabled = true) + : base(name, value, alignment, enabled) + { + DropdownOptions = dropdownOptions ?? new(); + } +} + +public class ButtonListElement : FormEntry +{ + public List Buttons { get; set; } + + public ButtonListElement(List buttons = null, FormAlignment alignment = FormAlignment.Default, + bool enabled = true) + : base(null, null, alignment, enabled) + { + Buttons = buttons ?? new(); + + if (Alignment == FormAlignment.Default) + Alignment = FormAlignment.Center; + } +} + +public class SeperatorElement : FormEntry +{ + public SeperatorElement(string name = "", string value = "", FormAlignment alignment = FormAlignment.Default, + bool enabled = true) : base(name, value, alignment, enabled) + { + + } +} + +public class ImageElement : FormEntry +{ + public Func> GetImage { get; set; } + public Action Click { get; set; } + + public ImageElement(string name = "", string value = "", Func> getImage = null, Action click = null, FormAlignment alignment = FormAlignment.Default, + bool enabled = true) + : base(name, value, alignment, enabled) + { + GetImage = getImage; + Click = click; + } +} + +public class HorizontalPanelElement : FormEntry +{ + public List Entries { get; set; } + + public HorizontalPanelElement(string name = "", string value = "", List entries = null, FormAlignment alignment = FormAlignment.Default, + bool enabled = true) + : base(name, value, alignment, enabled) + { + Entries = entries ?? new(); + } +} + +public abstract class FormEntry { public string Name { get; set; } public string Value { get; set; } public bool Enabled { get; set; } - public FormEntryType Type { get; set; } - public Action LinkClick { get; set; } - public List DropdownOptions { get; set; } - public List ButtonList { get; set; } public Form ContainingForm { get; set; } - public Func> GetImage { get; set; } - public List HorizontalPanel { get; set; } public FormAlignment Alignment; public event Action? OnChange; public void InvokeOnChange() => OnChange?.Invoke(this); - - public FormEntry(FormEntryType type, string name = "", string value = "", List dropdownOptions = null, - List buttonList = null, Action linkClick = null, Func> image = null, List horizontalPanel = null, FormAlignment alignment = FormAlignment.Default, bool enabled = true) + + public FormEntry(string name = "", string value = "", FormAlignment alignment = FormAlignment.Default, bool enabled = true) { - Type = type; Name = name; Value = value; Enabled = enabled; - DropdownOptions = dropdownOptions; - ButtonList = buttonList; - LinkClick = linkClick; Alignment = alignment; - GetImage = image; - HorizontalPanel = horizontalPanel; - - if (Type == FormEntryType.ButtonList && Alignment == FormAlignment.Default) - Alignment = FormAlignment.Center; } } \ No newline at end of file diff --git a/LegendaryIntegration/Extensions/LegendaryGameForm.cs b/LegendaryIntegration/Extensions/LegendaryGameForm.cs index 9d12b21..5f922ea 100644 --- a/LegendaryIntegration/Extensions/LegendaryGameForm.cs +++ b/LegendaryIntegration/Extensions/LegendaryGameForm.cs @@ -13,15 +13,15 @@ public static class LegendaryGameForm Form f = new(new() { - new FormEntry(FormEntryType.TextBox, "Legendary game configuration and info", "Bold", alignment: FormAlignment.Center), - new FormEntry(FormEntryType.TextBox, $"{game.Name} by {game.Developer}"), - new FormEntry(FormEntryType.TextBox, $"AppId: {game.InternalName}"), - new FormEntry(FormEntryType.TextBox, $"Current Version: {game.InstalledVersion}"), - new FormEntry(FormEntryType.ClickableLinkBox, $"Location on disk: {game.InstallPath}", linkClick: x => Utils.OpenFolder(game.InstallPath)), - new FormEntry(FormEntryType.TextBox, "\nConfig", "Bold", alignment: FormAlignment.Center), - new FormEntry(FormEntryType.Toggle, "Always launch offline", game.ConfigAlwaysOffline ? "1" : "0"), - new FormEntry(FormEntryType.Toggle, "Always skip version check", game.ConfigAlwaysSkipUpdateCheck ? "1" : "0"), - new FormEntry(FormEntryType.TextInput, "Additional game arguments", game.ConfigAdditionalGameArgs), + Form.TextBox("Legendary game configuration and info", FormAlignment.Center, "Bold"), + Form.TextBox($"{game.Name} by {game.Developer}"), + Form.TextBox($"AppId: {game.InternalName}"), + Form.TextBox($"Current Version: {game.InstalledVersion}"), + Form.ClickableLinkBox($"Location on disk: {game.InstallPath}", _ => Utils.OpenFolder(game.InstallPath)), + Form.TextBox("\nConfig", FormAlignment.Center, "Bold"), + Form.Toggle("Always launch offline", game.ConfigAlwaysOffline), + Form.Toggle("Always skip version check", game.ConfigAlwaysSkipUpdateCheck), + Form.TextInput("Additional game arguments", game.ConfigAdditionalGameArgs), Form.Button("Back", _ => LegendaryGameSource.Source.App.HideForm(), "Save", x => { diff --git a/LegendaryIntegration/Service/LegendaryEOSOverlay.cs b/LegendaryIntegration/Service/LegendaryEOSOverlay.cs index dd675b0..e9e51fa 100644 --- a/LegendaryIntegration/Service/LegendaryEOSOverlay.cs +++ b/LegendaryIntegration/Service/LegendaryEOSOverlay.cs @@ -17,7 +17,7 @@ public async void OpenGUI() installed = File.Exists(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config", "legendary", "overlay_install.json")); List entries = new() - {new(FormEntryType.TextBox, "EOS Overlay", "Bold", alignment: FormAlignment.Center)}; + {Form.TextBox("EOS Overlay", alignment: FormAlignment.Center, "Bold")}; if (installed) { @@ -26,7 +26,7 @@ public async void OpenGUI() if (t.ExitCode == 0) { - entries.Add(new(FormEntryType.TextBox, string.Join("\n", t.StdErr))); + entries.Add(Form.TextBox(string.Join("\n", t.StdErr))); } } @@ -46,7 +46,7 @@ public async void OpenGUI() buttons.Add(new("Install Overlay", x => Install())); } - entries.Add(new(FormEntryType.ButtonList, buttonList: buttons)); + entries.Add(Form.ButtonList(buttons: buttons)); _app.ShowForm(new(entries)); } diff --git a/LocalGames/Gui/AddOrEditGameGui.cs b/LocalGames/Gui/AddOrEditGameGui.cs index 6a7713a..1636377 100644 --- a/LocalGames/Gui/AddOrEditGameGui.cs +++ b/LocalGames/Gui/AddOrEditGameGui.cs @@ -44,14 +44,14 @@ public void ShowGui(string possibleWarn = "", string gameName = "", string execP List entries = new() { - new FormEntry(FormEntryType.TextBox, $"{addOrEdit} a local game", "Bold"), - new FormEntry(FormEntryType.TextInput, "Game name:", gameName), - new FormEntry(FormEntryType.FilePicker, "Game executable:", execPath), - new FormEntry(FormEntryType.TextBox, "\nOptional", "Bold"), - new FormEntry(FormEntryType.FolderPicker, "Working Directory:", workingDirectory), - new FormEntry(FormEntryType.FilePicker, "Cover Image:", coverImage), - new FormEntry(FormEntryType.FilePicker, "Background Image:", backgroundImage), - new FormEntry(FormEntryType.TextInput, "CLI Arguments:", args), + Form.TextBox($"{addOrEdit} a local game", fontWeight: "Bold"), + Form.TextInput("Game name:", gameName), + Form.FilePicker("Game executable:", execPath), + Form.TextBox("\nOptional", fontWeight: "Bold"), + Form.FolderPicker("Working Directory:", workingDirectory), + Form.FilePicker("Cover Image:", coverImage), + Form.FilePicker("Background Image:", backgroundImage), + Form.TextInput("CLI Arguments:", args), Form.Button("Cancel", _ => _app.HideForm(), addOrEdit, entry => { new Thread(() => AddGame(entry)).Start(); @@ -59,7 +59,7 @@ public void ShowGui(string possibleWarn = "", string gameName = "", string execP }; if (possibleWarn != "") - entries.Add(new(FormEntryType.TextBox, possibleWarn, "Bold")); + entries.Add(Form.TextBox(possibleWarn, fontWeight: "Bold")); Form form = new(entries); if (game != null) diff --git a/LocalGames/Gui/AddOrEditGenerationRules.cs b/LocalGames/Gui/AddOrEditGenerationRules.cs index b6b2993..2bad217 100644 --- a/LocalGames/Gui/AddOrEditGenerationRules.cs +++ b/LocalGames/Gui/AddOrEditGenerationRules.cs @@ -66,7 +66,7 @@ public void ShowGui(string name = "", List? extensions = null, string lo if (rules != null) { - elements.Last().ButtonList.Add(new($"Delete {name}", _ => Delete(rules))); + (elements.Last() as ButtonListElement)!.Buttons.Add(new($"Delete {name}", _ => Delete(rules))); } if (errMessage != "") diff --git a/SteamGridDbMiddleware/Gui/OnImageEdit.cs b/SteamGridDbMiddleware/Gui/OnImageEdit.cs index bd89ef5..80320a6 100644 --- a/SteamGridDbMiddleware/Gui/OnImageEdit.cs +++ b/SteamGridDbMiddleware/Gui/OnImageEdit.cs @@ -55,7 +55,7 @@ public async void ShowGui() form.Add(Form.Button("Back", _ => Hide(), "Change search term", _ => NewSearchTerm(), $"Remove current {Type}", _ => Clear())); if (Instance.Storage.Data.GetOverride(Game, Type) == null) - form.Last().ButtonList.Last().Action = null; + (form.Last() as ButtonListElement)!.Buttons.Last().Action = null; List> imageGroups = Enumerable.Range(0, (overrides.Count / _perRow)) .Select(x => overrides.Skip(x * _perRow).Take(_perRow).ToList()).ToList();