updates
This commit is contained in:
parent
32ed347b58
commit
f41e197f20
4 changed files with 100 additions and 149 deletions
|
|
@ -364,8 +364,9 @@ func _place_camera(instant: bool) -> void:
|
||||||
|
|
||||||
|
|
||||||
## The camera spot that fits the mat (and the bot's hand past it) into the screen the panels leave
|
## The camera spot that fits the mat (and the bot's hand past it) into the screen the panels leave
|
||||||
## free, from your side: angled for "seat", straight down for "top". Tries a few aim points and
|
## free, from your side: angled for "seat", straight down for "top". Tries a few aim points, slid
|
||||||
## keeps the closest camera that fits, then applies the zoom.
|
## sideways to center the mat in that space, and keeps the closest camera that fits, then applies
|
||||||
|
## the zoom.
|
||||||
func _fit_camera() -> Transform3D:
|
func _fit_camera() -> Transform3D:
|
||||||
var side := 1.0 if me == 0 else -1.0
|
var side := 1.0 if me == 0 else -1.0
|
||||||
var vp := get_viewport().get_visible_rect().size
|
var vp := get_viewport().get_visible_rect().size
|
||||||
|
|
@ -387,7 +388,7 @@ func _fit_camera() -> Transform3D:
|
||||||
var hi := 80.0
|
var hi := 80.0
|
||||||
for _k in 22:
|
for _k in 22:
|
||||||
var d := (lo + hi) / 2.0
|
var d := (lo + hi) / 2.0
|
||||||
camera.transform = Transform3D(Basis.IDENTITY, target + dir * d).looking_at(target, up)
|
camera.transform = _aim(target, dir, d, up, points, region)
|
||||||
var fits := true
|
var fits := true
|
||||||
for pt in points:
|
for pt in points:
|
||||||
if not region.has_point(camera.unproject_position(pt)):
|
if not region.has_point(camera.unproject_position(pt)):
|
||||||
|
|
@ -399,11 +400,31 @@ func _fit_camera() -> Transform3D:
|
||||||
lo = d
|
lo = d
|
||||||
if hi < best_d:
|
if hi < best_d:
|
||||||
best_d = hi
|
best_d = hi
|
||||||
best = Transform3D(Basis.IDENTITY, target + dir * hi * _zoom).looking_at(target, up)
|
best = _aim(target, dir, hi * _zoom, up, points, region)
|
||||||
camera.transform = saved
|
camera.transform = saved
|
||||||
return best
|
return best
|
||||||
|
|
||||||
|
|
||||||
|
## The camera `d` from `target` along `dir`, slid sideways so `points` are centered across
|
||||||
|
## `region`. A slide shifts a point on screen in proportion, so two trial spots give the slide.
|
||||||
|
## Leaves the camera there.
|
||||||
|
func _aim(target: Vector3, dir: Vector3, d: float, up: Vector3, points: Array, region: Rect2) -> Transform3D:
|
||||||
|
var mids := []
|
||||||
|
for x in [0.0, 1.0]:
|
||||||
|
var at := target + Vector3(x, 0, 0)
|
||||||
|
camera.transform = Transform3D(Basis.IDENTITY, at + dir * d).looking_at(at, up)
|
||||||
|
var lo := INF
|
||||||
|
var hi := -INF
|
||||||
|
for pt in points:
|
||||||
|
var sx := camera.unproject_position(pt).x
|
||||||
|
lo = minf(lo, sx)
|
||||||
|
hi = maxf(hi, sx)
|
||||||
|
mids.append((lo + hi) / 2.0)
|
||||||
|
var at := target + Vector3((region.get_center().x - mids[0]) / (mids[1] - mids[0]), 0, 0)
|
||||||
|
camera.transform = Transform3D(Basis.IDENTITY, at + dir * d).looking_at(at, up)
|
||||||
|
return camera.transform
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------------
|
||||||
# Picking
|
# Picking
|
||||||
|
|
||||||
|
|
|
||||||
1
tests/attack_click.gd.uid
Normal file
1
tests/attack_click.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bvoswls5ywhn7
|
||||||
211
ui/hud.gd
211
ui/hud.gd
|
|
@ -1,10 +1,10 @@
|
||||||
class_name Hud
|
class_name Hud
|
||||||
extends CanvasLayer
|
extends CanvasLayer
|
||||||
## The 2D layer over the table (godot-plan.md §4, "Anything with text is 2D"): the status bar, a
|
## The 2D layer over the table (godot-plan.md §4, "Anything with text is 2D"): the status bar, a
|
||||||
## status strip per player, the action panel, the card inspector, the source menu and move list,
|
## status strip per player, the card inspector, the source menu and move list, the terminal log
|
||||||
## the terminal log drawer, the combat readout, the hand-focus row and the dialogs. It draws what
|
## drawer, the combat readout, the hand-focus row and the dialogs. It draws what Game hands it in
|
||||||
## Game hands it in refresh() and reports clicks as signals; it never builds an action. Its look
|
## refresh() and reports clicks as signals; it never builds an action. Its look comes from Style
|
||||||
## comes from Style (ui-plan.md §2–3).
|
## (ui-plan.md §2–3).
|
||||||
|
|
||||||
signal move_chosen(move: Dictionary)
|
signal move_chosen(move: Dictionary)
|
||||||
signal source_picked(key: String)
|
signal source_picked(key: String)
|
||||||
|
|
@ -20,7 +20,6 @@ signal hand_hovered(info: Dictionary)
|
||||||
signal hand_picked(key: String, at: Vector2)
|
signal hand_picked(key: String, at: Vector2)
|
||||||
signal hand_focus_changed(open: bool)
|
signal hand_focus_changed(open: bool)
|
||||||
|
|
||||||
const STEPS := [["deploy", "Deploy"], ["play", "Play"], ["attack", "Attack"], ["playAgain", "Play again"]]
|
|
||||||
const STAT_LABELS := {
|
const STAT_LABELS := {
|
||||||
"capturesUnowned": "Open locations captured", "capturesUndefended": "Undefended enemy locations captured",
|
"capturesUnowned": "Open locations captured", "capturesUndefended": "Undefended enemy locations captured",
|
||||||
"capturesInCombat": "Locations won in combat", "attacks": "Attacks", "attacksWon": "Rolls won attacking",
|
"capturesInCombat": "Locations won in combat", "attacks": "Attacks", "attacksWon": "Rolls won attacking",
|
||||||
|
|
@ -44,12 +43,8 @@ var theme: Theme
|
||||||
var _root: Control
|
var _root: Control
|
||||||
var _status: Label
|
var _status: Label
|
||||||
var _stack: Label
|
var _stack: Label
|
||||||
## One per row of the left column, the opponent's first: {panel, box, title, side, turn, bar, gb, body, badge}.
|
## One per player strip, the opponent's first: {panel, box, title, side, turn, bar, gb, body, badge}.
|
||||||
var _strips: Array = []
|
var _strips: Array = []
|
||||||
var _banner_text: RichTextLabel
|
|
||||||
var _steps: RichTextLabel
|
|
||||||
var _primary: Button
|
|
||||||
var _end_command: Button
|
|
||||||
var _right: VBoxContainer
|
var _right: VBoxContainer
|
||||||
var _source_menu: PanelContainer
|
var _source_menu: PanelContainer
|
||||||
var _source_box: VBoxContainer
|
var _source_box: VBoxContainer
|
||||||
|
|
@ -115,7 +110,7 @@ func _ready() -> void:
|
||||||
_root.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
_root.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
add_child(_root)
|
add_child(_root)
|
||||||
_build_top()
|
_build_top()
|
||||||
_build_left()
|
_build_strips()
|
||||||
_build_right()
|
_build_right()
|
||||||
_build_combat()
|
_build_combat()
|
||||||
_build_banner()
|
_build_banner()
|
||||||
|
|
@ -180,50 +175,30 @@ func _build_top() -> void:
|
||||||
row.add_child(b)
|
row.add_child(b)
|
||||||
|
|
||||||
|
|
||||||
func _build_left() -> void:
|
## The player strips, side by side under the status bar, over the table.
|
||||||
var col := VBoxContainer.new()
|
func _build_strips() -> void:
|
||||||
col.position = Vector2(Style.MARGIN, Style.PANEL_TOP + 6)
|
var row := HBoxContainer.new()
|
||||||
col.custom_minimum_size = Vector2(Style.PANEL_LEFT - 2 * Style.MARGIN, 0)
|
row.set_anchors_preset(Control.PRESET_TOP_WIDE)
|
||||||
col.add_theme_constant_override("separation", 8)
|
row.offset_left = Style.MARGIN
|
||||||
_root.add_child(col)
|
row.offset_right = -Style.PANEL_RIGHT
|
||||||
|
row.offset_top = Style.BAR_H + 6
|
||||||
|
row.add_theme_constant_override("separation", 8)
|
||||||
|
_root.add_child(row)
|
||||||
for i in 2:
|
for i in 2:
|
||||||
col.add_child(_make_strip())
|
row.add_child(_make_strip())
|
||||||
var actions := PanelContainer.new()
|
|
||||||
var abox := Style.chamfer_box(Style.ACCENT, Style.PANEL, 1.5, 0.0, 10.0)
|
|
||||||
abox.ticks = true
|
|
||||||
abox.set_content_margin_all(10)
|
|
||||||
actions.add_theme_stylebox_override("panel", abox)
|
|
||||||
var box := VBoxContainer.new()
|
|
||||||
box.add_theme_constant_override("separation", 8)
|
|
||||||
actions.add_child(box)
|
|
||||||
_banner_text = Widgets.rich()
|
|
||||||
_banner_text.custom_minimum_size = Vector2(Style.PANEL_LEFT - 2 * Style.MARGIN - 22, 0)
|
|
||||||
box.add_child(_banner_text)
|
|
||||||
_steps = Widgets.rich()
|
|
||||||
_steps.add_theme_font_size_override("normal_font_size", 11)
|
|
||||||
_steps.add_theme_font_size_override("bold_font_size", 11)
|
|
||||||
box.add_child(_steps)
|
|
||||||
_primary = Widgets.button("", func(): if not _primary_move.is_empty(): move_chosen.emit(_primary_move), "PrimaryButton")
|
|
||||||
_primary.custom_minimum_size = Vector2(0, 40)
|
|
||||||
box.add_child(_primary)
|
|
||||||
_end_command = Widgets.button("End command Enter", func(): end_command_pressed.emit())
|
|
||||||
box.add_child(_end_command)
|
|
||||||
col.add_child(actions)
|
|
||||||
|
|
||||||
|
|
||||||
## A player's status strip: name, the Bandwidth bar, the location track, counts and Anomalies.
|
## A player's status strip, one line: name, the Bandwidth bar, the location track.
|
||||||
func _make_strip() -> PanelContainer:
|
func _make_strip() -> PanelContainer:
|
||||||
var pc := PanelContainer.new()
|
var pc := PanelContainer.new()
|
||||||
|
pc.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
var sb := Style.chamfer_box(Style.ACCENT_DK, Style.PANEL, 1.0, 0.0, 9.0)
|
var sb := Style.chamfer_box(Style.ACCENT_DK, Style.PANEL, 1.0, 0.0, 9.0)
|
||||||
sb.left_bar = 3.0
|
sb.left_bar = 3.0
|
||||||
sb.content_margin_left = 12
|
sb.content_margin_left = 12
|
||||||
pc.add_theme_stylebox_override("panel", sb)
|
pc.add_theme_stylebox_override("panel", sb)
|
||||||
var v := VBoxContainer.new()
|
|
||||||
v.add_theme_constant_override("separation", 3)
|
|
||||||
pc.add_child(v)
|
|
||||||
var head := HBoxContainer.new()
|
var head := HBoxContainer.new()
|
||||||
head.add_theme_constant_override("separation", 7)
|
head.add_theme_constant_override("separation", 8)
|
||||||
v.add_child(head)
|
pc.add_child(head)
|
||||||
var badge_slot := CenterContainer.new()
|
var badge_slot := CenterContainer.new()
|
||||||
head.add_child(badge_slot)
|
head.add_child(badge_slot)
|
||||||
var title := Label.new()
|
var title := Label.new()
|
||||||
|
|
@ -232,32 +207,33 @@ func _make_strip() -> PanelContainer:
|
||||||
head.add_child(title)
|
head.add_child(title)
|
||||||
var side := Label.new()
|
var side := Label.new()
|
||||||
side.theme_type_variation = "Micro"
|
side.theme_type_variation = "Micro"
|
||||||
side.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
||||||
head.add_child(side)
|
head.add_child(side)
|
||||||
var turn := Label.new()
|
|
||||||
turn.add_theme_font_override("font", Style.body_font(800))
|
|
||||||
turn.add_theme_font_size_override("font_size", 11)
|
|
||||||
head.add_child(turn)
|
|
||||||
var gb_row := HBoxContainer.new()
|
|
||||||
gb_row.add_theme_constant_override("separation", 8)
|
|
||||||
v.add_child(gb_row)
|
|
||||||
var bar := BandwidthBar.new()
|
var bar := BandwidthBar.new()
|
||||||
bar.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
bar.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
bar.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
bar.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||||
gb_row.add_child(bar)
|
head.add_child(bar)
|
||||||
var gb := RichTextLabel.new()
|
var gb := RichTextLabel.new()
|
||||||
gb.bbcode_enabled = true
|
gb.bbcode_enabled = true
|
||||||
gb.fit_content = true
|
gb.fit_content = true
|
||||||
gb.scroll_active = false
|
gb.scroll_active = false
|
||||||
gb.autowrap_mode = TextServer.AUTOWRAP_OFF
|
gb.autowrap_mode = TextServer.AUTOWRAP_OFF
|
||||||
gb.custom_minimum_size = Vector2(78, 0)
|
gb.custom_minimum_size = Vector2(78, 0)
|
||||||
|
gb.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||||
gb.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
gb.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
gb_row.add_child(gb)
|
head.add_child(gb)
|
||||||
var body := Widgets.rich()
|
var body := Widgets.rich()
|
||||||
|
body.autowrap_mode = TextServer.AUTOWRAP_OFF
|
||||||
|
body.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||||
body.add_theme_font_size_override("normal_font_size", 12)
|
body.add_theme_font_size_override("normal_font_size", 12)
|
||||||
body.add_theme_font_size_override("bold_font_size", 12)
|
body.add_theme_font_size_override("bold_font_size", 12)
|
||||||
body.custom_minimum_size = Vector2(Style.PANEL_LEFT - 2 * Style.MARGIN - 26, 0)
|
head.add_child(body)
|
||||||
v.add_child(body)
|
var turn := Label.new()
|
||||||
|
turn.add_theme_font_override("font", Style.body_font(800))
|
||||||
|
turn.add_theme_font_size_override("font_size", 11)
|
||||||
|
# Held wide when empty too, so the two strips' bars line up.
|
||||||
|
turn.custom_minimum_size = Vector2(74, 0)
|
||||||
|
turn.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||||
|
head.add_child(turn)
|
||||||
_strips.append({"panel": pc, "box": sb, "title": title, "side": side, "turn": turn, "bar": bar, "gb": gb,
|
_strips.append({"panel": pc, "box": sb, "title": title, "side": side, "turn": turn, "bar": bar, "gb": gb,
|
||||||
"body": body, "badge_slot": badge_slot, "badge_for": -1})
|
"body": body, "badge_slot": badge_slot, "badge_for": -1})
|
||||||
return pc
|
return pc
|
||||||
|
|
@ -270,7 +246,7 @@ func _build_right() -> void:
|
||||||
_right.anchor_bottom = 1.0
|
_right.anchor_bottom = 1.0
|
||||||
_right.offset_left = -Style.PANEL_RIGHT + Style.MARGIN
|
_right.offset_left = -Style.PANEL_RIGHT + Style.MARGIN
|
||||||
_right.offset_right = -Style.MARGIN
|
_right.offset_right = -Style.MARGIN
|
||||||
_right.offset_top = Style.PANEL_TOP + 6
|
_right.offset_top = Style.BAR_H + 6
|
||||||
_right.offset_bottom = -Style.MARGIN
|
_right.offset_bottom = -Style.MARGIN
|
||||||
_right.add_theme_constant_override("separation", 8)
|
_right.add_theme_constant_override("separation", 8)
|
||||||
_root.add_child(_right)
|
_root.add_child(_right)
|
||||||
|
|
@ -536,7 +512,7 @@ func _build_drawer() -> void:
|
||||||
_drawer_handle.add_theme_stylebox_override("normal", hb)
|
_drawer_handle.add_theme_stylebox_override("normal", hb)
|
||||||
_drawer_handle.add_theme_stylebox_override("hover", hb.tinted(Color("#0c2730f0"), Style.ACCENT))
|
_drawer_handle.add_theme_stylebox_override("hover", hb.tinted(Color("#0c2730f0"), Style.ACCENT))
|
||||||
_drawer_handle.add_theme_stylebox_override("pressed", hb.tinted(Color(Style.ACCENT, 0.3), Style.ACCENT))
|
_drawer_handle.add_theme_stylebox_override("pressed", hb.tinted(Color(Style.ACCENT, 0.3), Style.ACCENT))
|
||||||
# The handle stays in the bottom-left corner, under the left column, open or shut.
|
# The handle stays in the bottom-left corner, open or shut.
|
||||||
_drawer_handle.anchor_top = 1.0
|
_drawer_handle.anchor_top = 1.0
|
||||||
_drawer_handle.anchor_bottom = 1.0
|
_drawer_handle.anchor_bottom = 1.0
|
||||||
_drawer_handle.offset_left = Style.MARGIN
|
_drawer_handle.offset_left = Style.MARGIN
|
||||||
|
|
@ -623,7 +599,7 @@ func refresh(ctx: Dictionary) -> void:
|
||||||
var window = RulesEngine.open_window(v)
|
var window = RulesEngine.open_window(v)
|
||||||
var in_window: bool = my_turn and window != null and v.choice == null
|
var in_window: bool = my_turn and window != null and v.choice == null
|
||||||
var my_choice: bool = my_turn and v.choice != null and v.choice.player == me
|
var my_choice: bool = my_turn and v.choice != null and v.choice.player == me
|
||||||
_status.text = status_line(v, m)
|
_status.text = status_line(v, m) + (" · paused" if ctx.paused and not v.over else "")
|
||||||
var items := []
|
var items := []
|
||||||
for it in v.stack:
|
for it in v.stack:
|
||||||
items.append("%s (%s%s)" % [it.name.trim_prefix("Execute: "), State.player_name(it.player), " → %s" % it.target if it.target else ""])
|
items.append("%s (%s%s)" % [it.name.trim_prefix("Execute: "), State.player_name(it.player), " → %s" % it.target if it.target else ""])
|
||||||
|
|
@ -632,45 +608,23 @@ func refresh(ctx: Dictionary) -> void:
|
||||||
_fill_strip(_strips[0], v, m.bot_side, me, v.active == m.bot_side and not v.over, not my_turn and not v.over)
|
_fill_strip(_strips[0], v, m.bot_side, me, v.active == m.bot_side and not v.over, not my_turn and not v.over)
|
||||||
_fill_strip(_strips[1], v, me, me, v.active == me and not v.over, my_turn and not v.over)
|
_fill_strip(_strips[1], v, me, me, v.active == me and not v.over, my_turn and not v.over)
|
||||||
|
|
||||||
# The action panel.
|
# What Space plays (as Game's key handler picks it): a pass, or else ending the step.
|
||||||
if v.active == me:
|
|
||||||
var parts := []
|
|
||||||
for st in STEPS:
|
|
||||||
var on: bool = v.step == st[0] or (v.step == "resolve" and st[0] == "attack")
|
|
||||||
if on:
|
|
||||||
parts.append("[bgcolor=%s][color=%s][b] %s [/b][/color][/bgcolor]" % [Style.hex(Style.ACCENT), Style.hex(Style.BG), st[1].to_upper()])
|
|
||||||
else:
|
|
||||||
parts.append("[color=%s]%s[/color]" % [Style.hex(Style.MUTED), st[1].to_upper()])
|
|
||||||
_steps.text = ("[color=%s] › [/color]" % Style.hex(Style.ACCENT_DK)).join(parts)
|
|
||||||
else:
|
|
||||||
_steps.text = "[color=%s]%s'S COMMAND[/color]" % [Style.hex(Style.OWNER[m.bot_side]), State.player_name(m.bot_side).to_upper()]
|
|
||||||
_primary_move = {}
|
_primary_move = {}
|
||||||
for mv in ctx.moves:
|
if v.choice == null:
|
||||||
if mv.action.type == "pass":
|
for t in ["pass", "end"]:
|
||||||
_primary_move = mv
|
var hit := (ctx.moves as Array).filter(func(mv): return mv.action.type == t)
|
||||||
break
|
if not hit.is_empty():
|
||||||
if _primary_move.is_empty():
|
_primary_move = hit[0]
|
||||||
for mv in ctx.moves:
|
|
||||||
if mv.action.type == "end":
|
|
||||||
_primary_move = mv
|
|
||||||
break
|
break
|
||||||
if not _primary_move.is_empty() and v.choice == null:
|
var can_end: bool = my_turn and v.choice == null and window == null and v.active == me
|
||||||
_primary.text = "%s Space" % _primary_move.label
|
|
||||||
_primary.disabled = false
|
|
||||||
else:
|
|
||||||
_primary.text = "Game over" if v.over else ("%s is deciding…" % State.player_name(m.bot_side) if not my_turn else "Choose an option")
|
|
||||||
_primary.disabled = true
|
|
||||||
_end_command.disabled = not my_turn or v.choice != null or window != null or v.active != me
|
|
||||||
|
|
||||||
_banner_text.text = _banner_for(ctx, in_window, my_turn)
|
|
||||||
_banner_text.visible = _banner_text.text != ""
|
|
||||||
_draw_source_menu(ctx, in_window, my_choice)
|
_draw_source_menu(ctx, in_window, my_choice)
|
||||||
_draw_log(m)
|
_draw_log(m)
|
||||||
_draw_combat(m, v, ctx)
|
_draw_combat(m, v, ctx)
|
||||||
_draw_salvage()
|
_draw_salvage()
|
||||||
if _moves_version != m.version:
|
if _moves_version != m.version:
|
||||||
_moves_version = m.version
|
_moves_version = m.version
|
||||||
_draw_moves(ctx.moves, v.over)
|
_draw_moves(ctx.moves, v.over, can_end)
|
||||||
if _focus_open:
|
if _focus_open:
|
||||||
_sync_focus()
|
_sync_focus()
|
||||||
if my_choice:
|
if my_choice:
|
||||||
|
|
@ -725,57 +679,22 @@ func _fill_strip(st: Dictionary, v: Dictionary, p: int, me: int, active: bool, d
|
||||||
var c := Style.hex(col)
|
var c := Style.hex(col)
|
||||||
var mu := Style.hex(Style.MUTED)
|
var mu := Style.hex(Style.MUTED)
|
||||||
var track := "■".repeat(held) + "[color=%s]%s[/color]" % [Style.hex(Color(col, 0.3)), "□".repeat(maxi(0, need - held))]
|
var track := "■".repeat(held) + "[color=%s]%s[/color]" % [Style.hex(Color(col, 0.3)), "□".repeat(maxi(0, need - held))]
|
||||||
var out := "[color=%s]%s[/color] %d/%d [color=%s]LOC[/color]\n" % [c, track, held, need, mu]
|
st.body.text = "[color=%s]%s[/color] %d/%d [color=%s]LOC[/color]" % [c, track, held, need, mu]
|
||||||
out += "[color=%s]HAND[/color] %d [color=%s]DECK[/color] %d [color=%s]DISC[/color] %d [color=%s]SRV[/color] %d" % [
|
|
||||||
mu, pl.hand.size(), mu, pl.deck.size(), mu, pl.discard.size(), mu, pl.serverPile.size()]
|
|
||||||
for i in pl.anomalies.size():
|
|
||||||
var av: Dictionary = pl.anomalies[i]
|
|
||||||
var r := State.ref(p, i + 1)
|
|
||||||
if i >= 4 and av.at == null:
|
|
||||||
continue
|
|
||||||
var name := State.name_of(v, av.card) if av.card >= 0 and State.anomaly(v, State.original_of(r)).faceUp else "face down"
|
|
||||||
var where: String = av.at if av.at != null else ("slot" if name != "face down" else "")
|
|
||||||
var n := "%d′" % (i - 3) if i >= 4 else str(i + 1)
|
|
||||||
var stats := GameTable.badge_text(v, r)
|
|
||||||
var name_col := Style.hex(Style.SCREEN if name != "face down" else Style.MUTED)
|
|
||||||
out += "\n[color=%s]%s[/color] [color=%s]%s[/color] [color=%s]%s[/color] %s" % [c, n, name_col, _escape(name), mu, where, stats]
|
|
||||||
st.body.text = out
|
|
||||||
|
|
||||||
|
|
||||||
func _banner_for(ctx: Dictionary, in_window: bool, my_turn: bool) -> String:
|
## What a response window is open on, e.g. "Combat at B2, before the roll".
|
||||||
var m: LocalMatch = ctx.match
|
static func _window_subject(m: LocalMatch, v: Dictionary) -> String:
|
||||||
var v: Dictionary = ctx.view
|
var w: Dictionary = RulesEngine.open_window(v)
|
||||||
if v.over:
|
var c = v.combat if v.combat != null and not v.combat.ended else null
|
||||||
return ""
|
var top = v.stack.back() if not v.stack.is_empty() else null
|
||||||
if in_window:
|
if w.kind == "preRoll" and c != null:
|
||||||
var w: Dictionary = RulesEngine.open_window(v)
|
return "Combat at %s, before the roll" % c.loc
|
||||||
var c = v.combat if v.combat != null and not v.combat.ended else null
|
if w.kind == "postRoll" and c != null:
|
||||||
var what := ""
|
return "Combat at %s, after the roll" % c.loc
|
||||||
var top = v.stack.back() if not v.stack.is_empty() else null
|
if top != null and top.player != m.human:
|
||||||
if w.kind == "preRoll" and c != null:
|
return "%s %s %s%s" % [State.player_name(top.player), "plays" if top.kind == "execution" else "uses", top.name, " on %s" % top.target if top.target else ""]
|
||||||
what = "Combat at %s, before the roll" % c.loc
|
var what := _last_by(m, m.bot_side).trim_suffix(".")
|
||||||
elif w.kind == "postRoll" and c != null:
|
return what if what != "" else "A response window is open"
|
||||||
what = "Combat at %s, after the roll" % c.loc
|
|
||||||
elif top != null and top.player != m.human:
|
|
||||||
what = "%s %s %s%s" % [State.player_name(top.player), "plays" if top.kind == "execution" else "uses", top.name, " on %s" % top.target if top.target else ""]
|
|
||||||
else:
|
|
||||||
what = _last_by(m, m.bot_side).trim_suffix(".")
|
|
||||||
if what == "":
|
|
||||||
what = "A response window is open"
|
|
||||||
return "[color=%s][b]%s: respond?[/b][/color] Pick a glowing card or Ability, or Space to pass." % [Style.hex(Style.WARN), _escape(what)]
|
|
||||||
if my_turn and v.choice == null:
|
|
||||||
var hint: String = {
|
|
||||||
"deploy": "Place, move or recall Anomalies, then advance one. A command is one advance or one attack.",
|
|
||||||
"play": "Play Hardware, Programs and Executions, and build Firewalls.",
|
|
||||||
"attack": "Attack from a location next to an enemy one.",
|
|
||||||
"resolve": "", "playAgain": "Play more cards, then end your command.",
|
|
||||||
}[v.step]
|
|
||||||
return "[color=%s][b]// YOUR COMMAND[/b][/color]\n%s" % [Style.hex(Style.ACCENT), hint]
|
|
||||||
if not my_turn:
|
|
||||||
var last := _last_by(m, m.bot_side)
|
|
||||||
return "[color=%s][b]%s[/b][/color] %s\n[color=%s]%s[/color]" % [Style.hex(Style.OWNER[m.bot_side]), State.player_name(m.bot_side).to_upper(),
|
|
||||||
"is paused." if ctx.paused else "is deciding…", Style.hex(Style.MUTED), _escape(last)]
|
|
||||||
return ""
|
|
||||||
|
|
||||||
|
|
||||||
static func _last_by(m: LocalMatch, p: int) -> String:
|
static func _last_by(m: LocalMatch, p: int) -> String:
|
||||||
|
|
@ -815,6 +734,7 @@ func _draw_source_menu(ctx: Dictionary, in_window: bool, my_choice: bool) -> voi
|
||||||
by_source[mv.source] = []
|
by_source[mv.source] = []
|
||||||
by_source[mv.source].append(mv)
|
by_source[mv.source].append(mv)
|
||||||
_source_box.add_child(Widgets.title("// YOUR RESPONSES"))
|
_source_box.add_child(Widgets.title("// YOUR RESPONSES"))
|
||||||
|
_source_box.add_child(Widgets.muted("%s. Pick a glowing card or Ability, or pass." % _window_subject(ctx.match, v)))
|
||||||
for src in by_source:
|
for src in by_source:
|
||||||
var list: Array = by_source[src]
|
var list: Array = by_source[src]
|
||||||
if list.size() == 1:
|
if list.size() == 1:
|
||||||
|
|
@ -828,7 +748,11 @@ func _draw_source_menu(ctx: Dictionary, in_window: bool, my_choice: bool) -> voi
|
||||||
|
|
||||||
|
|
||||||
func _move_button(mv: Dictionary, text := "") -> Button:
|
func _move_button(mv: Dictionary, text := "") -> Button:
|
||||||
var b := Widgets.button(text if text != "" else mv.label, func(): move_chosen.emit(mv))
|
return _list_button(text if text != "" else mv.label, func(): move_chosen.emit(mv))
|
||||||
|
|
||||||
|
|
||||||
|
func _list_button(text: String, fn: Callable) -> Button:
|
||||||
|
var b := Widgets.button(text, fn)
|
||||||
b.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
b.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||||
b.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
b.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||||
b.add_theme_font_size_override("font_size", 13)
|
b.add_theme_font_size_override("font_size", 13)
|
||||||
|
|
@ -1034,7 +958,8 @@ func _process(_delta: float) -> void:
|
||||||
_watch_focus_edge()
|
_watch_focus_edge()
|
||||||
|
|
||||||
|
|
||||||
func _draw_moves(moves: Array, over: bool) -> void:
|
## Every move, grouped, with the keys for Space's move and (when `can_end`) ending the command.
|
||||||
|
func _draw_moves(moves: Array, over: bool, can_end: bool) -> void:
|
||||||
_clear(_moves_box)
|
_clear(_moves_box)
|
||||||
if moves.is_empty():
|
if moves.is_empty():
|
||||||
_moves_box.add_child(Widgets.muted("Game over." if over else "Nothing to do until the bot moves."))
|
_moves_box.add_child(Widgets.muted("Game over." if over else "Nothing to do until the bot moves."))
|
||||||
|
|
@ -1044,7 +969,9 @@ func _draw_moves(moves: Array, over: bool) -> void:
|
||||||
t.add_theme_color_override("font_color", Style.ACCENT)
|
t.add_theme_color_override("font_color", Style.ACCENT)
|
||||||
_moves_box.add_child(t)
|
_moves_box.add_child(t)
|
||||||
for mv in g[1]:
|
for mv in g[1]:
|
||||||
_moves_box.add_child(_move_button(mv))
|
_moves_box.add_child(_move_button(mv, "%s Space" % mv.label if mv == _primary_move else ""))
|
||||||
|
if g[0] == "Turn" and can_end:
|
||||||
|
_moves_box.add_child(_list_button("End command Enter", func(): end_command_pressed.emit()))
|
||||||
|
|
||||||
|
|
||||||
## Shows a card or board object in the inspector: `info` is {art: card name or "", text: bbcode,
|
## Shows a card or board object in the inspector: `info` is {art: card name or "", text: bbcode,
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,11 @@ const MARK_STRENGTH := {"source": 1.0, "respond": 1.2, "selected": 2.0, "target"
|
||||||
# 1600 × 900 base size; scale by the viewport.
|
# 1600 × 900 base size; scale by the viewport.
|
||||||
|
|
||||||
const BASE := Vector2(1600, 900)
|
const BASE := Vector2(1600, 900)
|
||||||
const PANEL_LEFT := 300.0
|
|
||||||
const PANEL_RIGHT := 360.0
|
const PANEL_RIGHT := 360.0
|
||||||
const PANEL_TOP := 44.0
|
## The status bar, and under it the row of player strips over the table.
|
||||||
|
const BAR_H := 44.0
|
||||||
|
const STRIPS_H := 40.0
|
||||||
|
const PANEL_TOP := BAR_H + STRIPS_H
|
||||||
const PANEL_BOTTOM := 176.0
|
const PANEL_BOTTOM := 176.0
|
||||||
## Gap between a panel and the screen edge.
|
## Gap between a panel and the screen edge.
|
||||||
const MARGIN := 8.0
|
const MARGIN := 8.0
|
||||||
|
|
@ -277,4 +279,4 @@ static func scale_of(vp: Vector2) -> Vector2:
|
||||||
## The screen rect the panels leave free for the table, in viewport pixels.
|
## The screen rect the panels leave free for the table, in viewport pixels.
|
||||||
static func table_region(vp: Vector2, bottom := PANEL_BOTTOM) -> Rect2:
|
static func table_region(vp: Vector2, bottom := PANEL_BOTTOM) -> Rect2:
|
||||||
var s := scale_of(vp)
|
var s := scale_of(vp)
|
||||||
return Rect2(PANEL_LEFT * s.x, PANEL_TOP * s.y, vp.x - (PANEL_LEFT + PANEL_RIGHT) * s.x, vp.y - (PANEL_TOP + bottom) * s.y)
|
return Rect2(0, PANEL_TOP * s.y, vp.x - PANEL_RIGHT * s.x, vp.y - (PANEL_TOP + bottom) * s.y)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue