From 2468d6d81244944b74cb2a52d5922b950d0addd4 Mon Sep 17 00:00:00 2001 From: amazingalek Date: Mon, 3 Feb 2020 21:20:26 +0100 Subject: [PATCH] Mods menu (#67) * mods menu * mod config UI * menu controller support --- OWML.Common/IModConfig.cs | 13 +- OWML.Common/IModData.cs | 3 + OWML.Common/Menus/IModButton.cs | 2 + OWML.Common/Menus/IModConfigMenu.cs | 10 + OWML.Common/Menus/IModInput.cs | 17 ++ OWML.Common/Menus/IModInputMenu.cs | 12 + OWML.Common/Menus/IModMenu.cs | 31 ++- OWML.Common/Menus/IModMenus.cs | 2 + OWML.Common/Menus/IModNumberInput.cs | 8 + OWML.Common/Menus/IModPopupMenu.cs | 2 + OWML.Common/Menus/IModSliderInput.cs | 11 + OWML.Common/Menus/IModTabMenu.cs | 4 + OWML.Common/Menus/IModTabbedMenu.cs | 1 + OWML.Common/Menus/IModTextInput.cs | 8 + OWML.Common/Menus/IModToggleInput.cs | 11 + OWML.Common/Menus/IModsMenu.cs | 10 + OWML.Common/Menus/InputType.cs | 9 + OWML.Common/OWML.Common.csproj | 9 + OWML.Launcher/App.cs | 2 +- OWML.ModHelper.Menus/ModButton.cs | 14 +- OWML.ModHelper.Menus/ModConfigMenu.cs | 210 ++++++++++++++++++ OWML.ModHelper.Menus/ModInput.cs | 62 ++++++ OWML.ModHelper.Menus/ModInputField.cs | 35 +++ OWML.ModHelper.Menus/ModInputMenu.cs | 94 ++++++++ OWML.ModHelper.Menus/ModMainMenu.cs | 5 +- OWML.ModHelper.Menus/ModMenu.cs | 199 ++++++++++++++++- OWML.ModHelper.Menus/ModMenus.cs | 16 +- OWML.ModHelper.Menus/ModNumberInput.cs | 60 +++++ OWML.ModHelper.Menus/ModOptionsMenu.cs | 62 ++++-- OWML.ModHelper.Menus/ModPopupMenu.cs | 7 +- OWML.ModHelper.Menus/ModSliderInput.cs | 51 +++++ OWML.ModHelper.Menus/ModTabMenu.cs | 35 ++- OWML.ModHelper.Menus/ModTextInput.cs | 59 +++++ OWML.ModHelper.Menus/ModToggleInput.cs | 49 ++++ OWML.ModHelper.Menus/ModsMenu.cs | 104 +++++++-- .../OWML.ModHelper.Menus.csproj | 11 + OWML.ModHelper.Menus/packages.config | 1 + OWML.ModHelper/ControllerButton.cs | 34 +++ OWML.ModHelper/DontDestroyOnLoad.cs | 12 + OWML.ModHelper/ModConfig.cs | 38 +++- OWML.ModHelper/OWML.ModHelper.csproj | 12 +- OWML.ModLoader/ModData.cs | 17 +- OWML.ModLoader/ModFinder.cs | 9 +- OWML.ModLoader/Owo.cs | 26 +-- .../OWML.EnableDebugMode/manifest.json | 2 +- .../OWML.LoadCustomAssets/LoadCustomAssets.cs | 33 +-- .../OWML.LoadCustomAssets/default-config.json | 29 ++- .../OWML.LoadCustomAssets/manifest.json | 2 +- OWML.sln.DotSettings | 1 + Readme.md | 1 + 50 files changed, 1321 insertions(+), 134 deletions(-) create mode 100644 OWML.Common/Menus/IModConfigMenu.cs create mode 100644 OWML.Common/Menus/IModInput.cs create mode 100644 OWML.Common/Menus/IModInputMenu.cs create mode 100644 OWML.Common/Menus/IModNumberInput.cs create mode 100644 OWML.Common/Menus/IModSliderInput.cs create mode 100644 OWML.Common/Menus/IModTextInput.cs create mode 100644 OWML.Common/Menus/IModToggleInput.cs create mode 100644 OWML.Common/Menus/IModsMenu.cs create mode 100644 OWML.Common/Menus/InputType.cs create mode 100644 OWML.ModHelper.Menus/ModConfigMenu.cs create mode 100644 OWML.ModHelper.Menus/ModInput.cs create mode 100644 OWML.ModHelper.Menus/ModInputField.cs create mode 100644 OWML.ModHelper.Menus/ModInputMenu.cs create mode 100644 OWML.ModHelper.Menus/ModNumberInput.cs create mode 100644 OWML.ModHelper.Menus/ModSliderInput.cs create mode 100644 OWML.ModHelper.Menus/ModTextInput.cs create mode 100644 OWML.ModHelper.Menus/ModToggleInput.cs create mode 100644 OWML.ModHelper/ControllerButton.cs create mode 100644 OWML.ModHelper/DontDestroyOnLoad.cs diff --git a/OWML.Common/IModConfig.cs b/OWML.Common/IModConfig.cs index e0c894e4..6cf4b734 100644 --- a/OWML.Common/IModConfig.cs +++ b/OWML.Common/IModConfig.cs @@ -1,12 +1,17 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace OWML.Common { public interface IModConfig { - bool Enabled { get; } - bool RequireVR { get; } - Dictionary Settings { get; } + bool Enabled { get; set; } + bool RequireVR { get; set; } + Dictionary Settings { get; set; } + T GetSettingsValue(string key); + void SetSettingsValue(string key, object value); + + [Obsolete("Use GetSettingsValue instead")] T GetSetting(string key); } } diff --git a/OWML.Common/IModData.cs b/OWML.Common/IModData.cs index 86aeeecb..cbf14944 100644 --- a/OWML.Common/IModData.cs +++ b/OWML.Common/IModData.cs @@ -4,5 +4,8 @@ public interface IModData { IModManifest Manifest { get; } IModConfig Config { get; } + IModConfig DefaultConfig { get; } + + void ResetConfig(); } } \ No newline at end of file diff --git a/OWML.Common/Menus/IModButton.cs b/OWML.Common/Menus/IModButton.cs index 41eff159..7a65931e 100644 --- a/OWML.Common/Menus/IModButton.cs +++ b/OWML.Common/Menus/IModButton.cs @@ -28,5 +28,7 @@ public interface IModButton void Show(); void Hide(); + + void SetControllerCommand(SingleAxisCommand inputCommand); } } \ No newline at end of file diff --git a/OWML.Common/Menus/IModConfigMenu.cs b/OWML.Common/Menus/IModConfigMenu.cs new file mode 100644 index 00000000..2718a63c --- /dev/null +++ b/OWML.Common/Menus/IModConfigMenu.cs @@ -0,0 +1,10 @@ +namespace OWML.Common.Menus +{ + public interface IModConfigMenu : IModPopupMenu + { + IModData ModData { get; } + IModBehaviour Mod { get; } + + void Initialize(Menu modMenuCopy, IModToggleInput toggleTemplate, IModSliderInput sliderTemplate, IModTextInput textInputTemplate, IModNumberInput numberInputTemplate); + } +} diff --git a/OWML.Common/Menus/IModInput.cs b/OWML.Common/Menus/IModInput.cs new file mode 100644 index 00000000..57639f06 --- /dev/null +++ b/OWML.Common/Menus/IModInput.cs @@ -0,0 +1,17 @@ +using System; +using UnityEngine; + +namespace OWML.Common.Menus +{ + public interface IModInput + { + event Action OnChange; + T Value { get; set; } + MonoBehaviour Element { get; } + string Title { get; set; } + int Index { get; set; } + void Show(); + void Hide(); + void Initialize(IModMenu menu); + } +} \ No newline at end of file diff --git a/OWML.Common/Menus/IModInputMenu.cs b/OWML.Common/Menus/IModInputMenu.cs new file mode 100644 index 00000000..4d81e1b8 --- /dev/null +++ b/OWML.Common/Menus/IModInputMenu.cs @@ -0,0 +1,12 @@ +using System; + +namespace OWML.Common.Menus +{ + public interface IModInputMenu : IModMenu + { + event Action OnConfirm; + event Action OnCancel; + void Initialize(PopupInputMenu inputMenu); + void Open(InputType inputType, string value); + } +} diff --git a/OWML.Common/Menus/IModMenu.cs b/OWML.Common/Menus/IModMenu.cs index d7b065b5..a747b07d 100644 --- a/OWML.Common/Menus/IModMenu.cs +++ b/OWML.Common/Menus/IModMenu.cs @@ -9,10 +9,37 @@ public interface IModMenu event Action OnInit; Menu Menu { get; } + List Buttons { get; } IModButton GetButton(string title); - void AddButton(IModButton button); - void AddButton(IModButton button, int index); + IModButton AddButton(IModButton button); + IModButton AddButton(IModButton button, int index); + + List ToggleInputs { get; } + IModToggleInput GetToggleInput(string title); + IModToggleInput AddToggleInput(IModToggleInput input); + IModToggleInput AddToggleInput(IModToggleInput input, int index); + + List SliderInputs { get; } + IModSliderInput GetSliderInput(string title); + IModSliderInput AddSliderInput(IModSliderInput input); + IModSliderInput AddSliderInput(IModSliderInput input, int index); + + List TextInputs { get; } + IModTextInput GetTextInput(string title); + IModTextInput AddTextInput(IModTextInput input); + IModTextInput AddTextInput(IModTextInput input, int index); + + List NumberInputs { get; } + IModNumberInput GetNumberInput(string title); + IModNumberInput AddNumberInput(IModNumberInput input); + IModNumberInput AddNumberInput(IModNumberInput input, int index); + + object GetInputValue(string key); + void SetInputValue(string key, object value); + + void SelectFirst(); + void UpdateNavigation(); [Obsolete("Use Buttons instead")] List