48 lines
2.1 KiB
GDScript3
48 lines
2.1 KiB
GDScript3
|
|
extends TestBase
|
||
|
|
## Group marks: a member card's top-right corner shows its group's colour (its
|
||
|
|
## own, else the theme's GROUP); a card that only lies inside the frame has
|
||
|
|
## none. The colour is saved and undoable.
|
||
|
|
## Run: godot --headless --path . -s res://tests/test_group_marks.gd -- --sample
|
||
|
|
|
||
|
|
|
||
|
|
func _init() -> void:
|
||
|
|
if not await start_main():
|
||
|
|
return
|
||
|
|
main.data.load_dict({"format_version": 2, "id": "marks-test", "name": "Marks", "tables": [
|
||
|
|
{"id": "a", "name": "Alpha", "x": 40, "y": 60, "entries": [{"id": "e1", "text": "One"}]},
|
||
|
|
{"id": "b", "name": "Bravo", "x": 400, "y": 60, "entries": [{"id": "e1", "text": "Two"}]},
|
||
|
|
{"id": "c", "name": "Charlie", "x": 40, "y": 500, "entries": [{"id": "e1", "text": "Three"}]},
|
||
|
|
]})
|
||
|
|
main._rebuild_cards()
|
||
|
|
main.set_mode(Main.Mode.BUILD)
|
||
|
|
await _frames()
|
||
|
|
var g := main.data.add_group("G", ["a", "b"])
|
||
|
|
main.mark_dirty()
|
||
|
|
await _frames()
|
||
|
|
var mark := main.card_for("a").group_mark
|
||
|
|
_check(mark.visible and mark._color == Style.GROUP, "a member shows the theme's group mark")
|
||
|
|
_check(not main.card_for("c").group_mark.visible, "a card outside the group has no mark")
|
||
|
|
|
||
|
|
Actions.set_group_colour(main, g, "#3c8dd8")
|
||
|
|
await _frames()
|
||
|
|
_check(main.card_for("b").group_mark._color == Color("#3c8dd8"), "colouring the group recolours its members' marks")
|
||
|
|
_eq(TableGroup.from_dict(g.to_dict()).color, "#3c8dd8", "the group colour is saved")
|
||
|
|
main.undo_redo.undo()
|
||
|
|
await _frames()
|
||
|
|
_check(main.card_for("b").group_mark._color == Style.GROUP, "undo puts the theme colour back")
|
||
|
|
|
||
|
|
# Lying inside the frame isn't membership: no mark until it joins.
|
||
|
|
var c := main.card_for("c")
|
||
|
|
c.position = main.data.groups[0].position + Vector2(20, 40)
|
||
|
|
await _frames()
|
||
|
|
_check(not c.group_mark.visible, "a card that only overlaps the frame stays unmarked")
|
||
|
|
main.data.add_to_group("c", main.data.groups[0].id)
|
||
|
|
main.mark_dirty()
|
||
|
|
await _frames()
|
||
|
|
_check(main.card_for("c").group_mark.visible, "joining the group marks it")
|
||
|
|
main.data.remove_from_group("c")
|
||
|
|
main.mark_dirty()
|
||
|
|
await _frames()
|
||
|
|
_check(not main.card_for("c").group_mark.visible, "leaving the group clears the mark")
|
||
|
|
finish()
|