aboutsummaryrefslogtreecommitdiff
path: root/client/menu/settings/settings_category.gd
diff options
context:
space:
mode:
Diffstat (limited to 'client/menu/settings/settings_category.gd')
-rw-r--r--client/menu/settings/settings_category.gd51
1 files changed, 42 insertions, 9 deletions
diff --git a/client/menu/settings/settings_category.gd b/client/menu/settings/settings_category.gd
index c4601429..7425ea19 100644
--- a/client/menu/settings/settings_category.gd
+++ b/client/menu/settings/settings_category.gd
@@ -14,15 +14,48 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
class_name SettingsCategory
-extends Object
+extends GameSetting
-var name: String
-var id: String
-var settings: Dictionary # Dictionary[String, GameSetting]
-var presets # Array[Preset] | null
+var settings: Array # Dictionary[String, GameSetting]
+var presets # Array[Preset]
-func _init(new_name: String, new_id: String, new_settings: Dictionary, new_presets = null):
- name = new_name
- id = new_id
+var options: VBoxContainer
+
+func _init(new_id: String, new_settings: Array, new_presets = []):
+ super(new_id)
settings = new_settings
- presets = new_presets
+ presets = new_presets
+
+func set_parent(parent: GameSetting):
+ super(parent)
+ for c in settings:
+ c.set_parent(self)
+
+func _update_row():
+ if row == null: row = ScrollContainerCustom.new()
+ if options == null: options = VBoxContainer.new()
+ row.name = tr(nskey)
+ row.size_flags_horizontal = Control.SIZE_EXPAND_FILL
+ options.size_flags_horizontal = Control.SIZE_EXPAND_FILL
+
+ if options.get_parent() != row:
+ row.add_child(options)
+
+ if presets != null:
+ for i in presets:
+ var prow: SettingsRow = preload("res://menu/settings/settings_row.tscn").instantiate()
+ options.add_child(prow)
+ prow.label.text = i.label
+ prow.reset_button.visible = false
+ for b in i.buttons():
+ prow.value_parent.add_child(b)
+
+ for r in settings:
+ r._update_row()
+ if r.row.get_parent() != options:
+ print(r.row)
+ options.add_child(r.row)
+
+func check():
+ for c in settings:
+ c.check()