- CardCatalog: one list of card kinds for the palette, right-click New card and new-card names; Dice table and Deck are their own items. - LeftDock holds the palette and List view in the shared dock tab style. - Play greys the palette under a Switch to Build notice (replaces the greyed + Card button); + Card menu removed; Card palette button in Build. - Templates dropped from the palette land where they are let go. - Phones: + opens the palette full screen. - docs/SHEETS.md: the Sheets and unified editor plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
2.7 KiB
GDScript
70 lines
2.7 KiB
GDScript
extends AppTestBase
|
|
## List view: rows for every card with thread counts and Roll, search, new
|
|
## groups, and drag-and-drop moves (reorder, into a group, group in group).
|
|
## Run: tools/run_tests.sh list_view
|
|
|
|
|
|
func run() -> void:
|
|
if not await start_main():
|
|
return
|
|
await _test_rows()
|
|
await _test_moves()
|
|
finish()
|
|
|
|
|
|
func _rows(it: TreeItem, out: Array) -> Array:
|
|
var c := it.get_first_child()
|
|
while c:
|
|
out.append(c)
|
|
_rows(c, out)
|
|
c = c.get_next()
|
|
return out
|
|
|
|
|
|
func _find(id: String) -> TreeItem:
|
|
for it: TreeItem in _rows(main.list_view.tree.get_root(), []):
|
|
if ListTree._meta(it).get("id") == id:
|
|
return it
|
|
return null
|
|
|
|
|
|
func _test_rows() -> void:
|
|
var lv := main.list_view
|
|
_check(not lv.shown(), "the list starts hidden")
|
|
lv.set_shown(true)
|
|
await _frames(2)
|
|
var rows := _rows(lv.tree.get_root(), [])
|
|
_check(rows.size() == main.data.tables.size(), "a row per card (%d)" % rows.size())
|
|
var road := _find("road")
|
|
_check(road != null and road.get_text(ListTree.COL_THREADS).contains("←1") and road.get_text(ListTree.COL_ROLL) == "Roll", "a row shows its threads and Roll: " + (road.get_text(ListTree.COL_THREADS) if road else ""))
|
|
_check(road.get_tooltip_text(ListTree.COL_THREADS).contains("from Wilderness Travel"), "the thread tooltip says where they come from")
|
|
lv._search.text = "weapon"
|
|
lv._search.text_changed.emit("weapon")
|
|
await _frames()
|
|
var hits := _rows(lv.tree.get_root(), [])
|
|
_check(hits.size() >= 1 and hits.size() < rows.size(), "search narrows the list (%d rows)" % hits.size())
|
|
lv._search.text = ""
|
|
lv._search.text_changed.emit("")
|
|
|
|
|
|
func _test_moves() -> void:
|
|
var lv := main.list_view
|
|
var n := main.data.groups.size()
|
|
lv.new_group()
|
|
await _frames(2)
|
|
_check(main.data.groups.size() == n + 1, "+ Group adds an empty group")
|
|
var g := main.data.groups[main.data.groups.size() - 1]
|
|
ListOrder.move(main, {"kind": "card", "id": "towns"}, {"kind": "group", "id": g.id}, 0)
|
|
await _frames(2)
|
|
_check(main.data.group_of("towns") == g, "dropping a card on a group moves it in")
|
|
var f2 := main.data.add_group("Inner", [])
|
|
ListOrder.move(main, {"kind": "group", "id": f2.id}, {"kind": "group", "id": g.id}, 0)
|
|
_check(f2.parent == g.id, "a group dropped on a group goes inside it")
|
|
ListOrder.move(main, {"kind": "group", "id": g.id}, {"kind": "group", "id": f2.id}, 0)
|
|
_check(g.parent == "", "a group can't go inside its own inner group")
|
|
var ids := main.data.tables.map(func(t: RollTable) -> String: return t.id)
|
|
ListOrder.move(main, {"kind": "card", "id": ids[3]}, {"kind": "card", "id": ids[0]}, -1)
|
|
_check(main.data.tables[0].id == ids[3], "dropping above a card reorders the spread's list")
|
|
main.undo_redo.undo()
|
|
_check(main.data.tables[0].id == ids[0], "and undo puts it back")
|
|
|