Skip to content
Snippets Groups Projects
Commit b0b68903 authored by Nyx (Neal Orman)'s avatar Nyx (Neal Orman)
Browse files

EXT-4253 "unsaved" detection seems buggy

Corrected bug where saving an outfit wouldn't update the "unsaved" marker on
the UI. Also switched the UI to use a popup dialog to request the name of
the outfit being made, as we could not convey everything we needed to on the
button alone.

Code reviewed by Vir
parent e1105245
Branches
Tags
No related merge requests found
...@@ -1364,15 +1364,15 @@ void LLAgentWearables::makeNewOutfit(const std::string& new_folder_name, ...@@ -1364,15 +1364,15 @@ void LLAgentWearables::makeNewOutfit(const std::string& new_folder_name,
} }
} }
class LLAutoRenameFolder: public LLInventoryCallback class LLShowCreatedOutfit: public LLInventoryCallback
{ {
public: public:
LLAutoRenameFolder(LLUUID& folder_id): LLShowCreatedOutfit(LLUUID& folder_id):
mFolderID(folder_id) mFolderID(folder_id)
{ {
} }
virtual ~LLAutoRenameFolder() virtual ~LLShowCreatedOutfit()
{ {
LLSD key; LLSD key;
LLSideTray::getInstance()->showPanel("panel_outfits_inventory", key); LLSideTray::getInstance()->showPanel("panel_outfits_inventory", key);
...@@ -1382,13 +1382,15 @@ class LLAutoRenameFolder: public LLInventoryCallback ...@@ -1382,13 +1382,15 @@ class LLAutoRenameFolder: public LLInventoryCallback
{ {
outfit_panel->getRootFolder()->clearSelection(); outfit_panel->getRootFolder()->clearSelection();
outfit_panel->getRootFolder()->setSelectionByID(mFolderID, TRUE); outfit_panel->getRootFolder()->setSelectionByID(mFolderID, TRUE);
outfit_panel->getRootFolder()->setNeedsAutoRename(TRUE);
} }
LLAccordionCtrlTab* tab_outfits = outfit_panel ? outfit_panel->findChild<LLAccordionCtrlTab>("tab_outfits") : 0; LLAccordionCtrlTab* tab_outfits = outfit_panel ? outfit_panel->findChild<LLAccordionCtrlTab>("tab_outfits") : 0;
if (tab_outfits && !tab_outfits->getDisplayChildren()) if (tab_outfits && !tab_outfits->getDisplayChildren())
{ {
tab_outfits->changeOpenClose(tab_outfits->getDisplayChildren()); tab_outfits->changeOpenClose(tab_outfits->getDisplayChildren());
} }
LLAppearanceManager::instance().updateIsDirty();
LLAppearanceManager::instance().updatePanelOutfitName("");
} }
virtual void fire(const LLUUID&) virtual void fire(const LLUUID&)
...@@ -1413,9 +1415,9 @@ LLUUID LLAgentWearables::makeNewOutfitLinks(const std::string& new_folder_name) ...@@ -1413,9 +1415,9 @@ LLUUID LLAgentWearables::makeNewOutfitLinks(const std::string& new_folder_name)
LLFolderType::FT_OUTFIT, LLFolderType::FT_OUTFIT,
new_folder_name); new_folder_name);
LLPointer<LLInventoryCallback> cb = new LLAutoRenameFolder(folder_id); LLPointer<LLInventoryCallback> cb = new LLShowCreatedOutfit(folder_id);
LLAppearanceManager::instance().shallowCopyCategory(LLAppearanceManager::instance().getCOF(),folder_id, cb); LLAppearanceManager::instance().shallowCopyCategory(LLAppearanceManager::instance().getCOF(),folder_id, cb);
LLAppearanceManager::instance().createBaseOutfitLink(folder_id, NULL); LLAppearanceManager::instance().createBaseOutfitLink(folder_id, cb);
return folder_id; return folder_id;
} }
......
...@@ -392,6 +392,21 @@ const LLViewerInventoryItem* LLAppearanceManager::getBaseOutfitLink() ...@@ -392,6 +392,21 @@ const LLViewerInventoryItem* LLAppearanceManager::getBaseOutfitLink()
return NULL; return NULL;
} }
bool LLAppearanceManager::getBaseOutfitName(std::string& name)
{
const LLViewerInventoryItem* outfit_link = getBaseOutfitLink();
if(outfit_link)
{
const LLViewerInventoryCategory *cat = outfit_link->getLinkedCategory();
if (cat)
{
name = cat->getName();
return true;
}
}
return false;
}
// Update appearance from outfit folder. // Update appearance from outfit folder.
void LLAppearanceManager::changeOutfit(bool proceed, const LLUUID& category, bool append) void LLAppearanceManager::changeOutfit(bool proceed, const LLUUID& category, bool append)
{ {
...@@ -630,6 +645,7 @@ void LLAppearanceManager::createBaseOutfitLink(const LLUUID& category, LLPointer ...@@ -630,6 +645,7 @@ void LLAppearanceManager::createBaseOutfitLink(const LLUUID& category, LLPointer
LLAssetType::AT_LINK_FOLDER, link_waiter); LLAssetType::AT_LINK_FOLDER, link_waiter);
new_outfit_name = catp->getName(); new_outfit_name = catp->getName();
} }
updatePanelOutfitName(new_outfit_name); updatePanelOutfitName(new_outfit_name);
} }
......
...@@ -63,6 +63,7 @@ class LLAppearanceManager: public LLSingleton<LLAppearanceManager> ...@@ -63,6 +63,7 @@ class LLAppearanceManager: public LLSingleton<LLAppearanceManager>
// Finds the folder link to the currently worn outfit // Finds the folder link to the currently worn outfit
const LLViewerInventoryItem *getBaseOutfitLink(); const LLViewerInventoryItem *getBaseOutfitLink();
bool getBaseOutfitName(std::string &name);
// Update the displayed outfit name in UI. // Update the displayed outfit name in UI.
void updatePanelOutfitName(const std::string& name); void updatePanelOutfitName(const std::string& name);
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "llagent.h" #include "llagent.h"
#include "llagentwearables.h" #include "llagentwearables.h"
#include "llappearancemgr.h"
#include "llbutton.h" #include "llbutton.h"
#include "llfloaterreg.h" #include "llfloaterreg.h"
...@@ -44,6 +45,8 @@ ...@@ -44,6 +45,8 @@
#include "llinventoryfunctions.h" #include "llinventoryfunctions.h"
#include "llinventorypanel.h" #include "llinventorypanel.h"
#include "lllandmark.h" #include "lllandmark.h"
#include "lllineeditor.h"
#include "llmodaldialog.h"
#include "llsidepanelappearance.h" #include "llsidepanelappearance.h"
#include "llsidetray.h" #include "llsidetray.h"
#include "lltabcontainer.h" #include "lltabcontainer.h"
...@@ -61,12 +64,75 @@ ...@@ -61,12 +64,75 @@
static LLRegisterPanelClassWrapper<LLPanelOutfitsInventory> t_inventory("panel_outfits_inventory"); static LLRegisterPanelClassWrapper<LLPanelOutfitsInventory> t_inventory("panel_outfits_inventory");
bool LLPanelOutfitsInventory::sShowDebugEditor = false; bool LLPanelOutfitsInventory::sShowDebugEditor = false;
class LLOutfitSaveAsDialog : public LLModalDialog
{
private:
std::string mItemName;
std::string mTempItemName;
boost::signals2::signal<void (const std::string&)> mSaveAsSignal;
public:
LLOutfitSaveAsDialog( const LLSD& key )
: LLModalDialog( key ),
mTempItemName(key.asString())
{
}
BOOL postBuild()
{
getChild<LLUICtrl>("Save")->setCommitCallback(boost::bind(&LLOutfitSaveAsDialog::onSave, this ));
getChild<LLUICtrl>("Cancel")->setCommitCallback(boost::bind(&LLOutfitSaveAsDialog::onCancel, this ));
childSetTextArg("name ed", "[DESC]", mTempItemName);
return TRUE;
}
void setSaveAsCommit( const boost::signals2::signal<void (const std::string&)>::slot_type& cb )
{
mSaveAsSignal.connect(cb);
}
virtual void onOpen(const LLSD& key)
{
LLLineEditor* edit = getChild<LLLineEditor>("name ed");
if (edit)
{
edit->setFocus(TRUE);
edit->selectAll();
}
}
void onSave()
{
mItemName = childGetValue("name ed").asString();
LLStringUtil::trim(mItemName);
if( !mItemName.empty() )
{
mSaveAsSignal(mItemName);
closeFloater(); // destroys this object
}
}
void onCancel()
{
closeFloater(); // destroys this object
}
};
LLPanelOutfitsInventory::LLPanelOutfitsInventory() : LLPanelOutfitsInventory::LLPanelOutfitsInventory() :
mActivePanel(NULL), mActivePanel(NULL),
mParent(NULL) mParent(NULL)
{ {
mSavedFolderState = new LLSaveFolderState(); mSavedFolderState = new LLSaveFolderState();
mSavedFolderState->setApply(FALSE); mSavedFolderState->setApply(FALSE);
static bool registered_dialog = false;
if (!registered_dialog)
{
LLFloaterReg::add("outfit_save_as", "floater_outfit_save_as.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLOutfitSaveAsDialog>);
registered_dialog = true;
}
} }
LLPanelOutfitsInventory::~LLPanelOutfitsInventory() LLPanelOutfitsInventory::~LLPanelOutfitsInventory()
...@@ -177,10 +243,28 @@ void LLPanelOutfitsInventory::onEdit() ...@@ -177,10 +243,28 @@ void LLPanelOutfitsInventory::onEdit()
{ {
} }
void LLPanelOutfitsInventory::onNew() void LLPanelOutfitsInventory::onSave()
{
std::string outfit_name;
if (!LLAppearanceManager::getInstance()->getBaseOutfitName(outfit_name))
{
outfit_name = LLViewerFolderType::lookupNewCategoryName(LLFolderType::FT_OUTFIT);
}
LLOutfitSaveAsDialog* save_as_dialog = LLFloaterReg::showTypedInstance<LLOutfitSaveAsDialog>("outfit_save_as", LLSD(outfit_name), TRUE);
if (save_as_dialog)
{
save_as_dialog->setSaveAsCommit(boost::bind(&LLPanelOutfitsInventory::onSaveCommit, this, _1 ));
}
}
void LLPanelOutfitsInventory::onSaveCommit(const std::string& outfit_name)
{ {
const std::string& outfit_name = LLViewerFolderType::lookupNewCategoryName(LLFolderType::FT_OUTFIT);
LLUUID outfit_folder = gAgentWearables.makeNewOutfitLinks(outfit_name); LLUUID outfit_folder = gAgentWearables.makeNewOutfitLinks(outfit_name);
LLSD key;
LLSideTray::getInstance()->showPanel("panel_outfits_inventory", key);
if (mAppearanceTabs) if (mAppearanceTabs)
{ {
mAppearanceTabs->selectTabByName("outfitslist_tab"); mAppearanceTabs->selectTabByName("outfitslist_tab");
...@@ -290,7 +374,7 @@ void LLPanelOutfitsInventory::onGearButtonClick() ...@@ -290,7 +374,7 @@ void LLPanelOutfitsInventory::onGearButtonClick()
void LLPanelOutfitsInventory::onAddButtonClick() void LLPanelOutfitsInventory::onAddButtonClick()
{ {
onNew(); onSave();
} }
void LLPanelOutfitsInventory::showActionMenu(LLMenuGL* menu, std::string spawning_view_name) void LLPanelOutfitsInventory::showActionMenu(LLMenuGL* menu, std::string spawning_view_name)
...@@ -329,7 +413,7 @@ void LLPanelOutfitsInventory::onCustomAction(const LLSD& userdata) ...@@ -329,7 +413,7 @@ void LLPanelOutfitsInventory::onCustomAction(const LLSD& userdata)
const std::string command_name = userdata.asString(); const std::string command_name = userdata.asString();
if (command_name == "new") if (command_name == "new")
{ {
onNew(); onSave();
} }
if (command_name == "edit") if (command_name == "edit")
{ {
......
...@@ -59,7 +59,9 @@ class LLPanelOutfitsInventory : public LLPanel ...@@ -59,7 +59,9 @@ class LLPanelOutfitsInventory : public LLPanel
void onAdd(); void onAdd();
void onRemove(); void onRemove();
void onEdit(); void onEdit();
void onNew(); void onSave();
void onSaveCommit(const std::string& item_name);
void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action); void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action);
void onSelectorButtonClicked(); void onSelectorButtonClicked();
......
...@@ -255,7 +255,7 @@ void LLSidepanelAppearance::onNewOutfitButtonClicked() ...@@ -255,7 +255,7 @@ void LLSidepanelAppearance::onNewOutfitButtonClicked()
{ {
if (!mLookInfo->getVisible()) if (!mLookInfo->getVisible())
{ {
mPanelOutfitsInventory->onNew(); mPanelOutfitsInventory->onSave();
} }
} }
...@@ -321,16 +321,12 @@ void LLSidepanelAppearance::refreshCurrentOutfitName(const std::string& name) ...@@ -321,16 +321,12 @@ void LLSidepanelAppearance::refreshCurrentOutfitName(const std::string& name)
mOutfitDirtyTag->setVisible(LLAppearanceManager::getInstance()->isOutfitDirty()); mOutfitDirtyTag->setVisible(LLAppearanceManager::getInstance()->isOutfitDirty());
if (name == "") if (name == "")
{ {
const LLViewerInventoryItem *outfit_link = LLAppearanceManager::getInstance()->getBaseOutfitLink(); std::string outfit_name;
if (outfit_link) if (LLAppearanceManager::getInstance()->getBaseOutfitName(outfit_name))
{
const LLViewerInventoryCategory *cat = outfit_link->getLinkedCategory();
if (cat && cat->getPreferredType() == LLFolderType::FT_OUTFIT)
{ {
mCurrentLookName->setText(cat->getName()); mCurrentLookName->setText(outfit_name);
return; return;
} }
}
mCurrentLookName->setText(getString("No Outfit")); mCurrentLookName->setText(getString("No Outfit"));
mOpenOutfitBtn->setEnabled(FALSE); mOpenOutfitBtn->setEnabled(FALSE);
} }
......
...@@ -61,6 +61,7 @@ class LLSidepanelAppearance : public LLPanel ...@@ -61,6 +61,7 @@ class LLSidepanelAppearance : public LLPanel
void fetchInventory(); void fetchInventory();
void inventoryFetched(); void inventoryFetched();
void updateVerbs(); void updateVerbs();
void onNewOutfitButtonClicked();
private: private:
void onFilterEdit(const std::string& search_string); void onFilterEdit(const std::string& search_string);
...@@ -68,7 +69,6 @@ class LLSidepanelAppearance : public LLPanel ...@@ -68,7 +69,6 @@ class LLSidepanelAppearance : public LLPanel
void onOpenOutfitButtonClicked(); void onOpenOutfitButtonClicked();
void onEditAppearanceButtonClicked(); void onEditAppearanceButtonClicked();
void onEditButtonClicked(); void onEditButtonClicked();
void onNewOutfitButtonClicked();
void onBackButtonClicked(); void onBackButtonClicked();
void onEditWearBackClicked(); void onEditWearBackClicked();
void toggleLookInfoPanel(BOOL visible); void toggleLookInfoPanel(BOOL visible);
......
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<floater
legacy_header_height="18"
border="true"
can_close="false"
can_minimize="false"
height="100"
layout="topleft"
name="modal container"
width="240">
<button
height="20"
label="Save"
label_selected="Save"
layout="topleft"
left="20"
name="Save"
top="70"
width="82" />
<button
height="20"
label="Cancel"
label_selected="Cancel"
layout="topleft"
left_pad="36"
name="Cancel"
top_delta="0"
width="82" />
<text
type="string"
length="1"
follows="left|top"
font="SansSerif"
height="16"
layout="topleft"
left="20"
name="Save item as:"
top="10"
width="200">
Save outfit as:
</text>
<line_editor
type="string"
length="1"
border_style="line"
border_thickness="1"
follows="left|top"
font="SansSerif"
handle_edit_keys_directly="true"
height="20"
layout="topleft"
left_delta="0"
max_length="63"
name="name ed"
top_pad="4"
width="200">
[DESC]
</line_editor>
</floater>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment