diff --git a/QSB/Menus/IMenuAPI.cs b/QSB/Menus/IMenuAPI.cs new file mode 100644 index 00000000..cbcdbd3e --- /dev/null +++ b/QSB/Menus/IMenuAPI.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.UI; + +namespace QSB.Menus +{ + public interface IMenuAPI + { + // Title screen + GameObject TitleScreen_MakeMenuOpenButton(string name, Menu menuToOpen); + GameObject TitleScreen_MakeSceneLoadButton(string name, SubmitActionLoadScene.LoadableScenes sceneToLoad, PopupMenu confirmPopup = null); + Button TitleScreen_MakeSimpleButton(string name); + // Pause menu + GameObject PauseMenu_MakeMenuOpenButton(string name, Menu menuToOpen, Menu customMenu = null); + GameObject PauseMenu_MakeSceneLoadButton(string name, SubmitActionLoadScene.LoadableScenes sceneToLoad, PopupMenu confirmPopup = null, Menu customMenu = null); + Button PauseMenu_MakeSimpleButton(string name, Menu customMenu = null); + Menu PauseMenu_MakePauseListMenu(string title); + // Options + Menu OptionsMenu_MakeNonScrollingOptionsTab(string name); + GameObject OptionsMenu_MakeTwoButtonToggle(string label, string trueText, string falseText, string tooltipText, bool savedValue, Menu menuTab); + GameObject OptionsMenu_MakeNonDisplaySliderElement(string label, string tooltipText, float savedValue, Menu menuTab); + void OptionsMenu_MakeSpacer(float minHeight, Menu menuTab); + void OptionsMenu_MakeLabel(string label, Menu menuTab); + void OptionsMenu_MakeTextInput(string label, string placeholderText, string savedValue, Menu menuTab); + // Misc + PopupMenu MakeTwoChoicePopup(string message, string confirmText, string cancelText); + PopupInputMenu MakeInputFieldPopup(string message, string placeholderMessage, string confirmText, string cancelText); + } +} diff --git a/QSB/Menus/MenuManager.cs b/QSB/Menus/MenuManager.cs new file mode 100644 index 00000000..17978e70 --- /dev/null +++ b/QSB/Menus/MenuManager.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace QSB.Menus +{ + class MenuManager : MonoBehaviour + { + private IMenuAPI MenuApi => QSBCore.MenuApi; + private PopupMenu HostWaitingPopup; + private PopupMenu ClientWaitingPopup; + + public void Start() + { + MakeTitleMenus(); + } + + private void MakeTitleMenus() + { + HostWaitingPopup = MenuApi.MakeTwoChoicePopup("Waiting for players to join...", "Start Multiplayer Game", "Stop Server"); + HostWaitingPopup.OnPopupCancel += StopServerOrLeaveServer; + ClientWaitingPopup = MenuApi.MakeTwoChoicePopup("Waiting for game to start...", "uhhhhh", "Disconnect"); + ClientWaitingPopup.OnPopupCancel += StopServerOrLeaveServer; + + var hostButton = MenuApi.TitleScreen_MakeSimpleButton("HOST SERVER"); + hostButton.onClick.AddListener(HostServer); + var connectButton = MenuApi.TitleScreen_MakeSimpleButton("CONNECT TO SERVER"); + connectButton.onClick.AddListener(ConnectToServer); + + var menu = MenuApi.OptionsMenu_MakeNonScrollingOptionsTab("MULTIPLAYER"); + //MenuApi.OptionsMenu_MakeLabel("Connection Information", menu); + MenuApi.OptionsMenu_MakeTextInput("IP Address", "IP Address", QSBCore.DefaultServerIP, menu); + MenuApi.OptionsMenu_MakeTextInput("Port", "Port", $"{QSBCore.Port}", menu); + } + + private void HostServer() + { + HostWaitingPopup.EnableMenu(true); + QSBNetworkManager.Instance.StartHost(); + } + + private void StopServerOrLeaveServer() + { + QSBNetworkManager.Instance.StopHost(); + } + + private void ConnectToServer() + { + ClientWaitingPopup.EnableMenu(true); + QSBNetworkManager.Instance.StartClient(); + } + } +} \ No newline at end of file diff --git a/QSB/QSB.csproj b/QSB/QSB.csproj index 96db5440..e3c85420 100644 --- a/QSB/QSB.csproj +++ b/QSB/QSB.csproj @@ -159,6 +159,8 @@ + + diff --git a/QSB/QSB.csproj.user b/QSB/QSB.csproj.user index 9f1e3257..7bf6c3df 100644 --- a/QSB/QSB.csproj.user +++ b/QSB/QSB.csproj.user @@ -1,7 +1,7 @@  - E:\Epic\Epic Games\OuterWilds + D:\EpicGames\OuterWilds C:\Users\Henry\AppData\Roaming\OuterWildsModManager\OWML ShowAllFiles diff --git a/QSB/QSBCore.cs b/QSB/QSBCore.cs index e8f6bd67..d1c53753 100644 --- a/QSB/QSBCore.cs +++ b/QSB/QSBCore.cs @@ -8,6 +8,7 @@ using QSB.ConversationSync; using QSB.ElevatorSync; using QSB.GeyserSync; using QSB.ItemSync; +using QSB.Menus; using QSB.OrbSync; using QSB.Patches; using QSB.Player; @@ -69,6 +70,7 @@ namespace QSB public static bool IsInMultiplayer => QNetworkManager.singleton.isNetworkActive; public static string QSBVersion => Helper.Manifest.Version; public static GameObject GameObjectInstance => _thisInstance.gameObject; + public static IMenuAPI MenuApi { get; private set; } private static QSBCore _thisInstance; private const float _debugLineSpacing = 11f; @@ -89,6 +91,8 @@ namespace QSB Helper = ModHelper; DebugLog.ToConsole($"* Start of QSB version {Helper.Manifest.Version} - authored by {Helper.Manifest.Author}", MessageType.Info); + MenuApi = ModHelper.Interaction.GetModApi("_nebula.MenuFramework"); + NetworkAssetBundle = Helper.Assets.LoadBundle("assets/network"); InstrumentAssetBundle = Helper.Assets.LoadBundle("assets/instruments"); ConversationAssetBundle = Helper.Assets.LoadBundle("assets/conversation"); @@ -96,7 +100,7 @@ namespace QSB QSBPatchManager.Init(); gameObject.AddComponent(); - gameObject.AddComponent(); + //gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); @@ -104,6 +108,7 @@ namespace QSB gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); + gameObject.AddComponent(); // WorldObject managers gameObject.AddComponent(); diff --git a/QSB/manifest.json b/QSB/manifest.json index c84b03ae..9f226f2b 100644 --- a/QSB/manifest.json +++ b/QSB/manifest.json @@ -5,9 +5,10 @@ "description": "Adds online multiplayer to the game.", "warning": { "title": "Follow these steps before playing multiplayer :", - "body": "- Disable *all* other mods. (Can heavily affect performance)\n- Make sure you are not running any other network-intensive applications.\n- Make sure you have forwarded/opened the correct ports. (See the GitHub readme.)" + "body": "- Disable *all* other mods. (Can heavily affect performance)\n- Make sure you are not running any other network-intensive applications.\n- Make sure you have forwarded/opened the correct ports. (See the GitHub readme.)" }, "uniqueName": "Raicuparta.QuantumSpaceBuddies", "version": "0.11.0", - "owmlVersion": "1.1.8" + "owmlVersion": "1.1.8", + "dependencies": [ "_nebula.MenuFramework" ] } \ No newline at end of file diff --git a/QuantumUNET/QuantumUNET.csproj b/QuantumUNET/QuantumUNET.csproj index 4b0d8041..9f52e6c5 100644 --- a/QuantumUNET/QuantumUNET.csproj +++ b/QuantumUNET/QuantumUNET.csproj @@ -57,7 +57,7 @@ False - E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.PhysicsModule.dll + $(GameDir)\OuterWilds_Data\Managed\UnityEngine.PhysicsModule.dll False diff --git a/QuantumUNET/QuantumUNET.csproj.user b/QuantumUNET/QuantumUNET.csproj.user index ec6d119b..c8a11e84 100644 --- a/QuantumUNET/QuantumUNET.csproj.user +++ b/QuantumUNET/QuantumUNET.csproj.user @@ -1,7 +1,7 @@  - E:\Epic\Epic Games\OuterWilds + D:\EpicGames\OuterWilds C:\Users\Henry\AppData\Roaming\OuterWildsModManager\OWML ShowAllFiles