|
@ -1,4 +1,5 @@ |
|
|
using CustomUI.BeatSaber; |
|
|
using CustomUI.BeatSaber; |
|
|
|
|
|
using CustomUI.Utilities; |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
@ -24,6 +25,8 @@ namespace BSIPA_ModList.UI |
|
|
|
|
|
|
|
|
public void Init(Sprite icon, string name, string version, string author, string description, bool canUpdate) |
|
|
public void Init(Sprite icon, string name, string version, string author, string description, bool canUpdate) |
|
|
{ |
|
|
{ |
|
|
|
|
|
Logger.log.Debug($"init info view controller"); |
|
|
|
|
|
|
|
|
Icon = icon; |
|
|
Icon = icon; |
|
|
Name = name; |
|
|
Name = name; |
|
|
Version = version; |
|
|
Version = version; |
|
@ -31,19 +34,20 @@ namespace BSIPA_ModList.UI |
|
|
Description = description; |
|
|
Description = description; |
|
|
CanUpdate = canUpdate; |
|
|
CanUpdate = canUpdate; |
|
|
|
|
|
|
|
|
|
|
|
// i also have no clue why this is necessary
|
|
|
rectTransform.anchorMin = new Vector2(0f, 0f); |
|
|
rectTransform.anchorMin = new Vector2(0f, 0f); |
|
|
rectTransform.anchorMax = new Vector2(0.4f, 1f); |
|
|
|
|
|
|
|
|
rectTransform.anchorMax = new Vector2(0.5f, 1f); |
|
|
|
|
|
|
|
|
var go = new GameObject("Info View"); |
|
|
|
|
|
|
|
|
var go = new GameObject("Info View", typeof(RectTransform)); |
|
|
go.SetActive(false); |
|
|
go.SetActive(false); |
|
|
|
|
|
go.AddComponent<RectMask2D>(); |
|
|
view = go.AddComponent<ModInfoView>(); |
|
|
view = go.AddComponent<ModInfoView>(); |
|
|
view.gameObject.AddComponent<RectMask2D>(); |
|
|
|
|
|
view.Init(this); |
|
|
|
|
|
var rt = view.transform as RectTransform; |
|
|
var rt = view.transform as RectTransform; |
|
|
rt.SetParent(transform); |
|
|
rt.SetParent(transform); |
|
|
rt.anchorMin = new Vector2(0f, 0f); |
|
|
rt.anchorMin = new Vector2(0f, 0f); |
|
|
rt.anchorMax = new Vector2(1f, 1f); |
|
|
rt.anchorMax = new Vector2(1f, 1f); |
|
|
rt.anchoredPosition = new Vector2(0.2f, 0f); |
|
|
|
|
|
|
|
|
rt.anchoredPosition = new Vector2(0f, 0f); |
|
|
|
|
|
view.Init(this); |
|
|
go.SetActive(true); |
|
|
go.SetActive(true); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -55,38 +59,165 @@ namespace BSIPA_ModList.UI |
|
|
private TextMeshProUGUI titleText; |
|
|
private TextMeshProUGUI titleText; |
|
|
private TextMeshProUGUI authorText; |
|
|
private TextMeshProUGUI authorText; |
|
|
private TextMeshProUGUI descText; |
|
|
private TextMeshProUGUI descText; |
|
|
|
|
|
private Image icon; |
|
|
|
|
|
|
|
|
public void Init(ModInfoViewController controller) |
|
|
public void Init(ModInfoViewController controller) |
|
|
{ |
|
|
{ |
|
|
|
|
|
Logger.log.Debug($"init info view"); |
|
|
this.controller = controller; |
|
|
this.controller = controller; |
|
|
|
|
|
|
|
|
var rectTransform = transform as RectTransform; |
|
|
var rectTransform = transform as RectTransform; |
|
|
rectTransform.sizeDelta = new Vector2(60f, 10f); |
|
|
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 = BeatSaberUI.CreateText(rectTransform, $"{controller.Name} <size=60%>{controller.Version}", new Vector2(11f, 27.5f)); |
|
|
titleText.fontSize = 6f; |
|
|
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); |
|
|
|
|
|
|
|
|
authorText = BeatSaberUI.CreateText(rectTransform, controller.Author, new Vector2(11f, 22f)); |
|
|
|
|
|
authorText.fontSize = 4.5f; |
|
|
|
|
|
descText = BeatSaberUI.CreateText(rectTransform, controller.Description, new Vector2(-4.5f, 12.5f)); |
|
|
|
|
|
descText.enableWordWrapping = true; |
|
|
|
|
|
descText.overflowMode = TextOverflowModes.ScrollRect; |
|
|
|
|
|
|
|
|
|
|
|
icon = new GameObject("Mod Info View Icon", typeof(RectTransform)).AddComponent<Image>(); |
|
|
|
|
|
icon.gameObject.SetActive(false); |
|
|
|
|
|
icon.rectTransform.SetParent(rectTransform, false); |
|
|
|
|
|
icon.rectTransform.anchorMin = new Vector2(0.5f, 0.44f); |
|
|
|
|
|
icon.rectTransform.anchorMax = new Vector2(0.5f, 0.5f); |
|
|
|
|
|
icon.rectTransform.sizeDelta = new Vector2(60f, 10f); |
|
|
|
|
|
icon.rectTransform.anchoredPosition = new Vector2(-27.8f, 27.3f); |
|
|
|
|
|
icon.sprite = controller.Icon; |
|
|
|
|
|
icon.preserveAspect = true; |
|
|
|
|
|
icon.useSpriteMesh = true; |
|
|
|
|
|
icon.material = UIUtilities.NoGlowMaterial; |
|
|
|
|
|
icon.gameObject.SetActive(true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void OnUpdate() |
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
|
#if ADJUST_INFO_TEXT_UI_KEYS
|
|
|
|
|
|
private int currentItem = 0; |
|
|
|
|
|
#endif
|
|
|
|
|
|
public void Update() |
|
|
{ |
|
|
{ |
|
|
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); |
|
|
|
|
|
|
|
|
#if ADJUST_INFO_TEXT_UI_KEYS
|
|
|
|
|
|
RectTransform rt; |
|
|
|
|
|
switch (currentItem) |
|
|
|
|
|
{ |
|
|
|
|
|
default: |
|
|
|
|
|
currentItem = 0; |
|
|
|
|
|
goto case 0; // idk why this is needed tbh
|
|
|
|
|
|
case 0: |
|
|
|
|
|
rt = titleText.rectTransform; |
|
|
|
|
|
break; |
|
|
|
|
|
case 1: |
|
|
|
|
|
rt = authorText.rectTransform; |
|
|
|
|
|
break; |
|
|
|
|
|
case 2: |
|
|
|
|
|
rt = descText.rectTransform; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.N)) |
|
|
|
|
|
currentItem++; |
|
|
|
|
|
|
|
|
|
|
|
var cpos = rt.anchoredPosition; |
|
|
|
|
|
if (Input.GetKey(KeyCode.LeftArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchoredPosition = new Vector2(cpos.x - .1f, cpos.y); |
|
|
|
|
|
} |
|
|
|
|
|
else if (Input.GetKey(KeyCode.RightArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchoredPosition = new Vector2(cpos.x + .1f, cpos.y); |
|
|
|
|
|
} |
|
|
|
|
|
else if (Input.GetKey(KeyCode.UpArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchoredPosition = new Vector2(cpos.x, cpos.y + .1f); |
|
|
|
|
|
} |
|
|
|
|
|
else if (Input.GetKey(KeyCode.DownArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchoredPosition = new Vector2(cpos.x, cpos.y - .1f); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
Logger.log.Debug($"Position now at {rt.anchoredPosition}"); |
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
var rt = icon.rectTransform; |
|
|
|
|
|
if (Input.GetKey(KeyCode.Z)) |
|
|
|
|
|
{ // adjust anchormin
|
|
|
|
|
|
var cpos = rt.anchorMin; |
|
|
|
|
|
if (Input.GetKey(KeyCode.LeftArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchorMin = new Vector2(cpos.x - .001f, cpos.y); |
|
|
|
|
|
} |
|
|
|
|
|
else if (Input.GetKey(KeyCode.RightArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchorMin = new Vector2(cpos.x + .001f, cpos.y); |
|
|
|
|
|
} |
|
|
|
|
|
else if (Input.GetKey(KeyCode.UpArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchorMin = new Vector2(cpos.x, cpos.y + .001f); |
|
|
|
|
|
} |
|
|
|
|
|
else if (Input.GetKey(KeyCode.DownArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchorMin = new Vector2(cpos.x, cpos.y - .001f); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
Logger.log.Debug($"Anchor min now at {rt.anchorMin}"); |
|
|
|
|
|
} |
|
|
|
|
|
else if(Input.GetKey(KeyCode.X)) |
|
|
|
|
|
{ // adjust anchorMax
|
|
|
|
|
|
var cpos = rt.anchorMax; |
|
|
|
|
|
if (Input.GetKey(KeyCode.LeftArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchorMax = new Vector2(cpos.x - .001f, cpos.y); |
|
|
|
|
|
} |
|
|
|
|
|
else if (Input.GetKey(KeyCode.RightArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchorMax = new Vector2(cpos.x + .001f, cpos.y); |
|
|
|
|
|
} |
|
|
|
|
|
else if (Input.GetKey(KeyCode.UpArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchorMax = new Vector2(cpos.x, cpos.y + .001f); |
|
|
|
|
|
} |
|
|
|
|
|
else if (Input.GetKey(KeyCode.DownArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchorMax = new Vector2(cpos.x, cpos.y - .001f); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
Logger.log.Debug($"Anchor max now at {rt.anchorMax}"); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
var cpos = rt.anchoredPosition; |
|
|
|
|
|
if (Input.GetKey(KeyCode.LeftArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchoredPosition = new Vector2(cpos.x - .1f, cpos.y); |
|
|
|
|
|
} |
|
|
|
|
|
else if (Input.GetKey(KeyCode.RightArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchoredPosition = new Vector2(cpos.x + .1f, cpos.y); |
|
|
|
|
|
} |
|
|
|
|
|
else if (Input.GetKey(KeyCode.UpArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchoredPosition = new Vector2(cpos.x, cpos.y + .1f); |
|
|
|
|
|
} |
|
|
|
|
|
else if (Input.GetKey(KeyCode.DownArrow)) |
|
|
|
|
|
{ |
|
|
|
|
|
rt.anchoredPosition = new Vector2(cpos.x, cpos.y - .1f); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
Logger.log.Debug($"Position now at {rt.anchoredPosition}"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
#endif
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |