feat: complete mobile UI implementation

This commit is contained in:
shenlei
2026-09-04 19:54:33 +09:00
parent 9a4a044da5
commit b19d5b5dd3
132 changed files with 6643 additions and 180 deletions
+33
View File
@@ -9,6 +9,8 @@
# 世界→图:Δ = blip.xz - player.xz,按 scale 转像素,(+x 右, -z 上),超出半径夹到边缘。
extends Node
signal map_pressed
const RADIUS := 70.0
const SCALE := 0.25 # 像素/米(越大越放大)
# CPythonMiniMap 的 waypoint 夹边留边:c_fMiniMapWindowRadius = min(w,h)/2 - 9.0f
@@ -77,6 +79,29 @@ func set_scale(pixels_per_meter: float) -> void:
func get_scale() -> float:
return _scale
# Reparent the same live minimap view into the mobile top-right HUD. The
# drawing/data path stays shared; only the presentation container changes.
func mount_mobile(host: Control) -> void:
if host == null or _root == null:
return
var old_parent := _root.get_parent()
if old_parent:
old_parent.remove_child(_root)
host.add_child(_root)
_root.set_anchors_preset(Control.PRESET_TOP_LEFT)
_root.position = Vector2(0, 0)
_root.size = Vector2(140, 156)
_root.scale = Vector2(0.64, 0.64)
_root.mouse_filter = Control.MOUSE_FILTER_STOP
func restore_desktop_layout() -> void:
if _root == null:
return
_root.scale = Vector2.ONE
_root.set_anchors_preset(Control.PRESET_TOP_RIGHT)
_root.position = Vector2(-2 * RADIUS - 16, 12)
_root.size = Vector2(2 * RADIUS, 2 * RADIUS + 16)
# CPythonMiniMap::AddSignalPoint stores quest-script waypoints separately from
# server target markers. EventManager supplies absolute server centimetres.
func add_signal_point(x: float, y: float) -> void:
@@ -177,7 +202,15 @@ func _observer_position(vid: int, fallback: Vector3 = Vector3.ZERO) -> Vector3:
return cur
func _on_gui_input(event: InputEvent) -> void:
if event is InputEventScreenTouch and event.pressed:
map_pressed.emit()
_root.accept_event()
return
if event is InputEventMouseButton and event.pressed:
if event.button_index == MOUSE_BUTTON_LEFT:
map_pressed.emit()
_root.accept_event()
return
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
set_scale(_scale * 1.15)
_root.accept_event()