add ability to view gvfs entries in hex editor
This commit is contained in:
@@ -27,26 +27,47 @@
|
||||
std::list<DOFloaterHex*> DOFloaterHex::sInstances;
|
||||
S32 DOFloaterHex::sUploadAmount = 10;
|
||||
|
||||
DOFloaterHex::DOFloaterHex(LLInventoryItem* item)
|
||||
DOFloaterHex::DOFloaterHex(LLUUID item_id, BOOL vfs, LLAssetType::EType asset_type)
|
||||
: LLFloater()
|
||||
{
|
||||
sInstances.push_back(this);
|
||||
mItem = item;
|
||||
LLUICtrlFactory::getInstance()->buildFloater(this, "floater_hex.xml");
|
||||
}
|
||||
|
||||
// static
|
||||
void DOFloaterHex::show(LLUUID item_id)
|
||||
//this bit should be rewritten entirely
|
||||
void DOFloaterHex::show(LLUUID item_id, BOOL vfs, LLAssetType::EType asset_type)
|
||||
{
|
||||
LLInventoryItem* item = (LLInventoryItem*)gInventory.getItem(item_id);
|
||||
if(item)
|
||||
if(!vfs)
|
||||
{
|
||||
LLInventoryItem* item = (LLInventoryItem*)gInventory.getItem(item_id);
|
||||
if(item)
|
||||
{
|
||||
S32 left, top;
|
||||
gFloaterView->getNewFloaterPosition(&left, &top);
|
||||
LLRect rect = gSavedSettings.getRect("FloaterHexRect");
|
||||
rect.translate(left - rect.mLeft, top - rect.mTop);
|
||||
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);
|
||||
}
|
||||
} else if (item_id.notNull() && asset_type != LLAssetType::AT_NONE) {
|
||||
S32 left, top;
|
||||
gFloaterView->getNewFloaterPosition(&left, &top);
|
||||
LLRect rect = gSavedSettings.getRect("FloaterHexRect");
|
||||
rect.translate(left - rect.mLeft, top - rect.mTop);
|
||||
DOFloaterHex* floaterp = new DOFloaterHex(item);
|
||||
DOFloaterHex* floaterp = new DOFloaterHex(item_id);
|
||||
floaterp->setRect(rect);
|
||||
|
||||
floaterp->mVFS = true;
|
||||
floaterp->mAssetId = item_id;
|
||||
floaterp->mAssetType = asset_type;
|
||||
|
||||
gFloaterView->adjustToFitScreen(floaterp, FALSE);
|
||||
}
|
||||
}
|
||||
@@ -80,7 +101,7 @@ BOOL DOFloaterHex::postBuild(void)
|
||||
childSetEnabled("save_btn", false);
|
||||
childSetAction("save_btn", onClickSave, this);
|
||||
|
||||
if(mItem)
|
||||
if(!mVFS && mItem)
|
||||
{
|
||||
std::string title = "Hex editor: " + mItem->getName();
|
||||
const char* asset_type_name = LLAssetType::lookup(mItem->getType());
|
||||
@@ -90,19 +111,21 @@ BOOL DOFloaterHex::postBuild(void)
|
||||
}
|
||||
setTitle(title);
|
||||
}
|
||||
#if OPENSIM_RULES!=1
|
||||
if(mItem->getCreatorUUID() == gAgentID)
|
||||
if(!mVFS)
|
||||
{
|
||||
#endif /* OPENSIM_RULES!=1 */
|
||||
// Load the asset
|
||||
editor->setVisible(FALSE);
|
||||
childSetText("status_text", std::string("Loading..."));
|
||||
LLInventoryBackup::download(mItem, this, imageCallback, assetCallback);
|
||||
#if OPENSIM_RULES!=1
|
||||
}
|
||||
else if (mVFS) //the asset already exists in the VFS, we don't need to fetch it
|
||||
//and we don't want to associate it with an item
|
||||
{
|
||||
setTitle(mAssetId.asString());
|
||||
readVFile();
|
||||
} else {
|
||||
this->close(false);
|
||||
}
|
||||
#endif /* OPENSIM_RULES!=1 */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -428,4 +451,35 @@ void DOFloaterHex::handleSizing()
|
||||
}
|
||||
}
|
||||
|
||||
void DOFloaterHex::readVFile()
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
llerrs << "Memory Allocation Failed" << llendl;
|
||||
return;
|
||||
}
|
||||
|
||||
file.read((U8*)buffer, size);
|
||||
|
||||
std::vector<U8> new_data;
|
||||
for(S32 i = 0; i < size; i++)
|
||||
new_data.push_back(buffer[i]);
|
||||
|
||||
delete[] buffer;
|
||||
|
||||
floater->mEditor->setValue(new_data);
|
||||
floater->mEditor->setVisible(TRUE);
|
||||
|
||||
floater->childSetText("status_text", std::string("Editing VFile"));
|
||||
|
||||
floater->childSetEnabled("upload_btn", false);
|
||||
floater->childSetEnabled("save_btn", false);
|
||||
}
|
||||
|
||||
// </edit>
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
#include "dohexeditor.h"
|
||||
#include "llinventory.h"
|
||||
#include "llviewerimage.h"
|
||||
#include "llassettype.h"
|
||||
|
||||
class DOFloaterHex
|
||||
: public LLFloater
|
||||
{
|
||||
public:
|
||||
DOFloaterHex(LLInventoryItem* item);
|
||||
DOFloaterHex(LLUUID item_id, BOOL vfs=false, LLAssetType::EType asset_type = LLAssetType::AT_NONE);
|
||||
static void show(LLUUID item_id);
|
||||
BOOL postBuild(void);
|
||||
void close(bool app_quitting);
|
||||
@@ -33,7 +34,11 @@ public:
|
||||
static void onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status);
|
||||
static void onCommitColumnCount(LLUICtrl *control, void *user_data);
|
||||
void handleSizing();
|
||||
void readVFile();
|
||||
LLInventoryItem* mItem;
|
||||
LLUUID mAssetId;
|
||||
LLAssetType::EType mAssetType;
|
||||
BOOL mVFS;
|
||||
DOHexEditor* mEditor;
|
||||
static std::list<DOFloaterHex*> sInstances;
|
||||
private:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// <edit>
|
||||
//A lot of bad things going on in here, needs a rewrite.
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
#include "llfloatervfsexplorer.h"
|
||||
#include "lluictrlfactory.h"
|
||||
@@ -9,6 +10,7 @@
|
||||
#include "lllocalinventory.h"
|
||||
#include "llviewerwindow.h"
|
||||
#include "llassetconverter.h"
|
||||
#include "dohexeditor.h"
|
||||
|
||||
LLFloaterVFSExplorer* LLFloaterVFSExplorer::sInstance;
|
||||
std::map<LLVFSFileSpecifier, LLVFSFileBlock*> LLFloaterVFSExplorer::sVFSFileMap;
|
||||
@@ -67,6 +69,7 @@ void LLFloaterVFSExplorer::refresh()
|
||||
void LLFloaterVFSExplorer::reloadAll()
|
||||
{
|
||||
//get our magic from gvfs here
|
||||
//this should re-request all assets from the server if possible.
|
||||
refresh();
|
||||
}
|
||||
void LLFloaterVFSExplorer::setEditID(LLUUID edit_id)
|
||||
@@ -169,4 +172,16 @@ void LLFloaterVFSExplorer::onClickReload(void* user_data)
|
||||
LLFloaterVFSExplorer* floaterp = (LLFloaterVFSExplorer*)user_data;
|
||||
floaterp->reloadAll();
|
||||
}
|
||||
// static
|
||||
void LLFloaterVFSExplorer::onClickEditData(void* user_data)
|
||||
{
|
||||
LLVFSFileSpecifier file;
|
||||
std::map<LLVFSFileSpecifier, LLVFSFileBlock*>::iterator end = sVFSFileMap.end();
|
||||
for(std::map<LLVFSFileSpecifier, LLVFSFileBlock*>::iterator iter = sVFSFileMap.begin(); iter != end; ++iter)
|
||||
{
|
||||
if((*iter).first.mFileID == mEditID)
|
||||
file = (*iter).first;
|
||||
}
|
||||
DOHexEditor::showVFS(file.mFileID, file.mFileType);
|
||||
}
|
||||
// </edit>
|
||||
|
||||
@@ -1,39 +1,40 @@
|
||||
// <edit>
|
||||
#ifndef LL_LLFLOATERVFSEXPLORER_H
|
||||
#define LL_LLFLOATERVFSEXPLORER_H
|
||||
|
||||
#include "llfloater.h"
|
||||
#include "llassettype.h"
|
||||
#include "llvfs.h"
|
||||
|
||||
class LLFloaterVFSExplorer : LLFloater
|
||||
{
|
||||
typedef struct
|
||||
{
|
||||
std::string mFilename;
|
||||
std::string mName;
|
||||
LLUUID mID;
|
||||
LLAssetType::EType mType;
|
||||
} entry;
|
||||
public:
|
||||
LLFloaterVFSExplorer();
|
||||
~LLFloaterVFSExplorer();
|
||||
static void show();
|
||||
BOOL postBuild();
|
||||
void refresh();
|
||||
void reloadAll();
|
||||
void removeEntry();
|
||||
void setEditID(LLUUID edit_id);
|
||||
LLVFSFileSpecifier getEditEntry();
|
||||
static void onCommitFileList(LLUICtrl* ctrl, void* user_data);
|
||||
static void onClickCopyUUID(void* user_data);
|
||||
static void onClickRemove(void* user_data);
|
||||
static void onClickReload(void* user_data);
|
||||
private:
|
||||
static LLFloaterVFSExplorer* sInstance;
|
||||
static std::map<LLVFSFileSpecifier, LLVFSFileBlock*> sVFSFileMap;
|
||||
LLUUID mEditID;
|
||||
void setEditEnabled(bool enabled);
|
||||
};
|
||||
#endif
|
||||
// </edit>
|
||||
// <edit>
|
||||
#ifndef LL_LLFLOATERVFSEXPLORER_H
|
||||
#define LL_LLFLOATERVFSEXPLORER_H
|
||||
|
||||
#include "llfloater.h"
|
||||
#include "llassettype.h"
|
||||
#include "llvfs.h"
|
||||
|
||||
class LLFloaterVFSExplorer : LLFloater
|
||||
{
|
||||
typedef struct
|
||||
{
|
||||
std::string mFilename;
|
||||
std::string mName;
|
||||
LLUUID mID;
|
||||
LLAssetType::EType mType;
|
||||
} entry;
|
||||
public:
|
||||
LLFloaterVFSExplorer();
|
||||
~LLFloaterVFSExplorer();
|
||||
static void show();
|
||||
BOOL postBuild();
|
||||
void refresh();
|
||||
void reloadAll();
|
||||
void removeEntry();
|
||||
void setEditID(LLUUID edit_id);
|
||||
LLVFSFileSpecifier getEditEntry();
|
||||
static void onCommitFileList(LLUICtrl* ctrl, void* user_data);
|
||||
static void onClickCopyUUID(void* user_data);
|
||||
static void onClickRemove(void* user_data);
|
||||
static void onClickReload(void* user_data);
|
||||
static void onClickEditData(void* user_data);
|
||||
private:
|
||||
static LLFloaterVFSExplorer* sInstance;
|
||||
static std::map<LLVFSFileSpecifier, LLVFSFileBlock*> sVFSFileMap;
|
||||
LLUUID mEditID;
|
||||
void setEditEnabled(bool enabled);
|
||||
};
|
||||
#endif
|
||||
// </edit>
|
||||
|
||||
Reference in New Issue
Block a user