示例#1
0
	resource_address resource_system::resolve_address(
		bool is_file, 
		const char* resource_type_name, 
		const char* folder, 
		const char* extensions, 
		const char* id, 
		const char* id_source_description) {

		if (is_string_empty(id)) {
			ALERT("resource_id is empty.\n\nresource_type: {}\nid_source: {}", resource_type_name, id_source_description);
			return resource_address();
		}

		if (does_id_have_bad_chars(id)) {
			ALERT("resource_id can only contain lowercase alphanumeric chars and _.\n\nresource_type: '{}'\nresource_id: '{}'\nid_source: {}", resource_type_name, id, id_source_description);
			return resource_address();
		}

		for (auto& provider : _providers) {
			auto address = resolve_address_with_provider(is_file, folder, extensions, id, provider);
			if (!address.empty()) {
				return address;
			}
		}

		ALERT("resource not found : {}{}\n\nresource_type: {}\nfolder: {}\nid_source: {}\n\nproviders: {}", id, extensions, resource_type_name, folder, id_source_description, build_newline_seperated_providers_description());
		return resource_address();
	}
示例#2
0
	resource_address resource_system::resolve_address_to_file_in_directory(
		const char* resource_type_name,
		const resource_address& dir_address,
		const char* extensions,
		const char* id) {

		ASSERT(dir_address.is_directory());
		ASSERT(dir_address.get_provider_type() == resource_provider_type::FILE_SYSTEM);

		if (is_string_empty(extensions)) {
			auto file_path = make_file_path(dir_address.get_path(), id);
			if (_file_system.does_file_exist(file_path)) {
				return make_resource_address_with_file_system_provider(true, file_path);
			}
		}

		for (auto& ext : split_string(extensions, ";")) {
			auto file_name = std::string(id) + ext;
			auto file_path = make_file_path(dir_address.get_path(), file_name);
			if (_file_system.does_file_exist(file_path)) {
				return make_resource_address_with_file_system_provider(true, file_path);
			}
		}

		ALERT("resource not found : {}{}\n\nresource_type: {}\ndirectory: {}", id, extensions, resource_type_name, dir_address.get_path());
		return resource_address();
	}
示例#3
0
文件: bmeditor.c 项目: Sohil876/gftp2
static gchar* get_entry_string (GtkEntry *entry)
{
    const gchar *temp;
    gchar *str;

    temp = gtk_entry_get_text (entry);
    if (is_string_empty (temp))
        str = NULL;
    else
        str = g_strstrip (g_strdup (temp));

    return str;
}
示例#4
0
文件: button.cpp 项目: jseward/solar
	void button::render(const window_render_params& params) {
		auto& renderer = params._window_renderer;
		
		auto state = make_best_window_render_state(*this, params);

		renderer.begin_brush_rendering();		
		renderer.render_brush(*this, get_underlay(state), brush_render_mode::STRETCHED);
		renderer.render_brush(*this, _icon, brush_render_mode::STRETCHED, _style.get()._icon_layout);
		renderer.end_brush_rendering();

		const wchar_t* text = get_text();
		if (!is_string_empty(text)) {
			renderer.begin_font_rendering();
			renderer.render_font(*this, _style.get()._font_def, text);
			renderer.end_font_rendering();
		}
	}
示例#5
0
	resource_address resource_system::resolve_address_with_file_system(bool is_file, const char* folder, const char* extensions, const char* id, const std::string& root_path) {
		if (is_file) {
			for (auto& ext : split_string(extensions, ";")) {
				auto file_name = std::string(id) + ext;
				auto file_path = make_file_path(root_path, folder, file_name);
				if (_file_system.does_file_exist(file_path)) {
					return make_resource_address_with_file_system_provider(true, file_path);
				}
			}
		}
		else {
			ASSERT(is_string_empty(extensions));
			auto dir_path = make_file_path(root_path, folder, id);
			if (_file_system.does_directory_exist(dir_path)) {
				return make_resource_address_with_file_system_provider(false, dir_path);
			}
		}
		return resource_address();
	}