101 lines
3.8 KiB
C#
101 lines
3.8 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Vanguard.UI
|
|
{
|
|
/// <summary>Общие элементы-заглушки: бейдж «скоро» и панель раздела.</summary>
|
|
public static class StubUi
|
|
{
|
|
public const string Soon = "скоро";
|
|
|
|
/// <summary>Бейдж «скоро» в правом верхнем углу родителя.</summary>
|
|
public static RectTransform Badge(Transform parent, Vector2 offset)
|
|
{
|
|
var go = new GameObject("SoonBadge", typeof(RectTransform), typeof(Image));
|
|
var rect = (RectTransform)go.transform;
|
|
rect.SetParent(parent, false);
|
|
rect.anchorMin = new Vector2(1f, 1f);
|
|
rect.anchorMax = new Vector2(1f, 1f);
|
|
rect.pivot = new Vector2(1f, 1f);
|
|
rect.sizeDelta = new Vector2(72f, 24f);
|
|
rect.anchoredPosition = offset;
|
|
|
|
var image = go.GetComponent<Image>();
|
|
image.sprite = NeonUi.Body(
|
|
72,
|
|
24,
|
|
12,
|
|
new Color(0.10f, 0.22f, 0.42f, 0.9f),
|
|
new Color(0.24f, 0.55f, 1f, 0.7f),
|
|
1);
|
|
image.type = Image.Type.Simple;
|
|
image.raycastTarget = false;
|
|
|
|
var text = UiKit.CreateText(
|
|
rect,
|
|
"Label",
|
|
Soon,
|
|
12,
|
|
new Color(0.66f, 0.82f, 1f),
|
|
TextAnchor.MiddleCenter);
|
|
UiKit.Stretch(text.rectTransform);
|
|
text.horizontalOverflow = HorizontalWrapMode.Overflow;
|
|
return rect;
|
|
}
|
|
|
|
/// <summary>Панель раздела, которого ещё нет на сервере.</summary>
|
|
public static RectTransform Panel(
|
|
Transform parent,
|
|
string name,
|
|
string title,
|
|
string note)
|
|
{
|
|
var root = new GameObject(name, typeof(RectTransform));
|
|
var rect = (RectTransform)root.transform;
|
|
rect.SetParent(parent, false);
|
|
UiKit.Stretch(rect);
|
|
|
|
var icon = new GameObject("Lock", typeof(RectTransform));
|
|
var iconRect = (RectTransform)icon.transform;
|
|
iconRect.SetParent(rect, false);
|
|
iconRect.anchorMin = new Vector2(0.5f, 0.5f);
|
|
iconRect.anchorMax = new Vector2(0.5f, 0.5f);
|
|
iconRect.pivot = new Vector2(0.5f, 0.5f);
|
|
iconRect.sizeDelta = new Vector2(64f, 64f);
|
|
iconRect.anchoredPosition = new Vector2(0f, 104f);
|
|
LobbyIcon.Lock(iconRect, new Color(0.36f, 0.56f, 0.9f, 0.9f));
|
|
|
|
var titleText = UiKit.CreateText(
|
|
rect,
|
|
"Title",
|
|
title,
|
|
26,
|
|
new Color(0.86f, 0.92f, 1f),
|
|
TextAnchor.MiddleCenter);
|
|
titleText.fontStyle = FontStyle.Bold;
|
|
var titleRect = titleText.rectTransform;
|
|
titleRect.anchorMin = new Vector2(0.5f, 0.5f);
|
|
titleRect.anchorMax = new Vector2(0.5f, 0.5f);
|
|
titleRect.pivot = new Vector2(0.5f, 0.5f);
|
|
titleRect.sizeDelta = new Vector2(560f, 40f);
|
|
titleRect.anchoredPosition = new Vector2(0f, 34f);
|
|
|
|
var noteText = UiKit.CreateText(
|
|
rect,
|
|
"Note",
|
|
note,
|
|
17,
|
|
new Color(0.58f, 0.68f, 0.86f),
|
|
TextAnchor.UpperCenter);
|
|
var noteRect = noteText.rectTransform;
|
|
noteRect.anchorMin = new Vector2(0.5f, 0.5f);
|
|
noteRect.anchorMax = new Vector2(0.5f, 0.5f);
|
|
noteRect.pivot = new Vector2(0.5f, 0.5f);
|
|
noteRect.sizeDelta = new Vector2(620f, 90f);
|
|
noteRect.anchoredPosition = new Vector2(0f, -42f);
|
|
|
|
return rect;
|
|
}
|
|
}
|
|
}
|