using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using NHSE.Core;
using NHSE.WinForms.Properties;
namespace NHSE.WinForms
{
#if DEBUG
public static class DevUtil
{
private static readonly string[] Languages = { "jp", "de", "es", "fr", "it", "ko", "zhs", "zht" };
private const string DefaultLanguage = GameLanguage.DefaultLanguage;
public static bool IsUpdatingTranslations { get; private set; }
///
/// Call this to update all translatable resources (Program Messages, Legality Text, Program GUI)
///
public static void UpdateAll()
{
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Update translation files with current values?"))
return;
IsUpdatingTranslations = true;
DumpStringsMessage();
UpdateTranslations();
UpdateInternalNameTranslations();
IsUpdatingTranslations = false;
}
private static void UpdateTranslations()
{
WinFormsTranslator.LoadSpecialForms = LoadSpecialForms;
WinFormsTranslator.SetRemovalMode(false); // add mode
WinFormsTranslator.LoadAllForms(LoadBanlist); // populate with every possible control
WinFormsTranslator.UpdateAll(DefaultLanguage, Languages); // propagate to others
WinFormsTranslator.DumpAll(Banlist); // dump current to file
WinFormsTranslator.SetRemovalMode(); // remove used keys, don't add any
WinFormsTranslator.LoadAllForms(LoadBanlist); // de-populate
WinFormsTranslator.RemoveAll(DefaultLanguage, PurgeBanlist); // remove all lines from above generated files that still remain
// Move translated files from the debug exe loc to their project location
var files = Directory.GetFiles(Application.StartupPath);
var dir = GetResourcePath().Replace("NHSE.Core", "NHSE.WinForms");
foreach (var f in files)
{
var fn = Path.GetFileName(f);
if (!fn.EndsWith(".txt"))
continue;
if (!fn.StartsWith("lang_"))
continue;
var loc = Path.Combine(dir, fn);
if (File.Exists(loc))
File.Delete(loc);
File.Move(f, loc);
}
Application.Exit();
}
private static void LoadSpecialForms()
{
// For forms that require more complete initialization (dynamically added user controls)
var path = Settings.Default.LastFilePath;
var sav = new HorizonSave(path);
using var editor = new Editor(sav);
using var items = new PlayerItemEditor(new[] {new Item()}, 1, 1);
using var so = new SingleObjectEditor