blob: ee4b8cb98a2692b527ecf28b2bf0135692b4af6f (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 | class_name SettingsRow
extends PanelContainer
@onready var value_parent = $HBoxContainer/BoxContainer
@onready var label = $HBoxContainer/Label
var value_node
var description = tr("no value was given to the row")
func setup(description_: String, value):
	description = description_
	if value is bool:
		value_node = CheckButton.new()
		value_node.button_pressed = value
	elif value is String:
		value_node = LineEdit.new()
		value_node.text = value
func _ready():
	if value_node != null:
		var c: Control = value_node
		c.size_flags_vertical = Control.SIZE_EXPAND_FILL
		c.size_flags_horizontal = Control.SIZE_EXPAND_FILL
		label.text = description
		value_parent.add_child(c)
func get_value():
	if value_node != null:
		if value_node is CheckButton:
			return value_node.button_pressed
		elif value_node is LineEdit:
			return value_node.text
		else:
			return null
	else:
		return null
 |