startup popups

This commit is contained in:
Mister_Nebula 2022-05-04 10:31:44 +01:00
parent 4bcce01890
commit f95bfb7914
8 changed files with 234 additions and 79 deletions

View File

@ -1,14 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
# Visual Studio Version 17
VisualStudioVersion = 17.0.31912.275
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MenuFramework", "MenuFramework\MenuFramework.csproj", "{D894866C-F6A2-4BBB-BB41-EC8164AC185F}"
ProjectSection(ProjectDependencies) = postProject
{AD61351D-B3D3-49AC-AC38-6F601003A234} = {AD61351D-B3D3-49AC-AC38-6F601003A234}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestMod", "TestMod\TestMod.csproj", "{AD61351D-B3D3-49AC-AC38-6F601003A234}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -20,10 +15,6 @@ Global
{D894866C-F6A2-4BBB-BB41-EC8164AC185F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D894866C-F6A2-4BBB-BB41-EC8164AC185F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D894866C-F6A2-4BBB-BB41-EC8164AC185F}.Release|Any CPU.Build.0 = Release|Any CPU
{AD61351D-B3D3-49AC-AC38-6F601003A234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD61351D-B3D3-49AC-AC38-6F601003A234}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD61351D-B3D3-49AC-AC38-6F601003A234}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD61351D-B3D3-49AC-AC38-6F601003A234}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -38,6 +38,7 @@ namespace MenuFramework
gameObject.AddComponent<TitleButtonManager>();
gameObject.AddComponent<PopupMenuManager>();
gameObject.AddComponent<PauseButtonManager>();
gameObject.AddComponent<StartupPopupManager>();
//gameObject.AddComponent<OptionsMenuManager>();
LoadManager.OnCompleteSceneLoad += OnSceneLoad;

View File

@ -8,16 +8,6 @@ namespace MenuFramework
public class MenuAPI
{
// TITLE SCREEN
[Obsolete]
public GameObject TitleScreen_MakeMenuOpenButton(string name, Menu menuToOpen)
=> TitleButtonManager.Instance.MakeMenuOpenButton(name, 0, menuToOpen);
[Obsolete]
public GameObject TitleScreen_MakeSceneLoadButton(string name, SubmitActionLoadScene.LoadableScenes sceneToLoad, PopupMenu confirmPopup = null)
=> TitleButtonManager.Instance.MakeSceneLoadButton(name, 0, sceneToLoad, confirmPopup);
[Obsolete]
public Button TitleScreen_MakeSimpleButton(string name)
=> TitleButtonManager.Instance.MakeSimpleButton(name, 0);
public GameObject TitleScreen_MakeMenuOpenButton(string name, int index, Menu menuToOpen)
=> TitleButtonManager.Instance.MakeMenuOpenButton(name, index, menuToOpen);
@ -49,5 +39,9 @@ namespace MenuFramework
public PopupMenu MakeInfoPopup(string message, string continueButtonText)
=> PopupMenuManager.Instance.CreateInfoPopup(message, continueButtonText);
// STARTUP POPUPS
public void RegisterStartupPopup(string message)
=> StartupPopupManager.Instance.RegisterStartupPopup(message);
}
}

View File

