This commit is contained in:
Jonathan Payne
2014-09-07 14:45:04 -07:00
3 changed files with 33 additions and 7 deletions
+9 -2
View File
@@ -26,8 +26,15 @@ static void GetResolutionFromFileName( RString sPath, int &iWidth, int &iHeight
if( !re.Compare(sPath, asMatches) )
return;
iWidth = StringToInt( asMatches[0] );
iHeight = StringToInt( asMatches[1] );
// Check for nonsense values. Some people might not intend the hint. -Kyz
int maybe_width= StringToInt(asMatches[0]);
int maybe_height= StringToInt(asMatches[1]);
if(maybe_width <= 0 || maybe_height <= 0 || maybe_width > iWidth || maybe_height > iHeight)
{
return;
}
iWidth = maybe_width;
iHeight = maybe_height;
}
RageBitmapTexture::RageBitmapTexture( RageTextureID name ) :
+23 -4
View File
@@ -22,7 +22,7 @@ RageTexture::~RageTexture()
void RageTexture::CreateFrameRects()
{
GetFrameDimensionsFromFileName( GetID().filename, &m_iFramesWide, &m_iFramesHigh );
GetFrameDimensionsFromFileName( GetID().filename, &m_iFramesWide, &m_iFramesHigh, m_iSourceWidth, m_iSourceHeight );
// Fill in the m_FrameRects with the bounds of each frame in the animation.
m_TextureCoordRects.clear();
@@ -42,7 +42,7 @@ void RageTexture::CreateFrameRects()
}
}
void RageTexture::GetFrameDimensionsFromFileName( RString sPath, int* piFramesWide, int* piFramesHigh )
void RageTexture::GetFrameDimensionsFromFileName( RString sPath, int* piFramesWide, int* piFramesHigh, int source_width, int source_height )
{
static Regex match( " ([0-9]+)x([0-9]+)([\\. ]|$)" );
vector<RString> asMatch;
@@ -51,8 +51,27 @@ void RageTexture::GetFrameDimensionsFromFileName( RString sPath, int* piFramesWi
*piFramesWide = *piFramesHigh = 1;
return;
}
*piFramesWide = StringToInt(asMatch[0]);
*piFramesHigh = StringToInt(asMatch[1]);
// Check for nonsense values. Some people might not intend the hint. -Kyz
int maybe_width= StringToInt(asMatch[0]);
int maybe_height= StringToInt(asMatch[1]);
if(maybe_width <= 0 || maybe_height <= 0)
{
*piFramesWide = *piFramesHigh = 1;
return;
}
// Font.cpp uses this function, but can't pass in a texture size. Other
// textures can pass in a size though, and having more frames than pixels
// makes no sense. -Kyz
if(source_width > 0 && source_height > 0)
{
if(maybe_width > source_width || maybe_height > source_height)
{
*piFramesWide = *piFramesHigh = 1;
return;
}
}
*piFramesWide = maybe_width;
*piFramesHigh = maybe_height;
}
const RectF *RageTexture::GetTextureCoordRect( int iFrameNo ) const
+1 -1
View File
@@ -61,7 +61,7 @@ public:
// The ID that we were asked to load:
const RageTextureID &GetID() const { return m_ID; }
static void GetFrameDimensionsFromFileName( RString sPath, int* puFramesWide, int* puFramesHigh );
static void GetFrameDimensionsFromFileName( RString sPath, int* puFramesWide, int* puFramesHigh, int source_width= 0, int source_height= 0 );
// Lua
virtual void PushSelf( lua_State *L );