Пример #1
0
String NavigationMeshInstance::get_configuration_warning() const {

	if (!is_visible_in_tree() || !is_inside_tree())
		return String();

	if (!navmesh.is_valid()) {
		return TTR("A NavigationMesh resource must be set or created for this node to work.");
	}
	const Spatial *c = this;
	while (c) {

		if (c->cast_to<Navigation>())
			return String();

		c = c->get_parent()->cast_to<Spatial>();
	}

	return TTR("NavigationMeshInstance must be a child or grandchild to a Navigation node. It only provides navigation data.");
}
Пример #2
0
String NavigationPolygonInstance::get_configuration_warning() const {

	if (!is_visible_in_tree() || !is_inside_tree())
		return String();

	if (!navpoly.is_valid()) {
		return TTR("A NavigationPolygon resource must be set or created for this node to work. Please set a property or draw a polygon.");
	}
	const Node2D *c = this;
	while (c) {

		if (Object::cast_to<Navigation2D>(c)) {
			return String();
		}

		c = Object::cast_to<Node2D>(c->get_parent());
	}

	return TTR("NavigationPolygonInstance must be a child or grandchild to a Navigation2D node. It only provides navigation data.");
}
Пример #3
0
void Spatial::set_gizmo(const Ref<SpatialGizmo> &p_gizmo) {

#ifdef TOOLS_ENABLED

	if (data.gizmo_disabled)
		return;
	if (data.gizmo.is_valid() && is_inside_world())
		data.gizmo->free();
	data.gizmo = p_gizmo;
	if (data.gizmo.is_valid() && is_inside_world()) {

		data.gizmo->create();
		if (is_visible_in_tree()) {
			data.gizmo->redraw();
		}
		data.gizmo->transform();
	}

#endif
}
Пример #4
0
void SceneTreeDialog::_notification(int p_what) {

	if (p_what == NOTIFICATION_ENTER_TREE) {
		connect("confirmed", this, "_select");
	}

	if (p_what == NOTIFICATION_EXIT_TREE) {
		disconnect("confirmed", this, "_select");
	}
	if (p_what == NOTIFICATION_DRAW) {

		RID ci = get_canvas_item();
		get_stylebox("panel", "PopupMenu")->draw(ci, Rect2(Point2(), get_size()));
	}

	if (p_what == NOTIFICATION_VISIBILITY_CHANGED && is_visible_in_tree()) {

		tree->update_tree();
	}
}
Пример #5
0
void CreateDialog::_notification(int p_what) {

	switch (p_what) {
		case NOTIFICATION_ENTER_TREE: {
			connect("confirmed", this, "_confirmed");
			favorite->set_icon(get_icon("Favorites", "EditorIcons"));
		} break;
		case NOTIFICATION_EXIT_TREE: {
			disconnect("confirmed", this, "_confirmed");
		} break;
		case NOTIFICATION_VISIBILITY_CHANGED: {
			if (is_visible_in_tree()) {
				search_box->call_deferred("grab_focus"); // still not visible
				search_box->select_all();
			}
		} break;
		case NOTIFICATION_POPUP_HIDE: {
			EditorSettings::get_singleton()->set("interface/dialogs/create_new_node_bounds", get_rect());
		} break;
	}
}
Пример #6
0
void Popup::_notification(int p_what) {

	if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
		if (popped_up && !is_visible_in_tree()) {
			popped_up = false;
			notification(NOTIFICATION_POPUP_HIDE);
			emit_signal("popup_hide");
		}

		update_configuration_warning();
	}

	if (p_what == NOTIFICATION_ENTER_TREE) {
//small helper to make editing of these easier in editor
#ifdef TOOLS_ENABLED
		if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
			set_as_toplevel(false);
		}