@ -39,78 +39,73 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=1.2.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lib.Harmony.1.2.0.1\lib\net35\0Harmony.dll</HintPath>
<HintPath>..\packages\Lib.Harmony.1.2.0.1\lib\net472\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp_publicized">
<HintPath>$(GameDir)\OuterWilds_Data\Managed\publicized_assemblies\Assembly-CSharp_publicized.dll</HintPath>
<HintPath>D:\SteamLibrary\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\publicized_assemblies\Assembly-CSharp_publicized.dll</HintPath>
</Reference>
<Reference Include="NAudio-Unity, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.1.0\lib\net40\NAudio-Unity.dll</HintPath>
<HintPath>..\packages\OWML.2.3.3\lib\net48\NAudio-Unity.dll</HintPath>
</Reference>
<Reference Include="netstandard">
<HintPath>$(GameDir)\OuterWilds_Data\Managed\netstandard.dll</HintPath>
<Reference Include="OWML.Common, Version=2.3.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.3.3\lib\net48\OWML.Common.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Json.Net.Unity3D.9.0.1\lib\net35\Newtonsoft.Json.dll</HintPath>
<Reference Include="OWML.Logging, Version=2.3.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.3.3\lib\net48\OWML.Logging.dll</HintPath>
</Reference>
<Reference Include="OWML.Common, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.1.0\lib\net40\OWML.Common.dll</HintPath>
<Reference Include="OWML.ModHelper, Version=2.3.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.3.3\lib\net48\OWML.ModHelper.dll</HintPath>
</Reference>
<Reference Include="OWML.Logging, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.1.0\lib\net40\OWML.Logging.dll</HintPath>
<Reference Include="OWML.ModHelper.Assets, Version=2.3.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.3.3\lib\net48\OWML.ModHelper.Assets.dll</HintPath>
</Reference>
<Reference Include="OWML.ModHelper, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.1.0\lib\net40\OWML.ModHelper.dll</HintPath>
<Reference Include="OWML.ModHelper.Events, Version=2.3.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.3.3\lib\net48\OWML.ModHelper.Events.dll</HintPath>
</Reference>
<Reference Include="OWML.ModHelper.Assets, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.1.0\lib\net40\OWML.ModHelper.Assets.dll</HintPath>
<Reference Include="OWML.ModHelper.Input, Version=2.3.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.3.3\lib\net48\OWML.ModHelper.Input.dll</HintPath>
</Reference>
<Reference Include="OWML.ModHelper.Events, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.1.0\lib\net40\OWML.ModHelper.Events.dll</HintPath>
<Reference Include="OWML.ModHelper.Interaction, Version=2.3.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.3.3\lib\net48\OWML.ModHelper.Interaction.dll</HintPath>
</Reference>
<Reference Include="OWML.ModHelper.Input, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.1.0\lib\net40\OWML.ModHelper.Input.dll</HintPath>
<Reference Include="OWML.ModHelper.Menus, Version=2.3.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.3.3\lib\net48\OWML.ModHelper.Menus.dll</HintPath>
</Reference>
<Reference Include="OWML.ModHelper.Interaction, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.1.0\lib\net40\OWML.ModHelper.Interaction.dll</HintPath>
<Reference Include="OWML.Utils, Version=2.3.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.3.3\lib\net48\OWML.Utils.dll</HintPath>
</Reference>
<Reference Include="OWML.ModHelper.Menus, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.1.0\lib\net40\OWML.ModHelper.Menus.dll</HintPath>
</Reference>
<Reference Include="OWML.Utils, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.2.1.0\lib\net40\OWML.Utils.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml">
<HintPath>$(GameDir)\OuterWilds_Data\Managed\System.Xml.dll</HintPath>
<Reference Include="Unity.InputSystem, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\Unity.InputSystem.dll</HintPath>
</Reference>
<Reference Include="Unity.InputSystem">
<HintPath>$(GameDir)\OuterWilds_Data\Managed\Unity.InputSystem.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.dll</HintPath>
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AssetBundleModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
<HintPath>D:\SteamLibrary\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.IMGUIModule">
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
<Reference Include="UnityEngine.IMGUIModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule">
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
<Reference Include="UnityEngine.TextRenderingModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.UI.dll</HintPath>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.UIModule.dll</HintPath>
<Reference Include="UnityEngine.UIModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.UIModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@ -121,6 +116,7 @@
<Compile Include="PopupMenuManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="StartupPopupManager.cs" />
<Compile Include="TitleButtonManager.cs" />
</ItemGroup>
<ItemGroup>

View File

