[MP] Cleanup and fixes for replication plugin.
- Remove dead code. - Fix "Add from path" adding the wrong string when targeting root node.
This commit is contained in:
parent
ea0247086b
commit
43f51d78d1
modules/multiplayer/editor
@ -255,8 +255,6 @@ void ReplicationEditor::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("_update_checked", "property", "column", "checked"), &ReplicationEditor::_update_checked);
|
ClassDB::bind_method(D_METHOD("_update_checked", "property", "column", "checked"), &ReplicationEditor::_update_checked);
|
||||||
ClassDB::bind_method("_can_drop_data_fw", &ReplicationEditor::_can_drop_data_fw);
|
ClassDB::bind_method("_can_drop_data_fw", &ReplicationEditor::_can_drop_data_fw);
|
||||||
ClassDB::bind_method("_drop_data_fw", &ReplicationEditor::_drop_data_fw);
|
ClassDB::bind_method("_drop_data_fw", &ReplicationEditor::_drop_data_fw);
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("keying_changed"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReplicationEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
bool ReplicationEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
||||||
@ -322,10 +320,6 @@ void ReplicationEditor::_notification(int p_what) {
|
|||||||
add_pick_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
|
add_pick_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
|
||||||
pin->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons")));
|
pin->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons")));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
|
||||||
update_keying();
|
|
||||||
} break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,28 +335,15 @@ void ReplicationEditor::_add_pressed() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String np_text = np_line_edit->get_text();
|
String np_text = np_line_edit->get_text();
|
||||||
if (np_text.find(":") == -1) {
|
int idx = np_text.find(":");
|
||||||
np_text = ":" + np_text;
|
if (idx == -1) {
|
||||||
|
np_text = ".:" + np_text;
|
||||||
|
} else if (idx == 0) {
|
||||||
|
np_text = "." + np_text;
|
||||||
}
|
}
|
||||||
NodePath prop = NodePath(np_text);
|
NodePath path = NodePath(np_text);
|
||||||
if (prop.is_empty()) {
|
|
||||||
return;
|
_add_sync_property(path);
|
||||||
}
|
|
||||||
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
|
|
||||||
undo_redo->create_action(TTR("Add property"));
|
|
||||||
config = current->get_replication_config();
|
|
||||||
if (config.is_null()) {
|
|
||||||
config.instantiate();
|
|
||||||
current->set_replication_config(config);
|
|
||||||
undo_redo->add_do_method(current, "set_replication_config", config);
|
|
||||||
undo_redo->add_undo_method(current, "set_replication_config", Ref<SceneReplicationConfig>());
|
|
||||||
_update_config();
|
|
||||||
}
|
|
||||||
undo_redo->add_do_method(config.ptr(), "add_property", prop);
|
|
||||||
undo_redo->add_undo_method(config.ptr(), "remove_property", prop);
|
|
||||||
undo_redo->add_do_method(this, "_update_config");
|
|
||||||
undo_redo->add_undo_method(this, "_update_config");
|
|
||||||
undo_redo->commit_action();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplicationEditor::_tree_item_edited() {
|
void ReplicationEditor::_tree_item_edited() {
|
||||||
@ -440,32 +421,12 @@ void ReplicationEditor::_update_checked(const NodePath &p_prop, int p_column, bo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplicationEditor::update_keying() {
|
|
||||||
/// TODO make keying usable.
|
|
||||||
#if 0
|
|
||||||
bool keying_enabled = false;
|
|
||||||
EditorSelectionHistory *editor_history = EditorNode::get_singleton()->get_editor_selection_history();
|
|
||||||
if (is_visible_in_tree() && config.is_valid() && editor_history->get_path_size() > 0) {
|
|
||||||
Object *obj = ObjectDB::get_instance(editor_history->get_path_object(0));
|
|
||||||
keying_enabled = Object::cast_to<Node>(obj) != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keying_enabled == keying) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
keying = keying_enabled;
|
|
||||||
emit_signal(SNAME("keying_changed"));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReplicationEditor::_update_config() {
|
void ReplicationEditor::_update_config() {
|
||||||
deleting = NodePath();
|
deleting = NodePath();
|
||||||
tree->clear();
|
tree->clear();
|
||||||
tree->create_item();
|
tree->create_item();
|
||||||
drop_label->set_visible(true);
|
drop_label->set_visible(true);
|
||||||
if (!config.is_valid()) {
|
if (!config.is_valid()) {
|
||||||
update_keying();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TypedArray<NodePath> props = config->get_properties();
|
TypedArray<NodePath> props = config->get_properties();
|
||||||
@ -476,7 +437,6 @@ void ReplicationEditor::_update_config() {
|
|||||||
const NodePath path = props[i];
|
const NodePath path = props[i];
|
||||||
_add_property(path, config->property_get_spawn(path), config->property_get_sync(path));
|
_add_property(path, config->property_get_spawn(path), config->property_get_sync(path));
|
||||||
}
|
}
|
||||||
update_keying();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplicationEditor::edit(MultiplayerSynchronizer *p_sync) {
|
void ReplicationEditor::edit(MultiplayerSynchronizer *p_sync) {
|
||||||
@ -532,43 +492,6 @@ void ReplicationEditor::_add_property(const NodePath &p_property, bool p_spawn,
|
|||||||
item->set_editable(2, true);
|
item->set_editable(2, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplicationEditor::property_keyed(const String &p_property) {
|
|
||||||
ERR_FAIL_COND(!current || config.is_null());
|
|
||||||
Node *root = current->get_node(current->get_root_path());
|
|
||||||
ERR_FAIL_COND(!root);
|
|
||||||
EditorSelectionHistory *history = EditorNode::get_singleton()->get_editor_selection_history();
|
|
||||||
ERR_FAIL_COND(history->get_path_size() == 0);
|
|
||||||
Node *node = Object::cast_to<Node>(ObjectDB::get_instance(history->get_path_object(0)));
|
|
||||||
ERR_FAIL_COND(!node);
|
|
||||||
if (node->is_class("MultiplayerSynchronizer")) {
|
|
||||||
error_dialog->set_text(TTR("Properties of 'MultiplayerSynchronizer' cannot be configured for replication."));
|
|
||||||
error_dialog->popup_centered();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (history->get_path_size() > 1 || p_property.get_slice_count(":") > 1) {
|
|
||||||
error_dialog->set_text(TTR("Subresources cannot yet be configured for replication."));
|
|
||||||
error_dialog->popup_centered();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String path = root->get_path_to(node);
|
|
||||||
for (int i = 1; i < history->get_path_size(); i++) {
|
|
||||||
String prop = history->get_path_property(i);
|
|
||||||
ERR_FAIL_COND(prop == "");
|
|
||||||
path += ":" + prop;
|
|
||||||
}
|
|
||||||
path += ":" + p_property;
|
|
||||||
|
|
||||||
NodePath prop = path;
|
|
||||||
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
|
|
||||||
undo_redo->create_action(TTR("Add property"));
|
|
||||||
undo_redo->add_do_method(config.ptr(), "add_property", prop);
|
|
||||||
undo_redo->add_undo_method(config.ptr(), "remove_property", prop);
|
|
||||||
undo_redo->add_do_method(this, "_update_config");
|
|
||||||
undo_redo->add_undo_method(this, "_update_config");
|
|
||||||
undo_redo->commit_action();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// ReplicationEditorPlugin
|
/// ReplicationEditorPlugin
|
||||||
ReplicationEditorPlugin::ReplicationEditorPlugin() {
|
ReplicationEditorPlugin::ReplicationEditorPlugin() {
|
||||||
repl_editor = memnew(ReplicationEditor);
|
repl_editor = memnew(ReplicationEditor);
|
||||||
@ -580,26 +503,9 @@ ReplicationEditorPlugin::ReplicationEditorPlugin() {
|
|||||||
ReplicationEditorPlugin::~ReplicationEditorPlugin() {
|
ReplicationEditorPlugin::~ReplicationEditorPlugin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplicationEditorPlugin::_keying_changed() {
|
|
||||||
// TODO make lock usable.
|
|
||||||
//InspectorDock::get_inspector_singleton()->set_keying(repl_editor->has_keying(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReplicationEditorPlugin::_property_keyed(const String &p_keyed, const Variant &p_value, bool p_advance) {
|
|
||||||
if (!repl_editor->has_keying()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
repl_editor->property_keyed(p_keyed);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReplicationEditorPlugin::_notification(int p_what) {
|
void ReplicationEditorPlugin::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_ENTER_TREE: {
|
case NOTIFICATION_ENTER_TREE: {
|
||||||
//Node3DEditor::get_singleton()->connect("transform_key_request", callable_mp(this, &AnimationPlayerEditorPlugin::_transform_key_request));
|
|
||||||
InspectorDock::get_inspector_singleton()->connect("property_keyed", callable_mp(this, &ReplicationEditorPlugin::_property_keyed));
|
|
||||||
repl_editor->connect("keying_changed", callable_mp(this, &ReplicationEditorPlugin::_keying_changed));
|
|
||||||
// TODO make lock usable.
|
|
||||||
//InspectorDock::get_inspector_singleton()->connect("object_inspected", callable_mp(repl_editor, &ReplicationEditor::update_keying));
|
|
||||||
get_tree()->connect("node_removed", callable_mp(this, &ReplicationEditorPlugin::_node_removed));
|
get_tree()->connect("node_removed", callable_mp(this, &ReplicationEditorPlugin::_node_removed));
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
@ -635,8 +541,6 @@ bool ReplicationEditorPlugin::handles(Object *p_object) const {
|
|||||||
|
|
||||||
void ReplicationEditorPlugin::make_visible(bool p_visible) {
|
void ReplicationEditorPlugin::make_visible(bool p_visible) {
|
||||||
if (p_visible) {
|
if (p_visible) {
|
||||||
//editor->hide_animation_player_editors();
|
|
||||||
//editor->animation_panel_make_visible(true);
|
|
||||||
button->show();
|
button->show();
|
||||||
EditorNode::get_singleton()->make_bottom_panel_item_visible(repl_editor);
|
EditorNode::get_singleton()->make_bottom_panel_item_visible(repl_editor);
|
||||||
} else if (!repl_editor->get_pin()->is_pressed()) {
|
} else if (!repl_editor->get_pin()->is_pressed()) {
|
||||||
|
@ -61,7 +61,6 @@ private:
|
|||||||
Ref<SceneReplicationConfig> config;
|
Ref<SceneReplicationConfig> config;
|
||||||
NodePath deleting;
|
NodePath deleting;
|
||||||
Tree *tree = nullptr;
|
Tree *tree = nullptr;
|
||||||
bool keying = false;
|
|
||||||
|
|
||||||
PropertySelector *prop_selector = nullptr;
|
PropertySelector *prop_selector = nullptr;
|
||||||
SceneTreeDialog *pick_node = nullptr;
|
SceneTreeDialog *pick_node = nullptr;
|
||||||
@ -98,11 +97,8 @@ protected:
|
|||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void update_keying();
|
|
||||||
void edit(MultiplayerSynchronizer *p_object);
|
void edit(MultiplayerSynchronizer *p_object);
|
||||||
bool has_keying() const { return keying; }
|
|
||||||
MultiplayerSynchronizer *get_current() const { return current; }
|
MultiplayerSynchronizer *get_current() const { return current; }
|
||||||
void property_keyed(const String &p_property);
|
|
||||||
|
|
||||||
Button *get_pin() { return pin; }
|
Button *get_pin() { return pin; }
|
||||||
ReplicationEditor();
|
ReplicationEditor();
|
||||||
@ -117,8 +113,6 @@ private:
|
|||||||
ReplicationEditor *repl_editor = nullptr;
|
ReplicationEditor *repl_editor = nullptr;
|
||||||
|
|
||||||
void _node_removed(Node *p_node);
|
void _node_removed(Node *p_node);
|
||||||
void _keying_changed();
|
|
||||||
void _property_keyed(const String &p_keyed, const Variant &p_value, bool p_advance);
|
|
||||||
|
|
||||||
void _pinned();
|
void _pinned();
|
||||||
|
|
||||||
@ -133,17 +127,5 @@ public:
|
|||||||
ReplicationEditorPlugin();
|
ReplicationEditorPlugin();
|
||||||
~ReplicationEditorPlugin();
|
~ReplicationEditorPlugin();
|
||||||
};
|
};
|
||||||
#else
|
|
||||||
class ReplicationEditorPlugin : public EditorPlugin {
|
|
||||||
GDCLASS(ReplicationEditorPlugin, EditorPlugin);
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual void edit(Object *p_object) override {}
|
|
||||||
virtual bool handles(Object *p_object) const override { return false; }
|
|
||||||
virtual void make_visible(bool p_visible) override {}
|
|
||||||
|
|
||||||
ReplicationEditorPlugin() {}
|
|
||||||
~ReplicationEditorPlugin() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // REPLICATION_EDITOR_PLUGIN_H
|
#endif // REPLICATION_EDITOR_PLUGIN_H
|
||||||
|
Loading…
Reference in New Issue
Block a user