Merge pull request #58187 from jakobbouchard/notification-switch-chunk-c
Convert _notification methods to switch - Chunk C
This commit is contained in:
commit
009254d87c
37 changed files with 378 additions and 327 deletions
|
|
@ -491,61 +491,63 @@ Vector<Face3> CSGShape3D::get_faces(uint32_t p_usage_flags) const {
|
|||
}
|
||||
|
||||
void CSGShape3D::_notification(int p_what) {
|
||||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
||||
Node *parentn = get_parent();
|
||||
if (parentn) {
|
||||
parent = Object::cast_to<CSGShape3D>(parentn);
|
||||
if (parent) {
|
||||
set_base(RID());
|
||||
root_mesh.unref();
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
Node *parentn = get_parent();
|
||||
if (parentn) {
|
||||
parent = Object::cast_to<CSGShape3D>(parentn);
|
||||
if (parent) {
|
||||
set_base(RID());
|
||||
root_mesh.unref();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (use_collision && is_root_shape()) {
|
||||
root_collision_shape.instantiate();
|
||||
root_collision_instance = PhysicsServer3D::get_singleton()->body_create();
|
||||
PhysicsServer3D::get_singleton()->body_set_mode(root_collision_instance, PhysicsServer3D::BODY_MODE_STATIC);
|
||||
PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
|
||||
PhysicsServer3D::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid());
|
||||
PhysicsServer3D::get_singleton()->body_set_space(root_collision_instance, get_world_3d()->get_space());
|
||||
PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id());
|
||||
set_collision_layer(collision_layer);
|
||||
set_collision_mask(collision_mask);
|
||||
}
|
||||
if (use_collision && is_root_shape()) {
|
||||
root_collision_shape.instantiate();
|
||||
root_collision_instance = PhysicsServer3D::get_singleton()->body_create();
|
||||
PhysicsServer3D::get_singleton()->body_set_mode(root_collision_instance, PhysicsServer3D::BODY_MODE_STATIC);
|
||||
PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
|
||||
PhysicsServer3D::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid());
|
||||
PhysicsServer3D::get_singleton()->body_set_space(root_collision_instance, get_world_3d()->get_space());
|
||||
PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id());
|
||||
set_collision_layer(collision_layer);
|
||||
set_collision_mask(collision_mask);
|
||||
}
|
||||
|
||||
_make_dirty();
|
||||
}
|
||||
_make_dirty();
|
||||
} break;
|
||||
|
||||
if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
|
||||
if (use_collision && is_root_shape() && root_collision_instance.is_valid()) {
|
||||
PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
|
||||
}
|
||||
}
|
||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||
if (use_collision && is_root_shape() && root_collision_instance.is_valid()) {
|
||||
PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
|
||||
}
|
||||
} break;
|
||||
|
||||
if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) {
|
||||
if (parent) {
|
||||
parent->_make_dirty();
|
||||
}
|
||||
}
|
||||
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
|
||||
if (parent) {
|
||||
parent->_make_dirty();
|
||||
}
|
||||
} break;
|
||||
|
||||
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
|
||||
if (parent) {
|
||||
parent->_make_dirty();
|
||||
}
|
||||
}
|
||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||
if (parent) {
|
||||
parent->_make_dirty();
|
||||
}
|
||||
} break;
|
||||
|
||||
if (p_what == NOTIFICATION_EXIT_TREE) {
|
||||
if (parent) {
|
||||
parent->_make_dirty();
|
||||
}
|
||||
parent = nullptr;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
if (parent) {
|
||||
parent->_make_dirty();
|
||||
}
|
||||
parent = nullptr;
|
||||
|
||||
if (use_collision && is_root_shape() && root_collision_instance.is_valid()) {
|
||||
PhysicsServer3D::get_singleton()->free(root_collision_instance);
|
||||
root_collision_instance = RID();
|
||||
root_collision_shape.unref();
|
||||
}
|
||||
_make_dirty();
|
||||
if (use_collision && is_root_shape() && root_collision_instance.is_valid()) {
|
||||
PhysicsServer3D::get_singleton()->free(root_collision_instance);
|
||||
root_collision_instance = RID();
|
||||
root_collision_shape.unref();
|
||||
}
|
||||
_make_dirty();
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -183,10 +183,12 @@ void GDNativeLibrarySingletonEditor::_item_edited() {
|
|||
}
|
||||
|
||||
void GDNativeLibrarySingletonEditor::_notification(int p_what) {
|
||||
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
|
||||
if (is_visible_in_tree()) {
|
||||
_update_libraries();
|
||||
}
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||
if (is_visible_in_tree()) {
|
||||
_update_libraries();
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -763,17 +763,19 @@ Variant NativeScriptInstance::call(const StringName &p_method, const Variant **p
|
|||
return Variant();
|
||||
}
|
||||
|
||||
void NativeScriptInstance::notification(int p_notification) {
|
||||
void NativeScriptInstance::notification(int p_what) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (p_notification == MainLoop::NOTIFICATION_CRASH) {
|
||||
if (current_method_call != StringName()) {
|
||||
ERR_PRINT("NativeScriptInstance detected crash on method: " + current_method_call);
|
||||
current_method_call = "";
|
||||
}
|
||||
switch (p_what) {
|
||||
case MainLoop::NOTIFICATION_CRASH: {
|
||||
if (current_method_call != StringName()) {
|
||||
ERR_PRINT("NativeScriptInstance detected crash on method: " + current_method_call);
|
||||
current_method_call = "";
|
||||
}
|
||||
} break;
|
||||
}
|
||||
#endif
|
||||
|
||||
Variant value = p_notification;
|
||||
Variant value = p_what;
|
||||
const Variant *args[1] = { &value };
|
||||
Callable::CallError error;
|
||||
call("_notification", args, 1, error);
|
||||
|
|
@ -1639,7 +1641,6 @@ void NativeReloadNode::_bind_methods() {
|
|||
|
||||
void NativeReloadNode::_notification(int p_what) {
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_APPLICATION_FOCUS_OUT: {
|
||||
if (unloaded) {
|
||||
|
|
@ -1672,7 +1673,6 @@ void NativeReloadNode::_notification(int p_what) {
|
|||
}
|
||||
|
||||
unloaded = true;
|
||||
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_APPLICATION_FOCUS_IN: {
|
||||
|
|
@ -1736,10 +1736,7 @@ void NativeReloadNode::_notification(int p_what) {
|
|||
for (Set<StringName>::Element *R = libs_to_remove.front(); R; R = R->next()) {
|
||||
NSL->library_gdnatives.erase(R->get());
|
||||
}
|
||||
|
||||
} break;
|
||||
default: {
|
||||
};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ public:
|
|||
virtual void get_method_list(List<MethodInfo> *p_list) const;
|
||||
virtual bool has_method(const StringName &p_method) const;
|
||||
virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
|
||||
virtual void notification(int p_notification);
|
||||
virtual void notification(int p_what);
|
||||
String to_string(bool *r_valid);
|
||||
virtual Ref<Script> get_script() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -45,17 +45,20 @@ GDScriptLanguageServer::GDScriptLanguageServer() {
|
|||
|
||||
void GDScriptLanguageServer::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
start();
|
||||
break;
|
||||
case NOTIFICATION_EXIT_TREE:
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
stop();
|
||||
break;
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_INTERNAL_PROCESS: {
|
||||
if (started && !use_thread) {
|
||||
protocol.poll();
|
||||
}
|
||||
} break;
|
||||
|
||||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||
String host = String(_EDITOR_GET("network/language_server/remote_host"));
|
||||
int port = (int)_EDITOR_GET("network/language_server/remote_port");
|
||||
|
|
|
|||
|
|
@ -703,8 +703,8 @@ void GridMap::_notification(int p_what) {
|
|||
RS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, get_world_3d()->get_scenario());
|
||||
RS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform());
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||
Transform3D new_xform = get_global_transform();
|
||||
if (new_xform == last_transform) {
|
||||
|
|
@ -721,6 +721,7 @@ void GridMap::_notification(int p_what) {
|
|||
RS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform());
|
||||
}
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_EXIT_WORLD: {
|
||||
for (const KeyValue<OctantKey, Octant *> &E : octant_map) {
|
||||
_octant_exit_world(E.key);
|
||||
|
|
@ -732,8 +733,8 @@ void GridMap::_notification(int p_what) {
|
|||
for (int i = 0; i < baked_meshes.size(); i++) {
|
||||
RS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, RID());
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||
_update_visibility();
|
||||
} break;
|
||||
|
|
|
|||
|
|
@ -1456,15 +1456,17 @@ GridMapEditor::~GridMapEditor() {
|
|||
}
|
||||
|
||||
void GridMapEditorPlugin::_notification(int p_what) {
|
||||
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
|
||||
switch ((int)EditorSettings::get_singleton()->get("editors/grid_map/editor_side")) {
|
||||
case 0: { // Left.
|
||||
Node3DEditor::get_singleton()->move_control_to_left_panel(grid_map_editor);
|
||||
} break;
|
||||
case 1: { // Right.
|
||||
Node3DEditor::get_singleton()->move_control_to_right_panel(grid_map_editor);
|
||||
} break;
|
||||
}
|
||||
switch (p_what) {
|
||||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||
switch ((int)EditorSettings::get_singleton()->get("editors/grid_map/editor_side")) {
|
||||
case 0: { // Left.
|
||||
Node3DEditor::get_singleton()->move_control_to_left_panel(grid_map_editor);
|
||||
} break;
|
||||
case 1: { // Right.
|
||||
Node3DEditor::get_singleton()->move_control_to_right_panel(grid_map_editor);
|
||||
} break;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,10 +46,12 @@ void NavigationMeshEditor::_node_removed(Node *p_node) {
|
|||
}
|
||||
}
|
||||
|
||||
void NavigationMeshEditor::_notification(int p_option) {
|
||||
if (p_option == NOTIFICATION_ENTER_TREE) {
|
||||
button_bake->set_icon(get_theme_icon(SNAME("Bake"), SNAME("EditorIcons")));
|
||||
button_reset->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
|
||||
void NavigationMeshEditor::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
button_bake->set_icon(get_theme_icon(SNAME("Bake"), SNAME("EditorIcons")));
|
||||
button_reset->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class NavigationMeshEditor : public Control {
|
|||
protected:
|
||||
void _node_removed(Node *p_node);
|
||||
static void _bind_methods();
|
||||
void _notification(int p_option);
|
||||
void _notification(int p_what);
|
||||
|
||||
public:
|
||||
void edit(NavigationRegion3D *p_nav_region);
|
||||
|
|
|
|||
|
|
@ -3981,6 +3981,7 @@ void VisualScriptEditor::_notification(int p_what) {
|
|||
_update_graph();
|
||||
}
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||
update_toggle_scripts_button();
|
||||
members_section->set_visible(is_visible_in_tree());
|
||||
|
|
|
|||
|
|
@ -118,9 +118,11 @@ void VisualScriptPropertySelector::_notification(int p_what) {
|
|||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||
_update_icons();
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
connect("confirmed", callable_mp(this, &VisualScriptPropertySelector::_confirmed));
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_PROCESS: {
|
||||
// Update background search.
|
||||
if (search_runner.is_valid()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue