Improve map text readability

This commit is contained in:
2026-06-19 13:11:26 +09:00
parent 761e571901
commit b9fb2dd79e
2 changed files with 39 additions and 10 deletions

View File

@@ -2971,9 +2971,6 @@ func _draw_units() -> void:
_draw_unit_class_emblem(rect, center, unit, team_color)
_draw_unit_class_badge(rect, unit, team_color)
var label := _short_name(String(unit["name"]))
draw_string(font, rect.position + Vector2(2, TILE_SIZE - 18), label, HORIZONTAL_ALIGNMENT_CENTER, TILE_SIZE - 4, 11, Color.WHITE)
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))
@@ -2983,6 +2980,7 @@ func _draw_units() -> void:
if unit.get("id", "") == state.selected_unit_id:
draw_arc(center, 29, 0.0, TAU, 48, Color(1.0, 0.92, 0.25), 3.0)
_draw_unit_nameplate(rect, _short_name(String(unit["name"])))
func _draw_target_selection_markers() -> void:
@@ -3000,7 +2998,17 @@ func _draw_target_selection_markers() -> void:
draw_rect(rect.grow(-6.0), color, false, 2.2)
draw_rect(marker_rect, Color(0.025, 0.028, 0.034, 0.88))
draw_rect(marker_rect, color, false, 1.4)
draw_string(font, marker_rect.position + Vector2(0, 13), str(marker.get("text", "")), HORIZONTAL_ALIGNMENT_CENTER, marker_rect.size.x, 12, color)
_draw_ink_text(font, marker_rect.position + Vector2(0, 13), str(marker.get("text", "")), HORIZONTAL_ALIGNMENT_CENTER, marker_rect.size.x, 12, color)
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)
_draw_ink_text(font, label_rect.position + Vector2(0, 10), label, HORIZONTAL_ALIGNMENT_CENTER, label_rect.size.x, 9, UI_PARCHMENT_TEXT)
func _target_selection_marker_entries() -> Array[Dictionary]:
@@ -3648,12 +3656,8 @@ func _draw_target_preview_badge() -> void:
if not state.is_inside(cell):
return
var rect := _rect_for_cell(cell)
var size := TARGET_PREVIEW_BADGE_SIZE
var badge_rect := Rect2(
rect.position + Vector2((TILE_SIZE - size.x) * 0.5, 5.0),
size
)
var badge_rect := _target_preview_badge_rect(cell, size)
var kind := str(badge.get("kind", ""))
var color := _target_preview_badge_color(kind)
var background := Color(0.025, 0.028, 0.034, 0.88)
@@ -3662,7 +3666,20 @@ func _draw_target_preview_badge() -> void:
draw_rect(badge_rect, background)
draw_rect(badge_rect, color, false, 2.0)
draw_string(font, badge_rect.position + Vector2(0, 16), text, HORIZONTAL_ALIGNMENT_CENTER, badge_rect.size.x, 14, color)
_draw_ink_text(font, badge_rect.position + Vector2(0, 16), text, HORIZONTAL_ALIGNMENT_CENTER, badge_rect.size.x, 14, color)
func _target_preview_badge_rect(cell: Vector2i, size: Vector2 = TARGET_PREVIEW_BADGE_SIZE) -> Rect2:
var cell_rect := _rect_for_cell(cell)
var position := cell_rect.position + Vector2((TILE_SIZE - size.x) * 0.5, 5.0)
var board := _board_rect()
var min_x := board.position.x + 2.0
var min_y := board.position.y + 2.0
var max_x := maxf(min_x, board.end.x - size.x - 2.0)
var max_y := maxf(min_y, board.end.y - size.y - 2.0)
position.x = clampf(position.x, min_x, max_x)
position.y = clampf(position.y, min_y, max_y)
return Rect2(position, size)
func _target_preview_badge() -> Dictionary:
@@ -3899,6 +3916,10 @@ func _rect_for_cell(cell: Vector2i) -> Rect2:
return Rect2(BOARD_OFFSET + Vector2(cell.x, cell.y) * TILE_SIZE, Vector2(TILE_SIZE, TILE_SIZE))
func _board_rect() -> Rect2:
return Rect2(BOARD_OFFSET, Vector2(state.map_size.x, state.map_size.y) * TILE_SIZE)
func _short_name(unit_name: String) -> String:
if unit_name.length() <= 9:
return unit_name