Skip animations setting; questions animate like pauses; pop-ups fade in

View > Skip animations makes every roll instant (Shift-click still does it
for one roll). A roll with a question now animates up to it and on after
the answer, instead of jumping to the end. Pause and question pop-ups fade
and grow in unless the roll skips animations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
RobinFiredrake 2026-11-15 12:25:08 -06:00
parent fe0f52180b
commit 91c19980f7
8 changed files with 102 additions and 34 deletions

View file

@ -184,7 +184,7 @@ func _test_lit_and_choice() -> void:
var node := main.group_node(g.id)
# A real roll through the hidden choice card: the pop-up opens and answers.
main.prompt_hook = main.rolling._ask_player
main.start_roll("start")
main.start_roll("start", true)
var d: ChoiceDialog = null
for i in 60:
await process_frame

View file

@ -17,6 +17,7 @@ func _init() -> void:
await _load_demo()
_test_cards()
await _test_scripted()
await _test_question_animates()
await _test_dialog_answers()
await _test_cancel()
await _test_replace()
@ -110,13 +111,13 @@ func _test_cards() -> void:
func _test_scripted() -> void:
var log: Array = []
main.prompt_hook = _scripted({"text": "Brin", "number": 3, "pick": 1}, log)
main.start_roll("start")
main.start_roll("start", true)
_eq(log.size(), 3, "three questions: name, rooms, way out")
var kinds: Array = []
for r: Dictionary in log:
kinds.append(r["kind"])
_eq(kinds, ["text", "number", "pick"], "asked in chain order")
_check(main.current.get("done", false), "a roll with questions shows at once after the last answer")
_check(main.current.get("done", false), "a fast roll with questions shows at once after the last answer")
_eq(_var("name"), "Brin", "text answer saved")
_eq(_var("rooms"), 3, "number answer saved")
var passes := 0
@ -143,6 +144,29 @@ func _test_scripted() -> void:
main.prompt_hook = main.rolling._ask_player
## A normal (not fast) roll animates up to a question and on after it, as a
## pause does, and its pop-up fades in; Skip animations makes it all instant.
func _test_question_animates() -> void:
var log: Array = []
main.prompt_hook = _scripted({"text": "Brin", "number": 1, "pick": 1}, log)
main.start_roll("start")
_eq(log.size(), 0, "a normal roll animates before its first question")
for i in 1200:
await process_frame
if main.current.get("done", false):
break
_check(main.current.get("done", false) and not main.current.get("fast", false), "the roll animates on after the answers")
SkipAnimations.set_on(main, true)
log.clear()
main.start_roll("start")
_check(log.size() >= 3, "Skip animations: the questions come at once")
SkipAnimations.set_on(main, false)
main.prompt_hook = main.rolling._ask_player
var dialog := ModalCard.new("Plain")
_check(not dialog.animate_in, "pop-ups don't animate unless a roll asks for it")
dialog.free()
func _test_dialog_answers() -> void:
main.start_roll("start", true)
await process_frame
@ -186,7 +210,7 @@ func _test_dialog_answers() -> void:
func _test_cancel() -> void:
main.start_roll("start")
main.start_roll("start", true)
await process_frame
var d := main.rolling.pending_choice()
_check(d != null, "a pop-up is open")
@ -202,7 +226,7 @@ func _test_cancel() -> void:
_check(main.tray._halt.visible and main.tray._halt_label.text.contains("Cancelled"), "the tray says Cancelled")
_check(main.rolling_ctx == null, "no roll is left running")
# Freeing the dialog some other way also answers Cancel.
main.start_roll("start")
main.start_roll("start", true)
await process_frame
d = main.rolling.pending_choice()
if d:
@ -212,13 +236,13 @@ func _test_cancel() -> void:
func _test_replace() -> void:
main.start_roll("start")
main.start_roll("start", true)
await process_frame
var first := main.rolling.pending_choice()
_check(first != null, "first roll asks")
var first_reply := first.reply if first else null
var history := main.history.size()
main.start_roll("start")
main.start_roll("start", true)
_check(first_reply != null and first_reply.finished, "a new roll answers the old question with Cancel")
await process_frame
var second := main.rolling.pending_choice()
@ -244,7 +268,7 @@ func _test_replace() -> void:
func _test_keys() -> void:
main.start_roll("start")
main.start_roll("start", true)
await process_frame
var d := main.rolling.pending_choice()
if d:

View file

