[Local Textures] Small hack to allow changing texture id

This commit is contained in:
Lirusaito
2019-02-07 01:33:34 -05:00
parent 8a4ab08810
commit aa0fea6931
3 changed files with 36 additions and 0 deletions

View File

@@ -292,6 +292,15 @@ void LocalBitmap::setType( S32 type )
bitmap_type = type;
}
void LocalBitmap::setID(const LLUUID& uuid)
{
LLViewerFetchedTexture* image = gTextureList.findImage(id);
gTextureList.deleteImage(image);
id = uuid;
image->setID(id);
gTextureList.addImage(image);
}
/* [information query functions] */
std::string LocalBitmap::getShortName() const
{
@@ -719,6 +728,11 @@ FloaterLocalAssetBrowser::FloaterLocalAssetBrowser()
// checkbox callbacks
mUpdateChkBox->setCommitCallback(boost::bind(&FloaterLocalAssetBrowser::onClickUpdateChkbox,this));
// Allow changing the ID!
mUUIDTxt->setCommitCallback(boost::bind(&FloaterLocalAssetBrowser::onUpdateID, this, _2));
mUUIDTxt->setCommitOnReturn(true);
mUUIDTxt->setCommitOnFocusLost(true);
}
void FloaterLocalAssetBrowser::show(void*)
@@ -786,6 +800,21 @@ void FloaterLocalAssetBrowser::onCommitTypeCombo()
}
}
void FloaterLocalAssetBrowser::onUpdateID(const LLSD& val)
{
const auto& id = val.asUUID();
const auto& col = mBitmapList->getFirstSelected()->getColumn(BITMAPLIST_COL_ID);
const auto& old_id = col->getValue().asString();
if (id.isNull() && id.asString() != old_id) // Just reset if invalid or unchanged
mUUIDTxt->setValue(old_id);
else
{
gLocalBrowser->GetBitmapUnit(LLUUID(old_id))->setID(id);
mTextureView->setImageAssetID(id);
col->setValue(id);
}
}
void FloaterLocalAssetBrowser::FloaterResize(bool expand)
{
mMoreBtn->setVisible(!expand);
@@ -860,6 +889,7 @@ void FloaterLocalAssetBrowser::UpdateRightSide()
mTextureView->setEnabled(true);
mUpdateChkBox->setEnabled(true);
mTypeComboBox->setEnabled(true);
mUUIDTxt->setEnabled(true);
}
}
else
@@ -871,6 +901,7 @@ void FloaterLocalAssetBrowser::UpdateRightSide()
mTypeComboBox->selectFirstItem();
mTypeComboBox->setEnabled(false);
mUUIDTxt->setEnabled(false);
const auto none = LLStringExplicit("None");
mPathTxt->setText(none);

View File

@@ -129,6 +129,8 @@ class LocalBitmap
public: /* [information query functions] */
std::string getShortName() const;
std::string getFileName() const;
LLUUID getID() const;
void setID(const LLUUID&);
LLSD getLastModified() const;
std::string getLinkStatus() const;
bool getUpdateBool() const;
@@ -240,6 +242,8 @@ private:
// Combobox type select
void onCommitTypeCombo();
void onUpdateID(const LLSD& val);
// Widgets
LLButton* mAddBtn;
LLButton* mDelBtn;

View File

@@ -135,6 +135,7 @@ public:
/*virtual*/ bool isActiveFetching();
/*virtual*/ const LLUUID& getID() const { return mID; }
void setID(const LLUUID& id) { mID = id; } // Edit for local assets to cut down on reloads, be sure to remove from wherever this has been added first.
void setBoostLevel(S32 level);
S32 getBoostLevel() { return mBoostLevel; }