diff options
Diffstat (limited to 'client/menu')
-rw-r--r-- | client/menu/character_menu.gd | 14 | ||||
-rw-r--r-- | client/menu/main_menu.gd | 4 | ||||
-rw-r--r-- | client/menu/settings_menu.gd | 15 | ||||
-rw-r--r-- | client/menu/settings_row.gd | 36 | ||||
-rw-r--r-- | client/menu/settings_row.tscn | 24 |
5 files changed, 84 insertions, 9 deletions
diff --git a/client/menu/character_menu.gd b/client/menu/character_menu.gd index f4b878be..fd4e3707 100644 --- a/client/menu/character_menu.gd +++ b/client/menu/character_menu.gd @@ -19,21 +19,21 @@ extends Control @onready var num_hairstyles := character.hairstyles.keys().size() func _ready(): - $VBoxContainer/top_panel/a/username.text = Global.settings["username"] - character.select_hairstyle(Global.settings["character"]) + $VBoxContainer/top_panel/a/username.text = Global.profile["username"] + character.select_hairstyle(Global.profile["character"]) func _on_back_pressed(): $SceneTransition.transition_to("res://menu/main_menu.tscn") func _on_username_text_changed(new_text): - Global.settings["username"] = new_text + Global.profile["username"] = new_text func _on_character_back_pressed(): - Global.settings["character"] = (Global.settings["character"] - 1) % num_hairstyles - character.select_hairstyle(Global.settings["character"]) + Global.profile["character"] = (Global.profile["character"] - 1) % num_hairstyles + character.select_hairstyle(Global.profile["character"]) Global.save_profile() func _on_character_forward_pressed(): - Global.settings["character"] = (Global.settings["character"] + 1) % num_hairstyles - character.select_hairstyle(Global.settings["character"]) + Global.profile["character"] = (Global.profile["character"] + 1) % num_hairstyles + character.select_hairstyle(Global.profile["character"]) Global.save_profile() diff --git a/client/menu/main_menu.gd b/client/menu/main_menu.gd index 31ca5462..bd4cdcb0 100644 --- a/client/menu/main_menu.gd +++ b/client/menu/main_menu.gd @@ -25,7 +25,7 @@ func _ready(): quick_connect.grab_focus() if OS.has_feature("web"): quit_button.hide() - connect_uri.text = Global.settings["last_server_url"] + connect_uri.text = Global.profile["last_server_url"] func _on_quit_pressed(): transition.quit() @@ -35,7 +35,7 @@ func _on_credits_pressed(): func _on_connect_pressed(): var url = $side/margin/options/connect/uri.text - Global.settings["last_server_url"] = url + Global.profile["last_server_url"] = url Global.save_profile() connect_to(url) diff --git a/client/menu/settings_menu.gd b/client/menu/settings_menu.gd index a023cf36..f7abd9e6 100644 --- a/client/menu/settings_menu.gd +++ b/client/menu/settings_menu.gd @@ -15,5 +15,20 @@ # extends Control +@onready var options: VBoxContainer = $outer_gap/panel/inner_gap/options + +var settings: Dictionary + func _on_back_pressed(): + for k in settings.keys(): + Global.settings[k]["value"] = settings[k].get_value() + Global.save_settings() $SceneTransition.transition_to("res://menu/main_menu.tscn") + +func _ready(): + for k in Global.settings.keys(): + var v = Global.settings[k] + var row: SettingsRow = preload("res://menu/settings_row.tscn").instantiate() + row.setup(v["description"], v["value"]) + options.add_child(row) + settings[k] = row 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 diff --git a/client/menu/settings_row.tscn b/client/menu/settings_row.tscn new file mode 100644 index 00000000..b083d291 --- /dev/null +++ b/client/menu/settings_row.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=2 format=3 uid="uid://o5e5vpem8w0k"] + +[ext_resource type="Script" path="res://menu/settings_row.gd" id="1_lxjnc"] + +[node name="SettingsRow" type="PanelContainer"] +offset_right = 105.0 +offset_bottom = 23.0 +size_flags_horizontal = 3 +script = ExtResource("1_lxjnc") + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 2 + +[node name="Label" type="Label" parent="HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="BoxContainer" type="BoxContainer" parent="HBoxContainer"] +custom_minimum_size = Vector2(300, 50) +layout_mode = 2 +alignment = 2 + +[node name="Button" type="Button" parent="HBoxContainer"] +layout_mode = 2 |