@ -13,6 +13,8 @@ var _pulse_tween: Tween
## True when _play_one lit nodes again (after a pause) without redrawing yet.
var _relit := false
var _choice: ChoiceDialog
## True while the roll asking a question skips animations (its pop-up appears at once).
var _ask_fast := false
## Rolls waiting at a paused thread.
var pauses: RollPauses
## Deck-mode draws not shown yet in an animated roll.
@ -33,10 +35,10 @@ func _init(p_main: Main) -> void:
## Rolls a table and plays the result down its pipes. A fast roll (Shift held
## while clicking, or `fast`) skips the flicker and the beads and shows the
## whole result at once. Choice cards still ask (docs/LOGIC.md §8): before a
## question opens, the steps so far light up; after the last answer the rest
## of the roll shows at once. Starting a roll while a question is open cancels
## the old roll.
## whole result at once; so does the "Skip animations" setting. Choice cards
## still ask (docs/LOGIC.md §8): the roll animates up to the question, waits,
## then animates the rest, as a pause does. Starting a roll while a question
## is open cancels the old roll.
func start_roll(tid: String, fast: bool = false) -> void:
var t := m.data.get_table(tid)
if t == null or t.kind == RollTable.KIND_VARIABLE:
@ -48,7 +50,7 @@ func start_roll(tid: String, fast: bool = false) -> void:
# A minimized question keeps waiting; a new roll must not cancel it.
if _choice_waiting("Answer the waiting question first"):
return
fast = fast or Input.is_key_pressed(KEY_SHIFT)
fast = fast or Input.is_key_pressed(KEY_SHIFT) or SkipAnimations.on(m)
_archive_current()
_token += 1
if m.sound:
@ -80,9 +82,7 @@ func start_roll(tid: String, fast: bool = false) -> void:
if ctx.persistent_changed:
m.local_state._store_variables()
return
# Questions light the roll so far at once, so the rest shows at once too;
# a pause (or a cost) animates up to itself and the rest animates after.
var prompted: bool = run.get("other_prompt", false)
# A question, pause or cost animates up to itself; the rest animates after.
m.lit_entries.clear()
m.lit_pipes.clear()
m.lit_texts.clear()
@ -92,7 +92,7 @@ func start_roll(tid: String, fast: bool = false) -> void:
if ctx.halted != "":
m.current["halted"] = ctx.halted
m.local_state._store_roll(ctx)
if fast or prompted or (m.current["all"] as Array).size() > LONG_CHAIN:
if fast or (m.current["all"] as Array).size() > LONG_CHAIN:
_finish_fast_roll()
return
deck_reveal.hold(m.current["all"], my)
@ -118,26 +118,25 @@ func _prompt_for(req: Dictionary, run: Dictionary) -> Variant:
m.current["prompted"] = true
m.current["asking"] = Formatter.strip_tags(str(req.get("title", "")))
var reply: Variant
if run.get("fast", false) or m.rolling_ctx == null:
show_progress()
else:
# The roll so far animates (dice, lights, threads), then it waits.
# Steps shown before an earlier pause are listed again as they replay,
# and the previous roll's lights go out first.
m.current["steps"] = []
m.lit_entries.clear()
m.lit_pipes.clear()
m.lit_texts.clear()
m.lit_columns.clear()
m._refresh_lit()
await _play_node(m.rolling_ctx.root, int(run["token"]))
if int(run["token"]) != _token:
return null
_ask_fast = run.get("fast", false)
if str(req.get("kind", "")) == "pause":
if run.get("fast", false) or m.rolling_ctx == null:
show_progress()
else:
# The roll so far animates (dice, lights, threads), then it waits.
# Steps shown before an earlier pause are listed again as they replay,
# and the previous roll's lights go out first.
m.current["steps"] = []
m.lit_entries.clear()
m.lit_pipes.clear()
m.lit_texts.clear()
m.lit_columns.clear()
m._refresh_lit()
await _play_node(m.rolling_ctx.root, int(run["token"]))
if int(run["token"]) != _token:
return null
reply = await pauses.wait(req, run)
else:
run["other_prompt"] = true
show_progress()
reply = await m.prompt_hook.call(req)
if int(run["token"]) != _token:
return null
@ -150,6 +149,7 @@ func _prompt_for(req: Dictionary, run: Dictionary) -> Variant:
func _ask_player(req: Dictionary) -> Variant:
cancel_choice()
var d := ChoiceDialog.new(req)
d.animate_in = not _ask_fast
_choice = d
var waiter := d.reply
m._add_modal(d)

