diff --git a/game/addons/data_manager/_data/settings.res b/game/addons/data_manager/_data/settings.res deleted file mode 100644 index b3619664..00000000 Binary files a/game/addons/data_manager/_data/settings.res and /dev/null differ diff --git a/game/addons/data_manager/_data/settings.tres b/game/addons/data_manager/_data/settings.tres new file mode 100644 index 00000000..ae915a2d --- /dev/null +++ b/game/addons/data_manager/_data/settings.tres @@ -0,0 +1,7 @@ +[gd_resource type="Resource" load_steps=2 format=2] + +[ext_resource path="res://addons/data_manager/resources/data_manager_addon_settings.gd" type="Script" id=1] + +[resource] +script = ExtResource( 1 ) +folder_count = 0 diff --git a/game/addons/data_manager/resources/data_manager_addon_settings.gd b/game/addons/data_manager/resources/data_manager_addon_settings.gd index 2ec21290..fd25b531 100644 --- a/game/addons/data_manager/resources/data_manager_addon_settings.gd +++ b/game/addons/data_manager/resources/data_manager_addon_settings.gd @@ -1,4 +1,117 @@ tool extends Resource +class SettingEntry: + var folder : String = "" + var header : String = "" + var name : String = "" + var type : String = "" +var folders : Array = Array() + +func _get(property): + if property == "folder_count": + return folders.size() + + if property.begins_with("folders/"): + var sindex : String = property.get_slice("/", 1) + + if sindex == "": + return null + + var index : int = sindex.to_int() + + if index < 0 || index >= folders.size(): + return null + + var p : String = property.get_slice("/", 2) + + if p == "folder": + return folders[index].folder + elif p == "header": + return folders[index].header + elif p == "name": + return folders[index].name + elif p == "type": + return folders[index].type + else: + return null + + return null + +func _set(property, val): + if property == "folder_count": + set_folder_count(val) + return true + + if property.begins_with("folders/"): + var sindex : String = property.get_slice("/", 1) + + if sindex == "": + return null + + var index : int = sindex.to_int() + + if index < 0: + return false + + if index >= folders.size(): + return false + + var p : String = property.get_slice("/", 2) + + if p == "folder": + folders[index].folder = val + return true + elif p == "header": + folders[index].header = val + return true + elif p == "name": + folders[index].name = val + return true + elif p == "type": + folders[index].type = val + return true + + return false + +func _get_property_list() -> Array: + var props : Array = Array() + + props.append({ + "name": "folder_count", + "type": TYPE_INT, + }) + + for i in range(folders.size()): + props.append({ + "name": "folders/" + str(i) + "/folder", + "type": TYPE_STRING, + }) + props.append({ + "name": "folders/" + str(i) + "/header", + "type": TYPE_STRING, + }) + props.append({ + "name": "folders/" + str(i) + "/name", + "type": TYPE_STRING, + }) + props.append({ + "name": "folders/" + str(i) + "/type", + "type": TYPE_STRING, + }) + + return props + +func apply_folder_size(val : int) -> void: + folders.resize(val) + + for i in range(folders.size()): + if !folders[i]: + folders[i] = SettingEntry.new() + +func set_folder_count(val : int) -> void: + apply_folder_size(val) + + emit_changed() + property_list_changed_notify()