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
+75
View File
@@ -19,6 +19,7 @@
# 的窗口栈统一处理(关最顶层);H 键复用 `toggle()`。
extends Node
const MobileTouchButton = preload("res://ui/mobile/mobile_touch_button.gd")
# helpwindow.py 的 name → uiScriptLocale key(逐字,含原脚本里重名的两个 `help_02`)。
const FLOAT_ROWS := {
"help_01": "HELP_MOVE_KEY",
@@ -99,6 +100,9 @@ var uiscript_dir := ""
var _win: Dictionary = {}
var _loc # Localeres://locale.gd
var _mobile_mode := false
var _mobile_root: Control
var _mobile_labels: Array[Label] = []
func setup(ui_manager: CanvasLayer, m2client: Node = null, assets := "") -> void:
ui = ui_manager
@@ -117,18 +121,37 @@ func setup(ui_manager: CanvasLayer, m2client: Node = null, assets := "") -> void
# --- open / close ---------------------------------------------------
func is_open() -> bool:
if _mobile_mode:
return _mobile_root != null and is_instance_valid(_mobile_root)
return not _win.is_empty() and is_instance_valid(_win.get("root"))
func set_mobile_mode(enabled: bool) -> void:
if not enabled and _mobile_root != null:
var old_mode := _mobile_mode
_mobile_mode = true
close()
_mobile_mode = old_mode
_mobile_mode = enabled
func toggle() -> void:
if is_open(): close()
else: open()
func close() -> void:
if _mobile_mode:
if _mobile_root and is_instance_valid(_mobile_root) and ui:
ui.close(_mobile_root)
_mobile_root = null
_mobile_labels.clear()
return
if is_open():
ui.close(_win["root"])
_win = {}
func open() -> void:
if _mobile_mode:
_open_mobile()
return
if is_open():
return
var path := uiscript_dir.path_join("helpwindow.py")
@@ -141,6 +164,45 @@ func open() -> void:
_relabel()
_wire()
func _open_mobile() -> void:
if is_open():
return
_mobile_root = Control.new()
_mobile_root.name = "MobileHelpWindow"
_mobile_root.size = Vector2(760, 340)
_mobile_root.set_meta("mobile_title", "帮助")
_mobile_root.mouse_filter = Control.MOUSE_FILTER_STOP
var panel := Panel.new()
panel.set_anchors_preset(Control.PRESET_FULL_RECT)
panel.add_theme_stylebox_override("panel", _mobile_panel_style())
_mobile_root.add_child(panel)
var scroll := ScrollContainer.new()
scroll.position = Vector2(14, 48)
scroll.size = Vector2(732, 278)
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
scroll.mouse_filter = Control.MOUSE_FILTER_STOP
_mobile_root.add_child(scroll)
var list := VBoxContainer.new()
list.custom_minimum_size = Vector2(710, 0)
list.add_theme_constant_override("separation", 4)
scroll.add_child(list)
_mobile_labels.clear()
for key in FLOAT_ROWS.values():
var row := Label.new()
row.text = "" + _text(String(key))
row.custom_minimum_size = Vector2(700, 28)
row.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
row.add_theme_font_size_override("font_size", 13)
row.add_theme_color_override("font_color", Color(0.82, 0.9, 1.0))
list.add_child(row)
_mobile_labels.append(row)
var task_hint := Label.new()
task_hint.text = "\n" + _text("HELP_QUICKSLOT") + " · " + _text("HELP_SYSTEM_BUTTON")
task_hint.add_theme_font_size_override("font_size", 11)
task_hint.add_theme_color_override("font_color", Color(0.66, 0.76, 0.9))
list.add_child(task_hint)
ui.open(_mobile_root)
func _node(nm: String) -> Control:
if _win.is_empty():
return null
@@ -181,6 +243,11 @@ func _text(key: String) -> String:
# 已绑定的帮助行文本(供自检 / 调试)。
func rows() -> Array:
if _mobile_mode:
var mobile_rows: Array = []
for key in FLOAT_ROWS.values():
mobile_rows.append(_text(String(key)))
return mobile_rows
var out: Array = []
for nm in FLOAT_ROWS:
var n := _node(nm)
@@ -195,3 +262,11 @@ func _wire() -> void:
if btn is BaseButton:
btn.pressed.connect(close)
# helpwindow.py2 的多页按钮在单页版不存在;此处不绑。
func _mobile_panel_style() -> StyleBoxFlat:
var style := StyleBoxFlat.new()
style.bg_color = Color(0.04, 0.065, 0.1, 0.98)
style.border_color = Color(0.52, 0.68, 0.9, 0.86)
style.set_border_width_all(1)
style.set_corner_radius_all(8)
return style