mirror of
https://github.com/Relintai/godot-resources-as-sheets-plugin.git
synced 2025-04-08 17:41:50 +02:00
Implement CSV insert/delete
This commit is contained in:
parent
5643968a3e
commit
9eb9462484
@ -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):
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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):
|
||||
|
49
upgrades.csv
Normal file
49
upgrades.csv
Normal file
@ -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; ;"
|
||||
"
|
|
13
upgrades.csv.import
Normal file
13
upgrades.csv.import
Normal file
@ -0,0 +1,13 @@
|
||||
[remap]
|
||||
|
||||
importer="csv_translation"
|
||||
type="Translation"
|
||||
valid=false
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://upgrades.csv"
|
||||
[params]
|
||||
|
||||
compress=true
|
||||
delimiter=0
|
39
upgrades_spreadsheet_import.tres
Normal file
39
upgrades_spreadsheet_import.tres
Normal file
@ -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 = {
|
||||
}
|
Loading…
Reference in New Issue
Block a user