mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2024-11-10 07:11:54 +00:00
Merge pull request #530 from Pan7/fixedTex
Fixed textures for the texture browser
This commit is contained in:
commit
222adc1c87
3 changed files with 98 additions and 8 deletions
|
@ -105,6 +105,9 @@
|
|||
#define CHASEMOUSE_KEY "ChaseMouse"
|
||||
#define MOUSEWHEELZOOM_KEY "MousewheelZoom"
|
||||
#define ENTITYSHOW_KEY "EntityShow"
|
||||
#define FIXEDTEXSIZE_KEY "UseFixedTextureSize"
|
||||
#define FIXEDTEXSIZEWIDTH_KEY "FixedTextureSizeWidth"
|
||||
#define FIXEDTEXSIZEHEIGHT_KEY "FixedTextureSizeHeight"
|
||||
#define TEXTURESCALE_KEY "TextureScale"
|
||||
#define TEXTURESCROLLBAR_KEY "TextureScrollbar"
|
||||
#define DISPLAYLISTS_KEY "UseDisplayLists"
|
||||
|
@ -628,6 +631,9 @@ PrefsDlg::PrefsDlg (){
|
|||
m_bSelectCurves = TRUE;
|
||||
m_bSelectModels = TRUE;
|
||||
m_nEntityShowState = ENTITY_SKINNED_BOXED;
|
||||
m_bFixedTextureSize = TRUE;
|
||||
m_nFixedTextureSizeWidth = 64;
|
||||
m_nFixedTextureSizeHeight = 64;
|
||||
m_nTextureScale = 2;
|
||||
m_bSwitchClip = FALSE;
|
||||
m_bSelectWholeEntities = TRUE;
|
||||
|
@ -1539,11 +1545,12 @@ void PrefsDlg::BuildDialog(){
|
|||
// Main Preferences dialog
|
||||
GtkWidget *dialog, *mainvbox, *hbox, *sc_win, *preflabel;
|
||||
|
||||
GtkWidget *ftw_label, *fth_label;
|
||||
// Widgets on notebook pages
|
||||
GtkWidget *check, *label, *scale, *hbox2, *combo,
|
||||
*table, *spin, *entry, *pixmap,
|
||||
*radio, *button, *pageframe, *vbox;
|
||||
|
||||
GtkSizeGroup *size_group;
|
||||
GList *combo_list = (GList*)NULL;
|
||||
GList *lst;
|
||||
GtkAdjustment *adj;
|
||||
|
@ -2075,6 +2082,47 @@ void PrefsDlg::BuildDialog(){
|
|||
}
|
||||
g_list_free( combo_list );
|
||||
|
||||
check = gtk_check_button_new_with_label( _( "Use Fixed Texture Size" ) );
|
||||
gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, FALSE, 0 );
|
||||
gtk_widget_show( check );
|
||||
AddDialogData( check, &m_bFixedTextureSize, DLG_CHECK_BOOL );
|
||||
|
||||
hbox2 = gtk_hbox_new( FALSE, 5 );
|
||||
gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, FALSE, 0 );
|
||||
gtk_widget_show( hbox2 );
|
||||
|
||||
ftw_label = label = gtk_label_new( _( "Fixed Texture Wdith" ) );
|
||||
gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 );
|
||||
gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.0 );
|
||||
gtk_widget_show( label );
|
||||
|
||||
spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 1, 1024, 1, 10, 0 ) ), 1, 0 );
|
||||
gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( spin ), TRUE );
|
||||
g_object_set( spin, "xalign", 1.0, NULL );
|
||||
gtk_box_pack_start( GTK_BOX( hbox2 ), spin, FALSE, FALSE, 0 );
|
||||
gtk_widget_show( spin );
|
||||
AddDialogData( spin, &m_nFixedTextureSizeWidth, DLG_SPIN_INT );
|
||||
|
||||
hbox2 = gtk_hbox_new( FALSE, 5 );
|
||||
gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, FALSE, 0 );
|
||||
gtk_widget_show( hbox2 );
|
||||
|
||||
fth_label = label = gtk_label_new( _( "Fixed Texture Height" ) );
|
||||
gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 );
|
||||
gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.0 );
|
||||
gtk_widget_show( label );
|
||||
|
||||
spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 1, 1024, 1, 10, 0 ) ), 1, 0 );
|
||||
gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( spin ), TRUE );
|
||||
g_object_set( spin, "xalign", 1.0, NULL );
|
||||
gtk_box_pack_start( GTK_BOX( hbox2 ), spin, FALSE, FALSE, 0 );
|
||||
gtk_widget_show( spin );
|
||||
AddDialogData( spin, &m_nFixedTextureSizeHeight, DLG_SPIN_INT );
|
||||
|
||||
size_group = gtk_size_group_new( GTK_SIZE_GROUP_HORIZONTAL );
|
||||
gtk_size_group_add_widget( size_group, ftw_label );
|
||||
gtk_size_group_add_widget( size_group, fth_label );
|
||||
g_object_unref( size_group );
|
||||
check = gtk_check_button_new_with_label( _( "Show Texture Directory List" ) );
|
||||
gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, FALSE, 0 );
|
||||
gtk_widget_show( check );
|
||||
|
|
|
@ -650,6 +650,9 @@ int m_nCubicScale;
|
|||
bool m_bSelectCurves;
|
||||
bool m_bSelectModels;
|
||||
int m_nEntityShowState;
|
||||
bool m_bFixedTextureSize;
|
||||
int m_nFixedTextureSizeWidth;
|
||||
int m_nFixedTextureSizeHeight;
|
||||
int m_nTextureScale;
|
||||
bool m_bNormalizeColors;
|
||||
bool m_bSwitchClip;
|
||||
|
|
|
@ -1129,6 +1129,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;
|
||||
|
@ -1195,8 +1233,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;
|
||||
|
@ -1348,8 +1387,9 @@ void SelectTexture( int mx, int my, bool bShift, bool bFitScale ){
|
|||
if ( !q ) {
|
||||
break;
|
||||
}
|
||||
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 ( mx > x && mx - x < nWidth
|
||||
&& my < y && y - my < nHeight + FONT_HEIGHT ) {
|
||||
if ( bShift ) {
|
||||
|
@ -1519,8 +1559,7 @@ void Texture_Draw( int width, int height ){
|
|||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue