From 0c380ebc085df0f7edce3bac51c57c150dd1e999 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 25 Sep 2024 23:05:44 +0200 Subject: Fix upload cost calculation for snapshots to inventory based on encoded image size and display upload cost to user --- indra/newview/llpanelsnapshotinventory.cpp | 42 +++++++++++++++------- .../default/xui/de/panel_snapshot_inventory.xml | 2 +- .../default/xui/en/panel_snapshot_inventory.xml | 4 ++- .../default/xui/es/panel_snapshot_inventory.xml | 2 +- .../default/xui/fr/panel_snapshot_inventory.xml | 2 +- .../default/xui/it/panel_snapshot_inventory.xml | 2 +- .../default/xui/ja/panel_snapshot_inventory.xml | 2 +- .../default/xui/pt/panel_snapshot_inventory.xml | 2 +- .../default/xui/ru/panel_snapshot_inventory.xml | 2 +- .../default/xui/tr/panel_snapshot_inventory.xml | 2 +- .../default/xui/zh/panel_snapshot_inventory.xml | 2 +- 11 files changed, 41 insertions(+), 23 deletions(-) (limited to 'indra') diff --git a/indra/newview/llpanelsnapshotinventory.cpp b/indra/newview/llpanelsnapshotinventory.cpp index 74dadce960..b81b891685 100644 --- a/indra/newview/llpanelsnapshotinventory.cpp +++ b/indra/newview/llpanelsnapshotinventory.cpp @@ -64,6 +64,8 @@ private: void updateControls(const LLSD& info) override; void onSend(); + void updateUploadCost(); + S32 calculateUploadCost(); }; static LLPanelInjector panel_class1("llpanelsnapshotinventory"); @@ -92,6 +94,8 @@ bool LLPanelSnapshotInventory::postBuild() // virtual void LLPanelSnapshotInventory::onOpen(const LLSD& key) { + updateUploadCost(); + LLPanelSnapshot::onOpen(key); } @@ -100,6 +104,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) @@ -111,19 +117,7 @@ void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl) 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) @@ -143,3 +137,25 @@ void LLPanelSnapshotInventory::onSend() } } } + +void LLPanelSnapshotInventory::updateUploadCost() +{ + getChild("hint_lbl")->setTextArg("[UPLOAD_COST]", llformat("%d", calculateUploadCost())); +} + +S32 LLPanelSnapshotInventory::calculateUploadCost() +{ + S32 w = 0; + S32 h = 0; + + if (mSnapshotFloater) + { + if (LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView()) + { + w = preview->getEncodedImageWidth(); + h = preview->getEncodedImageHeight(); + } + } + + return LLAgentBenefitsMgr::current().getTextureUploadCost(w, h); +} diff --git a/indra/newview/skins/default/xui/de/panel_snapshot_inventory.xml b/indra/newview/skins/default/xui/de/panel_snapshot_inventory.xml index 602424821f..09447cbbaf 100644 --- a/indra/newview/skins/default/xui/de/panel_snapshot_inventory.xml +++ b/indra/newview/skins/default/xui/de/panel_snapshot_inventory.xml @@ -7,7 +7,7 @@ - + diff --git a/indra/newview/skins/default/xui/en/panel_snapshot_inventory.xml b/indra/newview/skins/default/xui/en/panel_snapshot_inventory.xml index f8040b9a65..0cac1b410f 100644 --- a/indra/newview/skins/default/xui/en/panel_snapshot_inventory.xml +++ b/indra/newview/skins/default/xui/en/panel_snapshot_inventory.xml @@ -60,7 +60,7 @@ name="Large(512x512)" value="[i512,i512]" /> To save your image as a texture select one of the square formats. + +Upload cost: L$[UPLOAD_COST]