Browse Source

Continued tweaks to UI

pull/46/head
Anairkoen Schno 5 years ago
parent
commit
35a639c934
6 changed files with 103 additions and 10 deletions
  1. +3
    -0
      BSIPA-ModList/BSIPA-ModList.csproj
  2. +21
    -1
      BSIPA-ModList/UI/ModListFlowCoordinator.cs
  3. +67
    -6
      BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs
  4. +11
    -3
      BSIPA-ModList/UI/ViewControllers/ModListController.cs
  5. BIN
      Refs/Unity.TextMeshPro.dll
  6. +1
    -0
      Refs/refs.txt

+ 3
- 0
BSIPA-ModList/BSIPA-ModList.csproj View File

@ -47,6 +47,9 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Unity.TextMeshPro">
<HintPath>..\Refs\Unity.TextMeshPro.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\Refs\UnityEngine.dll</HintPath>
</Reference>


+ 21
- 1
BSIPA-ModList/UI/ModListFlowCoordinator.cs View File

@ -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)


+ 67
- 6
BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs View File

@ -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<ModInfoView>();
view.gameObject.AddComponent<RectMask2D>();
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} <size=60%>{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);
}
}
}

+ 11
- 3
BSIPA-ModList/UI/ViewControllers/ModListController.cs View File

@ -58,11 +58,11 @@ namespace BSIPA_ModList.UI
if (infoView == null)
{
infoView = BeatSaberUI.CreateViewController<ModInfoViewController>();
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);
}
}
}

BIN
Refs/Unity.TextMeshPro.dll View File


+ 1
- 0
Refs/refs.txt View File

@ -2,6 +2,7 @@
"Beat Saber_Data/
""Managed/
"""Assembly-CSharp.dll
"""Unity.TextMeshPro.dll
"""UnityEngine.
""""dll
""""xml


Loading…
Cancel
Save