summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelsnapshotinventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpanelsnapshotinventory.cpp')
-rw-r--r--indra/newview/llpanelsnapshotinventory.cpp128
1 files changed, 33 insertions, 95 deletions
diff --git a/indra/newview/llpanelsnapshotinventory.cpp b/indra/newview/llpanelsnapshotinventory.cpp
index 5a7dd92b98..dda14c1e32 100644
--- a/indra/newview/llpanelsnapshotinventory.cpp
+++ b/indra/newview/llpanelsnapshotinventory.cpp
@@ -42,77 +42,35 @@
/**
* The panel provides UI for saving snapshot as an inventory texture.
*/
-class LLPanelSnapshotInventoryBase
- : public LLPanelSnapshot
-{
- LOG_CLASS(LLPanelSnapshotInventoryBase);
-
-public:
- LLPanelSnapshotInventoryBase();
-
- /*virtual*/ bool postBuild();
-protected:
- void onSend();
- /*virtual*/ LLSnapshotModel::ESnapshotType getSnapshotType();
-};
-
class LLPanelSnapshotInventory
- : public LLPanelSnapshotInventoryBase
+ : public LLPanelSnapshot
{
LOG_CLASS(LLPanelSnapshotInventory);
public:
LLPanelSnapshotInventory();
- /*virtual*/ bool postBuild();
- /*virtual*/ void onOpen(const LLSD& key);
+ bool postBuild() override;
+ void onOpen(const LLSD& key) override;
void onResolutionCommit(LLUICtrl* ctrl);
private:
- /*virtual*/ std::string getWidthSpinnerName() const { return "inventory_snapshot_width"; }
- /*virtual*/ std::string getHeightSpinnerName() const { return "inventory_snapshot_height"; }
- /*virtual*/ std::string getAspectRatioCBName() const { return "inventory_keep_aspect_check"; }
- /*virtual*/ std::string getImageSizeComboName() const { return "texture_size_combo"; }
- /*virtual*/ std::string getImageSizePanelName() const { return LLStringUtil::null; }
- /*virtual*/ void updateControls(const LLSD& info);
-
-};
-
-class LLPanelOutfitSnapshotInventory
- : public LLPanelSnapshotInventoryBase
-{
- LOG_CLASS(LLPanelOutfitSnapshotInventory);
-
-public:
- LLPanelOutfitSnapshotInventory();
- /*virtual*/ bool postBuild();
- /*virtual*/ void onOpen(const LLSD& key);
+ std::string getWidthSpinnerName() const override { return "inventory_snapshot_width"; }
+ std::string getHeightSpinnerName() const override { return "inventory_snapshot_height"; }
+ std::string getAspectRatioCBName() const override { return "inventory_keep_aspect_check"; }
+ std::string getImageSizeComboName() const override { return "texture_size_combo"; }
+ std::string getImageSizePanelName() const override { return LLStringUtil::null; }
+ LLSnapshotModel::ESnapshotType getSnapshotType() override;
+ void updateControls(const LLSD& info) override;
-private:
- /*virtual*/ std::string getWidthSpinnerName() const { return ""; }
- /*virtual*/ std::string getHeightSpinnerName() const { return ""; }
- /*virtual*/ std::string getAspectRatioCBName() const { return ""; }
- /*virtual*/ std::string getImageSizeComboName() const { return "texture_size_combo"; }
- /*virtual*/ std::string getImageSizePanelName() const { return LLStringUtil::null; }
- /*virtual*/ void updateControls(const LLSD& info);
-
- /*virtual*/ void cancel();
+ void onSend();
+ void updateUploadCost();
+ S32 calculateUploadCost();
};
static LLPanelInjector<LLPanelSnapshotInventory> panel_class1("llpanelsnapshotinventory");
-static LLPanelInjector<LLPanelOutfitSnapshotInventory> panel_class2("llpaneloutfitsnapshotinventory");
-
-LLPanelSnapshotInventoryBase::LLPanelSnapshotInventoryBase()
-{
-}
-
-bool LLPanelSnapshotInventoryBase::postBuild()
-{
- return LLPanelSnapshot::postBuild();
-}
-
-LLSnapshotModel::ESnapshotType LLPanelSnapshotInventoryBase::getSnapshotType()
+LLSnapshotModel::ESnapshotType LLPanelSnapshotInventory::getSnapshotType()
{
return LLSnapshotModel::SNAPSHOT_TEXTURE;
}
@@ -130,12 +88,14 @@ bool LLPanelSnapshotInventory::postBuild()
getChild<LLSpinCtrl>(getHeightSpinnerName())->setAllowEdit(false);
getChild<LLUICtrl>(getImageSizeComboName())->setCommitCallback(boost::bind(&LLPanelSnapshotInventory::onResolutionCommit, this, _1));
- return LLPanelSnapshotInventoryBase::postBuild();
+ return LLPanelSnapshot::postBuild();
}
// virtual
void LLPanelSnapshotInventory::onOpen(const LLSD& key)
{
+ updateUploadCost();
+
LLPanelSnapshot::onOpen(key);
}
@@ -144,6 +104,8 @@ void LLPanelSnapshotInventory::updateControls(const LLSD& info)
{
const bool have_snapshot = info.has("have-snapshot") ? info["have-snapshot"].asBoolean() : true;
getChild<LLUICtrl>("save_btn")->setEnabled(have_snapshot);
+
+ updateUploadCost();
}
void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl)
@@ -153,21 +115,9 @@ void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl)
getChild<LLSpinCtrl>(getHeightSpinnerName())->setVisible(!current_window_selected);
}
-void LLPanelSnapshotInventoryBase::onSend()
+void LLPanelSnapshotInventory::onSend()
{
- S32 w = 0;
- S32 h = 0;
-
- if( mSnapshotFloater )
- {
- LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView();
- if( preview )
- {
- preview->getSize(w, h);
- }
- }
-
- S32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(w, h);
+ S32 expected_upload_cost = calculateUploadCost();
if (can_afford_transaction(expected_upload_cost))
{
if (mSnapshotFloater)
@@ -188,36 +138,24 @@ void LLPanelSnapshotInventoryBase::onSend()
}
}
-LLPanelOutfitSnapshotInventory::LLPanelOutfitSnapshotInventory()
+void LLPanelSnapshotInventory::updateUploadCost()
{
- mCommitCallbackRegistrar.add("Inventory.SaveOutfitPhoto", { boost::bind(&LLPanelOutfitSnapshotInventory::onSend, this), cb_info::UNTRUSTED_BLOCK });
- mCommitCallbackRegistrar.add("Inventory.SaveOutfitCancel", { boost::bind(&LLPanelOutfitSnapshotInventory::cancel, this), cb_info::UNTRUSTED_BLOCK });
+ getChild<LLUICtrl>("hint_lbl")->setTextArg("[UPLOAD_COST]", llformat("%d", calculateUploadCost()));
}
-// virtual
-bool LLPanelOutfitSnapshotInventory::postBuild()
+S32 LLPanelSnapshotInventory::calculateUploadCost()
{
- return LLPanelSnapshotInventoryBase::postBuild();
-}
-
-// virtual
-void LLPanelOutfitSnapshotInventory::onOpen(const LLSD& key)
-{
- getChild<LLUICtrl>("hint_lbl")->setTextArg("[UPLOAD_COST]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost()));
- LLPanelSnapshot::onOpen(key);
-}
-
-// virtual
-void LLPanelOutfitSnapshotInventory::updateControls(const LLSD& info)
-{
- const bool have_snapshot = info.has("have-snapshot") ? info["have-snapshot"].asBoolean() : true;
- getChild<LLUICtrl>("save_btn")->setEnabled(have_snapshot);
-}
+ S32 w = 0;
+ S32 h = 0;
-void LLPanelOutfitSnapshotInventory::cancel()
-{
if (mSnapshotFloater)
{
- mSnapshotFloater->closeFloater();
+ if (LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView())
+ {
+ w = preview->getEncodedImageWidth();
+ h = preview->getEncodedImageHeight();
+ }
}
+
+ return LLAgentBenefitsMgr::current().getTextureUploadCost(w, h);
}