Пример #1
0
void Font_Impl::load_font( GraphicContext &context, const FontDescription &desc, const std::string &filename )
{
	free_font();

	if (desc.get_subpixel())
	{
		glyph_cache.enable_subpixel = true;
		glyph_cache.anti_alias = true;	// Implies anti_alias is set
	}
	else
	{
		glyph_cache.enable_subpixel = false;
		glyph_cache.anti_alias = desc.get_anti_alias();
	}

#ifdef WIN32
	std::string path = PathHelp::get_fullpath(filename, PathHelp::path_type_file);
	std::string new_filename = PathHelp::get_filename(filename, PathHelp::path_type_file);
	FileSystem vfs(path);
	font_engine = new FontEngine_Win32(desc, new_filename, vfs);
	glyph_cache.font_metrics = font_engine->get_metrics();
#elif defined(__APPLE__)
    
    font_engine = new FontEngine_Cocoa(desc, filename);
    glyph_cache.font_metrics = font_engine->get_metrics();

#else
	std::string font_file_path = filename;
	if (font_file_path.empty())
	{
	    // Obtain the best matching font file from fontconfig.
		FontConfig &fc = FontConfig::instance();
		font_file_path = fc.match_font(desc);
	}

	std::string path = PathHelp::get_fullpath(font_file_path, PathHelp::path_type_file);
	std::string new_filename = PathHelp::get_filename(font_file_path, PathHelp::path_type_file);
	FileSystem vfs(path);
	IODevice io_dev = vfs.open_file(new_filename);

	int average_width = desc.get_average_width();
	int height = desc.get_height();

	// Ensure width and height are positive
	if (average_width < 0) average_width =-average_width;
	if (height < 0) height =-height;

	font_engine = new FontEngine_Freetype(io_dev, average_width, height);

	glyph_cache.font_metrics = font_engine->get_metrics();

#endif
}
Пример #2
0
void GUIComponent::create_components(const std::string &fullname)
{
	std::string path = PathHelp::get_fullpath(fullname, PathHelp::path_type_file);
	std::string filename = PathHelp::get_filename(fullname, PathHelp::path_type_file);
	FileSystem vfs(path);
	create_components(filename, vfs);
}
Пример #3
0
void CL_ResourceManager::load(const CL_String &fullname)
{
	CL_String path = CL_PathHelp::get_fullpath(fullname, CL_PathHelp::path_type_file);
	CL_String filename = CL_PathHelp::get_filename(fullname, CL_PathHelp::path_type_file);
	CL_VirtualFileSystem vfs(path);
	load(filename, vfs.get_root_directory());
}
Пример #4
0
void XMLResourceDocument::load(const std::string &fullname)
{
	std::string path = PathHelp::get_fullpath(fullname, PathHelp::path_type_file);
	std::string filename = PathHelp::get_filename(fullname, PathHelp::path_type_file);
	FileSystem vfs(path);
	load(filename, vfs);
}
Пример #5
0
void FontProvider_Vector::load_font(const FontDescription &desc, const std::string &filename)
{
#ifdef WIN32
	font_engine = new FontEngine_Win32(desc, filename);
#elif defined(__APPLE__)
	font_engine = new FontEngine_Cocoa(desc, filename);
#else

	std::string font_file_path = filename;
	if (font_file_path.empty())
	{
	    // Obtain the best matching font file from fontconfig.
		FontConfig &fc = FontConfig::instance();
		font_file_path = fc.match_font(desc);
	}

	std::string path = PathHelp::get_fullpath(font_file_path, PathHelp::path_type_file);
	std::string new_filename = PathHelp::get_filename(font_file_path, PathHelp::path_type_file);
	FileSystem vfs(path);
	IODevice io_dev = vfs.open_file(new_filename);

	int average_width = desc.get_average_width();
	int height = desc.get_height();

	// Ensure width and height are positive
	if (average_width < 0) average_width =-average_width;
	if (height < 0) height =-height;

	font_engine = new FontEngine_Freetype(io_dev, average_width, height);
#endif

	metrics = font_engine->get_metrics();
}
Пример #6
0
void CL_GUIComponent::create_components(const CL_StringRef &fullname)
{
	CL_String path = CL_PathHelp::get_fullpath(fullname, CL_PathHelp::path_type_file);
	CL_String filename = CL_PathHelp::get_filename(fullname, CL_PathHelp::path_type_file);
	CL_VirtualFileSystem vfs(path);
	create_components(filename, vfs.get_root_directory());
}
Пример #7
0
Sprite::Sprite(Canvas &canvas, const std::string &fullname, const ImageImportDescription &import_desc)
{
	std::string path = PathHelp::get_fullpath(fullname, PathHelp::path_type_file);
	std::string filename = PathHelp::get_filename(fullname, PathHelp::path_type_file);
	FileSystem vfs(path);
	*this = Sprite(canvas, filename, vfs, import_desc);
}
Пример #8
0
void CL_CollisionOutline::load(const CL_StringRef &fullname)
{
	CL_String path = CL_PathHelp::get_fullpath(fullname, CL_PathHelp::path_type_file);
	CL_String filename = CL_PathHelp::get_filename(fullname, CL_PathHelp::path_type_file);
	CL_VirtualFileSystem vfs(path);
	load(filename, vfs.get_root_directory());
}
Пример #9
0
/* main */
int main(int argc, char * argv[])
{
	int o;
	AppServerOptions options = ASO_LOCAL;
	char * root = "/";
	mode_t mask;
	char * p;

	mask = umask(0);
	umask(mask);
	while((o = getopt(argc, argv, "LRr:u:")) != -1)
		switch(o)
		{
			case 'L':
				options = ASO_LOCAL;
				break;
			case 'R':
				options = ASO_REMOTE;
				break;
			case 'r':
				root = optarg;
				break;
			case 'u':
				mask = strtol(optarg, &p, 0);
				if(optarg[0] == '\0' || *p != '\0')
					return _usage();
				break;
			default:
				return _usage();
		}
	if(optind != argc)
		return _usage();
	return (vfs(options, mask, root) == 0) ? 0 : 2;
}
Пример #10
0
	void CursorDescription::add_frame(const std::string &fullname, const ImageImportDescription &import_desc)
	{
		std::string path = PathHelp::get_fullpath(fullname, PathHelp::path_type_file);
		std::string filename = PathHelp::get_filename(fullname, PathHelp::path_type_file);
		FileSystem vfs(path);
		add_frame(filename, vfs, import_desc);
	}
