Subtitles and menu text sections in the editor

This commit is contained in:
2026-10-09 22:42:50 +02:00
parent ef68edbe45
commit a10593ec24
9 changed files with 816 additions and 31 deletions

View File

@@ -111,6 +111,94 @@ def test_bank_sound_apply_revert_in_editor(win, tmp_path):
assert files(root) == before and not w.ws.store.entries
def test_subtitles_tab_edit_and_link(win):
w, root, _ = win
before = files(root)
w.tabs.setCurrentWidget(w.subs)
p = w.subs
assert p.lang == "INT" and p.model.rowCount() == 2
p.search.setText("scanner")
p._filter()
assert p.proxy.rowCount() == 1
p.table.selectRow(0)
assert p.edit.text() == "Scanner line two." and "/ 17 characters" in p.lbl_info.text()
p.edit.setText("x" * 30)
assert not p.b_apply.isEnabled() # longer than the room
p.edit.setText("Scan two.")
p.apply_current()
key = p.current.key
assert w.ws.texts.state(key) == "modified" and p.model.modified[key] == "Scan two."
p.go_to_sound.emit(p.current.sound) # "Go to the sound"
assert w.tabs.currentIndex() == 0 and w.editor.sound.name == "CHR_RadioScanner_2"
box = w.editor.subtitle
assert [e.text() for e in box.edits] == ["Scan two.", "Second part."]
box.edits[1].setText("Part two.")
box.apply()
assert w.ws.texts.current(key.replace(":0", ":1")) == "Part two."
box.open_in_list.emit(box.keys[1]) # back to the Subtitles tab
assert w.tabs.currentWidget() is p and p.current.key == box.keys[1]
box.revert()
assert files(root) == before and not w.ws.texts.records()
def test_subtitles_find_replace(win):
w, root, _ = win
before = files(root)
w.tabs.setCurrentWidget(w.subs)
p = w.subs
assert p.find_replace("line", "row") == 1
assert w.ws.texts.current("SUB:INT:%s:0" % synth.SPEECH_EVENT) == "Scanner row two."
p.revert_all()
assert files(root) == before
def test_menu_text_tab(win):
w, root, _ = win
before = files(root)
w.tabs.setCurrentWidget(w.menu)
p = w.menu
assert p.model.rowCount() == 4
p.filters["File"].setCurrentText("FRONTEND.int")
p.search.setText("press")
p._filter()
assert p.proxy.rowCount() == 1
p.table.selectRow(0)
p.edit.setText("Press Enter to start")
p.apply_current()
assert w.ws.texts.current("MENU:INT:FRONTEND.int:Menu:Start") == "Press Enter to start"
p.cb_mod.setChecked(True)
assert p.proxy.rowCount() == 1
p.revert_all()
assert files(root) == before
def test_mod_with_texts(win, tmp_path):
w, root, _ = win
tx = w.ws.texts
tx.apply({"SUB:INT:%s:0" % synth.SPEECH_EVENT: "Mod line.", "MENU:INT:FRONTEND.int:Menu:Quit": "Leave"})
pkg = str(tmp_path / "texts.acmod")
w.export_mod_dialog(path=pkg, keys=tx.modified(), title="texts")
tx.revert_all()
w.import_mod_dialog(path=pkg, confirm=False)
assert tx.current("MENU:INT:FRONTEND.int:Menu:Quit") == "Leave"
assert tx.current("SUB:INT:%s:0" % synth.SPEECH_EVENT) == "Mod line."
tx.revert_all()
def test_text_undone_outside_shows_banner(win):
w, root, _ = win
tx = w.ws.texts
k = "MENU:INT:FRONTEND.int:Menu:Start"
tx.apply({k: "Go"})
path = tx.files(k)[0]
open(path, "wb").write(open(w.ws.store.full_copy(w.ws.game.rel(path)), "rb").read()) # like 'verify files'
w.check_problems()
assert not w.banner.isHidden() and "text changes" in w.banner_text.text()
w.reapply_lost()
assert tx.current(k) == "Go" and tx.state(k) == "modified"
tx.revert_all()
def test_record_simulated_input(win):
w, root, _ = win
w.select_name("CHR_RadioScanner_1")