Ejemplo n.º 1
0
FString I_GetLongPathName(FString shortpath)
{
	static TOptWin32Proc<DWORD (WINAPI*)(LPCTSTR, LPTSTR, DWORD)>
		GetLongPathNameA("kernel32.dll", "GetLongPathNameA");

	// Doesn't exist on NT4
	if (GetLongPathName == NULL)
		return shortpath;

	DWORD buffsize = GetLongPathNameA.Call(shortpath.GetChars(), NULL, 0);
	if (buffsize == 0)
	{ // nothing to change (it doesn't exist, maybe?)
		return shortpath;
	}
	TCHAR *buff = new TCHAR[buffsize];
	DWORD buffsize2 = GetLongPathNameA.Call(shortpath.GetChars(), buff, buffsize);
	if (buffsize2 >= buffsize)
	{ // Failure! Just return the short path
		delete[] buff;
		return shortpath;
	}
	FString longpath(buff, buffsize2);
	delete[] buff;
	return longpath;
}
Ejemplo n.º 2
0
	gfx::SpriteSheet &Context::SpriteSheet(char const *file)
	{
		std::string longpath(TextureFilePath) ;
		longpath += file ;
		char const *path = longpath.c_str() ;

		mSpriteSheets.insert(std::make_pair(path, gfx::SpriteSheet())) ;
		gfx::SpriteSheet &spritesheet = mSpriteSheets.at(path) ;

		spritesheet.Texture = LoadTexture(file) ;

		return spritesheet ;
	}
Ejemplo n.º 3
0
FString I_GetLongPathName(FString shortpath)
{
	DWORD buffsize = GetLongPathName(shortpath.GetChars(), NULL, 0);
	if (buffsize == 0)
	{ // nothing to change (it doesn't exist, maybe?)
		return shortpath;
	}
	TCHAR *buff = new TCHAR[buffsize];
	DWORD buffsize2 = GetLongPathName(shortpath.GetChars(), buff, buffsize);
	if (buffsize2 >= buffsize)
	{ // Failure! Just return the short path
		delete[] buff;
		return shortpath;
	}
	FString longpath(buff, buffsize2);
	delete[] buff;
	return longpath;
}
Ejemplo n.º 4
0
	sf::Texture* Context::LoadTexture(char const *p)
	{
		std::string longpath(TextureFilePath) ;
		longpath += p ;
		char const *path = longpath.c_str() ;

		auto find = mTextures.find(path) ;
		if (find != mTextures.end()) return find->second ;

		sf::Texture *nTexture = new sf::Texture ;
		ASSERT(nTexture, "out of memory!") ;

		bool res = nTexture->loadFromFile(path) ;
		
		ASSERT(res, (std::string( "Could not open file: ") + path).c_str()) ;

		mTextures[path] = nTexture ;
		return nTexture ; 
	}