using System.Collections;
using System.IO;
using System.Linq;
using UnityEngine;
namespace GrassCutter
{
public partial class DemoBot
{
///
/// `-demolang all` (or `-demolang de,ru,ja`): every screen in every interface language, to check the translations
/// fit. Shots go to <folder>/<code>/NN_screen.png; the menu ones first, then one game in which the
/// language is switched the way a player does it, from the settings.
///
IEnumerator Languages(string which)
{
var langs = which == "all" ? Loc.All.ToList() : which.Split(',').Select(Loc.Find).Where(l => l != null).ToList();
Log($"languages: {string.Join(", ", langs.Select(l => l.code))}");
Achievements.Forget();
TeamState.DeleteSave();
yield return new WaitForSeconds(3f);
var root = folder;
// the menu and what opens from it, before any game
foreach (var l in langs)
{
Loc.Set(l.code, false);
folder = Path.Combine(root, l.code);
yield return new WaitForSeconds(1.2f);
yield return Shot("00_menu");
UIRoot.I.OpenSlots();
yield return Settle("01_slots");
UIRoot.I.OpenBrowser();
yield return Settle("02_find_games");
UIRoot.I.OpenCharacter();
yield return Settle("03_character");
UIRoot.I.OpenSettings();
yield return Settle("04_settings", close: false);
// every tab, and the bottom of the long keys list
for (int t = 1; t < 6; t++)
{
UIRoot.I.SettingsTab(t);
yield return Settle("04" + (char)('a' + t) + "_settings", close: false);
}
UIRoot.I.SettingsScrollEnd();
yield return Settle("04g_settings_keys_end", close: false);
UIRoot.I.SettingsTab(0);
UIRoot.I.OpenLanguages();
yield return Settle("05_languages");
UIRoot.I.CloseTopModal();
UIRoot.I.Confirm(Loc.T("Reset progress?"), Loc.T("Your base, cash, tools and upgrades will be wiped."), () => { });
yield return Settle("06_confirm");
UIRoot.I.OpenDifficulty(_ => { });
yield return Settle("07_difficulty");
}
folder = root;
Loc.Set(langs[0].code, false);
NetSession.Instance.HostLocal();
while (!Me || !Ts) yield return null;
yield return new WaitForSeconds(4f);
Log("in game");
// a garage, a belt and a robot dock to open, money to spend
var gAt = Soil17(26f, -30f);
var garage = Spawner.Instance.SpawnPiece(PieceId.Garage, gAt, Quaternion.identity, gAt, true);
var b0 = Soil17(20f, -42f) + Vector3.up * GameDefs.BeltLowest;
var belt = Spawner.Instance.SpawnPiece(PieceId.Belt, b0, Quaternion.LookRotation(Vector3.right), b0 + Vector3.right * 6f, true);
Ts.ServerSetMoney(1234567.5d);
yield return new WaitForSeconds(2f);
foreach (var l in langs)
{
folder = Path.Combine(root, l.code);
// the way a player does it: settings, then the language list
UIRoot.I.OpenSettings();
yield return new WaitForSeconds(0.5f);
Loc.Set(l.code, false);
yield return new WaitForSeconds(1f);
yield return Shot("10_settings_ingame");
while (UIRoot.I.AnyModal) { UIRoot.I.CloseTopModal(); yield return null; }
yield return new WaitForSeconds(0.4f);
// by the supply wall (empty hands and their hint in the first language only)
Me.Teleport(new Vector3(-6.4f, 0.1f, -1.5f));
Me.LookAt(new Vector3(-8.5f, 1.2f, -1.5f));
UIRoot.I.Hud.Banner(Loc.T("WELCOME TO HERBARIA-7"), Loc.T("Earth has run out of grass. Cut it, bundle it, ship it home."), 3.2f);
yield return new WaitForSeconds(1.2f);
yield return Shot("11_hud_wall");
UIRoot.I.OpenSupply();
yield return Settle("12_supply");
UIRoot.I.OpenShop();
yield return Settle("13_upgrades");
if (garage)
{
UIRoot.I.OpenGarage(garage.GetComponent());
yield return Settle("14_garage");
UIRoot.I.OpenPiece(garage);
yield return Settle("15_piece_garage");
}
if (belt)
{
UIRoot.I.OpenPiece(belt);
yield return Settle("16_piece_belt");
}
UIRoot.I.OpenMap();
yield return Settle("17_map");
UIRoot.I.OpenNotebook();
yield return Settle("18_notebook");
UIRoot.I.OpenStations();
yield return Settle("19_stations");
UIRoot.I.OpenAwards();
yield return Settle("20_achievements");
UIRoot.I.OpenPause();
yield return Settle("21_pause");
// tools in hand, the tab list, toasts
Cheats.Run("tool all");
yield return new WaitForSeconds(0.3f);
Me.Tools.Equip(ToolId.Scythe);
Me.Teleport(new Vector3(13f, Soil + 0.1f, -2f));
Me.LookAt(new Vector3(15f, Soil, -2f));
Hud.Toast(Loc.F("Sector {0:N0} mown clean! +{1}", 12345, UIK.Money(170d)), Hud.ToastKind.Money);
Ts.AnnounceRpc(Loc.Pack("A new {0} is waiting at the garage!", Loc.Key(GameDefs.Vehicle(VehicleKind.Combine).nameEn)));
Ctl.BotTabHeld = true;
yield return new WaitForSeconds(1f);
yield return Shot("22_tab_and_toasts");
Ctl.BotTabHeld = false;
// the hammer's palette
Me.Tools.Equip(ToolId.Hammer);
yield return new WaitForSeconds(0.4f);
var pb = PlayerBuild.Local;
if (pb) pb.Select(PieceId.Garage);
yield return new WaitForSeconds(0.6f);
yield return Shot("23_build");
Me.Tools.Equip(ToolId.Scythe);
// looking at a built piece, and a call with its captions
Me.Teleport(gAt + new Vector3(-6f, 0.4f, -9f));
Me.LookAt(gAt + Vector3.up * 1.2f);
yield return new WaitForSeconds(0.6f);
yield return Shot("24_aim_piece");
DirectorCall.Call("dir_m1");
float t0 = Time.time;
while (Time.time - t0 < 9f) yield return null;
yield return Shot("25_call");
while (DirectorCall.Busy && Time.time - t0 < 40f) yield return null;
yield return new WaitForSeconds(1f);
Assistant.Say("asst_storm");
yield return new WaitForSeconds(2.2f);
yield return Shot("26_assistant");
while (Assistant.Busy) yield return null;
yield return new WaitForSeconds(0.5f);
Log($"{l.code} done");
}
folder = root;
Log("languages done");
Application.Quit();
}
/// A screen just opened: let it pop in, take it, close it.
IEnumerator Settle(string shot, bool close = true)
{
yield return new WaitForSeconds(0.9f);
yield return Shot(shot);
if (close) { UIRoot.I.CloseTopModal(); yield return new WaitForSeconds(0.3f); }
}
}
}