diff --git a/addons/resources_speadsheet_view/editor_view.gd b/addons/resources_speadsheet_view/editor_view.gd index 4cd649a..a7b3d66 100644 --- a/addons/resources_speadsheet_view/editor_view.gd +++ b/addons/resources_speadsheet_view/editor_view.gd @@ -377,8 +377,7 @@ func _on_Path_text_entered(new_text : String = ""): func _on_RecentPaths_item_selected(index : int): current_path = recent_paths[index] get_node(path_folder_path).text = recent_paths[index] - display_folder(current_path) - refresh() + display_folder(current_path, sorting_by, sorting_reverse, true) func _on_FileDialog_dir_selected(path : String): diff --git a/addons/resources_speadsheet_view/editor_view.tscn b/addons/resources_speadsheet_view/editor_view.tscn index c316012..17a5065 100644 --- a/addons/resources_speadsheet_view/editor_view.tscn +++ b/addons/resources_speadsheet_view/editor_view.tscn @@ -555,7 +555,6 @@ mode = 0 filters = PoolStringArray( "*.csv" ) [node name="ImportExport" parent="Control" instance=ExtResource( 18 )] -visible = false anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 diff --git a/addons/resources_speadsheet_view/import_export/import_export_dialog.gd b/addons/resources_speadsheet_view/import_export/import_export_dialog.gd index 6b8355e..2005566 100644 --- a/addons/resources_speadsheet_view/import_export/import_export_dialog.gd +++ b/addons/resources_speadsheet_view/import_export/import_export_dialog.gd @@ -55,9 +55,8 @@ func _on_FileDialogText_file_selected(path : String): func _open_dialog(path : String): - node_classname_field.text = TextEditingUtils\ - .string_snake_to_naming_case(import_data.edited_path.get_file().get_basename())\ - .replace(" ", "") + node_classname_field.text = import_data.edited_path.get_file().get_basename()\ + .capitalize().replace(" ", "") import_data.script_classname = node_classname_field.text for x in formats_import: @@ -66,6 +65,7 @@ func _open_dialog(path : String): _load_property_names() _create_prop_editors() + $"TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/StyleSettingsI"._send_signal() func _load_property_names(): @@ -74,6 +74,7 @@ func _load_property_names(): import_data.prop_types.fill(4) for i in import_data.prop_names.size(): import_data.prop_names[i] = entries[0][i]\ + .replace("\"", "")\ .replace(" ", "_")\ .replace("-", "_")\ .replace(".", "_")\ @@ -109,6 +110,7 @@ func _create_prop_editors(): func _generate_class(save_script = true): + save_script = true # Built-ins work no more. Why? No idea. But they worked for a bit. import_data.new_script = import_data.generate_script(entries, save_script) if save_script: ResourceSaver.save(import_data.edited_path.get_basename() + ".gd", import_data.new_script) @@ -206,3 +208,7 @@ func _on_export_space_toggled(button_pressed : bool): func _reset_controls(): $"TabContainer/Export/HBoxContainer2/CheckBox".pressed = false _on_remove_first_row_toggled(true) + + +func _on_enum_format_changed(case, delimiter, bool_yes, bool_no): + import_data.enum_format = [case, delimiter, bool_yes, bool_no] diff --git a/addons/resources_speadsheet_view/import_export/import_export_dialog.tscn b/addons/resources_speadsheet_view/import_export/import_export_dialog.tscn index 4e8885c..646464b 100644 --- a/addons/resources_speadsheet_view/import_export/import_export_dialog.tscn +++ b/addons/resources_speadsheet_view/import_export/import_export_dialog.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://addons/resources_speadsheet_view/import_export/import_export_dialog.gd" type="Script" id=1] [ext_resource path="res://addons/resources_speadsheet_view/import_export/property_list_item.tscn" type="PackedScene" id=2] [ext_resource path="res://addons/resources_speadsheet_view/import_export/formats_import/import_csv.gd" type="Script" id=3] +[ext_resource path="res://addons/resources_speadsheet_view/import_export/import_export_enum_format.tscn" type="PackedScene" id=4] [sub_resource type="ButtonGroup" id=1] @@ -31,10 +32,11 @@ margin_left = 4.0 margin_top = 32.0 margin_right = -4.0 margin_bottom = -4.0 +mouse_filter = 2 [node name="MarginContainer" type="MarginContainer" parent="TabContainer/Import"] margin_right = 485.0 -margin_bottom = 306.0 +margin_bottom = 298.0 size_flags_vertical = 3 custom_constants/margin_right = 4 custom_constants/margin_top = 4 @@ -45,7 +47,7 @@ custom_constants/margin_bottom = 0 margin_left = 4.0 margin_top = 4.0 margin_right = 481.0 -margin_bottom = 306.0 +margin_bottom = 298.0 scroll_horizontal_enabled = false [node name="VBoxContainer" type="VBoxContainer" parent="TabContainer/Import/MarginContainer/ScrollContainer"] @@ -55,7 +57,7 @@ size_flags_horizontal = 3 [node name="GridContainer" type="GridContainer" parent="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer"] margin_right = 477.0 -margin_bottom = 132.0 +margin_bottom = 80.0 columns = 2 [node name="Label" type="Label" parent="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/GridContainer"] @@ -95,72 +97,22 @@ margin_top = 52.0 margin_right = 477.0 margin_bottom = 76.0 -[node name="Label4" type="Label" parent="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/GridContainer"] -margin_top = 83.0 -margin_right = 246.0 -margin_bottom = 97.0 -text = "Boolean True/False" - -[node name="HBoxContainer" type="HBoxContainer" parent="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/GridContainer"] -margin_left = 250.0 -margin_top = 80.0 -margin_right = 477.0 -margin_bottom = 100.0 - -[node name="Case" type="OptionButton" parent="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/GridContainer/HBoxContainer"] -margin_right = 148.0 -margin_bottom = 20.0 -size_flags_horizontal = 3 -text = "Caps Every Word" -clip_text = true -items = [ "all lower", null, false, 0, null, "caps Except First", null, false, 1, null, "Caps Every Word", null, false, 2, null, "ALL CAPS", null, false, 3, null ] -selected = 2 - -[node name="Separator" type="OptionButton" parent="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/GridContainer/HBoxContainer"] -margin_left = 152.0 -margin_right = 227.0 -margin_bottom = 20.0 -size_flags_horizontal = 3 -size_flags_stretch_ratio = 0.5 -text = "Space \" \"" -clip_text = true -items = [ "Space \" \"", null, false, 0, null, "Underscore \"_\"", null, false, 1, null, "Kebab \"-\"", null, false, 2, null ] -selected = 0 - -[node name="Label3" type="Label" parent="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/GridContainer"] -margin_top = 109.0 -margin_right = 246.0 -margin_bottom = 123.0 -text = "Enum word case/separator" - -[node name="HBoxContainer2" type="HBoxContainer" parent="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/GridContainer"] -margin_left = 250.0 -margin_top = 104.0 -margin_right = 477.0 -margin_bottom = 128.0 - -[node name="True" type="LineEdit" parent="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/GridContainer/HBoxContainer2"] -margin_right = 111.0 -margin_bottom = 24.0 -size_flags_horizontal = 3 -text = "Yes" - -[node name="False" type="LineEdit" parent="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/GridContainer/HBoxContainer2"] -margin_left = 115.0 -margin_right = 227.0 -margin_bottom = 24.0 -size_flags_horizontal = 3 -text = "No" - [node name="Control2" type="Control" parent="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/GridContainer"] -margin_top = 132.0 +margin_top = 80.0 margin_right = 246.0 +margin_bottom = 80.0 + +[node name="StyleSettingsI" parent="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer" instance=ExtResource( 4 )] +pause_mode = 2 +margin_top = 84.0 +margin_right = 477.0 margin_bottom = 132.0 [node name="HBoxContainer" type="HBoxContainer" parent="TabContainer/Import"] -margin_top = 310.0 +margin_top = 302.0 margin_right = 485.0 -margin_bottom = 330.0 +margin_bottom = 322.0 +mouse_filter = 2 alignment = 1 [node name="Ok2" type="Button" parent="TabContainer/Import/HBoxContainer"] @@ -181,6 +133,13 @@ margin_right = 434.0 margin_bottom = 20.0 text = "Cancel" +[node name="Control" type="Control" parent="TabContainer/Import"] +margin_top = 326.0 +margin_right = 485.0 +margin_bottom = 330.0 +rect_min_size = Vector2( 0, 4 ) +mouse_filter = 2 + [node name="Export" type="VBoxContainer" parent="TabContainer"] visible = false anchor_right = 1.0 @@ -261,84 +220,21 @@ margin_bottom = 24.0 pressed = true text = "First row contains property names (CSV)" -[node name="GridContainer" type="GridContainer" parent="TabContainer/Export"] +[node name="StyleSettingsE" parent="TabContainer/Export" instance=ExtResource( 4 )] margin_top = 167.0 margin_right = 485.0 margin_bottom = 215.0 -columns = 2 - -[node name="Label4" type="Label" parent="TabContainer/Export/GridContainer"] -margin_top = 3.0 -margin_right = 241.0 -margin_bottom = 17.0 -size_flags_horizontal = 3 -text = "Boolean True/False" - -[node name="HBoxContainer" type="HBoxContainer" parent="TabContainer/Export/GridContainer"] -margin_left = 245.0 -margin_right = 485.0 -margin_bottom = 20.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="Case" type="OptionButton" parent="TabContainer/Export/GridContainer/HBoxContainer"] -margin_right = 157.0 -margin_bottom = 20.0 -size_flags_horizontal = 3 -text = "Caps Every Word" -clip_text = true -items = [ "all lower", null, false, 0, null, "caps Except First", null, false, 1, null, "Caps Every Word", null, false, 2, null, "ALL CAPS", null, false, 3, null ] -selected = 2 - -[node name="Separator" type="OptionButton" parent="TabContainer/Export/GridContainer/HBoxContainer"] -margin_left = 161.0 -margin_right = 240.0 -margin_bottom = 20.0 -size_flags_horizontal = 3 -size_flags_stretch_ratio = 0.5 -text = "Space \" \"" -clip_text = true -items = [ "Space \" \"", null, false, 0, null, "Underscore \"_\"", null, false, 1, null, "Kebab \"-\"", null, false, 2, null ] -selected = 0 - -[node name="Label3" type="Label" parent="TabContainer/Export/GridContainer"] -margin_top = 29.0 -margin_right = 241.0 -margin_bottom = 43.0 -size_flags_horizontal = 3 -text = "Enum word case/separator" - -[node name="HBoxContainer2" type="HBoxContainer" parent="TabContainer/Export/GridContainer"] -margin_left = 245.0 -margin_top = 24.0 -margin_right = 485.0 -margin_bottom = 48.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="True" type="LineEdit" parent="TabContainer/Export/GridContainer/HBoxContainer2"] -margin_right = 118.0 -margin_bottom = 24.0 -size_flags_horizontal = 3 -text = "Yes" - -[node name="False" type="LineEdit" parent="TabContainer/Export/GridContainer/HBoxContainer2"] -margin_left = 122.0 -margin_right = 240.0 -margin_bottom = 24.0 -size_flags_horizontal = 3 -text = "No" [node name="Control" type="Control" parent="TabContainer/Export"] margin_top = 219.0 margin_right = 485.0 -margin_bottom = 306.0 +margin_bottom = 298.0 size_flags_vertical = 3 [node name="HBoxContainer" type="HBoxContainer" parent="TabContainer/Export"] -margin_top = 310.0 +margin_top = 302.0 margin_right = 485.0 -margin_bottom = 330.0 +margin_bottom = 322.0 alignment = 1 [node name="Button" type="Button" parent="TabContainer/Export/HBoxContainer"] @@ -353,9 +249,17 @@ margin_right = 319.0 margin_bottom = 20.0 text = "Cancel" +[node name="Control2" type="Control" parent="TabContainer/Export"] +margin_top = 326.0 +margin_right = 485.0 +margin_bottom = 330.0 +rect_min_size = Vector2( 0, 4 ) + [connection signal="item_selected" from="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/GridContainer/OptionButton" to="." method="_on_filename_options_item_selected"] [connection signal="text_changed" from="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/GridContainer/LineEdit" to="." method="_on_classname_field_text_changed"] [connection signal="toggled" from="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/GridContainer/CheckBox" to="." method="_on_remove_first_row_toggled"] +[connection signal="format_changed" from="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/StyleSettingsI" to="." method="_on_enum_format_changed"] +[connection signal="format_changed" from="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/StyleSettingsI" to="TabContainer/Export/StyleSettingsE" method="_on_format_changed"] [connection signal="pressed" from="TabContainer/Import/HBoxContainer/Ok2" to="." method="_on_import_edit_pressed"] [connection signal="pressed" from="TabContainer/Import/HBoxContainer/Ok" to="." method="_on_import_to_tres_pressed"] [connection signal="pressed" from="TabContainer/Import/HBoxContainer/Cancel" to="." method="hide"] @@ -364,5 +268,7 @@ text = "Cancel" [connection signal="pressed" from="TabContainer/Export/HBoxContainer2/Button3" to="." method="_on_export_delimeter_pressed" binds= [ " " ]] [connection signal="toggled" from="TabContainer/Export/HBoxContainer2/CheckBox" to="." method="_on_export_space_toggled"] [connection signal="toggled" from="TabContainer/Export/HBoxContainer3/CheckBox" to="." method="_on_remove_first_row_toggled"] +[connection signal="format_changed" from="TabContainer/Export/StyleSettingsE" to="." method="_on_enum_format_changed"] +[connection signal="format_changed" from="TabContainer/Export/StyleSettingsE" to="TabContainer/Import/MarginContainer/ScrollContainer/VBoxContainer/StyleSettingsI" method="_on_format_changed"] [connection signal="pressed" from="TabContainer/Export/HBoxContainer/Button" to="." method="_on_export_csv_pressed"] [connection signal="pressed" from="TabContainer/Export/HBoxContainer/Cancel" to="." method="hide"] diff --git a/addons/resources_speadsheet_view/import_export/import_export_enum_format.gd b/addons/resources_speadsheet_view/import_export/import_export_enum_format.gd new file mode 100644 index 0000000..d7ca2e2 --- /dev/null +++ b/addons/resources_speadsheet_view/import_export/import_export_enum_format.gd @@ -0,0 +1,21 @@ +tool +extends GridContainer + +signal format_changed(case, delimiter, bool_yes, bool_no) + + +func _send_signal(arg1 = null): + emit_signal( + "format_changed", + $"HBoxContainer/Case".selected, + [" ", "_", "-"][$"HBoxContainer/Separator".selected], + $"HBoxContainer2/True".text, + $"HBoxContainer2/False".text + ) + + +func _on_format_changed(case, delimiter, bool_yes, bool_no): + $"HBoxContainer/Case".selected = case + $"HBoxContainer/Separator".selected = [" ", "_", "-"].find(delimiter) + $"HBoxContainer2/True".text = bool_yes + $"HBoxContainer2/False".text = bool_no diff --git a/addons/resources_speadsheet_view/import_export/import_export_enum_format.tscn b/addons/resources_speadsheet_view/import_export/import_export_enum_format.tscn new file mode 100644 index 0000000..9c0a8df --- /dev/null +++ b/addons/resources_speadsheet_view/import_export/import_export_enum_format.tscn @@ -0,0 +1,76 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/resources_speadsheet_view/import_export/import_export_enum_format.gd" type="Script" id=1] + +[node name="EnumFormat" type="GridContainer"] +margin_right = 400.0 +margin_bottom = 48.0 +rect_pivot_offset = Vector2( 40, 71 ) +columns = 2 +script = ExtResource( 1 ) + +[node name="Label3" type="Label" parent="."] +margin_top = 3.0 +margin_right = 198.0 +margin_bottom = 17.0 +size_flags_horizontal = 3 +text = "Enum word case/separator" + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +margin_left = 202.0 +margin_right = 400.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 + +[node name="Case" type="OptionButton" parent="HBoxContainer"] +margin_right = 129.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 +text = "Caps Every Word" +clip_text = true +items = [ "all lower", null, false, 0, null, "caps Except First", null, false, 1, null, "Caps Every Word", null, false, 2, null, "ALL CAPS", null, false, 3, null ] +selected = 2 + +[node name="Separator" type="OptionButton" parent="HBoxContainer"] +margin_left = 133.0 +margin_right = 198.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 0.5 +text = "Space \" \"" +clip_text = true +items = [ "Space \" \"", null, false, 0, null, "Underscore \"_\"", null, false, 1, null, "Kebab \"-\"", null, false, 2, null ] +selected = 0 + +[node name="Label4" type="Label" parent="."] +margin_top = 29.0 +margin_right = 198.0 +margin_bottom = 43.0 +size_flags_horizontal = 3 +text = "Boolean True/False" + +[node name="HBoxContainer2" type="HBoxContainer" parent="."] +margin_left = 202.0 +margin_top = 24.0 +margin_right = 400.0 +margin_bottom = 48.0 +size_flags_horizontal = 3 + +[node name="True" type="LineEdit" parent="HBoxContainer2"] +margin_right = 97.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 +text = "Yes" + +[node name="False" type="LineEdit" parent="HBoxContainer2"] +margin_left = 101.0 +margin_right = 198.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 +text = "No" + +[connection signal="mouse_entered" from="Label3" to="." method="_on_Label3_mouse_entered"] +[connection signal="item_selected" from="HBoxContainer/Case" to="." method="_send_signal"] +[connection signal="item_selected" from="HBoxContainer/Separator" to="." method="_send_signal"] +[connection signal="text_changed" from="HBoxContainer2/True" to="." method="_send_signal"] +[connection signal="text_changed" from="HBoxContainer2/False" to="." method="_send_signal"] diff --git a/addons/resources_speadsheet_view/import_export/spreadsheet_import.gd b/addons/resources_speadsheet_view/import_export/spreadsheet_import.gd index 5a58f2e..6b7615c 100644 --- a/addons/resources_speadsheet_view/import_export/spreadsheet_import.gd +++ b/addons/resources_speadsheet_view/import_export/spreadsheet_import.gd @@ -17,6 +17,13 @@ enum PropType { MAX, } +enum NameCasing { + ALL_LOWER, + CAPS_WORD_EXCEPT_FIRST, + CAPS_WORD, + ALL_CAPS, +} + const SUFFIX := "_spreadsheet_import.tres" const TYPE_MAP := { TYPE_STRING : PropType.STRING, @@ -38,12 +45,12 @@ export var remove_first_row := true export var new_script : GDScript export var view_script : Script = SpreadsheetEditFormatCsv export var delimeter := ";" +export var enum_format := [NameCasing.CAPS_WORD, " ", "Yes", "No"] export var uniques : Dictionary func initialize(path): - resource_path = path.get_basename() + SUFFIX edited_path = path prop_types = [] prop_names = [] @@ -60,6 +67,8 @@ func string_to_property(string : String, col_index : int): PropType.BOOL: string = string.to_lower() + if string == enum_format[2].to_lower(): return true + if string == enum_format[3].to_lower(): return false return !string in ["no", "disabled", "-", "false", "absent", "wrong", "off", ""] PropType.REAL: @@ -79,7 +88,7 @@ func string_to_property(string : String, col_index : int): return int(uniques[col_index]["N_A"]) else: - return int(uniques[col_index][string.to_upper().replace(" ", "_")]) + return int(uniques[col_index][string.capitalize().replace(" ", "_").to_upper()]) func property_to_string(value, col_index : int) -> String: @@ -98,7 +107,7 @@ func property_to_string(value, col_index : int) -> String: return str(value) PropType.BOOL: - return str(value) # TODO: make this actually persist + return enum_format[2] if value else enum_format[3] PropType.REAL, PropType.INT: return str(value) @@ -113,7 +122,7 @@ func property_to_string(value, col_index : int) -> String: var dict = uniques[col_index] for k in dict: if dict[k] == value: - return TextEditingUtils.string_snake_to_naming_case(k) + return change_name_to_format(k, enum_format[0], enum_format[1]) return str(value) @@ -239,7 +248,7 @@ func get_uniques(entries : Array) -> Dictionary: for j in entries.size(): if j == 0 and remove_first_row: continue - cur_value = entries[j][i].replace(" ", "_").to_upper() + cur_value = entries[j][i].capitalize().to_upper().replace(" ", "_") if cur_value == "": cur_value = "N_A" @@ -249,6 +258,21 @@ func get_uniques(entries : Array) -> Dictionary: return result +static func change_name_to_format(name : String, case : int, delim : String): + var string = name.capitalize().replace(" ", delim) + if case == NameCasing.ALL_LOWER: + return string.to_lower() + + if case == NameCasing.CAPS_WORD_EXCEPT_FIRST: + return string[0].to_lower() + string.substr(1) + + if case == NameCasing.CAPS_WORD: + return string + + if case == NameCasing.ALL_CAPS: + return string.to_upper() + + static func get_resource_property_types(res : Resource, properties : Array) -> Array: var result = [] result.resize(properties.size()) diff --git a/addons/resources_speadsheet_view/text_editing_utils.gd b/addons/resources_speadsheet_view/text_editing_utils.gd index 7eb9480..7065016 100644 --- a/addons/resources_speadsheet_view/text_editing_utils.gd +++ b/addons/resources_speadsheet_view/text_editing_utils.gd @@ -142,23 +142,10 @@ static func _step_cursor(text : String, start : int, step : int = 1, ctrl_presse return 0 -static func string_snake_to_naming_case(string : String, add_spaces : bool = true) -> String: - if string == "": return "" - - var split = string.split("_", false) - for i in split.size(): - split[i] = split[i][0].to_upper() + split[i].substr(1).to_lower() - - return (" " if add_spaces else "").join(split) +static func string_snake_to_naming_case(string : String, delimiter : String = " ") -> String: + if delimiter == " ": return string.capitalize() + return string.capitalize().replace(" ", delimiter) -static func pascal_case_to_snake_case(string : String) -> String: - var i = 0 - while i < string.length(): - if string.ord_at(i) < 97: - string = string.left(i) + ("_" if i > 0 else "") + string[i].to_lower() + string.substr(i + 1) - i += 1 - - i += 1 - - return string +static func pascal_case_to_snake_case(string : String, delimiter : String = "_") -> String: + return string.capitalize().replace(" ", delimiter) diff --git a/example/Random Upgrades/upgrade_data.gd b/example/Random Upgrades/upgrade_data.gd index 11f6966..2380288 100644 --- a/example/Random Upgrades/upgrade_data.gd +++ b/example/Random Upgrades/upgrade_data.gd @@ -9,10 +9,16 @@ enum Attributes { Luck, } +enum Type { + Weapon, + Passive, + Mastery, +} + export var color1 := Color.white export var max_duplicates := 0 export(Array, String) var tags : Array -export(int, "Weapon", "Passive", "Mastery") var type := 0 +export(Type) var type := 0 export(Array, Attributes) var attributes export var icon : Texture export var custom_scene : PackedScene diff --git a/example/Random Upgrades/upgrades_csv/upgrades.csv b/example/Random Upgrades/upgrades_csv/upgrades.csv new file mode 100644 index 0000000..6a4da43 --- /dev/null +++ b/example/Random Upgrades/upgrades_csv/upgrades.csv @@ -0,0 +1,31 @@ +resource_name;color1;max_duplicates;tags;type;attributes;icon;custom_scene;color2;base_weight;is_notable;multiplier_per_tag;multiplier_if_tag_present;multiplier_if_tag_not_present;max_tags_present;list_item_delimeter;list_row_delimeter +Upgrade: Elemental Damage;ffffffff;9;[elemental];PASSIVE;[1];res://example/Random Upgrades/icons/all_icons/all_icons_6.tres;;fff64c4c;10;No;;;elemental 0;; ;" +" +Upgrade: Health;ffffffff;9;[health, melee];PASSIVE;[2];res://example/Random Upgrades/icons/all_icons/all_icons_1.tres;;ff21ff3e;10;No;strength 1.5 melee 2.0;;;; ;" +" +Mastery: Magic;ffffd829;9;[magic, mastery];MASTERY;[1, 1, 4];res://example/Random Upgrades/icons/all_icons/all_icons_5.tres;;ff6831d3;1;Yes;magic 1.2;;magic 0;; ;" +" +Mastery: Strength;ffffd829;9;[strength, mastery];MASTERY;[0, 0, 4];res://example/Random Upgrades/icons/all_icons/all_icons_2.tres;;fffdf033;1;Yes;;;strength 0;; ;" +" +Upgrade: Area of Effect;ffffffff;4;[aoe];PASSIVE;[3];res://example/Random Upgrades/icons/all_icons/all_icons_6.tres;;fff64c4c;10;No;;;aoe 0;; ;" +" +Upgrade: Magic;ffffffff;9;[magic];PASSIVE;[1];res://example/Random Upgrades/icons/all_icons/all_icons_5.tres;;ff3073e6;10;No;;;magic 0;; ;" +" +Upgrade: Strength;ffffffff;9;[strength];PASSIVE;[0];res://example/Random Upgrades/icons/all_icons/all_icons_2.tres;;fffc9531;10;No;;;strength 0;; ;" +" +Weapon: Axe;ffa2c2ff;1;[strength, melee, weapon];WEAPON;[0, 2];res://example/Random Upgrades/icons/all_icons/all_icons_3.tres;;fffc9531;10;No;strength 2.0;;;weapon 4; ;" +" +Weapon: Blizzard;ffa2c2ff;1;[weapon, magic, elemental];WEAPON;[1, 2];res://example/Random Upgrades/icons/all_icons/all_icons_4.tres;;ff3073e6;10;No;magic 2.0;;;weapon 4; ;" +" +Weapon: Chaos Blast;ffa2c2ff;1;[weapon, magic, projectile, legendary];WEAPON;[1, 1, 1, 3];res://example/Random Upgrades/icons/all_icons/all_icons_4.tres;res://example/Random Upgrades/new scene.tscn;ff6831d3;1;Yes;magic 2.0;;;weapon 4; ;" +" +Weapon: Daggers;ffa2c2ff;1;[weapon, strength, projectile];WEAPON;[0, 3];res://example/Random Upgrades/icons/all_icons/all_icons_3.tres;;fffc9531;10;No;strength 2.0;;;weapon 4; ;" +" +Weapon: Fireball;ffa2c2ff;1;[weapon, magic, projectile, elemental];WEAPON;[1, 2];res://example/Random Upgrades/icons/all_icons/all_icons_4.tres;;ff3073e6;10;No;magic 2.0;;;weapon 4; ;" +" +Weapon: Giga Sword;ffa2c2ff;1;[weapon, strength, melee, legendary];WEAPON;[0, 0, 0, 2];res://example/Random Upgrades/icons/all_icons/all_icons_3.tres;res://example/Random Upgrades/new scene.tscn;fffdf033;1;Yes;strength 2.0;;;weapon 4; ;" +" +Weapon: Lightning;ffa2c2ff;1;[weapon, magic, elemental];WEAPON;[1, 3];res://example/Random Upgrades/icons/all_icons/all_icons_4.tres;;ff3073e6;10;No;magic 2.0;;;weapon 4; ;" +" +Weapon: Spear;ffa2c2ff;1;[weapon, strength, melee];WEAPON;[0, 3];res://example/Random Upgrades/icons/all_icons/all_icons_3.tres;;fffc9531;10;No;strength 2.0;;;weapon 4; ;" +" diff --git a/upgrades.csv.import b/example/Random Upgrades/upgrades_csv/upgrades.csv.import similarity index 61% rename from upgrades.csv.import rename to example/Random Upgrades/upgrades_csv/upgrades.csv.import index c5c8fe6..1ac2098 100644 --- a/upgrades.csv.import +++ b/example/Random Upgrades/upgrades_csv/upgrades.csv.import @@ -6,7 +6,7 @@ valid=false [deps] -source_file="res://upgrades.csv" +source_file="res://example/Random Upgrades/upgrades_csv/upgrades.csv" [params] compress=true diff --git a/example/Random Upgrades/upgrades_csv/upgrades.gd b/example/Random Upgrades/upgrades_csv/upgrades.gd new file mode 100644 index 0000000..b62ee60 --- /dev/null +++ b/example/Random Upgrades/upgrades_csv/upgrades.gd @@ -0,0 +1,26 @@ +class_name Upgrades +extends Resource + +enum Type { + PASSIVE = 0, + MASTERY = 1, + WEAPON = 2, + MAX, +} + +export var color1 := "" +export var max_duplicates := 0.0 +export var tags := "" +export(Type) var type := 0 +export var attributes := "" +export var icon : Resource +export var custom_scene := "" +export var color2 := "" +export var base_weight := 0.0 +export var is_notable := false +export var multiplier_per_tag := "" +export var multiplier_if_tag_present := "" +export var multiplier_if_tag_not_present := "" +export var max_tags_present := "" +export var list_item_delimeter := "" +export var list_row_delimeter := "" diff --git a/example/Random Upgrades/upgrades_csv/upgrades_spreadsheet_import.tres b/example/Random Upgrades/upgrades_csv/upgrades_spreadsheet_import.tres new file mode 100644 index 0000000..5268027 --- /dev/null +++ b/example/Random Upgrades/upgrades_csv/upgrades_spreadsheet_import.tres @@ -0,0 +1,25 @@ +[gd_resource type="Resource" load_steps=4 format=2] + +[ext_resource path="res://addons/resources_speadsheet_view/import_export/spreadsheet_import.gd" type="Script" id=1] +[ext_resource path="res://addons/resources_speadsheet_view/import_export/formats_edit/edit_csv.gd" type="Script" id=2] +[ext_resource path="res://example/Random Upgrades/upgrades_csv/upgrades.gd" type="Script" id=3] + +[resource] +script = ExtResource( 1 ) +prop_types = [ 3, 3, 2, 3, 10, 3, 9, 3, 3, 2, 0, 3, 3, 3, 3, 3, 3 ] +prop_names = [ "resource_name", "color1", "max_duplicates", "tags", "type", "attributes", "icon", "custom_scene", "color2", "base_weight", "is_notable", "multiplier_per_tag", "multiplier_if_tag_present", "multiplier_if_tag_not_present", "max_tags_present", "list_item_delimeter", "list_row_delimeter" ] +edited_path = "res://example/Random Upgrades/upgrades_csv/upgrades.csv" +prop_used_as_filename = "" +script_classname = "Upgrades" +remove_first_row = true +new_script = ExtResource( 3 ) +view_script = ExtResource( 2 ) +delimeter = ";" +enum_format = [ 3, " ", "Yes", "No" ] +uniques = { +4: { +"MASTERY": 1, +"PASSIVE": 0, +"WEAPON": 2 +} +} diff --git a/project.godot b/project.godot index 2e85bc4..d608208 100644 --- a/project.godot +++ b/project.godot @@ -73,6 +73,11 @@ _global_script_classes=[ { "class": "ThemeStylebox", "language": "GDScript", "path": "res://addons/resources_speadsheet_view/editor_stylebox_overrider.gd" +}, { +"base": "Resource", +"class": "Upgrades", +"language": "GDScript", +"path": "res://example/Random Upgrades/upgrades_csv/upgrades.gd" } ] _global_script_class_icons={ "CellEditor": "", @@ -87,7 +92,8 @@ _global_script_class_icons={ "SpreadsheetImportFormatCsv": "", "TextEditingUtils": "", "ThemeIconButton": "", -"ThemeStylebox": "" +"ThemeStylebox": "", +"Upgrades": "" } color_rows=false color_arrays=true @@ -100,6 +106,12 @@ resources_spreadsheet_view/clip_headers=false resources_spreadsheet_view/dupe_arrays=true resources_spreadsheet_view/array_min_width=128.0 resources_spreadsheet_view/context_menu_on_leftclick=false +resources_spreadsheet_view/Color_Rows=true +resources_spreadsheet_view/Color_Arrays=true +resources_spreadsheet_view/Array_Min_Width=128.0 +resources_spreadsheet_view/Clip_Headers=false +resources_spreadsheet_view/Dupe_Arrays=true +resources_spreadsheet_view/Context_Menu_On_Leftclick=false [application] diff --git a/upgrades.csv b/upgrades.csv deleted file mode 100644 index d0d84a0..0000000 --- a/upgrades.csv +++ /dev/null @@ -1,49 +0,0 @@ -resource_path; resource_name; color1; max_duplicates; tags; type; attributes; icon; custom_scene; color2; base_weight; is_notable; multiplier_per_tag; multiplier_if_tag_present; multiplier_if_tag_not_present; max_tags_present; list_item_delimeter; list_row_delimeter -; Upgrade: Elemental Damage; ffffffff; 9; [elemental]; ; [1]; res://example/Random Upgrades/icons/all_icons/all_icons_6.tres; ; fff64c4c; 10; False; ; ; elemental 0; ; ;" -" -; Upgrade: Elemental Damage; ffffffff; 9; [elemental]; ; [1]; res://example/Random Upgrades/icons/all_icons/all_icons_6.tres; ; fff64c4c; 10; False; ; ; elemental 0; ; ;" -" -; Upgrade: Health; ffffffff; 9; [health, melee]; ; [2]; res://example/Random Upgrades/icons/all_icons/all_icons_1.tres; ; ff21ff3e; 10; False; strength 1.5 melee 2.0; ; ; ; ;" -" -; Upgrade: Health; ffffffff; 9; [health, melee]; ; [2]; res://example/Random Upgrades/icons/all_icons/all_icons_1.tres; ; ff21ff3e; 10; False; strength 1.5 melee 2.0; ; ; ; ;" -" -; Mastery: Magic; ffffd829; 9; [magic, mastery]; ; [1, 1, 4]; res://example/Random Upgrades/icons/all_icons/all_icons_5.tres; ; ff6831d3; 1; True; magic 1.2; ; magic 0; ; ;" -" -mastery_magic; Mastery: Magic; ffffd829; 9; [magic, mastery]; ; [1, 1, 4]; res://example/Random Upgrades/icons/all_icons/all_icons_5.tres; ; ff6831d3; 1; True; magic 1.2; ; magic 0; ; ;" -" -; Mastery: Strength; ffffd829; 9; [strength, mastery]; ; [0, 0, 4]; res://example/Random Upgrades/icons/all_icons/all_icons_2.tres; ; fffdf033; 1; True; ; ; strength 0; ; ;" -" -; Mastery: Strength; ffffd829; 9; [strength, mastery]; ; [0, 0, 4]; res://example/Random Upgrades/icons/all_icons/all_icons_2.tres; ; fffdf033; 1; True; ; ; strength 0; ; ;" -" -; Upgrade: Area of Effect; ffffffff; 4; [aoe]; ; [3]; res://example/Random Upgrades/icons/all_icons/all_icons_6.tres; ; fff64c4c; 10; False; ; ; aoe 0; ; ;" -" -; Upgrade: Area of Effect; ffffffff; 4; [aoe]; ; [3]; res://example/Random Upgrades/icons/all_icons/all_icons_6.tres; ; fff64c4c; 10; False; ; ; aoe 0; ; ;" -" -; Upgrade: Area of Effect; ffffffff; 4; [aoe]; ; [3]; res://example/Random Upgrades/icons/all_icons/all_icons_6.tres; ; fff64c4c; 10; False; ; ; aoe 0; ; ;" -" -; Upgrade: Area of Effect; ffffffff; 4; [aoe]; ; [3]; res://example/Random Upgrades/icons/all_icons/all_icons_6.tres; ; fff64c4c; 10; False; ; ; aoe 0; ; ;" -" -; Upgrade: Area of Effect; ffffffff; 4; [aoe]; ; [3]; res://example/Random Upgrades/icons/all_icons/all_icons_6.tres; ; fff64c4c; 10; False; ; ; aoe 0; ; ;" -" -; Upgrade: Magic; ffffffff; 9; [magic]; ; [1]; res://example/Random Upgrades/icons/all_icons/all_icons_5.tres; ; ff3073e6; 10; False; ; ; magic 0; ; ;" -" -; Upgrade: Magic; ffffffff; 9; [magic]; ; [1]; res://example/Random Upgrades/icons/all_icons/all_icons_5.tres; ; ff3073e6; 10; False; ; ; magic 0; ; ;" -" -; Upgrade: Strength; ffffffff; 9; [strength]; ; [0]; res://example/Random Upgrades/icons/all_icons/all_icons_2.tres; ; fffc9531; 10; False; ; ; strength 0; ; ;" -" -; Weapon: Axe; ffa2c2ff; 1; [strength, melee, weapon]; ; [0, 2]; res://example/Random Upgrades/icons/all_icons/all_icons_3.tres; ; fffc9531; 10; False; strength 2.0; ; ; weapon 4; ;" -" -weapon_blizzard; Weapon: Blizzard; ffa2c2ff; 1; [weapon, magic, elemental]; ; [1, 2]; res://example/Random Upgrades/icons/all_icons/all_icons_4.tres; ; ff3073e6; 10; False; magic 2.0; ; ; weapon 4; ;" -" -weapon_chaos_blast; Weapon: Chaos Blast; ffa2c2ff; 1; [weapon, magic, projectile, legendary]; ; [1, 1, 1, 3]; res://example/Random Upgrades/icons/all_icons/all_icons_4.tres; res://example/Random Upgrades/new scene.tscn; ff6831d3; 1; True; magic 2.0; ; ; weapon 4; ;" -" -weapon_dagger; Weapon: Daggers; ffa2c2ff; 1; [weapon, strength, projectile]; ; [0, 3]; res://example/Random Upgrades/icons/all_icons/all_icons_3.tres; ; fffc9531; 10; False; strength 2.0; ; ; weapon 4; ;" -" -weapon_fireball; Weapon: Fireball; ffa2c2ff; 1; [weapon, magic, projectile, elemental]; ; [1, 2]; res://example/Random Upgrades/icons/all_icons/all_icons_4.tres; ; ff3073e6; 10; False; magic 2.0; ; ; weapon 4; ;" -" -weapon_giga_sword; Weapon: Giga Sword; ffa2c2ff; 1; [weapon, strength, melee, legendary]; ; [0, 0, 0, 2]; res://example/Random Upgrades/icons/all_icons/all_icons_3.tres; res://example/Random Upgrades/new scene.tscn; fffdf033; 1; True; strength 2.0; ; ; weapon 4; ;" -" -weapon_lightning; Weapon: Lightning; ffa2c2ff; 1; [weapon, magic, elemental]; ; [1, 3]; res://example/Random Upgrades/icons/all_icons/all_icons_4.tres; ; ff3073e6; 10; False; magic 2.0; ; ; weapon 4; ;" -" -weapon_spear; Weapon: Spear; ffa2c2ff; 1; [weapon, strength, melee]; ; [0, 3]; res://example/Random Upgrades/icons/all_icons/all_icons_3.tres; ; fffc9531; 10; False; strength 2.0; ; ; weapon 4; ;" -" diff --git a/upgrades_spreadsheet_import.tres b/upgrades_spreadsheet_import.tres deleted file mode 100644 index 8551072..0000000 --- a/upgrades_spreadsheet_import.tres +++ /dev/null @@ -1,39 +0,0 @@ -[gd_resource type="Resource" load_steps=4 format=2] - -[ext_resource path="res://addons/resources_speadsheet_view/import_export/spreadsheet_import.gd" type="Script" id=1] -[ext_resource path="res://addons/resources_speadsheet_view/import_export/formats_edit/edit_csv.gd" type="Script" id=2] - -[sub_resource type="GDScript" id=1] -script/source = "extends Resource - -export var color1 := \"\" -export var max_duplicates := 0.0 -export var tags := \"\" -export var type := \"\" -export var attributes := \"\" -export var icon : Resource -export var custom_scene := \"\" -export var color2 := \"\" -export var base_weight := 0.0 -export var is_notable := \"\" -export var multiplier_per_tag := \"\" -export var multiplier_if_tag_present := \"\" -export var multiplier_if_tag_not_present := \"\" -export var max_tags_present := \"\" -export var list_item_delimeter := \"\" -export var list_row_delimeter := \"\" -" - -[resource] -script = ExtResource( 1 ) -prop_types = [ 3, 3, 3, 2, 3, 3, 3, 9, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3 ] -prop_names = [ "resource_path", "resource_name", "color1", "max_duplicates", "tags", "type", "attributes", "icon", "custom_scene", "color2", "base_weight", "is_notable", "multiplier_per_tag", "multiplier_if_tag_present", "multiplier_if_tag_not_present", "max_tags_present", "list_item_delimeter", "list_row_delimeter" ] -edited_path = "res://upgrades.csv" -prop_used_as_filename = "" -script_classname = "Upgrades" -remove_first_row = true -new_script = SubResource( 1 ) -view_script = ExtResource( 2 ) -delimeter = "; " -uniques = { -}