Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.14.0 #597

Merged
merged 23 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d8305cd
Fix off-centre subtab buttons
throckmorpheus Aug 16, 2024
501eb16
Set names of main tab objects
throckmorpheus Aug 16, 2024
190a364
Fix off-centre scroll viewport in sub-tabs
throckmorpheus Aug 17, 2024
8d54632
Add very slight margin to tab buttons so 'AUDIO & LANGUAGES' text doe…
throckmorpheus Aug 19, 2024
b7c7e92
Fixed option menu buttons not responding to controller input for navi…
throckmorpheus Aug 21, 2024
f375f3d
Fix up options menu button styling
throckmorpheus Aug 21, 2024
3014ea4
Remove (Clone) from name
MegaPiggy Sep 26, 2024
17accd7
update upload-artifact
MegaPiggy Sep 26, 2024
f41f3a6
better font and size
MegaPiggy Sep 26, 2024
4238d94
default to type name if not given
MegaPiggy Sep 26, 2024
42b3093
Allow for negative numbers
MegaPiggy Sep 26, 2024
7555c05
Merge pull request #593 from throckmorpheus/menu-fixes
MegaPiggy Sep 26, 2024
48a14d4
Highlight "MODS" tab instead of "OWML" by default
misternebula Oct 10, 2024
0a4e76b
Fix #592 (MOD OPTIONS closes when clicked on)
misternebula Oct 10, 2024
a5d1301
Revert "Fix #592 (MOD OPTIONS closes when clicked on)"
misternebula Oct 10, 2024
6392f7d
Fix #585
misternebula Oct 10, 2024
7d2f751
fix #592
misternebula Oct 10, 2024
5d8c06f
update text entry buttons to have new value
misternebula Oct 10, 2024
d1563e1
rename SetCurrentValue to SetValue
misternebula Oct 10, 2024
87f747d
Update OWML.Manifest.json
misternebula Oct 10, 2024
866e5c7
Revert "rename SetCurrentValue to SetValue"
misternebula Oct 11, 2024
09af8a9
add in backwards compat for OnInputPopupValidateChar
misternebula Oct 11, 2024
78f39b5
Remove broken code I accidentally added back in whoops
misternebula Oct 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/OWML.Abstractions/GameObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public TBehaviour CreateAndAdd<TBehaviour>(string name = null) =>
CreateAndAdd<TBehaviour>(typeof(TBehaviour), name);

public TBehaviour CreateAndAdd<TBehaviour>(Type type, string name = null) =>
(TBehaviour)(object)new GameObject(name).AddComponent(type);
(TBehaviour)(object)new GameObject(name ?? type.Name).AddComponent(type);
}
}
6 changes: 6 additions & 0 deletions src/OWML.Common/Interfaces/Menus/IMenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@ public interface IMenuManager
public IPopupMenuManager PopupMenuManager { get; }

internal IList<IModBehaviour> ModList { get; set; }

/// <summary>
/// Keeps the Mod Options tab open, since it is ephemeral.
/// Otherwise, a popup opening in the tab would close it.
/// </summary>
public void ForceModOptionsOpen(bool force);
}
}
7 changes: 6 additions & 1 deletion src/OWML.Common/Interfaces/Menus/IOWMLPopupInputMenu.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
using UnityEngine.UI;
using System;
using UnityEngine.UI;

namespace OWML.Common.Interfaces.Menus
{
public interface IOWMLPopupInputMenu
{
[Obsolete("Use OnValidateChar instead.")]
public event PopupInputMenu.InputPopupValidateCharEvent OnInputPopupValidateChar;

public delegate bool InputPopupValidateCharEvent(string input, int charIndex, char addedChar);
public event InputPopupValidateCharEvent OnValidateChar;

public void EnableMenu(bool value);

public string GetInputText();
Expand Down
10 changes: 10 additions & 0 deletions src/OWML.Common/Interfaces/Menus/IOWMLTextEntryElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,15 @@ public interface IOWMLTextEntryElement : IOWMLMenuValueOption
public event TextEntryConfirmEvent OnConfirmEntry;

public string GetInputText();

/// <summary>
/// Sets the text that is displayed without updating the underlying option value.
/// </summary>
public void SetText(string text);

/// <summary>
/// Sets the underlying option value to the text, and updates the displayed text.
/// </summary>
public void SetCurrentValue(string text);
}
}
2 changes: 1 addition & 1 deletion src/OWML.Launcher/OWML.Manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "Alek",
"name": "OWML",
"uniqueName": "Alek.OWML",
"version": "2.13.0",
"version": "2.14.0",
"minGameVersion": "1.1.15.1018",
"maxGameVersion": "1.1.15.1018"
}
29 changes: 22 additions & 7 deletions src/OWML.ModHelper.Menus/CustomInputs/OWMLPopupInputMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class OWMLPopupInputMenu : PopupMenu, IOWMLPopupInputMenu
protected bool _virtualKeyboardOpen;

public event PopupInputMenu.InputPopupTextChangedEvent OnInputPopupTextChanged;
public event IOWMLPopupInputMenu.InputPopupValidateCharEvent OnValidateChar;

