cooking_walk: find the answer box by type, not by name
The previous answer box is freed with QueueFree when hidden; when the next question opens in the same frame the new box gets an auto name and the old one, still named AnswerBox, is already queued for deletion. On a slow disk this happened often and the test failed to find the variants.
This commit is contained in:
1 parent
0a32c0756c
commit
f11cbbb651
1 file changed
+25
-1
@@ -435,7 +435,7 @@ namespace Mods.CookingWalkTest
|
||||
{
|
||||
// IDialogBox — контракт ядра без Node-членов; сам бокс живёт
|
||||
// под concrete-узлом DialogBox в дереве.
|
||||
var box = (dialogBox as Node)?.FindChild("AnswerBox", true, false) as Control;
|
||||
var box = FindAnswerBox(dialogBox as Node);
|
||||
if (box == null)
|
||||
throw new CheckException("AnswerBox node not found under dialog box");
|
||||
var content = box.FindChild("Content", true, false);
|
||||
@@ -451,6 +451,30 @@ namespace Mods.CookingWalkTest
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет показанный AnswerBox по типу, а не по имени узла: прошлый бокс
|
||||
/// освобождается через QueueFree при скрытии, и если следующий вопрос
|
||||
/// открывается в том же кадре, новый бокс получает автоимя
|
||||
/// (<c>@Control@N</c>), а старый с именем «AnswerBox» уже помечен на удаление.
|
||||
/// </summary>
|
||||
private static Cthangover.Mods.Dialog.AnswerBox FindAnswerBox(Node node)
|
||||
{
|
||||
if (node == null)
|
||||
return null;
|
||||
|
||||
foreach (var child in node.GetChildren())
|
||||
{
|
||||
if (child is Cthangover.Mods.Dialog.AnswerBox box && !box.IsQueuedForDeletion() && box.Visible)
|
||||
return box;
|
||||
|
||||
var found = FindAnswerBox(child);
|
||||
if (found != null)
|
||||
return found;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private bool TryGetDialogBox(out IDialogBox box)
|
||||
{
|
||||
var node = SceneContextNode.FindNode<Node>("DialogBox");
|
||||
|
||||
Reference in new issue
Block a user