View file

@ -11,6 +11,8 @@ var body: VBoxContainer
var footer: HBoxContainer
var title_label: Label
var close_on_backdrop := true
## Fade and rise in when shown (roll pop-ups, unless animations are skipped).
var animate_in := false
var _scroll: ScrollContainer
var _width := 520.0
@ -70,8 +72,22 @@ func _init(title: String = "", width: float = 520.0) -> void:
func _ready() -> void:
resized.connect(_fit)
_fit()
if animate_in:
modulate.a = 0.0
await get_tree().process_frame
_fit()
if animate_in and is_inside_tree():
_play_entrance()
## The backdrop fades in while the card grows into place with a small overshoot.
## (Scale only: the card sits in a CenterContainer, which owns its position.)
func _play_entrance() -> void:
card.pivot_offset = card.size / 2.0
card.scale = Vector2(0.94, 0.94)
var tween := create_tween().set_parallel(true)
tween.tween_property(self, "modulate:a", 1.0, 0.2).set_ease(Tween.EASE_OUT)
tween.tween_property(card, "scale", Vector2.ONE, 0.3).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT)
func _fit() -> void:

View file

@ -45,6 +45,7 @@ func _popup(item: Dictionary) -> ModalCard:
dialog.add_button("Later", "plain", dialog.close)
dialog.add_button("Don't pay" if item["cost"] else "Stop here", "plain", reply.bind(false))
dialog.add_button("Pay ▸" if item["cost"] else "Continue ▸", "primary", reply.bind(true))
dialog.animate_in = not (item["run"] as Dictionary).get("fast", false)
m._add_modal(dialog)
return dialog

20
ui/skip_animations.gd Normal file
View file

@ -0,0 +1,20 @@
class_name SkipAnimations
extends RefCounted
## The "Skip animations" setting (View ▾): every roll shows its result at once,
## with no flicker, beads or pop-up motion. Shift-click does the same for one roll.
const SETTING := "skip_animations"
## Used when there is no state store (tests that build a bare Main).
static var _skip_mem := false
static func on(m: Main) -> bool:
return bool(m.state.get_setting(SETTING, false)) if m and m.state else _skip_mem
static func set_on(m: Main, value: bool) -> void:
_skip_mem = value
if m and m.state:
m.state.set_setting(SETTING, value)
m.state.save()

View file

@ -0,0 +1 @@
uid://c7430sis573db

View file

@ -14,6 +14,7 @@ const ID_LIST := 6
const ID_BOOK := 7
const ID_SOUND := 8
const ID_CONFIRM_DELETE := 9
const ID_SKIP_ANIM := 10
var m: Main
@ -38,6 +39,8 @@ func setup(p_main: Main) -> void:
pm.add_check_item("Book", ID_BOOK)
pm.add_check_item("Ask before deleting", ID_CONFIRM_DELETE)
pm.set_item_tooltip(pm.get_item_index(ID_CONFIRM_DELETE), "The Delete key asks “Are you sure?” first")
pm.add_check_item("Skip animations", ID_SKIP_ANIM)
pm.set_item_tooltip(pm.get_item_index(ID_SKIP_ANIM), "Rolls show their result at once, with no flicker, beads or pop-up motion.\nShift-click a die to skip them for one roll.")
pm.set_item_tooltip(pm.get_item_index(ID_BOOK), "Reusable results (Pages) to drag onto tables")
pm.set_item_tooltip(pm.get_item_index(ID_LIST), "The cards as a list with their groups, beside the spread")
pm.add_separator()
@ -60,6 +63,7 @@ func sync() -> void:
pm.set_item_checked(pm.get_item_index(ID_LIST), m.list_view.visible)
pm.set_item_checked(pm.get_item_index(ID_BOOK), m.book.visible)
pm.set_item_checked(pm.get_item_index(ID_CONFIRM_DELETE), DeleteKey.asks(m))
pm.set_item_checked(pm.get_item_index(ID_SKIP_ANIM), SkipAnimations.on(m))
func collapse_label() -> String:
@ -86,5 +90,7 @@ func activate(id: int) -> void:
m.add_child(ThemeDialog.new(m))
ID_CONFIRM_DELETE:
DeleteKey.set_asks(m, not DeleteKey.asks(m))
ID_SKIP_ANIM:
SkipAnimations.set_on(m, not SkipAnimations.on(m))
ID_SOUND:
SoundPanel.open(m, get_global_rect().position + Vector2(0, size.y + 4))