From 30e25859286cb5e0c32ae902424df570865cd545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Fri, 8 May 2009 11:24:43 +0000 Subject: [PATCH] Allow change of visible name for textures git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5994 383ad7c9-94d9-4d36-a494-682f7c89f535 --- TextureControl.cc | 15 ++++++++++++++- TextureData.cc | 3 ++- TextureData.hh | 6 ++++++ textureProperties.cc | 12 ++++++++++-- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/TextureControl.cc b/TextureControl.cc index 1382589..33b44c0 100644 --- a/TextureControl.cc +++ b/TextureControl.cc @@ -667,6 +667,11 @@ bool TextureControlPlugin::parseMode( QString _mode, Texture& _texture ) { _texture.indexMappingProperty( value ); changed = true; } + }else if ( sectionName == "visiblename" ) { + if ( value != _texture.visibleName() ) { + _texture.visibleName( value ); + changed = true; + } } else if ( sectionName == "type" ) { if ( ( value == "halfedgebased" ) && ( _texture.type() != HALFEDGEBASED ) ) { _texture.type( HALFEDGEBASED ); @@ -769,6 +774,11 @@ void TextureControlPlugin::slotSetTextureMode(QString _textureName ,QString _mod changed = true; } + if ( _mode.contains("visiblename") && (texture.visibleName() != localTex.visibleName() ) ){ + localTex.visibleName( texture.visibleName() ); + changed = true; + } + //only update if the texture is enabled if (changed){ if ( texData->isEnabled(_textureName) ) @@ -1179,7 +1189,10 @@ void TextureControlPlugin::slotUpdateContextMenu( int _objectId ) { if ( texData->textures()[i].hidden() ) continue; - action = actionGroup->addAction( texData->textures()[i].name() ); + if ( !texData->textures()[i].visibleName().isEmpty() ) + action = actionGroup->addAction( texData->textures()[i].visibleName() ); + else + action = actionGroup->addAction( texData->textures()[i].name() ); action->setCheckable(true); diff --git a/TextureData.cc b/TextureData.cc index 88b5ccc..5e9b742 100755 --- a/TextureData.cc +++ b/TextureData.cc @@ -35,6 +35,7 @@ Texture::Texture() : name_("No Texture"), + visibleName_(""), filename_("Invalid"), id_(-1), glName_(0), @@ -294,7 +295,7 @@ int TextureData::getTextureIndex(QString _textureName) // Search the list of textures if we have the texture int textureid = -1; for ( int i = 0 ; i < (int)textures_.size() ; ++i ) { - if ( textures_[i].name() == _textureName ) { + if ( (textures_[i].name() == _textureName) || (textures_[i].visibleName() == _textureName) ) { textureid = i; break; } diff --git a/TextureData.hh b/TextureData.hh index 76881d6..b151c7e 100755 --- a/TextureData.hh +++ b/TextureData.hh @@ -101,6 +101,9 @@ class Texture { void name( QString _name ) { name_ = _name; }; QString name() { return name_; }; + void visibleName( QString _name ) { visibleName_ = _name; }; + QString visibleName() { return visibleName_; }; + void dimension( uint _dimension ) { dimension_ = _dimension; }; uint dimension( ) { return dimension_; }; @@ -142,6 +145,9 @@ class Texture { /// Texture Name QString name_; + /// Name visible in the gui + QString visibleName_; + /// Filename of the texture QString filename_; diff --git a/textureProperties.cc b/textureProperties.cc index 063c444..622c8ba 100644 --- a/textureProperties.cc +++ b/textureProperties.cc @@ -91,9 +91,17 @@ void texturePropertiesWidget::show(TextureData* _texData, int _id, QString _name for (uint i=0; i < texData_->textures().size(); i++) if ( ! texData_->textures()[i].hidden() ) { if ( texData_->textures()[i].type() != MULTITEXTURE ) { - textureList->addTopLevelItem( new QTreeWidgetItem((QTreeWidget*)0, QStringList( texData_->textures()[i].name() ) ) ); + if ( !texData_->textures()[i].visibleName().isEmpty() ) + textureList->addTopLevelItem( new QTreeWidgetItem((QTreeWidget*)0, QStringList( texData_->textures()[i].visibleName() ) ) ); + else + textureList->addTopLevelItem( new QTreeWidgetItem((QTreeWidget*)0, QStringList( texData_->textures()[i].name() ) ) ); } else { - QTreeWidgetItem* parent = new QTreeWidgetItem((QTreeWidget*)0, QStringList( texData_->textures()[i].name() ) ); + QTreeWidgetItem* parent = 0; + if ( !texData_->textures()[i].visibleName().isEmpty() ) + parent = new QTreeWidgetItem((QTreeWidget*)0, QStringList( texData_->textures()[i].visibleName() ) ); + else + parent = new QTreeWidgetItem((QTreeWidget*)0, QStringList( texData_->textures()[i].name() ) ); + textureList->addTopLevelItem( parent ) ; for ( int j = 0 ; j < texData_->textures()[i].multiTextureList.size() ; ++j ) textureList->addTopLevelItem( new QTreeWidgetItem(parent, QStringList(texData_->textures()[i].multiTextureList[j] )) ); -- GitLab