Refine large map edge navigation

This commit is contained in:
2026-06-19 19:22:48 +09:00
parent 9a9c677863
commit 3427116513
3 changed files with 111 additions and 18 deletions

View File

@@ -2839,25 +2839,64 @@ func _draw_edge_scroll_cues(view_rect: Rect2) -> void:
if not _is_minimap_visible():
return
var min_offset := _clamped_board_scroll_offset(Vector2(-9999.0, -9999.0))
var cue_color := Color(UI_OLD_BRONZE.r, UI_OLD_BRONZE.g, UI_OLD_BRONZE.b, 0.18)
var hot_color := Color(UI_OLD_BRONZE.r, UI_OLD_BRONZE.g, UI_OLD_BRONZE.b, 0.36)
var strip := 14.0
var mouse_position := view_rect.get_center()
if is_inside_tree():
mouse_position = get_viewport().get_mouse_position()
var active_sides := _edge_scroll_active_sides(mouse_position, view_rect)
if board_scroll_offset.x < -0.5:
draw_rect(Rect2(view_rect.position, Vector2(strip, view_rect.size.y)), cue_color)
draw_line(view_rect.position + Vector2(5.0, view_rect.size.y * 0.5), view_rect.position + Vector2(11.0, view_rect.size.y * 0.5 - 8.0), hot_color, 2.0)
draw_line(view_rect.position + Vector2(5.0, view_rect.size.y * 0.5), view_rect.position + Vector2(11.0, view_rect.size.y * 0.5 + 8.0), hot_color, 2.0)
var active_left := bool(active_sides.get("left", false))
var strip_left := _edge_scroll_cue_strip_width(active_left)
var cue_color_left := _edge_scroll_cue_fill_color(active_left)
var line_color_left := _edge_scroll_cue_line_color(active_left)
draw_rect(Rect2(view_rect.position, Vector2(strip_left, view_rect.size.y)), cue_color_left)
draw_line(view_rect.position + Vector2(5.0, view_rect.size.y * 0.5), view_rect.position + Vector2(11.0, view_rect.size.y * 0.5 - 8.0), line_color_left, 2.0)
draw_line(view_rect.position + Vector2(5.0, view_rect.size.y * 0.5), view_rect.position + Vector2(11.0, view_rect.size.y * 0.5 + 8.0), line_color_left, 2.0)
if board_scroll_offset.x > min_offset.x + 0.5:
draw_rect(Rect2(Vector2(view_rect.end.x - strip, view_rect.position.y), Vector2(strip, view_rect.size.y)), cue_color)
draw_line(Vector2(view_rect.end.x - 5.0, view_rect.position.y + view_rect.size.y * 0.5), Vector2(view_rect.end.x - 11.0, view_rect.position.y + view_rect.size.y * 0.5 - 8.0), hot_color, 2.0)
draw_line(Vector2(view_rect.end.x - 5.0, view_rect.position.y + view_rect.size.y * 0.5), Vector2(view_rect.end.x - 11.0, view_rect.position.y + view_rect.size.y * 0.5 + 8.0), hot_color, 2.0)
var active_right := bool(active_sides.get("right", false))
var strip_right := _edge_scroll_cue_strip_width(active_right)
var cue_color_right := _edge_scroll_cue_fill_color(active_right)
var line_color_right := _edge_scroll_cue_line_color(active_right)
draw_rect(Rect2(Vector2(view_rect.end.x - strip_right, view_rect.position.y), Vector2(strip_right, view_rect.size.y)), cue_color_right)
draw_line(Vector2(view_rect.end.x - 5.0, view_rect.position.y + view_rect.size.y * 0.5), Vector2(view_rect.end.x - 11.0, view_rect.position.y + view_rect.size.y * 0.5 - 8.0), line_color_right, 2.0)
draw_line(Vector2(view_rect.end.x - 5.0, view_rect.position.y + view_rect.size.y * 0.5), Vector2(view_rect.end.x - 11.0, view_rect.position.y + view_rect.size.y * 0.5 + 8.0), line_color_right, 2.0)
if board_scroll_offset.y < -0.5:
draw_rect(Rect2(view_rect.position, Vector2(view_rect.size.x, strip)), cue_color)
draw_line(view_rect.position + Vector2(view_rect.size.x * 0.5, 5.0), view_rect.position + Vector2(view_rect.size.x * 0.5 - 8.0, 11.0), hot_color, 2.0)
draw_line(view_rect.position + Vector2(view_rect.size.x * 0.5, 5.0), view_rect.position + Vector2(view_rect.size.x * 0.5 + 8.0, 11.0), hot_color, 2.0)
var active_up := bool(active_sides.get("up", false))
var strip_up := _edge_scroll_cue_strip_width(active_up)
var cue_color_up := _edge_scroll_cue_fill_color(active_up)
var line_color_up := _edge_scroll_cue_line_color(active_up)
draw_rect(Rect2(view_rect.position, Vector2(view_rect.size.x, strip_up)), cue_color_up)
draw_line(view_rect.position + Vector2(view_rect.size.x * 0.5, 5.0), view_rect.position + Vector2(view_rect.size.x * 0.5 - 8.0, 11.0), line_color_up, 2.0)
draw_line(view_rect.position + Vector2(view_rect.size.x * 0.5, 5.0), view_rect.position + Vector2(view_rect.size.x * 0.5 + 8.0, 11.0), line_color_up, 2.0)
if board_scroll_offset.y > min_offset.y + 0.5:
draw_rect(Rect2(Vector2(view_rect.position.x, view_rect.end.y - strip), Vector2(view_rect.size.x, strip)), cue_color)
draw_line(Vector2(view_rect.position.x + view_rect.size.x * 0.5, view_rect.end.y - 5.0), Vector2(view_rect.position.x + view_rect.size.x * 0.5 - 8.0, view_rect.end.y - 11.0), hot_color, 2.0)
draw_line(Vector2(view_rect.position.x + view_rect.size.x * 0.5, view_rect.end.y - 5.0), Vector2(view_rect.position.x + view_rect.size.x * 0.5 + 8.0, view_rect.end.y - 11.0), hot_color, 2.0)
var active_down := bool(active_sides.get("down", false))
var strip_down := _edge_scroll_cue_strip_width(active_down)
var cue_color_down := _edge_scroll_cue_fill_color(active_down)
var line_color_down := _edge_scroll_cue_line_color(active_down)
draw_rect(Rect2(Vector2(view_rect.position.x, view_rect.end.y - strip_down), Vector2(view_rect.size.x, strip_down)), cue_color_down)
draw_line(Vector2(view_rect.position.x + view_rect.size.x * 0.5, view_rect.end.y - 5.0), Vector2(view_rect.position.x + view_rect.size.x * 0.5 - 8.0, view_rect.end.y - 11.0), line_color_down, 2.0)
draw_line(Vector2(view_rect.position.x + view_rect.size.x * 0.5, view_rect.end.y - 5.0), Vector2(view_rect.position.x + view_rect.size.x * 0.5 + 8.0, view_rect.end.y - 11.0), line_color_down, 2.0)
func _edge_scroll_active_sides(mouse_position: Vector2, view_rect: Rect2) -> Dictionary:
var velocity := _edge_scroll_velocity_for_position(mouse_position, view_rect)
return {
"left": velocity.x > 0.0,
"right": velocity.x < 0.0,
"up": velocity.y > 0.0,
"down": velocity.y < 0.0
}
func _edge_scroll_cue_strip_width(active: bool) -> float:
return 20.0 if active else 14.0
func _edge_scroll_cue_fill_color(active: bool) -> Color:
return Color(UI_OLD_BRONZE.r, UI_OLD_BRONZE.g, UI_OLD_BRONZE.b, 0.34 if active else 0.18)
func _edge_scroll_cue_line_color(active: bool) -> Color:
return Color(UI_OLD_BRONZE.r, UI_OLD_BRONZE.g, UI_OLD_BRONZE.b, 0.62 if active else 0.36)
func _draw_minimap() -> void: