mirror of
https://github.com/Relintai/godot-resources-as-sheets-plugin.git
synced 2024-11-10 10:12:08 +01:00
Add row colorization
This commit is contained in:
parent
eac20fb2fb
commit
0746595ce0
@ -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,7 +113,7 @@ 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
|
||||
|
||||
@ -163,6 +164,7 @@ func _create_table(root_node : Control, columns_changed : bool):
|
||||
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
|
||||
@ -361,6 +372,7 @@ 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()
|
||||
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:
|
||||
|
@ -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")
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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
|
@ -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"
|
||||
|
@ -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 = ""
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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 = ""
|
||||
|
@ -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 = ""
|
||||
|
@ -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 = ""
|
||||
|
@ -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 = ""
|
||||
|
@ -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 = ""
|
||||
|
@ -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 = ""
|
||||
|
@ -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 = ""
|
||||
|
@ -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 = ""
|
||||
|
Loading…
Reference in New Issue
Block a user