Пример #11
0
void GameOverState::load_gfx(CL_GraphicContext& gc, std::string skin)
{
	unload_gfx();

	// Getting skins resources
	CL_VirtualFileSystem vfs(skin, true);
	CL_VirtualDirectory vd(vfs, "./");	
	CL_ResourceManager gfx("menu_gameover.xml",vd);

	_dialog_gameover = CL_Sprite(gc, "menu_gameover/dialog_gameover", &gfx);
	_dialog_highscore = CL_Sprite(gc, "menu_gameover/dialog_highscore", &gfx);
	_score1_x = CL_Integer_to_int("menu_gameover/score1_left", &gfx);
	_score1_y = CL_Integer_to_int("menu_gameover/score1_top", &gfx);
	_score2_x = CL_Integer_to_int("menu_gameover/score2_left", &gfx);
	_score2_y = CL_Integer_to_int("menu_gameover/score2_top", &gfx);

	_quit_choice_item.set_gfx(gc, gfx, 
		"menu_gameover/new_game_question/yes/unselected",
		"menu_gameover/new_game_question/yes/selected",
		"menu_gameover/new_game_question/no/unselected",
		"menu_gameover/new_game_question/no/selected");

	_quit_choice_item.set_x(
		CL_Integer_to_int("menu_gameover/new_game_question/yes/left", &gfx));
	_quit_choice_item.set_x2(
		CL_Integer_to_int("menu_gameover/new_game_question/no/left", &gfx));
	_quit_choice_item.set_y(
		CL_Integer_to_int("menu_gameover/new_game_question/yes/top", &gfx));
	_quit_choice_item.set_y2(
		CL_Integer_to_int("menu_gameover/new_game_question/no/top", &gfx));
}
Пример #12
0
	Texture2D::Texture2D(GraphicContext &context, const std::string &fullname, const ImageImportDescription &import_desc)
	{
		std::string path = PathHelp::get_fullpath(fullname, PathHelp::path_type_file);
		std::string filename = PathHelp::get_filename(fullname, PathHelp::path_type_file);
		FileSystem vfs(path);
		*this = Texture2D(context, filename, vfs, import_desc);
	}
