Localization in es, zh, ja, ko, vi; novel editor hub removed (its collection is gone, tools open from the menu and the toolbar)

This commit is contained in:
cthangover committed 2026-10-23 20:54:37 +02:00
1 parent e1a1d770cf
commit 3ddb61d61e
19 files changed
+1714 -282

No files matched your search

@@ -1,105 +0,0 @@
using System;
using System.Linq;
using Cthangover.Core.Scenes;
using Cthangover.Core.UI.Tool.ScenarioEditor;
using Cthangover.Mods.Interface.Tool;
using Cthangover.Tools.Common;
using Cthangover.Tools.Hub;
using Cthangover.Tools.Services;
using Godot;
namespace Cthangover.Tools.Tests.Windows
{
/// <summary>
/// Play-test round trip of the scenario editor opened from the
/// <see cref="NovelEditorHub"/>: plays this suite's own scenario (so the
/// editor's save-before-play rewrites a test file, not game content), lets
/// the play end the way a finished dialog ends it
/// (<see cref="SceneManager.IsTestPlayActive"/> drops), then plays again and
/// presses Stop. Both times the game must come back to the hub with the
/// editor visible — not to the engine's main menu. Advanced one step per
/// driver tick; <see cref="Tick"/> returns true when done.
/// </summary>
public class ScenarioPlayReturnCheck
{
private const string SuiteModId = "editor_tools__windows";
private const string ScenarioPath = "scenarios/playtest_return.scenario";
private const int ShellSettleTicks = 3;
private readonly Action<bool, string> _check;
private ScenarioEditorWindow _window;
private int _step;
private int _settle;
/// <summary>Creates the check; <paramref name="check"/> records one assertion.</summary>
public ScenarioPlayReturnCheck(Action<bool, string> check)
{
_check = check;
}
/// <summary>Advances the round trip by one step; true once finished.</summary>
public bool Tick(SceneTree tree)
{
switch (_step)
{
case 0:
_window = (ScenarioEditorWindow)ToolWindow.ShowWindow(new ScenarioEditorWindow());
var tabs = _window.FindChildren("*", "", true, false).OfType<ScenarioEditTabs>().FirstOrDefault();
tabs?.OpenFile(ScenarioFileService.MakeKey(SuiteModId, ScenarioPath));
_check(tabs?.HasActiveFile == true, "scenario_editor: test scenario opened");
break;
case 1:
case 4:
PressButton(_window, "tools/scenario_editor/play");
_settle = ShellSettleTicks;
break;
case 2:
if (!InGame(tree))
return false;
SceneManager.IsTestPlayActive = false;
break;
case 5:
if (!InGame(tree))
return false;
PressButton(tree.Root, "tools/scenario_editor/stop");
break;
case 3:
case 6:
if (tree.CurrentScene is not NovelEditorHub || !_window.Visible)
return false;
_check(true, _step == 3
? "scenario_editor: the scenario's end returns to the editor hub"
: "scenario_editor: Stop returns to the editor hub");
if (_step == 6)
{
_window.QueueFree();
return true;
}
break;
}
_step++;
return false;
}
/// <summary>The play-test left the hub for the game shell and the shell settled.</summary>
private bool InGame(SceneTree tree)
{
if (tree.CurrentScene is NovelEditorHub || GodotSceneService.IsTransitioning || --_settle > 0)
return false;
_check(!_window.Visible, "scenario_editor: play hides the editor and enters the game");
return true;
}
private static void PressButton(Node root, string textKey)
{
var text = ToolUi.Tr(textKey);
var button = root.FindChildren("*", nameof(Button), true, false).OfType<Button>().FirstOrDefault(b => b.Text == text);
button?.EmitSignal(BaseButton.SignalName.Pressed);
}
}
}
@@ -1,12 +1,9 @@
using System.Collections.Generic;
using System.IO;
using Cthangover.Core.Bootstrap;
using Cthangover.Core.Games;
using Cthangover.Core.UI.Tool;
using Cthangover.Core.Utils;
using Cthangover.Mods.Interface.Menu;
using Cthangover.Mods.Interface.Tool;
using Cthangover.Tools.Hub;
using Cthangover.Mods.Interface.View;
using Godot;
@@ -20,13 +17,6 @@ namespace Cthangover.Tools.Tests.Windows
/// closes it. A window that throws while constructing or laying out fails
/// only its own check, the others still run. Ends with the runner contract
/// <c>[TEST_RESULT] name=tools_windows passed=N failed=M</c> and the exit code.
/// <para/>
/// Launched as the <c>novel_editor</c> game (<c>--game=novel_editor --new</c>)
/// it first waits for the collection's entry scene, the
/// <see cref="NovelEditorHub"/>, and checks it lists a launcher button for
/// every registered tool before opening the windows; after the windows it
/// plays a scenario from the editor and checks that both the scenario's
/// end and Stop return to the hub (<see cref="ScenarioPlayReturnCheck"/>).
/// </summary>
public partial class ToolWindowsTestDriverNode : Node
{
@@ -45,8 +35,6 @@ namespace Cthangover.Tools.Tests.Windows
private double _elapsed;
private bool _finished;
private Window _window;
private bool _inHub;
private ScenarioPlayReturnCheck _playCheck;
private readonly ToolWindowsErrorLogger _errors = new();
/// <summary>Creates the driver; <paramref name="shotsDir"/> null or empty disables screenshots.</summary>
@@ -78,25 +66,12 @@ namespace Cthangover.Tools.Tests.Windows
if (!Boot.IsReady || tree?.CurrentScene == null)
return;
_inHub = ActiveGame.Id == NovelEditorHub.SceneName;
if (_inHub && tree.CurrentScene is not NovelEditorHub)
return;
_tools.AddRange(ToolFactory.Instance.GetAll());
Check(_tools.Count > 0, $"tools registered ({_tools.Count})");
if (_inHub)
CheckHub(tree.CurrentScene);
OpenNext();
return;
}
if (_playCheck != null)
{
if (_playCheck.Tick(GetTree()))
Finish();
return;
}
if (_window == null)
return;
@@ -124,10 +99,7 @@ namespace Cthangover.Tools.Tests.Windows
_toolIndex++;
if (_toolIndex >= _tools.Count)
{
if (_inHub)
_playCheck = new ScenarioPlayReturnCheck(Check);
else
Finish();
Finish();
return;
}
@@ -146,24 +118,6 @@ namespace Cthangover.Tools.Tests.Windows
}
}
/// <summary>Every registered tool has its launcher button on the hub screen.</summary>
private void CheckHub(Node hub)
{
var keys = new HashSet<string>();
CollectButtonKeys(hub, keys);
foreach (var tool in _tools)
Check(keys.Contains(tool.LocaleKey), $"hub: launcher button for {tool.Id}");
SaveShot("novel_editor_hub");
}
private static void CollectButtonKeys(Node node, HashSet<string> keys)
{
if (node is Button button && button.HasMeta(MenuBuilder.LocaleMetaKey))
keys.Add(button.GetMeta(MenuBuilder.LocaleMetaKey).AsString());
foreach (var child in node.GetChildren())
CollectButtonKeys(child, keys);
}
private void InspectAndClose()
{
var id = _tools[_toolIndex].Id;