MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / icon_annotation

Method icon_annotation

modules/gdscript/gdscript_parser.cpp:4335–4364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4333}
4334
4335bool GDScriptParser::icon_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
4336 ERR_FAIL_COND_V_MSG(p_target->type != Node::CLASS, false, R"("@icon" annotation can only be applied to classes.)");
4337 ERR_FAIL_COND_V(p_annotation->resolved_arguments.is_empty(), false);
4338
4339 ClassNode *class_node = static_cast<ClassNode *>(p_target);
4340 String path = p_annotation->resolved_arguments[0];
4341
4342#ifdef DEBUG_ENABLED
4343 if (!class_node->icon_path.is_empty()) {
4344 push_error(R"("@icon" annotation can only be used once.)", p_annotation);
4345 return false;
4346 }
4347 if (path.is_empty()) {
4348 push_error(R"("@icon" annotation argument must contain the path to the icon.)", p_annotation->arguments[0]);
4349 return false;
4350 }
4351#endif // DEBUG_ENABLED
4352
4353 class_node->icon_path = path;
4354
4355 if (path.is_empty() || path.is_absolute_path()) {
4356 class_node->simplified_icon_path = path.simplify_path();
4357 } else if (path.is_relative_path()) {
4358 class_node->simplified_icon_path = script_path.get_base_dir().path_join(path).simplify_path();
4359 } else {
4360 class_node->simplified_icon_path = path;
4361 }
4362
4363 return true;
4364}
4365
4366bool GDScriptParser::static_unload_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
4367 ERR_FAIL_COND_V_MSG(p_target->type != Node::CLASS, false, vformat(R"("%s" annotation can only be applied to classes.)", p_annotation->name));

Callers

nothing calls this directly

Calls 6

is_absolute_pathMethod · 0.80
is_relative_pathMethod · 0.80
path_joinMethod · 0.80
get_base_dirMethod · 0.80
is_emptyMethod · 0.45
simplify_pathMethod · 0.45

Tested by

no test coverage detected