mirror of
https://github.com/Relintai/godot-resources-as-sheets-plugin.git
synced 2025-04-08 17:41:50 +02:00
Fix enum views not recognizing custom enum values
This commit is contained in:
parent
faa4de9d28
commit
f98397ea5c
@ -6,7 +6,30 @@ func can_edit_value(value, type, property_hint, column_index) -> bool:
|
||||
|
||||
|
||||
func set_value(node : Control, value):
|
||||
node.text = hint_strings_array[node.get_index() % hint_strings_array.size()][value]
|
||||
if value == null:
|
||||
# Sometimes, when creating new property, becomes null
|
||||
value = 0
|
||||
|
||||
var value_str : String
|
||||
var key_found := -1
|
||||
var hint_arr : Array = hint_strings_array[node.get_index() % hint_strings_array.size()]
|
||||
for i in hint_arr.size():
|
||||
var colon_found : int = hint_arr[i].rfind(":")
|
||||
if colon_found == -1:
|
||||
key_found = value
|
||||
break
|
||||
|
||||
if hint_arr[i].substr(colon_found + 1).to_int() == value:
|
||||
key_found = i
|
||||
break
|
||||
|
||||
if key_found != -1:
|
||||
value_str = hint_arr[key_found]
|
||||
|
||||
else:
|
||||
value_str = "?:%s" % value
|
||||
|
||||
node.text = value_str
|
||||
node.self_modulate = Color(node.text.hash()) + Color(0.25, 0.25, 0.25, 1.0)
|
||||
node.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
|
||||
|
@ -14,13 +14,24 @@ func can_edit_value(value, type, property_hint, column_index) -> bool:
|
||||
|
||||
func _write_value_to_child(value, key, hint_arr : PackedStringArray, child : Label, colored : bool):
|
||||
var value_str : String
|
||||
if value == 0:
|
||||
var key_found := -1
|
||||
for i in hint_arr.size():
|
||||
var colon_found := hint_arr[i].rfind(":")
|
||||
if colon_found == -1:
|
||||
key_found = value
|
||||
break
|
||||
|
||||
if hint_arr[i].substr(colon_found + 1).to_int() == value:
|
||||
key_found = i
|
||||
break
|
||||
|
||||
if key_found == 0:
|
||||
# Enum array hints have "2/3:" before list.
|
||||
var found := hint_arr[0].find(":") + 1
|
||||
value_str = hint_arr[0].substr(hint_arr[0].find(":") + 1)
|
||||
|
||||
elif value < hint_arr.size():
|
||||
value_str = hint_arr[value]
|
||||
elif key_found != -1:
|
||||
value_str = hint_arr[key_found]
|
||||
|
||||
else:
|
||||
value_str = "?:%s" % value
|
||||
|
@ -42,7 +42,12 @@ func _create_option_button(index : int):
|
||||
if index >= options_container.get_child_count() - _init_nodes_in_options_container:
|
||||
node = Button.new()
|
||||
options_container.add_child(node)
|
||||
node.pressed.connect(_on_option_clicked.bind(index))
|
||||
var colon_found : int = value.rfind(":")
|
||||
if colon_found == -1:
|
||||
node.pressed.connect(_on_option_clicked.bind(index))
|
||||
|
||||
else:
|
||||
node.pressed.connect(_on_option_clicked.bind(value.substr(colon_found + 1).to_int()))
|
||||
|
||||
else:
|
||||
node = options_container.get_child(index + _init_nodes_in_options_container)
|
||||
@ -53,7 +58,7 @@ func _create_option_button(index : int):
|
||||
return node
|
||||
|
||||
|
||||
func _add_value(option_value):
|
||||
func _add_value(option_value : int):
|
||||
_stored_value.append(option_value)
|
||||
var values = sheet.get_edited_cells_values()
|
||||
var cur_value
|
||||
@ -69,7 +74,7 @@ func _add_value(option_value):
|
||||
sheet.set_edited_cells_values(values)
|
||||
|
||||
|
||||
func _remove_value(option_value):
|
||||
func _remove_value(option_value : int):
|
||||
_stored_value.append(option_value)
|
||||
var values = sheet.get_edited_cells_values()
|
||||
var cur_value
|
||||
|
@ -3,11 +3,12 @@ class_name UpgradeData
|
||||
extends Resource
|
||||
|
||||
enum Attributes {
|
||||
Strength,
|
||||
Strength = 0,
|
||||
Magic,
|
||||
Endurance,
|
||||
Agility,
|
||||
Luck,
|
||||
Mastery = 128,
|
||||
}
|
||||
|
||||
@export var color1 := Color.WHITE
|
||||
|
@ -13,7 +13,7 @@ color1 = Color(1, 0.847059, 0.160784, 1)
|
||||
max_duplicates = 9
|
||||
tags = Array[String](["magic", "mastery"])
|
||||
type = 2
|
||||
attributes = Array[int]([1, 1, 4])
|
||||
attributes = Array[int]([1, 1, 4, 128])
|
||||
icon = ExtResource("1_ardng")
|
||||
prerequisites = Array[ExtResource("2")]([ExtResource("2_485ad"), ExtResource("3_xnxxn"), ExtResource("4_kn0kg")])
|
||||
color2 = Color(0.407843, 0.192157, 0.827451, 1)
|
||||
|
@ -13,7 +13,7 @@ color1 = Color(1, 0.847059, 0.160784, 1)
|
||||
max_duplicates = 9
|
||||
tags = Array[String](["strength", "mastery"])
|
||||
type = 2
|
||||
attributes = Array[int]([0, 0, 4])
|
||||
attributes = Array[int]([0, 0, 4, 128])
|
||||
icon = ExtResource("1_442ey")
|
||||
prerequisites = Array[ExtResource("2")]([ExtResource("2_kb33p"), ExtResource("3_tt25f"), ExtResource("4_kpsn8")])
|
||||
color2 = Color(0.992157, 0.941176, 0.2, 1)
|
||||
|
Loading…
Reference in New Issue
Block a user