コード例 #1
0
void EditorAssetLibrary::_notification(int p_what) {

	switch (p_what) {
		case NOTIFICATION_READY: {

			error_tr->set_texture(get_icon("Error", "EditorIcons"));
			reverse->set_icon(get_icon("Sort", "EditorIcons"));

			error_label->raise();
		} break;

		case NOTIFICATION_VISIBILITY_CHANGED: {

			if (is_visible()) {
				_repository_changed(0); // Update when shown for the first time
			}
		} break;

		case NOTIFICATION_PROCESS: {

			HTTPClient::Status s = request->get_http_client_status();
			bool visible = s != HTTPClient::STATUS_DISCONNECTED;

			if (visible != load_status->is_visible()) {
				load_status->set_visible(visible);
			}

			if (visible) {
				switch (s) {

					case HTTPClient::STATUS_RESOLVING: {
						load_status->set_value(0.1);
					} break;
					case HTTPClient::STATUS_CONNECTING: {
						load_status->set_value(0.2);
					} break;
					case HTTPClient::STATUS_REQUESTING: {
						load_status->set_value(0.3);
					} break;
					case HTTPClient::STATUS_BODY: {
						load_status->set_value(0.4);
					} break;
					default: {}
				}
			}

			bool no_downloads = downloads_hb->get_child_count() == 0;
			if (no_downloads == downloads_scroll->is_visible()) {
				downloads_scroll->set_visible(!no_downloads);
			}

		} break;
		case NOTIFICATION_THEME_CHANGED: {

			library_scroll_bg->add_style_override("panel", get_stylebox("bg", "Tree"));
			error_tr->set_texture(get_icon("Error", "EditorIcons"));
			reverse->set_icon(get_icon("Sort", "EditorIcons"));
		} break;
	}
}
コード例 #2
0
void EditorAssetLibrary::_notification(int p_what) {

	if (p_what==NOTIFICATION_READY) {
		TextureFrame *tf = memnew(TextureFrame);
		tf->set_texture(get_icon("Error","EditorIcons"));
		reverse->set_icon(get_icon("Updown","EditorIcons"));

		error_hb->add_child(tf);
		error_label->raise();
	}

	if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
		if(!is_hidden()) {
			_repository_changed(0); // Update when shown for the first time
		}
	}

	if (p_what==NOTIFICATION_PROCESS) {

		HTTPClient::Status s = request->get_http_client_status();
		bool visible = s!=HTTPClient::STATUS_DISCONNECTED;

		if (visible != !load_status->is_hidden()) {
			load_status->set_hidden(!visible);
		}

		if (visible) {
			switch(s) {

				case HTTPClient::STATUS_RESOLVING: {
					load_status->set_val(0.1);
				} break;
				case HTTPClient::STATUS_CONNECTING: {
					load_status->set_val(0.2);
				} break;
				case HTTPClient::STATUS_REQUESTING: {
					load_status->set_val(0.3);
				} break;
				case HTTPClient::STATUS_BODY: {
					load_status->set_val(0.4);
				} break;
				default: {}

			}
		}

		bool no_downloads = downloads_hb->get_child_count()==0;
		if (no_downloads != downloads_scroll->is_hidden()) {
			downloads_scroll->set_hidden(no_downloads);
		}
	}

}