Use switch instead of if statement

This commit is contained in:
Nils ANDRÉ-CHANG 2019-07-14 11:26:22 +01:00
parent 584ca0f156
commit 7a1b399df2
1 changed files with 158 additions and 160 deletions

View File

@ -238,14 +238,8 @@ void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) {
void EditorNode::_notification(int p_what) {
if (p_what == NOTIFICATION_EXIT_TREE) {
editor_data.save_editor_external_data();
FileAccess::set_file_close_fail_notify_callback(NULL);
log->deinit(); // do not get messages anymore
}
if (p_what == NOTIFICATION_PROCESS) {
switch (p_what) {
case NOTIFICATION_PROCESS: {
if (opening_prev && !confirmation->is_visible())
opening_prev = false;
@ -284,9 +278,9 @@ void EditorNode::_notification(int p_what) {
scene_root->set_size_override(true, Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height")));
ResourceImporterTexture::get_singleton()->update_imports();
}
if (p_what == NOTIFICATION_ENTER_TREE) {
} break;
case NOTIFICATION_ENTER_TREE: {
Engine::get_singleton()->set_editor_hint(true);
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec")));
@ -298,13 +292,16 @@ void EditorNode::_notification(int p_what) {
get_tree()->connect("files_dropped", this, "_dropped_files");
/* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */
}
if (p_what == NOTIFICATION_EXIT_TREE) {
} break;
case NOTIFICATION_EXIT_TREE: {
editor_data.save_editor_external_data();
FileAccess::set_file_close_fail_notify_callback(NULL);
log->deinit(); // do not get messages anymore
editor_data.clear_edited_scenes();
}
if (p_what == NOTIFICATION_READY) {
} break;
case NOTIFICATION_READY: {
VisualServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport_rid(), true);
VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport_rid(), true);
@ -321,28 +318,28 @@ void EditorNode::_notification(int p_what) {
_update_debug_options();
/* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */
}
} break;
if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) {
case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
// Restore the original FPS cap after focusing back on the editor
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec")));
EditorFileSystem::get_singleton()->scan_changes();
}
} break;
if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_OUT) {
case MainLoop::NOTIFICATION_WM_FOCUS_OUT: {
// Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/unfocused_low_processor_mode_sleep_usec")));
}
} break;
if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) {
case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {
_menu_option_confirm(FILE_QUIT, false);
}
} break;
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
scene_tabs->set_tab_close_display_policy((bool(EDITOR_GET("interface/scene_tabs/always_show_close_button")) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY));
Ref<Theme> theme = create_editor_theme(theme_base->get_theme());
@ -413,10 +410,11 @@ void EditorNode::_notification(int p_what) {
p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_icon("Godot", "EditorIcons"));
_update_update_spinner();
}
} break;
if (p_what == Control::NOTIFICATION_RESIZED) {
case Control::NOTIFICATION_RESIZED: {
_update_scene_tabs();
} break;
}
}