diff --git a/BSIPA-ModList/BSIPA-ModList.csproj b/BSIPA-ModList/BSIPA-ModList.csproj index 9eaa304b..c5185fea 100644 --- a/BSIPA-ModList/BSIPA-ModList.csproj +++ b/BSIPA-ModList/BSIPA-ModList.csproj @@ -51,12 +51,22 @@ ..\Refs\UnityEngine.CoreModule.dll False + + ..\Refs\UnityEngine.UI.dll + False + + + ..\Refs\UnityEngine.UIModule.dll + False + - - + + + + diff --git a/BSIPA-ModList/Plugin.cs b/BSIPA-ModList/Plugin.cs index 3eec9210..5de5c496 100644 --- a/BSIPA-ModList/Plugin.cs +++ b/BSIPA-ModList/Plugin.cs @@ -5,6 +5,8 @@ using CustomUI.BeatSaber; using BSIPA_ModList.UI; using CustomUI.MenuButton; using UnityEngine.Events; +using UnityEngine; +using System.Linq; namespace BSIPA_ModList { @@ -29,7 +31,8 @@ namespace BSIPA_ModList { } - private ModListMenu menu; + private MainFlowCoordinator mainFlow; + private ModListFlowCoordinator menuFlow; private MenuButton button; public void OnApplicationStart() @@ -43,14 +46,18 @@ namespace BSIPA_ModList public void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode) { - if (scene.name == "MenuCore" && button == null) + if (scene.name == "MenuCore") { - menu = BeatSaberUI.CreateCustomMenu("Installed Mods"); - button = MenuButtonUI.AddButton("All Mods", "Shows all installed mods, along with controls for updating them.", () => - { - Logger.log.Debug("Presenting menu"); - menu.Present(); - }); + if (mainFlow == null) + mainFlow = Resources.FindObjectsOfTypeAll().First(); + if (menuFlow == null) + menuFlow = new GameObject("BSIPA Mod List Flow Coordinator").AddComponent(); + if (button == null) + button = MenuButtonUI.AddButton("Mod List", "Look at installed mods, and control updating", () => + { + Logger.log.Debug("Presenting own flow controller"); + menuFlow.PresentOn(mainFlow); + }); } } diff --git a/BSIPA-ModList/UI/ModListFlowCoordinator.cs b/BSIPA-ModList/UI/ModListFlowCoordinator.cs new file mode 100644 index 00000000..f339bdfd --- /dev/null +++ b/BSIPA-ModList/UI/ModListFlowCoordinator.cs @@ -0,0 +1,58 @@ +using CustomUI.BeatSaber; +using CustomUI.Utilities; +using IPA.Loader; +using System; +using System.Linq; +using System.Reflection; +using UnityEngine; +using VRUI; + +namespace BSIPA_ModList.UI +{ + internal class ModListFlowCoordinator : FlowCoordinator + { + private BackButtonNavigationController navigationController; + private ModListController modList; + +#pragma warning disable CS0618 + protected override void DidActivate(bool firstActivation, ActivationType activationType) + { // thx Caeden + if (firstActivation && activationType == ActivationType.AddedToHierarchy) + { + title = "Installed Mods"; + + navigationController = BeatSaberUI.CreateViewController(); + navigationController.didFinishEvent += backButton_DidFinish; + + modList = BeatSaberUI.CreateViewController(); + modList.Init(navigationController, PluginManager.AllPlugins, PluginLoader.ignoredPlugins, PluginManager.Plugins); + + PushViewControllerToNavigationController(navigationController, modList); + } + + ProvideInitialViewControllers(navigationController); + } +#pragma warning restore + + private delegate void PresentFlowCoordDel(FlowCoordinator self, FlowCoordinator newF, Action finished, bool immediate, bool replaceTop); + private static PresentFlowCoordDel presentFlow; + + public void PresentOn(FlowCoordinator main, Action finished = null, bool immediate = false, bool replaceTop = false) + { + if (presentFlow == null) + { + var ty = typeof(FlowCoordinator); + var m = ty.GetMethod("PresentFlowCoordinator", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + presentFlow = (PresentFlowCoordDel)Delegate.CreateDelegate(typeof(PresentFlowCoordDel), m); + } + + presentFlow(main, this, finished, immediate, replaceTop); + } + + private void backButton_DidFinish() + { + MainFlowCoordinator mainFlow = Resources.FindObjectsOfTypeAll().First(); + mainFlow.InvokeMethod("DismissFlowCoordinator", this, null, false); + } + } +} diff --git a/BSIPA-ModList/UI/ModListMenu.cs b/BSIPA-ModList/UI/ModListMenu.cs deleted file mode 100644 index 9d1af08f..00000000 --- a/BSIPA-ModList/UI/ModListMenu.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CustomUI.BeatSaber; -using IPA.Loader; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BSIPA_ModList.UI -{ - internal class ModListMenu : CustomMenu - { - private ModListController controller; - -#pragma warning disable CS0618 - public ModListMenu() - { - Logger.log.Debug("Menu constructor"); - - controller = BeatSaberUI.CreateViewController(); - controller.Init(PluginManager.AllPlugins, PluginLoader.ignoredPlugins, PluginManager.Plugins); - SetMainViewController(controller, true); - } -#pragma warning restore - } -} diff --git a/BSIPA-ModList/UI/ViewControllers/BackButtonNavigationController.cs b/BSIPA-ModList/UI/ViewControllers/BackButtonNavigationController.cs new file mode 100644 index 00000000..7c73beb0 --- /dev/null +++ b/BSIPA-ModList/UI/ViewControllers/BackButtonNavigationController.cs @@ -0,0 +1,22 @@ +using CustomUI.BeatSaber; +using System; +using UnityEngine.UI; +using VRUI; + +namespace BSIPA_ModList.UI +{ + internal class BackButtonNavigationController : VRUINavigationController + { + public event Action didFinishEvent; + + private Button _backButton; + + protected override void DidActivate(bool firstActivation, ActivationType activationType) + { + if (firstActivation && activationType == ActivationType.AddedToHierarchy) + { + _backButton = BeatSaberUI.CreateBackButton(rectTransform, didFinishEvent.Invoke); + } + } + } +} \ No newline at end of file diff --git a/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs b/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs new file mode 100644 index 00000000..60cde929 --- /dev/null +++ b/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs @@ -0,0 +1,14 @@ +using CustomUI.BeatSaber; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BSIPA_ModList.UI +{ + internal class ModInfoViewController : CustomViewController + { + + } +} diff --git a/BSIPA-ModList/UI/ModListController.cs b/BSIPA-ModList/UI/ViewControllers/ModListController.cs similarity index 93% rename from BSIPA-ModList/UI/ModListController.cs rename to BSIPA-ModList/UI/ViewControllers/ModListController.cs index 55218d97..f80a887a 100644 --- a/BSIPA-ModList/UI/ModListController.cs +++ b/BSIPA-ModList/UI/ViewControllers/ModListController.cs @@ -6,6 +6,7 @@ using HMUI; using IPA.Loader; using IPA.Old; using UnityEngine; +using VRUI; namespace BSIPA_ModList.UI { @@ -99,8 +100,10 @@ namespace BSIPA_ModList.UI } #pragma warning restore + private BackButtonNavigationController navigation; + #pragma warning disable CS0618 - public void Init(IEnumerable bsipaPlugins, IEnumerable ignoredPlugins, IEnumerable ipaPlugins) + public void Init(BackButtonNavigationController navigation, IEnumerable bsipaPlugins, IEnumerable ignoredPlugins, IEnumerable ipaPlugins) { Logger.log.Debug("List Controller Init"); @@ -108,6 +111,7 @@ namespace BSIPA_ModList.UI DidSelectRowEvent = DidSelectRow; includePageButtons = true; + this.navigation = navigation; reuseIdentifier = "BSIPAModListTableCell"; diff --git a/Refs/UnityEngine.UI.dll b/Refs/UnityEngine.UI.dll new file mode 100644 index 00000000..7e63d157 Binary files /dev/null and b/Refs/UnityEngine.UI.dll differ diff --git a/Refs/UnityEngine.UIModule.dll b/Refs/UnityEngine.UIModule.dll new file mode 100644 index 00000000..5dd5d149 Binary files /dev/null and b/Refs/UnityEngine.UIModule.dll differ diff --git a/Refs/UnityEngine.UIModule.xml b/Refs/UnityEngine.UIModule.xml new file mode 100644 index 00000000..b3e5081a --- /dev/null +++ b/Refs/UnityEngine.UIModule.xml @@ -0,0 +1,548 @@ + + + + + UnityEngine.UIModule + + + + Enum mask of possible shader channel properties that can also be included when the Canvas mesh is created. + + + + + No additional shader parameters are needed. + + + + + Include the normals on the mesh vertices. + + + + + Include the Tangent on the mesh vertices. + + + + + Include UV1 on the mesh vertices. + + + + + Include UV2 on the mesh vertices. + + + + + Include UV3 on the mesh vertices. + + + + + Element that can be used for screen rendering. + + + + + Get or set the mask of additional shader channels to be used when creating the Canvas mesh. + + + + + Cached calculated value based upon SortingLayerID. + + + + + Is this the root Canvas? + + + + + The normalized grid size that the canvas will split the renderable area into. + + + + + Allows for nested canvases to override pixelPerfect settings inherited from parent canvases. + + + + + Override the sorting of canvas. + + + + + Force elements in the canvas to be aligned with pixels. Only applies with renderMode is Screen Space. + + + + + Get the render rect for the Canvas. + + + + + How far away from the camera is the Canvas generated. + + + + + The number of pixels per unit that is considered the default. + + + + + Is the Canvas in World or Overlay mode? + + + + + The render order in which the canvas is being emitted to the Scene. (Read Only) + + + + + Returns the Canvas closest to root, by checking through each parent and returning the last canvas found. If no other canvas is found then the canvas will return itself. + + + + + Used to scale the entire canvas, while still making it fit the screen. Only applies with renderMode is Screen Space. + + + + + The normalized grid size that the canvas will split the renderable area into. + + + + + Unique ID of the Canvas' sorting layer. + + + + + Name of the Canvas' sorting layer. + + + + + Canvas' order within a sorting layer. + + + + + For Overlay mode, display index on which the UI canvas will appear. + + + + + Event that is called just before Canvas rendering happens. + + + + + + Camera used for sizing the Canvas when in Screen Space - Camera. Also used as the Camera that events will be sent through for a World Space [[Canvas]. + + + + + Force all canvases to update their content. + + + + + Returns the default material that can be used for rendering normal elements on the Canvas. + + + + + Returns the default material that can be used for rendering text elements on the Canvas. + + + + + Gets or generates the ETC1 Material. + + + The generated ETC1 Material from the Canvas. + + + + + A Canvas placable element that can be used to modify children Alpha, Raycasting, Enabled state. + + + + + Set the alpha of the group. + + + + + Does this group block raycasting (allow collision). + + + + + Should the group ignore parent groups? + + + + + Is the group interactable (are the elements beneath the group enabled). + + + + + Returns true if the Group allows raycasts. + + + + + + + A component that will render to the screen after all normal rendering has completed when attached to a Canvas. Designed for GUI application. + + + + + Depth of the renderer relative to the root canvas. + + + + + Indicates whether geometry emitted by this renderer is ignored. + + + + + Indicates whether geometry emitted by this renderer can be ignored when the vertex color alpha is close to zero for every vertex of the mesh. + + + + + True if any change has occured that would invalidate the positions of generated geometry. + + + + + Enable 'render stack' pop draw call. + + + + + True if rect clipping has been enabled on this renderer. +See Also: CanvasRenderer.EnableRectClipping, CanvasRenderer.DisableRectClipping. + + + + + Is the UIRenderer a mask component. + + + + + The number of materials usable by this renderer. + + + + + The number of materials usable by this renderer. Used internally for masking. + + + + + Depth of the renderer realative to the parent canvas. + + + + + Take the Vertex steam and split it corrisponding arrays (positions, colors, uv0s, uv1s, normals and tangents). + + The UIVertex list to split. + The destination list for the verts positions. + The destination list for the verts colors. + The destination list for the verts uv0s. + The destination list for the verts uv1s. + The destination list for the verts normals. + The destination list for the verts tangents. + + + + Remove all cached vertices. + + + + + Convert a set of vertex components into a stream of UIVertex. + + + + + + + + + + + + + Disables rectangle clipping for this CanvasRenderer. + + + + + Enables rect clipping on the CanvasRendered. Geometry outside of the specified rect will be clipped (not rendered). + + + + + + Get the current alpha of the renderer. + + + + + Get the current color of the renderer. + + + + + Get the final inherited alpha calculated by including all the parent alphas from included parent CanvasGroups. + + + The calculated inherited alpha. + + + + + Gets the current Material assigned to the CanvasRenderer. + + The material index to retrieve (0 if this parameter is omitted). + + Result. + + + + + Gets the current Material assigned to the CanvasRenderer. + + The material index to retrieve (0 if this parameter is omitted). + + Result. + + + + + Gets the current Material assigned to the CanvasRenderer. Used internally for masking. + + + + + + Set the alpha of the renderer. Will be multiplied with the UIVertex alpha and the Canvas alpha. + + Alpha. + + + + The Alpha Texture that will be passed to the Shader under the _AlphaTex property. + + The Texture to be passed. + + + + Set the color of the renderer. Will be multiplied with the UIVertex color and the Canvas color. + + Renderer multiply color. + + + + Set the material for the canvas renderer. If a texture is specified then it will be used as the 'MainTex' instead of the material's 'MainTex'. +See Also: CanvasRenderer.SetMaterialCount, CanvasRenderer.SetTexture. + + Material for rendering. + Material texture overide. + Material index. + + + + Set the material for the canvas renderer. If a texture is specified then it will be used as the 'MainTex' instead of the material's 'MainTex'. +See Also: CanvasRenderer.SetMaterialCount, CanvasRenderer.SetTexture. + + Material for rendering. + Material texture overide. + Material index. + + + + Sets the Mesh used by this renderer. + + + + + + Set the material for the canvas renderer. Used internally for masking. + + + + + + + Sets the texture used by this renderer's material. + + + + + + Set the vertices for the UIRenderer. + + Array of vertices to set. + Number of vertices to set. + + + + Set the vertices for the UIRenderer. + + Array of vertices to set. + Number of vertices to set. + + + + Given a list of UIVertex, split the stream into it's component types. + + + + + + + + + + + + + This element can filter raycasts. If the top level element is hit it can further 'check' if the location is valid. + + + + + Given a point and a camera is the raycast valid. + + Screen position. + Raycast camera. + + Valid. + + + + + Utility class containing helper methods for working with RectTransform. + + + + + Flips the horizontal and vertical axes of the RectTransform size and alignment, and optionally its children as well. + + The RectTransform to flip. + Flips around the pivot if true. Flips within the parent rect if false. + Flip the children as well? + + + + Flips the alignment of the RectTransform along the horizontal or vertical axis, and optionally its children as well. + + The RectTransform to flip. + Flips around the pivot if true. Flips within the parent rect if false. + Flip the children as well? + The axis to flip along. 0 is horizontal and 1 is vertical. + + + + Convert a given point in screen space into a pixel correct point. + + + + + + Pixel adjusted point. + + + + + Given a rect transform, return the corner points in pixel accurate coordinates. + + + + + Pixel adjusted rect. + + + + + Does the RectTransform contain the screen point as seen from the given camera? + + The RectTransform to test with. + The screen point to test. + The camera from which the test is performed from. (Optional) + + True if the point is inside the rectangle. + + + + + Transform a screen space point to a position in the local space of a RectTransform that is on the plane of its rectangle. + + The RectTransform to find a point inside. + The camera associated with the screen space position. + Screen space position. + Point in local space of the rect transform. + + Returns true if the plane of the RectTransform is hit, regardless of whether the point is inside the rectangle. + + + + + Transform a screen space point to a position in world space that is on the plane of the given RectTransform. + + The RectTransform to find a point inside. + The camera associated with the screen space position. + Screen space position. + Point in world space. + + Returns true if the plane of the RectTransform is hit, regardless of whether the point is inside the rectangle. + + + + + RenderMode for the Canvas. + + + + + Render using the Camera configured on the Canvas. + + + + + Render at the end of the Scene using a 2D Canvas. + + + + + Render using any Camera in the Scene that can render the layer. + + + + + The UI module implements basic components required for Unity's UI system + + + + diff --git a/Refs/refs.txt b/Refs/refs.txt index a9387a7a..3818beda 100644 --- a/Refs/refs.txt +++ b/Refs/refs.txt @@ -9,6 +9,11 @@ """"CoreModule. """""dll """""xml +""""UI +""""".dll +"""""Module. +""""""dll +""""""xml "Plugins/ ""BeatSaberCustomUI. """dll