and add the actual vfs explorer, why not.
This commit is contained in:
172
indra/newview/llfloatervfsexplorer.cpp
Normal file
172
indra/newview/llfloatervfsexplorer.cpp
Normal file
@@ -0,0 +1,172 @@
|
||||
// <edit>
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
#include "llfloatervfsexplorer.h"
|
||||
#include "lluictrlfactory.h"
|
||||
#include "llscrolllistctrl.h"
|
||||
#include "llcheckboxctrl.h"
|
||||
#include "llfilepicker.h"
|
||||
#include "llvfs.h"
|
||||
#include "lllocalinventory.h"
|
||||
#include "llviewerwindow.h"
|
||||
#include "llassetconverter.h"
|
||||
|
||||
LLFloaterVFSExplorer* LLFloaterVFSExplorer::sInstance;
|
||||
std::map<LLVFSFileSpecifier, LLVFSFileBlock*> LLFloaterVFSExplorer::sVFSFileMap;
|
||||
|
||||
LLFloaterVFSExplorer::LLFloaterVFSExplorer()
|
||||
: LLFloater(),
|
||||
mEditID(LLUUID::null)
|
||||
{
|
||||
LLUICtrlFactory::getInstance()->buildFloater(this, "floater_vfs_explorer.xml");
|
||||
}
|
||||
LLFloaterVFSExplorer::~LLFloaterVFSExplorer()
|
||||
{
|
||||
sInstance = NULL;
|
||||
}
|
||||
// static
|
||||
void LLFloaterVFSExplorer::show()
|
||||
{
|
||||
if(sInstance)
|
||||
sInstance->open();
|
||||
else
|
||||
{
|
||||
sInstance = new LLFloaterVFSExplorer();
|
||||
sInstance->open();
|
||||
}
|
||||
}
|
||||
BOOL LLFloaterVFSExplorer::postBuild()
|
||||
{
|
||||
childSetCommitCallback("file_list", onCommitFileList, this);
|
||||
childSetAction("remove_btn", onClickRemove, this);
|
||||
childSetAction("reload_all_btn", onClickReload, this);
|
||||
childSetAction("copy_uuid_btn", onClickCopyUUID, this);
|
||||
refresh();
|
||||
return TRUE;
|
||||
}
|
||||
void LLFloaterVFSExplorer::refresh()
|
||||
{
|
||||
LLScrollListCtrl* list = getChild<LLScrollListCtrl>("file_list");
|
||||
list->clearRows();
|
||||
sVFSFileMap = gVFS->getFileList();
|
||||
std::map<LLVFSFileSpecifier, LLVFSFileBlock*>::iterator end = sVFSFileMap.end();
|
||||
for(std::map<LLVFSFileSpecifier, LLVFSFileBlock*>::iterator iter = sVFSFileMap.begin(); iter != end; ++iter)
|
||||
{
|
||||
LLVFSFileSpecifier file_spec = iter->first;
|
||||
LLSD element;
|
||||
element["id"] = file_spec.mFileID;
|
||||
LLSD& name_column = element["columns"][0];
|
||||
name_column["column"] = "name";
|
||||
name_column["value"] = file_spec.mFileID.asString();
|
||||
LLSD& type_column = element["columns"][1];
|
||||
type_column["column"] = "type";
|
||||
type_column["value"] = std::string(LLAssetType::lookup(file_spec.mFileType));
|
||||
list->addElement(element, ADD_BOTTOM);
|
||||
}
|
||||
setEditID(mEditID);
|
||||
}
|
||||
void LLFloaterVFSExplorer::reloadAll()
|
||||
{
|
||||
//get our magic from gvfs here
|
||||
refresh();
|
||||
}
|
||||
void LLFloaterVFSExplorer::setEditID(LLUUID edit_id)
|
||||
{
|
||||
LLScrollListCtrl* list = getChild<LLScrollListCtrl>("file_list");
|
||||
bool found_in_list = (list->getItemIndex(edit_id) != -1);
|
||||
bool found_in_files = false;
|
||||
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 == edit_id)
|
||||
{
|
||||
found_in_files = true;
|
||||
file = (*iter).first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(found_in_files && found_in_list)
|
||||
{
|
||||
mEditID = edit_id;
|
||||
list->selectByID(edit_id);
|
||||
setEditEnabled(true);
|
||||
childSetText("name_edit", file.mFileID.asString());
|
||||
childSetText("id_edit", file.mFileID.asString());
|
||||
childSetValue("type_combo", std::string(LLAssetType::lookup(file.mFileType)));
|
||||
}
|
||||
else
|
||||
{
|
||||
mEditID = LLUUID::null;
|
||||
list->deselectAllItems(TRUE);
|
||||
setEditEnabled(false);
|
||||
childSetText("name_edit", std::string(""));
|
||||
childSetText("id_edit", std::string(""));
|
||||
childSetValue("type_combo", std::string("animatn"));
|
||||
}
|
||||
}
|
||||
LLVFSFileSpecifier LLFloaterVFSExplorer::getEditEntry()
|
||||
{
|
||||
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)
|
||||
return (*iter).first;
|
||||
}
|
||||
file.mFileID = LLUUID::null;
|
||||
return file;
|
||||
}
|
||||
|
||||
void LLFloaterVFSExplorer::removeEntry()
|
||||
{
|
||||
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)
|
||||
{
|
||||
gVFS->removeFile((*iter).first.mFileID, (*iter).first.mFileType);
|
||||
sVFSFileMap.erase(iter);
|
||||
break;
|
||||
}
|
||||
else ++iter;
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
void LLFloaterVFSExplorer::setEditEnabled(bool enabled)
|
||||
{
|
||||
childSetEnabled("name_edit", false);
|
||||
childSetEnabled("id_edit", false);
|
||||
childSetEnabled("type_combo", false);
|
||||
childSetEnabled("remove_btn", enabled);
|
||||
childSetEnabled("copy_uuid_btn", enabled);
|
||||
}
|
||||
// static
|
||||
void LLFloaterVFSExplorer::onCommitFileList(LLUICtrl* ctrl, void* user_data)
|
||||
{
|
||||
LLFloaterVFSExplorer* floaterp = (LLFloaterVFSExplorer*)user_data;
|
||||
LLScrollListCtrl* list = floaterp->getChild<LLScrollListCtrl>("file_list");
|
||||
LLUUID selected_id(LLUUID::null);
|
||||
if(list->getFirstSelected())
|
||||
selected_id = list->getFirstSelected()->getUUID();
|
||||
floaterp->setEditID(selected_id);
|
||||
}
|
||||
// static
|
||||
void LLFloaterVFSExplorer::onClickCopyUUID(void* user_data)
|
||||
{
|
||||
LLFloaterVFSExplorer* floaterp = (LLFloaterVFSExplorer*)user_data;
|
||||
LLVFSFileSpecifier file = floaterp->getEditEntry();
|
||||
gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(file.mFileID.asString()));
|
||||
}
|
||||
// static
|
||||
void LLFloaterVFSExplorer::onClickRemove(void* user_data)
|
||||
{
|
||||
LLFloaterVFSExplorer* floaterp = (LLFloaterVFSExplorer*)user_data;
|
||||
floaterp->removeEntry();
|
||||
}
|
||||
// static
|
||||
void LLFloaterVFSExplorer::onClickReload(void* user_data)
|
||||
{
|
||||
LLFloaterVFSExplorer* floaterp = (LLFloaterVFSExplorer*)user_data;
|
||||
floaterp->reloadAll();
|
||||
}
|
||||
// </edit>
|
||||
39
indra/newview/llfloatervfsexplorer.h
Normal file
39
indra/newview/llfloatervfsexplorer.h
Normal file
@@ -0,0 +1,39 @@
|
||||
// <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>
|
||||
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||||
<floater can_close="true" can_drag_on_left="false" can_minimize="true"
|
||||
can_resize="false" width="320" min_width="320" height="320" min_height="320"
|
||||
name="floater_vfs" title="VFS Explorer" rect_control="FloaterVFSRect">
|
||||
<button name="reload_all_btn" follows="left|top" width="100" left="10" bottom_delta="-43" height="20" label="Reload All"/>
|
||||
<scroll_list bottom="75" can_resize="true" column_padding="0" draw_heading="true"
|
||||
follows="left|top|bottom|right" left="10" multi_select="true"
|
||||
name="file_list" right="-10" search_column="0" top="-50">
|
||||
<column dynamicwidth="true" name="name" label="name" />
|
||||
<column name="type" label="type" width="100" />
|
||||
</scroll_list>
|
||||
<line_editor name="name_edit" follows="left|bottom|right" bottom="53" left="10" width="300" height="20"/>
|
||||
<line_editor name="id_edit" follows="left|bottom|right" bottom_delta="-23" left="10" width="200" height="20"/>
|
||||
<combo_box allow_text_entry="false" bottom_delta="-1" follows="left|bottom|right" height="20"
|
||||
left="210" max_chars="20" mouse_opaque="true" name="type_combo" width="100">
|
||||
<combo_item name="texture" value="texture">
|
||||
texture
|
||||
</combo_item>
|
||||
<combo_item name="sound" value="sound">
|
||||
sound
|
||||
</combo_item>
|
||||
<combo_item name="callcard" value="callcard">
|
||||
callcard
|
||||
</combo_item>
|
||||
<combo_item name="landmark" value="landmark">
|
||||
landmark
|
||||
</combo_item>
|
||||
<combo_item name="script" value="script">
|
||||
script
|
||||
</combo_item>
|
||||
<combo_item name="clothing" value="clothing">
|
||||
clothing
|
||||
</combo_item>
|
||||
<combo_item name="object" value="object">
|
||||
object
|
||||
</combo_item>
|
||||
<combo_item name="notecard" value="notecard">
|
||||
notecard
|
||||
</combo_item>
|
||||
<combo_item name="category" value="category">
|
||||
category
|
||||
</combo_item>
|
||||
<combo_item name="root" value="root">
|
||||
root
|
||||
</combo_item>
|
||||
<combo_item name="lsltext" value="lsltext">
|
||||
lsltext
|
||||
</combo_item>
|
||||
<combo_item name="lslbyte" value="lslbyte">
|
||||
lslbyte
|
||||
</combo_item>
|
||||
<combo_item name="txtr_tga" value="txtr_tga">
|
||||
txtr_tga
|
||||
</combo_item>
|
||||
<combo_item name="bodypart" value="bodypart">
|
||||
bodypart
|
||||
</combo_item>
|
||||
<combo_item name="trash" value="trash">
|
||||
trash
|
||||
</combo_item>
|
||||
<combo_item name="snapshot" value="snapshot">
|
||||
snapshot
|
||||
</combo_item>
|
||||
<combo_item name="lstndfnd" value="lstndfnd">
|
||||
lstndfnd
|
||||
</combo_item>
|
||||
<combo_item name="snd_wav" value="snd_wav">
|
||||
snd_wav
|
||||
</combo_item>
|
||||
<combo_item name="img_tga" value="img_tga">
|
||||
img_tga
|
||||
</combo_item>
|
||||
<combo_item name="jpeg" value="jpeg">
|
||||
jpeg
|
||||
</combo_item>
|
||||
<combo_item name="animatn" value="animatn">
|
||||
animatn
|
||||
</combo_item>
|
||||
<combo_item name="gesture" value="gesture">
|
||||
gesture
|
||||
</combo_item>
|
||||
<combo_item name="simstate" value="simstate">
|
||||
simstate
|
||||
</combo_item>
|
||||
</combo_box>
|
||||
<button name="copy_uuid_btn" follows="left|bottom" width="75" bottom="7" left="10" height="20" label="Copy UUID"/>
|
||||
<button name="remove_btn" follows="left|bottom" width="75" bottom_delta="0" left_delta="75" height="20" label="Remove"/>
|
||||
</floater>
|
||||
Reference in New Issue
Block a user