# Hurry Curry! - a game about cooking # Copyright 2024 tpart # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, version 3 of the License only. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # class_name SettingsCategory extends GameSetting var settings: Array # Dictionary[String, GameSetting] var presets # Array[Preset] var options: VBoxContainer func _init(new_id: String, new_settings: Array, new_presets = []): super(new_id) settings = new_settings 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()