2026-11-10 19:53:07 -06:00
|
|
|
extends TestBase
|
Help: topics for every new feature, a cheat sheet, and Try a demo spreads
Twelve new Help topics (menus, selecting and resizing, nested groups,
themes, List view, the Book, rolling more than once, pausing, costs,
one table adjusting another, sheets and saving, pictures, phones), and a
Keyboard shortcuts topic split into keys, mouse and touch. Topics with
[demo]key[/demo] get a 'Try a demo spread' link: DemoSpreads builds a
small example, DemoMode shows it unsaved and unlisted with Keep a copy
and Back to my spread. --demo=KEY opens one from the command line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:24:57 -06:00
|
|
|
## Help's demo spreads: every demo builds and rolls cleanly, Help links to
|
|
|
|
|
## them, and opening one shows it unsaved with a way back.
|
|
|
|
|
## Run: godot --headless --path . -s res://tests/test_demos.gd -- --sample
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _init() -> void:
|
2026-11-10 19:53:07 -06:00
|
|
|
if not require_sample():
|
Help: topics for every new feature, a cheat sheet, and Try a demo spreads
Twelve new Help topics (menus, selecting and resizing, nested groups,
themes, List view, the Book, rolling more than once, pausing, costs,
one table adjusting another, sheets and saving, pictures, phones), and a
Keyboard shortcuts topic split into keys, mouse and touch. Topics with
[demo]key[/demo] get a 'Try a demo spread' link: DemoSpreads builds a
small example, DemoMode shows it unsaved and unlisted with Keep a copy
and Back to my spread. --demo=KEY opens one from the command line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:24:57 -06:00
|
|
|
return
|
|
|
|
|
_test_builds()
|
2026-11-10 19:53:07 -06:00
|
|
|
if not await start_main():
|
|
|
|
|
return
|
Help: topics for every new feature, a cheat sheet, and Try a demo spreads
Twelve new Help topics (menus, selecting and resizing, nested groups,
themes, List view, the Book, rolling more than once, pausing, costs,
one table adjusting another, sheets and saving, pictures, phones), and a
Keyboard shortcuts topic split into keys, mouse and touch. Topics with
[demo]key[/demo] get a 'Try a demo spread' link: DemoSpreads builds a
small example, DemoMode shows it unsaved and unlisted with Keep a copy
and Back to my spread. --demo=KEY opens one from the command line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:24:57 -06:00
|
|
|
await _test_open()
|
2026-11-10 19:53:07 -06:00
|
|
|
finish()
|
Help: topics for every new feature, a cheat sheet, and Try a demo spreads
Twelve new Help topics (menus, selecting and resizing, nested groups,
themes, List view, the Book, rolling more than once, pausing, costs,
one table adjusting another, sheets and saving, pictures, phones), and a
Keyboard shortcuts topic split into keys, mouse and touch. Topics with
[demo]key[/demo] get a 'Try a demo spread' link: DemoSpreads builds a
small example, DemoMode shows it unsaved and unlisted with Keep a copy
and Back to my spread. --demo=KEY opens one from the command line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:24:57 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_builds() -> void:
|
|
|
|
|
var rng := RandomNumberGenerator.new()
|
|
|
|
|
for key: String in DemoSpreads.TITLES:
|
|
|
|
|
var b := DemoSpreads.build(key)
|
|
|
|
|
_check(not b.tables.is_empty() and b.id == "demo-" + key, "demo %s builds" % key)
|
|
|
|
|
var start := b.tables[0] if b.tables[0].kind != RollTable.KIND_VARIABLE else b.tables[1]
|
|
|
|
|
var tree := Roller.roll(b, start.id, rng)
|
|
|
|
|
var bad := Roller.flatten(tree, []).filter(func(s: Dictionary) -> bool: return s.get("stop", false) and not s.get("deck_empty", false))
|
|
|
|
|
_check(bad.is_empty(), "demo %s rolls cleanly: %s" % [key, str(bad.map(func(s: Dictionary) -> String: return str(s.get("text", ""))))])
|
|
|
|
|
var book := DemoSpreads.build("book")
|
|
|
|
|
_check(book.page_uses("p_sword") == 2, "the Book demo links two results to its page")
|
|
|
|
|
var linked := book.get_table("goblin").entries[1]
|
|
|
|
|
book.sync_page("p_sword")
|
|
|
|
|
_check(linked.text.contains("Holy Light"), "and they show the page's text")
|
|
|
|
|
var help := FileAccess.get_file_as_string("res://help/topics.txt")
|
|
|
|
|
var re := RegEx.create_from_string("\\[demo\\]([a-z_]+)\\[/demo\\]")
|
|
|
|
|
for m in re.search_all(help):
|
|
|
|
|
_check(DemoSpreads.has(m.get_string(1)), "help's demo link %s exists" % m.get_string(1))
|
|
|
|
|
_check(HelpDialog._inline("[demo]deck[/demo]").contains("url=demo:deck"), "a demo marker becomes a link")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_open() -> void:
|
|
|
|
|
var before := main.data.id
|
|
|
|
|
main.demo.open("deck")
|
|
|
|
|
await _frames(3)
|
|
|
|
|
_check(main.data.id == "demo-deck" and main.demo.active() and not main._saving_enabled, "a demo opens unsaved, with its bar")
|
|
|
|
|
main.demo.back()
|
|
|
|
|
await _frames(3)
|
|
|
|
|
_check(not main.demo.active() and main.data.id == before, "Back to my spread returns")
|
|
|
|
|
|