fix(tutorials): prevent crew training from reopening or trapping input

Record completion after the guided crew upgrade succeeds. Keep the guide dismissible and close it when its slot or menu target disappears. Compile the affected scripts with the stock queue flag bindings.
This commit is contained in:
N0VAN0M4LY committed 2026-11-30 05:02:55 +08:00
1 parent 0c9340f883
commit 0881d62766
25 files changed
+169 -9

No files matched your search

+15 -7
View File
@@ -64,6 +64,7 @@ let typeMap = {
Float = types.Float
Bool = types.Bool
CtrlsInGui = __CONTROL_MASKS__
QUEUE_TYPE_BIT = __QUEUE_MASKS__
}
function readText(p) {
let f = io.file(p, "rb")
@@ -177,7 +178,14 @@ def verify_gui_patches(
manifest_path = tmp_dir / "manifest.tsv"
manifest_path.write_text("\n".join(manifest_lines), encoding="utf-8")
# The standalone interpreter does not expose __argv as a script binding.
harness_source = HARNESS_SOURCE.replace("__CONTROL_MASKS__", _control_masks_literal(stock_archive))
harness_source = HARNESS_SOURCE.replace(
"__CONTROL_MASKS__",
_integer_table_literal(stock_archive, "globalscripts/sharedenums.nut", r"\benum\s+CtrlsInGui"),
)
harness_source = harness_source.replace(
"__QUEUE_MASKS__",
_integer_table_literal(stock_archive, "scripts/queue/queuetypebit.nut", r"\breturn\s+freeze\("),
)
harness_source = harness_source.replace("__MANIFEST_PATH__", json.dumps(manifest_path.as_posix(), ensure_ascii=False))
harness_path = tmp_dir / "harness.nut"
harness_path.write_text(harness_source, encoding="utf-8")
@@ -207,17 +215,17 @@ def verify_gui_patches(
return GuiCheckReport(len(patches), len(touched_files), tuple(errors))
def _control_masks_literal(archive: Archive) -> str:
"""Use the stock integer masks for constant expressions involving CtrlsInGui."""
source = archive.files.get("globalscripts/sharedenums.nut", b"").decode("utf-8")
enum = re.search(r"\benum\s+CtrlsInGui\s*\{([^{}]*)\}", source)
if enum is None:
def _integer_table_literal(archive: Archive, file: str, table_start: str) -> str:
"""Read a stock table of integer flags for constant expressions in the compiler."""
source = archive.files.get(file, b"").decode("utf-8")
table = re.search(table_start + r"\s*\{([^{}]*)\}", source)
if table is None:
return "{}"
fields = re.findall(
r"^[ \t]*([A-Za-z_][A-Za-z0-9_]*)[ \t]*=[ \t]*"
r"(0x[0-9a-fA-F]+|[0-9]+)[ \t]*,?[ \t]*(?://[^\r\n]*)?\r?$",
enum[1],
table[1],
re.MULTILINE,
)
return "{ " + ", ".join(f"{name} = {value}" for name, value in fields) + " }"