Updated LLFloaterBuyContents
This commit is contained in:
@@ -58,26 +58,36 @@
|
|||||||
|
|
||||||
#include "hippogridmanager.h"
|
#include "hippogridmanager.h"
|
||||||
|
|
||||||
LLFloaterBuyContents* LLFloaterBuyContents::sInstance = NULL;
|
|
||||||
|
|
||||||
LLFloaterBuyContents::LLFloaterBuyContents()
|
LLFloaterBuyContents::LLFloaterBuyContents()
|
||||||
: LLFloater(std::string("floater_buy_contents"), std::string("FloaterBuyContentsRect"), LLStringUtil::null)
|
: LLFloater(std::string("floater_buy_contents"), std::string("FloaterBuyContentsRect"), LLStringUtil::null)
|
||||||
{
|
{
|
||||||
LLUICtrlFactory::getInstance()->buildFloater(this, "floater_buy_contents.xml");
|
LLUICtrlFactory::getInstance()->buildFloater(this, "floater_buy_contents.xml");
|
||||||
|
}
|
||||||
|
|
||||||
childSetAction("cancel_btn", onClickCancel, this);
|
BOOL LLFloaterBuyContents::postBuild()
|
||||||
childSetAction("buy_btn", onClickBuy, this);
|
{
|
||||||
|
|
||||||
childDisable("item_list");
|
getChild<LLUICtrl>("cancel_btn")->setCommitCallback( boost::bind(&LLFloaterBuyContents::onClickCancel, this));
|
||||||
childDisable("buy_btn");
|
getChild<LLUICtrl>("buy_btn")->setCommitCallback( boost::bind(&LLFloaterBuyContents::onClickBuy, this));
|
||||||
childDisable("wear_check");
|
|
||||||
|
getChildView("item_list")->setEnabled(FALSE);
|
||||||
|
getChildView("buy_btn")->setEnabled(FALSE);
|
||||||
|
getChildView("wear_check")->setEnabled(FALSE);
|
||||||
|
|
||||||
setDefaultBtn("cancel_btn"); // to avoid accidental buy (SL-43130)
|
setDefaultBtn("cancel_btn"); // to avoid accidental buy (SL-43130)
|
||||||
|
|
||||||
|
// Always center the dialog. User can change the size,
|
||||||
|
// but purchases are important and should be center screen.
|
||||||
|
// This also avoids problems where the user resizes the application window
|
||||||
|
// mid-session and the saved rect is off-center.
|
||||||
|
center();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLFloaterBuyContents::~LLFloaterBuyContents()
|
LLFloaterBuyContents::~LLFloaterBuyContents()
|
||||||
{
|
{
|
||||||
sInstance = NULL;
|
removeVOInventoryListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -92,26 +102,20 @@ void LLFloaterBuyContents::show(const LLSaleInfo& sale_info)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new instance only if needed
|
LLFloaterBuyContents* floater = getInstance();
|
||||||
if (sInstance)
|
LLScrollListCtrl* list = floater->getChild<LLScrollListCtrl>("item_list");
|
||||||
{
|
if (list)
|
||||||
LLScrollListCtrl* list = sInstance->getChild<LLScrollListCtrl>("item_list");
|
list->deleteAllItems();
|
||||||
if (list) list->deleteAllItems();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sInstance = new LLFloaterBuyContents();
|
|
||||||
}
|
|
||||||
|
|
||||||
sInstance->open(); /*Flawfinder: ignore*/
|
floater->mObjectSelection = LLSelectMgr::getInstance()->getEditSelection();
|
||||||
sInstance->setFocus(TRUE);
|
|
||||||
sInstance->mObjectSelection = LLSelectMgr::getInstance()->getEditSelection();
|
|
||||||
|
|
||||||
|
floater->open(); /*Flawfinder: ignore*/
|
||||||
|
floater->setFocus(TRUE);
|
||||||
// Always center the dialog. User can change the size,
|
// Always center the dialog. User can change the size,
|
||||||
// but purchases are important and should be center screen.
|
// but purchases are important and should be center screen.
|
||||||
// This also avoids problems where the user resizes the application window
|
// This also avoids problems where the user resizes the application window
|
||||||
// mid-session and the saved rect is off-center.
|
// mid-session and the saved rect is off-center.
|
||||||
sInstance->center();
|
floater->center();
|
||||||
|
|
||||||
LLUUID owner_id;
|
LLUUID owner_id;
|
||||||
std::string owner_name;
|
std::string owner_name;
|
||||||
@@ -122,7 +126,7 @@ void LLFloaterBuyContents::show(const LLSaleInfo& sale_info)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sInstance->mSaleInfo = sale_info;
|
floater->mSaleInfo = sale_info;
|
||||||
|
|
||||||
// Update the display
|
// Update the display
|
||||||
LLSelectNode* node = selection->getFirstRootNode();
|
LLSelectNode* node = selection->getFirstRootNode();
|
||||||
@@ -132,17 +136,17 @@ void LLFloaterBuyContents::show(const LLSaleInfo& sale_info)
|
|||||||
gCacheName->getGroupName(owner_id, owner_name);
|
gCacheName->getGroupName(owner_id, owner_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
sInstance->childSetTextArg("contains_text", "[NAME]", node->mName);
|
floater->getChild<LLUICtrl>("contains_text")->setTextArg("[NAME]", node->mName);
|
||||||
sInstance->childSetTextArg("buy_text", "[CURRENCY]", gHippoGridManager->getConnectedGrid()->getCurrencySymbol());
|
floater->getChild<LLUICtrl>("buy_text")->setTextArg("[CURRENCY]", gHippoGridManager->getConnectedGrid()->getCurrencySymbol());
|
||||||
sInstance->childSetTextArg("buy_text", "[AMOUNT]", llformat("%d", sale_info.getSalePrice()));
|
floater->getChild<LLUICtrl>("buy_text")->setTextArg("[AMOUNT]", llformat("%d", sale_info.getSalePrice()));
|
||||||
sInstance->childSetTextArg("buy_text", "[NAME]", owner_name);
|
floater->getChild<LLUICtrl>("buy_text")->setTextArg("[NAME]", owner_name);
|
||||||
|
|
||||||
// Must do this after the floater is created, because
|
// Must do this after the floater is created, because
|
||||||
// sometimes the inventory is already there and
|
// sometimes the inventory is already there and
|
||||||
// the callback is called immediately.
|
// the callback is called immediately.
|
||||||
LLViewerObject* obj = selection->getFirstRootObject();
|
LLViewerObject* obj = selection->getFirstRootObject();
|
||||||
sInstance->registerVOInventoryListener(obj,NULL);
|
floater->registerVOInventoryListener(obj,NULL);
|
||||||
sInstance->requestVOInventory();
|
floater->requestVOInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -157,23 +161,26 @@ void LLFloaterBuyContents::inventoryChanged(LLViewerObject* obj,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inv)
|
LLScrollListCtrl* item_list = getChild<LLScrollListCtrl>("item_list");
|
||||||
{
|
|
||||||
llwarns << "No inventory in LLFloaterBuyContents::inventoryChanged"
|
|
||||||
<< llendl;
|
|
||||||
removeVOInventoryListener();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LLCtrlListInterface *item_list = childGetListInterface("item_list");
|
|
||||||
if (!item_list)
|
if (!item_list)
|
||||||
{
|
{
|
||||||
removeVOInventoryListener();
|
removeVOInventoryListener();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item_list->deleteAllItems();
|
||||||
|
|
||||||
|
if (!inv)
|
||||||
|
{
|
||||||
|
llwarns << "No inventory in LLFloaterBuyContents::inventoryChanged"
|
||||||
|
<< llendl;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// default to turning off the buy button.
|
// default to turning off the buy button.
|
||||||
childDisable("buy_btn");
|
LLView* buy_btn = getChildView("buy_btn");
|
||||||
|
buy_btn->setEnabled(FALSE);
|
||||||
|
|
||||||
LLUUID owner_id;
|
LLUUID owner_id;
|
||||||
BOOL is_group_owned;
|
BOOL is_group_owned;
|
||||||
@@ -214,13 +221,15 @@ void LLFloaterBuyContents::inventoryChanged(LLViewerObject* obj,
|
|||||||
|
|
||||||
// There will be at least one item shown in the display, so go
|
// There will be at least one item shown in the display, so go
|
||||||
// ahead and enable the buy button.
|
// ahead and enable the buy button.
|
||||||
childEnable("buy_btn");
|
buy_btn->setEnabled(TRUE);
|
||||||
|
|
||||||
// Create the line in the list
|
// Create the line in the list
|
||||||
LLSD row;
|
LLSD row;
|
||||||
|
|
||||||
BOOL item_is_multi = FALSE;
|
BOOL item_is_multi = FALSE;
|
||||||
if ( inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_LANDMARK_VISITED )
|
if ((inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_LANDMARK_VISITED
|
||||||
|
|| inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS)
|
||||||
|
&& !(inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_WEARABLES_MASK))
|
||||||
{
|
{
|
||||||
item_is_multi = TRUE;
|
item_is_multi = TRUE;
|
||||||
}
|
}
|
||||||
@@ -260,28 +269,25 @@ void LLFloaterBuyContents::inventoryChanged(LLViewerObject* obj,
|
|||||||
|
|
||||||
if (wearable_count > 0)
|
if (wearable_count > 0)
|
||||||
{
|
{
|
||||||
childEnable("wear_check");
|
getChildView("wear_check")->setEnabled(TRUE);
|
||||||
childSetValue("wear_check", LLSD(false) );
|
getChild<LLUICtrl>("wear_check")->setValue(LLSD(false) );
|
||||||
}
|
}
|
||||||
|
|
||||||
removeVOInventoryListener();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// static
|
void LLFloaterBuyContents::onClickBuy()
|
||||||
void LLFloaterBuyContents::onClickBuy(void*)
|
|
||||||
{
|
{
|
||||||
// Make sure this wasn't selected through other mechanisms
|
// Make sure this wasn't selected through other mechanisms
|
||||||
// (ie, being the default button and pressing enter.
|
// (ie, being the default button and pressing enter.
|
||||||
if(!sInstance->childIsEnabled("buy_btn"))
|
if(!getChildView("buy_btn")->getEnabled())
|
||||||
{
|
{
|
||||||
// We shouldn't be enabled. Just close.
|
// We shouldn't be enabled. Just close.
|
||||||
sInstance->close();
|
close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We may want to wear this item
|
// We may want to wear this item
|
||||||
if (sInstance->childGetValue("wear_check"))
|
if (getChild<LLUICtrl>("wear_check")->getValue())
|
||||||
{
|
{
|
||||||
LLInventoryState::sWearNewClothing = TRUE;
|
LLInventoryState::sWearNewClothing = TRUE;
|
||||||
}
|
}
|
||||||
@@ -293,14 +299,14 @@ void LLFloaterBuyContents::onClickBuy(void*)
|
|||||||
// *NOTE: doesn't work for multiple object buy, which UI does not
|
// *NOTE: doesn't work for multiple object buy, which UI does not
|
||||||
// currently support sale info is used for verification only, if
|
// currently support sale info is used for verification only, if
|
||||||
// it doesn't match region info then sale is canceled.
|
// it doesn't match region info then sale is canceled.
|
||||||
LLSelectMgr::getInstance()->sendBuy(gAgent.getID(), category_id, sInstance->mSaleInfo);
|
LLSelectMgr::getInstance()->sendBuy(gAgent.getID(), category_id, mSaleInfo);
|
||||||
|
|
||||||
sInstance->close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void LLFloaterBuyContents::onClickCancel(void*)
|
void LLFloaterBuyContents::onClickCancel()
|
||||||
{
|
{
|
||||||
sInstance->close();
|
close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,27 +47,26 @@ class LLViewerObject;
|
|||||||
class LLObjectSelection;
|
class LLObjectSelection;
|
||||||
|
|
||||||
class LLFloaterBuyContents
|
class LLFloaterBuyContents
|
||||||
: public LLFloater, public LLVOInventoryListener
|
: public LLFloater, public LLVOInventoryListener, public LLSingleton<LLFloaterBuyContents>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void show(const LLSaleInfo& sale_info);
|
static void show(const LLSaleInfo& sale_info);
|
||||||
|
|
||||||
protected:
|
|
||||||
LLFloaterBuyContents();
|
LLFloaterBuyContents();
|
||||||
~LLFloaterBuyContents();
|
~LLFloaterBuyContents();
|
||||||
|
/*virtual*/ BOOL postBuild();
|
||||||
|
|
||||||
|
protected:
|
||||||
void requestObjectInventories();
|
void requestObjectInventories();
|
||||||
/*virtual*/ void inventoryChanged(LLViewerObject* obj,
|
/*virtual*/ void inventoryChanged(LLViewerObject* obj,
|
||||||
LLInventoryObject::object_list_t* inv,
|
LLInventoryObject::object_list_t* inv,
|
||||||
S32 serial_num,
|
S32 serial_num,
|
||||||
void* data);
|
void* data);
|
||||||
|
|
||||||
static void onClickBuy(void*);
|
void onClickBuy();
|
||||||
static void onClickCancel(void*);
|
void onClickCancel();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static LLFloaterBuyContents* sInstance;
|
|
||||||
|
|
||||||
LLSafeHandle<LLObjectSelection> mObjectSelection;
|
LLSafeHandle<LLObjectSelection> mObjectSelection;
|
||||||
LLSaleInfo mSaleInfo;
|
LLSaleInfo mSaleInfo;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user