#endif
	}
}
Пример #7
0
void FindReplaceBar::_notification(int p_what) {

	if (p_what == NOTIFICATION_READY) {

		find_prev->set_icon(get_icon("MoveUp", "EditorIcons"));
		find_next->set_icon(get_icon("MoveDown", "EditorIcons"));
		hide_button->set_normal_texture(get_icon("Close", "EditorIcons"));
		hide_button->set_hover_texture(get_icon("Close", "EditorIcons"));
		hide_button->set_pressed_texture(get_icon("Close", "EditorIcons"));

	} else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {

		set_process_unhandled_input(is_visible_in_tree());
	} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {

		find_prev->set_icon(get_icon("MoveUp", "EditorIcons"));
		find_next->set_icon(get_icon("MoveDown", "EditorIcons"));
		hide_button->set_normal_texture(get_icon("Close", "EditorIcons"));
		hide_button->set_hover_texture(get_icon("Close", "EditorIcons"));
		hide_button->set_pressed_texture(get_icon("Close", "EditorIcons"));
	}
}
Пример #8
0
void Container::_notification(int p_what) {

	switch (p_what) {

		case NOTIFICATION_ENTER_TREE: {
			pending_sort = false;
			queue_sort();
		} break;
		case NOTIFICATION_RESIZED: {

			queue_sort();
		} break;
		case NOTIFICATION_THEME_CHANGED: {

			queue_sort();
		} break;
		case NOTIFICATION_VISIBILITY_CHANGED: {

			if (is_visible_in_tree()) {
				queue_sort();
			}
		} break;
	}
}
void AnimationNodeBlendSpace1DEditor::_notification(int p_what) {
	if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
		error_panel->add_style_override("panel", get_stylebox("bg", "Tree"));
		error_label->add_color_override("font_color", get_color("error_color", "Editor"));
		panel->add_style_override("panel", get_stylebox("bg", "Tree"));
		tool_blend->set_icon(get_icon("EditPivot", "EditorIcons"));
		tool_select->set_icon(get_icon("ToolSelect", "EditorIcons"));
		tool_create->set_icon(get_icon("EditKey", "EditorIcons"));
		tool_erase->set_icon(get_icon("Remove", "EditorIcons"));
		snap->set_icon(get_icon("SnapGrid", "EditorIcons"));
		open_editor->set_icon(get_icon("Edit", "EditorIcons"));
	}

	if (p_what == NOTIFICATION_PROCESS) {
		String error;

		if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) {
			error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
		} else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) {
			error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason();
		}

		if (error != error_label->get_text()) {
			error_label->set_text(error);
			if (error != String()) {
				error_panel->show();
			} else {
				error_panel->hide();
			}
		}
	}

	if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
		set_process(is_visible_in_tree());
	}
}
Пример #10
0
void ExportTemplateManager::_notification(int p_what) {

	if (p_what == NOTIFICATION_PROCESS) {

		update_countdown -= get_process_delta_time();

		if (update_countdown > 0) {
			return;
		}
		update_countdown = 0.5;
		String status;
		bool errored = false;

		switch (download_templates->get_http_client_status()) {
			case HTTPClient::STATUS_DISCONNECTED:
				status = TTR("Disconnected");
				errored = true;
				break;
			case HTTPClient::STATUS_RESOLVING: status = TTR("Resolving"); break;
			case HTTPClient::STATUS_CANT_RESOLVE:
				status = TTR("Can't Resolve");
				errored = true;
				break;
			case HTTPClient::STATUS_CONNECTING: status = TTR("Connecting..."); break;
			case HTTPClient::STATUS_CANT_CONNECT:
				status = TTR("Can't Connect");
				errored = true;
				break;
			case HTTPClient::STATUS_CONNECTED: status = TTR("Connected"); break;
			case HTTPClient::STATUS_REQUESTING: status = TTR("Requesting..."); break;
			case HTTPClient::STATUS_BODY:
				status = TTR("Downloading");
				if (download_templates->get_body_size() > 0) {
					status += " " + String::humanize_size(download_templates->get_downloaded_bytes()) + "/" + String::humanize_size(download_templates->get_body_size());
					template_download_progress->set_max(download_templates->get_body_size());
					template_download_progress->set_value(download_templates->get_downloaded_bytes());
				} else {
					status += " " + String::humanize_size(download_templates->get_downloaded_bytes());
				}
				break;
			case HTTPClient::STATUS_CONNECTION_ERROR:
				status = TTR("Connection Error");
				errored = true;
				break;
			case HTTPClient::STATUS_SSL_HANDSHAKE_ERROR:
				status = TTR("SSL Handshake Error");
				errored = true;
				break;
		}

		template_list_state->set_text(status);
		if (errored) {
			set_process(false);
			;
		}
	}

	if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
		if (!is_visible_in_tree()) {
			set_process(false);
		}
	}
}
Пример #11
0
void SoftBody::_update_pickable() {
	if (!is_inside_tree())
		return;
	bool pickable = ray_pickable && is_inside_tree() && is_visible_in_tree();
	PhysicsServer::get_singleton()->soft_body_set_ray_pickable(physics_rid, pickable);
}
Пример #12
0
void CodeTextEditor::_code_complete_timer_timeout() {
	if (!is_visible_in_tree())
		return;
	if (enable_complete_timer)
		text_editor->query_code_comple();
}
Пример #13
0
void EditorAudioBus::_notification(int p_what) {

	if (p_what == NOTIFICATION_READY) {

		for (int i = 0; i < CHANNELS_MAX; i++) {
			channel[i].vu_l->set_under_texture(get_icon("BusVuEmpty", "EditorIcons"));
			channel[i].vu_l->set_progress_texture(get_icon("BusVuFull", "EditorIcons"));
			channel[i].vu_r->set_under_texture(get_icon("BusVuEmpty", "EditorIcons"));
			channel[i].vu_r->set_progress_texture(get_icon("BusVuFull", "EditorIcons"));
			channel[i].prev_active = true;
		}
		scale->set_texture(get_icon("BusVuDb", "EditorIcons"));

		disabled_vu = get_icon("BusVuFrozen", "EditorIcons");

		Color solo_color = Color::html(EditorSettings::get_singleton()->is_dark_theme() ? "#ffe337" : "#ffeb70");
		Color mute_color = Color::html(EditorSettings::get_singleton()->is_dark_theme() ? "#ff2929" : "#ff7070");
		Color bypass_color = Color::html(EditorSettings::get_singleton()->is_dark_theme() ? "#22ccff" : "#70deff");

		solo->set_icon(get_icon("AudioBusSolo", "EditorIcons"));
		solo->add_color_override("icon_color_pressed", solo_color);
		mute->set_icon(get_icon("AudioBusMute", "EditorIcons"));
		mute->add_color_override("icon_color_pressed", mute_color);
		bypass->set_icon(get_icon("AudioBusBypass", "EditorIcons"));
		bypass->add_color_override("icon_color_pressed", bypass_color);

		bus_options->set_icon(get_icon("GuiMiniTabMenu", "EditorIcons"));

		update_bus();
		set_process(true);
	}

	if (p_what == NOTIFICATION_DRAW) {

		if (has_focus()) {
			draw_style_box(get_stylebox("focus", "Button"), Rect2(Vector2(), get_size()));
		} else if (is_master) {
			draw_style_box(get_stylebox("disabled", "Button"), Rect2(Vector2(), get_size()));
		}
	}

	if (p_what == NOTIFICATION_PROCESS) {

		if (cc != AudioServer::get_singleton()->get_bus_channels(get_index())) {
			cc = AudioServer::get_singleton()->get_bus_channels(get_index());
			_update_visible_channels();
		}

		for (int i = 0; i < cc; i++) {
			float real_peak[2] = { -100, -100 };
			bool activity_found = false;

			if (AudioServer::get_singleton()->is_bus_channel_active(get_index(), i)) {
				activity_found = true;
				real_peak[0] = MAX(real_peak[0], AudioServer::get_singleton()->get_bus_peak_volume_left_db(get_index(), i));
				real_peak[1] = MAX(real_peak[1], AudioServer::get_singleton()->get_bus_peak_volume_right_db(get_index(), i));
			}

			if (real_peak[0] > channel[i].peak_l) {
				channel[i].peak_l = real_peak[0];
			} else {
				channel[i].peak_l -= get_process_delta_time() * 60.0;
			}

			if (real_peak[1] > channel[i].peak_r) {
				channel[i].peak_r = real_peak[1];
			} else {
				channel[i].peak_r -= get_process_delta_time() * 60.0;
			}

			channel[i].vu_l->set_value(channel[i].peak_l);
			channel[i].vu_r->set_value(channel[i].peak_r);

			if (activity_found != channel[i].prev_active) {
				if (activity_found) {
					channel[i].vu_l->set_over_texture(Ref<Texture>());
					channel[i].vu_r->set_over_texture(Ref<Texture>());
				} else {
					channel[i].vu_l->set_over_texture(disabled_vu);
					channel[i].vu_r->set_over_texture(disabled_vu);
				}

				channel[i].prev_active = activity_found;
			}
		}
	}

	if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {

		for (int i = 0; i < CHANNELS_MAX; i++) {
			channel[i].peak_l = -100;
			channel[i].peak_r = -100;
			channel[i].prev_active = true;
		}

		set_process(is_visible_in_tree());
	}

	if (p_what == NOTIFICATION_THEME_CHANGED) {

		for (int i = 0; i < CHANNELS_MAX; i++) {
			channel[i].vu_l->set_under_texture(get_icon("BusVuEmpty", "EditorIcons"));
			channel[i].vu_l->set_progress_texture(get_icon("BusVuFull", "EditorIcons"));
			channel[i].vu_r->set_under_texture(get_icon("BusVuEmpty", "EditorIcons"));
			channel[i].vu_r->set_progress_texture(get_icon("BusVuFull", "EditorIcons"));
			channel[i].prev_active = true;
		}
		scale->set_texture(get_icon("BusVuDb", "EditorIcons"));

		disabled_vu = get_icon("BusVuFrozen", "EditorIcons");

		solo->set_icon(get_icon("AudioBusSolo", "EditorIcons"));
		mute->set_icon(get_icon("AudioBusMute", "EditorIcons"));
		bypass->set_icon(get_icon("AudioBusBypass", "EditorIcons"));

		bus_options->set_icon(get_icon("GuiMiniTabMenu", "EditorIcons"));
	}
}
Пример #14
0
void Spatial::_propagate_transform_changed(Spatial *p_origin) {

	if (!is_inside_tree()) {
		return;
	}

	/*
	if (data.dirty&DIRTY_GLOBAL)
		return; //already dirty
	*/

	data.children_lock++;

	for (List<Spatial *>::Element *E = data.children.front(); E; E = E->next()) {

		if (E->get()->data.toplevel_active)
			continue; //don't propagate to a toplevel
		E->get()->_propagate_transform_changed(p_origin);
	}
#ifdef TOOLS_ENABLED
	if ((data.gizmo.is_valid() || data.notify_transform) && !data.ignore_notification && !xform_change.in_list()) {
#else
	if (data.notify_transform && !data.ignore_notification && !xform_change.in_list()) {
#endif
		get_tree()->xform_change_list.add(&xform_change);
	}
	data.dirty |= DIRTY_GLOBAL;

	data.children_lock--;
}

void Spatial::_notification(int p_what) {

	switch (p_what) {
		case NOTIFICATION_ENTER_TREE: {

			Node *p = get_parent();
			if (p)
				data.parent = Object::cast_to<Spatial>(p);

			if (data.parent)
				data.C = data.parent->data.children.push_back(this);
			else
				data.C = NULL;

			if (data.toplevel && !Engine::get_singleton()->is_editor_hint()) {

				if (data.parent) {
					data.local_transform = data.parent->get_global_transform() * get_transform();
					data.dirty = DIRTY_VECTORS; //global is always dirty upon entering a scene
				}
				data.toplevel_active = true;
			}

			data.dirty |= DIRTY_GLOBAL; //global is always dirty upon entering a scene
			_notify_dirty();

			notification(NOTIFICATION_ENTER_WORLD);

		} break;
		case NOTIFICATION_EXIT_TREE: {

			notification(NOTIFICATION_EXIT_WORLD, true);
			if (xform_change.in_list())
				get_tree()->xform_change_list.remove(&xform_change);
			if (data.C)
				data.parent->data.children.erase(data.C);
			data.parent = NULL;
			data.C = NULL;
			data.toplevel_active = false;
		} break;
		case NOTIFICATION_ENTER_WORLD: {

			data.inside_world = true;
			data.viewport = NULL;
			Node *parent = get_parent();
			while (parent && !data.viewport) {
				data.viewport = Object::cast_to<Viewport>(parent);
				parent = parent->get_parent();
			}

			ERR_FAIL_COND(!data.viewport);

			if (get_script_instance()) {

				get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_enter_world, NULL, 0);
			}
#ifdef TOOLS_ENABLED
			if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) {

				//get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this);
				get_tree()->call_group_flags(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
				if (!data.gizmo_disabled) {

					if (data.gizmo.is_valid()) {
						data.gizmo->create();
						if (is_visible_in_tree()) {
							data.gizmo->redraw();
						}
						data.gizmo->transform();
					}
				}
			}
#endif

		} break;
		case NOTIFICATION_EXIT_WORLD: {

#ifdef TOOLS_ENABLED
			if (data.gizmo.is_valid()) {
				data.gizmo->free();
				data.gizmo.unref();
			}
#endif

			if (get_script_instance()) {

				get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_world, NULL, 0);
			}

			data.viewport = NULL;
			data.inside_world = false;

		} break;

		case NOTIFICATION_TRANSFORM_CHANGED: {

#ifdef TOOLS_ENABLED
			if (data.gizmo.is_valid()) {
				data.gizmo->transform();
			}
#endif
		} break;

		default: {
		}
	}
}

void Spatial::set_transform(const Transform &p_transform) {

	data.local_transform = p_transform;
	data.dirty |= DIRTY_VECTORS;
	_change_notify("translation");
	_change_notify("rotation");
	_change_notify("rotation_degrees");
	_change_notify("scale");
	_propagate_transform_changed(this);
	if (data.notify_local_transform) {
		notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED);
	}
}