diff options
| author | nokoe <nokoe@mailbox.org> | 2024-06-26 16:34:55 +0200 |
|---|---|---|
| committer | nokoe <nokoe@mailbox.org> | 2024-06-26 16:34:55 +0200 |
| commit | 5654b69e4c7e0aafe258ad0ab73105722a389def (patch) | |
| tree | 7e51e306380cd08219a96d4e21db32869e9b9eab /client/menu/settings_row.gd | |
| parent | 974d5151b28faf94dfa73e33a484eecaa2f69e40 (diff) | |
| download | hurrycurry-5654b69e4c7e0aafe258ad0ab73105722a389def.tar hurrycurry-5654b69e4c7e0aafe258ad0ab73105722a389def.tar.bz2 hurrycurry-5654b69e4c7e0aafe258ad0ab73105722a389def.tar.zst | |
add settings row
Diffstat (limited to 'client/menu/settings_row.gd')
| -rw-r--r-- | client/menu/settings_row.gd | 36 |
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 |