730 lines
36 KiB
C#
730 lines
36 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.SceneManagement;
|
||
using UnityEngine.UI;
|
||
|
||
namespace TKS.OutGame
|
||
{
|
||
/// <summary>
|
||
/// 설정 팝업(PD 2026-11-25 「옵션 메뉴 — 본영 우측 톱니 · 배경음 · 효과음 · 볼륨 · 플레이어 정보(PID 복사) · 소셜 계정 연동 · 쿠폰 · 개인정보 보호정책 · 서비스 약관(미리 설정된 링크) ·
|
||
/// 버전 · 계정 삭제(게스트) · 전투 조작 방식(지금 방식 ↔ 슬링샷 · 기본 = 지금 방식) · 언어 = 누르면 별도 팝업(8개 언어)」 · 「똑같이 따라하지는 마」).
|
||
/// 모양 = 전투 중단 팝업과 같은 그림 언어(붉은 옻칠 현판 머리 + 어두운 목패 몸통) · 안 = 종이 카드 3장(소리 · 게임 · 계정) + 바닥 줄(버전 · 계정 삭제 = 붉은 버튼).
|
||
/// 좌표 · 색 · 그림 · 링크 · 언어 목록 = 표 Resources/UI/Settings/settings_screen(C45) · 글자 = settings_text(UiText · 언어 칸).
|
||
/// 저장 = 소리 → <see cref="Sound"/> · 조작 · 언어 → <see cref="GameSettings"/>(둘 다 PlayerPrefs) · 기기 PID → SaveData.pid(서버 모드 = 서버 유저 번호).
|
||
/// 위에 뜨는 확인 창(계정 삭제 · 연동 고르기)은 OutGameRoot.Modal 이 이 팝업 위에 띄운다(닫으면 이 팝업이 그대로 남음).
|
||
/// </summary>
|
||
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");
|
||
}
|
||
|
||
/// <summary>표 lang 줄 = (코드, 그 언어로 쓴 이름) 목록(PD 순서).</summary>
|
||
public static List<KeyValuePair<string, string>> Languages()
|
||
{
|
||
LoadTables();
|
||
var list = new List<KeyValuePair<string, string>>();
|
||
if (tb != null)
|
||
foreach (var v in tb.All("lang"))
|
||
if (v.Length >= 2 && v[0].Trim().Length > 0) list.Add(new KeyValuePair<string, string>(v[0].Trim(), v[1].Trim()));
|
||
return list;
|
||
}
|
||
|
||
/// <summary>지금 언어 코드(저장 값 없음 = 첫 줄 · 한국어).</summary>
|
||
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;
|
||
}
|
||
|
||
/// <summary>언어 이름 글자에 글꼴 넣기 — 한글 · 기본 영문만이면 게임 글꼴 그대로 · 한자 · 가나 · 태국 · 베트남 성조 글자가 있으면 OS 글꼴(LangFont).</summary>
|
||
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;
|
||
}
|
||
}
|
||
|
||
/// <summary>언어 이름 글꼴 — 게임 글꼴(한글 · 영문)에는 한자 · 가나 · 태국 글자가 없어 OS 글꼴 여러 개(첫 글꼴에 없는 글자 = 뒤 글꼴)로.</summary>
|
||
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);
|
||
}
|
||
|
||
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<Image>();
|
||
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<Text>();
|
||
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);
|
||
}
|
||
|
||
/// <summary>색 버튼 = 테마 스킨 + 흰 글자(얇은 테) · 팩 버튼 아래 두께만큼 글자를 위로.</summary>
|
||
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<Button>();
|
||
b.targetGraphic = img;
|
||
if (onClick != null) b.onClick.AddListener(() => onClick());
|
||
var t = Txt(rt, label, size, fg, TextAnchor.MiddleCenter);
|
||
t.rectTransform.offsetMin = new Vector2(12f, Mathf.Min(10f, h * 0.12f));
|
||
t.rectTransform.offsetMax = new Vector2(-12f, 0f);
|
||
if (stroke) UISkin.Stroke(t, C("btn_text", 1, new Color(0.23f, 0.14f, 0.09f)), N("btn_text", 2, 2f));
|
||
return b;
|
||
}
|
||
|
||
static Button ColorBtn(Transform p, string name, float x, float y, string key, string label, Action onClick)
|
||
{
|
||
return Btn(p, name, x, y, N(key, 0, 240f), N(key, 1, 72f), S(key, 2, "button"), C(key, 3, UiKit.Red), label, (int)N(key, 4, 28f), C("btn_text", 0, Color.white), true, onClick);
|
||
}
|
||
|
||
/// <summary>뒤 어둡게 + 목패 몸통 + 붉은 현판(제목) + 닫기 X · 반환 = 몸통(내용 좌표 = 몸통 왼쪽 위 기준).</summary>
|
||
static RectTransform Frame(Transform parent, string name, string title, float w, float h, Action onClose, out GameObject root)
|
||
{
|
||
var dim = UiKit.Fill(name, parent);
|
||
root = dim.gameObject;
|
||
UiLayer.Nest(root, UiRate.Event, true);
|
||
var dimImg = UiKit.Paint(dim, new Color(0f, 0f, 0f, N("dim", 0, 0.6f)), false, true);
|
||
dimImg.raycastTarget = true; // 뒤 누름 막기
|
||
var body = UiKit.Rect("Panel", dim, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(N("panel", 1, 0f), N("panel", 2, 10f)), new Vector2(w, h));
|
||
Art(body, S("body_art", 0, "bt_tag_panel"), N("body_art", 2, 0.7f), C("body_art", 1, new Color(0.29f, 0.2f, 0.14f)), true);
|
||
float hw = N("head", 0, 560f), hh = N("head", 1, 124f);
|
||
var head = UiKit.Rect("Head", body, new Vector2(0.5f, 1f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(hw, hh));
|
||
Art(head, S("head_art", 0, "ms_plaque"), N("head_art", 1, 2.08f), Color.white);
|
||
var ht = Txt(head, title, (int)N("head_art", 2, 50f), C("head_art", 3, Color.white), TextAnchor.MiddleCenter);
|
||
ht.rectTransform.offsetMin = new Vector2(70f, 4f);
|
||
ht.rectTransform.offsetMax = new Vector2(-70f, 0f);
|
||
UISkin.Stroke(ht, C("card_title", 3, new Color(0.16f, 0.1f, 0.06f)), 3f);
|
||
float cs = N("close", 0, 88f);
|
||
var x = UiKit.Rect("Close", body, new Vector2(1f, 1f), new Vector2(0.5f, 0.5f), new Vector2(N("close", 1, -40f), N("close", 2, -40f)), new Vector2(cs, cs));
|
||
var ximg = UiKit.Skin(x, "close", Color.white, true);
|
||
var xb = x.gameObject.AddComponent<Button>();
|
||
xb.targetGraphic = ximg;
|
||
xb.onClick.AddListener(() => onClose());
|
||
return body;
|
||
}
|
||
|
||
/// <summary>종이 카드 + 위 제목(금 글자) · 반환 = 카드(행 좌표 = 카드 왼쪽 위 기준).</summary>
|
||
static RectTransform Card(Transform body, string title, float x, ref float y, float w, float h)
|
||
{
|
||
float th = N("card_title", 2, 48f);
|
||
var tt = TxtAt(body, title, (int)N("card_title", 0, 32f), C("card_title", 1, new Color(0.96f, 0.84f, 0.54f)), TextAnchor.MiddleLeft, x + 12f, y, w - 24f, th);
|
||
UISkin.Stroke(tt, C("card_title", 3, new Color(0.16f, 0.1f, 0.06f)), 2f);
|
||
y += th;
|
||
var card = At(body, "Card_" + title, x, y, w, h);
|
||
Art(card, S("card_art", 0, "bt_tag_panel"), N("card_art", 2, 1f), C("card_art", 1, new Color(0.95f, 0.89f, 0.77f)));
|
||
y += h + N("card_gap", 0, 18f);
|
||
return card;
|
||
}
|
||
|
||
static void Line(Transform card, float y, float w)
|
||
{
|
||
var rt = At(card, "Line", 18f, y - N("line", 1, 2f) * 0.5f, w - 36f, N("line", 1, 2f));
|
||
UiKit.Paint(rt, C("line", 0, new Color(0.85f, 0.76f, 0.6f)), false);
|
||
}
|
||
|
||
static Text RowLabel(Transform card, string s, float y, float rowH)
|
||
{
|
||
return TxtAt(card, s, (int)N("label", 0, 32f), C("label", 1, new Color(0.29f, 0.17f, 0.11f)), TextAnchor.MiddleLeft, N("row_x", 0, 28f), y, N("label", 2, 190f), rowH);
|
||
}
|
||
|
||
// ---------- 본 팝업 ----------
|
||
|
||
static void Build(OutGameRoot root)
|
||
{
|
||
float w = N("panel", 0, 940f);
|
||
float padX = N("pad", 0, 40f), padTop = N("pad", 1, 92f), padBottom = N("pad", 2, 36f);
|
||
float cw = w - padX * 2f;
|
||
float rowH = N("row_h", 0, 104f), inner = N("card_gap", 1, 10f);
|
||
float titleH = N("card_title", 2, 48f), gap = N("card_gap", 0, 18f);
|
||
float soundH = inner * 2f + rowH * 2f;
|
||
float gameH = inner * 2f + rowH + N("desc_h", 0, 48f) + rowH;
|
||
float acctH = inner * 2f + rowH * 2f + N("url_row", 0, 84f) + 18f;
|
||
float footH = N("footer", 0, 24f) + N("footer", 1, 80f);
|
||
float h = padTop + (titleH * 3f) + soundH + gameH + acctH + gap * 2f + footH + padBottom;
|
||
|
||
GameObject go;
|
||
var body = Frame(root.TopRoot, "SettingsPopup", T("set_title"), w, h, CloseWithSound, out go);
|
||
popup = go;
|
||
float y = padTop;
|
||
|
||
// ── 소리 ──
|
||
var sc = Card(body, T("set_sec_sound"), padX, ref y, cw, soundH);
|
||
SoundRow(sc, T("set_bgm"), inner, rowH, cw, Sound.BgmOn, v => Sound.BgmOn = v, Sound.BgmVolume, v => Sound.BgmVolume = v);
|
||
Line(sc, inner + rowH, cw);
|
||
SoundRow(sc, T("set_sfx"), inner + rowH, rowH, cw, Sound.SfxOn, v => Sound.SfxOn = v, Sound.SfxVolume, v => Sound.SfxVolume = v);
|
||
|
||
// ── 게임(조작 방식 · 언어) ──
|
||
var gc = Card(body, T("set_sec_game"), padX, ref y, cw, gameH);
|
||
ControlRow(gc, inner, rowH, cw);
|
||
float ly = inner + rowH + N("desc_h", 0, 48f);
|
||
Line(gc, ly, cw);
|
||
LangRow(root, gc, ly, rowH, cw);
|
||
|
||
// ── 계정 ──
|
||
var ac = Card(body, T("set_sec_account"), padX, ref y, cw, acctH);
|
||
y -= gap;
|
||
AccountRows(root, ac, inner, rowH, cw, body, y + N("footer", 0, 24f), w);
|
||
}
|
||
|
||
static void SoundRow(Transform card, string label, float y, float rowH, float cw, bool on, Action<bool> setOn, float vol, Action<float> setVol)
|
||
{
|
||
RowLabel(card, label, y, rowH);
|
||
float sh = N("switch", 1, 64f);
|
||
Slider slider = null;
|
||
Switch(card, N("sound_x", 0, 200f), y + (rowH - sh) * 0.5f, on, v =>
|
||
{
|
||
setOn(v);
|
||
if (slider != null) Dim(slider, v);
|
||
});
|
||
float sx = N("sound_x", 1, 356f);
|
||
slider = Volume(card, sx, y, cw - N("row_x", 0, 28f) - sx, rowH, vol, setVol);
|
||
Dim(slider, on);
|
||
}
|
||
|
||
/// <summary>끈 소리의 음량 막대 = 흐리게(값은 그대로 · 만지면 바뀜).</summary>
|
||
static void Dim(Slider s, bool on)
|
||
{
|
||
var cg = s.GetComponent<CanvasGroup>();
|
||
if (cg == null) cg = s.gameObject.AddComponent<CanvasGroup>();
|
||
cg.alpha = on ? 1f : 0.45f;
|
||
}
|
||
|
||
/// <summary>켜기/끄기 스위치(바탕 틴트 = 켜짐 금 · 꺼짐 갈색 · 손잡이 = 오른쪽 켜짐) · 이름 = Switch.</summary>
|
||
static void Switch(Transform p, float x, float y, bool on, Action<bool> changed)
|
||
{
|
||
float w = N("switch", 0, 124f), h = N("switch", 1, 64f), inset = N("switch", 4, 8f);
|
||
var rt = At(p, "Switch", x, y, w, h);
|
||
var track = Art(rt, S("switch_art", 0, "set_sw_bg"), N("switch_art", 2, 1f), Color.white, true);
|
||
float k = h - inset * 2f;
|
||
var knobRt = UiKit.Rect("Knob", rt, new Vector2(0f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(k, k));
|
||
Art(knobRt, S("switch_art", 1, "set_sw_knob"), N("switch_art", 2, 1f), Color.white);
|
||
bool state = on;
|
||
Action paint = () =>
|
||
{
|
||
track.color = state ? C("switch", 2, new Color(0.91f, 0.66f, 0.23f)) : C("switch", 3, new Color(0.55f, 0.46f, 0.38f));
|
||
knobRt.anchoredPosition = new Vector2(state ? w - inset - k * 0.5f : inset + k * 0.5f, 0f);
|
||
};
|
||
paint();
|
||
var b = rt.gameObject.AddComponent<Button>();
|
||
b.targetGraphic = track;
|
||
b.transition = Selectable.Transition.None;
|
||
b.onClick.AddListener(() =>
|
||
{
|
||
state = !state;
|
||
paint();
|
||
changed(state);
|
||
});
|
||
}
|
||
|
||
/// <summary>음량 막대(uGUI Slider · 바탕 · 채움 = 테마 진행 바 스킨 · 손잡이 = 팩 손잡이) · 이름 = Volume.</summary>
|
||
static Slider Volume(Transform p, float x, float y, float w, float rowH, float value, Action<float> changed)
|
||
{
|
||
float bh = N("slider", 0, 44f), kw = N("slider", 1, 72f), kh = N("slider", 2, 56f), ppu = N("slider", 5, 1.5f);
|
||
var rt = At(p, "Volume", x, y, w, rowH);
|
||
var bgRt = UiKit.Rect("Bg", rt, new Vector2(0f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(0f, bh));
|
||
bgRt.anchorMax = new Vector2(1f, 0.5f);
|
||
var bg = UiKit.Skin(bgRt, S("slider_art", 0, "bar_bg"), C("slider", 3, new Color(0.42f, 0.32f, 0.25f)), true);
|
||
bg.pixelsPerUnitMultiplier = ppu;
|
||
float inset = N("slider", 6, 6f); // 채움을 바탕 안쪽으로(가득 차도 바탕 테두리가 보이게)
|
||
var area = UiKit.Rect("FillArea", rt, new Vector2(0f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(-inset * 2f, bh - inset * 2f));
|
||
area.anchorMax = new Vector2(1f, 0.5f);
|
||
var fillRt = UiKit.Fill("Fill", area);
|
||
var fill = UiKit.Skin(fillRt, S("slider_art", 1, "bar_fill"), C("slider", 4, new Color(0.95f, 0.71f, 0.23f)));
|
||
fill.pixelsPerUnitMultiplier = ppu;
|
||
var handleArea = UiKit.Fill("HandleArea", rt, kw * 0.5f, kw * 0.5f, 0f, 0f);
|
||
var handleRt = UiKit.Rect("Handle", handleArea, new Vector2(0f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(kw, kh));
|
||
var knob = Art(handleRt, S("slider_art", 2, "set_sl_knob"), 1f, Color.white, true);
|
||
var s = rt.gameObject.AddComponent<Slider>();
|
||
s.transition = Selectable.Transition.None;
|
||
s.direction = Slider.Direction.LeftToRight;
|
||
s.minValue = 0f;
|
||
s.maxValue = 1f;
|
||
s.fillRect = fillRt;
|
||
s.handleRect = handleRt;
|
||
s.targetGraphic = knob;
|
||
s.value = Mathf.Clamp01(value);
|
||
// Slider 가 손잡이를 세로로 늘인다(앵커 0~1) → 높이 = 칸 높이 − 여백
|
||
handleRt.sizeDelta = new Vector2(kw, kh - rowH);
|
||
fill.enabled = s.value > 0.01f;
|
||
s.onValueChanged.AddListener(v =>
|
||
{
|
||
fill.enabled = v > 0.01f;
|
||
changed(v);
|
||
});
|
||
return s;
|
||
}
|
||
|
||
static void ControlRow(Transform card, float y, float rowH, float cw)
|
||
{
|
||
RowLabel(card, T("set_control"), y, rowH);
|
||
float x0 = N("seg", 0, 230f), sh = N("seg", 1, 80f), gapS = N("seg", 2, 12f);
|
||
float right = cw - N("row_x", 0, 28f);
|
||
float sw = (right - x0 - gapS) / 2f;
|
||
int fs = (int)N("seg", 3, 30f);
|
||
string[] keys = { "set_control_direct", "set_control_sling" };
|
||
int[] modes = { GameSettings.ControlDirect, GameSettings.ControlSlingshot };
|
||
var imgs = new Image[2];
|
||
var txts = new Text[2];
|
||
var desc = TxtAt(card, "", (int)N("soft", 0, 25f), C("soft", 1, new Color(0.48f, 0.35f, 0.25f)), TextAnchor.MiddleCenter, x0, y + rowH - 6f, right - x0, N("desc_h", 0, 48f));
|
||
Action paint = () =>
|
||
{
|
||
int cur = GameSettings.Control;
|
||
for (int i = 0; i < 2; i++)
|
||
{
|
||
bool sel = modes[i] == cur;
|
||
string k = sel ? "seg_on" : "seg_off";
|
||
UISkin.Apply(imgs[i], S(k, 0, sel ? "btn_l_yellow" : "button"));
|
||
imgs[i].color = C(k, 1, sel ? Color.white : new Color(0.8f, 0.71f, 0.54f));
|
||
txts[i].color = C(k, 2, sel ? new Color(0.29f, 0.17f, 0.11f) : new Color(0.42f, 0.31f, 0.21f));
|
||
}
|
||
desc.text = T(cur == GameSettings.ControlSlingshot ? "set_control_sling_desc" : "set_control_direct_desc");
|
||
};
|
||
for (int i = 0; i < 2; i++)
|
||
{
|
||
int mode = modes[i];
|
||
var b = Btn(card, "Control_" + mode, x0 + i * (sw + gapS), y + (rowH - sh) * 0.5f, sw, sh, "button", Color.white, T(keys[i]), fs, Color.black, false, null);
|
||
imgs[i] = (Image)b.targetGraphic;
|
||
txts[i] = b.GetComponentInChildren<Text>();
|
||
b.onClick.AddListener(() =>
|
||
{
|
||
if (GameSettings.Control == mode) return;
|
||
GameSettings.Control = mode;
|
||
paint();
|
||
});
|
||
}
|
||
paint();
|
||
}
|
||
|
||
static void LangRow(OutGameRoot root, Transform card, float y, float rowH, float cw)
|
||
{
|
||
RowLabel(card, T("set_lang"), y, rowH);
|
||
float bw = N("lang_btn", 0, 330f), bh = N("lang_btn", 1, 76f);
|
||
float x = cw - N("row_x", 0, 28f) - bw;
|
||
var b = Btn(card, "Language", x, y + (rowH - bh) * 0.5f, bw, bh, S("lang_btn", 2, "button"), C("lang_btn", 3, new Color(0.91f, 0.83f, 0.65f)), LangName(CurrentLang),
|
||
(int)N("lang_btn", 4, 32f), C("label", 1, new Color(0.29f, 0.17f, 0.11f)), false, () => OpenLang(root));
|
||
var t = b.GetComponentInChildren<Text>();
|
||
UseLangFont(t, t.text);
|
||
float az = N("lang_arrow", 1, 30f);
|
||
t.rectTransform.offsetMax = new Vector2(-(az + 24f), 0f);
|
||
var ar = UiKit.Rect("Arrow", b.transform, new Vector2(1f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-(az * 0.5f + 16f), 4f), new Vector2(az, az));
|
||
Art(ar, S("lang_arrow", 0, "set_arrow"), 1f, C("label", 1, new Color(0.29f, 0.17f, 0.11f)));
|
||
}
|
||
|
||
// ---------- 계정 ----------
|
||
|
||
static void AccountRows(OutGameRoot root, Transform card, float y, float rowH, float cw, Transform body, float footY, float w)
|
||
{
|
||
float rx = N("row_x", 0, 28f), right = cw - rx;
|
||
// PID 줄 = 이름 · 값 칸 · 복사
|
||
RowLabel(card, T("set_pid"), y, rowH);
|
||
float px = N("pid_box", 0, 140f), ph = N("pid_box", 1, 64f), cbw = N("copy_btn", 0, 132f), cbh = N("copy_btn", 1, 64f);
|
||
var box = At(card, "PidBox", px, y + (rowH - ph) * 0.5f, right - cbw - 12f - px, ph);
|
||
Art(box, "", 1f, C("pid_box", 2, new Color(0.9f, 0.83f, 0.67f)));
|
||
var pidText = Txt(box, "", (int)N("pid_box", 3, 24f), C("label", 1, new Color(0.29f, 0.17f, 0.11f)), TextAnchor.MiddleCenter);
|
||
pidText.rectTransform.offsetMin = new Vector2(12f, 0f);
|
||
pidText.rectTransform.offsetMax = new Vector2(-12f, 0f);
|
||
pidText.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||
pidText.resizeTextForBestFit = true;
|
||
string pid = "";
|
||
Btn(card, "CopyPid", right - cbw, y + (rowH - cbh) * 0.5f, cbw, cbh, S("copy_btn", 2, "btn_s_green"), C("copy_btn", 3, Color.white), T("set_copy"), (int)N("copy_btn", 4, 28f),
|
||
C("btn_text", 0, Color.white), true, () =>
|
||
{
|
||
if (string.IsNullOrEmpty(pid)) return;
|
||
GUIUtility.systemCopyBuffer = pid;
|
||
root.Toast(T("set_copied"));
|
||
});
|
||
Line(card, y + rowH, cw);
|
||
y += rowH;
|
||
|
||
// 로그인 줄 = 이름 · 상태(게스트 / 소셜 이름) · 버튼(계정 연동 / 로그아웃)
|
||
RowLabel(card, T("set_account"), y, rowH);
|
||
float abw = N("acct_btn", 0, 260f), abh = N("acct_btn", 1, 72f);
|
||
var state = TxtAt(card, "", (int)N("label", 0, 32f) - 2, C("soft", 1, new Color(0.48f, 0.35f, 0.25f)), TextAnchor.MiddleLeft, N("label", 2, 190f), y, right - abw - 12f - N("label", 2, 190f), rowH);
|
||
var acctBtn = Btn(card, "AccountBtn", right - abw, y + (rowH - abh) * 0.5f, abw, abh, S("acct_btn", 2, "button"), C("acct_btn", 3, new Color(0.24f, 0.47f, 0.78f)), T("set_link"),
|
||
(int)N("acct_btn", 4, 28f), C("btn_text", 0, Color.white), true, null);
|
||
var acctLabel = acctBtn.GetComponentInChildren<Text>();
|
||
Line(card, y + rowH, cw);
|
||
y += rowH;
|
||
|
||
// 링크 줄 = 쿠폰 입력 · 개인정보 보호정책 · 서비스 약관(표 url_* · 비면 준비 중)
|
||
float uh = N("url_row", 0, 84f), ug = N("url_row", 1, 12f);
|
||
float uw = (right - rx - ug * 2f) / 3f;
|
||
int ufs = (int)N("url_row", 2, 26f);
|
||
string[] uk = { "coupon", "privacy", "terms" };
|
||
for (int i = 0; i < 3; i++)
|
||
{
|
||
string k = uk[i];
|
||
Btn(card, "Url_" + k, rx + i * (uw + ug), y + 9f, uw, uh, S("url_" + k + "_btn", 0, "button"), C("url_" + k + "_btn", 1, new Color(0.36f, 0.42f, 0.53f)), T("set_" + k), ufs,
|
||
C("btn_text", 0, Color.white), true, () => OpenUrl(root, "url_" + k));
|
||
}
|
||
|
||
// 바닥 줄 = 버전(왼쪽) · 계정 삭제(오른쪽 · 게스트만) — 몸통 기준
|
||
float padX = N("pad", 0, 40f), fh = N("footer", 1, 80f);
|
||
TxtAt(body, UiText.F("set_version", new[] { Application.version }), (int)N("footer", 2, 26f), C("footer", 3, new Color(0.91f, 0.85f, 0.74f)), TextAnchor.MiddleLeft, padX + 12f, footY, 420f, fh);
|
||
float dbw = N("delete_btn", 0, 240f), dbh = N("delete_btn", 1, 72f);
|
||
var del = ColorBtn(body, "DeleteAccount", w - padX - dbw, footY + (fh - dbh) * 0.5f, "delete_btn", T("set_delete"), null);
|
||
var delLabel = del.GetComponentInChildren<Text>();
|
||
|
||
if (!Net.AccountPanel.Available)
|
||
{
|
||
// 기기 세이브 모드 = 게스트(이 기기에서만) · PID = 세이브의 고유 키
|
||
pid = LocalPid(root);
|
||
pidText.text = pid;
|
||
state.text = T("set_guest");
|
||
acctBtn.onClick.AddListener(() => root.Toast(T("set_link_offline")));
|
||
del.onClick.AddListener(() => ConfirmLocalDelete(root));
|
||
return;
|
||
}
|
||
|
||
// 서버 모드 = 계정 정보를 받은 뒤 채움(게스트 = 연동 · 삭제 / 소셜 = 로그아웃 · 탈퇴)
|
||
var sync = Net.ServerSync.Instance;
|
||
pidText.text = T("set_loading");
|
||
state.text = "";
|
||
acctBtn.gameObject.SetActive(false);
|
||
del.gameObject.SetActive(false);
|
||
var host = popup;
|
||
sync.AccountInfo(r =>
|
||
{
|
||
if (host == null || popup != host || pidText == null) return; // 받는 사이에 닫았다
|
||
if (!r.ok)
|
||
{
|
||
pidText.text = "-";
|
||
state.text = T("set_account_fail");
|
||
return;
|
||
}
|
||
bool guest = r.Str("accountType") == Net.ServerClient.MethodGuest;
|
||
pid = r.Str("userId");
|
||
pidText.text = pid;
|
||
acctBtn.gameObject.SetActive(true);
|
||
if (guest)
|
||
{
|
||
state.text = T("set_guest");
|
||
acctLabel.text = T("set_link");
|
||
acctBtn.onClick.AddListener(() => Link(root, sync));
|
||
del.gameObject.SetActive(true);
|
||
del.onClick.AddListener(() => Net.AccountPanel.ConfirmDelete(root, sync));
|
||
return;
|
||
}
|
||
state.text = UiText.F("set_linked", new[] { Net.SocialSignIn.Label(r.Str("provider")) });
|
||
acctLabel.text = T("set_logout");
|
||
acctBtn.onClick.AddListener(() => root.Modal(T("set_logout"), T("set_logout_body"),
|
||
new OutGameRoot.ModalButton(T("set_logout"), UiKit.Red, () => sync.Logout(why => root.Toast(UiText.F("set_logout_fail", new[] { why })))),
|
||
new OutGameRoot.ModalButton(T("set_cancel"), UiKit.Dark, null)));
|
||
int days = (int)r.Num("withdrawGraceDays");
|
||
if (days > 0)
|
||
{
|
||
del.gameObject.SetActive(true);
|
||
delLabel.text = T("set_withdraw");
|
||
del.onClick.AddListener(() => Net.AccountPanel.ConfirmWithdraw(root, sync, days));
|
||
}
|
||
});
|
||
}
|
||
|
||
/// <summary>기기 세이브의 PID(없으면 지금 만들어 저장 · GUID).</summary>
|
||
static string LocalPid(OutGameRoot root)
|
||
{
|
||
var s = root.Session;
|
||
if (s == null || s.Save == null) return "";
|
||
if (string.IsNullOrEmpty(s.Save.pid))
|
||
{
|
||
s.Save.pid = Guid.NewGuid().ToString();
|
||
s.Commit();
|
||
}
|
||
return s.Save.pid;
|
||
}
|
||
|
||
static void OpenUrl(OutGameRoot root, string key)
|
||
{
|
||
string url = S(key, 0, "");
|
||
if (url.Length == 0)
|
||
{
|
||
root.Toast(T("set_url_soon"));
|
||
return;
|
||
}
|
||
Application.OpenURL(url);
|
||
}
|
||
|
||
/// <summary>게스트 소셜 연동(서버 모드) — 연동 방법이 하나면 바로 · 둘이면 고르기 · 개발 모드(시험용 번호 입력) = 기존 계정 창.</summary>
|
||
static void Link(OutGameRoot root, Net.ServerSync sync)
|
||
{
|
||
bool g = Net.SocialSignIn.Available(Net.SocialSignIn.Google), a = Net.SocialSignIn.Available(Net.SocialSignIn.Apple);
|
||
if (!g && !a)
|
||
{
|
||
root.Toast(T("set_link_none"));
|
||
return;
|
||
}
|
||
if (Net.SocialSignIn.DevMode)
|
||
{
|
||
Close();
|
||
Net.AccountPanel.Open(root);
|
||
return;
|
||
}
|
||
if (g && a)
|
||
{
|
||
root.Modal(T("set_link"), T("set_link_pick"),
|
||
new OutGameRoot.ModalButton(Net.SocialSignIn.Label(Net.SocialSignIn.Google), UiKit.Jade, () => Net.AccountPanel.Link(root, sync, Net.SocialSignIn.Google, "", null)),
|
||
new OutGameRoot.ModalButton(Net.SocialSignIn.Label(Net.SocialSignIn.Apple), UiKit.Jade, () => Net.AccountPanel.Link(root, sync, Net.SocialSignIn.Apple, "", null)),
|
||
new OutGameRoot.ModalButton(T("set_cancel"), UiKit.Dark, null));
|
||
return;
|
||
}
|
||
Net.AccountPanel.Link(root, sync, g ? Net.SocialSignIn.Google : Net.SocialSignIn.Apple, "", null);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 기기 세이브 모드의 계정 삭제 — 확인 문구(「계정 삭제」)를 입력해야 지운다(서버 모드의 계정 창과 같은 확인) → 세이브 파일 삭제 → 타이틀부터 다시(신규 유저 흐름).
|
||
/// </summary>
|
||
static void ConfirmLocalDelete(OutGameRoot root)
|
||
{
|
||
InputField input = null;
|
||
var content = root.ModalCustom(T("set_delete"), 760f,
|
||
new OutGameRoot.ModalButton(T("set_delete_ok"), UiKit.Red, () =>
|
||
{
|
||
if (input == null || !Net.AccountPanel.Typed(input.text))
|
||
{
|
||
root.Toast(T("set_delete_typo"));
|
||
return;
|
||
}
|
||
root.CloseModal();
|
||
Close();
|
||
SaveStore.DeleteLocal();
|
||
string title = BootScenes.Title;
|
||
BootScenes.GoTo(Application.CanStreamedLevelBeLoaded(title) ? title : SceneManager.GetActiveScene().name);
|
||
}, true),
|
||
new OutGameRoot.ModalButton(T("set_cancel"), UiKit.Dark, null));
|
||
var top = new Vector2(0.5f, 1f);
|
||
UiKit.Label(content, T("set_delete_body"), 30, UiKit.Ink, TextAnchor.UpperCenter, top, top, new Vector2(0f, -10f), new Vector2(820f, 220f), false)
|
||
.horizontalOverflow = HorizontalWrapMode.Wrap;
|
||
input = Net.LoginPanel.Field(content, "Phrase", Net.AccountPanel.DeletePhrase, top, new Vector2(0f, -250f), new Vector2(560f, 90f), 20);
|
||
}
|
||
|
||
// ---------- 언어 팝업 ----------
|
||
|
||
public static void OpenLang(OutGameRoot root)
|
||
{
|
||
if (root == null || root.TopRoot == null) return;
|
||
LoadTables();
|
||
CloseLang();
|
||
Sound.PlayUi(SoundKeys.UiPopup);
|
||
var langs = Languages();
|
||
int cols = Mathf.Max(1, (int)N("lang_popup", 1, 2f));
|
||
float bw = N("lang_popup", 2, 350f), bh = N("lang_popup", 3, 96f), g = N("lang_popup", 4, 20f);
|
||
int rows = (langs.Count + cols - 1) / cols;
|
||
float w = N("lang_popup", 0, 820f);
|
||
float padTop = N("pad", 1, 92f), padBottom = N("pad", 2, 36f);
|
||
float aw = N("lang_apply", 0, 300f), ah = N("lang_apply", 1, 100f);
|
||
float gridH = rows * bh + Mathf.Max(0, rows - 1) * g;
|
||
float h = padTop + 12f + gridH + 36f + ah + padBottom;
|
||
|
||
GameObject go;
|
||
var body = Frame(root.TopRoot, "LanguagePopup", T("set_lang_title"), w, h, () =>
|
||
{
|
||
Sound.PlayUi(SoundKeys.UiClose);
|
||
CloseLang();
|
||
}, out go);
|
||
langPopup = go;
|
||
string pick = CurrentLang;
|
||
float gx = (w - (cols * bw + (cols - 1) * g)) * 0.5f;
|
||
var imgs = new List<Image>();
|
||
var codes = new List<string>();
|
||
Action paint = () =>
|
||
{
|
||
for (int i = 0; i < imgs.Count; i++)
|
||
{
|
||
bool sel = codes[i] == pick;
|
||
if (sel) UISkin.Apply(imgs[i], S("seg_on", 0, "btn_l_yellow"));
|
||
else
|
||
{
|
||
var sp = UISkin.Icon(S("card_art", 0, "bt_tag_panel"));
|
||
var old = imgs[i].transform.Find(UISkin.OverlayName);
|
||
if (old != null) UnityEngine.Object.Destroy(old.gameObject);
|
||
imgs[i].sprite = sp != null ? sp : UiKit.Round;
|
||
imgs[i].type = Image.Type.Sliced;
|
||
imgs[i].pixelsPerUnitMultiplier = sp != null ? N("card_art", 2, 1f) : 1f;
|
||
}
|
||
imgs[i].color = sel ? C("seg_on", 1, Color.white) : C("card_art", 1, new Color(0.95f, 0.89f, 0.77f));
|
||
}
|
||
};
|
||
for (int i = 0; i < langs.Count; i++)
|
||
{
|
||
string code = langs[i].Key;
|
||
int c = i % cols, r = i / cols;
|
||
var b = Btn(body, "Lang_" + code, gx + c * (bw + g), padTop + 12f + r * (bh + g), bw, bh, "button", Color.white, langs[i].Value, (int)N("lang_popup", 5, 34f),
|
||
C("label", 1, new Color(0.29f, 0.17f, 0.11f)), false, null);
|
||
UseLangFont(b.GetComponentInChildren<Text>(), langs[i].Value);
|
||
imgs.Add((Image)b.targetGraphic);
|
||
codes.Add(code);
|
||
b.onClick.AddListener(() =>
|
||
{
|
||
pick = code;
|
||
paint();
|
||
});
|
||
}
|
||
paint();
|
||
float ay = padTop + 12f + gridH + 36f;
|
||
Btn(body, "Apply", (w - aw) * 0.5f, ay, aw, ah, S("lang_apply", 2, "btn_l_yellow"), C("lang_apply", 3, Color.white), T("set_lang_apply"), (int)N("lang_apply", 4, 38f),
|
||
C("btn_text", 0, Color.white), true, () =>
|
||
{
|
||
bool changed = pick != CurrentLang;
|
||
CloseLang();
|
||
if (!changed) return;
|
||
GameSettings.Language = pick == UiText.Fallback ? "" : pick;
|
||
Open(root); // 설정 팝업 글자를 새 언어로 다시 그림
|
||
root.Toast(T("set_lang_done"));
|
||
});
|
||
}
|
||
|
||
public static void CloseLang()
|
||
{
|
||
if (langPopup == null) return;
|
||
langPopup.SetActive(false);
|
||
UnityEngine.Object.Destroy(langPopup);
|
||
langPopup = null;
|
||
}
|
||
}
|
||
}
|