Skip to content

Commit

Permalink
Merge pull request #568 from ow-mods/dev
Browse files Browse the repository at this point in the history
2.10.1
  • Loading branch information
misternebula authored Mar 20, 2024
2 parents d496f82 + 08034ba commit 86dc3d8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
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.10.0",
"version": "2.10.1",
"minGameVersion": "1.1.14.768",
"maxGameVersion": "1.1.14.768"
}
19 changes: 9 additions & 10 deletions src/OWML.ModHelper.Menus/NewMenuSystem/MenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public MenuManager(
_owmlConfig = owmlConfig;
_unityEvents = unityEvents;
TitleMenuManager = new TitleMenuManager();
PopupMenuManager = new PopupMenuManager(console, harmony);
PopupMenuManager = new PopupMenuManager(console, harmony, this);
OptionsMenuManager = new OptionsMenuManager(console, unityEvents, PopupMenuManager);
PauseMenuManager = new PauseMenuManager(console);

Expand All @@ -58,18 +58,14 @@ public MenuManager(

LoadManager.OnCompleteSceneLoad += (_, newScene) =>
{
if (newScene is OWScene.TitleScreen or OWScene.SolarSystem or OWScene.EyeOfTheUniverse)
if (newScene is OWScene.SolarSystem or OWScene.EyeOfTheUniverse)
{
SetupMenus(((IMenuManager)this).ModList);
}
};

modUnityEvents.RunWhen(
PlayerData.IsLoaded,
() => SetupMenus(((IMenuManager)this).ModList));
}

private void SetupMenus(IList<IModBehaviour> modList)
internal void SetupMenus(IList<IModBehaviour> modList)
{
void SaveConfig()
{
Expand Down Expand Up @@ -221,6 +217,7 @@ void SaveConfig()
{
mod.ModHelper.Config.SetSettingsValue(name, newValue);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
mod.Configure(mod.ModHelper.Config);
};
break;
case SettingType.TOGGLE:
Expand All @@ -233,6 +230,7 @@ void SaveConfig()
{
mod.ModHelper.Config.SetSettingsValue(name, newValue);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
mod.Configure(mod.ModHelper.Config);
};
break;
case SettingType.SELECTOR:
Expand All @@ -245,6 +243,7 @@ void SaveConfig()
{
mod.ModHelper.Config.SetSettingsValue(name, newSelection);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
mod.Configure(mod.ModHelper.Config);
};
break;
case SettingType.SEPARATOR:
Expand All @@ -258,9 +257,9 @@ void SaveConfig()
settingSlider.ModSettingKey = name;
settingSlider.OnValueChanged += (float newValue) =>
{
_console.WriteLine($"changed to {newValue}");
mod.ModHelper.Config.SetSettingsValue(name, newValue);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
mod.Configure(mod.ModHelper.Config);
};
break;
case SettingType.TEXT:
Expand All @@ -270,9 +269,9 @@ void SaveConfig()
textInput.OnConfirmEntry += () =>
{
var newValue = textInput.GetInputText();
_console.WriteLine($"changed to {newValue}");
mod.ModHelper.Config.SetSettingsValue(name, newValue);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
mod.Configure(mod.ModHelper.Config);
};
break;
case SettingType.NUMBER:
Expand All @@ -282,9 +281,9 @@ void SaveConfig()
numberInput.OnConfirmEntry += () =>
{
var newValue = double.Parse(numberInput.GetInputText());
_console.WriteLine($"changed to {newValue}");
mod.ModHelper.Config.SetSettingsValue(name, newValue);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
mod.Configure(mod.ModHelper.Config);
};
break;
default:
Expand Down
14 changes: 12 additions & 2 deletions src/OWML.ModHelper.Menus/NewMenuSystem/PopupMenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ public class PopupMenuManager : IPopupMenuManager
private GameObject _twoChoicePopupBase;
private GameObject _inputPopupBase;

public PopupMenuManager(IModConsole console, IHarmonyHelper harmony)
public PopupMenuManager(IModConsole console, IHarmonyHelper harmony, IMenuManager menuManager)
{
_console = console;
StartupPopupPatches.menuManager = menuManager as MenuManager;

LoadManager.OnCompleteSceneLoad += LoadManager_OnCompleteSceneLoad;

Expand Down Expand Up @@ -323,6 +324,8 @@ public IOWMLFourChoicePopupMenu CreateFourChoicePopup(string message, string con

public static class StartupPopupPatches
{
public static MenuManager menuManager;

public static bool DetermineStartupPopups(TitleScreenManager __instance)
{
if (__instance._profileManager.currentProfileGameSave.version == "NONE")
Expand Down Expand Up @@ -363,7 +366,7 @@ public static bool TryShowStartupPopupsAndShowMenu(TitleScreenManager __instance
return false;
}

if (PopupMenuManager.PopupsToShow.Count == 0)
if (PopupMenuManager.PopupsToShow == null || PopupMenuManager.PopupsToShow.Count == 0)
{
__instance._okCancelPopup.ResetPopup();
__instance.SetUpMainMenu();
Expand All @@ -375,6 +378,7 @@ public static bool TryShowStartupPopupsAndShowMenu(TitleScreenManager __instance

if (firstTimeRun)
{
menuManager.SetupMenus((menuManager as IMenuManager).ModList);
__instance.FadeInMenuOptions();
return false;
}
Expand All @@ -391,6 +395,12 @@ public static bool TryShowStartupPopups(TitleScreenManager __instance)
{
string text = "AAAAGGGGGHH";

if (PopupMenuManager.PopupsToShow == null || PopupMenuManager.PopupsToShow.Count == 0)
{
__instance.TryShowStartupPopupsAndShowMenu(true);
return false;
}

PopupMenuManager.ActivePopup = PopupMenuManager.PopupsToShow.First();

if (PopupMenuManager.ActivePopup <= 2)
Expand Down
2 changes: 2 additions & 0 deletions src/OWML.ModHelper.Menus/NewMenuSystem/TitleMenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public SubmitAction CreateTitleButton(string text, int index, bool fromTop)

titleScreenManager._mainMenuTextFields = titleScreenManager._mainMenuTextFields.Append(submitAction.GetComponentInChildren<Text>()).ToArray();

newButton.SetActive(true);

return submitAction;
}

Expand Down

0 comments on commit 86dc3d8

Please sign in to comment.