[Obsolete("Use OnValidateChar instead.")]
public event PopupInputMenu.InputPopupValidateCharEvent OnInputPopupValidateChar;

public override void Awake()
Expand Down Expand Up @@ -152,20 +155,32 @@ private void OnTextFieldChanged()

private char OnValidateInput(string input, int charIndex, char addedChar)
{
bool flag = true;
if (this.OnInputPopupValidateChar != null)
var isValidCharacter = true;
if (OnInputPopupValidateChar != null)
{
var invocationList = OnInputPopupValidateChar.GetInvocationList();
for (var i = 0; i < invocationList.Length; i++)
{
var flag2 = (bool)invocationList[i].DynamicInvoke(new object[] { addedChar });
isValidCharacter = isValidCharacter && flag2;
}
}

if (OnValidateChar != null && isValidCharacter)
{
Delegate[] invocationList = this.OnInputPopupValidateChar.GetInvocationList();
for (int i = 0; i < invocationList.Length; i++)
var invocationList = OnValidateChar.GetInvocationList();
for (var i = 0; i < invocationList.Length; i++)
{
bool flag2 = (bool)invocationList[i].DynamicInvoke(new object[] { addedChar });
flag = flag && flag2;
var flag2 = (bool)invocationList[i].DynamicInvoke(new object[] { input, charIndex, addedChar });
isValidCharacter = isValidCharacter && flag2;
}
}
if (flag)

if (isValidCharacter)
{
return addedChar;
}

return '\0';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ public string GetInputText()
return _popup.GetInputText();
}

public void SetCurrentValue(string text)
misternebula marked this conversation as resolved.
Show resolved Hide resolved
public void SetText(string text)
{
gameObject.GetComponentsInChildren<MenuOption>().First(x => x != this)._label.text = text;
}

public void SetCurrentValue(string text)
{
SetText(text);
_popup.GetInputField().text = text;
OnConfirmEntry();
}
Expand Down
2 changes: 1 addition & 1 deletion src/OWML.ModHelper.Menus/ModInputMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
33 changes: 30 additions & 3 deletions src/OWML.ModHelper.Menus/NewMenuSystem/MenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum SettingType
internal static List<(IModBehaviour behaviour, Menu modMenu)> ModSettingsMenus = new();

private bool _hasSetupMenusThisScene = false;
private bool _forceModOptionsOpen;

public MenuManager(
IModConsole console,
Expand All @@ -52,7 +53,7 @@ public MenuManager(
_unityEvents = unityEvents;
TitleMenuManager = new TitleMenuManager();
PopupMenuManager = new PopupMenuManager(console, harmony, this);
OptionsMenuManager = new OptionsMenuManager(console, unityEvents, PopupMenuManager);
OptionsMenuManager = new OptionsMenuManager(console, unityEvents, PopupMenuManager, this);
PauseMenuManager = new PauseMenuManager(console);

var harmonyInstance = harmony.GetValue<Harmony>("_harmony");
Expand Down Expand Up @@ -85,6 +86,11 @@ public MenuManager(
};
}

public void ForceModOptionsOpen(bool force)
{
_forceModOptionsOpen = force;
}

internal void SetupMenus(IList<IModBehaviour> modList)
{
if (_hasSetupMenusThisScene)
Expand All @@ -103,8 +109,8 @@ void SaveConfig()

// Create menus and submenus
var (modsMenu, modsMenuButton) = OptionsMenuManager.CreateTabWithSubTabs("MODS");
var (owmlSubTab, owmlSubTabButton) = OptionsMenuManager.AddSubTab(modsMenu, "OWML");
var (modsSubTab, modsSubTabButton) = OptionsMenuManager.AddSubTab(modsMenu, "MODS");
var (owmlSubTab, owmlSubTabButton) = OptionsMenuManager.AddSubTab(modsMenu, "OWML");

OWMLSettingsMenu = owmlSubTab;

Expand Down Expand Up @@ -210,7 +216,20 @@ void SaveConfig()

newModTab.OnDeactivateMenu += () =>
{
OptionsMenuManager.RemoveTab(newModTab);
if (_forceModOptionsOpen)
{
return;
}

// Fixes tab dissapearing when you click on it again
// Clicking on a tab closes and opens it again
_unityEvents.FireOnNextUpdate(() =>
{
if (!newModTab._isActivated)
{
OptionsMenuManager.RemoveTab(newModTab);
}
});
};

foreach (var (name, setting) in mod.ModHelper.Config.Settings)
Expand Down Expand Up @@ -307,6 +326,7 @@ void SaveConfig()
mod.ModHelper.Config.SetSettingsValue(name, newValue);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
mod.Configure(mod.ModHelper.Config);
textInput.SetText(newValue);
};
break;
case SettingType.NUMBER:
Expand All @@ -319,6 +339,7 @@ void SaveConfig()
mod.ModHelper.Config.SetSettingsValue(name, newValue);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
mod.Configure(mod.ModHelper.Config);
numberInput.SetText(newValue.ToString());
};
break;
default:
Expand Down Expand Up @@ -387,6 +408,12 @@ private void EditExistingMenus()
{
var text = item.GetComponent<UIStyleApplier>()._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);
}
}

Expand Down
Loading
Loading