diff --git a/scripts/scenes/battle_scene.gd b/scripts/scenes/battle_scene.gd index 0b68d40..df4666e 100644 --- a/scripts/scenes/battle_scene.gd +++ b/scripts/scenes/battle_scene.gd @@ -204,6 +204,7 @@ const BATTLE_UNIT_LIST_CLASS_CREST_PANEL_SIZE := Vector2(22, 22) const BATTLE_UNIT_LIST_CLASS_CREST_ICON_SIZE := Vector2(17, 17) const BATTLE_UNIT_LIST_BADGE_SIZE := Vector2(72, 22) const BATTLE_UNIT_LIST_BADGE_ICON_SIZE := Vector2(15, 15) +const BATTLE_UNIT_LIST_HP_BAR_SIZE := Vector2(40, 7) const SETTINGS_PANEL_SIZE := Vector2(420, 330) const LOCAL_COMMAND_BUTTON_SIZE := Vector2(92, 38) const LOCAL_COMMAND_CANCEL_BUTTON_SIZE := Vector2(196, 30) @@ -13116,10 +13117,14 @@ func _make_battle_unit_list_row(unit: Dictionary) -> HBoxContainer: var text := str((badge_entry as Dictionary).get("text", "")) var badge_tooltip := str((badge_entry as Dictionary).get("tooltip", tooltip_text)) var icon_texture: Texture2D = (badge_entry as Dictionary).get("icon", null) + var badge_kind := str((badge_entry as Dictionary).get("kind", "text")) + var fill_ratio := float((badge_entry as Dictionary).get("fill_ratio", -1.0)) badge_row.add_child(_make_battle_unit_list_badge( text, badge_tooltip, - icon_texture + icon_texture, + badge_kind, + fill_ratio )) return row @@ -13190,7 +13195,7 @@ func _format_battle_unit_list_row_text(unit: Dictionary) -> String: func _battle_unit_list_badge_entries(unit: Dictionary, row_tooltip: String) -> Array: var hp := int(unit.get("hp", 0)) var max_hp := maxi(1, int(unit.get("max_hp", 1))) - var hp_percent := int(round(float(hp) * 100.0 / float(max_hp))) + var hp_ratio := clampf(float(hp) / float(max_hp), 0.0, 1.0) var zone_text := _battle_zone_label(unit.get("pos", Vector2i(-1, -1))) return [ { @@ -13199,7 +13204,9 @@ func _battle_unit_list_badge_entries(unit: Dictionary, row_tooltip: String) -> A "icon": _load_unit_class_icon_texture(unit) }, { - "text": "%d%%" % hp_percent, + "kind": "hp", + "text": "", + "fill_ratio": hp_ratio, "tooltip": "병력 %d/%d\n%s" % [hp, max_hp, row_tooltip], "icon": _make_toolbar_icon("status") }, @@ -13216,7 +13223,7 @@ func _battle_unit_list_badge_entries(unit: Dictionary, row_tooltip: String) -> A ] -func _make_battle_unit_list_badge(text: String, tooltip_text: String, icon_texture: Texture2D = null) -> PanelContainer: +func _make_battle_unit_list_badge(text: String, tooltip_text: String, icon_texture: Texture2D = null, badge_kind: String = "text", fill_ratio: float = -1.0) -> PanelContainer: var panel := PanelContainer.new() panel.custom_minimum_size = BATTLE_UNIT_LIST_BADGE_SIZE panel.tooltip_text = tooltip_text @@ -13241,6 +13248,22 @@ func _make_battle_unit_list_badge(text: String, tooltip_text: String, icon_textu icon.tooltip_text = tooltip_text row.add_child(icon) + if badge_kind == "hp": + var hp_bar := ProgressBar.new() + hp_bar.name = "BattleUnitListHpBar" + hp_bar.custom_minimum_size = BATTLE_UNIT_LIST_HP_BAR_SIZE + hp_bar.size_flags_vertical = Control.SIZE_SHRINK_CENTER + hp_bar.min_value = 0.0 + hp_bar.max_value = 1.0 + hp_bar.value = clampf(fill_ratio, 0.0, 1.0) + hp_bar.show_percentage = false + hp_bar.tooltip_text = tooltip_text + hp_bar.add_theme_stylebox_override("background", _make_panel_style(Color(0.050, 0.029, 0.018, 0.96), UI_LACQUER_EDGE, 1, 0, 0, 0)) + hp_bar.add_theme_stylebox_override("fill", _make_panel_style(_unit_hp_color(clampf(fill_ratio, 0.0, 1.0)), Color(0.82, 0.72, 0.50, 1.0), 1, 0, 0, 0)) + row.add_child(hp_bar) + panel.set_meta("battle_unit_list_hp_bar", true) + return panel + if text.strip_edges().is_empty(): row.alignment = BoxContainer.ALIGNMENT_CENTER return panel diff --git a/tools/smoke_visual_assets.gd b/tools/smoke_visual_assets.gd index 2fd6268..8f0e1ac 100644 --- a/tools/smoke_visual_assets.gd +++ b/tools/smoke_visual_assets.gd @@ -4469,8 +4469,12 @@ func _check_battle_unit_list_panel(failures: Array[String]) -> void: var ally_visible_text := _collect_child_text(scene.battle_unit_list_rows) var ally_badge_text := _collect_descendant_text_by_name(scene.battle_unit_list_rows, "BattleUnitListBadgeLabel") var ally_tooltips := _collect_child_tooltips(scene.battle_unit_list_rows) - if not ally_badge_text.contains("100%") or not ally_badge_text.contains("서측"): - failures.append("ally battle unit list should show compact HP percent and zone badges: %s" % ally_badge_text) + if ally_badge_text.contains("%"): + failures.append("ally battle unit list should move exact HP percent into the hover bar tooltip: %s" % ally_badge_text) + if not ally_badge_text.contains("서측"): + failures.append("ally battle unit list should show compact zone badges: %s" % ally_badge_text) + if _find_descendant_by_name(scene.battle_unit_list_rows, "BattleUnitListHpBar") == null: + failures.append("ally battle unit list should show a visual HP bar instead of inline percent text") for class_label in ["지휘관", "기병", "보병", "궁병", "책사"]: if ally_badge_text.contains(class_label): failures.append("ally battle unit list should move class names into icon hover text: %s" % ally_badge_text) @@ -4504,8 +4508,12 @@ func _check_battle_unit_list_panel(failures: Array[String]) -> void: var enemy_visible_text := _collect_child_text(scene.battle_unit_list_rows) var enemy_badge_text := _collect_descendant_text_by_name(scene.battle_unit_list_rows, "BattleUnitListBadgeLabel") var enemy_tooltips := _collect_child_tooltips(scene.battle_unit_list_rows) - if not enemy_badge_text.contains("적") or not enemy_badge_text.contains("%"): - failures.append("enemy battle unit list should show compact status and HP percent badges: %s" % enemy_badge_text) + if not enemy_badge_text.contains("적"): + failures.append("enemy battle unit list should show compact status badges: %s" % enemy_badge_text) + if enemy_badge_text.contains("%"): + failures.append("enemy battle unit list should move exact HP percent into the hover bar tooltip: %s" % enemy_badge_text) + if _find_descendant_by_name(scene.battle_unit_list_rows, "BattleUnitListHpBar") == null: + failures.append("enemy battle unit list should show a visual HP bar instead of inline percent text") if not enemy_badge_text.contains("성채") and not enemy_badge_text.contains("동측"): failures.append("enemy battle unit list should show a readable zone badge instead of raw coordinates: %s" % enemy_badge_text) for class_label in ["지휘관", "기병", "보병", "궁병", "책사"]: