using System.Collections.Generic; using System.Globalization; using UnityEngine; namespace TKS.OutGame { /// /// 화면 설정 표(키 · 값 · 같은 키 여러 줄 = 목록 · 값 안 | = 칸) — 투기장(ArenaLeague)과 같은 형식을 편성 · 영웅 정보 배경이 같이 쓴다(C45 · 좌표·색·그림 경로는 표에만). /// public class ScreenTable { readonly Dictionary> kv = new Dictionary>(); /// Resources 경로(확장자 없음)의 표를 읽는다 · 없으면 null. public static ScreenTable Load(string path) { var rows = UiText.Rows(path); if (rows == null) return null; var t = new ScreenTable(); foreach (var r in rows) { string k, v; if (!r.TryGetValue("s_key", out k) || string.IsNullOrEmpty(k)) continue; r.TryGetValue("s_value", out v); List l; if (!t.kv.TryGetValue(k, out l)) t.kv[k] = l = new List(); l.Add(v ?? ""); } return t; } public bool Has(string key) { return kv.ContainsKey(key); } public string S(string key, string def = "") { List l; return kv.TryGetValue(key, out l) && l.Count > 0 && l[0].Length > 0 ? l[0] : def; } public string[] L(string key) { return S(key).Split('|'); } public List All(string key) { var list = new List(); List l; if (kv.TryGetValue(key, out l)) foreach (var v in l) list.Add(v.Split('|')); return list; } public static float F(string v, float def = 0f) { float f; return v != null && float.TryParse(v.Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out f) ? f : def; } public static float At(string[] a, int i, float def = 0f) { return a != null && i < a.Length && a[i].Trim().Length > 0 ? F(a[i], def) : def; } public static string Str(string[] a, int i) { return a != null && i < a.Length ? a[i].Trim() : ""; } public static Color Col(string[] a, int i, Color def) { Color c; return a != null && i < a.Length && ColorUtility.TryParseHtmlString(a[i].Trim(), out c) ? c : def; } public float Num(string key, float def = 0f) { return F(S(key), def); } public Color Color(string key, Color def) { return Col(L(key), 0, def); } } }