Fixed Texture Size for the Texture Browser

This commit is contained in:
Pan7 2015-10-12 16:51:38 +02:00
parent 0585822882
commit 51c301b8f7

View file

@ -1224,6 +1224,44 @@ void Texture_ShowStartupShaders(){
============================================================================
*/
void Texture_GetSize( qtexture_t *tex, int & nWidth, int & nHeight ){
if( !tex )
return;
if( g_PrefsDlg.m_bFixedTextureSize && g_PrefsDlg.m_nFixedTextureSizeWidth > 0 && g_PrefsDlg.m_nFixedTextureSizeHeight > 0 )
{
nWidth = g_PrefsDlg.m_nFixedTextureSizeWidth;
nHeight = g_PrefsDlg.m_nFixedTextureSizeHeight;
float ratioWidth = nHeight / nWidth;
float ratioHeight = nWidth / nHeight;
if( tex->width * ratioWidth > tex->height * ratioHeight )
{
nHeight *= tex->height * 1.0f / tex->width * ratioWidth;
} else
if( tex->height * ratioHeight > tex->width * ratioWidth )
{
nWidth *= tex->width * 1.0f / tex->height * ratioHeight;
}
} else {
nWidth = (int)( tex->width * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) );
nHeight = (int)( tex->height * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) );
}
}
void Texture_GetPosSize( qtexture_t *tex, int & nWidth, int & nHeight ){
if( !tex )
return;
if( g_PrefsDlg.m_bFixedTextureSize && g_PrefsDlg.m_nFixedTextureSizeWidth > 0 && g_PrefsDlg.m_nFixedTextureSizeHeight > 0 )
{
nWidth = g_PrefsDlg.m_nFixedTextureSizeWidth;
nHeight = g_PrefsDlg.m_nFixedTextureSizeHeight;
} else {
nWidth = (int)( tex->width * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) );
nHeight = (int)( tex->height * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) );
}
}
void Texture_StartPos( void ){
//++timo TODO: check use of current_texture and current_row?
current_x = 8;
@ -1290,8 +1328,9 @@ IShader* Texture_NextPos( int *x, int *y ){
continue;
}
int nWidth = (int)( q->width * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) );
int nHeight = (int)( q->height * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) );
int nWidth;
int nHeight;
Texture_GetPosSize( q, nWidth, nHeight );
if ( current_x + nWidth > g_qeglobals.d_texturewin.width - 8 && current_row ) { // go to the next row unless the texture is the first on the row
current_x = 8;
current_y -= current_row + FONT_HEIGHT + 4;
@ -1613,14 +1652,8 @@ void Texture_Draw( int width, int height ){
break;
}
if( g_PrefsDlg.m_bFixedTextureSize && g_PrefsDlg.m_nFixedTextureSizeWidth > 0 && g_PrefsDlg.m_nFixedTextureSizeHeight > 0 )
{
nWidth = g_PrefsDlg.m_nFixedTextureSizeWidth;
nHeight = g_PrefsDlg.m_nFixedTextureSizeHeight;
} else {
nWidth = (int)( q->width * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) );
nHeight = (int)( q->height * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) );
}
Texture_GetSize( q, nWidth, nHeight );
if ( y != last_y ) {
last_y = y;
last_height = 0;