diff --git a/addons/resources_speadsheet_view/editor_view.gd b/addons/resources_speadsheet_view/editor_view.gd index fef9312..4cd649a 100644 --- a/addons/resources_speadsheet_view/editor_view.gd +++ b/addons/resources_speadsheet_view/editor_view.gd @@ -378,6 +378,7 @@ 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() func _on_FileDialog_dir_selected(path : String): diff --git a/addons/resources_speadsheet_view/import_export/formats_edit/edit_base.gd b/addons/resources_speadsheet_view/import_export/formats_edit/edit_base.gd index c010d54..f138d31 100644 --- a/addons/resources_speadsheet_view/import_export/formats_edit/edit_base.gd +++ b/addons/resources_speadsheet_view/import_export/formats_edit/edit_base.gd @@ -27,7 +27,7 @@ func duplicate_rows(rows : Array, name_input : String): func delete_rows(rows : Array): pass -## Override with `return true` if `resource_name` is defined. +## Override with `return true` if `resource_path` is defined and the Rename butoon should show. func has_row_names(): return false diff --git a/addons/resources_speadsheet_view/import_export/formats_edit/edit_csv.gd b/addons/resources_speadsheet_view/import_export/formats_edit/edit_csv.gd index 227e7fe..c9bdff8 100644 --- a/addons/resources_speadsheet_view/import_export/formats_edit/edit_csv.gd +++ b/addons/resources_speadsheet_view/import_export/formats_edit/edit_csv.gd @@ -40,18 +40,35 @@ func create_resource(entry) -> Resource: func duplicate_rows(rows : Array, name_input : String): - # Not today (TODO) - pass + for x in rows: + var new_res = x.duplicate() + var index = resource_original_positions[x] + csv_rows.insert(index, import_data.resource_to_strings(new_res)) + _bump_row_indices(index + 1, 1) + resource_original_positions[new_res] = index + 1 + + save_entries([], []) func delete_rows(rows): - pass + for x in rows: + var index = resource_original_positions[x] + csv_rows.remove(index) + _bump_row_indices(index, -1) + resource_original_positions.erase(x) + + save_entries([], []) func has_row_names(): return false +func _bump_row_indices(from : int, increment : int = 1): + for k in resource_original_positions: + if resource_original_positions[k] >= from: + resource_original_positions[k] += increment + func import_from_path(path : String, insert_func : FuncRef, sort_by : String, sort_reverse : bool = false) -> Array: import_data = load(path) @@ -67,6 +84,7 @@ func import_from_path(path : String, insert_func : FuncRef, sort_by : String, so continue res = import_data.strings_to_resource(csv_rows[i]) + res.resource_path = "" insert_func.call_func(res, rows, sort_by, sort_reverse) resource_original_positions[res] = i 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 8a7c054..f72184f 100644 --- a/addons/resources_speadsheet_view/import_export/import_export_dialog.gd +++ b/addons/resources_speadsheet_view/import_export/import_export_dialog.gd @@ -124,7 +124,7 @@ func _generate_class(save_script = true): # Properties for i in import_data.prop_names.size(): - if import_data.prop_names[i] != "resource_name": + if import_data.prop_names[i] != "resource_path" && import_data.prop_names[i] != "resource_name": new_script.source_code += import_data.create_property_line_for_prop(i) import_data.new_script = new_script @@ -170,6 +170,7 @@ func _on_import_edit_pressed(): "resource_path" : true, "resource_local_to_scene" : true, } + editor_view.save_data() yield(get_tree(), "idle_frame") editor_view.refresh() diff --git a/addons/resources_speadsheet_view/selection_actions.gd b/addons/resources_speadsheet_view/selection_actions.gd index 20ffa7b..fdb97d7 100644 --- a/addons/resources_speadsheet_view/selection_actions.gd +++ b/addons/resources_speadsheet_view/selection_actions.gd @@ -57,9 +57,6 @@ func open(cells : Array, pin_to_cell : bool = false): show() $"Control2/Label".text = str(cells.size()) + (" Cells" if cells.size() % 10 != 1 else " Cell") $"GridContainer/Rename".visible = get_node(editor_view).has_row_names() - # TODO: remove this when dupes implemented for CSV. - $"GridContainer/Duplicate".visible = get_node(editor_view).has_row_names() - $"GridContainer/Delete".visible = get_node(editor_view).has_row_names() func _unhandled_input(event): diff --git a/upgrades.csv b/upgrades.csv new file mode 100644 index 0000000..d0d84a0 --- /dev/null +++ b/upgrades.csv @@ -0,0 +1,49 @@ +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.csv.import b/upgrades.csv.import new file mode 100644 index 0000000..c5c8fe6 --- /dev/null +++ b/upgrades.csv.import @@ -0,0 +1,13 @@ +[remap] + +importer="csv_translation" +type="Translation" +valid=false + +[deps] + +source_file="res://upgrades.csv" +[params] + +compress=true +delimiter=0 diff --git a/upgrades_spreadsheet_import.tres b/upgrades_spreadsheet_import.tres new file mode 100644 index 0000000..8551072 --- /dev/null +++ b/upgrades_spreadsheet_import.tres @@ -0,0 +1,39 @@ +[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 = { +}