using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace TKS.OutGame
{
///
/// 외형(코스튬) 창(2026-11-20 개발요청_코스튬 §2 · 목업 영웅정보_img 04 · 05) — 영웅 화면 「외형」 버튼 · 무대(유닛 대기 + 착용 레이어 · 미리보기) ·
/// 부위 칸 4(외형 = 잠김 「추후」) · 고른 부위 꾸미기 칸(벗기 · 보유 ✓ · 미보유 자물쇠 + 얻는 곳 · 추가 예정) · 모두 벗기 · 적용(보유만) · 미보유 두 번 = 상세 창.
/// 미리보기 = 창을 닫으면 버림. 글자 = UI/Costume/costume_text · 값 = 표(C45).
///
public static class CostumeWindow
{
public const string Texts = "UI/Costume/costume_text";
const float W = 940f;
const float L = 34f;
const float RW = 872f;
const int GridCols = 4;
const int GridRows = 2;
static string heroId;
static string slotSel;
static Dictionary preview;
static string lastTapped;
/// 시험 · 캡처 — 마지막 창(costume · detail) · 지금 미리보기.
public static string Last { get; private set; }
public static Dictionary Preview
{
get { return preview; }
}
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
static void ResetStatics()
{
heroId = slotSel = lastTapped = Last = null;
preview = null;
}
static string T(string k)
{
return UiText.T(k).Replace("\\n", "\n");
}
static string F(string k, params string[] a)
{
return UiText.F(k, a).Replace("\\n", "\n");
}
static Text Txt(RectTransform p, string name, string s, int size, Color c, float x, float y, float w, float h, TextAnchor a = TextAnchor.MiddleLeft, bool title = false)
{
var t = UiKit.Label(p, s, size, c, a, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(x, -y), new Vector2(w, h), title);
t.name = name;
if (title) UiKit.Title(t, true);
t.horizontalOverflow = HorizontalWrapMode.Overflow;
return t;
}
static Image Box(RectTransform p, string name, float x, float y, float w, float h, Color c, bool raycast = false)
{
return UiKit.Skin(UiKit.At(p, name, x, y, w, h), "card", c, raycast);
}
static Button Btn(RectTransform p, string name, string skin, string label, int size, Color fg, float x, float y, float w, float h, Action onClick)
{
return UiKit.SkinBtn(p, name, UISkin.Has(skin) ? skin : "button", UiKit.White, label, size, fg, x, y, w, h, onClick);
}
static Color Grade(string rarity)
{
var db = CostumeView.Db;
return UiKit.Col("gear_" + (db != null ? db.RarityGrade(rarity) : "white") + "_bg", UiKit.Dark);
}
/// 영웅 화면 「외형」 — 새로 열면 미리보기 = 지금 착용 · 빨간 점 끔.
public static void Open(OutGameRoot root, string id)
{
heroId = id;
preview = CostumeRules.Worn(CostumeView.Db, root.Session.Save.Hero(id));
lastTapped = null;
if (root.Session.Save.costumeNew)
{
root.Session.Save.costumeNew = false;
root.Session.Commit();
}
Draw(root);
}
static void Step(OutGameRoot root, int d)
{
Open(root, root.HeroDetail.StepHero(d));
}
static void Draw(OutGameRoot root)
{
UiText.Use(Texts);
var s = root.Session;
var db = CostumeView.Db;
var h = s.Def(heroId);
if (db == null || h == null || h.isSoldier || s.Save.Hero(heroId) == null)
{
root.Toast(T("cos_none"));
return;
}
if (slotSel == null || db.SlotOf(slotSel) == null || !db.SlotOf(slotSel).open) slotSel = CostumeRules.DrawOrder(db).Count > 0 ? db.slots[0].slot : null;
if (GrowthUi.On)
{
Draw2(root, null);
return;
}
Last = "costume";
var content = root.ModalCustom(T("cos_title"), 1720f);
var panel = (RectTransform)content.parent;
foreach (var dd in new[] { -1, 1 })
{
int k = dd;
var b = Box(panel, dd < 0 ? "Prev" : "Next", W - (dd < 0 ? 300f : 216f), 26f, 72f, 72f, UiKit.Col("chip_dark", UiKit.Dark), true);
b.gameObject.AddComponent