Improve unit focus HUD details
This commit is contained in:
@@ -293,7 +293,7 @@ func _create_hud() -> void:
|
||||
side_panel.add_child(side_column)
|
||||
|
||||
var selected_row := HBoxContainer.new()
|
||||
selected_row.custom_minimum_size = Vector2(420, 104)
|
||||
selected_row.custom_minimum_size = Vector2(420, 126)
|
||||
selected_row.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
selected_row.add_theme_constant_override("separation", 8)
|
||||
side_column.add_child(selected_row)
|
||||
@@ -321,7 +321,7 @@ func _create_hud() -> void:
|
||||
|
||||
selected_label = Label.new()
|
||||
selected_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
selected_label.custom_minimum_size = Vector2(320, 104)
|
||||
selected_label.custom_minimum_size = Vector2(320, 126)
|
||||
selected_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
selected_row.add_child(selected_label)
|
||||
|
||||
@@ -337,7 +337,7 @@ func _create_hud() -> void:
|
||||
|
||||
cell_info_label = Label.new()
|
||||
cell_info_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
cell_info_label.custom_minimum_size = Vector2(420, 90)
|
||||
cell_info_label.custom_minimum_size = Vector2(420, 78)
|
||||
side_column.add_child(cell_info_label)
|
||||
|
||||
forecast_label = Label.new()
|
||||
@@ -1744,16 +1744,7 @@ func _update_hud() -> void:
|
||||
if hovered_unit.is_empty():
|
||||
selected_label.text = "No unit selected."
|
||||
else:
|
||||
selected_label.text = "Hover: %s\n%s Lv.%d %s\nHP %d/%d MP %d/%d" % [
|
||||
str(hovered_unit.get("name", "Unit")),
|
||||
str(hovered_unit.get("team", "")).capitalize(),
|
||||
int(hovered_unit.get("level", 1)),
|
||||
str(hovered_unit.get("class", "Unit")),
|
||||
int(hovered_unit.get("hp", 0)),
|
||||
int(hovered_unit.get("max_hp", 1)),
|
||||
int(hovered_unit.get("mp", 0)),
|
||||
int(hovered_unit.get("max_mp", 0))
|
||||
]
|
||||
selected_label.text = _format_unit_focus_text(hovered_unit, "Hover")
|
||||
wait_button.disabled = true
|
||||
_update_tactic_button({})
|
||||
_hide_tactic_menu()
|
||||
@@ -1763,27 +1754,7 @@ func _update_hud() -> void:
|
||||
_hide_equip_menu()
|
||||
else:
|
||||
_update_hud_unit_portrait(selected)
|
||||
var roster_mark := " *" if selected.get("loaded_from_roster", false) else ""
|
||||
selected_label.text = "%s%s Lv.%d %s EXP %d\nHP %d/%d MP %d/%d ATK %d DEF %d INT %d\nMOV %d RNG %d-%d" % [
|
||||
selected["name"],
|
||||
roster_mark,
|
||||
selected["level"],
|
||||
selected["class"],
|
||||
selected.get("exp", 0),
|
||||
selected["hp"],
|
||||
selected["max_hp"],
|
||||
selected.get("mp", 0),
|
||||
selected.get("max_mp", 0),
|
||||
selected["atk"],
|
||||
selected["def"],
|
||||
selected.get("int", 0),
|
||||
selected["move"],
|
||||
selected.get("min_range", 1),
|
||||
selected["range"]
|
||||
]
|
||||
var selected_effects := state.get_status_effect_summary(selected["id"])
|
||||
if not selected_effects.is_empty():
|
||||
selected_label.text += "\nEffects: %s" % selected_effects
|
||||
selected_label.text = _format_unit_focus_text(selected, "Selected")
|
||||
wait_button.disabled = selected.get("acted", false) or not state.can_player_act() or _is_input_locked()
|
||||
_update_tactic_button(selected)
|
||||
_update_item_button(selected)
|
||||
@@ -1809,6 +1780,81 @@ func _format_objective_hud_text() -> String:
|
||||
return "Objective: %s" % text
|
||||
|
||||
|
||||
func _format_unit_focus_text(unit: Dictionary, prefix: String) -> String:
|
||||
if unit.is_empty():
|
||||
return "No unit selected."
|
||||
var roster_mark := " *" if unit.get("loaded_from_roster", false) else ""
|
||||
var control_label := " Protected" if not bool(unit.get("controllable", true)) else ""
|
||||
var lines := []
|
||||
lines.append("%s: %s%s%s" % [
|
||||
prefix,
|
||||
str(unit.get("name", "Unit")),
|
||||
roster_mark,
|
||||
control_label
|
||||
])
|
||||
lines.append("%s Lv.%d %s %s" % [
|
||||
str(unit.get("team", "")).capitalize(),
|
||||
int(unit.get("level", 1)),
|
||||
str(unit.get("class", "Unit")),
|
||||
_unit_role_text(unit)
|
||||
])
|
||||
lines.append("HP %d/%d MP %d/%d EXP %d" % [
|
||||
int(unit.get("hp", 0)),
|
||||
int(unit.get("max_hp", 1)),
|
||||
int(unit.get("mp", 0)),
|
||||
int(unit.get("max_mp", 0)),
|
||||
int(unit.get("exp", 0))
|
||||
])
|
||||
lines.append("ATK %d DEF %d INT %d AGI %d" % [
|
||||
int(unit.get("atk", 0)),
|
||||
int(unit.get("def", 0)),
|
||||
int(unit.get("int", 0)),
|
||||
int(unit.get("agi", 0))
|
||||
])
|
||||
lines.append("MOV %d %s RNG %d-%d" % [
|
||||
int(unit.get("move", 0)),
|
||||
_format_move_type(str(unit.get("move_type", "foot"))),
|
||||
int(unit.get("min_range", 1)),
|
||||
int(unit.get("range", 1))
|
||||
])
|
||||
var terrain_text := _unit_current_terrain_text(unit)
|
||||
if not terrain_text.is_empty():
|
||||
lines.append(terrain_text)
|
||||
var status_effects := state.get_status_effect_summary(str(unit.get("id", "")))
|
||||
if not status_effects.is_empty():
|
||||
lines.append("Effects: %s" % status_effects)
|
||||
return _join_strings(lines, "\n")
|
||||
|
||||
|
||||
func _unit_role_text(unit: Dictionary) -> String:
|
||||
var class_id := str(unit.get("class_id", ""))
|
||||
if class_id.contains("cavalry"):
|
||||
return "Shock cavalry"
|
||||
if class_id.contains("archer") or class_id.contains("marksman"):
|
||||
return "Ranged pressure"
|
||||
if class_id.contains("strategist") or class_id.contains("advisor"):
|
||||
return "Tactics support"
|
||||
if class_id.contains("hero") or class_id.contains("commander"):
|
||||
return "Command tactics"
|
||||
if class_id.contains("warrior") or class_id.contains("champion") or class_id.contains("bandit"):
|
||||
return "Assault fighter"
|
||||
return "Line infantry"
|
||||
|
||||
|
||||
func _unit_current_terrain_text(unit: Dictionary) -> String:
|
||||
var cell: Vector2i = unit.get("pos", Vector2i(-1, -1))
|
||||
if not state.is_inside(cell):
|
||||
return ""
|
||||
return "Tile %d,%d %s Cost %d DEF +%d AVO +%d%%" % [
|
||||
cell.x + 1,
|
||||
cell.y + 1,
|
||||
state.get_terrain_name(cell),
|
||||
state.get_move_cost(cell, str(unit.get("move_type", "foot"))),
|
||||
state.get_terrain_defense(cell),
|
||||
state.get_terrain_avoid(cell)
|
||||
]
|
||||
|
||||
|
||||
func _update_mission_panel() -> void:
|
||||
if mission_detail_label == null:
|
||||
return
|
||||
@@ -1887,24 +1933,17 @@ func _update_cell_info() -> void:
|
||||
var unit: Dictionary = summary["unit"]
|
||||
if not unit.is_empty():
|
||||
var control_label := " Protected" if not bool(unit.get("controllable", true)) else ""
|
||||
text += "\n%s%s %s Lv.%d %s (%s)\nHP %d/%d MP %d/%d ATK %d DEF %d INT %d AGI %d\nMOV %d RNG %d-%d\nGear: %s" % [
|
||||
text += "\nUnit: %s%s %s Lv.%d\n%s %s HP %d/%d MP %d/%d\nGear: %s" % [
|
||||
unit["name"],
|
||||
control_label,
|
||||
str(unit["team"]).capitalize(),
|
||||
unit["level"],
|
||||
str(unit.get("class", "Unit")),
|
||||
_format_move_type(str(unit.get("move_type", "foot"))),
|
||||
_unit_role_text(unit),
|
||||
unit["hp"],
|
||||
unit["max_hp"],
|
||||
unit.get("mp", 0),
|
||||
unit.get("max_mp", 0),
|
||||
unit["atk"],
|
||||
unit["def"],
|
||||
unit.get("int", 0),
|
||||
unit.get("agi", 0),
|
||||
unit.get("move", 0),
|
||||
unit.get("min_range", 1),
|
||||
unit["range"],
|
||||
_format_hover_unit_equipment(unit)
|
||||
]
|
||||
var status_effects := state.get_status_effect_summary(unit["id"])
|
||||
|
||||
Reference in New Issue
Block a user