Пример #13
0
CL_ShaderObject CL_ShaderObject::load_and_compile(CL_GraphicContext &gc, CL_ShaderType shader_type, const CL_StringRef &fullname)
{
	CL_String path = CL_PathHelp::get_fullpath(fullname, CL_PathHelp::path_type_file);
	CL_String filename = CL_PathHelp::get_filename(fullname, CL_PathHelp::path_type_file);
	CL_VirtualFileSystem vfs(path);
	return CL_ShaderObject::load_and_compile(gc, shader_type, filename, vfs.get_root_directory());
}
Пример #14
0
ShaderObject ShaderObject::load_and_compile(GraphicContext &gc, ShaderType shader_type, const std::string &fullname)
{
	std::string path = PathHelp::get_fullpath(fullname, PathHelp::path_type_file);
	std::string filename = PathHelp::get_filename(fullname, PathHelp::path_type_file);
	FileSystem vfs(path);
	return ShaderObject::load_and_compile(gc, shader_type, filename, vfs);
}
Пример #15
0
    int LuaIOLib::read_line (lua_State *lua, FileHandle *file, int chop) 
    {
        auto process = proc(lua);
        auto &vfs = process->vfs();

        luaL_Buffer b;
        luaL_buffinit(lua, &b);
        for (;;) 
        {
            size_t l;
            char *p = luaL_prepbuffer(&b);
            auto read_result = file->read_till_character('\n', LUAL_BUFFERSIZE, (uint8_t*)p);
            if (read_result.bytes() == 0)
            {
                luaL_pushresult(&b);  /* close buffer */
                return (lua_rawlen(lua, -1) > 0);  /* check whether read something */
            }
            l = strlen(p);

            if (l == 0 || p[l-1] != '\n')
            {
                luaL_addsize(&b, l);
            }
            else 
            {
                luaL_addsize(&b, l - chop);  /* chop 'eol' if needed */
                luaL_pushresult(&b);  /* close buffer */
                return 1;  /* read at least an `eol' */
            }
        }
    }
void CL_FontProvider_Freetype::load_font(const CL_FontDescription &desc)
{
	CL_String path = CL_PathHelp::get_fullpath(desc.get_typeface_name(), CL_PathHelp::path_type_file);
	CL_String filename = CL_PathHelp::get_filename(desc.get_typeface_name(), CL_PathHelp::path_type_file);
	CL_VirtualFileSystem vfs(path);
	CL_IODevice file = vfs.get_root_directory().open_file_read(filename);
	load_font(desc, file);
}
CL_OutlineProviderFile::CL_OutlineProviderFile(const CL_StringRef &fullname)
{
	CL_String path = CL_PathHelp::get_fullpath(fullname, CL_PathHelp::path_type_file);
	CL_String filename = CL_PathHelp::get_filename(fullname, CL_PathHelp::path_type_file);
	CL_VirtualFileSystem vfs(path);
	CL_IODevice file = vfs.get_root_directory().open_file_read(filename);
	impl = CL_SharedPtr<CL_OutlineProviderFile_Generic> (new CL_OutlineProviderFile_Generic( file ));
}
Пример #18
0
CL_Sprite::CL_Sprite(CL_GraphicContext &gc, const CL_StringRef &fullname, const CL_ImageImportDescription &import_desc)
{
	CL_String path = CL_PathHelp::get_fullpath(fullname, CL_PathHelp::path_type_file);
	CL_String filename = CL_PathHelp::get_filename(fullname, CL_PathHelp::path_type_file);
	CL_VirtualFileSystem vfs(path);
	CL_VirtualDirectory dir = vfs.get_root_directory();
	*this = CL_Sprite(gc, filename, dir, import_desc);
}
Пример #19
0
CL_CollisionOutline::CL_CollisionOutline(const CL_StringRef &fullname, int alpha_limit, CL_OutlineAccuracy accuracy, bool get_insides)
{
	CL_String path = CL_PathHelp::get_fullpath(fullname, CL_PathHelp::path_type_file);
	CL_String filename = CL_PathHelp::get_filename(fullname, CL_PathHelp::path_type_file);
	CL_VirtualFileSystem vfs(path);
	CL_VirtualDirectory dir = vfs.get_root_directory();
	*this = CL_CollisionOutline(filename, dir, alpha_limit, accuracy, get_insides);
}
Пример #20
0
void GUIManager::add_theme(const std::string &fullname)
{
	std::string path = PathHelp::get_fullpath(fullname, PathHelp::path_type_file);
	std::string filename = PathHelp::get_filename(fullname, PathHelp::path_type_file);
	FileSystem vfs(path);

	impl->css_document.add_sheet(author_sheet_origin, filename, vfs);
}
Пример #21
0
void TargaProvider::save(
	PixelBuffer buffer,
	const std::string &fullname)
{
	std::string path = PathHelp::get_fullpath(fullname, PathHelp::path_type_file);
	std::string filename = PathHelp::get_filename(fullname, PathHelp::path_type_file);
	FileSystem vfs(path);
	TargaProvider::save(buffer, filename, vfs);
}
Пример #22
0
CL_PixelBuffer CL_PNGProvider::load(
	const CL_String &fullname)
{
	CL_String path = CL_PathHelp::get_fullpath(fullname, CL_PathHelp::path_type_file);
	CL_String filename = CL_PathHelp::get_filename(fullname, CL_PathHelp::path_type_file);
	CL_VirtualFileSystem vfs(path);
	CL_VirtualDirectory dir = vfs.get_root_directory();
	return CL_PNGProvider::load(filename, dir);
}
Пример #23
0
void GUIManager::initialize(GUIWindowManager &window_manager, const std::string &path_to_theme)
{
	FileSystem vfs(path_to_theme);

	impl->resources = XMLResourceManager::create(XMLResourceDocument("resources.xml", vfs));

	set_window_manager(window_manager);
	set_css_document("theme.css", vfs);
}
Пример #24
0
void CL_CollisionOutline::save(const CL_StringRef &fullname) const
{

	CL_String path = CL_PathHelp::get_fullpath(fullname, CL_PathHelp::path_type_file);
	CL_String filename = CL_PathHelp::get_filename(fullname, CL_PathHelp::path_type_file);
	CL_VirtualFileSystem vfs(path);
	CL_VirtualDirectory dir = vfs.get_root_directory();
	save(filename, dir);
}
Пример #25
0
    int LuaIOLib::io_make_dir(lua_State *lua)
    {
        auto process = proc(lua);
        auto filename = luaL_checkstring(lua, 1);

        auto result = process->vfs().create_folder(filename);
        lua_pushinteger(lua, result);

        return 1;
    }
