diff --git a/addons/resources_speadsheet_view/editor_view.gd b/addons/resources_speadsheet_view/editor_view.gd index 76d4b08..5cdeba3 100644 --- a/addons/resources_speadsheet_view/editor_view.gd +++ b/addons/resources_speadsheet_view/editor_view.gd @@ -18,6 +18,7 @@ var save_data_path : String = get_script().resource_path.get_base_dir() + "/save var sorting_by := "" var sorting_reverse := false var is_undo_redoing := false +var undo_redo_version := 0 var all_cell_editors := [] @@ -112,10 +113,10 @@ func _load_resources_from_folder(folderpath : String, sort_by : String, sort_rev column_types.append(x["type"]) column_hints.append(x["hint"]) for y in all_cell_editors: - if y.can_edit_value(res.get(x["name"]), x["hint"]): + if y.can_edit_value(res.get(x["name"]), x["type"], x["hint"]): column_editors.append(y) break - + cur_dir_script = res.get_script() if !(sort_by in res): sort_by = "resource_path" @@ -162,7 +163,8 @@ func _create_table(root_node : Control, columns_changed : bool): while to_free > 0: root_node.get_child(columns.size()).free() to_free -= 1 - + + var next_color := Color.white for i in rows.size(): for j in columns.size(): if root_node.get_child_count() <= (i + 1) * columns.size() + j: @@ -178,6 +180,15 @@ func _create_table(root_node : Control, columns_changed : bool): if columns[j] == "resource_path": column_editors[j].set_value(new_node, new_node.text.get_file()) + if j == 0: + next_color = Color.white + + if column_types[j] == TYPE_COLOR: + next_color = rows[i].get(columns[j]) + + column_editors[j].set_color(new_node, next_color) + + func add_path_to_recent(path : String, is_loading : bool = false): if path in recent_paths: return @@ -360,7 +371,8 @@ func _input(event : InputEvent): # This shortcut is used by Godot as well. if Input.is_key_pressed(KEY_CONTROL) and event.scancode == KEY_Y: - editor_plugin.undo_redo.redo() + editor_plugin.undo_redo.redo() + return editor_plugin.undo_redo.create_action("Set Cell Value") editor_plugin.undo_redo.add_undo_method( @@ -368,7 +380,7 @@ func _input(event : InputEvent): "_update_resources", edited_cells_resources.duplicate(), edited_cells.duplicate(), - columns[_get_cell_column(edited_cells[0])], + _get_cell_column(edited_cells[0]), _get_edited_cells_values() ) @@ -380,11 +392,12 @@ func _input(event : InputEvent): "_update_resources", edited_cells_resources.duplicate(), edited_cells.duplicate(), - columns[_get_cell_column(edited_cells[0])], + _get_cell_column(edited_cells[0]), _get_edited_cells_values() ) editor_plugin.undo_redo.commit_action() editor_interface.get_resource_filesystem().scan() + undo_redo_version = editor_plugin.undo_redo.get_version() func _key_specific_action(event : InputEvent): @@ -466,16 +479,13 @@ func set_cell(cell, value): column_editors[column].set_value(cell, value) -func _update_resources(update_rows : Array, update_cells : Array, update_column : String, values : Array): +func _update_resources(update_rows : Array, update_cells : Array, update_column : int, values : Array): var cells := get_node(path_table_root).get_children() - var cell_editor = column_editors[_get_cell_column(cells[0])] for i in update_rows.size(): - update_rows[i].set(update_column, values[i]) + update_rows[i].set(columns[update_column], values[i]) ResourceSaver.save(update_rows[i].resource_path, update_rows[i]) - if is_undo_redoing: - cell_editor.set_value(update_cells[i], values[i]) - - is_undo_redoing = false + if undo_redo_version > editor_plugin.undo_redo.get_version(): + column_editors[update_column].set_value(update_cells[i], values[i]) func _get_edited_cells_resources() -> Array: diff --git a/addons/resources_speadsheet_view/editor_view.tscn b/addons/resources_speadsheet_view/editor_view.tscn index 5f77536..18dcb2c 100644 --- a/addons/resources_speadsheet_view/editor_view.tscn +++ b/addons/resources_speadsheet_view/editor_view.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=9 format=2] [ext_resource path="res://addons/resources_speadsheet_view/editor_view.gd" type="Script" id=1] -[ext_resource path="res://addons/resources_speadsheet_view/typed_cells/cell_editor.gd" type="Script" id=2] +[ext_resource path="res://addons/resources_speadsheet_view/typed_cells/cell_editor_string.gd" type="Script" id=2] [ext_resource path="res://addons/resources_speadsheet_view/typed_cells/cell_editor_color.gd" type="Script" id=3] [ext_resource path="res://addons/resources_speadsheet_view/editor_icon_button.gd" type="Script" id=4] [ext_resource path="res://addons/resources_speadsheet_view/typed_cells/cell_editor_bool.gd" type="Script" id=5] @@ -43,7 +43,7 @@ __meta__ = { "_edit_lock_": true } table_header_scene = ExtResource( 6 ) -cell_editor_classes = [ ExtResource( 5 ), ExtResource( 3 ), ExtResource( 2 ) ] +cell_editor_classes = [ ExtResource( 3 ), ExtResource( 5 ), ExtResource( 2 ) ] path_folder_path = NodePath("HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer/Path") path_recent_paths = NodePath("HeaderContentSplit/VBoxContainer/HBoxContainer/RecentPaths") path_table_root = NodePath("HeaderContentSplit/MarginContainer/FooterContentSplit/Panel/Scroll/MarginContainer/TableGrid") diff --git a/addons/resources_speadsheet_view/plugin.cfg b/addons/resources_speadsheet_view/plugin.cfg index cd16468..d31302a 100644 --- a/addons/resources_speadsheet_view/plugin.cfg +++ b/addons/resources_speadsheet_view/plugin.cfg @@ -5,5 +5,5 @@ description="Edit Many Resources from one Folder as a table. Heavily inspired by Multi-Cursor-Editing in text editors, so after selecting multiple cells (in the same column!) using Ctrl+Click or Shift+Click, most Basic-to-Intermediate movements should be available." author="Don Tnowe" -version="0.2" +version="0.3" script="plugin.gd" diff --git a/addons/resources_speadsheet_view/typed_cells/cell_editor.gd b/addons/resources_speadsheet_view/typed_cells/cell_editor.gd index 15d6ca9..24513ed 100644 --- a/addons/resources_speadsheet_view/typed_cells/cell_editor.gd +++ b/addons/resources_speadsheet_view/typed_cells/cell_editor.gd @@ -5,7 +5,7 @@ const CELL_SCENE_DIR = "res://addons/resources_speadsheet_view/typed_cells/" # Override to define where the cell should be shown. -func can_edit_value(value, property_hint) -> bool: +func can_edit_value(value, type, property_hint) -> bool: return true # Override to change how the cell is created; preload a scene or create nodes from code. @@ -34,4 +34,4 @@ func get_text_length(node : Control): func set_color(node : Control, color : Color): - node.get_node("Back").modulate = color + node.get_node("Back").modulate = color * 1.0 diff --git a/addons/resources_speadsheet_view/typed_cells/cell_editor_bool.gd b/addons/resources_speadsheet_view/typed_cells/cell_editor_bool.gd index ad80518..6f0780c 100644 --- a/addons/resources_speadsheet_view/typed_cells/cell_editor_bool.gd +++ b/addons/resources_speadsheet_view/typed_cells/cell_editor_bool.gd @@ -1,8 +1,8 @@ extends CellEditor -func can_edit_value(value, property_hint) -> bool: - return value is bool +func can_edit_value(value, type, property_hint) -> bool: + return type == TYPE_BOOL func set_value(node : Control, value): diff --git a/addons/resources_speadsheet_view/typed_cells/cell_editor_color.gd b/addons/resources_speadsheet_view/typed_cells/cell_editor_color.gd index 9928909..9a62ac1 100644 --- a/addons/resources_speadsheet_view/typed_cells/cell_editor_color.gd +++ b/addons/resources_speadsheet_view/typed_cells/cell_editor_color.gd @@ -3,8 +3,8 @@ extends CellEditor var _cached_color := Color.white -func can_edit_value(value, property_hint) -> bool: - return value is Color +func can_edit_value(value, type, property_hint) -> bool: + return type == TYPE_COLOR func get_value(node : Control): diff --git a/addons/resources_speadsheet_view/typed_cells/cell_editor_string.gd b/addons/resources_speadsheet_view/typed_cells/cell_editor_string.gd new file mode 100644 index 0000000..78f5744 --- /dev/null +++ b/addons/resources_speadsheet_view/typed_cells/cell_editor_string.gd @@ -0,0 +1,5 @@ +extends CellEditor + + +func set_color(node : Control, color : Color): + node.get_node("Back").modulate = color * 0.6 if !node.text.is_valid_float() else color diff --git a/example/upgrades/elemental.tres b/example/upgrades/elemental.tres index 677ab9a..b59b6bb 100644 --- a/example/upgrades/elemental.tres +++ b/example/upgrades/elemental.tres @@ -5,11 +5,14 @@ [resource] resource_name = "Upgrade: Elemental Damage" script = ExtResource( 1 ) +color1 = Color( 1, 1, 1, 1 ) max_duplicates = 9 tags = "elemental" requires_one_of_tags = "" +color2 = Color( 0.964706, 0.298039, 0.298039, 1 ) tag_delimeter = " " base_weight = 10.0 +is_notable = false multiplier_per_tag = "" multiplier_if_tag_present = "" multiplier_if_tag_not_present = "elemental 0" diff --git a/example/upgrades/health.tres b/example/upgrades/health.tres index f1089d4..17dedd3 100644 --- a/example/upgrades/health.tres +++ b/example/upgrades/health.tres @@ -5,11 +5,14 @@ [resource] resource_name = "Upgrade: Health" script = ExtResource( 1 ) +color1 = Color( 1, 1, 1, 1 ) max_duplicates = 9 tags = "health melee" requires_one_of_tags = "" +color2 = Color( 0.129412, 1, 0.243137, 1 ) tag_delimeter = " " base_weight = 10.0 +is_notable = false multiplier_per_tag = "strength 1.5 melee 2.0" multiplier_if_tag_present = "" multiplier_if_tag_not_present = "" diff --git a/example/upgrades/up_aoe.tres b/example/upgrades/up_aoe.tres index 91f1bc8..ddbc513 100644 --- a/example/upgrades/up_aoe.tres +++ b/example/upgrades/up_aoe.tres @@ -5,11 +5,14 @@ [resource] resource_name = "Upgrade: Area of Effect" script = ExtResource( 1 ) +color1 = Color( 1, 1, 1, 1 ) max_duplicates = 4 tags = "aoe" requires_one_of_tags = "" +color2 = Color( 0.964706, 0.298039, 0.298039, 1 ) tag_delimeter = " " base_weight = 10.0 +is_notable = false multiplier_per_tag = "" multiplier_if_tag_present = "" multiplier_if_tag_not_present = "aoe 0" diff --git a/example/upgrades/up_magic.tres b/example/upgrades/up_magic.tres index 5b48f54..c0d1fd2 100644 --- a/example/upgrades/up_magic.tres +++ b/example/upgrades/up_magic.tres @@ -5,11 +5,14 @@ [resource] resource_name = "Upgrade: Magic" script = ExtResource( 1 ) +color1 = Color( 1, 1, 1, 1 ) max_duplicates = 9 tags = "magic" requires_one_of_tags = "" +color2 = Color( 0.189457, 0.452246, 0.902344, 1 ) tag_delimeter = " " base_weight = 10.0 +is_notable = false multiplier_per_tag = "" multiplier_if_tag_present = "" multiplier_if_tag_not_present = "magic 0" diff --git a/example/upgrades/up_strength.tres b/example/upgrades/up_strength.tres index 50eda89..f67e897 100644 --- a/example/upgrades/up_strength.tres +++ b/example/upgrades/up_strength.tres @@ -5,11 +5,14 @@ [resource] resource_name = "Upgrade: Strength" script = ExtResource( 1 ) +color1 = Color( 1, 1, 1, 1 ) max_duplicates = 9 tags = "strength" requires_one_of_tags = "" +color2 = Color( 0.988235, 0.584314, 0.192157, 1 ) tag_delimeter = " " base_weight = 10.0 +is_notable = false multiplier_per_tag = "" multiplier_if_tag_present = "" multiplier_if_tag_not_present = "strength 0" diff --git a/example/upgrades/weapon_axe.tres b/example/upgrades/weapon_axe.tres index 11e419e..a04e2ee 100644 --- a/example/upgrades/weapon_axe.tres +++ b/example/upgrades/weapon_axe.tres @@ -5,11 +5,14 @@ [resource] resource_name = "Weapon: Axe" script = ExtResource( 1 ) +color1 = Color( 1, 1, 0.2, 1 ) max_duplicates = 0 tags = "weapon strength aoe melee" requires_one_of_tags = "" +color2 = Color( 0.988235, 0.584314, 0.192157, 1 ) tag_delimeter = " " base_weight = 10.0 +is_notable = false multiplier_per_tag = "strength 2.0" multiplier_if_tag_present = "" multiplier_if_tag_not_present = "" diff --git a/example/upgrades/weapon_blizzard.tres b/example/upgrades/weapon_blizzard.tres index 0647ee8..0f9e600 100644 --- a/example/upgrades/weapon_blizzard.tres +++ b/example/upgrades/weapon_blizzard.tres @@ -5,11 +5,14 @@ [resource] resource_name = "Weapon: Blizzard" script = ExtResource( 1 ) +color1 = Color( 1, 1, 0.2, 1 ) max_duplicates = 0 tags = "weapon magic aoe elemental" requires_one_of_tags = "" +color2 = Color( 0.189457, 0.452246, 0.902344, 1 ) tag_delimeter = " " base_weight = 10.0 +is_notable = false multiplier_per_tag = "magic 2.0" multiplier_if_tag_present = "" multiplier_if_tag_not_present = "" diff --git a/example/upgrades/weapon_chaos_blast.tres b/example/upgrades/weapon_chaos_blast.tres index f613212..a802977 100644 --- a/example/upgrades/weapon_chaos_blast.tres +++ b/example/upgrades/weapon_chaos_blast.tres @@ -5,11 +5,14 @@ [resource] resource_name = "Weapon: Chaos Blast" script = ExtResource( 1 ) +color1 = Color( 1, 1, 0.2, 1 ) max_duplicates = 0 tags = "weapon magic legendary chaosblast aoe" requires_one_of_tags = "" +color2 = Color( 0.40631, 0.190945, 0.832031, 1 ) tag_delimeter = " " base_weight = 1.0 +is_notable = false multiplier_per_tag = "magic 2.0" multiplier_if_tag_present = "" multiplier_if_tag_not_present = "" diff --git a/example/upgrades/weapon_dagger.tres b/example/upgrades/weapon_dagger.tres index c37aa33..097e8ae 100644 --- a/example/upgrades/weapon_dagger.tres +++ b/example/upgrades/weapon_dagger.tres @@ -5,11 +5,14 @@ [resource] resource_name = "Weapon: Daggers" script = ExtResource( 1 ) +color1 = Color( 1, 1, 0.2, 1 ) max_duplicates = 0 tags = "weapon strength dagger projectile" requires_one_of_tags = "" +color2 = Color( 0.988235, 0.584314, 0.192157, 1 ) tag_delimeter = " " base_weight = 10.0 +is_notable = true multiplier_per_tag = "strength 2.0" multiplier_if_tag_present = "" multiplier_if_tag_not_present = "" diff --git a/example/upgrades/weapon_fireball.tres b/example/upgrades/weapon_fireball.tres index c14f8bb..fd00b7a 100644 --- a/example/upgrades/weapon_fireball.tres +++ b/example/upgrades/weapon_fireball.tres @@ -5,11 +5,14 @@ [resource] resource_name = "Weapon: Fireball" script = ExtResource( 1 ) +color1 = Color( 1, 1, 0.2, 1 ) max_duplicates = 0 tags = "weapon magic fireball projectile elemental" requires_one_of_tags = "" +color2 = Color( 0.189457, 0.452246, 0.902344, 1 ) tag_delimeter = " " base_weight = 10.0 +is_notable = true multiplier_per_tag = "magic 2.0" multiplier_if_tag_present = "" multiplier_if_tag_not_present = "" diff --git a/example/upgrades/weapon_giga_sword.tres b/example/upgrades/weapon_giga_sword.tres index 01e28d4..65ada02 100644 --- a/example/upgrades/weapon_giga_sword.tres +++ b/example/upgrades/weapon_giga_sword.tres @@ -5,11 +5,14 @@ [resource] resource_name = "Weapon: Giga Sword" script = ExtResource( 1 ) +color1 = Color( 1, 1, 0.2, 1 ) max_duplicates = 0 tags = "weapon strength legendary gigasword melee" requires_one_of_tags = "" +color2 = Color( 0.988235, 0.93848, 0.192157, 1 ) tag_delimeter = " " base_weight = 1.0 +is_notable = true multiplier_per_tag = "strength 2.0" multiplier_if_tag_present = "" multiplier_if_tag_not_present = "" diff --git a/example/upgrades/weapon_lightning.tres b/example/upgrades/weapon_lightning.tres index a643298..93a163c 100644 --- a/example/upgrades/weapon_lightning.tres +++ b/example/upgrades/weapon_lightning.tres @@ -5,11 +5,14 @@ [resource] resource_name = "Weapon: Lightning" script = ExtResource( 1 ) +color1 = Color( 1, 1, 0.2, 1 ) max_duplicates = 0 tags = "weapon magic lightning elemental" requires_one_of_tags = "" +color2 = Color( 0.189457, 0.452246, 0.902344, 1 ) tag_delimeter = " " base_weight = 10.0 +is_notable = true multiplier_per_tag = "magic 2.0" multiplier_if_tag_present = "" multiplier_if_tag_not_present = "" diff --git a/example/upgrades/weapon_spear.tres b/example/upgrades/weapon_spear.tres index d2d63f2..b5fdb0d 100644 --- a/example/upgrades/weapon_spear.tres +++ b/example/upgrades/weapon_spear.tres @@ -5,11 +5,14 @@ [resource] resource_name = "Weapon: Spear" script = ExtResource( 1 ) +color1 = Color( 1, 1, 0.2, 1 ) max_duplicates = 0 tags = "weapon strength spear melee" requires_one_of_tags = "" +color2 = Color( 0.988235, 0.584314, 0.192157, 1 ) tag_delimeter = " " base_weight = 10.0 +is_notable = true multiplier_per_tag = "strength 2.0" multiplier_if_tag_present = "" multiplier_if_tag_not_present = ""