Partly drawn tint: a colour layer behind the row

The row's own background is see-through on a plain row, so tinting it
showed nothing. A ColorRect behind the contents now carries the tint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
RobinFiredrake 2026-12-01 16:42:08 -06:00
parent e060fda21f
commit 13b8834564
2 changed files with 32 additions and 6 deletions

View file

@ -99,12 +99,16 @@ func _test_partly_drawn(t: RollTable) -> void:
(main.decks.get_or_add(t.id, DeckState.new()) as DeckState).take(first)
card.update_deck()
var row: Control = card.rows[first.id]
_check(row.self_modulate == TableCardSkin.partly_drawn_tint() and row.modulate == Color.WHITE, "a partly drawn row is tinted")
var layer := TableCardSkin.partly_drawn_layer(row)
_check(layer != null and layer.visible and layer.color == TableCardSkin.partly_drawn_tint() and layer.get_index() == 0, "a partly drawn row is tinted")
await _frames()
_check(layer.size.x > 0.0 and layer.size.y > 0.0, "the tint covers the row")
_eq(number.text, "1 / 2", "a partly drawn row shows its copies left")
main.set_mode(Main.Mode.BUILD)
await _frames()
card = main.card_for(t.id)
_check(card.rows[first.id].self_modulate == TableCardSkin.partly_drawn_tint(), "it is tinted in Build mode too")
var build_layer := TableCardSkin.partly_drawn_layer(card.rows[first.id])
_check(build_layer != null and build_layer.visible, "it is tinted in Build mode too")
main.set_mode(Main.Mode.PLAY)
await _frames()
card = main.card_for(t.id)
@ -112,7 +116,8 @@ func _test_partly_drawn(t: RollTable) -> void:
card.update_deck()
row = card.rows[first.id]
number = card.rows_ui.parts[first.id]["num"]
_check(row.modulate == TableCardSkin.DRAWN_LOOK and row.self_modulate == Color.WHITE, "with no copies left the row is greyed out")
var gone_layer := TableCardSkin.partly_drawn_layer(row)
_check(row.modulate == TableCardSkin.DRAWN_LOOK and (gone_layer == null or not gone_layer.visible), "with no copies left the row is greyed out")
_eq(number.text, plain, "it shows its own number again")
first.weight = weight
main.reshuffle_table(t.id)

View file

@ -103,7 +103,7 @@ func dim_drawn() -> void:
var gone := left <= 0
var partly := not gone and left < copies
row.modulate = DRAWN_LOOK if gone else Color.WHITE
row.self_modulate = partly_drawn_tint() if partly else Color.WHITE
_show_partly_drawn(row, partly)
row.tooltip_text = "Already drawn: Shuffle the deck to put it back" if gone else ""
_show_copies_left(e, left, copies, partly)
@ -113,9 +113,30 @@ func dim_drawn() -> void:
const PARTLY_DRAWN_TURN := 200.0
## The tint on a row with some of its copies drawn.
## The tint on a row with some of its copies drawn (laid over the row, so it
## shows on a plain row, a striped one and a lit one alike).
static func partly_drawn_tint() -> Color:
return Color.WHITE.lerp(Style.turned_accent(PARTLY_DRAWN_TURN), 0.55)
return Color(Style.turned_accent(PARTLY_DRAWN_TURN), 0.45)
## A row's partly drawn tint: a colour layer behind its contents, made on
## first use. Returns the layer, or null when the row has none.
static func partly_drawn_layer(row: Control) -> ColorRect:
return row.get_node_or_null("PartlyDrawnTint") as ColorRect
func _show_partly_drawn(row: Control, partly: bool) -> void:
var layer := partly_drawn_layer(row)
if layer == null:
if not partly:
return
layer = ColorRect.new()
layer.name = "PartlyDrawnTint"
layer.mouse_filter = Control.MOUSE_FILTER_IGNORE
row.add_child(layer)
row.move_child(layer, 0) # first child: drawn behind the row's contents
layer.color = partly_drawn_tint()
layer.visible = partly
## Play mode: a partly drawn row's number becomes "<left> / <weight>".