#149 - a line is typed out at about three and a half words a second, with a scan sweep running down the panel and faint rules across it while it decodes. The frame carries the charge while it works and settles when the line lands; the caret is a solid write-head during the decode and only starts blinking once it is waiting on the reader. Two implementation notes worth keeping. The full text is set and then REVEALED with visible_characters rather than the string being grown - a growing string re-wraps on nearly every frame, so words jump between rows as they are typed. And a press on a line still arriving FINISHES it instead of dismissing it: without that, a player clicking at their usual pace skips the second line having never seen a word of it, which is the exact thing #127 exists to prevent. #153 - "after a dialog popup the input system is lost on keypress". Nothing was lost; it was never delivered. A dialog stops the tree (#128), a paused node receives no input, so a key RELEASED while the line was up never reached the controller - keys_down kept it and the fleet flew on in that direction once the game restarted. NOTIFICATION_UNPAUSED arrives whatever a node's process mode is, which makes it the one moment the question can be asked, and the physical keyboard is the authority on what is actually held. That fixes anything that stops the tree, not only dialogs, and the test checks it that way. #154 - the banner was the ninth child of the UI layer and every panel came after it, so all twelve of them drew over the top. It is the last child now, in both scenes. Input order was never the problem and does not change: the UI layer already sees unhandled input before the controllers do.
This commit is contained in:
parent
721913c040
commit
b721760803
9 changed files with 419 additions and 23 deletions
|
|
@ -26,6 +26,15 @@ extends Control
|
|||
# The pause is owned HERE rather than by each caller, because the thing that
|
||||
# must not get out of step is "a line is showing" and "the game is stopped",
|
||||
# and the only code that knows the first is this file.
|
||||
#
|
||||
# #149: a line ARRIVES rather than appearing. It is typed out at a readable
|
||||
# rate, with a scan sweep running down the panel while it does - a
|
||||
# transmission being decoded rather than a caption being switched on.
|
||||
#
|
||||
# A press during the typing FINISHES it instead of dismissing the line. That
|
||||
# is not a flourish: without it, a player who clicks quickly through two
|
||||
# lines never sees the second one at all, and the whole point of #127 was
|
||||
# that lines wait for the reader.
|
||||
|
||||
signal dismissed
|
||||
|
||||
|
|
@ -46,6 +55,14 @@ const SPEAKER_FONT_SIZE: int = 20
|
|||
const SPEAKER_PAD: float = 12.0
|
||||
const SPEAKER_INSET: float = 46.0
|
||||
const DEFAULT_SPEAKER: String = "CONVOY CONTROL"
|
||||
# #149: how fast a line decodes. Fast enough not to be a wait, slow enough
|
||||
# to read as arriving - about three and a half words a second.
|
||||
const CHARS_PER_SECOND: float = 42.0
|
||||
# The scan sweep's travel time, top to bottom of the panel.
|
||||
const SWEEP_SECONDS: float = 0.9
|
||||
const SWEEP_COLOR: Color = Color(0.55, 0.95, 1.0)
|
||||
# Faint horizontal rules over the whole panel, the way a screen has them.
|
||||
const SCANLINE_GAP: float = 7.0
|
||||
|
||||
var label: Label
|
||||
var speaker_label: Label
|
||||
|
|
@ -53,6 +70,8 @@ var queued: Array = []
|
|||
var current: String = ""
|
||||
var speaker: String = ""
|
||||
var shown_for: float = 0.0
|
||||
# How much of the current line has been decoded, in characters.
|
||||
var revealed: float = 0.0
|
||||
# Whether the pause currently in force is OURS. Checked before lifting it, so
|
||||
# a pause somebody else put on (a menu, a future one) is never lifted by a
|
||||
# dialog closing.
|
||||
|
|
@ -184,6 +203,12 @@ func is_speaking() -> bool:
|
|||
func dismiss() -> bool:
|
||||
if current == "":
|
||||
return false
|
||||
# #149: still arriving, so this press is "show me the rest" rather than
|
||||
# "I have read it". It still counts as handled - the press must not fall
|
||||
# through and steer the fleet either way.
|
||||
if is_typing():
|
||||
finish_typing()
|
||||
return true
|
||||
dismissed.emit()
|
||||
_advance()
|
||||
return true
|
||||
|
|
@ -191,6 +216,7 @@ func dismiss() -> bool:
|
|||
|
||||
func _advance() -> void:
|
||||
shown_for = 0.0
|
||||
revealed = 0.0
|
||||
if queued.is_empty():
|
||||
current = ""
|
||||
speaker = ""
|
||||
|
|
@ -200,7 +226,12 @@ func _advance() -> void:
|
|||
var next: Dictionary = queued.pop_front()
|
||||
current = String(next.line)
|
||||
speaker = String(next.speaker)
|
||||
revealed = 0.0
|
||||
label.text = current
|
||||
# The full text is set and then hidden a character at a time, rather than
|
||||
# the text growing. Growing it would re-wrap the line on nearly every
|
||||
# frame, so words would jump between rows as they were typed.
|
||||
label.visible_characters = 0
|
||||
speaker_label.text = speaker
|
||||
visible = true
|
||||
_layout()
|
||||
|
|
@ -208,12 +239,27 @@ func _advance() -> void:
|
|||
_sync_pause()
|
||||
|
||||
|
||||
func is_typing() -> bool:
|
||||
return current != "" and revealed < float(current.length())
|
||||
|
||||
|
||||
# Shows the whole line at once. What a press does while it is still arriving.
|
||||
func finish_typing() -> void:
|
||||
revealed = float(current.length())
|
||||
if label != null:
|
||||
label.visible_characters = -1
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if current == "":
|
||||
return
|
||||
# Only for the fade-in and the prompt's blink. Nothing here closes the
|
||||
# line - that is the player's job (#127).
|
||||
# The fade-in, the prompt's blink, and the decode. Nothing here closes
|
||||
# the line - that is the player's job (#127).
|
||||
shown_for += delta
|
||||
if is_typing():
|
||||
revealed = minf(revealed + delta * CHARS_PER_SECOND, float(current.length()))
|
||||
label.visible_characters = -1 if not is_typing() else int(revealed)
|
||||
queue_redraw()
|
||||
|
||||
|
||||
|
|
@ -277,9 +323,41 @@ func _draw() -> void:
|
|||
# bottom edge read as an underline attached to the last line rather than
|
||||
# as part of the frame.
|
||||
|
||||
# #149: the panel reads as a screen decoding something.
|
||||
#
|
||||
# Faint rules across the whole of it, always - a surface with a raster
|
||||
# rather than a sheet of glass - and a bright sweep running down it while
|
||||
# the line is still arriving, which stops when the decode does. The
|
||||
# sweep is the thing that says "this is happening now"; without it a
|
||||
# half-typed line just looks like a short line.
|
||||
var inner: Rect2 = Rect2(Vector2(INSET, CUT * 0.5),
|
||||
Vector2(maxf(size.x - INSET * 2.0, 0.0), maxf(size.y - CUT, 0.0)))
|
||||
var rule: float = inner.position.y
|
||||
while rule < inner.end.y:
|
||||
draw_line(Vector2(inner.position.x, rule), Vector2(inner.end.x, rule),
|
||||
Color(SWEEP_COLOR, 0.05 * alpha), 1.0)
|
||||
rule += SCANLINE_GAP
|
||||
|
||||
if is_typing():
|
||||
var sweep: float = fposmod(shown_for, SWEEP_SECONDS) / SWEEP_SECONDS
|
||||
var y: float = lerpf(inner.position.y, inner.end.y, sweep)
|
||||
# Brightest at the head with a short trail above it, so it reads as
|
||||
# travelling rather than as a line that moved.
|
||||
for step in range(6):
|
||||
var trail: float = y - float(step) * 3.0
|
||||
if trail < inner.position.y:
|
||||
break
|
||||
draw_line(Vector2(inner.position.x, trail), Vector2(inner.end.x, trail),
|
||||
Color(SWEEP_COLOR, alpha * 0.30 * (1.0 - float(step) / 6.0)), 1.0)
|
||||
# And the frame carries the same charge while it is working.
|
||||
NeonDraw.draw_glowing_line(self, Vector2(INSET, y), Vector2(size.x - INSET, y),
|
||||
Color(SWEEP_COLOR, alpha * 0.5), 0.7, 0.25)
|
||||
|
||||
# A blinking caret at the bottom right - the one thing that says a click
|
||||
# is what moves this on.
|
||||
var blink: float = 0.45 + 0.55 * absf(sin(shown_for * 3.0))
|
||||
# Solid while decoding - there is nothing to prompt for yet - and
|
||||
# blinking once the line is complete and waiting on the reader.
|
||||
var blink: float = 1.0 if is_typing() else 0.45 + 0.55 * absf(sin(shown_for * 3.0))
|
||||
var tip: Vector2 = Vector2(size.x - CUT - 6.0, size.y - INSET - 12.0)
|
||||
NeonDraw.draw_glowing_path(self, PackedVector2Array([
|
||||
tip + Vector2(-11.0, -7.0), tip, tip + Vector2(-11.0, 7.0),
|
||||
|
|
|
|||
Loading…
Reference in a new issue