summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/dictionary_property_edit.cpp1
-rw-r--r--editor/editor_data.cpp14
-rw-r--r--editor/editor_node.cpp8
-rw-r--r--editor/editor_properties.cpp10
-rw-r--r--editor/editor_sectioned_inspector.cpp3
-rw-r--r--editor/inspector_dock.cpp12
-rw-r--r--editor/plugins/animation_tree_editor_plugin.cpp7
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp2
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp30
-rw-r--r--editor/property_editor.cpp8
-rw-r--r--editor/property_selector.cpp12
-rw-r--r--editor/script_editor_debugger.cpp13
12 files changed, 58 insertions, 62 deletions
diff --git a/editor/dictionary_property_edit.cpp b/editor/dictionary_property_edit.cpp
index bb01fadb72..82db639379 100644
--- a/editor/dictionary_property_edit.cpp
+++ b/editor/dictionary_property_edit.cpp
@@ -190,5 +190,4 @@ bool DictionaryPropertyEdit::_get(const StringName &p_name, Variant &r_ret) cons
}
DictionaryPropertyEdit::DictionaryPropertyEdit() {
- obj = 0;
}
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index d7c610f109..5cb7720170 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -156,8 +156,8 @@ bool EditorHistory::is_history_obj_inspector_only(int p_obj) const {
}
ObjectID EditorHistory::get_history_obj(int p_obj) const {
- ERR_FAIL_INDEX_V(p_obj, history.size(), 0);
- ERR_FAIL_INDEX_V(history[p_obj].level, history[p_obj].path.size(), 0);
+ ERR_FAIL_INDEX_V(p_obj, history.size(), ObjectID());
+ ERR_FAIL_INDEX_V(history[p_obj].level, history[p_obj].path.size(), ObjectID());
return history[p_obj].path[history[p_obj].level].object;
}
@@ -204,12 +204,12 @@ bool EditorHistory::is_current_inspector_only() const {
ObjectID EditorHistory::get_current() {
if (current < 0 || current >= history.size())
- return 0;
+ return ObjectID();
History &h = history.write[current];
Object *obj = ObjectDB::get_instance(h.path[h.level].object);
if (!obj)
- return 0;
+ return ObjectID();
return obj->get_instance_id();
}
@@ -226,15 +226,15 @@ int EditorHistory::get_path_size() const {
ObjectID EditorHistory::get_path_object(int p_index) const {
if (current < 0 || current >= history.size())
- return 0;
+ return ObjectID();
const History &h = history[current];
- ERR_FAIL_INDEX_V(p_index, h.path.size(), 0);
+ ERR_FAIL_INDEX_V(p_index, h.path.size(), ObjectID());
Object *obj = ObjectDB::get_instance(h.path[p_index].object);
if (!obj)
- return 0;
+ return ObjectID();
return obj->get_instance_id();
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 4440a747be..a6172faeaa 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1558,7 +1558,7 @@ void EditorNode::_dialog_action(String p_file) {
save_resource_in_path(saving_resource, p_file);
saving_resource = Ref<Resource>();
ObjectID current = editor_history.get_current();
- Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
+ Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!current_obj);
current_obj->_change_notify();
} break;
@@ -1711,7 +1711,7 @@ void EditorNode::push_item(Object *p_object, const String &p_property, bool p_in
return;
}
- uint32_t id = p_object->get_instance_id();
+ ObjectID id = p_object->get_instance_id();
if (id != editor_history.get_current()) {
if (p_inspector_only) {
@@ -1767,8 +1767,8 @@ static bool overrides_external_editor(Object *p_object) {
void EditorNode::_edit_current() {
- uint32_t current = editor_history.get_current();
- Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
+ ObjectID current = editor_history.get_current();
+ Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL;
bool inspector_only = editor_history.is_current_inspector_only();
this->current = current_obj;
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 0794940cb1..905e928c5a 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -388,13 +388,13 @@ void EditorPropertyMember::_property_select() {
} else if (hint == MEMBER_METHOD_OF_INSTANCE) {
- Object *instance = ObjectDB::get_instance(hint_text.to_int64());
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (instance)
selector->select_method_from_instance(instance, current);
} else if (hint == MEMBER_METHOD_OF_SCRIPT) {
- Object *obj = ObjectDB::get_instance(hint_text.to_int64());
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (Object::cast_to<Script>(obj)) {
selector->select_method_from_script(Object::cast_to<Script>(obj), current);
}
@@ -420,13 +420,13 @@ void EditorPropertyMember::_property_select() {
} else if (hint == MEMBER_PROPERTY_OF_INSTANCE) {
- Object *instance = ObjectDB::get_instance(hint_text.to_int64());
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (instance)
selector->select_property_from_instance(instance, current);
} else if (hint == MEMBER_PROPERTY_OF_SCRIPT) {
- Object *obj = ObjectDB::get_instance(hint_text.to_int64());
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (Object::cast_to<Script>(obj)) {
selector->select_property_from_script(Object::cast_to<Script>(obj), current);
}
@@ -858,7 +858,7 @@ void EditorPropertyObjectID::update_property() {
type = "Object";
ObjectID id = get_edited_object()->get(get_edited_property());
- if (id != 0) {
+ if (id.is_valid()) {
edit->set_text(type + " ID: " + itos(id));
edit->set_disabled(false);
edit->set_icon(EditorNode::get_singleton()->get_class_icon(type));
diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp
index 2090c12c91..c4a84bfcdc 100644
--- a/editor/editor_sectioned_inspector.cpp
+++ b/editor/editor_sectioned_inspector.cpp
@@ -177,7 +177,7 @@ String SectionedInspector::get_full_item_path(const String &p_item) {
void SectionedInspector::edit(Object *p_object) {
if (!p_object) {
- obj = 0;
+ obj = ObjectID();
sections->clear();
filter->set_edited(NULL);
@@ -308,7 +308,6 @@ EditorInspector *SectionedInspector::get_inspector() {
}
SectionedInspector::SectionedInspector() :
- obj(0),
sections(memnew(Tree)),
filter(memnew(SectionedInspectorFilter)),
inspector(memnew(EditorInspector)),
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index c681cdd033..954a941a96 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -166,8 +166,8 @@ void InspectorDock::_resource_file_selected(String p_file) {
}
void InspectorDock::_save_resource(bool save_as) const {
- uint32_t current = EditorNode::get_singleton()->get_editor_history()->get_current();
- Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
+ ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current();
+ Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
@@ -180,8 +180,8 @@ void InspectorDock::_save_resource(bool save_as) const {
}
void InspectorDock::_unref_resource() const {
- uint32_t current = EditorNode::get_singleton()->get_editor_history()->get_current();
- Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
+ ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current();
+ Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
@@ -191,8 +191,8 @@ void InspectorDock::_unref_resource() const {
}
void InspectorDock::_copy_resource() const {
- uint32_t current = EditorNode::get_singleton()->get_editor_history()->get_current();
- Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
+ ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current();
+ Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index 8dc7e4638d..a729c90160 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -59,7 +59,7 @@ void AnimationTreeEditor::edit(AnimationTree *p_tree) {
path = tree->get_meta("_tree_edit_path");
edit_path(path);
} else {
- current_root = 0;
+ current_root = ObjectID();
}
}
@@ -128,7 +128,7 @@ void AnimationTreeEditor::edit_path(const Vector<String> &p_path) {
}
}
} else {
- current_root = 0;
+ current_root = ObjectID();
edited_path = button_path;
}
@@ -151,7 +151,7 @@ void AnimationTreeEditor::_about_to_show_root() {
void AnimationTreeEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_PROCESS) {
- ObjectID root = 0;
+ ObjectID root;
if (tree && tree->get_tree_root().is_valid()) {
root = tree->get_tree_root()->get_instance_id();
}
@@ -242,7 +242,6 @@ AnimationTreeEditor::AnimationTreeEditor() {
add_child(memnew(HSeparator));
- current_root = 0;
singleton = this;
editor_base = memnew(PanelContainer);
editor_base->set_v_size_flags(SIZE_EXPAND_FILL);
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 27ba518f01..f7a3b50052 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -3659,7 +3659,7 @@ bool CanvasItemEditor::_build_bones_list(Node *p_node) {
// Add a last bone if the Bone2D has no Bone2D child
BoneKey bk;
bk.from = canvas_item->get_instance_id();
- bk.to = 0;
+ bk.to = ObjectID();
if (!bone_list.has(bk)) {
BoneList b;
b.length = 0;
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 88376f6ce6..cf6c8feaed 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -252,7 +252,7 @@ void SpatialEditorViewport::_clear_selected() {
void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_allow_locked) {
- if (!clicked)
+ if (clicked.is_null())
return;
Node *node = Object::cast_to<Node>(ObjectDB::get_instance(clicked));
@@ -309,7 +309,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
Set<Ref<EditorSpatialGizmo> > found_gizmos;
Node *edited_scene = get_tree()->get_edited_scene_root();
- ObjectID closest = 0;
+ ObjectID closest;
Node *item = NULL;
float closest_dist = 1e20;
int selected_handle = -1;
@@ -356,7 +356,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
}
if (!item)
- return 0;
+ return ObjectID();
if (!editor_selection->is_selected(item) || (r_gizmo_handle && selected_handle >= 0)) {
@@ -850,9 +850,9 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
clicked = selection_results[0].item->get_instance_id();
selection_results.clear();
- if (clicked) {
+ if (clicked.is_valid()) {
_select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != SpatialEditor::TOOL_MODE_LIST_SELECT);
- clicked = 0;
+ clicked = ObjectID();
}
} else if (!selection_results.empty()) {
@@ -1095,7 +1095,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (_gizmo_select(_edit.mouse_pos))
break;
- clicked = 0;
+ clicked = ObjectID();
clicked_includes_current = false;
if ((spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT && b->get_control()) || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE) {
@@ -1139,7 +1139,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
clicked_wants_append = b->get_shift();
- if (!clicked) {
+ if (clicked.is_null()) {
if (!clicked_wants_append)
_clear_selected();
@@ -1150,7 +1150,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
cursor.region_end = b->get_position();
}
- if (clicked && gizmo_handle >= 0) {
+ if (clicked.is_valid() && gizmo_handle >= 0) {
Spatial *spa = Object::cast_to<Spatial>(ObjectDB::get_instance(clicked));
if (spa) {
@@ -1175,10 +1175,10 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
_edit.gizmo = Ref<EditorSpatialGizmo>();
break;
}
- if (clicked) {
+ if (clicked.is_valid()) {
_select_clicked(clicked_wants_append, true);
// Processing was deferred.
- clicked = 0;
+ clicked = ObjectID();
}
if (cursor.region_select) {
@@ -1279,7 +1279,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
} else if (nav_scheme == NAVIGATION_MODO && m->get_alt()) {
nav_mode = NAVIGATION_ORBIT;
} else {
- if (clicked) {
+ if (clicked.is_valid()) {
if (!clicked_includes_current) {
@@ -1288,7 +1288,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
_compute_edit(_edit.mouse_pos);
- clicked = 0;
+ clicked = ObjectID();
_edit.mode = TRANSFORM_TRANSLATE;
}
@@ -2945,9 +2945,9 @@ void SpatialEditorViewport::_selection_result_pressed(int p_result) {
clicked = selection_results[p_result].item->get_instance_id();
- if (clicked) {
+ if (clicked.is_valid()) {
_select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != SpatialEditor::TOOL_MODE_LIST_SELECT);
- clicked = 0;
+ clicked = ObjectID();
}
}
@@ -3581,7 +3581,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
editor_data = editor->get_scene_tree_dock()->get_editor_data();
editor_selection = editor->get_editor_selection();
undo_redo = editor->get_undo_redo();
- clicked = 0;
+
clicked_includes_current = false;
orthogonal = false;
lock_rotation = false;
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 63f0b02a40..1691ce3a63 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -639,7 +639,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
MAKE_PROPSELECT
- Object *instance = ObjectDB::get_instance(hint_text.to_int64());
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (instance)
property_select->select_method_from_instance(instance, v);
updating = false;
@@ -648,7 +648,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_METHOD_OF_SCRIPT) {
MAKE_PROPSELECT
- Object *obj = ObjectDB::get_instance(hint_text.to_int64());
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (Object::cast_to<Script>(obj)) {
property_select->select_method_from_script(Object::cast_to<Script>(obj), v);
}
@@ -688,7 +688,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
MAKE_PROPSELECT
- Object *instance = ObjectDB::get_instance(hint_text.to_int64());
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (instance)
property_select->select_property_from_instance(instance, v);
@@ -698,7 +698,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) {
MAKE_PROPSELECT
- Object *obj = ObjectDB::get_instance(hint_text.to_int64());
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (Object::cast_to<Script>(obj)) {
property_select->select_property_from_script(Object::cast_to<Script>(obj), v);
}
diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp
index fdb1ce3e62..1de5099c4a 100644
--- a/editor/property_selector.cpp
+++ b/editor/property_selector.cpp
@@ -404,7 +404,7 @@ void PropertySelector::select_method_from_base_type(const String &p_base, const
base_type = p_base;
selected = p_current;
type = Variant::NIL;
- script = 0;
+ script = ObjectID();
properties = false;
instance = NULL;
virtuals_only = p_virtuals_only;
@@ -437,7 +437,7 @@ void PropertySelector::select_method_from_basic_type(Variant::Type p_type, const
base_type = "";
selected = p_current;
type = p_type;
- script = 0;
+ script = ObjectID();
properties = false;
instance = NULL;
virtuals_only = false;
@@ -453,7 +453,7 @@ void PropertySelector::select_method_from_instance(Object *p_instance, const Str
base_type = p_instance->get_class();
selected = p_current;
type = Variant::NIL;
- script = 0;
+ script = ObjectID();
{
Ref<Script> scr = p_instance->get_script();
if (scr.is_valid())
@@ -474,7 +474,7 @@ void PropertySelector::select_property_from_base_type(const String &p_base, cons
base_type = p_base;
selected = p_current;
type = Variant::NIL;
- script = 0;
+ script = ObjectID();
properties = true;
instance = NULL;
virtuals_only = false;
@@ -509,7 +509,7 @@ void PropertySelector::select_property_from_basic_type(Variant::Type p_type, con
base_type = "";
selected = p_current;
type = p_type;
- script = 0;
+ script = ObjectID();
properties = true;
instance = NULL;
virtuals_only = false;
@@ -525,7 +525,7 @@ void PropertySelector::select_property_from_instance(Object *p_instance, const S
base_type = "";
selected = p_current;
type = Variant::NIL;
- script = 0;
+ script = ObjectID();
properties = true;
instance = p_instance;
virtuals_only = false;
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index 3aec50528f..2b28aa87a3 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -172,7 +172,7 @@ public:
}
String get_title() {
- if (remote_object_id)
+ if (remote_object_id.is_valid())
return TTR("Remote ") + String(type_name) + ": " + itos(remote_object_id);
else
return "<null>";
@@ -197,7 +197,6 @@ public:
}
ScriptEditorDebuggerInspectedObject() {
- remote_object_id = 0;
}
};
@@ -302,7 +301,7 @@ void ScriptEditorDebugger::_scene_tree_selected() {
return;
}
- inspected_object_id = item->get_metadata(0);
+ inspected_object_id = item->get_metadata(0).operator ObjectID();
Array msg;
msg.push_back("inspect_object");
@@ -434,7 +433,7 @@ int ScriptEditorDebugger::_update_scene_tree(TreeItem *parent, const Array &node
TreeItem *item = inspect_scene_tree->create_item(parent);
item->set_text(0, item_text);
item->set_tooltip(0, TTR("Type:") + " " + item_type);
- ObjectID id = ObjectID(nodes[current_index + 3]);
+ ObjectID id = nodes[current_index + 3].operator ObjectID();
Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(nodes[current_index + 2], "");
if (icon.is_valid()) {
item->set_icon(0, icon);
@@ -1107,7 +1106,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
int frame_size = 6;
for (int i = 0; i < p_data.size(); i += frame_size) {
MultiplayerAPI::ProfilingInfo pi;
- pi.node = p_data[i + 0];
+ pi.node = p_data[i + 0].operator ObjectID();
pi.node_path = p_data[i + 1];
pi.incoming_rpc = p_data[i + 2];
pi.incoming_rset = p_data[i + 3];
@@ -1253,7 +1252,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
inspect_edited_object_timeout -= get_process_delta_time();
if (inspect_edited_object_timeout < 0) {
inspect_edited_object_timeout = EditorSettings::get_singleton()->get("debugger/remote_inspect_refresh_interval");
- if (inspected_object_id) {
+ if (inspected_object_id.is_valid()) {
if (ScriptEditorDebuggerInspectedObject *obj = Object::cast_to<ScriptEditorDebuggerInspectedObject>(ObjectDB::get_instance(editor->get_editor_history()->get_current()))) {
if (obj->remote_object_id == inspected_object_id) {
//take the chance and re-inspect selected object
@@ -2486,7 +2485,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
auto_switch_remote_scene_tree = EDITOR_DEF("debugger/auto_switch_to_remote_scene_tree", false);
inspect_scene_tree_timeout = EDITOR_DEF("debugger/remote_scene_tree_refresh_interval", 1.0);
inspect_edited_object_timeout = EDITOR_DEF("debugger/remote_inspect_refresh_interval", 0.2);
- inspected_object_id = 0;
+ inspected_object_id = ObjectID();
updating_scene_tree = false;
}