Add minimap hover details
This commit is contained in:
@@ -659,6 +659,7 @@ func _draw() -> void:
|
||||
_draw_floating_texts()
|
||||
_draw_map_view_chrome()
|
||||
_draw_minimap()
|
||||
_draw_minimap_hover_badge()
|
||||
|
||||
|
||||
func _make_panel_style(fill: Color, border: Color, border_width: int, radius: int, margin: int, shadow_size: int) -> StyleBoxFlat:
|
||||
@@ -4539,6 +4540,41 @@ func _draw_minimap() -> void:
|
||||
draw_rect(map_rect, Color(UI_BRUSH_RULE.r, UI_BRUSH_RULE.g, UI_BRUSH_RULE.b, 0.90), false, 1.5)
|
||||
|
||||
|
||||
func _draw_minimap_hover_badge() -> void:
|
||||
if not _is_minimap_visible():
|
||||
return
|
||||
var viewport := get_viewport()
|
||||
if viewport == null:
|
||||
return
|
||||
var badge := _minimap_hover_badge(viewport.get_mouse_position())
|
||||
if badge.is_empty():
|
||||
return
|
||||
var lines: Array[String] = badge.get("lines", [])
|
||||
if lines.is_empty():
|
||||
return
|
||||
var badge_rect: Rect2 = badge.get("rect", Rect2())
|
||||
if badge_rect.size.x <= 0.0 or badge_rect.size.y <= 0.0:
|
||||
return
|
||||
var color := _hover_info_badge_color(str(badge.get("kind", "terrain")))
|
||||
var background := Color(0.035, 0.022, 0.014, 0.93)
|
||||
var font := _draw_ui_font(true)
|
||||
|
||||
draw_rect(badge_rect, background)
|
||||
draw_rect(badge_rect.grow(-2.0), Color(color.r, color.g, color.b, 0.12))
|
||||
draw_rect(badge_rect, color, false, 2.0)
|
||||
for index in range(lines.size()):
|
||||
var line_color := color if index == 0 else UI_PARCHMENT_TEXT
|
||||
_draw_ink_text(
|
||||
font,
|
||||
badge_rect.position + Vector2(8.0, 16.0 + float(index) * 15.0),
|
||||
lines[index],
|
||||
HORIZONTAL_ALIGNMENT_LEFT,
|
||||
badge_rect.size.x - 16.0,
|
||||
12,
|
||||
line_color
|
||||
)
|
||||
|
||||
|
||||
func _draw_minimap_objective_markers() -> void:
|
||||
for cell in state.get_objective_cells():
|
||||
if not state.is_inside(cell):
|
||||
@@ -7090,6 +7126,81 @@ func _minimap_view_rect() -> Rect2:
|
||||
)
|
||||
|
||||
|
||||
func _minimap_cell_for_screen_position(screen_position: Vector2) -> Vector2i:
|
||||
if not _is_minimap_visible() or state.map_size.x <= 0 or state.map_size.y <= 0:
|
||||
return Vector2i(-1, -1)
|
||||
var map_rect := _minimap_map_rect()
|
||||
if not map_rect.has_point(screen_position):
|
||||
return Vector2i(-1, -1)
|
||||
var local := screen_position - map_rect.position
|
||||
var x := clampi(int(floor((local.x / map_rect.size.x) * float(state.map_size.x))), 0, state.map_size.x - 1)
|
||||
var y := clampi(int(floor((local.y / map_rect.size.y) * float(state.map_size.y))), 0, state.map_size.y - 1)
|
||||
return Vector2i(x, y)
|
||||
|
||||
|
||||
func _minimap_hover_badge(screen_position: Vector2) -> Dictionary:
|
||||
var cell := _minimap_cell_for_screen_position(screen_position)
|
||||
if not state.is_inside(cell):
|
||||
return {}
|
||||
var lines := _minimap_hover_badge_lines(cell)
|
||||
if lines.is_empty():
|
||||
return {}
|
||||
return {
|
||||
"cell": cell,
|
||||
"kind": _hover_info_badge_kind(cell),
|
||||
"lines": lines,
|
||||
"rect": _minimap_hover_badge_rect(screen_position, lines)
|
||||
}
|
||||
|
||||
|
||||
func _minimap_hover_badge_lines(cell: Vector2i) -> Array[String]:
|
||||
if not state.is_inside(cell):
|
||||
return []
|
||||
var summary := state.get_cell_summary(cell)
|
||||
var terrain_name := _terrain_display_name(str(summary.get("terrain", "")))
|
||||
var lines: Array[String] = []
|
||||
var unit: Dictionary = summary.get("unit", {})
|
||||
if not unit.is_empty():
|
||||
lines.append("%s · %s" % [_short_name(str(unit.get("name", "부대"))), _unit_team_text(str(unit.get("team", "")))])
|
||||
lines.append("%s · %s" % [_unit_class_display_name(unit), terrain_name])
|
||||
else:
|
||||
lines.append("전장도 %s · %s" % [_format_cell_label(cell), terrain_name])
|
||||
var markers: Array[String] = []
|
||||
var objective_label := state.get_objective_cell_label(cell)
|
||||
if not objective_label.is_empty():
|
||||
markers.append("목표 %s" % objective_label)
|
||||
var event_label := state.get_event_marker_label(cell)
|
||||
if not event_label.is_empty():
|
||||
markers.append("표식 %s" % event_label)
|
||||
if show_threat_overlay:
|
||||
var threat_names := state.get_threatening_unit_names(cell, BattleState.TEAM_ENEMY)
|
||||
if not threat_names.is_empty():
|
||||
markers.append("감시 %s" % _compact_name_list(threat_names, 2))
|
||||
if not markers.is_empty():
|
||||
lines.append(_join_strings(markers, " · "))
|
||||
lines.append("클릭/드래그로 전장 이동")
|
||||
var capped_lines: Array[String] = []
|
||||
for index in range(mini(lines.size(), 4)):
|
||||
capped_lines.append(lines[index])
|
||||
return capped_lines
|
||||
|
||||
|
||||
func _minimap_hover_badge_rect(screen_position: Vector2, lines: Array[String]) -> Rect2:
|
||||
var size := _hover_info_badge_size(lines)
|
||||
var position := screen_position + Vector2(12.0, 12.0)
|
||||
var view_rect := _map_view_rect()
|
||||
var minimap_rect := _minimap_rect()
|
||||
var min_x := view_rect.position.x + 2.0
|
||||
var min_y := view_rect.position.y + 2.0
|
||||
var max_x := maxf(min_x, view_rect.end.x - size.x - 2.0)
|
||||
var max_y := maxf(min_y, minimap_rect.position.y - size.y - 8.0)
|
||||
if max_y < min_y:
|
||||
max_y = maxf(min_y, view_rect.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 _board_scroll_offset_for_minimap_position(screen_position: Vector2) -> Vector2:
|
||||
var map_rect := _minimap_map_rect()
|
||||
var board_size := _board_size()
|
||||
@@ -7312,7 +7423,10 @@ func _handle_minimap_mouse_motion(event: InputEventMouseMotion) -> bool:
|
||||
if minimap_dragging:
|
||||
_scroll_board_to_minimap_position(event.position)
|
||||
return true
|
||||
return _minimap_rect().has_point(event.position)
|
||||
if _minimap_rect().has_point(event.position):
|
||||
queue_redraw()
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _edge_scroll_velocity_for_position(mouse_position: Vector2, view_rect: Rect2) -> Vector2:
|
||||
|
||||
Reference in New Issue
Block a user