Пример #26
0
    int LuaIOLib::io_delete(lua_State *lua)
    {
        auto process = proc(lua);
        auto filename = luaL_checkstring(lua, 1);

        auto result = process->vfs().remove_entry(filename);
        lua_pushinteger(lua, result);

        return 1;
    }
Пример #27
0
	Font::Font(const FontDescription &desc, const std::string &ttf_filename)
	{
		std::string path = PathHelp::get_fullpath(ttf_filename, PathHelp::path_type_file);
		std::string new_filename = PathHelp::get_filename(ttf_filename, PathHelp::path_type_file);
		FileSystem vfs(path);

		FontFamily font_family(new_filename);
		font_family.add(desc, new_filename, vfs);
		impl = std::make_shared<Font_Impl>(font_family, desc);
	}
Пример #28
0
PixelBuffer ImageProviderFactory::load(
	const std::string &fullname,
	const std::string &type,
	bool srgb)
{
	std::string path = PathHelp::get_fullpath(fullname, PathHelp::path_type_file);
	std::string filename = PathHelp::get_filename(fullname, PathHelp::path_type_file);
	FileSystem vfs(path);
	return ImageProviderFactory::load(filename, vfs, type, srgb);
}
Пример #29
0
void ImageProviderFactory::save(
	PixelBuffer buffer,
	const std::string &fullname,
	const std::string &type)
{
	std::string path = PathHelp::get_fullpath(fullname, PathHelp::path_type_file);
	std::string filename = PathHelp::get_filename(fullname, PathHelp::path_type_file);
	FileSystem vfs(path);
	return ImageProviderFactory::save(buffer, filename, vfs, type);
}
Пример #30
0
	SoundProvider_Wave::SoundProvider_Wave(
		const std::string &fullname, bool stream)
		: impl(std::make_shared<SoundProvider_Wave_Impl>())
	{
		std::string path = PathHelp::get_fullpath(fullname, PathHelp::path_type_file);
		std::string filename = PathHelp::get_filename(fullname, PathHelp::path_type_file);
		FileSystem vfs(path);
		IODevice input = vfs.open_file(filename, File::open_existing, File::access_read, File::share_all);
		impl->load(input);
	}