@ -0,0 +1,178 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace MenuFramework
{
internal class StartupPopupManager : MonoBehaviour
{
public static StartupPopupManager Instance { get; private set; }
private void Awake()
=> Instance = this;
private void Start()
{
Main.Helper.HarmonyHelper.AddPrefix<TitleScreenManager>(nameof(TitleScreenManager.DetermineStartupPopups), typeof(StartupPatches), nameof(StartupPatches.DetermineStartupPopups));
Main.Helper.HarmonyHelper.AddPrefix<TitleScreenManager>(nameof(TitleScreenManager.OnUserConfirmStartupPopup), typeof(StartupPatches), nameof(StartupPatches.OnUserConfirmStartupPopup));
if (typeof(TitleScreenManager).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static).Any(x => x.Name == "ShowStartupPopupsAndShowMenu"))
{
Main.Helper.HarmonyHelper.AddPrefix<TitleScreenManager>(nameof(TitleScreenManager.ShowStartupPopupsAndShowMenu), typeof(StartupPatches), nameof(StartupPatches.ShowStartupPopupsAndShowMenu));
}
else
{
Main.Helper.HarmonyHelper.AddPrefix<TitleScreenManager>("TryShowStartupPopupsAndShowMenu", typeof(StartupPatches), nameof(StartupPatches.TryShowStartupPopupsAndShowMenu));
Main.Helper.HarmonyHelper.AddPrefix<TitleScreenManager>("TryShowStartupPopups", typeof(StartupPatches), nameof(StartupPatches.TryShowStartupPopups));
}
}
public int ActivePopup;
public List<int> PopupsToShow = new List<int>();
public List<string> Popups = new List<string>()
{
UITextLibrary.GetString(UITextType.MenuMessage_InputUpdate),
UITextLibrary.GetString(UITextType.MenuMessage_ReducedFrightOptionAvail),
UITextLibrary.GetString(UITextType.MenuMessage_NewExhibit)
};
public void RegisterStartupPopup(string message)
{
PopupsToShow.Add(Popups.Count);
Popups.Add(message);
}
}
public static class StartupPatches
{
public static bool DetermineStartupPopups(TitleScreenManager __instance)
{
if (__instance._profileManager.currentProfileGameSave.version == "NONE")
{
StartupPopupManager.Instance.PopupsToShow.Add(0);
}
var ownsDlc = EntitlementsManager.IsDlcOwned() == EntitlementsManager.AsyncOwnershipStatus.Owned;
if (ownsDlc && (__instance._profileManager.currentProfileGameSave.shownPopups & StartupPopups.ReducedFrights) == StartupPopups.None)
{
StartupPopupManager.Instance.PopupsToShow.Add(1);
}
if (ownsDlc && (__instance._profileManager.currentProfileGameSave.shownPopups & StartupPopups.NewExhibit) == StartupPopups.None)
{
StartupPopupManager.Instance.PopupsToShow.Add(2);
}
return false;
}
public static bool ShowStartupPopupsAndShowMenu(TitleScreenManager __instance)
{
var popupManger = StartupPopupManager.Instance;
if (popupManger.PopupsToShow.Count == 0)
{
__instance._okCancelPopup.ResetPopup();
__instance.SetUpMainMenu();
__instance.FadeInMenuOptions();
return false;
}
popupManger.ActivePopup = popupManger.PopupsToShow.OrderBy(x => x).First();
var message = popupManger.Popups[popupManger.ActivePopup];
__instance._inputModule.EnableInputs();
__instance._titleMenuRaycastBlocker.blocksRaycasts = false;
__instance._okCancelPopup.ResetPopup();
__instance._okCancelPopup.SetUpPopup(message, InputLibrary.menuConfirm, null, __instance._continuePrompt, null, true, false);
__instance._okCancelPopup.OnPopupConfirm += __instance.OnUserConfirmStartupPopup;
__instance._okCancelPopup.EnableMenu(true);
return false;
}
public static bool OnUserConfirmStartupPopup(TitleScreenManager __instance)
{
var popupManger = StartupPopupManager.Instance;
popupManger.PopupsToShow.Remove(popupManger.ActivePopup);
if (popupManger.ActivePopup <= 2)
{
switch (popupManger.ActivePopup)
{
case 0:
PlayerData.SetShownPopups(StartupPopups.ResetInputs);
break;
case 1:
PlayerData.SetShownPopups(StartupPopups.ReducedFrights);
break;
case 2:
PlayerData.SetShownPopups(StartupPopups.NewExhibit);
break;
}
PlayerData.SaveCurrentGame();
}
popupManger.ActivePopup = -1;
__instance._okCancelPopup.OnPopupConfirm -= __instance.OnUserConfirmStartupPopup;
__instance._inputModule.DisableInputs();
__instance._titleMenuRaycastBlocker.blocksRaycasts = true;
var titleType = __instance.GetType();
if (titleType.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static).Any(x => x.Name == "ShowStartupPopupsAndShowMenu"))
{
__instance.GetType().GetMethod("ShowStartupPopupsAndShowMenu", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, null);
}
else
{
__instance.GetType().GetMethod("TryShowStartupPopupsAndShowMenu", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, null);
}
return false;
}
public static bool TryShowStartupPopupsAndShowMenu(TitleScreenManager __instance)
{
var popupManger = StartupPopupManager.Instance;
if (popupManger.PopupsToShow.Count == 0)
{
__instance._okCancelPopup.ResetPopup();
__instance.SetUpMainMenu();
__instance.FadeInMenuOptions();
return false;
}
__instance.GetType().GetMethod("TryShowStartupPopups", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, null);
return false;
}
public static bool TryShowStartupPopups(TitleScreenManager __instance)
{
var popupManger = StartupPopupManager.Instance;
popupManger.ActivePopup = popupManger.PopupsToShow.First();
var message = popupManger.Popups[popupManger.ActivePopup];
__instance._inputModule.EnableInputs();
__instance._titleMenuRaycastBlocker.blocksRaycasts = false;
__instance._okCancelPopup.ResetPopup();
__instance._okCancelPopup.SetUpPopup(message, InputLibrary.menuConfirm, null, __instance._continuePrompt, null, true, false);
__instance._okCancelPopup.OnPopupConfirm += __instance.OnUserConfirmStartupPopup;
__instance._okCancelPopup.EnableMenu(true);
return false;
}
}
}

