diff options
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 0f7166c101..a0d02b12b5 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -66,6 +66,10 @@ Variant::Type GDScriptParser::get_builtin_type(const StringName &p_type) { return Variant::VARIANT_MAX; } +#ifdef TOOLS_ENABLED +HashMap<String, String> GDScriptParser::theme_color_names; +#endif + void GDScriptParser::cleanup() { builtin_types.clear(); } @@ -121,6 +125,15 @@ GDScriptParser::GDScriptParser() { #ifdef DEBUG_ENABLED is_ignoring_warnings = !(bool)GLOBAL_GET("debug/gdscript/warnings/enable"); #endif + +#ifdef TOOLS_ENABLED + if (theme_color_names.is_empty()) { + theme_color_names.insert("x", "axis_x_color"); + theme_color_names.insert("y", "axis_y_color"); + theme_color_names.insert("z", "axis_z_color"); + theme_color_names.insert("w", "axis_w_color"); + } +#endif } GDScriptParser::~GDScriptParser() { @@ -3840,18 +3853,31 @@ bool GDScriptParser::tool_annotation(const AnnotationNode *p_annotation, Node *p bool GDScriptParser::icon_annotation(const AnnotationNode *p_annotation, Node *p_node) { ERR_FAIL_COND_V_MSG(p_node->type != Node::CLASS, false, R"("@icon" annotation can only be applied to classes.)"); ERR_FAIL_COND_V(p_annotation->resolved_arguments.is_empty(), false); + ClassNode *p_class = static_cast<ClassNode *>(p_node); + String path = p_annotation->resolved_arguments[0]; + #ifdef DEBUG_ENABLED if (!p_class->icon_path.is_empty()) { push_error(R"("@icon" annotation can only be used once.)", p_annotation); return false; } - if (String(p_annotation->resolved_arguments[0]).is_empty()) { + if (path.is_empty()) { push_error(R"("@icon" annotation argument must contain the path to the icon.)", p_annotation->arguments[0]); return false; } #endif // DEBUG_ENABLED - p_class->icon_path = p_annotation->resolved_arguments[0]; + + p_class->icon_path = path; + + if (path.is_empty() || path.is_absolute_path()) { + p_class->simplified_icon_path = path.simplify_path(); + } else if (path.is_relative_path()) { + p_class->simplified_icon_path = script_path.get_base_dir().path_join(path).simplify_path(); + } else { + p_class->simplified_icon_path = path; + } + return true; } |