From dae72dcee4baa02eff8fb6f2c0757552ecf81a2f Mon Sep 17 00:00:00 2001 From: Hazim Gazov Date: Sat, 26 Jun 2010 17:57:34 +0000 Subject: [PATCH] vfs explorer can now be used to view cached asset data with the built in hex editor --- indra/newview/dofloaterhex.cpp | 62 +++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/indra/newview/dofloaterhex.cpp b/indra/newview/dofloaterhex.cpp index eff028be4..5c560f14c 100644 --- a/indra/newview/dofloaterhex.cpp +++ b/indra/newview/dofloaterhex.cpp @@ -31,6 +31,17 @@ DOFloaterHex::DOFloaterHex(LLUUID item_id, BOOL vfs, LLAssetType::EType asset_ty : LLFloater() { sInstances.push_back(this); + if(vfs) + { + mVFS = true; + mAssetId = item_id; + mAssetType = asset_type; + } else { + mVFS = false; + mAssetId = mItem->getAssetUUID(); + mAssetType = mItem->getType(); + } + llinfos << "Asset ID: " << item_id.asString() << llendl; LLUICtrlFactory::getInstance()->buildFloater(this, "floater_hex.xml"); } @@ -49,9 +60,6 @@ void DOFloaterHex::show(LLUUID item_id, BOOL vfs, LLAssetType::EType asset_type) DOFloaterHex* floaterp = new DOFloaterHex(item_id); floaterp->setRect(rect); - floaterp->mVFS = false; - floaterp->mAssetId = item->getAssetUUID(); - floaterp->mAssetType = item->getType(); floaterp->mItem = item; gFloaterView->adjustToFitScreen(floaterp, FALSE); @@ -61,12 +69,10 @@ void DOFloaterHex::show(LLUUID item_id, BOOL vfs, LLAssetType::EType asset_type) gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect = gSavedSettings.getRect("FloaterHexRect"); rect.translate(left - rect.mLeft, top - rect.mTop); - DOFloaterHex* floaterp = new DOFloaterHex(item_id); + DOFloaterHex* floaterp = new DOFloaterHex(item_id, true, asset_type); floaterp->setRect(rect); - floaterp->mVFS = true; - floaterp->mAssetId = item_id; - floaterp->mAssetType = asset_type; + llinfos << "Asset ID: " << item_id.asString() << llendl; gFloaterView->adjustToFitScreen(floaterp, FALSE); } @@ -139,6 +145,7 @@ void DOFloaterHex::imageCallback(BOOL success, BOOL final, void* userdata) { + if(final) { LLInventoryBackup::callbackdata* data = static_cast(userdata); @@ -179,6 +186,7 @@ void DOFloaterHex::assetCallback(LLVFS *vfs, LLAssetType::EType type, void* user_data, S32 status, LLExtStat ext_status) { + LLInventoryBackup::callbackdata* data = static_cast(user_data); DOFloaterHex* floater = (DOFloaterHex*)(data->floater); if(!floater) return; @@ -259,6 +267,7 @@ void DOFloaterHex::assetCallback(LLVFS *vfs, // static void DOFloaterHex::onClickUpload(void* user_data) { + DOFloaterHex* floater = (DOFloaterHex*)user_data; LLInventoryItem* item = floater->mItem; @@ -453,29 +462,34 @@ void DOFloaterHex::handleSizing() void DOFloaterHex::readVFile() { + if(!mVFS) return; // quick cut paste job // Todo: this doesn't work for static vfs shit LLVFile file(gVFS, mAssetId, mAssetType, LLVFile::READ); - S32 size = file.getSize(); - - char* buffer = new char[size]; - if (buffer == NULL) + if(file.getVFSThread()) { - llerrs << "Memory Allocation Failed" << llendl; - return; + S32 size = file.getSize(); + + char* buffer = new char[size]; + if (buffer == NULL) + { + llerrs << "Memory Allocation Failed" << llendl; + return; + } + + file.read((U8*)buffer, size); + + std::vector new_data; + for(S32 i = 0; i < size; i++) + new_data.push_back(buffer[i]); + + delete[] buffer; + + mEditor->setValue(new_data); + mEditor->setVisible(TRUE); + } - file.read((U8*)buffer, size); - - std::vector new_data; - for(S32 i = 0; i < size; i++) - new_data.push_back(buffer[i]); - - delete[] buffer; - - mEditor->setValue(new_data); - mEditor->setVisible(TRUE); - childSetText("status_text", std::string("Editing VFile")); childSetEnabled("upload_btn", false);