View File

@ -4,6 +4,6 @@
"name": "Menu Framework",
"description": "Custom menu framework/wrapper.",
"uniqueName": "_nebula.MenuFramework",
"version": "2.1.1",
"version": "3.0.0",
"owmlVersion": "2.2.0"
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Json.Net.Unity3D" version="9.0.1" targetFramework="net35" />
<package id="Lib.Harmony" version="1.2.0.1" targetFramework="net35" requireReinstallation="true" />
<package id="OWML" version="2.1.0" targetFramework="net48" />
<package id="Lib.Harmony" version="1.2.0.1" targetFramework="net48" />
<package id="OWML" version="2.3.3" targetFramework="net48" />
</packages>

View File

@ -7,13 +7,6 @@ namespace TestMod
public interface IMenuAPI
{
// Title screen
[Obsolete]
GameObject TitleScreen_MakeMenuOpenButton(string name, Menu menuToOpen);
[Obsolete]
GameObject TitleScreen_MakeSceneLoadButton(string name, SubmitActionLoadScene.LoadableScenes sceneToLoad, PopupMenu confirmPopup = null);
[Obsolete]
Button TitleScreen_MakeSimpleButton(string name);
GameObject TitleScreen_MakeMenuOpenButton(string name, int index, Menu menuToOpen);
GameObject TitleScreen_MakeSceneLoadButton(string name, int index, SubmitActionLoadScene.LoadableScenes sceneToLoad, PopupMenu confirmPopup = null);
Button TitleScreen_MakeSimpleButton(string name, int index);
@ -26,5 +19,7 @@ namespace TestMod
PopupMenu MakeTwoChoicePopup(string message, string confirmText, string cancelText);
PopupInputMenu MakeInputFieldPopup(string message, string placeholderMessage, string confirmText, string cancelText);
PopupMenu MakeInfoPopup(string message, string continueButtonText);
// Startup Popups
void RegisterStartupPopup(string message);
}
}