mirror of
https://github.com/Relintai/godot-resources-as-sheets-plugin.git
synced 2025-02-17 03:34:19 +01:00
Fix error importing enums with some names
This commit is contained in:
parent
58e410898f
commit
0937f685b4
@ -52,7 +52,7 @@ func string_to_property(string : String, col_index : int):
|
||||
|
||||
PropType.BOOL:
|
||||
string = string.to_lower()
|
||||
return !string in ["no", "disabled", "-", "false", "absent", "wrong", ""]
|
||||
return !string in ["no", "disabled", "-", "false", "absent", "wrong", "off", ""]
|
||||
|
||||
PropType.REAL:
|
||||
return string.to_float()
|
||||
@ -122,19 +122,36 @@ func create_property_line_for_prop(col_index : int):
|
||||
PropType.ENUM:
|
||||
return result.replace(
|
||||
"export var",
|
||||
"export("
|
||||
+ TextEditingUtils.string_snake_to_naming_case(
|
||||
prop_names[col_index]
|
||||
).replace(" ", "")
|
||||
+ ") var"
|
||||
"export(" + _escape_forbidden_enum_names(
|
||||
TextEditingUtils\
|
||||
.string_snake_to_naming_case(prop_names[col_index])\
|
||||
.replace(" ", "")
|
||||
) + ") var"
|
||||
) + "= 0\n"
|
||||
|
||||
|
||||
func _escape_forbidden_enum_names(string : String) -> String:
|
||||
if ClassDB.class_exists(string):
|
||||
return string + "_"
|
||||
|
||||
# Not in ClassDB, but are engine types and can be property names
|
||||
if string in [
|
||||
"Color", "String", "Plane",
|
||||
"Basis", "Transform", "Variant",
|
||||
]:
|
||||
return string + "_"
|
||||
|
||||
return string
|
||||
|
||||
|
||||
func create_enum_for_prop(col_index):
|
||||
var result := (
|
||||
"enum "
|
||||
+ TextEditingUtils.string_snake_to_naming_case(prop_names[col_index]).replace(" ", "")
|
||||
+ " {\n"
|
||||
+ _escape_forbidden_enum_names(
|
||||
TextEditingUtils\
|
||||
.string_snake_to_naming_case(prop_names[col_index])\
|
||||
.replace(" ", "")
|
||||
) + " {\n"
|
||||
)
|
||||
for k in uniques[col_index]:
|
||||
result += (
|
||||
|
@ -145,7 +145,7 @@ static func _step_cursor(text : String, start : int, step : int = 1, ctrl_presse
|
||||
static func string_snake_to_naming_case(string : String, add_spaces : bool = true) -> String:
|
||||
if string == "": return ""
|
||||
|
||||
var split = string.split("_")
|
||||
var split = string.split("_", false)
|
||||
for i in split.size():
|
||||
split[i] = split[i][0].to_upper() + split[i].substr(1).to_lower()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user