mirror of
https://github.com/Relintai/godot-resources-as-sheets-plugin.git
synced 2025-02-21 08:34:26 +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:
|
PropType.BOOL:
|
||||||
string = string.to_lower()
|
string = string.to_lower()
|
||||||
return !string in ["no", "disabled", "-", "false", "absent", "wrong", ""]
|
return !string in ["no", "disabled", "-", "false", "absent", "wrong", "off", ""]
|
||||||
|
|
||||||
PropType.REAL:
|
PropType.REAL:
|
||||||
return string.to_float()
|
return string.to_float()
|
||||||
@ -122,19 +122,36 @@ func create_property_line_for_prop(col_index : int):
|
|||||||
PropType.ENUM:
|
PropType.ENUM:
|
||||||
return result.replace(
|
return result.replace(
|
||||||
"export var",
|
"export var",
|
||||||
"export("
|
"export(" + _escape_forbidden_enum_names(
|
||||||
+ TextEditingUtils.string_snake_to_naming_case(
|
TextEditingUtils\
|
||||||
prop_names[col_index]
|
.string_snake_to_naming_case(prop_names[col_index])\
|
||||||
).replace(" ", "")
|
.replace(" ", "")
|
||||||
+ ") var"
|
) + ") var"
|
||||||
) + "= 0\n"
|
) + "= 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):
|
func create_enum_for_prop(col_index):
|
||||||
var result := (
|
var result := (
|
||||||
"enum "
|
"enum "
|
||||||
+ TextEditingUtils.string_snake_to_naming_case(prop_names[col_index]).replace(" ", "")
|
+ _escape_forbidden_enum_names(
|
||||||
+ " {\n"
|
TextEditingUtils\
|
||||||
|
.string_snake_to_naming_case(prop_names[col_index])\
|
||||||
|
.replace(" ", "")
|
||||||
|
) + " {\n"
|
||||||
)
|
)
|
||||||
for k in uniques[col_index]:
|
for k in uniques[col_index]:
|
||||||
result += (
|
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:
|
static func string_snake_to_naming_case(string : String, add_spaces : bool = true) -> String:
|
||||||
if string == "": return ""
|
if string == "": return ""
|
||||||
|
|
||||||
var split = string.split("_")
|
var split = string.split("_", false)
|
||||||
for i in split.size():
|
for i in split.size():
|
||||||
split[i] = split[i][0].to_upper() + split[i].substr(1).to_lower()
|
split[i] = split[i][0].to_upper() + split[i].substr(1).to_lower()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user