diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 90e0373e2..76038ec21 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,7 +55,7 @@ jobs: - name: pack run: dotnet pack -o . src\OWML.ModHelper\OWML.ModHelper.csproj -p:NuspecFile=OWML.ModHelper.nuspec -p:NuspecProperties="version=${{ steps.version.outputs.prop }};" - name: upload nuget - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: owml-nuget path: OWML.*.nupkg @@ -67,7 +67,7 @@ jobs: mkdir Mods 7z a OWML.zip * - name: upload zip - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: owml-zip path: src\OWML.Launcher\bin\Debug\net48\OWML.zip diff --git a/src/OWML.Abstractions/GameObjectHelper.cs b/src/OWML.Abstractions/GameObjectHelper.cs index 95c40065d..e59bfc98d 100644 --- a/src/OWML.Abstractions/GameObjectHelper.cs +++ b/src/OWML.Abstractions/GameObjectHelper.cs @@ -13,6 +13,6 @@ public TBehaviour CreateAndAdd(string name = null) => CreateAndAdd(typeof(TBehaviour), name); public TBehaviour CreateAndAdd(Type type, string name = null) => - (TBehaviour)(object)new GameObject(name).AddComponent(type); + (TBehaviour)(object)new GameObject(name ?? type.Name).AddComponent(type); } } diff --git a/src/OWML.Common/Interfaces/Menus/IOWMLPopupInputMenu.cs b/src/OWML.Common/Interfaces/Menus/IOWMLPopupInputMenu.cs index dc27beb3a..1115e0854 100644 --- a/src/OWML.Common/Interfaces/Menus/IOWMLPopupInputMenu.cs +++ b/src/OWML.Common/Interfaces/Menus/IOWMLPopupInputMenu.cs @@ -4,7 +4,9 @@ namespace OWML.Common.Interfaces.Menus { public interface IOWMLPopupInputMenu { - public event PopupInputMenu.InputPopupValidateCharEvent OnInputPopupValidateChar; + public delegate bool InputPopupValidateCharEvent(string input, int charIndex, char addedChar); + + public event InputPopupValidateCharEvent OnInputPopupValidateChar; public void EnableMenu(bool value); diff --git a/src/OWML.ModHelper.Menus/CustomInputs/OWMLPopupInputMenu.cs b/src/OWML.ModHelper.Menus/CustomInputs/OWMLPopupInputMenu.cs index 09f77af30..65f9b74a8 100644 --- a/src/OWML.ModHelper.Menus/CustomInputs/OWMLPopupInputMenu.cs +++ b/src/OWML.ModHelper.Menus/CustomInputs/OWMLPopupInputMenu.cs @@ -15,7 +15,7 @@ public class OWMLPopupInputMenu : PopupMenu, IOWMLPopupInputMenu protected bool _virtualKeyboardOpen; public event PopupInputMenu.InputPopupTextChangedEvent OnInputPopupTextChanged; - public event PopupInputMenu.InputPopupValidateCharEvent OnInputPopupValidateChar; + public event IOWMLPopupInputMenu.InputPopupValidateCharEvent OnInputPopupValidateChar; public override void Awake() { @@ -158,7 +158,7 @@ private char OnValidateInput(string input, int charIndex, char addedChar) Delegate[] invocationList = this.OnInputPopupValidateChar.GetInvocationList(); for (int i = 0; i < invocationList.Length; i++) { - bool flag2 = (bool)invocationList[i].DynamicInvoke(new object[] { addedChar }); + bool flag2 = (bool)invocationList[i].DynamicInvoke(new object[] { input, charIndex, addedChar }); flag = flag && flag2; } } diff --git a/src/OWML.ModHelper.Menus/ModInputMenu.cs b/src/OWML.ModHelper.Menus/ModInputMenu.cs index 5bff28165..8ed10e155 100644 --- a/src/OWML.ModHelper.Menus/ModInputMenu.cs +++ b/src/OWML.ModHelper.Menus/ModInputMenu.cs @@ -75,7 +75,7 @@ private bool OnValidateNumber() => float.TryParse(_inputMenu.GetInputText(), out _); private bool OnValidateCharNumber(char c) => - "0123456789.".Contains("" + c); + "0123456789.-".Contains(c.ToString()); protected override void OnPopupConfirm() { diff --git a/src/OWML.ModHelper.Menus/NewMenuSystem/MenuManager.cs b/src/OWML.ModHelper.Menus/NewMenuSystem/MenuManager.cs index b95bc7990..c15878f94 100644 --- a/src/OWML.ModHelper.Menus/NewMenuSystem/MenuManager.cs +++ b/src/OWML.ModHelper.Menus/NewMenuSystem/MenuManager.cs @@ -387,6 +387,12 @@ private void EditExistingMenus() { var text = item.GetComponent()._textItems[0]; text.horizontalOverflow = HorizontalWrapMode.Wrap; + + // Give a little bit of margin to account for the dividing lines + // (as otherwise it can look like the text is on top of them when in mouse mode) + float margin = 0.03f; + text.rectTransform.anchorMin = new Vector2(margin, 0.0f); + text.rectTransform.anchorMax = new Vector2(1f - margin, 1.0f); } } diff --git a/src/OWML.ModHelper.Menus/NewMenuSystem/OptionsMenuManager.cs b/src/OWML.ModHelper.Menus/NewMenuSystem/OptionsMenuManager.cs index b3191800e..1c2fb2be7 100644 --- a/src/OWML.ModHelper.Menus/NewMenuSystem/OptionsMenuManager.cs +++ b/src/OWML.ModHelper.Menus/NewMenuSystem/OptionsMenuManager.cs @@ -31,6 +31,7 @@ public OptionsMenuManager(IModConsole console, IModUnityEvents unityEvents, IPop newMenu.transform.localScale = Vector3.one; newMenu.transform.localPosition = Vector3.zero; newMenu.transform.localRotation = Quaternion.identity; + newMenu.name = $"Menu-{name}"; var rt = newMenu.GetComponent(); var ert = existingMenu.GetComponent(); rt.anchorMin = ert.anchorMin; @@ -84,6 +85,7 @@ public OptionsMenuManager(IModConsole console, IModUnityEvents unityEvents, IPop newSubMenu.transform.localScale = Vector3.one; newSubMenu.transform.localPosition = Vector3.zero; newSubMenu.transform.localRotation = Quaternion.identity; + newSubMenu.name = $"Menu-{name}"; var rectTransform = newSubMenu.GetComponent(); rectTransform.anchorMin = existingTabbedSubMenu.GetComponent().anchorMin; rectTransform.anchorMax = existingTabbedSubMenu.GetComponent().anchorMax; @@ -169,7 +171,7 @@ public void RemoveTab(Menu tab) newSubMenuTabButton.transform.localScale = Vector3.one; newSubMenuTabButton.transform.localPosition = Vector3.zero; newSubMenuTabButton.transform.localRotation = Quaternion.identity; - newSubMenuTabButton.transform.SetSiblingIndex(newSubMenuTabButton.transform.parent.childCount - 2); + newSubMenuTabButton.transform.SetSiblingIndex(newSubMenuTabButton.transform.parent.childCount - 3); newSubMenuTabButton.name = $"Button-{name}Tab"; Object.Destroy(newSubMenuTabButton.GetComponentInChildren()); newSubMenuTabButton.GetComponentInChildren().text = name; @@ -190,6 +192,9 @@ public void RemoveTab(Menu tab) rt.offsetMax = ert.offsetMax; rt.sizeDelta = ert.sizeDelta; + var viewportRect = newSubMenu.GetComponentInChildren().GetComponent(); + viewportRect.anchoredPosition3D = Vector3.zero; + if (menu._selectOnActivate == null) { menu._selectOnActivate = newSubMenuTabButton.GetComponent