feat(designer): 输入框撑满面板 + 共享元素词表常量

This commit is contained in:
2026-07-22 11:01:22 +08:00
parent 7b0843d8a9
commit 1f00720f44
+8 -1
View File
@@ -1,12 +1,17 @@
## 游戏设计器通用 UI 辅助(静态方法,各标签页复用) ## 游戏设计器通用 UI 辅助(静态方法 + 共享常量,各标签页复用)
@tool @tool
extends RefCounted extends RefCounted
## 元素词表(spell_tab 复选框 / resonance_tab 元素下拉共用);label 双语显示,tag 存储,index 对齐
const ELEM_LABELS := ["火 Fire", "冰 Ice", "雷 Lightning", "水 Water", "毒 Poison"]
const ELEM_TAGS := ["tag:fire", "tag:ice", "tag:lightning", "tag:water", "tag:poison"]
static func spin(min_v: float, max_v: float, step: float, val: float) -> SpinBox: static func spin(min_v: float, max_v: float, step: float, val: float) -> SpinBox:
var s := SpinBox.new() var s := SpinBox.new()
s.min_value = min_v; s.max_value = max_v; s.step = step s.min_value = min_v; s.max_value = max_v; s.step = step
s.value = val s.value = val
s.custom_minimum_size = Vector2(80, 0) s.custom_minimum_size = Vector2(80, 0)
s.size_flags_horizontal = Control.SIZE_EXPAND_FILL
return s return s
static func line(text: String, placeholder: String = "") -> LineEdit: static func line(text: String, placeholder: String = "") -> LineEdit:
@@ -14,6 +19,7 @@ static func line(text: String, placeholder: String = "") -> LineEdit:
le.text = text le.text = text
le.placeholder_text = placeholder le.placeholder_text = placeholder
le.custom_minimum_size = Vector2(120, 0) le.custom_minimum_size = Vector2(120, 0)
le.size_flags_horizontal = Control.SIZE_EXPAND_FILL
return le return le
static func opt(items: Array, selected: int) -> OptionButton: static func opt(items: Array, selected: int) -> OptionButton:
@@ -21,6 +27,7 @@ static func opt(items: Array, selected: int) -> OptionButton:
for it in items: for it in items:
o.add_item(str(it)) o.add_item(str(it))
o.selected = clampi(selected, 0, items.size() - 1) o.selected = clampi(selected, 0, items.size() - 1)
o.size_flags_horizontal = Control.SIZE_EXPAND_FILL
return o return o
static func header(text: String) -> Label: static func header(text: String) -> Label: