66 lines
2.3 KiB
Plaintext
66 lines
2.3 KiB
Plaintext
|
|
extends Node
|
||
|
|
|
||
|
|
@onready var syncedFeatures: ConfigFile = ConfigFile.new()
|
||
|
|
@onready var settingsmenu = $/root/Main/Settingsmenu/VBoxContainer/MarginContainer2/HBoxContainer/VBoxContainer
|
||
|
|
@onready var config : ConfigFile = ConfigFile.new()
|
||
|
|
|
||
|
|
func _ready() -> void:
|
||
|
|
var ms = MultiplayerSynchronizer.new()
|
||
|
|
var spg = SceneReplicationConfig.new()
|
||
|
|
var ppath = name + ":syncedFeatures"
|
||
|
|
spg.add_property(ppath)
|
||
|
|
ms.replication_config = spg
|
||
|
|
$/root.add_child.call_deferred(ms)
|
||
|
|
var err = config.load("user://config.cfg")
|
||
|
|
if err != OK:
|
||
|
|
config.load("res://defaultconfig.cfg")
|
||
|
|
if err == ERR_FILE_NOT_FOUND:
|
||
|
|
push_warning("New config file created")
|
||
|
|
config.save("user://config.cfg")
|
||
|
|
else:
|
||
|
|
push_error("Failed to load config: " + str(err) + "\n Loading default config.")
|
||
|
|
if Featuremanager.get_feature("debug","value", false) == true:
|
||
|
|
push_warning("Debugmode is set to true -> Loading default config")
|
||
|
|
config.load("res://defaultconfig.cfg")
|
||
|
|
update_menu()
|
||
|
|
for feature in config.get_sections():
|
||
|
|
if config.has_section_key(feature,"synced"):
|
||
|
|
for keys in config.get_section_keys(feature):
|
||
|
|
pass
|
||
|
|
#syncedFeatures.set(feature,config.get_value(feature,key))
|
||
|
|
# @param featurename: Test
|
||
|
|
func get_feature(featurename: String, key: String, default = false):
|
||
|
|
if !config.has_section_key(featurename,key):
|
||
|
|
return default
|
||
|
|
return config.get_value(featurename, key)
|
||
|
|
func set_feature_key(featurename: String, key: String, value):
|
||
|
|
config.set_value(featurename, key,value)
|
||
|
|
func remove_feature(featurename: String):
|
||
|
|
config.erase_section(featurename)
|
||
|
|
func remove_feature_key(featurename: String, key: String):
|
||
|
|
config.erase_section_key(featurename, key)
|
||
|
|
func update_menu():
|
||
|
|
for feature in config.get_sections():
|
||
|
|
var container = HBoxContainer.new()
|
||
|
|
container.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||
|
|
container.name = feature
|
||
|
|
var label = Label.new()
|
||
|
|
label.text = feature
|
||
|
|
container.add_child(label)
|
||
|
|
var control : Control
|
||
|
|
match config.get_value(feature,"mode","_"):
|
||
|
|
"check":
|
||
|
|
control = CheckButton.new()
|
||
|
|
"color:":
|
||
|
|
control = ColorPickerButton.new()
|
||
|
|
"text":
|
||
|
|
control = LineEdit.new()
|
||
|
|
"menu":
|
||
|
|
control = OptionButton.new()
|
||
|
|
"button":
|
||
|
|
control = Button.new()
|
||
|
|
_:
|
||
|
|
control = Button.new()
|
||
|
|
container.add_child(control)
|
||
|
|
settingsmenu.add_child(container)
|