diff --git a/indra/newview/llpanelsnapshot.cpp b/indra/newview/llpanelsnapshot.cpp index 7c898b0678..095308fc50 100644 --- a/indra/newview/llpanelsnapshot.cpp +++ b/indra/newview/llpanelsnapshot.cpp @@ -37,6 +37,7 @@ // newview #include "llsidetraypanelcontainer.h" +#include "llsnapshotlivepreview.h" #include "llviewercontrol.h" // gSavedSettings #include "llagentbenefits.h" @@ -108,6 +109,17 @@ void LLPanelSnapshot::onOpen(const LLSD& key) { getParentByType()->notify(LLSD().with("image-format-change", true)); } + + // If resolution is set to "Current Window", force a snapshot update + // each time a snapshot panel is opened to determine the correct + // image size (and upload fee) depending on the snapshot type. + if (mSnapshotFloater && getChild(getImageSizeComboName())->getValue().asString() == "[i0,i0]") + { + if (LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView()) + { + preview->mForceUpdateSnapshot = true; + } + } } LLSnapshotModel::ESnapshotFormat LLPanelSnapshot::getImageFormat() const diff --git a/indra/newview/llpanelsnapshotinventory.cpp b/indra/newview/llpanelsnapshotinventory.cpp index 1c05b59568..97ca2666e2 100644 --- a/indra/newview/llpanelsnapshotinventory.cpp +++ b/indra/newview/llpanelsnapshotinventory.cpp @@ -48,78 +48,36 @@ /** * 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*/ ~LLPanelSnapshotInventory(); // Store settings at logout - /*virtual*/ bool postBuild(); - /*virtual*/ void onOpen(const LLSD& key); + ~LLPanelSnapshotInventory() override; // Store settings at logout + 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); + 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; -}; - -class LLPanelOutfitSnapshotInventory - : public LLPanelSnapshotInventoryBase -{ - LOG_CLASS(LLPanelOutfitSnapshotInventory); - -public: - LLPanelOutfitSnapshotInventory(); - /*virtual*/ bool postBuild(); - /*virtual*/ void onOpen(const LLSD& key); - -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 panel_class1("llpanelsnapshotinventory"); -static LLPanelInjector panel_class2("llpaneloutfitsnapshotinventory"); - -LLPanelSnapshotInventoryBase::LLPanelSnapshotInventoryBase() -{ -} - -bool LLPanelSnapshotInventoryBase::postBuild() -{ - return LLPanelSnapshot::postBuild(); -} - -LLSnapshotModel::ESnapshotType LLPanelSnapshotInventoryBase::getSnapshotType() +LLSnapshotModel::ESnapshotType LLPanelSnapshotInventory::getSnapshotType() { return LLSnapshotModel::SNAPSHOT_TEXTURE; } @@ -130,6 +88,15 @@ LLPanelSnapshotInventory::LLPanelSnapshotInventory() mCommitCallbackRegistrar.add("Inventory.Cancel", boost::bind(&LLPanelSnapshotInventory::cancel, this)); } +// Store settings at logout +LLPanelSnapshotInventory::~LLPanelSnapshotInventory() +{ + gSavedSettings.setS32("LastSnapshotToInventoryResolution", getImageSizeComboBox()->getCurrentIndex()); + gSavedSettings.setS32("LastSnapshotToInventoryWidth", getTypedPreviewWidth()); + gSavedSettings.setS32("LastSnapshotToInventoryHeight", getTypedPreviewHeight()); +} +// + // virtual bool LLPanelSnapshotInventory::postBuild() { @@ -145,15 +112,16 @@ bool LLPanelSnapshotInventory::postBuild() getHeightSpinner()->setValue(gSavedSettings.getS32("LastSnapshotToInventoryHeight")); // - return LLPanelSnapshotInventoryBase::postBuild(); + return LLPanelSnapshot::postBuild(); } // virtual void LLPanelSnapshotInventory::onOpen(const LLSD& key) { + updateUploadCost(); + // FIRE-10537 - Temp texture uploads aren't functional on SSB regions - if (LLAgentBenefitsMgr::current().getTextureUploadCost() == 0 - || gAgent.getRegion()->getCentralBakeVersion() > 0) + if (LLAgentBenefitsMgr::current().getTextureUploadCost() == 0 || gAgent.getRegion()->getCentralBakeVersion() > 0) { gSavedSettings.setBOOL("TemporaryUpload", false); } @@ -167,6 +135,8 @@ void LLPanelSnapshotInventory::updateControls(const LLSD& info) { const bool have_snapshot = info.has("have-snapshot") ? info["have-snapshot"].asBoolean() : true; getChild("save_btn")->setEnabled(have_snapshot); + + updateUploadCost(); } void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl) @@ -176,30 +146,9 @@ void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl) getChild(getHeightSpinnerName())->setVisible(!current_window_selected); } -// Store settings at logout -LLPanelSnapshotInventory::~LLPanelSnapshotInventory() +void LLPanelSnapshotInventory::onSend() { - gSavedSettings.setS32("LastSnapshotToInventoryResolution", getImageSizeComboBox()->getCurrentIndex()); - gSavedSettings.setS32("LastSnapshotToInventoryWidth", getTypedPreviewWidth()); - gSavedSettings.setS32("LastSnapshotToInventoryHeight", getTypedPreviewHeight()); -} -// - -void LLPanelSnapshotInventoryBase::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) @@ -220,36 +169,24 @@ void LLPanelSnapshotInventoryBase::onSend() } } -LLPanelOutfitSnapshotInventory::LLPanelOutfitSnapshotInventory() +void LLPanelSnapshotInventory::updateUploadCost() { - mCommitCallbackRegistrar.add("Inventory.SaveOutfitPhoto", boost::bind(&LLPanelOutfitSnapshotInventory::onSend, this)); - mCommitCallbackRegistrar.add("Inventory.SaveOutfitCancel", boost::bind(&LLPanelOutfitSnapshotInventory::cancel, this)); + getChild("hint_lbl")->setTextArg("[UPLOAD_COST]", llformat("%d", calculateUploadCost())); } -// virtual -bool LLPanelOutfitSnapshotInventory::postBuild() +S32 LLPanelSnapshotInventory::calculateUploadCost() { - return LLPanelSnapshotInventoryBase::postBuild(); -} + S32 w = 0; + S32 h = 0; -// virtual -void LLPanelOutfitSnapshotInventory::onOpen(const LLSD& key) -{ - getChild("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("save_btn")->setEnabled(have_snapshot); -} - -void LLPanelOutfitSnapshotInventory::cancel() -{ if (mSnapshotFloater) { - mSnapshotFloater->closeFloater(); + if (LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView()) + { + w = preview->getEncodedImageWidth(); + h = preview->getEncodedImageHeight(); + } } + + return LLAgentBenefitsMgr::current().getTextureUploadCost(w, h); } diff --git a/indra/newview/llpanelsnapshotoptions.cpp b/indra/newview/llpanelsnapshotoptions.cpp index a9f1d0b8ba..bcc0460ceb 100644 --- a/indra/newview/llpanelsnapshotoptions.cpp +++ b/indra/newview/llpanelsnapshotoptions.cpp @@ -30,13 +30,9 @@ #include "llsidetraypanelcontainer.h" #include "llfloatersnapshot.h" // FIXME: create a snapshot model -#include "llsnapshotlivepreview.h" #include "llfloaterreg.h" #include "llfloaterflickr.h" // Share to Flickr -#include "llagentbenefits.h" - - /** * Provides several ways to save a snapshot. */ @@ -47,9 +43,7 @@ class LLPanelSnapshotOptions public: LLPanelSnapshotOptions(); - ~LLPanelSnapshotOptions(); - /*virtual*/ bool postBuild(); - /*virtual*/ void onOpen(const LLSD& key); + bool postBuild() override; private: void updateUploadCost(); @@ -74,10 +68,6 @@ LLPanelSnapshotOptions::LLPanelSnapshotOptions() mCommitCallbackRegistrar.add("Snapshot.SendToFlickr", boost::bind(&LLPanelSnapshotOptions::onSendToFlickr, this)); // Share to Flickr } -LLPanelSnapshotOptions::~LLPanelSnapshotOptions() -{ -} - // virtual bool LLPanelSnapshotOptions::postBuild() { @@ -85,30 +75,6 @@ bool LLPanelSnapshotOptions::postBuild() return LLPanel::postBuild(); } -// virtual -void LLPanelSnapshotOptions::onOpen(const LLSD& key) -{ - updateUploadCost(); -} - -void LLPanelSnapshotOptions::updateUploadCost() -{ - S32 w = 0; - S32 h = 0; - - if( mSnapshotFloater ) - { - LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView(); - if( preview ) - { - preview->getSize(w, h); - } - } - - S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(w, h); - getChild("save_to_inventory_btn")->setLabelArg("[AMOUNT]", llformat("%d", upload_cost)); -} - void LLPanelSnapshotOptions::openPanel(const std::string& panel_name) { LLSideTrayPanelContainer* parent = dynamic_cast(getParent()); diff --git a/indra/newview/skins/default/xui/az/panel_snapshot_options.xml b/indra/newview/skins/default/xui/az/panel_snapshot_options.xml index cd850967db..a53d5f7c10 100644 --- a/indra/newview/skins/default/xui/az/panel_snapshot_options.xml +++ b/indra/newview/skins/default/xui/az/panel_snapshot_options.xml @@ -5,7 +5,7 @@