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

Method _add_property

modules/multiplayer/editor/replication_editor.cpp:555–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

553}
554
555void ReplicationEditor::_add_property(const NodePath &p_property, bool p_spawn, SceneReplicationConfig::ReplicationMode p_mode) {
556 String prop = String(p_property);
557 TreeItem *item = tree->create_item();
558 item->set_selectable(0, false);
559 item->set_selectable(1, false);
560 item->set_selectable(2, false);
561 item->set_selectable(3, false);
562 item->set_text(0, prop);
563 item->set_metadata(0, prop);
564 Node *root_node = current && !current->get_root_path().is_empty() ? current->get_node(current->get_root_path()) : nullptr;
565 Ref<Texture2D> icon = _get_class_icon(root_node);
566 if (root_node) {
567 String path = prop.substr(0, prop.find_char(':'));
568 String subpath = prop.substr(path.size());
569 Node *node = root_node->get_node_or_null(path);
570 if (!node) {
571 node = root_node;
572 }
573 item->set_text(0, String(node->get_name()) + ":" + subpath);
574 icon = _get_class_icon(node);
575 bool valid = false;
576 Variant value = node->get(subpath, &valid);
577 if (valid && !can_sync(value)) {
578 item->set_icon(0, get_theme_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons)));
579 item->set_tooltip_text(0, TTR("Property of this type not supported."));
580 } else {
581 item->set_icon(0, icon);
582 }
583 } else {
584 item->set_icon(0, icon);
585 }
586 item->add_button(3, get_theme_icon(SNAME("Remove"), EditorStringName(EditorIcons)));
587 item->set_text_alignment(1, HORIZONTAL_ALIGNMENT_CENTER);
588 item->set_cell_mode(1, TreeItem::CELL_MODE_CHECK);
589 item->set_checked(1, p_spawn);
590 item->set_editable(1, true);
591 item->set_text_alignment(2, HORIZONTAL_ALIGNMENT_CENTER);
592 item->set_cell_mode(2, TreeItem::CELL_MODE_RANGE);
593 item->set_range_config(2, 0, 2, 1);
594 item->set_text(2, TTR("Never", "Replication Mode") + "," + TTR("Always", "Replication Mode") + "," + TTR("On Change", "Replication Mode"));
595 item->set_range(2, (int)p_mode);
596 item->set_editable(2, true);
597}

Callers

nothing calls this directly

Calls 15

can_syncFunction · 0.85
TTRFunction · 0.85
set_metadataMethod · 0.80
substrMethod · 0.80
find_charMethod · 0.80
get_node_or_nullMethod · 0.80
set_cell_modeMethod · 0.80
set_range_configMethod · 0.80
sizeMethod · 0.65
StringClass · 0.50
create_itemMethod · 0.45
set_selectableMethod · 0.45

Tested by

no test coverage detected