From 99eebb1d6fd8b9fbf6920cb7300c17ee5f027bc0 Mon Sep 17 00:00:00 2001 From: wusumac <736139669@qq.com> Date: Mon, 24 Aug 2026 19:09:38 +0800 Subject: [PATCH] fix(bat002): reconstruct approved live battle chrome --- runtime/entry/battle_live_art.gd | 365 +++++++++++++++++++++++++------ runtime/entry/entry_shell.gd | 301 +++++++++++++++++++------ 2 files changed, 535 insertions(+), 131 deletions(-) diff --git a/runtime/entry/battle_live_art.gd b/runtime/entry/battle_live_art.gd index 2f09c1a2..a0b44bbb 100644 --- a/runtime/entry/battle_live_art.gd +++ b/runtime/entry/battle_live_art.gd @@ -1,10 +1,21 @@ class_name ABGBattleLiveArt extends Control +## Engine-drawn battle chrome reconstructed from the approved BAT-002 master. +## Runtime labels, values and hit targets remain separate overlay nodes. + var live_state := "waiting_for_next_event" var event_kind := "" var source_side := "" var target_side := "" +var source_anchor := Vector2(0.46, 0.60) +var target_anchor := Vector2(0.67, 0.58) +var ally_anchors: Array[Vector2] = [] +var enemy_anchors: Array[Vector2] = [] +var party_count := 0 +var enemy_count := 0 +var playback_paused := true +var playback_speed := 1 func _ready() -> void: @@ -25,84 +36,308 @@ func set_event_state(state: String, kind: String, source: String, target: String queue_redraw() +func set_presentation_state( + paused: bool, + speed: float, + allies: Array[Vector2], + enemies: Array[Vector2], + event_source: Vector2, + event_target: Vector2 +) -> void: + playback_paused = paused + playback_speed = int(speed) + ally_anchors = allies.duplicate() + enemy_anchors = enemies.duplicate() + party_count = ally_anchors.size() + enemy_count = enemy_anchors.size() + source_anchor = event_source + target_anchor = event_target + queue_redraw() + + func _draw() -> void: if size.x <= 0.0 or size.y <= 0.0: return - var width := size.x - var height := size.y - var top_height := height * 0.125 - var bottom_y := height * 0.80 - var navy := Color("#0d1927", 0.94) - var navy_light := Color("#1e3349", 0.86) - var crimson := Color("#542b37", 0.90) - var gold := Color("#d9b45f", 0.94) - var ivory := Color("#f4e8c8", 0.92) - var ally := Color("#67b7df", 0.92) - var enemy := Color("#df6c68", 0.92) + _draw_top_rails() + _draw_field_language() + _draw_bottom_rail() - draw_rect(Rect2(0.0, 0.0, width * 0.34, top_height), navy) - draw_rect(Rect2(width * 0.66, 0.0, width * 0.34, top_height), navy) - draw_style_box(_plate(Color("#eadfbe", 0.94), Color(gold, 0.86), 2, 3), Rect2(width * 0.405, 0.0, width * 0.19, height * 0.12)) - draw_rect(Rect2(0.0, bottom_y, width, height - bottom_y), Color("#0c1724", 0.96)) - draw_line(Vector2(0.0, top_height - 2.0), Vector2(width * 0.34, top_height - 2.0), gold, 2.0) - draw_line(Vector2(width * 0.66, top_height - 2.0), Vector2(width, top_height - 2.0), gold, 2.0) - draw_line(Vector2(0.0, bottom_y), Vector2(width, bottom_y), gold, 2.0) - draw_line(Vector2(0.0, top_height - 7.0), Vector2(width * 0.34, top_height - 7.0), Color(gold, 0.28), 1.0) - draw_line(Vector2(width * 0.66, top_height - 7.0), Vector2(width, top_height - 7.0), Color(gold, 0.28), 1.0) - draw_line(Vector2(0.0, bottom_y + 6.0), Vector2(width, bottom_y + 6.0), Color(gold, 0.28), 1.0) - draw_rect(Rect2(0.0, 0.0, width * 0.07, top_height), navy_light) - draw_rect(Rect2(width * 0.93, 0.0, width * 0.07, top_height), crimson) - draw_line(Vector2(width * 0.07, 0.0), Vector2(width * 0.07, top_height), gold, 2.0) - draw_line(Vector2(width * 0.93, 0.0), Vector2(width * 0.93, top_height), gold, 2.0) - for index in range(4): - _draw_diamond(Vector2(width * (0.13 + index * 0.034), height * 0.073), width * 0.008, ally) - for index in range(3): - _draw_diamond(Vector2(width * (0.78 + index * 0.034), height * 0.073), width * 0.008, enemy) +func _draw_top_rails() -> void: + var w := size.x + var h := size.y + var gold := Color("#d6ad58", 0.98) + var gold_dim := Color("#78633f", 0.92) + var navy := Color("#101b2a", 0.96) + var navy_inner := Color("#18293b", 0.96) + var blue := Color("#315a87", 0.98) + var red := Color("#7d3540", 0.98) + var crimson := Color("#401f29", 0.98) + var ivory := Color("#f1e4c2", 0.98) - draw_style_box(_plate(Color("#12263a", 0.64), Color(gold, 0.62), 1, 3), Rect2(width * 0.025, height * 0.135, width * 0.31, height * 0.13)) - draw_rect(Rect2(width * 0.355, height * 0.135, width * 0.29, height * 0.135), Color("#102235", 0.42)) + # Long asymmetric faction rails with pointed inner shoulders. + var left_outer := PackedVector2Array([ + Vector2(w * 0.052, h * 0.016), Vector2(w * 0.325, h * 0.016), + Vector2(w * 0.344, h * 0.108), Vector2(w * 0.330, h * 0.122), + Vector2(w * 0.060, h * 0.108), + ]) + draw_colored_polygon(left_outer, gold_dim) + var left_inner := PackedVector2Array([ + Vector2(w * 0.058, h * 0.024), Vector2(w * 0.319, h * 0.024), + Vector2(w * 0.336, h * 0.101), Vector2(w * 0.324, h * 0.111), + Vector2(w * 0.058, h * 0.099), + ]) + draw_colored_polygon(left_inner, navy) + draw_polyline(left_outer + PackedVector2Array([left_outer[0]]), gold, 2.0) + draw_line(Vector2(w * 0.060, h * 0.091), Vector2(w * 0.321, h * 0.102), Color(gold, 0.42), 1.0) - var ally_cord_y := height * 0.69 - var enemy_cord_y := height * 0.69 - draw_line(Vector2(width * 0.07, ally_cord_y), Vector2(width * 0.52, ally_cord_y), Color("#d8bf7b", 0.82), 3.0) - draw_line(Vector2(width * 0.61, enemy_cord_y), Vector2(width * 0.95, enemy_cord_y), Color("#b97572", 0.76), 3.0) - draw_line(Vector2(width * 0.51, height * 0.61), Vector2(width * 0.61, height * 0.61), Color(gold, 0.68), 2.0) - draw_line(Vector2(width * 0.61, height * 0.61), Vector2(width * 0.595, height * 0.60), Color(gold, 0.68), 2.0) - draw_line(Vector2(width * 0.61, height * 0.61), Vector2(width * 0.595, height * 0.62), Color(gold, 0.68), 2.0) + var right_outer := PackedVector2Array([ + Vector2(w * 0.675, h * 0.016), Vector2(w * 0.948, h * 0.016), + Vector2(w * 0.940, h * 0.108), Vector2(w * 0.670, h * 0.122), + Vector2(w * 0.656, h * 0.108), + ]) + draw_colored_polygon(right_outer, gold_dim) + var right_inner := PackedVector2Array([ + Vector2(w * 0.681, h * 0.024), Vector2(w * 0.942, h * 0.024), + Vector2(w * 0.942, h * 0.099), Vector2(w * 0.676, h * 0.111), + Vector2(w * 0.664, h * 0.101), + ]) + draw_colored_polygon(right_inner, navy) + draw_polyline(right_outer + PackedVector2Array([right_outer[0]]), gold, 2.0) + draw_line(Vector2(w * 0.679, h * 0.102), Vector2(w * 0.940, h * 0.091), Color(gold, 0.42), 1.0) - for index in range(5): - var separator_x := width * (0.17 + index * 0.15) - draw_line(Vector2(separator_x, bottom_y + height * 0.025), Vector2(separator_x, height - height * 0.025), Color(gold, 0.34), 1.0) + # Hanging crest endcaps preserve the approved blue/red silhouette. + var left_cap := PackedVector2Array([ + Vector2(w * 0.014, 0.0), Vector2(w * 0.073, 0.0), + Vector2(w * 0.073, h * 0.105), Vector2(w * 0.052, h * 0.144), + Vector2(w * 0.015, h * 0.112), + ]) + draw_colored_polygon(left_cap, blue) + draw_polyline(left_cap + PackedVector2Array([left_cap[0]]), gold, 2.0) + var right_cap := PackedVector2Array([ + Vector2(w * 0.927, 0.0), Vector2(w * 0.986, 0.0), + Vector2(w * 0.985, h * 0.112), Vector2(w * 0.948, h * 0.144), + Vector2(w * 0.927, h * 0.105), + ]) + draw_colored_polygon(right_cap, red) + draw_polyline(right_cap + PackedVector2Array([right_cap[0]]), gold, 2.0) + _draw_crest(Vector2(w * 0.044, h * 0.057), minf(w, h) * 0.026, Color("#edf1ec")) + _draw_crest(Vector2(w * 0.956, h * 0.057), minf(w, h) * 0.026, Color("#f3e8dc")) - if not event_kind.is_empty(): - var source := Vector2(width * 0.45, height * 0.52) if source_side == "ally" else Vector2(width * 0.69, height * 0.50) - var target := Vector2(width * 0.69, height * 0.50) if target_side == "enemy" else Vector2(width * 0.45, height * 0.52) - var path_color := _event_color() - draw_line(source, target, Color(path_color, 0.84), 3.0) - var direction := (target - source).normalized() - var perpendicular := Vector2(-direction.y, direction.x) - draw_colored_polygon(PackedVector2Array([ - target, - target - direction * width * 0.018 + perpendicular * width * 0.009, - target - direction * width * 0.018 - perpendicular * width * 0.009, - ]), path_color) - draw_circle(target, width * 0.022, Color(path_color, 0.18)) - draw_arc(target, width * 0.022, 0.0, TAU, 32, path_color, 2.0) - elif live_state == "waiting_for_next_event": - var center := Vector2(width * 0.565, height * 0.52) - draw_arc(center, width * 0.020, 0.0, TAU, 24, Color(ivory, 0.72), 2.0) - _draw_diamond(center, width * 0.007, gold) + # Status pips remain inside the long rails instead of becoming cards. + for index in range(party_count): + _draw_diamond(Vector2(w * (0.178 + index * 0.034), h * 0.064), w * 0.0075, Color("#68b8e9")) + for index in range(enemy_count): + _draw_diamond(Vector2(w * (0.790 - index * 0.034), h * 0.064), w * 0.0075, Color("#e05c5c")) + + # One continuous ivory playback ribbon. Logical buttons sit transparently on top. + var ribbon_outer := PackedVector2Array([ + Vector2(w * 0.390, 0.0), Vector2(w * 0.610, 0.0), + Vector2(w * 0.598, h * 0.103), Vector2(w * 0.402, h * 0.103), + ]) + draw_colored_polygon(ribbon_outer, gold_dim) + var ribbon_inner := PackedVector2Array([ + Vector2(w * 0.394, 0.0), Vector2(w * 0.606, 0.0), + Vector2(w * 0.594, h * 0.093), Vector2(w * 0.406, h * 0.093), + ]) + draw_colored_polygon(ribbon_inner, ivory) + draw_polyline(ribbon_outer + PackedVector2Array([ribbon_outer[0]]), Color("#b99a59"), 2.0) + for split_x in [0.465, 0.535]: + draw_line(Vector2(w * split_x, 0.0), Vector2(w * split_x, h * 0.093), Color("#b59d6c", 0.62), 1.0) + _draw_pause_icon(Vector2(w * 0.428, h * 0.045), h * 0.025, navy_inner) + _draw_speed_icon(Vector2(w * 0.492, h * 0.045), h * 0.023, navy_inner) + _draw_magnifier(Vector2(w * 0.570, h * 0.042), h * 0.020, navy_inner) + + # Settings is a compact rail-integrated target, not a text block. + _draw_cog(Vector2(w * 0.910, h * 0.063), h * 0.020, Color("#e9d8ad"), crimson) + + +func _draw_field_language() -> void: + var w := size.x + var h := size.y + var gold := Color("#e0bd69", 0.92) + var ivory := Color("#f5ead0", 0.94) + var path_color := _event_color() + + # A narrow field-attached objective bracket keeps the painted world open. + var objective := PackedVector2Array([ + Vector2(w * 0.018, h * 0.142), Vector2(w * 0.278, h * 0.142), + Vector2(w * 0.294, h * 0.157), Vector2(w * 0.282, h * 0.238), + Vector2(w * 0.018, h * 0.238), + ]) + draw_colored_polygon(objective, Color("#102238", 0.60)) + draw_line(objective[0], objective[1], Color(gold, 0.72), 1.5) + draw_line(objective[4], objective[3], Color(gold, 0.42), 1.0) + draw_line(objective[0], objective[4], Color(gold, 0.68), 2.0) + + # Small role/status markers remain attached to the actors. + for index in range(ally_anchors.size()): + _draw_actor_state_marker(_to_px(ally_anchors[index]), Color("#6fc0e7"), index == ally_anchors.size() - 1) + for index in range(enemy_anchors.size()): + _draw_actor_state_marker(_to_px(enemy_anchors[index]), Color("#dc6662"), index == 0) + + if event_kind.is_empty() or source_side.is_empty() or target_side.is_empty(): + if live_state == "waiting_for_next_event": + var waiting_center := Vector2(w * 0.50, h * 0.345) + draw_arc(waiting_center, w * 0.014, 0.0, TAU, 24, Color(ivory, 0.78), 2.0) + _draw_diamond(waiting_center, w * 0.0045, gold) + elif event_kind == "opening": + var opening_center := Vector2(w * 0.50, h * 0.365) + draw_arc(opening_center, w * 0.020, 0.0, TAU, 28, Color(gold, 0.68), 2.0) + _draw_diamond(opening_center, w * 0.006, ivory) + return + + var source := _to_px(source_anchor) + var target := _to_px(target_anchor) + var bend := -h * 0.095 if source.x < target.x else h * 0.075 + var path := _quadratic_path(source, target, bend) + for offset in [-3.0, 0.0, 3.0]: + var shifted := PackedVector2Array() + for point in path: + shifted.append(point + Vector2(0.0, offset)) + draw_polyline(shifted, Color(path_color, 0.30 if offset != 0.0 else 0.90), 1.2 if offset != 0.0 else 2.4) + var direction := (path[-1] - path[-2]).normalized() + var perpendicular := Vector2(-direction.y, direction.x) + draw_colored_polygon(PackedVector2Array([ + target, + target - direction * w * 0.018 + perpendicular * w * 0.008, + target - direction * w * 0.018 - perpendicular * w * 0.008, + ]), path_color) + draw_arc(source, w * 0.012, 0.0, TAU, 28, Color(path_color, 0.92), 2.0) + draw_circle(source, w * 0.005, Color(path_color, 0.55)) + draw_circle(target, w * 0.027, Color(path_color, 0.14)) + draw_arc(target, w * 0.027, 0.0, TAU, 36, Color(path_color, 0.92), 2.0) + + # The urgent marker is tied to the target endpoint, never a central debug band. + var urgent := target - Vector2(0.0, h * 0.205) + draw_line(urgent + Vector2(0.0, h * 0.030), target - Vector2(0.0, h * 0.025), Color(path_color, 0.45), 3.0) + var urgent_shape := PackedVector2Array([ + urgent + Vector2(0.0, -h * 0.036), urgent + Vector2(w * 0.020, 0.0), + urgent + Vector2(0.0, h * 0.036), urgent + Vector2(-w * 0.020, 0.0), + ]) + draw_colored_polygon(urgent_shape, Color(path_color, 0.94)) + draw_polyline(urgent_shape + PackedVector2Array([urgent_shape[0]]), Color("#fff0d8"), 2.0) + draw_line(urgent - Vector2(0.0, h * 0.014), urgent + Vector2(0.0, h * 0.009), ivory, 3.0) + draw_circle(urgent + Vector2(0.0, h * 0.020), 2.0, ivory) + + +func _draw_bottom_rail() -> void: + var w := size.x + var h := size.y + var top := h * 0.80 + var gold := Color("#d0aa58", 0.96) + var rail := Color("#0e1723", 0.97) + var rail_inner := Color("#172434", 0.98) + var plate := Color("#202a35", 0.98) + + draw_rect(Rect2(0.0, top, w, h - top), rail) + draw_line(Vector2(0.0, top), Vector2(w, top), gold, 2.0) + draw_line(Vector2(0.0, top + h * 0.009), Vector2(w, top + h * 0.009), Color(gold, 0.28), 1.0) + draw_rect(Rect2(w * 0.012, h * 0.835, w * 0.142, h * 0.132), rail_inner) + draw_style_box(_plate(Color("#131b25", 0.98), Color(gold, 0.78), 1, 3), Rect2(w * 0.018, h * 0.857, w * 0.125, h * 0.095)) + _draw_hourglass(Vector2(w * 0.042, h * 0.905), h * 0.023, Color("#e6d5a8")) + + for index in range(maxi(1, party_count)): + var rect := Rect2(w * (0.170 + index * 0.153), h * 0.817, w * 0.143, h * 0.165) + draw_style_box(_plate(plate, Color(gold, 0.88), 1, 2), rect) + draw_rect(Rect2(rect.position + Vector2(rect.size.x * 0.055, rect.size.y * 0.735), Vector2(rect.size.x * 0.89, rect.size.y * 0.075)), Color("#071015", 0.96)) + draw_rect(Rect2(rect.position + Vector2(rect.size.x * 0.055, rect.size.y * 0.855), Vector2(rect.size.x * 0.89, rect.size.y * 0.075)), Color("#071015", 0.96)) + var badge := rect.position + Vector2(rect.size.x * 0.085, rect.size.y * 0.105) + _draw_diamond(badge, rect.size.x * 0.09, Color("#30291e")) + draw_arc(badge, rect.size.x * 0.09, 0.0, TAU, 4, gold, 1.5) + + # The boundary command remains a compact rail glyph inside a generous hit area. + var command_center := Vector2(w * 0.904, h * 0.895) + draw_circle(command_center, h * 0.035, Color("#18283a", 0.98)) + draw_arc(command_center, h * 0.035, 0.0, TAU, 28, Color(gold, 0.90), 1.5) + draw_line(command_center - Vector2(h * 0.012, 0.0), command_center + Vector2(h * 0.012, 0.0), Color("#e9dcb9"), 2.0) + draw_line(command_center + Vector2(h * 0.004, -h * 0.009), command_center + Vector2(h * 0.012, 0.0), Color("#e9dcb9"), 2.0) + draw_line(command_center + Vector2(h * 0.004, h * 0.009), command_center + Vector2(h * 0.012, 0.0), Color("#e9dcb9"), 2.0) func _event_color() -> Color: match event_kind: - "healing": return Color("#70c59b", 0.94) - "guard", "guarded_recovery": return Color("#7fb9dc", 0.94) - "magic": return Color("#b58bd6", 0.94) - "knockout": return Color("#e16c67", 0.96) - "result": return Color("#dfbd68", 0.96) - return Color("#e2b75f", 0.94) + "healing": return Color("#70c59b", 0.96) + "guard", "guarded_recovery": return Color("#73b8dc", 0.96) + "magic": return Color("#b58bd6", 0.96) + "knockout": return Color("#e16c67", 0.98) + "result": return Color("#dfbd68", 0.98) + return Color("#e2b75f", 0.96) + + +func _draw_actor_state_marker(center: Vector2, color: Color, emphasized: bool) -> void: + var radius := size.x * (0.0048 if not emphasized else 0.0062) + draw_circle(center, radius * 1.25, Color("#13202a", 0.62)) + _draw_diamond(center, radius, color) + draw_arc(center, radius * 1.25, 0.0, TAU, 20, Color("#f4e6c3", 0.72), 1.0) + + +func _draw_crest(center: Vector2, radius: float, color: Color) -> void: + _draw_diamond(center, radius * 0.72, Color(color, 0.94)) + draw_line(center - Vector2(radius * 0.85, radius * 0.55), center + Vector2(radius * 0.85, radius * 0.55), color, 2.0) + draw_line(center - Vector2(radius * 0.85, -radius * 0.55), center + Vector2(radius * 0.85, -radius * 0.55), color, 2.0) + draw_circle(center, radius * 0.18, Color("#29445c")) + + +func _draw_pause_icon(center: Vector2, radius: float, color: Color) -> void: + if playback_paused: + var triangle := PackedVector2Array([ + center + Vector2(-radius * 0.42, -radius * 0.62), + center + Vector2(radius * 0.62, 0.0), + center + Vector2(-radius * 0.42, radius * 0.62), + ]) + draw_colored_polygon(triangle, color) + else: + draw_rect(Rect2(center - Vector2(radius * 0.48, radius * 0.62), Vector2(radius * 0.32, radius * 1.24)), color) + draw_rect(Rect2(center + Vector2(radius * 0.16, -radius * 0.62), Vector2(radius * 0.32, radius * 1.24)), color) + + +func _draw_speed_icon(center: Vector2, radius: float, color: Color) -> void: + var chevrons := 1 if playback_speed <= 1 else (2 if playback_speed <= 2 else 3) + for index in range(chevrons): + var offset := (float(index) - float(chevrons - 1) * 0.5) * radius * 0.72 + var c := center + Vector2(offset, 0.0) + draw_colored_polygon(PackedVector2Array([ + c + Vector2(-radius * 0.38, -radius * 0.62), + c + Vector2(radius * 0.42, 0.0), + c + Vector2(-radius * 0.38, radius * 0.62), + ]), color) + + +func _draw_magnifier(center: Vector2, radius: float, color: Color) -> void: + draw_arc(center - Vector2(radius * 0.18, radius * 0.18), radius * 0.68, 0.0, TAU, 24, color, 3.0) + draw_line(center + Vector2(radius * 0.34, radius * 0.34), center + Vector2(radius * 0.95, radius * 0.95), color, 3.0) + + +func _draw_cog(center: Vector2, radius: float, color: Color, fill: Color) -> void: + draw_circle(center, radius * 1.12, Color(fill, 0.94)) + for index in range(8): + var angle := TAU * float(index) / 8.0 + var direction := Vector2(cos(angle), sin(angle)) + draw_line(center + direction * radius * 0.82, center + direction * radius * 1.24, color, 2.0) + draw_arc(center, radius * 0.72, 0.0, TAU, 24, color, 2.0) + draw_circle(center, radius * 0.22, color) + + +func _draw_hourglass(center: Vector2, radius: float, color: Color) -> void: + draw_line(center - Vector2(radius * 0.65, radius), center + Vector2(radius * 0.65, -radius), color, 2.0) + draw_line(center + Vector2(radius * 0.65, radius), center - Vector2(radius * 0.65, -radius), color, 2.0) + draw_line(center - Vector2(radius * 0.78, radius), center + Vector2(radius * 0.78, -radius), color, 2.0) + draw_line(center - Vector2(radius * 0.78, -radius), center + Vector2(radius * 0.78, radius), color, 2.0) + + +func _quadratic_path(source: Vector2, target: Vector2, bend: float) -> PackedVector2Array: + var points := PackedVector2Array() + var midpoint := (source + target) * 0.5 + Vector2(0.0, bend) + for index in range(21): + var t := float(index) / 20.0 + var point := source * pow(1.0 - t, 2.0) + midpoint * 2.0 * (1.0 - t) * t + target * pow(t, 2.0) + points.append(point) + return points + + +func _to_px(point: Vector2) -> Vector2: + return Vector2(point.x * size.x, point.y * size.y) func _draw_diamond(center: Vector2, radius: float, color: Color) -> void: diff --git a/runtime/entry/entry_shell.gd b/runtime/entry/entry_shell.gd index 7542544e..04edb22f 100644 --- a/runtime/entry/entry_shell.gd +++ b/runtime/entry/entry_shell.gd @@ -175,6 +175,8 @@ var battle_live_resume_state := "waiting_for_next_event" var battle_live_notice := "" var battle_live_error_code := "" var battle_live_interruption: Dictionary = {} +var battle_live_rendering := false +var battle_live_render_requested := false var title_master_design_canvas: Control var guild_master_design_canvas: Control var party_master_design_canvas: Control @@ -206,7 +208,9 @@ func _notification(what: int) -> void: _layout_battle_live_canvas() if what in [NOTIFICATION_APPLICATION_PAUSED, NOTIFICATION_APPLICATION_FOCUS_OUT]: if current_screen == "battle" and not battle_opening_mode and is_instance_valid(battle_live_canvas): - _battle_live_interrupt("application_paused" if what == NOTIFICATION_APPLICATION_PAUSED else "focus_lost") + # Focus notifications can arrive while the live canvas is replacing its + # children. Defer the state transition until the parent mutation ends. + call_deferred("_battle_live_interrupt", "application_paused" if what == NOTIFICATION_APPLICATION_PAUSED else "focus_lost") func _ready() -> void: @@ -4298,6 +4302,10 @@ func show_battle(company := {}, auto_play := false, resume_requires_review := fa func _render_battle_live() -> void: + if battle_live_rendering: + battle_live_render_requested = true + return + battle_live_rendering = true _build_battle_live_canvas() var battle: Dictionary = guild_company.get("active_contract", {}).get("battle_state", {}) _build_battle_live_overlay(guild_company, battle) @@ -4305,6 +4313,10 @@ func _render_battle_live() -> void: var focus_target := find_child("BattleLiveSettings", true, false) as Button if focus_target != null: focus_target.call_deferred("grab_focus") + battle_live_rendering = false + if battle_live_render_requested: + battle_live_render_requested = false + call_deferred("_render_battle_live") func _build_battle_live_canvas() -> void: @@ -4355,11 +4367,21 @@ func _build_battle_live_overlay(company: Dictionary, battle: Dictionary) -> void var art := BattleLiveArt.new() art.name = "BattleLiveArt" art.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) + var source_id := String(battle_live_event.get("actor_id", "")) + var target_id := String(battle_live_event.get("target_id", "")) art.set_event_state( battle_live_state, String(battle_live_event.get("kind", "")), - _battle_live_actor_side(String(battle_live_event.get("actor_id", "")), battle), - _battle_live_actor_side(String(battle_live_event.get("target_id", "")), battle) + _battle_live_actor_side(source_id, battle), + _battle_live_actor_side(target_id, battle) + ) + art.set_presentation_state( + battle_paused, + battle_speed, + _battle_live_marker_anchors(battle, true), + _battle_live_marker_anchors(battle, false), + _battle_live_actor_anchor(source_id, battle, true), + _battle_live_actor_anchor(target_id, battle, false) ) battle_live_canvas.add_child(art) var overlay := Control.new() @@ -4375,53 +4397,62 @@ func _build_battle_live_overlay(company: Dictionary, battle: Dictionary) -> void func _build_battle_live_top(parent: Control, battle: Dictionary) -> void: var party_count := Array(battle.get("front_to_rear_ids", [])).size() var enemy_count := Array(battle.get("enemy_ids", [])).size() - var company_status := _battle_live_overlay_label(parent, "BattleLiveCompanyStatus", _tr("远征团 %d", "COMPANY %d") % party_count, Rect2(0.105, 0.025, 0.20, 0.055), 16, Color("#f5ead0")) + var company_status := _battle_live_overlay_label(parent, "BattleLiveCompanyStatus", _tr("%d 远征团", "%d COMPANY") % party_count, Rect2(0.090, 0.025, 0.155, 0.055), 11, Color("#f5ead0")) company_status.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT - var enemy_status := _battle_live_overlay_label(parent, "BattleLiveEnemyStatus", _tr("敌方 %d", "ENEMY %d") % enemy_count, Rect2(0.735, 0.025, 0.16, 0.055), 16, Color("#f5ead0")) + var enemy_status := _battle_live_overlay_label(parent, "BattleLiveEnemyStatus", _tr("敌方 %d", "ENEMY %d") % enemy_count, Rect2(0.790, 0.025, 0.120, 0.055), 11, Color("#f5ead0")) enemy_status.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT var controls_locked := battle_live_state in ["outcome_locked", "invalid_event_data", "snapshot_retrying", "loading_resume", "interrupted_background", "no_resumable_battle"] - var pause_text := ">" if battle_paused else "II" - var pause := _battle_live_button(parent, "BattleLivePause", pause_text, Rect2(0.385, 0.0, 0.075, 0.14), toggle_battle_pause, false) + var pause := _battle_live_button(parent, "BattleLivePause", "", Rect2(0.390, 0.0, 0.075, 0.14), toggle_battle_pause, false) pause.tooltip_text = _tr("继续自动观察", "Resume automatic observation") if battle_paused else _tr("暂停自动观察", "Pause automatic observation") _set_battle_live_button_disabled(pause, controls_locked or battle_live_state in ["inspect_handoff", "pause_controls_handoff"]) - var speed := _battle_live_button(parent, "BattleLiveSpeed", "%dx" % int(battle_speed), Rect2(0.465, 0.0, 0.075, 0.14), cycle_battle_speed, false) + var speed := _battle_live_button(parent, "BattleLiveSpeed", "", Rect2(0.465, 0.0, 0.070, 0.14), cycle_battle_speed, false) speed.tooltip_text = _tr("切换 1x / 2x / 4x 展示速度", "Cycle 1x / 2x / 4x presentation speed") _set_battle_live_button_disabled(speed, controls_locked or battle_live_state in ["action_committed", "event_resolving", "inspect_handoff", "pause_controls_handoff"]) - var inspect_text := "x" if battle_live_state == "inspect_handoff" else "i" - var inspect := _battle_live_button(parent, "BattleLiveInspect", inspect_text, Rect2(0.545, 0.0, 0.075, 0.14), _battle_live_toggle_inspect, false) + var speed_value := _battle_live_overlay_label(parent, "BattleLiveSpeedValue", "x%d" % int(battle_speed), Rect2(0.503, 0.020, 0.030, 0.050), 8, Color("#24303a")) + speed_value.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + var inspect := _battle_live_button(parent, "BattleLiveInspect", "", Rect2(0.535, 0.0, 0.075, 0.14), _battle_live_toggle_inspect, false) inspect.tooltip_text = _tr("返回战场", "Return to battlefield") if battle_live_state == "inspect_handoff" else _tr("交给 BAT-003 检查原因", "Hand cause inspection to BAT-003") _set_battle_live_button_disabled(inspect, battle_live_state in ["outcome_locked", "invalid_event_data", "snapshot_retrying", "loading_resume", "interrupted_background", "no_resumable_battle", "pause_controls_handoff"]) - var settings_button := _battle_live_button(parent, "BattleLiveSettings", _tr("设置", "SETTINGS"), Rect2(0.900, 0.0, 0.095, 0.14), _battle_live_open_settings, false) + var settings_button := _battle_live_button(parent, "BattleLiveSettings", "", Rect2(0.872, 0.0, 0.075, 0.14), _battle_live_open_settings, false) + settings_button.tooltip_text = _tr("设置", "Settings") _set_battle_live_button_disabled(settings_button, battle_live_state in ["invalid_event_data", "snapshot_retrying", "loading_resume", "interrupted_background", "no_resumable_battle"]) func _build_battle_live_field(parent: Control, company: Dictionary, battle: Dictionary) -> void: - var objective_title := _battle_live_overlay_label(parent, "BattleLiveTitle", _tr("风镜初渡 · 自动观察", "WINDGLASS CROSSING · LIVE"), Rect2(0.040, 0.145, 0.28, 0.028), 10, Color("#e8d39d")) + var objective_title := _battle_live_overlay_label(parent, "BattleLiveTitle", _tr("风镜初渡 · 自动观察", "WINDGLASS CROSSING · LIVE"), Rect2(0.030, 0.148, 0.245, 0.024), 8, Color("#e8d39d")) objective_title.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT - var objective := _battle_live_overlay_label(parent, "BattleLiveObjective", _tr("目标 · 击破敌方队列", "BREAK THE ENEMY LINE"), Rect2(0.040, 0.177, 0.28, 0.040), 13, Color("#f5ead0")) + var objective := _battle_live_overlay_label(parent, "BattleLiveObjective", _tr("击破敌方队列", "BREAK THE ENEMY LINE"), Rect2(0.030, 0.173, 0.245, 0.032), 11, Color("#f5ead0")) objective.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT - var no_respawn := _battle_live_overlay_label(parent, "BattleLiveNoRespawn", _tr("无战斗内复活", "NO RESPAWN"), Rect2(0.040, 0.222, 0.125, 0.025), 8, Color("#f0c979")) + var no_respawn := _battle_live_overlay_label(parent, "BattleLiveNoRespawn", _tr("不可复活", "NO RESPAWN"), Rect2(0.030, 0.207, 0.105, 0.023), 7, Color("#f0c979")) no_respawn.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT - var no_reserve := _battle_live_overlay_label(parent, "BattleLiveNoReserve", _tr("无后备自动入场", "NO RESERVE ENTRY"), Rect2(0.165, 0.222, 0.155, 0.025), 8, Color("#f0c979")) - no_reserve.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT + var no_reserve := _battle_live_overlay_label(parent, "BattleLiveNoReserve", _tr("无后备入场", "NO RESERVE"), Rect2(0.138, 0.207, 0.137, 0.023), 7, Color("#f0c979")) + no_reserve.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT - var event_state := _battle_live_overlay_label(parent, "BattleLiveEventState", _battle_live_state_copy(), Rect2(0.370, 0.142, 0.26, 0.025), 8, Color("#e8d39d")) + var has_event := not battle_live_event.is_empty() and battle_live_state != "waiting_for_next_event" + var opening_event := String(battle_live_event.get("kind", "")) == "opening" + var event_state := _battle_live_overlay_label(parent, "BattleLiveEventState", _battle_live_state_copy(), Rect2(0.555, 0.350, 0.15, 0.022), 6, Color("#e8d39d")) event_state.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + event_state.visible = not opening_event and (has_event or battle_live_state in ["paused", "inspect_handoff", "pause_controls_handoff", "outcome_locked", "invalid_event_data", "snapshot_retrying", "loading_resume", "interrupted_background", "no_resumable_battle"]) var event_title_text := _battle_live_event_title() - var event_title := _battle_live_overlay_label(parent, "BattleLiveCurrentEvent", event_title_text, Rect2(0.370, 0.170, 0.26, 0.040), 12, Color("#f5ead0")) + var event_title_rect := Rect2(0.370, 0.295, 0.26, 0.042) if not has_event else Rect2(0.555, 0.375, 0.17, 0.032) + var event_title_size := 12 if not has_event else 8 + var event_title := _battle_live_overlay_label(parent, "BattleLiveCurrentEvent", event_title_text, event_title_rect, event_title_size, Color("#f5ead0")) event_title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER event_title.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART if battle_live_event.is_empty(): event_title.name = "BattleWaitingForNextEvent" + event_title.visible = not opening_event or battle_live_event.is_empty() var detail_text := _battle_live_event_detail(company, battle) - var event_detail := _battle_live_overlay_label(parent, "BattleLiveEventDetail", detail_text, Rect2(0.370, 0.210, 0.26, 0.027), 8, Color("#b8d6e8")) + var event_detail := _battle_live_overlay_label(parent, "BattleLiveEventDetail", detail_text, _battle_live_relation_rect(battle), 7, Color("#f6e3b0")) event_detail.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER event_detail.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART - event_detail.visible = not detail_text.is_empty() - var event_id := _battle_live_overlay_label(parent, "BattleLiveEventId", _battle_live_event_identity(), Rect2(0.370, 0.238, 0.26, 0.022), 7, Color("#9db6c2")) + event_detail.visible = not detail_text.is_empty() and String(battle_live_event.get("kind", "")) != "opening" + var event_id := _battle_live_overlay_label(parent, "BattleLiveEventId", _battle_live_event_identity(), _battle_live_event_id_rect(battle), 6, Color("#d9c88f")) event_id.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + event_id.visible = not opening_event and (has_event or battle_live_state in ["outcome_locked", "invalid_event_data", "interrupted_background"]) var delta_text := _battle_live_delta_copy() - var delta := _battle_live_overlay_label(parent, "BattleLiveEventDelta", delta_text, Rect2(0.445, 0.300, 0.12, 0.055), 15, _battle_live_delta_color()) + var delta_size := 10 if delta_text == _tr("已验证", "VERIFIED") else 16 + var delta := _battle_live_overlay_label(parent, "BattleLiveEventDelta", delta_text, _battle_live_delta_rect(battle), delta_size, _battle_live_delta_color()) delta.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER delta.visible = not delta_text.is_empty() _build_battle_live_diagnostic_actions(parent) @@ -4432,11 +4463,17 @@ func _build_battle_live_field(parent: Control, company: Dictionary, battle: Dict actors.mouse_filter = Control.MOUSE_FILTER_IGNORE parent.add_child(actors) var ids: Array = battle.get("front_to_rear_ids", []) - var visual_slots := [Rect2(0.075, 0.455, 0.115, 0.225), Rect2(0.185, 0.445, 0.115, 0.235), Rect2(0.295, 0.435, 0.115, 0.245), Rect2(0.405, 0.425, 0.115, 0.255)] + var visual_slots := _battle_live_ally_slots() for visual_index in range(ids.size()): var source_index := ids.size() - 1 - visual_index var recruit_id := String(ids[source_index]) var actor := _battle_opening_actor(source_index, _recruit_by_id(company, recruit_id), battle, visual_slots[mini(visual_index, visual_slots.size() - 1)]) + var position_label := actor.get_node_or_null("BattlePositionLabel") as Label + var name_label := actor.get_node_or_null("BattleActorName") as Label + if position_label != null: + position_label.visible = false + if name_label != null: + name_label.visible = false _battle_live_add_event_contour(actor, recruit_id) actors.add_child(actor) @@ -4446,15 +4483,17 @@ func _build_battle_live_field(parent: Control, company: Dictionary, battle: Dict enemies.mouse_filter = Control.MOUSE_FILTER_IGNORE parent.add_child(enemies) var enemy_ids: Array = battle.get("enemy_ids", []) - var enemy_slots := [Rect2(0.625, 0.475, 0.105, 0.205), Rect2(0.735, 0.455, 0.105, 0.225), Rect2(0.845, 0.435, 0.105, 0.245)] + var enemy_slots := _battle_live_enemy_slots() for enemy_index in range(enemy_ids.size()): var enemy_id_value := String(enemy_ids[enemy_index]) var enemy_actor := _battle_live_enemy(enemy_index, enemy_id_value, enemy_slots[mini(enemy_index, enemy_slots.size() - 1)]) _battle_live_add_event_contour(enemy_actor, enemy_id_value) enemies.add_child(enemy_actor) - var recent := _battle_live_overlay_label(parent, "BattleLiveRecentEvents", _battle_live_recent_copy(battle), Rect2(0.32, 0.750, 0.42, 0.030), 7, Color("#d2e0dd")) + var recent_copy := _battle_live_recent_copy(battle) + var recent := _battle_live_overlay_label(parent, "BattleLiveRecentEvents", recent_copy, Rect2(0.30, 0.758, 0.40, 0.028), 7, Color("#edf0dd")) recent.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER recent.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS + recent.visible = not recent_copy.is_empty() func _build_battle_live_diagnostic_actions(parent: Control) -> void: @@ -4473,18 +4512,20 @@ func _build_battle_live_diagnostic_actions(parent: Control) -> void: func _build_battle_live_bottom(parent: Control, company: Dictionary, battle: Dictionary) -> void: var tick := int(battle_live_observation.get("next_phase_index", 0)) - var phase := _battle_live_overlay_label(parent, "BattleLiveTick", _tr("事件 %d/%d", "EVENT %d/%d") % [tick, int(battle.get("total_phases", 9))], Rect2(0.018, 0.835, 0.135, 0.035), 10, Color("#f5ead0")) - phase.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT - var rule := _battle_live_overlay_label(parent, "BattleLiveRule", _tr("自动战斗 · 无指令", "AUTOMATIC · NO COMMANDS"), Rect2(0.018, 0.875, 0.135, 0.035), 8, Color("#e8d39d")) - rule.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT - var snapshot := _battle_live_overlay_label(parent, "BattleLiveSnapshotHash", _short_hash(battle.get("snapshot_hash", "")), Rect2(0.018, 0.930, 0.135, 0.030), 7, Color("#9ec9dd")) - snapshot.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT + var total := int(battle.get("total_phases", 9)) + var rule := _battle_live_overlay_label(parent, "BattleLiveRule", _tr("自动", "AUTO"), Rect2(0.055, 0.842, 0.075, 0.023), 7, Color("#e8d39d")) + rule.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + var phase := _battle_live_overlay_label(parent, "BattleLiveTick", "%02d / %02d" % [tick, total], Rect2(0.052, 0.870, 0.088, 0.060), 14, Color("#f5ead0")) + phase.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + var snapshot := _battle_live_overlay_label(parent, "BattleLiveSnapshotHash", _short_hash(battle.get("snapshot_hash", "")), Rect2(0.018, 0.952, 0.125, 0.020), 6, Color("#9ec9dd")) + snapshot.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + snapshot.visible = false var ids: Array = battle.get("front_to_rear_ids", []) for visual_index in range(ids.size()): var source_index := ids.size() - 1 - visual_index var recruit := _recruit_by_id(company, String(ids[source_index])) - parent.add_child(_battle_live_state_cell(source_index, recruit, battle, Rect2(0.17 + visual_index * 0.15, 0.825, 0.145, 0.15))) - var next_text := _tr("撤退入口", "RETREAT ENTRY") + parent.add_child(_battle_live_state_cell(source_index, recruit, battle, Rect2(0.170 + visual_index * 0.153, 0.817, 0.143, 0.165))) + var next_text := _tr("撤退", "RETREAT") var next_action := Callable(self, "_battle_live_open_retreat_entry") var next_disabled := battle_live_state in ["action_committed", "event_resolving", "invalid_event_data", "snapshot_retrying", "loading_resume", "no_resumable_battle"] var next_tooltip := _tr("BAT-004/BAT-005 负责控制与确认", "BAT-004/BAT-005 own controls and confirmation") @@ -4495,7 +4536,7 @@ func _build_battle_live_bottom(parent: Control, company: Dictionary, battle: Dic next_disabled = false next_tooltip = _tr("OUT-001 负责结果诊断", "OUT-001 owns result diagnosis") "inspect_handoff", "pause_controls_handoff": - next_text = _tr("返回战场", "RETURN") + next_text = _tr("返回", "RETURN") next_action = Callable(self, "_battle_live_cancel_handoff") next_disabled = false next_tooltip = _tr("返回已冻结的战场状态", "Return to the frozen battlefield state") @@ -4504,7 +4545,7 @@ func _build_battle_live_bottom(parent: Control, company: Dictionary, battle: Dic next_action = Callable(self, "_battle_live_open_bat006") next_disabled = false next_tooltip = _tr("BAT-006 负责中断恢复检查", "BAT-006 owns interruption review") - var next_button := _battle_live_button(parent, "BattleLiveNextBoundary", next_text, Rect2(0.80, 0.825, 0.175, 0.15), next_action, false) + var next_button := _battle_live_button(parent, "BattleLiveNextBoundary", next_text, Rect2(0.825, 0.810, 0.155, 0.180), next_action, false) next_button.tooltip_text = next_tooltip _set_battle_live_button_disabled(next_button, next_disabled) @@ -4535,24 +4576,34 @@ func _battle_live_enemy(index: int, enemy_id: String, rect: Rect2) -> Control: portrait.anchor_bottom = 0.80 portrait.mouse_filter = Control.MOUSE_FILTER_IGNORE enemy.add_child(portrait) + var hp_back := ColorRect.new() + hp_back.name = "BattleEnemyHPBack" + hp_back.anchor_left = 0.10 + hp_back.anchor_top = 0.755 + hp_back.anchor_right = 0.90 + hp_back.anchor_bottom = 0.835 + hp_back.color = Color("#11161a", 0.92) + hp_back.mouse_filter = Control.MOUSE_FILTER_IGNORE + enemy.add_child(hp_back) var hp := ColorRect.new() hp.name = "BattleEnemyHP" - hp.anchor_left = 0.12 - hp.anchor_top = 0.78 - hp.anchor_right = 0.88 - hp.anchor_bottom = 0.82 + hp.anchor_left = 0.13 + hp.anchor_top = 0.775 + hp.anchor_right = 0.87 + hp.anchor_bottom = 0.815 hp.color = Color("#d95f59") hp.mouse_filter = Control.MOUSE_FILTER_IGNORE enemy.add_child(hp) var label := _label(_content_name("enemies", enemy_id), _battle_live_text_size(8), Color("#ffe5d1")) label.name = "BattleEnemyName" - label.anchor_top = 0.86 + label.anchor_top = 0.84 label.anchor_right = 1.0 label.anchor_bottom = 1.0 label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS label.mouse_filter = Control.MOUSE_FILTER_IGNORE + label.visible = false enemy.add_child(label) return enemy @@ -4562,35 +4613,67 @@ func _battle_live_state_cell(position: int, recruit: Dictionary, battle: Diction cell.name = "BattleLiveStateCell%d" % position _set_normalized_rect(cell, rect) cell.mouse_filter = Control.MOUSE_FILTER_IGNORE + cell.clip_contents = true var portrait := TextureRect.new() - portrait.texture = _battle_opening_actor_texture(recruit) + portrait.name = "BattleLiveStatePortrait" + portrait.texture = InitialCompanyArt.texture_for(recruit) portrait.expand_mode = TextureRect.EXPAND_IGNORE_SIZE portrait.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED portrait.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS - portrait.anchor_left = 0.01 - portrait.anchor_top = 0.08 - portrait.anchor_right = 0.28 - portrait.anchor_bottom = 0.92 + portrait.anchor_left = 0.03 + portrait.anchor_top = 0.015 + portrait.anchor_right = 0.55 + portrait.anchor_bottom = 0.71 portrait.mouse_filter = Control.MOUSE_FILTER_IGNORE cell.add_child(portrait) - var identity := _label(_tr("%d 号 · %s", "POS %d · %s") % [position, _recruit_name(recruit)], _battle_live_text_size(7), Color("#f5ead0")) - identity.anchor_left = 0.30 - identity.anchor_top = 0.14 - identity.anchor_right = 0.98 - identity.anchor_bottom = 0.52 + var position_label := _label("%d" % (position + 1), _battle_live_text_size(8), Color("#f5ead0")) + position_label.name = "BattleLiveStatePosition" + position_label.anchor_left = 0.0 + position_label.anchor_top = 0.0 + position_label.anchor_right = 0.18 + position_label.anchor_bottom = 0.22 + position_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + position_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER + position_label.mouse_filter = Control.MOUSE_FILTER_IGNORE + cell.add_child(position_label) + var identity := _label(_recruit_name(recruit), _battle_live_text_size(7), Color("#f5ead0")) + identity.name = "BattleLiveStateIdentity" + identity.anchor_left = 0.48 + identity.anchor_top = 0.12 + identity.anchor_right = 0.96 + identity.anchor_bottom = 0.40 identity.vertical_alignment = VERTICAL_ALIGNMENT_CENTER identity.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS identity.mouse_filter = Control.MOUSE_FILTER_IGNORE cell.add_child(identity) var fallen := String(recruit.get("recruit_id", "")) in Array(battle.get("knocked_out_ids", [])) - var state := _label(_tr("本战离场", "FALLEN") if fallen else _tr("队列就绪", "LINE READY"), _battle_live_text_size(7), Color("#e98b83") if fallen else Color("#8fd2a2")) - state.anchor_left = 0.30 - state.anchor_top = 0.54 - state.anchor_right = 0.98 - state.anchor_bottom = 0.86 + var state := _label(_tr("离场", "FALLEN") if fallen else _tr("就绪", "READY"), _battle_live_text_size(6), Color("#e98b83") if fallen else Color("#8fd2a2")) + state.name = "BattleLiveStateStatus" + state.anchor_left = 0.48 + state.anchor_top = 0.42 + state.anchor_right = 0.96 + state.anchor_bottom = 0.64 state.vertical_alignment = VERTICAL_ALIGNMENT_CENTER state.mouse_filter = Control.MOUSE_FILTER_IGNORE cell.add_child(state) + var hp := ColorRect.new() + hp.name = "BattleLiveStateHP" + hp.anchor_left = 0.070 + hp.anchor_top = 0.752 + hp.anchor_right = 0.070 if fallen else 0.930 + hp.anchor_bottom = 0.794 + hp.color = Color("#73bd64") + hp.mouse_filter = Control.MOUSE_FILTER_IGNORE + cell.add_child(hp) + var resource := ColorRect.new() + resource.name = "BattleLiveStateResource" + resource.anchor_left = 0.070 + resource.anchor_top = 0.872 + resource.anchor_right = 0.070 if fallen else 0.820 + resource.anchor_bottom = 0.914 + resource.color = Color("#4f9ee0") if not fallen else Color("#5a6268") + resource.mouse_filter = Control.MOUSE_FILTER_IGNORE + cell.add_child(resource) return cell @@ -4603,17 +4686,81 @@ func _battle_live_add_event_contour(actor: Control, actor_id: String) -> void: return var contour := Panel.new() contour.name = "BattleLiveSourceContour" if actor_id == source_id else "BattleLiveTargetContour" - contour.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) + contour.anchor_left = 0.08 + contour.anchor_top = 0.735 + contour.anchor_right = 0.92 + contour.anchor_bottom = 0.845 contour.mouse_filter = Control.MOUSE_FILTER_IGNORE var style := StyleBoxFlat.new() - style.bg_color = Color.TRANSPARENT + style.bg_color = Color("#f0c96d", 0.08) if actor_id == source_id else Color("#e36b66", 0.10) style.border_color = Color("#f0c96d") if actor_id == source_id else Color("#e36b66") style.set_border_width_all(2) - style.set_corner_radius_all(4) + style.set_corner_radius_all(2) contour.add_theme_stylebox_override("panel", style) actor.add_child(contour) +func _battle_live_ally_slots() -> Array[Rect2]: + return [ + Rect2(0.060, 0.440, 0.115, 0.245), + Rect2(0.175, 0.430, 0.115, 0.255), + Rect2(0.290, 0.420, 0.115, 0.265), + Rect2(0.405, 0.410, 0.115, 0.275), + ] + + +func _battle_live_enemy_slots() -> Array[Rect2]: + return [ + Rect2(0.625, 0.455, 0.105, 0.225), + Rect2(0.745, 0.435, 0.105, 0.245), + Rect2(0.865, 0.415, 0.105, 0.265), + ] + + +func _battle_live_marker_anchors(battle: Dictionary, allies: bool) -> Array[Vector2]: + var result: Array[Vector2] = [] + var ids: Array = battle.get("front_to_rear_ids", []) if allies else battle.get("enemy_ids", []) + var slots: Array[Rect2] = _battle_live_ally_slots() if allies else _battle_live_enemy_slots() + for visual_index in range(ids.size()): + var slot: Rect2 = slots[mini(visual_index, slots.size() - 1)] + result.append(slot.position + Vector2(slot.size.x * 0.50, slot.size.y * 0.055)) + return result + + +func _battle_live_actor_anchor(actor_id: String, battle: Dictionary, source_fallback: bool) -> Vector2: + var ally_ids: Array = battle.get("front_to_rear_ids", []) + var ally_source_index := ally_ids.find(actor_id) + if ally_source_index >= 0: + var ally_visual_index := ally_ids.size() - 1 - ally_source_index + var ally_slots := _battle_live_ally_slots() + var ally_slot: Rect2 = ally_slots[mini(ally_visual_index, ally_slots.size() - 1)] + return ally_slot.position + Vector2(ally_slot.size.x * 0.50, ally_slot.size.y * 0.58) + var enemy_ids: Array = battle.get("enemy_ids", []) + var enemy_index := enemy_ids.find(actor_id) + if enemy_index >= 0: + var enemy_slots := _battle_live_enemy_slots() + var enemy_slot: Rect2 = enemy_slots[mini(enemy_index, enemy_slots.size() - 1)] + return enemy_slot.position + Vector2(enemy_slot.size.x * 0.50, enemy_slot.size.y * 0.58) + return Vector2(0.47, 0.56) if source_fallback else Vector2(0.67, 0.56) + + +func _battle_live_relation_rect(battle: Dictionary) -> Rect2: + var source := _battle_live_actor_anchor(String(battle_live_event.get("actor_id", "")), battle, true) + var target := _battle_live_actor_anchor(String(battle_live_event.get("target_id", "")), battle, false) + var center := (source + target) * 0.5 + return Rect2(clampf(center.x - 0.105, 0.34, 0.66), clampf(center.y - 0.105, 0.40, 0.58), 0.21, 0.030) + + +func _battle_live_event_id_rect(battle: Dictionary) -> Rect2: + var target := _battle_live_actor_anchor(String(battle_live_event.get("target_id", "")), battle, false) + return Rect2(clampf(target.x - 0.075, 0.34, 0.82), clampf(target.y - 0.285, 0.24, 0.36), 0.15, 0.025) + + +func _battle_live_delta_rect(battle: Dictionary) -> Rect2: + var target := _battle_live_actor_anchor(String(battle_live_event.get("target_id", "")), battle, false) + return Rect2(clampf(target.x - 0.050, 0.04, 0.90), clampf(target.y - 0.235, 0.26, 0.42), 0.10, 0.060) + + func _battle_live_actor_side(actor_id: String, battle: Dictionary) -> String: if actor_id in Array(battle.get("front_to_rear_ids", [])): return "ally" @@ -4674,11 +4821,17 @@ func _battle_live_event_detail(company: Dictionary, battle: Dictionary) -> Strin "no_resumable_battle": return _battle_error_text(battle_live_error_code) if battle_live_event.is_empty(): return "" - var source := _battle_live_actor_name(company, battle, String(battle_live_event.get("actor_id", ""))) - var target := _battle_live_actor_name(company, battle, String(battle_live_event.get("target_id", ""))) - var amount := int(battle_live_event.get("amount", 0)) - if source.is_empty() and target.is_empty(): + var source_id := String(battle_live_event.get("actor_id", "")) + var target_id := String(battle_live_event.get("target_id", "")) + if source_id.is_empty() and target_id.is_empty(): return _tr("事件边界已验证", "Event boundary verified") + var source := _battle_live_actor_name(company, battle, source_id) + var target := _battle_live_actor_name(company, battle, target_id) + var amount := int(battle_live_event.get("amount", 0)) + if source_id.is_empty(): + return _tr("目标 %s · 数值 %d", "TARGET %s · VALUE %d") % [target, amount] + if target_id.is_empty(): + return _tr("来源 %s · 数值 %d", "SOURCE %s · VALUE %d") % [source, amount] return _tr("%s → %s · 数值 %d", "%s -> %s · VALUE %d") % [source, target, amount] @@ -4725,9 +4878,11 @@ func _battle_live_actor_name(company: Dictionary, battle: Dictionary, actor_id: func _battle_live_recent_copy(battle: Dictionary) -> String: var events: Array = battle.get("phase_events", []) if events.is_empty(): - return _tr("最近事件:暂无", "RECENT EVENTS: NONE") + return "" + if events.size() == 1 and String(events[0].get("kind", "")) == "opening": + return "" var copies: Array[String] = [] - for event in events.slice(maxi(0, events.size() - 3), events.size()): + for event in events.slice(maxi(0, events.size() - 2), events.size()): copies.append(_battle_event_text(String(event.get("caption_id", "")))) return " · ".join(copies) @@ -4765,8 +4920,22 @@ func _battle_live_button(parent: Control, node_name: String, text_value: String, var label := button.get_node_or_null("ButtonLabel") as Label if label != null: label.add_theme_font_size_override("font_size", _battle_live_text_size(10 if not primary else 12)) - if node_name in ["BattleLivePause", "BattleLiveSpeed", "BattleLiveInspect"]: - button.add_theme_stylebox_override("disabled", _flat_style(Color("#e5d8b7", 0.90), Color("#9e8756", 0.86), 1, 3)) + if node_name in ["BattleLivePause", "BattleLiveSpeed", "BattleLiveInspect", "BattleLiveSettings"]: + for state_name in ["normal", "hover", "pressed", "focus", "disabled", "hover_pressed"]: + button.add_theme_stylebox_override(state_name, _flat_style(Color.TRANSPARENT, Color.TRANSPARENT, 0, 0)) + if label != null: + label.visible = false + elif node_name == "BattleLiveNextBoundary": + for state_name in ["normal", "pressed", "disabled", "hover_pressed"]: + button.add_theme_stylebox_override(state_name, _flat_style(Color.TRANSPARENT, Color.TRANSPARENT, 0, 0)) + button.add_theme_stylebox_override("hover", _flat_style(Color("#d8b45c", 0.10), Color("#e4c979", 0.55), 1, 3)) + button.add_theme_stylebox_override("focus", _flat_style(Color("#d8b45c", 0.12), Color("#f3db99", 0.85), 2, 3)) + if label != null: + label.anchor_left = 0.08 + label.anchor_top = 0.62 + label.anchor_right = 0.92 + label.anchor_bottom = 0.92 + label.add_theme_font_size_override("font_size", _battle_live_text_size(7)) return button