Fix Issue 1413: Local Texture Default Texture Update Settings, Also fix the side issue of the More section not having visible ui at first.

Also I got fed up with the bad code and leaks so I did some refactoring of floaterlocalassetbrowse.*, but just a bit.
This commit is contained in:
Inusaito Sayori
2014-03-27 21:33:21 -04:00
parent 70e92a1cea
commit 039be1f8e9
3 changed files with 289 additions and 390 deletions

View File

@@ -1017,6 +1017,17 @@ Found in Advanced->Rendering->Info Displays</string>
<key>Value</key>
<boolean>1</boolean>
</map>
<key>LocalBitmapUpdate</key>
<map>
<key>Comment</key>
<string>Default setting for whether local textures should update or not upon change, changed by toggling on or off.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<boolean>0</boolean>
</map>
<key>InstantMessageLogPathAnyAccount</key>
<map>
<key>Comment</key>

View File

@@ -72,6 +72,8 @@ this feature is still a work in progress.
#include "llvovolume.h"
#include "llface.h"
/* static pointer to self, wai? oh well. */
static FloaterLocalAssetBrowser* sLFInstance = NULL;
/*=======================================*/
/* Instantiating manager class */
@@ -79,7 +81,7 @@ this feature is still a work in progress.
/*=======================================*/
LocalAssetBrowser* gLocalBrowser;
LocalAssetBrowserTimer* gLocalBrowserTimer;
std::vector<LocalBitmap*> LocalAssetBrowser::loaded_bitmaps;
std::vector<LocalBitmap> LocalAssetBrowser::loaded_bitmaps;
bool LocalAssetBrowser::mLayerUpdated;
bool LocalAssetBrowser::mSculptUpdated;
@@ -93,54 +95,54 @@ bool LocalAssetBrowser::mSculptUpdated;
LocalBitmap::LocalBitmap(std::string fullpath)
{
this->valid = false;
valid = false;
if ( gDirUtilp->fileExists(fullpath) )
{
/* taking care of basic properties */
this->id.generate();
this->filename = fullpath;
this->linkstatus = LINK_OFF;
this->keep_updating = false;
this->shortname = gDirUtilp->getBaseFileName(this->filename, true);
this->bitmap_type = TYPE_TEXTURE;
this->sculpt_dirty = false;
this->volume_dirty = false;
this->valid = false;
id.generate();
filename = fullpath;
keep_updating = gSavedSettings.getBOOL("LocalBitmapUpdate");
linkstatus = keep_updating ? LINK_ON : LINK_OFF;
shortname = gDirUtilp->getBaseFileName(filename, true);
bitmap_type = TYPE_TEXTURE;
sculpt_dirty = false;
volume_dirty = false;
valid = false;
/* taking care of extension type now to avoid switch madness */
std::string temp_exten = gDirUtilp->getExtension(this->filename);
std::string temp_exten = gDirUtilp->getExtension(filename);
if (temp_exten == "bmp") { this->extension = IMG_EXTEN_BMP; }
else if (temp_exten == "tga") { this->extension = IMG_EXTEN_TGA; }
else if (temp_exten == "jpg" || temp_exten == "jpeg") { this->extension = IMG_EXTEN_JPG; }
else if (temp_exten == "png") { this->extension = IMG_EXTEN_PNG; }
else { return; } // no valid extension.
if (temp_exten == "bmp") extension = IMG_EXTEN_BMP;
else if (temp_exten == "tga") extension = IMG_EXTEN_TGA;
else if (temp_exten == "jpg" || temp_exten == "jpeg") extension = IMG_EXTEN_JPG;
else if (temp_exten == "png") extension = IMG_EXTEN_PNG;
else return; // no valid extension.
/* getting file's last modified */
llstat temp_stat;
LLFile::stat(this->filename, &temp_stat);
LLFile::stat(filename, &temp_stat);
std::time_t time = temp_stat.st_mtime;
this->last_modified = asctime( localtime(&time) );
last_modified = asctime( localtime(&time) );
/* checking if the bitmap is valid && decoding if it is */
LLImageRaw* raw_image = new LLImageRaw();
if ( this->decodeSelf(raw_image) )
LLPointer<LLImageRaw> raw_image = new LLImageRaw;
if (decodeSelf(raw_image))
{
/* creating a shell LLViewerTexture and fusing raw image into it */
LLViewerFetchedTexture* viewer_image = new LLViewerFetchedTexture( "file://"+this->filename, this->id, LOCAL_USE_MIPMAPS );
LLViewerFetchedTexture* viewer_image = new LLViewerFetchedTexture( "file://"+filename, id, LOCAL_USE_MIPMAPS );
viewer_image->createGLTexture( LOCAL_DISCARD_LEVEL, raw_image );
viewer_image->setCachedRawImage(-1,raw_image);
/* making damn sure gTextureList will not delete it prematurely */
viewer_image->ref();
viewer_image->ref();
/* finalizing by adding LLViewerTexture instance into gTextureList */
gTextureList.addImage(viewer_image);
/* filename is valid, bitmap is decoded and valid, i can haz liftoff! */
this->valid = true;
valid = true;
}
}
}
@@ -152,60 +154,64 @@ LocalBitmap::~LocalBitmap()
/* [maintenence functions] */
void LocalBitmap::updateSelf()
{
if ( this->linkstatus == LINK_ON || this->linkstatus == LINK_UPDATING )
if (linkstatus == LINK_ON || linkstatus == LINK_UPDATING)
{
/* making sure file still exists */
if ( !gDirUtilp->fileExists(this->filename) ) { this->linkstatus = LINK_BROKEN; return; }
if (!gDirUtilp->fileExists(filename))
{
linkstatus = LINK_BROKEN;
return;
}
/* exists, let's check if it's lastmod has changed */
llstat temp_stat;
LLFile::stat(this->filename, &temp_stat);
LLFile::stat(filename, &temp_stat);
std::time_t temp_time = temp_stat.st_mtime;
LLSD new_last_modified = asctime( localtime(&temp_time) );
if ( this->last_modified.asString() == new_last_modified.asString() ) { return; }
if (last_modified.asString() == new_last_modified.asString()) return;
/* here we update the image */
LLImageRaw* new_imgraw = new LLImageRaw();
if ( !decodeSelf(new_imgraw) ) { this->linkstatus = LINK_UPDATING; return; }
else { this->linkstatus = LINK_ON; }
LLViewerFetchedTexture* image = gTextureList.findImage(this->id);
if (!image->forSculpt())
{ image->createGLTexture( LOCAL_DISCARD_LEVEL, new_imgraw ); }
LLPointer<LLImageRaw> new_imgraw = new LLImageRaw;
if (!decodeSelf(new_imgraw))
{
linkstatus = LINK_UPDATING;
return;
}
else
{ image->setCachedRawImage(-1,new_imgraw); }
{
linkstatus = LINK_ON;
}
LLViewerFetchedTexture* image = gTextureList.findImage(id);
if (!image->forSculpt())
image->createGLTexture(LOCAL_DISCARD_LEVEL, new_imgraw);
else
image->setCachedRawImage(-1,new_imgraw);
/* finalizing by updating lastmod to current */
this->last_modified = new_last_modified;
last_modified = new_last_modified;
/* setting unit property to reflect that it has been changed */
switch (this->bitmap_type)
switch (bitmap_type)
{
case TYPE_TEXTURE:
{ break; }
case TYPE_SCULPT:
{
/* sets a bool to run through all visible sculpts in one go, and update the ones necessary. */
this->sculpt_dirty = true;
this->volume_dirty = true;
gLocalBrowser->setSculptUpdated( true );
break;
}
{
/* sets a bool to run through all visible sculpts in one go, and update the ones necessary. */
sculpt_dirty = true;
volume_dirty = true;
gLocalBrowser->setSculptUpdated( true );
break;
}
case TYPE_LAYER:
{
/* sets a bool to rebake layers after the iteration is done with */
gLocalBrowser->setLayerUpdated( true );
break;
}
{
/* sets a bool to rebake layers after the iteration is done with */
gLocalBrowser->setLayerUpdated( true );
break;
}
case TYPE_TEXTURE:
default:
{ break; }
break;
}
}
@@ -213,51 +219,47 @@ void LocalBitmap::updateSelf()
bool LocalBitmap::decodeSelf(LLImageRaw* rawimg)
{
switch (this->extension)
switch (extension)
{
case IMG_EXTEN_BMP:
{
LLPointer<LLImageBMP> bmp_image = new LLImageBMP;
if ( !bmp_image->load(filename) ) { break; }
if ( !bmp_image->decode(rawimg, 0.0f) ) { break; }
rawimg->biasedScaleToPowerOfTwo( LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT );
return true;
}
{
LLPointer<LLImageBMP> bmp_image = new LLImageBMP;
if (!bmp_image->load(filename)) break;
if (!bmp_image->decode(rawimg, 0.0f)) break;
rawimg->biasedScaleToPowerOfTwo(LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT);
return true;
}
case IMG_EXTEN_TGA:
{
LLPointer<LLImageTGA> tga_image = new LLImageTGA;
if ( !tga_image->load(filename) ) { break; }
if ( !tga_image->decode(rawimg) ) { break; }
if( ( tga_image->getComponents() != 3) &&
( tga_image->getComponents() != 4) ) { break; }
rawimg->biasedScaleToPowerOfTwo( LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT );
return true;
}
{
LLPointer<LLImageTGA> tga_image = new LLImageTGA;
if (!tga_image->load(filename)) break;
if (!tga_image->decode(rawimg)) break;
if (( tga_image->getComponents() != 3) &&
( tga_image->getComponents() != 4) )
break;
rawimg->biasedScaleToPowerOfTwo(LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT);
return true;
}
case IMG_EXTEN_JPG:
{
LLPointer<LLImageJPEG> jpeg_image = new LLImageJPEG;
if ( !jpeg_image->load(filename) ) { break; }
if ( !jpeg_image->decode(rawimg, 0.0f) ) { break; }
rawimg->biasedScaleToPowerOfTwo( LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT );
return true;
}
{
LLPointer<LLImageJPEG> jpeg_image = new LLImageJPEG;
if (!jpeg_image->load(filename)) break;
if (!jpeg_image->decode(rawimg, 0.0f)) break;
rawimg->biasedScaleToPowerOfTwo(LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT);
return true;
}
case IMG_EXTEN_PNG:
{
LLPointer<LLImagePNG> png_image = new LLImagePNG;
if ( !png_image->load(filename) ) { break; }
if ( !png_image->decode(rawimg, 0.0f) ) { break; }
rawimg->biasedScaleToPowerOfTwo( LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT );
return true;
}
{
LLPointer<LLImagePNG> png_image = new LLImagePNG;
if ( !png_image->load(filename) ) break;
if ( !png_image->decode(rawimg, 0.0f) ) break;
rawimg->biasedScaleToPowerOfTwo(LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT);
return true;
}
default:
break;
}
@@ -266,54 +268,55 @@ bool LocalBitmap::decodeSelf(LLImageRaw* rawimg)
void LocalBitmap::setUpdateBool()
{
if ( this->linkstatus != LINK_BROKEN )
if (linkstatus != LINK_BROKEN)
{
if ( !this->keep_updating )
if (!keep_updating)
{
this->linkstatus = LINK_ON;
this->keep_updating = true;
linkstatus = LINK_ON;
keep_updating = true;
}
else
{
this->linkstatus = LINK_OFF;
this->keep_updating = false;
linkstatus = LINK_OFF;
keep_updating = false;
}
}
else
{
this->keep_updating = false;
keep_updating = false;
}
gSavedSettings.setBOOL("LocalBitmapUpdate", keep_updating);
}
void LocalBitmap::setType( S32 type )
{
this->bitmap_type = type;
bitmap_type = type;
}
/* [information query functions] */
std::string LocalBitmap::getShortName()
{
return this->shortname;
return shortname;
}
std::string LocalBitmap::getFileName()
{
return this->filename;
return filename;
}
LLUUID LocalBitmap::getID()
{
return this->id;
return id;
}
LLSD LocalBitmap::getLastModified()
{
return this->last_modified;
return last_modified;
}
std::string LocalBitmap::getLinkStatus()
{
switch(this->linkstatus)
switch(linkstatus)
{
case LINK_ON:
return "On";
@@ -334,22 +337,17 @@ std::string LocalBitmap::getLinkStatus()
bool LocalBitmap::getUpdateBool()
{
return this->keep_updating;
return keep_updating;
}
bool LocalBitmap::getIfValidBool()
{
return this->valid;
}
LocalBitmap* LocalBitmap::getThis()
{
return this;
return valid;
}
S32 LocalBitmap::getType()
{
return this->bitmap_type;
return bitmap_type;
}
std::vector<LLFace*> LocalBitmap::getFaceUsesThis(LLDrawable* drawable)
@@ -360,8 +358,8 @@ std::vector<LLFace*> LocalBitmap::getFaceUsesThis(LLDrawable* drawable)
{
LLFace* newface = drawable->getFace(face_iter);
if ( this->id == newface->getTexture()->getID() )
{ matching_faces.push_back(newface); }
if (id == newface->getTexture()->getID())
matching_faces.push_back(newface);
}
return matching_faces;
@@ -389,10 +387,10 @@ std::vector<affected_object> LocalBitmap::getUsingObjects(bool seek_by_type, boo
if ( obj && obj->mDrawable )
{
/* looking for textures */
if ( seek_textures || ( seek_by_type && this->bitmap_type == TYPE_TEXTURE ) )
if (seek_textures || (seek_by_type && bitmap_type == TYPE_TEXTURE))
{
std::vector<LLFace*> affected_faces = this->getFaceUsesThis( obj->mDrawable );
if ( !affected_faces.empty() )
std::vector<LLFace*> affected_faces = getFaceUsesThis(obj->mDrawable);
if (!affected_faces.empty())
{
shell.face_list = affected_faces;
obj_relevant = true;
@@ -400,22 +398,18 @@ std::vector<affected_object> LocalBitmap::getUsingObjects(bool seek_by_type, boo
}
/* looking for sculptmaps */
if ( ( seek_sculptmaps || ( seek_by_type && this->bitmap_type == TYPE_SCULPT ) )
&& obj->isSculpted() && obj->getVolume()
&& this->id == obj->getVolume()->getParams().getSculptID()
)
if ((seek_sculptmaps || (seek_by_type && bitmap_type == TYPE_SCULPT))
&& obj->isSculpted() && obj->getVolume()
&& id == obj->getVolume()->getParams().getSculptID())
{
shell.local_sculptmap = true;
obj_relevant = true;
}
}
if (obj_relevant)
{ affected_vector.push_back(shell); }
if (obj_relevant) affected_vector.push_back(shell);
}
return affected_vector;
}
@@ -423,15 +417,15 @@ void LocalBitmap::getDebugInfo()
{
/* debug function: dumps everything human readable into llinfos */
llinfos << "===[local bitmap debug]===" << "\n"
<< "path: " << this->filename << "\n"
<< "name: " << this->shortname << "\n"
<< "extension: " << this->extension << "\n"
<< "uuid: " << this->id << "\n"
<< "last modified: " << this->last_modified << "\n"
<< "link status: " << this->getLinkStatus() << "\n"
<< "keep updated: " << this->keep_updating << "\n"
<< "type: " << this->bitmap_type << "\n"
<< "is valid: " << this->valid << "\n"
<< "path: " << filename << "\n"
<< "name: " << shortname << "\n"
<< "extension: " << extension << "\n"
<< "uuid: " << id << "\n"
<< "last modified: " << last_modified << "\n"
<< "link status: " << getLinkStatus() << "\n"
<< "keep updated: " << keep_updating << "\n"
<< "type: " << bitmap_type << "\n"
<< "is valid: " << valid << "\n"
<< "==========================" << llendl;
}
@@ -447,8 +441,8 @@ void LocalBitmap::getDebugInfo()
LocalAssetBrowser::LocalAssetBrowser()
{
this->mLayerUpdated = false;
this->mSculptUpdated = false;
mLayerUpdated = false;
mSculptUpdated = false;
}
LocalAssetBrowser::~LocalAssetBrowser()
@@ -472,17 +466,15 @@ void LocalAssetBrowser::AddBitmap_continued(AIFilePicker* filepicker)
std::vector<std::string> const& filenames(filepicker->getFilenames());
for(std::vector<std::string>::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename)
{
LocalBitmap* unit = new LocalBitmap(*filename);
if ( unit->getIfValidBool() )
LocalBitmap unit(*filename);
if (unit.getIfValidBool())
{
loaded_bitmaps.push_back( unit );
loaded_bitmaps.push_back(unit);
change_happened = true;
}
}
if ( change_happened )
{ onChangeHappened(); }
if (change_happened) onChangeHappened();
}
void LocalAssetBrowser::DelBitmap( std::vector<LLScrollListItem*> delete_vector, S32 column )
@@ -498,34 +490,26 @@ void LocalAssetBrowser::DelBitmap( std::vector<LLScrollListItem*> delete_vector,
for (local_list_iter iter = loaded_bitmaps.begin();
iter != loaded_bitmaps.end();)
{
LocalBitmap* unit = (*iter)->getThis();
if ( unit->getID() == id )
if ((*iter).getID() == id)
{
LLViewerFetchedTexture* image = gTextureList.findImage(id);
gTextureList.deleteImage( image );
image->unref();
iter = loaded_bitmaps.erase(iter);
delete unit;
unit = NULL;
change_happened = true;
}
else
{ iter++; }
++iter;
}
}
}
if ( change_happened )
{ onChangeHappened(); }
if (change_happened) onChangeHappened();
}
void LocalAssetBrowser::onUpdateBool(LLUUID id)
{
LocalBitmap* unit = GetBitmapUnit( id );
if ( unit )
if (LocalBitmap* unit = GetBitmapUnit(id))
{
unit->setUpdateBool();
PingTimer();
@@ -534,32 +518,22 @@ void LocalAssetBrowser::onUpdateBool(LLUUID id)
void LocalAssetBrowser::onSetType(LLUUID id, S32 type)
{
LocalBitmap* unit = GetBitmapUnit( id );
if ( unit )
{ unit->setType(type); }
if (LocalBitmap* unit = GetBitmapUnit(id)) unit->setType(type);
}
LocalBitmap* LocalAssetBrowser::GetBitmapUnit(LLUUID id)
{
local_list_iter iter = loaded_bitmaps.begin();
for (; iter != loaded_bitmaps.end(); iter++)
{
if ( (*iter)->getID() == id )
{
return (*iter)->getThis();
}
}
for (local_list_iter iter = loaded_bitmaps.begin(); iter != loaded_bitmaps.end(); ++iter)
if ((*iter).getID() == id)
return &(*iter);
return NULL;
}
bool LocalAssetBrowser::IsDoingUpdates()
{
local_list_iter iter = loaded_bitmaps.begin();
for (; iter != loaded_bitmaps.end(); iter++)
for (local_list_iter iter = loaded_bitmaps.begin(); iter != loaded_bitmaps.end(); iter++)
{
if ( (*iter)->getUpdateBool() )
{ return true; } /* if at least one unit in the list needs updates - we need a timer. */
if ((*iter).getUpdateBool()) return true; /* if at least one unit in the list needs updates - we need a timer. */
}
return false;
@@ -572,7 +546,7 @@ bool LocalAssetBrowser::IsDoingUpdates()
void LocalAssetBrowser::onChangeHappened()
{
/* own floater update */
FloaterLocalAssetBrowser::UpdateBitmapScrollList();
if (sLFInstance) sLFInstance->UpdateBitmapScrollList();
/* texturepicker related */
const LLView::child_list_t* child_list = gFloaterView->getChildList();
@@ -599,44 +573,37 @@ void LocalAssetBrowser::onChangeHappened()
void LocalAssetBrowser::PingTimer()
{
if ( !loaded_bitmaps.empty() && IsDoingUpdates() )
if (!loaded_bitmaps.empty() && IsDoingUpdates())
{
if (!gLocalBrowserTimer)
{ gLocalBrowserTimer = new LocalAssetBrowserTimer(); }
if ( !gLocalBrowserTimer->isRunning() )
{ gLocalBrowserTimer->start(); }
if (!gLocalBrowserTimer)
gLocalBrowserTimer = new LocalAssetBrowserTimer();
if (!gLocalBrowserTimer->isRunning())
gLocalBrowserTimer->start();
}
else
else if (gLocalBrowserTimer && gLocalBrowserTimer->isRunning())
{
if (gLocalBrowserTimer)
{
if ( gLocalBrowserTimer->isRunning() )
{ gLocalBrowserTimer->stop(); }
}
gLocalBrowserTimer->stop();
}
}
/* This function refills the texture picker floater's scrolllist with the updated contents of bitmaplist */
void LocalAssetBrowser::UpdateTextureCtrlList(LLScrollListCtrl* ctrl)
{
if ( ctrl ) // checking again in case called externally for some silly reason.
if (ctrl) // checking again in case called externally for some silly reason.
{
ctrl->clearRows();
if ( !loaded_bitmaps.empty() )
{
local_list_iter iter = loaded_bitmaps.begin();
for ( ; iter != loaded_bitmaps.end(); iter++ )
for (local_list_iter iter = loaded_bitmaps.begin(); iter != loaded_bitmaps.end(); ++iter)
{
LLSD element;
element["columns"][0]["column"] = "unit_name";
element["columns"][0]["type"] = "text";
element["columns"][0]["value"] = (*iter)->shortname;
element["columns"][0]["value"] = (*iter).shortname;
element["columns"][1]["column"] = "unit_id_HIDDEN";
element["columns"][1]["type"] = "text";
element["columns"][1]["value"] = (*iter)->id;
element["columns"][1]["value"] = (*iter).id;
ctrl->addElement(element);
}
@@ -644,73 +611,58 @@ void LocalAssetBrowser::UpdateTextureCtrlList(LLScrollListCtrl* ctrl)
}
}
void LocalAssetBrowser::PerformTimedActions(void)
void LocalAssetBrowser::PerformTimedActions()
{
// perform checking if updates are needed && update if so.
local_list_iter iter;
for (iter = loaded_bitmaps.begin(); iter != loaded_bitmaps.end(); iter++)
{ (*iter)->updateSelf(); }
// one or more sculpts have been updated, refreshing them.
if ( mSculptUpdated )
for (local_list_iter iter = loaded_bitmaps.begin(); iter != loaded_bitmaps.end(); ++iter)
{
LocalAssetBrowser::local_list_iter iter;
for(iter = loaded_bitmaps.begin(); iter != loaded_bitmaps.end(); iter++)
(*iter).updateSelf();
// one or more sculpts have been updated, refreshing them.
if (mSculptUpdated && (*iter).sculpt_dirty)
{
if ( (*iter)->sculpt_dirty )
{
PerformSculptUpdates( (*iter)->getThis() );
(*iter)->sculpt_dirty = false;
}
PerformSculptUpdates(*iter);
(*iter).sculpt_dirty = false;
}
mSculptUpdated = false;
}
mSculptUpdated = false;
// one of the layer bitmaps has been updated, we need to rebake.
if ( mLayerUpdated )
if (mLayerUpdated)
{
if (isAgentAvatarValid())
{
if (isAgentAvatarValid())
gAgentAvatarp->forceBakeAllTextures(SLAM_FOR_DEBUG);
}
mLayerUpdated = false;
}
}
void LocalAssetBrowser::PerformSculptUpdates(LocalBitmap* unit)
void LocalAssetBrowser::PerformSculptUpdates(LocalBitmap& unit)
{
/* looking for sculptmap using objects only */
std::vector<affected_object> object_list = unit->getUsingObjects(false, false, true);
std::vector<affected_object> object_list = unit.getUsingObjects(false, false, true);
if (object_list.empty()) { return; }
for( std::vector<affected_object>::iterator iter = object_list.begin();
iter != object_list.end(); iter++ )
{
affected_object aobj = *iter;
if ( aobj.object )
if (aobj.object)
{
if ( !aobj.local_sculptmap ) { continue; } // should never get here. only in case of misuse.
if (!aobj.local_sculptmap) continue; // should never get here. only in case of misuse.
// update code [begin]
if ( unit->volume_dirty )
if (unit.volume_dirty)
{
LLImageRaw* rawimage = gTextureList.findImage( unit->getID() )->getCachedRawImage();
LLImageRaw* rawimage = gTextureList.findImage(unit.getID())->getCachedRawImage();
aobj.object->getVolume()->sculpt(rawimage->getWidth(), rawimage->getHeight(),
rawimage->getComponents(), rawimage->getData(), 0);
unit->volume_dirty = false;
aobj.object->getVolume()->sculpt(rawimage->getWidth(), rawimage->getHeight(), rawimage->getComponents(), rawimage->getData(), 0);
unit.volume_dirty = false;
}
// tell affected drawable it's got updated
aobj.object->mDrawable->getVOVolume()->setSculptChanged( true );
aobj.object->mDrawable->getVOVolume()->markForUpdate( true );
// tell affected drawable it's got updated
aobj.object->mDrawable->getVOVolume()->setSculptChanged(true);
aobj.object->mDrawable->getVOVolume()->markForUpdate(true);
// update code [end]
}
}
}
/*==================================================*/
@@ -722,36 +674,6 @@ void LocalAssetBrowser::PerformSculptUpdates(LocalBitmap* unit)
Destroyed when the floater is closed.
*/
// Floater Globals
FloaterLocalAssetBrowser* FloaterLocalAssetBrowser::sLFInstance = NULL;
// widgets:
LLButton* mAddBtn;
LLButton* mDelBtn;
LLButton* mMoreBtn;
LLButton* mLessBtn;
LLButton* mUploadBtn;
LLScrollListCtrl* mBitmapList;
LLTextureCtrl* mTextureView;
LLCheckBoxCtrl* mUpdateChkBox;
LLLineEditor* mPathTxt;
LLLineEditor* mUUIDTxt;
LLLineEditor* mNameTxt;
LLTextBox* mLinkTxt;
LLTextBox* mTimeTxt;
LLComboBox* mTypeComboBox;
LLTextBox* mCaptionPathTxt;
LLTextBox* mCaptionUUIDTxt;
LLTextBox* mCaptionLinkTxt;
LLTextBox* mCaptionNameTxt;
LLTextBox* mCaptionTimeTxt;
FloaterLocalAssetBrowser::FloaterLocalAssetBrowser()
: LLFloater(std::string("local_bitmap_browser_floater"))
{
@@ -791,12 +713,15 @@ FloaterLocalAssetBrowser::FloaterLocalAssetBrowser()
mDelBtn->setEnabled( false );
mUploadBtn->setEnabled( false );
// Initialize visibility
FloaterResize(true);
// setting button callbacks:
mAddBtn->setClickedCallback( onClickAdd, this);
mDelBtn->setClickedCallback( onClickDel, this);
mMoreBtn->setClickedCallback( onClickMore, this);
mLessBtn->setClickedCallback( onClickLess, this);
mUploadBtn->setClickedCallback( onClickUpload, this);
mAddBtn->setClickedCallback(boost::bind(&FloaterLocalAssetBrowser::onClickAdd, this));
mDelBtn->setClickedCallback(boost::bind(&FloaterLocalAssetBrowser::onClickDel, this));
mMoreBtn->setClickedCallback(boost::bind(&FloaterLocalAssetBrowser::FloaterResize, this, true));
mLessBtn->setClickedCallback(boost::bind(&FloaterLocalAssetBrowser::FloaterResize, this, false));
mUploadBtn->setClickedCallback(boost::bind(&FloaterLocalAssetBrowser::onClickUpload, this));
// combo callback
mTypeComboBox->setCommitCallback(boost::bind(&FloaterLocalAssetBrowser::onCommitTypeCombo,this));
@@ -806,48 +731,35 @@ FloaterLocalAssetBrowser::FloaterLocalAssetBrowser()
// checkbox callbacks
mUpdateChkBox->setCommitCallback(boost::bind(&FloaterLocalAssetBrowser::onClickUpdateChkbox,this));
}
void FloaterLocalAssetBrowser::show(void*)
{
if (!sLFInstance)
sLFInstance = new FloaterLocalAssetBrowser();
sLFInstance->open();
if (!sLFInstance)
sLFInstance = new FloaterLocalAssetBrowser();
sLFInstance->open();
sLFInstance->UpdateBitmapScrollList();
}
FloaterLocalAssetBrowser::~FloaterLocalAssetBrowser()
{
sLFInstance=NULL;
sLFInstance = NULL;
}
void FloaterLocalAssetBrowser::onClickAdd(void* userdata)
void FloaterLocalAssetBrowser::onClickAdd()
{
gLocalBrowser->AddBitmap();
}
void FloaterLocalAssetBrowser::onClickDel(void* userdata)
void FloaterLocalAssetBrowser::onClickDel()
{
gLocalBrowser->DelBitmap( sLFInstance->mBitmapList->getAllSelected() );
gLocalBrowser->DelBitmap(mBitmapList->getAllSelected());
}
/* what stopped me from using a single button and simply changing it's label
is the fact that i'd need to hardcode the button labels here, and that is griff. */
void FloaterLocalAssetBrowser::onClickMore(void* userdata)
{
FloaterResize(true);
}
void FloaterLocalAssetBrowser::onClickLess(void* userdata)
{
FloaterResize(false);
}
void FloaterLocalAssetBrowser::onClickUpload(void* userdata)
void FloaterLocalAssetBrowser::onClickUpload()
{
std::string filename = gLocalBrowser->GetBitmapUnit(
(LLUUID)sLFInstance->mBitmapList->getSelectedItemLabel(BITMAPLIST_COL_ID) )->getFileName();
(LLUUID)mBitmapList->getSelectedItemLabel(BITMAPLIST_COL_ID) )->getFileName();
if ( !filename.empty() )
{
@@ -879,71 +791,59 @@ void FloaterLocalAssetBrowser::onCommitTypeCombo()
{
std::string temp_str = mBitmapList->getSelectedItemLabel(BITMAPLIST_COL_ID);
if ( !temp_str.empty() )
if (!temp_str.empty())
{
S32 selection = sLFInstance->mTypeComboBox->getCurrentIndex();
gLocalBrowser->onSetType( (LLUUID)temp_str, selection );
S32 selection = mTypeComboBox->getCurrentIndex();
gLocalBrowser->onSetType((LLUUID)temp_str, selection);
}
}
void FloaterLocalAssetBrowser::FloaterResize(bool expand)
{
sLFInstance->mMoreBtn->setVisible(!expand);
sLFInstance->mLessBtn->setVisible(expand);
sLFInstance->mTextureView->setVisible(expand);
sLFInstance->mUpdateChkBox->setVisible(expand);
sLFInstance->mCaptionPathTxt->setVisible(expand);
sLFInstance->mCaptionUUIDTxt->setVisible(expand);
sLFInstance->mCaptionLinkTxt->setVisible(expand);
sLFInstance->mCaptionNameTxt->setVisible(expand);
sLFInstance->mCaptionTimeTxt->setVisible(expand);
sLFInstance->mTypeComboBox->setVisible(expand);
mMoreBtn->setVisible(!expand);
mLessBtn->setVisible(expand);
mTextureView->setVisible(expand);
mUpdateChkBox->setVisible(expand);
mCaptionPathTxt->setVisible(expand);
mCaptionUUIDTxt->setVisible(expand);
mCaptionLinkTxt->setVisible(expand);
mCaptionNameTxt->setVisible(expand);
mCaptionTimeTxt->setVisible(expand);
mTypeComboBox->setVisible(expand);
sLFInstance->mTimeTxt->setVisible(expand);
sLFInstance->mPathTxt->setVisible(expand);
sLFInstance->mUUIDTxt->setVisible(expand);
sLFInstance->mLinkTxt->setVisible(expand);
sLFInstance->mNameTxt->setVisible(expand);
if(expand)
{
sLFInstance->reshape(LF_FLOATER_EXPAND_WIDTH, LF_FLOATER_HEIGHT);
sLFInstance->setResizeLimits(LF_FLOATER_EXPAND_WIDTH, LF_FLOATER_HEIGHT);
sLFInstance->UpdateRightSide();
}
else
{
sLFInstance->reshape(LF_FLOATER_CONTRACT_WIDTH, LF_FLOATER_HEIGHT);
sLFInstance->setResizeLimits(LF_FLOATER_CONTRACT_WIDTH, LF_FLOATER_HEIGHT);
}
mTimeTxt->setVisible(expand);
mPathTxt->setVisible(expand);
mUUIDTxt->setVisible(expand);
mLinkTxt->setVisible(expand);
mNameTxt->setVisible(expand);
reshape(expand ? LF_FLOATER_EXPAND_WIDTH : LF_FLOATER_CONTRACT_WIDTH, LF_FLOATER_HEIGHT);
setResizeLimits(expand ? LF_FLOATER_EXPAND_WIDTH : LF_FLOATER_CONTRACT_WIDTH, LF_FLOATER_HEIGHT);
if (expand) UpdateRightSide();
}
void FloaterLocalAssetBrowser::UpdateBitmapScrollList()
{
if ( !sLFInstance ) { return; }
sLFInstance->mBitmapList->clearRows();
mBitmapList->clearRows();
if (!gLocalBrowser->loaded_bitmaps.empty())
{
LocalAssetBrowser::local_list_iter iter;
for(iter = gLocalBrowser->loaded_bitmaps.begin(); iter != gLocalBrowser->loaded_bitmaps.end(); iter++)
{
LLSD element;
element["columns"][BITMAPLIST_COL_NAME]["column"] = "bitmap_name";
element["columns"][BITMAPLIST_COL_NAME]["type"] = "text";
element["columns"][BITMAPLIST_COL_NAME]["value"] = (*iter)->getShortName();
element["columns"][BITMAPLIST_COL_NAME]["value"] = (*iter).getShortName();
element["columns"][BITMAPLIST_COL_ID]["column"] = "bitmap_uuid";
element["columns"][BITMAPLIST_COL_ID]["type"] = "text";
element["columns"][BITMAPLIST_COL_ID]["value"] = (*iter)->getID();
element["columns"][BITMAPLIST_COL_ID]["value"] = (*iter).getID();
sLFInstance->mBitmapList->addElement(element);
mBitmapList->addElement(element);
}
}
sLFInstance->onChooseBitmapList();
onChooseBitmapList();
}
void FloaterLocalAssetBrowser::UpdateRightSide()
@@ -951,47 +851,45 @@ void FloaterLocalAssetBrowser::UpdateRightSide()
/*
Since i'm not keeping a bool on if the floater is expanded or not, i'll
just check if one of the widgets that shows when the floater is expanded is visible.
Also obviously before updating - checking if something IS actually selected :o
*/
if (!mTextureView->getVisible()) return;
if ( !sLFInstance->mTextureView->getVisible() ) { return; }
if ( !sLFInstance->mBitmapList->getAllSelected().empty() )
{
LocalBitmap* unit = gLocalBrowser->GetBitmapUnit( LLUUID(sLFInstance->mBitmapList->getSelectedItemLabel(BITMAPLIST_COL_ID)) );
if (!mBitmapList->getAllSelected().empty())
{
LocalBitmap* unit = gLocalBrowser->GetBitmapUnit( LLUUID(mBitmapList->getSelectedItemLabel(BITMAPLIST_COL_ID)) );
if ( unit )
{
sLFInstance->mTextureView->setImageAssetID( unit->getID() );
sLFInstance->mUpdateChkBox->set( unit->getUpdateBool() );
sLFInstance->mPathTxt->setText( unit->getFileName() );
sLFInstance->mUUIDTxt->setText( unit->getID().asString() );
sLFInstance->mNameTxt->setText( unit->getShortName() );
sLFInstance->mTimeTxt->setText( unit->getLastModified().asString() );
sLFInstance->mLinkTxt->setText( unit->getLinkStatus() );
sLFInstance->mTypeComboBox->selectNthItem( unit->getType() );
mTextureView->setImageAssetID(unit->getID());
mUpdateChkBox->set(unit->getUpdateBool());
mPathTxt->setText(unit->getFileName());
mUUIDTxt->setText(unit->getID().asString());
mNameTxt->setText(unit->getShortName());
mTimeTxt->setText(unit->getLastModified().asString());
mLinkTxt->setText(unit->getLinkStatus());
mTypeComboBox->selectNthItem(unit->getType());
sLFInstance->mTextureView->setEnabled(true);
sLFInstance->mUpdateChkBox->setEnabled(true);
sLFInstance->mTypeComboBox->setEnabled(true);
mTextureView->setEnabled(true);
mUpdateChkBox->setEnabled(true);
mTypeComboBox->setEnabled(true);
}
}
else
{
sLFInstance->mTextureView->setImageAssetID( NO_IMAGE );
sLFInstance->mTextureView->setEnabled( false );
sLFInstance->mUpdateChkBox->set( false );
sLFInstance->mUpdateChkBox->setEnabled( false );
mTextureView->setImageAssetID(NO_IMAGE);
mTextureView->setEnabled(false);
mUpdateChkBox->set(false);
mUpdateChkBox->setEnabled(false);
sLFInstance->mTypeComboBox->selectFirstItem();
sLFInstance->mTypeComboBox->setEnabled( false );
sLFInstance->mPathTxt->setText( LLStringExplicit("None") );
sLFInstance->mUUIDTxt->setText( LLStringExplicit("None") );
sLFInstance->mNameTxt->setText( LLStringExplicit("None") );
sLFInstance->mLinkTxt->setText( LLStringExplicit("None") );
sLFInstance->mTimeTxt->setText( LLStringExplicit("None") );
mTypeComboBox->selectFirstItem();
mTypeComboBox->setEnabled(false);
mPathTxt->setText(LLStringExplicit("None"));
mUUIDTxt->setText(LLStringExplicit("None"));
mNameTxt->setText(LLStringExplicit("None"));
mLinkTxt->setText(LLStringExplicit("None"));
mTimeTxt->setText(LLStringExplicit("None"));
}
}

View File

@@ -98,7 +98,7 @@ class LocalBitmap
{
public:
LocalBitmap(std::string filename);
virtual ~LocalBitmap(void);
virtual ~LocalBitmap();
friend class LocalAssetBrowser;
public: /* [enums, typedefs, etc] */
@@ -127,23 +127,22 @@ class LocalBitmap
};
public: /* [information query functions] */
std::string getShortName(void);
std::string getFileName(void);
LLUUID getID(void);
LLSD getLastModified(void);
std::string getLinkStatus(void);
bool getUpdateBool(void);
std::string getShortName();
std::string getFileName();
LLUUID getID();
LLSD getLastModified();
std::string getLinkStatus();
bool getUpdateBool();
void setType( S32 );
bool getIfValidBool(void);
S32 getType(void);
void getDebugInfo(void);
bool getIfValidBool();
S32 getType();
void getDebugInfo();
private: /* [maintenence functions] */
void updateSelf(void);
void updateSelf();
bool decodeSelf(LLImageRaw* rawimg);
void setUpdateBool(void);
void setUpdateBool();
LocalBitmap* getThis(void);
std::vector<LLFace*> getFaceUsesThis(LLDrawable*);
std::vector<affected_object> getUsingObjects(bool seek_by_type = true,
bool seek_textures = false, bool seek_sculptmaps = false);
@@ -184,7 +183,7 @@ class LocalAssetBrowser
static void UpdateTextureCtrlList(LLScrollListCtrl*);
static void setLayerUpdated(bool toggle) { mLayerUpdated = toggle; }
static void setSculptUpdated(bool toggle) { mSculptUpdated = toggle; }
static void AddBitmap(void);
static void AddBitmap();
static void AddBitmap_continued(AIFilePicker* filepicker);
static void DelBitmap( std::vector<LLScrollListItem*>, S32 column = BITMAPLIST_COL_ID );
@@ -194,18 +193,18 @@ class LocalAssetBrowser
the latter - each time the button's pressed. */
private:
static void onChangeHappened(void);
static void onChangeHappened();
static void onUpdateBool(LLUUID);
static void onSetType(LLUUID, S32);
static LocalBitmap* GetBitmapUnit(LLUUID);
static bool IsDoingUpdates(void);
static void PingTimer(void);
static void PerformTimedActions(void);
static void PerformSculptUpdates(LocalBitmap*);
static bool IsDoingUpdates();
static void PingTimer();
static void PerformTimedActions();
static void PerformSculptUpdates(LocalBitmap&);
protected:
static std::vector<LocalBitmap*> loaded_bitmaps;
typedef std::vector<LocalBitmap*>::iterator local_list_iter;
static std::vector<LocalBitmap> loaded_bitmaps;
typedef std::vector<LocalBitmap>::iterator local_list_iter;
static bool mLayerUpdated;
static bool mSculptUpdated;
};
@@ -225,17 +224,13 @@ public:
FloaterLocalAssetBrowser();
virtual ~FloaterLocalAssetBrowser();
static void show(void*);
private:
/* Widget related callbacks */
// Button callback declarations
static void onClickAdd(void* userdata);
static void onClickDel(void* userdata);
static void onClickMore(void* userdata);
static void onClickLess(void* userdata);
static void onClickUpload(void* userdata);
// Button callback declarations
void onClickAdd();
void onClickDel();
void onClickUpload();
// ScrollList callback declarations
void onChooseBitmapList();
@@ -271,17 +266,12 @@ private:
LLTextBox* mCaptionNameTxt;
LLTextBox* mCaptionTimeTxt;
/* static pointer to self, wai? oh well. */
static FloaterLocalAssetBrowser* sLFInstance;
// non-widget functions
static void FloaterResize(bool expand);
static void UpdateRightSide(void);
void FloaterResize(bool expand);
void UpdateRightSide();
public:
static void UpdateBitmapScrollList(void);
void UpdateBitmapScrollList();
};
/*==================================================*/