summaryrefslogtreecommitdiff
path: root/client/menu/settings_row.gd
diff options
context:
space:
mode:
Diffstat (limited to 'client/menu/settings_row.gd')
-rw-r--r--client/menu/settings_row.gd36
1 files changed, 36 insertions, 0 deletions
diff --git a/client/menu/settings_row.gd b/client/menu/settings_row.gd
new file mode 100644
index 00000000..ee4b8cb9
--- /dev/null
+++ b/client/menu/settings_row.gd
@@ -0,0 +1,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