using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; namespace TKS.OutGame { /// /// 설정 팝업(PD 2026-11-25 「옵션 메뉴 — 본영 우측 톱니 · 배경음 · 효과음 · 볼륨 · 플레이어 정보(PID 복사) · 소셜 계정 연동 · 쿠폰 · 개인정보 보호정책 · 서비스 약관(미리 설정된 링크) · /// 버전 · 계정 삭제(게스트) · 전투 조작 방식(지금 방식 ↔ 슬링샷 · 기본 = 지금 방식) · 언어 = 누르면 별도 팝업(8개 언어)」 · 「똑같이 따라하지는 마」). /// 모양 = 전투 중단 팝업과 같은 그림 언어(붉은 옻칠 현판 머리 + 어두운 목패 몸통) · 안 = 종이 카드 3장(소리 · 게임 · 계정) + 바닥 줄(버전 · 계정 삭제 = 붉은 버튼). /// 좌표 · 색 · 그림 · 링크 · 언어 목록 = 표 Resources/UI/Settings/settings_screen(C45) · 글자 = settings_text(UiText · 언어 칸). /// 저장 = 소리 → · 조작 · 언어 → (둘 다 PlayerPrefs) · 기기 PID → SaveData.pid(서버 모드 = 서버 유저 번호). /// 위에 뜨는 확인 창(계정 삭제 · 연동 고르기)은 OutGameRoot.Modal 이 이 팝업 위에 띄운다(닫으면 이 팝업이 그대로 남음). /// public static class SettingsPopup { public const string TablePath = "UI/Settings/settings_screen"; public const string TextPath = "UI/Settings/settings_text"; static GameObject popup; static GameObject langPopup; static ScreenTable tb; static Font langFont; public static bool IsOpen { get { return popup != null; } } public static bool LangOpen { get { return langPopup != null; } } // ---------- 표 ---------- static void LoadTables() { if (tb == null) tb = ScreenTable.Load(TablePath); UiText.Use(TextPath); } static string[] L(string k) { return tb != null && tb.Has(k) ? tb.L(k) : new string[0]; } static float N(string k, int i, float d) { return ScreenTable.At(L(k), i, d); } static string S(string k, int i, string d) { var a = L(k); return i < a.Length && a[i].Trim().Length > 0 ? a[i].Trim() : d; } static Color C(string k, int i, Color d) { return ScreenTable.Col(L(k), i, d); } static string T(string key) { return UiText.T(key).Replace("\\n", "\n"); } /// 표 lang 줄 = (코드, 그 언어로 쓴 이름) 목록(PD 순서). public static List> Languages() { LoadTables(); var list = new List>(); if (tb != null) foreach (var v in tb.All("lang")) if (v.Length >= 2 && v[0].Trim().Length > 0) list.Add(new KeyValuePair(v[0].Trim(), v[1].Trim())); return list; } /// 지금 언어 코드(저장 값 없음 = 첫 줄 · 한국어). public static string CurrentLang { get { string l = GameSettings.Language; return l.Length > 0 ? l : UiText.Fallback; } } static string LangName(string code) { foreach (var kv in Languages()) if (kv.Key == code) return kv.Value; return code; } /// 언어 이름 글자에 글꼴 넣기 — 한글 · 기본 영문만이면 게임 글꼴 그대로 · 한자 · 가나 · 태국 · 베트남 성조 글자가 있으면 OS 글꼴(LangFont). static void UseLangFont(Text t, string name) { foreach (char ch in name ?? "") if (ch > 0x7E && !(ch >= 0xAC00 && ch <= 0xD7A3) && !(ch >= 0x3130 && ch <= 0x318F)) { t.font = LangFont; t.fontStyle = FontStyle.Bold; return; } } /// 언어 이름 글꼴 — 게임 글꼴(한글 · 영문)에는 한자 · 가나 · 태국 글자가 없어 OS 글꼴 여러 개(첫 글꼴에 없는 글자 = 뒤 글꼴)로. static Font LangFont { get { if (langFont != null) return langFont; var names = L("lang_font"); try { if (names.Length > 0) langFont = Font.CreateDynamicFontFromOSFont(names, 32); } catch (Exception e) { Debug.LogWarning("[TKS] 언어 이름 글꼴 만들기 실패 → 게임 글꼴: " + e.Message); } if (langFont == null) langFont = UISkin.TitleFont; return langFont; } } // ---------- 열기 · 닫기 ---------- public static void Open(OutGameRoot root) { if (root == null || root.TopRoot == null) return; LoadTables(); Close(); Sound.PlayUi(SoundKeys.UiPopup); Build(root); // 물리 뒤로 가기(2026-11-26 Google Play 요건) = 언어 목록이 떠 있으면 그것만 · 아니면 설정 창 닫기 if (popup != null) UiBack.Push(popup, () => { if (langPopup != null) CloseLang(); else Close(); return true; }); } public static void Close() { CloseLang(); if (popup == null) return; PlayerPrefs.Save(); // 음량 막대는 끄는 동안 값만 바꿔 둠 → 닫을 때 한 번 저장 popup.SetActive(false); UnityEngine.Object.Destroy(popup); popup = null; } static void CloseWithSound() { Sound.PlayUi(SoundKeys.UiClose); Close(); } // ---------- 틀 ---------- static RectTransform At(Transform p, string name, float x, float y, float w, float h) { return UiKit.Rect(name, p, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(x, -y), new Vector2(w, h)); } static Image Art(RectTransform rt, string id, float ppu, Color c, bool ray = false) { var img = rt.gameObject.AddComponent(); var sp = string.IsNullOrEmpty(id) ? null : UISkin.Icon(id); img.sprite = sp != null ? sp : UiKit.Round; img.color = c; img.raycastTarget = ray; if (sp == null || sp.border != Vector4.zero) { img.type = Image.Type.Sliced; img.pixelsPerUnitMultiplier = sp != null ? Mathf.Max(0.01f, ppu) : 1f; } else img.preserveAspect = true; return img; } static Text Txt(Transform p, string s, int size, Color c, TextAnchor a) { var rt = UiKit.Fill("Text", p); var t = rt.gameObject.AddComponent(); UISkin.UseTitle(t); t.text = s; t.fontSize = size; t.color = c; t.alignment = a; t.supportRichText = false; t.horizontalOverflow = HorizontalWrapMode.Wrap; t.verticalOverflow = VerticalWrapMode.Truncate; t.resizeTextForBestFit = true; // 긴 번역 글자도 칸 안에 t.resizeTextMinSize = Mathf.Max(14, Mathf.RoundToInt(size * 0.6f)); t.resizeTextMaxSize = size; t.raycastTarget = false; return t; } static Text TxtAt(Transform p, string s, int size, Color c, TextAnchor a, float x, float y, float w, float h) { return Txt(At(p, "Text", x, y, w, h), s, size, c, a); } /// 색 버튼 = 테마 스킨 + 흰 글자(얇은 테) · 팩 버튼 아래 두께만큼 글자를 위로. static Button Btn(Transform p, string name, float x, float y, float w, float h, string skin, Color tint, string label, int size, Color fg, bool stroke, Action onClick) { var rt = At(p, name, x, y, w, h); var img = UiKit.Skin(rt, skin, tint, true); var b = rt.gameObject.AddComponent