Updates to Beeks' pet project.

Signed-off-by: Beeks <HgDelirium@gmail.com>
This commit is contained in:
Beeks
2010-10-05 11:14:49 -04:00
parent 9eaf82378e
commit 668b7f6096
4 changed files with 168 additions and 47 deletions

View File

@@ -817,16 +817,17 @@
<key>Value</key> <key>Value</key>
<integer>0</integer> <integer>0</integer>
</map> </map>
<key>AscentUploadFolder</key> <key>AscentUploadSettings</key>
<map> <map>
<key>Comment</key> <key>Comment</key>
<string>Active folder for the Uploader</string> <string>Settings for upload browser</string>
<key>Persist</key> <key>Type</key>
<integer>1</integer> <string>LLSD</string>
<key>Type</key> <key>Value</key>
<string>String</string> <map>
<key>Value</key> <key>ActivePath</key>
<string>None</string> <string>None</string>
</map>
</map> </map>
<key>AscentUseCustomTag</key> <key>AscentUseCustomTag</key>
<map> <map>

View File

@@ -31,6 +31,7 @@
/// Local function declarations, constants, enums, and typedefs /// Local function declarations, constants, enums, and typedefs
///---------------------------------------------------------------------------- ///----------------------------------------------------------------------------
LLSD ASFloaterUploadBrowser::mUploaderSettings;
ASFloaterUploadBrowser* ASFloaterUploadBrowser::sInstance = NULL; ASFloaterUploadBrowser* ASFloaterUploadBrowser::sInstance = NULL;
@@ -43,24 +44,37 @@ ASFloaterUploadBrowser::ASFloaterUploadBrowser()
: LLFloater(std::string("floater_upload_browser"), std::string("FloaterUploadRect"), LLStringUtil::null) : LLFloater(std::string("floater_upload_browser"), std::string("FloaterUploadRect"), LLStringUtil::null)
{ {
LLUICtrlFactory::getInstance()->buildFloater(this, "floater_upload_browser.xml"); LLUICtrlFactory::getInstance()->buildFloater(this, "floater_upload_browser.xml");
mPathName = gSavedSettings.getString("AscentUploadFolder");
mUploaderSettings.clear();
mUploaderSettings = gSavedSettings.getLLSD("AscentUploadSettings");
mPathName = mUploaderSettings["ActivePath"].asString();
if (mPathName == "None") if (mPathName == "None")
mPathName = gDirUtilp->getExecutableDir(); mPathName = gDirUtilp->getExecutableDir();
mFilterType = "None"; mFilterType = "None";
//File list ------------------------------------------------------ //File list ------------------------------------------------------
mFileList = getChild<LLScrollListCtrl>("file_list"); mFileList = getChild<LLScrollListCtrl>("file_list");
childSetCommitCallback("file_list", onClickFile, this); childSetCommitCallback("file_list", onClickFile, this);
childSetDoubleClickCallback("file_list", onDoubleClick); childSetDoubleClickCallback("file_list", onDoubleClick);
//Above File List ------------------------------------------------ //Above File List ------------------------------------------------
mBookmarkCombo = getChild<LLComboBox>("bookmark_combo"); mBookmarkCombo = getChild<LLComboBox>("bookmark_combo");
S32 index;
for (index = 0; index < mUploaderSettings["Bookmarks"].size(); index++)
{
std::string bookmark = mUploaderSettings["Bookmarks"][index].asString();
if (bookmark != "")
mBookmarkCombo->add(bookmark, ADD_BOTTOM);
}
mDriveCombo = getChild<LLComboBox>("drive_combo"); mDriveCombo = getChild<LLComboBox>("drive_combo");
childSetCommitCallback("drive_combo", onChangeDrives, this); childSetCommitCallback("drive_combo", onChangeDrives, this);
//This is so unbelievably shitty I can't believe it -HgB //This is so unbelievably shitty I can't handle it -HgB
std::string drive_letters[] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; //Oh my god it's somehow worse now -HgB std::string drive_letters[] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; //Oh my god it's somehow worse now -HgB
S32 index;
mDriveCombo->removeall(); mDriveCombo->removeall();
for (index = 0; index < 26; index++) for (index = 0; index < 26; index++)
{ {
@@ -73,7 +87,7 @@ ASFloaterUploadBrowser::ASFloaterUploadBrowser()
} }
childSetAction("directory_button", onClickFilepathGoto, this); childSetAction("directory_button", onClickFilepathGoto, this);
childSetCommitCallback("dir_path", onDirCommit, (void*)this);
//Below File List ------------------------------------------------ //Below File List ------------------------------------------------
childSetCommitCallback("file_filter_combo", onUpdateFilter, this); childSetCommitCallback("file_filter_combo", onUpdateFilter, this);
@@ -81,8 +95,8 @@ ASFloaterUploadBrowser::ASFloaterUploadBrowser()
refresh(); refresh();
mFileList->sortByColumn(std::string("file_name"), TRUE); mFileList->sortByColumn(std::string("file_name"), TRUE);
mFileList->sortByColumn(std::string("file_type"), TRUE); mFileList->sortByColumn(std::string("file_type"), TRUE);
childHide("multiple_uploads_label");
childHide("bad_image_text");
} }
// Destroys the object // Destroys the object
@@ -91,12 +105,19 @@ ASFloaterUploadBrowser::~ASFloaterUploadBrowser()
sInstance = NULL; sInstance = NULL;
} }
//static void ASFloaterUploadBrowser::onDirCommit(LLUICtrl* ctrl, void* data)
void ASFloaterUploadBrowser::onClickFilepathGoto(void* data)
{ {
ASFloaterUploadBrowser* panelp = (ASFloaterUploadBrowser*)data; ASFloaterUploadBrowser* panelp = (ASFloaterUploadBrowser*)data;
std::string new_path = panelp->childGetValue("dir_path"); if (panelp)
if (new_path != panelp->mPathName) {
panelp->onClickFilepathGoto(data);
}
}
void ASFloaterUploadBrowser::updateBrowser(void* data, std::string new_path)
{
ASFloaterUploadBrowser* panelp = (ASFloaterUploadBrowser*)data;
if ((new_path != panelp->mPathName)||(new_path == ""))
{ {
panelp->mPathName = new_path; panelp->mPathName = new_path;
panelp->refresh(); panelp->refresh();
@@ -105,6 +126,14 @@ void ASFloaterUploadBrowser::onClickFilepathGoto(void* data)
} }
} }
//static
void ASFloaterUploadBrowser::onClickFilepathGoto(void* data)
{
ASFloaterUploadBrowser* panelp = (ASFloaterUploadBrowser*)data;
std::string new_path = panelp->childGetValue("dir_path");
panelp->updateBrowser(data, new_path);
}
void ASFloaterUploadBrowser::onClickFile(LLUICtrl* ctrl, void* user_data) void ASFloaterUploadBrowser::onClickFile(LLUICtrl* ctrl, void* user_data)
{ {
ASFloaterUploadBrowser* panelp = (ASFloaterUploadBrowser*)user_data; ASFloaterUploadBrowser* panelp = (ASFloaterUploadBrowser*)user_data;
@@ -116,10 +145,7 @@ void ASFloaterUploadBrowser::onChangeDrives(LLUICtrl* ctrl, void* user_data)
ASFloaterUploadBrowser* panelp = (ASFloaterUploadBrowser*)user_data; ASFloaterUploadBrowser* panelp = (ASFloaterUploadBrowser*)user_data;
if (panelp->mDriveCombo->getSelectedValue().asString() != panelp->mFilterType) if (panelp->mDriveCombo->getSelectedValue().asString() != panelp->mFilterType)
{ {
panelp->mPathName = panelp->mDriveCombo->getSelectedValue().asString(); panelp->updateBrowser(user_data, panelp->mDriveCombo->getSelectedValue().asString());
panelp->refresh();
panelp->mFileList->selectFirstItem();
panelp->childSetValue("asset_name", "");
} }
} }
@@ -131,9 +157,7 @@ void ASFloaterUploadBrowser::onUpdateFilter(LLUICtrl* ctrl, void* user_data)
{ {
panelp->mFilterType = ""; panelp->mFilterType = "";
panelp->mFilterType = combo->getSelectedValue().asString(); panelp->mFilterType = combo->getSelectedValue().asString();
panelp->refresh(); panelp->updateBrowser(user_data, "");
panelp->mFileList->selectFirstItem();
panelp->childSetValue("asset_name", "");
} }
} }
@@ -148,21 +172,44 @@ void ASFloaterUploadBrowser::refreshUploadOptions()
} }
else else
{ {
if (mFileList->getFirstSelected()->getColumn(LIST_FILE_TYPE)->getValue().asInteger() == LIST_TYPE_FILE) if (mFileList->getFirstSelected()->getColumn(LIST_ASSET_TYPE)->getValue().asInteger() == LIST_TYPE_FILE)
{ {
std::string name;
bool show_tex = false;
bool show_snd = false;
bool show_anm = false;
bool show_multiple = false;
if (mFileList->getAllSelected().size() > 1) if (mFileList->getAllSelected().size() > 1)
{ {
llinfos << "Selected multiple files." << llendl; llinfos << "Selected multiple files." << llendl;
childSetValue("asset_name", "(Multiple)"); name = "(Multiple)";
childSetLabelArg("upload_button", "[COST]", std::string("$L" + (10 * mFileList->getAllSelected().size()))); show_multiple = true;
childSetValue("multiple_uploads_label", "Multiple files selected. Total cost is: " + llformat("%d", mFileList->getAllSelected().size() * 10));
} }
else else
{ {
llinfos << "Selected a file." << llendl; int type = mFileList->getFirstSelected()->getColumn(LIST_FILE_TYPE)->getValue().asInteger();
std::string name = mFileList->getFirstSelected()->getColumn(LIST_FILE_NAME)->getValue().asString(); llinfos << "Selected a file, type" << type << llendl;
childSetValue("asset_name", name); if (type == FILE_TEXTURE)
childSetLabelArg("upload_button", "[COST]", std::string("$L10")); {
show_tex = true;
}
else if (type == FILE_SOUND)
{
show_snd = true;
}
else if (type == FILE_ANIMATION)
{
show_anm = true;
}
name = mFileList->getFirstSelected()->getColumn(LIST_FILE_NAME)->getValue().asString();
} }
childSetVisible("texture_preview_label", (show_tex && !show_multiple));
childSetVisible("texture_preview_combo", (show_tex && !show_multiple));
childSetVisible("multiple_uploads_label", show_multiple);
childSetValue("asset_name", name);
} }
} }
} }
@@ -176,14 +223,14 @@ void ASFloaterUploadBrowser::onDoubleClick(void* user_data)
void ASFloaterUploadBrowser::handleDoubleClick() void ASFloaterUploadBrowser::handleDoubleClick()
{ {
if (mFileList->getFirstSelected()->getColumn(LIST_FILE_TYPE)->getValue().asInteger() == LIST_TYPE_PARENT) if (mFileList->getFirstSelected()->getColumn(LIST_ASSET_TYPE)->getValue().asInteger() == LIST_TYPE_PARENT)
{ {
S32 dirLimiterIndex = mPathName.find_last_of(gDirUtilp->getDirDelimiter()); S32 dirLimiterIndex = mPathName.find_last_of(gDirUtilp->getDirDelimiter());
mPathName = mPathName.substr(0, dirLimiterIndex); mPathName = mPathName.substr(0, dirLimiterIndex);
refresh(); refresh();
mFileList->selectFirstItem(); mFileList->selectFirstItem();
} }
else if (mFileList->getFirstSelected()->getColumn(LIST_FILE_TYPE)->getValue().asInteger() == LIST_TYPE_FOLDER) else if (mFileList->getFirstSelected()->getColumn(LIST_ASSET_TYPE)->getValue().asInteger() == LIST_TYPE_FOLDER)
{ {
//Make sure that it's an actual folder so you don't get stuck - Specifically meant for files with no extension. -HgB //Make sure that it's an actual folder so you don't get stuck - Specifically meant for files with no extension. -HgB
std::string new_path = mPathName + gDirUtilp->getDirDelimiter() + mFileList->getFirstSelected()->getColumn(LIST_FILE_NAME)->getValue().asString(); std::string new_path = mPathName + gDirUtilp->getDirDelimiter() + mFileList->getFirstSelected()->getColumn(LIST_FILE_NAME)->getValue().asString();
@@ -205,7 +252,8 @@ void ASFloaterUploadBrowser::refresh()
mFileList->deselectAllItems(); mFileList->deselectAllItems();
mFileList->deleteAllItems(); mFileList->deleteAllItems();
childSetValue("dir_path", gDirUtilp->getDirName(fullPath)); childSetValue("dir_path", gDirUtilp->getDirName(fullPath));
gSavedSettings.setString("AscentUploadFolder", mPathName); mUploaderSettings["ActivePath"] = mPathName;
gSavedSettings.setLLSD("AscentUploadSettings", mUploaderSettings);
gDirUtilp->getNextFileInDir(gDirUtilp->getChatLogsDir(),"*", filename, false); //Clears the last file gDirUtilp->getNextFileInDir(gDirUtilp->getChatLogsDir(),"*", filename, false); //Clears the last file
bool found = true; bool found = true;
S32 file_count = 0; S32 file_count = 0;
@@ -229,46 +277,62 @@ void ASFloaterUploadBrowser::refresh()
filetype_column["column"] = "file_type"; filetype_column["column"] = "file_type";
filetype_column["type"] = "number"; filetype_column["type"] = "number";
LLSD& assettype_column = element["columns"][LIST_ASSET_TYPE];
assettype_column["column"] = "asset_type";
assettype_column["type"] = "number";
LLSD& invtype_column = element["columns"][LIST_INVENTORY_TYPE]; LLSD& invtype_column = element["columns"][LIST_INVENTORY_TYPE];
invtype_column["column"] = "icon_inventory_type"; invtype_column["column"] = "icon_inventory_type";
invtype_column["type"] = "icon"; invtype_column["type"] = "icon";
invtype_column["value"] = "inv_folder_trash.tga"; invtype_column["value"] = "inv_folder_trash.tga";
if (((extensionL == "jpeg")||(extensionL == "jpg")||(extensionL == "tga") if (((extensionL == "jpeg")||(extensionL == "jpg")||(extensionL == "tga")
||(extensionL == "png")||(extensionL == "bmp"))&&((mFilterType == "None")||(mFilterType == "Texture"))) ||(extensionL == "png")||(extensionL == "bmp"))&&((mFilterType == "None")||(mFilterType == "Texture")))
{ {
invtype_column["value"] = "inv_item_texture.tga"; invtype_column["value"] = "inv_item_texture.tga";
filename_column["value"] = filename.substr(0, periodIndex); filename_column["value"] = filename.substr(0, periodIndex);
filetype_column["value"] = LIST_TYPE_FILE; filetype_column["value"] = FILE_TEXTURE;
assettype_column["value"] = LIST_TYPE_FILE;
} }
else if ((extensionL == "wav")&&((mFilterType == "None")||(mFilterType == "Sound"))) else if ((extensionL == "wav")&&((mFilterType == "None")||(mFilterType == "Sound")))
{ {
invtype_column["value"] = "inv_item_sound.tga"; invtype_column["value"] = "inv_item_sound.tga";
filename_column["value"] = filename.substr(0, periodIndex); filename_column["value"] = filename.substr(0, periodIndex);
filetype_column["value"] = LIST_TYPE_FILE; filetype_column["value"] = FILE_SOUND;
assettype_column["value"] = LIST_TYPE_FILE;
} }
else if (((extensionL == "bvh")||(extensionL == "anim"))&&((mFilterType == "None")||(mFilterType == "Animation"))) else if (((extensionL == "bvh")||(extensionL == "anim"))&&((mFilterType == "None")||(mFilterType == "Animation")))
{ {
invtype_column["value"] = "inv_item_animation.tga"; invtype_column["value"] = "inv_item_animation.tga";
filename_column["value"] = filename.substr(0, periodIndex); filename_column["value"] = filename.substr(0, periodIndex);
filetype_column["value"] = LIST_TYPE_FILE; filetype_column["value"] = FILE_ANIMATION;
assettype_column["value"] = LIST_TYPE_FILE;
} }
else if ((extension == filename.substr(0, filename.length() - 1))&&(filename != ".")) else if ((extension == filename.substr(0, filename.length() - 1))&&(filename != "."))
{ {
invtype_column["value"] = "inv_folder_plain_closed.tga"; std::string test_path = mPathName + gDirUtilp->getDirDelimiter() + filename + gDirUtilp->getDirDelimiter();
filename_column["value"] = filename; S32 file_count = gDirUtilp->countFilesInDir(test_path, "*.*");
filetype_column["value"] = LIST_TYPE_FOLDER; if(file_count)
{
invtype_column["value"] = "inv_folder_plain_closed.tga";
filename_column["value"] = filename;
filetype_column["value"] = FOLDER;
assettype_column["value"] = LIST_TYPE_FOLDER;
}
} }
else if (filename == "..") else if (filename == "..")
{ {
invtype_column["value"] = "inv_folder_plain_open.tga"; invtype_column["value"] = "inv_folder_plain_open.tga";
filename_column["value"] = filename; filename_column["value"] = filename;
filetype_column["value"] = LIST_TYPE_PARENT; filetype_column["value"] = FOLDER;
assettype_column["value"] = LIST_TYPE_PARENT;
} }
if (invtype_column["value"].asString() != "inv_folder_trash.tga") if (invtype_column["value"].asString() != "inv_folder_trash.tga")
{ {
mFileList->addElement(element, ADD_BOTTOM); mFileList->addElement(element, ADD_BOTTOM);
if (filetype_column["value"].asInteger() == LIST_TYPE_FILE) if (assettype_column["value"].asInteger() == LIST_TYPE_FILE)
{ {
file_count++; file_count++;
} }
@@ -278,6 +342,8 @@ void ASFloaterUploadBrowser::refresh()
std::string result; std::string result;
LLResMgr::getInstance()->getIntegerString(result, file_count); LLResMgr::getInstance()->getIntegerString(result, file_count);
if (result == "")
result = "0";
childSetTextArg("result_label", "[COUNT]", result); childSetTextArg("result_label", "[COUNT]", result);
mFileList->sortItems(); mFileList->sortItems();

View File

@@ -28,10 +28,11 @@ public:
static void onClickFile(LLUICtrl* ctrl, void* user_data); static void onClickFile(LLUICtrl* ctrl, void* user_data);
static void onUpdateFilter(LLUICtrl* ctrl, void* user_data); static void onUpdateFilter(LLUICtrl* ctrl, void* user_data);
static void onDoubleClick(void* user_data); static void onDoubleClick(void* user_data);
static void onDirCommit (LLUICtrl* ctrl, void* data);
static void onChangeDrives(LLUICtrl* ctrl, void* user_data); static void onChangeDrives(LLUICtrl* ctrl, void* user_data);
static void onClickFilepathGoto(void* data); static void onClickFilepathGoto(void* data);
void updateBrowser(void* data, std::string new_path);
void refresh(); void refresh();
void refreshUploadOptions(); void refreshUploadOptions();
void handleDoubleClick(); void handleDoubleClick();
@@ -40,10 +41,12 @@ public:
std::vector<LLSD> datas; std::vector<LLSD> datas;
private: private:
static LLSD mUploaderSettings;
static ASFloaterUploadBrowser* sInstance; static ASFloaterUploadBrowser* sInstance;
enum FILE_COLUMN_ORDER enum FILE_COLUMN_ORDER
{ {
LIST_FILE_TYPE, LIST_FILE_TYPE,
LIST_ASSET_TYPE,
LIST_INVENTORY_TYPE, LIST_INVENTORY_TYPE,
LIST_FILE_NAME, LIST_FILE_NAME,
LIST_DATA LIST_DATA
@@ -54,6 +57,13 @@ private:
LIST_TYPE_FOLDER, LIST_TYPE_FOLDER,
LIST_TYPE_FILE LIST_TYPE_FILE
}; };
enum FILE_TYPE
{
FOLDER,
FILE_TEXTURE,
FILE_SOUND,
FILE_ANIMATION
};
LLScrollListCtrl* mFileList; LLScrollListCtrl* mFileList;
LLComboBox* mDriveCombo; LLComboBox* mDriveCombo;
LLComboBox* mBookmarkCombo; LLComboBox* mBookmarkCombo;

View File

@@ -42,6 +42,7 @@
tool_tip="Hold shift or control while clicking to select multiple files" tool_tip="Hold shift or control while clicking to select multiple files"
top="-68"> top="-68">
<column name="file_type" width="0" /> <column name="file_type" width="0" />
<column name="asset_type" width="0" />
<column image="ff_edit_mine_button.tga" name="icon_inventory_type" <column image="ff_edit_mine_button.tga" name="icon_inventory_type"
tool_tip="Inventory Type" width="20" /> tool_tip="Inventory Type" width="20" />
<column dynamicwidth="true" label="Filename" name="file_name" tool_tip="Filename" /> <column dynamicwidth="true" label="Filename" name="file_name" tool_tip="Filename" />
@@ -89,12 +90,55 @@
</text> </text>
<line_editor bottom_delta="-4" follows="left|top" font="SansSerifSmall" height="18" max_length="255" <line_editor bottom_delta="-4" follows="left|top" font="SansSerifSmall" height="18" max_length="255"
width="214" name="asset_desc" left_delta="70" select_all_on_focus_received="true" select_on_focus="true"/> width="214" name="asset_desc" left_delta="70" select_all_on_focus_received="true" select_on_focus="true"/>
<text bottom_delta="-20" follows="top|left" height="12" name="multiple_uploads_label" left="302">
Multiple files selected. Total cost is:
</text>
<text bottom_delta="0" follows="top|left" height="12" name="texture_preview_label" left="302">
Preview image as:
</text>
<combo_box bottom_delta="-5" follows="left|top" height="18" label="Texture Preview"
left_delta="120" name="texture_preview_combo" width="164">
<combo_item name="Image">
Image
</combo_item>
<combo_item name="Hair">
Hair
</combo_item>
<combo_item name="FemaleHead">
Female Head
</combo_item>
<combo_item name="FemaleUpperBody">
Female Upper Body
</combo_item>
<combo_item name="FemaleLowerBody">
Female Lower Body
</combo_item>
<combo_item name="MaleHead">
Male Head
</combo_item>
<combo_item name="MaleUpperBody">
Male Upper Body
</combo_item>
<combo_item name="MaleLowerBody">
Male Lower Body
</combo_item>
<combo_item name="Skirt">
Skirt
</combo_item>
<combo_item name="SculptedPrim">
Sculpted Prim
</combo_item>
</combo_box>
<text bottom="250" follows="top|left" left="302" name="bad_image_text">
Unable to read image.
Try saving image as 24 bit Targa (.tga).
</text>
<slider bottom_delta="0" can_edit_text="false" enabled="false" width="185" height="16" mouse_opaque="true" <slider bottom_delta="0" can_edit_text="false" enabled="false" width="185" height="16" mouse_opaque="true"
decimal_digits="0" increment="1" initial_val="16" left="30" min_val="1.0" max_val="16.0" visible="false" decimal_digits="0" increment="1" initial_val="16" left="30" min_val="1.0" max_val="16.0" visible="false"
name="timeline" show_text="false" value="1" control_name="AnimationTimelineScrubber"/> name="timeline" show_text="false" value="1" control_name="AnimationTimelineScrubber"/>
<button bottom="9" follows="bottom|left" height="22" label="Upload (L$10)" <button bottom="9" follows="bottom|left" height="22" label="Upload (L$10)"
left="325" name="upload_button" tool_tip="Standard upload (L$10)" left="325" name="upload_button" width="120" />
width="120" />
<button bottom_delta="0" follows="bottom|left" height="22" label="Temp Upload" <button bottom_delta="0" follows="bottom|left" height="22" label="Temp Upload"
left_delta="125" name="upload_button" tool_tip="Uploads a temporary version of the texture. It's free, but has a limited lifespan and area it can be used." left_delta="125" name="upload_button" tool_tip="Uploads a temporary version of the texture. It's free, but has a limited lifespan and area it can be used."
width="120" /> width="120" />