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
+46 -11
View File
@@ -13,6 +13,10 @@ var proto: Node
var _root: Control
var _text: RichTextLabel
var _cur := {}
var _mobile_mode := false
var _action_row: HBoxContainer
var _refine_button: Button
var _cancel_button: Button
func setup(m2client: Node, parent: Node, proto_node: Node = null) -> void:
client = m2client
@@ -26,6 +30,13 @@ func setup(m2client: Node, parent: Node, proto_node: Node = null) -> void:
func is_open() -> bool:
return _root != null and _root.visible
func get_mobile_window() -> Control:
return _root
func set_mobile_mode(enabled: bool) -> void:
_mobile_mode = enabled
_apply_mobile_layout()
func close() -> void:
if _root:
_root.visible = false
@@ -65,6 +76,28 @@ func _on_result(ok: bool) -> void:
_text.text = "[b]精炼成功[/b]" if ok else "[b]精炼失败[/b]"
_root.visible = true
func _apply_mobile_layout() -> void:
if _root == null or _text == null or _action_row == null:
return
if _mobile_mode:
_root.size = Vector2(460, 300)
_root.position = Vector2(-230, -150)
_text.position = Vector2(18, 52)
_text.size = Vector2(424, 178)
_text.custom_minimum_size = Vector2(424, 178)
_action_row.position = Vector2(18, 242)
_refine_button.custom_minimum_size = Vector2(204, 44)
_cancel_button.custom_minimum_size = Vector2(204, 44)
else:
_root.size = Vector2(320, 260)
_root.position = Vector2(-160, -130)
_text.position = Vector2(14, 34)
_text.size = Vector2(292, 160)
_text.custom_minimum_size = Vector2(292, 160)
_action_row.position = Vector2(14, 208)
_refine_button.custom_minimum_size = Vector2(120, 30)
_cancel_button.custom_minimum_size = Vector2(120, 30)
func _build(parent: Node) -> void:
_root = Control.new()
_root.set_anchors_preset(Control.PRESET_CENTER)
@@ -90,17 +123,19 @@ func _build(parent: Node) -> void:
_text.custom_minimum_size = Vector2(292, 160)
_text.size = Vector2(292, 160)
_root.add_child(_text)
var row := HBoxContainer.new()
_action_row = HBoxContainer.new()
var row := _action_row
row.position = Vector2(14, 208)
row.add_theme_constant_override("separation", 12)
_root.add_child(row)
var ok := Button.new()
ok.text = "精炼"
ok.custom_minimum_size = Vector2(120, 30)
ok.pressed.connect(_do_refine)
row.add_child(ok)
var cancel := Button.new()
cancel.text = "取消"
cancel.custom_minimum_size = Vector2(120, 30)
cancel.pressed.connect(func(): _root.visible = false)
row.add_child(cancel)
_refine_button = Button.new()
_refine_button.text = "精炼"
_refine_button.custom_minimum_size = Vector2(120, 30)
_refine_button.pressed.connect(_do_refine)
row.add_child(_refine_button)
_cancel_button = Button.new()
_cancel_button.text = "取消"
_cancel_button.custom_minimum_size = Vector2(120, 30)
_cancel_button.pressed.connect(func(): _root.visible = false)
row.add_child(_cancel_button)
_apply_mobile_layout()