diff --git a/BSIPA-ModList/BSIPA-ModList.csproj b/BSIPA-ModList/BSIPA-ModList.csproj index c0c14007..d644b784 100644 --- a/BSIPA-ModList/BSIPA-ModList.csproj +++ b/BSIPA-ModList/BSIPA-ModList.csproj @@ -47,6 +47,9 @@ + + ..\Refs\Unity.TextMeshPro.dll + ..\Refs\UnityEngine.dll diff --git a/BSIPA-ModList/UI/ModListFlowCoordinator.cs b/BSIPA-ModList/UI/ModListFlowCoordinator.cs index ab09b76d..61f1482e 100644 --- a/BSIPA-ModList/UI/ModListFlowCoordinator.cs +++ b/BSIPA-ModList/UI/ModListFlowCoordinator.cs @@ -55,22 +55,42 @@ namespace BSIPA_ModList.UI { if (immediate) { + Logger.log.Debug("setting selected immediately"); if (HasSelected) + { + Logger.log.Debug("popping vc"); PopViewController(immediate: true); + } + Logger.log.Debug("pushing vc"); PushViewController(selected, callback, true); + HasSelected = true; } else { + Logger.log.Debug("setting selected"); if (HasSelected) - PopViewController(() => PushViewController(selected, callback, immediate), immediate); + { + Logger.log.Debug("popping vc"); + PopViewController(() => + { + Logger.log.Debug("pushing vc"); + PushViewController(selected, callback, immediate); + HasSelected = true; + }, immediate); + } else + { + Logger.log.Debug("pushing vc"); PushViewController(selected, callback, immediate); + HasSelected = true; + } } } public void ClearSelected(Action callback = null, bool immediate = false) { if (HasSelected) PopViewController(callback, immediate); + HasSelected = false; } public void PushViewController(VRUIViewController controller, Action callback = null, bool immediate = false) diff --git a/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs b/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs index 2479627c..c9afbc9d 100644 --- a/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs +++ b/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs @@ -4,19 +4,23 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using TMPro; using UnityEngine; +using UnityEngine.UI; using VRUI; namespace BSIPA_ModList.UI { internal class ModInfoViewController : VRUIViewController { - private Sprite Icon; - private string Name; - private string Version; - private string Author; - private string Description; - private bool CanUpdate; + internal Sprite Icon; + internal string Name; + internal string Version; + internal string Author; + internal string Description; + internal bool CanUpdate; + + private ModInfoView view; public void Init(Sprite icon, string name, string version, string author, string description, bool canUpdate) { @@ -26,6 +30,63 @@ namespace BSIPA_ModList.UI Author = author; Description = description; CanUpdate = canUpdate; + + rectTransform.anchorMin = new Vector2(0f, 0f); + rectTransform.anchorMax = new Vector2(0.4f, 1f); + + var go = new GameObject("Info View"); + go.SetActive(false); + view = go.AddComponent(); + view.gameObject.AddComponent(); + view.Init(this); + var rt = view.transform as RectTransform; + rt.SetParent(transform); + rt.anchorMin = new Vector2(0f, 0f); + rt.anchorMax = new Vector2(1f, 1f); + rt.anchoredPosition = new Vector2(0.2f, 0f); + go.SetActive(true); + } + } + + internal class ModInfoView : MonoBehaviour + { + private ModInfoViewController controller; + + private TextMeshProUGUI titleText; + private TextMeshProUGUI authorText; + private TextMeshProUGUI descText; + + public void Init(ModInfoViewController controller) + { + this.controller = controller; + + var rectTransform = transform as RectTransform; + rectTransform.sizeDelta = new Vector2(60f, 10f); + + titleText = BeatSaberUI.CreateText(rectTransform, $"{controller.Name} {controller.Version}", new Vector2(0f, 0f)); + titleText.rectTransform.anchorMin = new Vector2(0f, .8f); + titleText.rectTransform.anchorMax = new Vector2(1f, 1f); + titleText.fontSize = 6f; + authorText = BeatSaberUI.CreateText(rectTransform, controller.Author, new Vector2(0f, 0f)); + titleText.rectTransform.anchorMin = new Vector2(0f, .6f); + titleText.rectTransform.anchorMax = new Vector2(1f, .8f); + authorText.fontSize = 3f; + descText = BeatSaberUI.CreateText(rectTransform, controller.Description, new Vector2(0f, 0f)); + descText.rectTransform.anchorMin = new Vector2(0f, .0f); + descText.rectTransform.anchorMax = new Vector2(1f, .6f); + } + + public void OnUpdate() + { + var cpos = titleText.rectTransform.anchoredPosition; + if (Input.GetKeyDown(KeyCode.LeftArrow)) + titleText.rectTransform.anchoredPosition = new Vector2(cpos.x - .1f, cpos.y); + if (Input.GetKeyDown(KeyCode.RightArrow)) + titleText.rectTransform.anchoredPosition = new Vector2(cpos.x + .1f, cpos.y); + if (Input.GetKeyDown(KeyCode.UpArrow)) + titleText.rectTransform.anchoredPosition = new Vector2(cpos.x, cpos.y + .1f); + if (Input.GetKeyDown(KeyCode.DownArrow)) + titleText.rectTransform.anchoredPosition = new Vector2(cpos.x, cpos.y - .1f); } } } diff --git a/BSIPA-ModList/UI/ViewControllers/ModListController.cs b/BSIPA-ModList/UI/ViewControllers/ModListController.cs index 801851bf..e96bb98b 100644 --- a/BSIPA-ModList/UI/ViewControllers/ModListController.cs +++ b/BSIPA-ModList/UI/ViewControllers/ModListController.cs @@ -58,11 +58,11 @@ namespace BSIPA_ModList.UI if (infoView == null) { infoView = BeatSaberUI.CreateViewController(); - infoView.Init(icon, Plugin.Metadata.Name, Plugin.Metadata.Version.ToString(), Plugin.Metadata.Manifest.Author, + infoView.Init(icon, Plugin.Metadata.Name, "v" + Plugin.Metadata.Version.ToString(), Plugin.Metadata.Manifest.Author, Plugin.Metadata.Manifest.Description, Plugin.Metadata.Features.FirstOrDefault(f => f is NoUpdateFeature) == null); } - list.flow.SetSelected(infoView); + list.flow.SetSelected(infoView, immediate: list.flow.HasSelected); } } @@ -84,6 +84,7 @@ namespace BSIPA_ModList.UI { Logger.log.Debug($"Selected BSIPAIgnoredModCell {Plugin.Name} {Plugin.Version}"); + list.flow.ClearSelected(); } } @@ -116,6 +117,8 @@ namespace BSIPA_ModList.UI public void OnSelect(ModListController cntrl) { Logger.log.Debug($"Selected IPAModCell {Plugin.Name} {Plugin.Version}"); + + list.flow.ClearSelected(); } } #pragma warning restore @@ -130,6 +133,9 @@ namespace BSIPA_ModList.UI DidActivateEvent = DidActivate; DidSelectRowEvent = DidSelectRow; + rectTransform.anchorMin = new Vector2(0f, 0f); + rectTransform.anchorMax = new Vector2(.4f, 1f); + includePageButtons = true; this.flow = flow; @@ -153,7 +159,9 @@ namespace BSIPA_ModList.UI private new void DidActivate(bool first, ActivationType type) { - + var rt = _customListTableView.transform as RectTransform; + rt.anchorMin = new Vector2(.1f, 0f); + rt.anchorMax = new Vector2(.9f, 1f); } } } diff --git a/Refs/Unity.TextMeshPro.dll b/Refs/Unity.TextMeshPro.dll new file mode 100644 index 00000000..56123d46 Binary files /dev/null and b/Refs/Unity.TextMeshPro.dll differ diff --git a/Refs/refs.txt b/Refs/refs.txt index 9554dac9..1a3c7067 100644 --- a/Refs/refs.txt +++ b/Refs/refs.txt @@ -2,6 +2,7 @@ "Beat Saber_Data/ ""Managed/ """Assembly-CSharp.dll +"""Unity.TextMeshPro.dll """UnityEngine. """"dll """"xml