Polish board unit labels with generated surfaces
This commit is contained in:
@@ -5859,10 +5859,7 @@ func _draw_units() -> void:
|
||||
_draw_unit_facing_marker(rect, unit, team_color, sprite_modulate)
|
||||
|
||||
var hp_ratio := float(unit["hp"]) / float(max(1, int(unit["max_hp"])))
|
||||
var hp_back := Rect2(rect.position + Vector2(8, TILE_SIZE - 8), Vector2(TILE_SIZE - 16, 5))
|
||||
var hp_front := Rect2(hp_back.position, Vector2(hp_back.size.x * hp_ratio, hp_back.size.y))
|
||||
draw_rect(hp_back, Color(0.08, 0.08, 0.09))
|
||||
draw_rect(hp_front, _unit_hp_color(hp_ratio))
|
||||
_draw_unit_hp_bar(rect, hp_ratio)
|
||||
_draw_unit_status_markers(center, hp_ratio, unit)
|
||||
|
||||
if selected_unit and not selection_frame_drawn:
|
||||
@@ -5967,12 +5964,48 @@ func _draw_unit_nameplate(rect: Rect2, label: String) -> void:
|
||||
if label.is_empty():
|
||||
return
|
||||
var font := _draw_ui_font(true)
|
||||
var label_rect := Rect2(rect.position + Vector2(4.0, TILE_SIZE - 21.0), Vector2(TILE_SIZE - 8.0, 13.0))
|
||||
draw_rect(label_rect, Color(0.025, 0.018, 0.012, 0.76))
|
||||
draw_rect(label_rect, Color(UI_OLD_BRONZE.r, UI_OLD_BRONZE.g, UI_OLD_BRONZE.b, 0.48), false, 1.0)
|
||||
var label_rect := _unit_nameplate_rect(rect)
|
||||
_draw_generated_badge_panel(
|
||||
label_rect,
|
||||
Color(UI_OLD_BRONZE.r, UI_OLD_BRONZE.g, UI_OLD_BRONZE.b, 0.74),
|
||||
Color(0.025, 0.018, 0.012, 0.62),
|
||||
_unit_board_panel_key(),
|
||||
0.08,
|
||||
1.0
|
||||
)
|
||||
_draw_ink_text(font, label_rect.position + Vector2(0, 10), label, HORIZONTAL_ALIGNMENT_CENTER, label_rect.size.x, 9, UI_PARCHMENT_TEXT)
|
||||
|
||||
|
||||
func _draw_unit_hp_bar(rect: Rect2, hp_ratio: float) -> void:
|
||||
var bar_rect := _unit_hp_bar_rect(rect)
|
||||
_draw_generated_badge_panel(
|
||||
bar_rect,
|
||||
Color(UI_TARNISHED_BRONZE.r, UI_TARNISHED_BRONZE.g, UI_TARNISHED_BRONZE.b, 0.70),
|
||||
Color(0.020, 0.018, 0.015, 0.66),
|
||||
_unit_board_panel_key(),
|
||||
0.06,
|
||||
1.0
|
||||
)
|
||||
var fill_width := maxf(0.0, (bar_rect.size.x - 2.0) * clampf(hp_ratio, 0.0, 1.0))
|
||||
if fill_width <= 0.0:
|
||||
return
|
||||
var fill_rect := Rect2(bar_rect.position + Vector2(1.0, 1.0), Vector2(fill_width, maxf(1.0, bar_rect.size.y - 2.0)))
|
||||
draw_rect(fill_rect, _unit_hp_color(hp_ratio))
|
||||
draw_rect(Rect2(fill_rect.position, Vector2(fill_rect.size.x, 1.0)), Color(1.0, 0.96, 0.72, 0.20))
|
||||
|
||||
|
||||
func _unit_nameplate_rect(rect: Rect2) -> Rect2:
|
||||
return Rect2(rect.position + Vector2(4.0, TILE_SIZE - 22.0), Vector2(TILE_SIZE - 8.0, 14.0))
|
||||
|
||||
|
||||
func _unit_hp_bar_rect(rect: Rect2) -> Rect2:
|
||||
return Rect2(rect.position + Vector2(7.0, TILE_SIZE - 8.0), Vector2(TILE_SIZE - 14.0, 6.0))
|
||||
|
||||
|
||||
func _unit_board_panel_key() -> String:
|
||||
return "hud_jade"
|
||||
|
||||
|
||||
func _target_selection_marker_entries() -> Array[Dictionary]:
|
||||
if basic_attack_targeting:
|
||||
return _attack_target_marker_entries()
|
||||
|
||||
Reference in New Issue
Block a user