170 lines
6.6 KiB
C#
170 lines
6.6 KiB
C#
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.IO;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
namespace TKS.OutGame
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// UI 리뉴얼 검증 캡처(PD #1100 · 에디터 DataImporter.CaptureUI 가 SessionState 로 출력 폴더를 넘기면 생성 · 세이브 = 메모리 전용 신규 유저).
|
|||
|
|
/// 1080×1920 = 로비 · 영웅 목록 · 영웅 상세 · 편성 · 거래 · 보물 · 내정 · 연무장 · 월드맵 팝업 · 전투 HUD · 전투 결과 · 팝업 + 1536×2048 = 로비 · 영웅 상세(겹침 확인) · 끝나면 스스로 종료.
|
|||
|
|
/// </summary>
|
|||
|
|
public class UICaptureDriver : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
public const string DirKey = "TKS_UI_CAPTURE_DIR";
|
|||
|
|
public string OutputDir;
|
|||
|
|
const int W = 1080, H = 1920, W2 = 1536, H2 = 2048;
|
|||
|
|
|
|||
|
|
readonly List<string> log = new List<string>();
|
|||
|
|
int shot = 1;
|
|||
|
|
|
|||
|
|
#if UNITY_EDITOR
|
|||
|
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
|
|||
|
|
static void AutoSpawn()
|
|||
|
|
{
|
|||
|
|
string dir = UnityEditor.SessionState.GetString(DirKey, "");
|
|||
|
|
if (string.IsNullOrEmpty(dir)) return;
|
|||
|
|
UnityEditor.SessionState.EraseString(DirKey);
|
|||
|
|
var d = new GameObject("UICaptureDriver").AddComponent<UICaptureDriver>();
|
|||
|
|
d.OutputDir = dir;
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
IEnumerator Start()
|
|||
|
|
{
|
|||
|
|
Directory.CreateDirectory(OutputDir);
|
|||
|
|
yield return null;
|
|||
|
|
yield return null;
|
|||
|
|
var root = OutGameRoot.Instance;
|
|||
|
|
var cam = Camera.main;
|
|||
|
|
if (root == null || cam == null)
|
|||
|
|
{
|
|||
|
|
Log("FAIL: OutGameRoot 또는 카메라 없음");
|
|||
|
|
Finish(1);
|
|||
|
|
yield break;
|
|||
|
|
}
|
|||
|
|
var s = root.Session;
|
|||
|
|
var db = s.Db;
|
|||
|
|
var d = s.Save;
|
|||
|
|
Log("theme=" + (UITheme.Current != null) + " titleFont=" + (UISkin.TitleFont != null ? UISkin.TitleFont.name : "-") + " memoryOnly=" + SaveStore.MemoryOnly);
|
|||
|
|
|
|||
|
|
// 캡처용 진행(메모리 세이브만): 재화 · 장비 · 보물 · 상자 · 순찰
|
|||
|
|
d.gold = 124500;
|
|||
|
|
d.gem = 1280;
|
|||
|
|
var id = db.Economy.StartHeroes.Length > 1 ? db.Economy.StartHeroes[1] : db.Economy.StartHeroes[0];
|
|||
|
|
var h = s.Def(id);
|
|||
|
|
var hs = s.Save.Hero(id);
|
|||
|
|
for (int i = 0; i < 4; i++) d.inv.AddGear(HeroRules.RequiredGear(db, h, hs, i), 1);
|
|||
|
|
for (int i = 0; i < 3; i++) s.Equip(id, i);
|
|||
|
|
HeroRules.GrantExp(hs, db.Levels.Get(1).expToNext + 5);
|
|||
|
|
var rng = new System.Random(1100);
|
|||
|
|
Counts.Set(d.inv.chests, "gold", 6);
|
|||
|
|
for (int i = 0; i < 6; i++) TreasureRules.Open(db, d, "gold", rng);
|
|||
|
|
Counts.Set(d.inv.chests, "bronze", 4);
|
|||
|
|
Counts.Set(d.inv.chests, "silver", 18);
|
|||
|
|
Counts.Set(d.inv.chests, "general", 1);
|
|||
|
|
d.inv.chestPoints = 35;
|
|||
|
|
d.patrol.startAt = SaveStore.Iso(s.Now.AddHours(-7));
|
|||
|
|
s.Commit();
|
|||
|
|
|
|||
|
|
root.ShowLobby();
|
|||
|
|
yield return Shot(cam, "lobby", W, H);
|
|||
|
|
root.Show(root.HeroList);
|
|||
|
|
yield return Shot(cam, "hero_list", W, H);
|
|||
|
|
root.ShowHero(id);
|
|||
|
|
yield return Shot(cam, "hero_detail", W, H);
|
|||
|
|
root.Show(root.Formation);
|
|||
|
|
yield return Shot(cam, "formation", W, H);
|
|||
|
|
root.Show(root.Trade);
|
|||
|
|
root.Trade.SetPage(0);
|
|||
|
|
yield return Shot(cam, "trade_gacha", W, H);
|
|||
|
|
root.Show(root.Treasures);
|
|||
|
|
root.Treasures.SetPage(2);
|
|||
|
|
root.Treasures.SelectChest("gold");
|
|||
|
|
yield return Shot(cam, "treasure_chests", W, H);
|
|||
|
|
root.Treasures.SetPage(0);
|
|||
|
|
yield return Shot(cam, "treasure_owned", W, H);
|
|||
|
|
root.Show(root.Domestic);
|
|||
|
|
root.Domestic.SetTrainType(UnitType.Infantry);
|
|||
|
|
root.Domestic.SetPage(1);
|
|||
|
|
yield return Shot(cam, "domestic_patrol", W, H);
|
|||
|
|
root.Arena.SetPage(0);
|
|||
|
|
root.Show(root.Arena);
|
|||
|
|
yield return Shot(cam, "arena", W, H);
|
|||
|
|
root.StaminaModal();
|
|||
|
|
yield return Shot(cam, "popup_stamina", W, H);
|
|||
|
|
root.CloseModal();
|
|||
|
|
|
|||
|
|
root.ShowLobby();
|
|||
|
|
root.ShowHero(id);
|
|||
|
|
yield return Shot(cam, "hero_detail_1536x2048", W2, H2);
|
|||
|
|
root.ShowLobby();
|
|||
|
|
yield return Shot(cam, "lobby_1536x2048", W2, H2);
|
|||
|
|
|
|||
|
|
root.OpenWorldMap();
|
|||
|
|
yield return Wait();
|
|||
|
|
var wm = root.Map;
|
|||
|
|
wm.OpenPopup(0);
|
|||
|
|
yield return Shot(cam, "worldmap_popup", W, H);
|
|||
|
|
wm.ConfirmPopup();
|
|||
|
|
var bm = root.Battle;
|
|||
|
|
float t0 = Time.realtimeSinceStartup;
|
|||
|
|
while (bm.Phase != BattlePhase.PlayerTurn && Time.realtimeSinceStartup - t0 < 10f) yield return null;
|
|||
|
|
yield return new WaitForSecondsRealtime(0.6f);
|
|||
|
|
Unit pick = null;
|
|||
|
|
foreach (var u in bm.AliveUnits(Faction.Player))
|
|||
|
|
if (bm.Skills != null && bm.Skills.Of(u) != null && bm.Skills.Of(u).Active != null)
|
|||
|
|
{
|
|||
|
|
pick = u;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
if (pick != null) bm.Sling.Select(pick);
|
|||
|
|
Log("hud select=" + (pick != null ? pick.DisplayName : "-") + " skill=" + bm.Hud.SkillButtonText);
|
|||
|
|
yield return Shot(cam, "battle_hud", W, H);
|
|||
|
|
foreach (var e in bm.AliveUnits(Faction.Enemy)) e.TakeDamage(e.Hp);
|
|||
|
|
bm.CheckBattleEnd();
|
|||
|
|
yield return new WaitForSecondsRealtime(0.6f);
|
|||
|
|
yield return Shot(cam, "battle_result", W, H);
|
|||
|
|
Finish(0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
static IEnumerator Wait()
|
|||
|
|
{
|
|||
|
|
yield return null;
|
|||
|
|
yield return new WaitForSecondsRealtime(0.3f);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
IEnumerator Shot(Camera cam, string name, int w, int h)
|
|||
|
|
{
|
|||
|
|
yield return Wait();
|
|||
|
|
string file = Path.Combine(OutputDir, shot.ToString("00") + "_" + name + ".png");
|
|||
|
|
shot++;
|
|||
|
|
yield return CaptureUtil.Capture(cam, w, h, file);
|
|||
|
|
Log("shot " + file);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void Log(string s)
|
|||
|
|
{
|
|||
|
|
log.Add(s);
|
|||
|
|
Debug.Log("[UICapture] " + s);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
File.WriteAllLines(Path.Combine(OutputDir, "capture_log.txt"), log.ToArray());
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void Finish(int code)
|
|||
|
|
{
|
|||
|
|
Log("finish code=" + code);
|
|||
|
|
#if UNITY_EDITOR
|
|||
|
|
UnityEditor.EditorApplication.Exit(code);
|
|||
|
|
#else
|
|||
|
|
Application.Quit(code);
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|