FIRE-34562: Make the snapshot fee calculation actually work (partial version of my fix contribution to LL)

master
Ansariel 2024-09-26 19:04:47 +02:00
parent 4a9bbc14bc
commit 63098acbdd
25 changed files with 81 additions and 162 deletions

View File

@ -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<LLFloater>()->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<LLUICtrl>(getImageSizeComboName())->getValue().asString() == "[i0,i0]")
{
if (LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView())
{
preview->mForceUpdateSnapshot = true;
}
}
}
LLSnapshotModel::ESnapshotFormat LLPanelSnapshot::getImageFormat() const

View File

@ -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(); // <FS:Ansariel> Store settings at logout
/*virtual*/ bool postBuild();
/*virtual*/ void onOpen(const LLSD& key);
~LLPanelSnapshotInventory() override; // <FS:Ansariel> 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<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,6 +88,15 @@ LLPanelSnapshotInventory::LLPanelSnapshotInventory()
mCommitCallbackRegistrar.add("Inventory.Cancel", boost::bind(&LLPanelSnapshotInventory::cancel, this));
}
// <FS:Ansariel> Store settings at logout
LLPanelSnapshotInventory::~LLPanelSnapshotInventory()
{
gSavedSettings.setS32("LastSnapshotToInventoryResolution", getImageSizeComboBox()->getCurrentIndex());
gSavedSettings.setS32("LastSnapshotToInventoryWidth", getTypedPreviewWidth());
gSavedSettings.setS32("LastSnapshotToInventoryHeight", getTypedPreviewHeight());
}
// </FS:Ansariel>
// virtual
bool LLPanelSnapshotInventory::postBuild()
{
@ -145,15 +112,16 @@ bool LLPanelSnapshotInventory::postBuild()
getHeightSpinner()->setValue(gSavedSettings.getS32("LastSnapshotToInventoryHeight"));
// </FS:Ansariel>
return LLPanelSnapshotInventoryBase::postBuild();
return LLPanelSnapshot::postBuild();
}
// virtual
void LLPanelSnapshotInventory::onOpen(const LLSD& key)
{
updateUploadCost();
// <FS:CR> 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<LLUICtrl>("save_btn")->setEnabled(have_snapshot);
updateUploadCost();
}
void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl)
@ -176,30 +146,9 @@ void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl)
getChild<LLSpinCtrl>(getHeightSpinnerName())->setVisible(!current_window_selected);
}
// <FS:Ansariel> Store settings at logout
LLPanelSnapshotInventory::~LLPanelSnapshotInventory()
void LLPanelSnapshotInventory::onSend()
{
gSavedSettings.setS32("LastSnapshotToInventoryResolution", getImageSizeComboBox()->getCurrentIndex());
gSavedSettings.setS32("LastSnapshotToInventoryWidth", getTypedPreviewWidth());
gSavedSettings.setS32("LastSnapshotToInventoryHeight", getTypedPreviewHeight());
}
// </FS:Ansariel>
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<LLUICtrl>("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<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);
}
void LLPanelOutfitSnapshotInventory::cancel()
{
if (mSnapshotFloater)
{
mSnapshotFloater->closeFloater();
if (LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView())
{
w = preview->getEncodedImageWidth();
h = preview->getEncodedImageHeight();
}
}
return LLAgentBenefitsMgr::current().getTextureUploadCost(w, h);
}

View File

@ -30,13 +30,9 @@
#include "llsidetraypanelcontainer.h"
#include "llfloatersnapshot.h" // FIXME: create a snapshot model
#include "llsnapshotlivepreview.h"
#include "llfloaterreg.h"
#include "llfloaterflickr.h" // <FS:Ansariel> 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)); // <FS:Ansariel> 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<LLUICtrl>("save_to_inventory_btn")->setLabelArg("[AMOUNT]", llformat("%d", upload_cost));
}
void LLPanelSnapshotOptions::openPanel(const std::string& panel_name)
{
LLSideTrayPanelContainer* parent = dynamic_cast<LLSideTrayPanelContainer*>(getParent());

View File

@ -5,7 +5,7 @@
<button label="Diskə yadda saxla" name="save_to_computer_btn"/>
</layout_panel>
<layout_panel name="lp_inventory">
<button label="Avadanlıq siyahısı (L$[AMOUNT])" name="save_to_inventory_btn"/>
<button label="Avadanlıq siyahısı" name="save_to_inventory_btn"/>
</layout_panel>
<layout_panel name="lp_profile">
<button label="Profilə yüklə" name="save_to_profile_btn"/>

View File

@ -15,6 +15,8 @@
<check_box label="Seitenverhältnis beibehalten" name="inventory_keep_aspect_check"/>
<text name="hint_lbl">
Um das Bild als Textur zu speichern, wählen Sie eines der quadratischen Formate aus.
Upload-Kosten: [UPLOAD_COST] L$
</text>
<button label="&#x25B6; Auswahl" name="cancel_btn"/>
<button label="Speichern" name="save_btn"/>

View File

@ -5,7 +5,7 @@
<button label="Auf Festplatte speichern" name="save_to_computer_btn"/>
</layout_panel>
<layout_panel name="lp_inventory">
<button label="Im Inventar speich. ([AMOUNT] L$)" name="save_to_inventory_btn"/>
<button label="Im Inventar speichern" name="save_to_inventory_btn"/>
</layout_panel>
<layout_panel name="lp_profile">
<button label="Auf Profil teilen" name="save_to_profile_btn"/>

View File

@ -128,6 +128,8 @@
type="string"
word_wrap="true">
To save your image as a texture select one of the square formats.
Upload cost: L$ [UPLOAD_COST]
</text>
<button
follows="right|bottom"

View File

@ -54,7 +54,7 @@
image_overlay_alignment="left"
image_top_pad="-1"
imgoverlay_label_space="10"
label="Save to Inventory (L$[AMOUNT])"
label="Save to Inventory"
layout="topleft"
left="9"
name="save_to_inventory_btn"

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<panel name="panel_snapshot_inventory">
<text name="hint_lbl">
Para guardar una imagen como textura, selecciona uno de los formatos cuadrados.
Guardar una imagen en el inventario cuesta [UPLOAD_COST] L$. Para guardar una imagen como textura, selecciona uno de los formatos cuadrados.
</text>
<combo_box label="Resolución" name="texture_size_combo">
<combo_box.item label="Ventana actual" name="CurrentWindow"/>

View File

@ -2,7 +2,7 @@
<panel name="panel_snapshot_options">
<button label="Publicar en los comentarios de mi perfil" name="save_to_profile_btn"/>
<button label="Enviar por correo electrónico" name="save_to_email_btn"/>
<button label="Guardar en mi inventario ([AMOUNT] L$)" name="save_to_inventory_btn"/>
<button label="Guardar en mi inventario" name="save_to_inventory_btn"/>
<button label="Guardar en mi ordenador" name="save_to_computer_btn"/>
<button label="Subir a Flickr" name="save_to_flickr_btn"/>
</panel>

View File

@ -12,7 +12,7 @@
<spinner width="50" name="inventory_snapshot_height"/>
<check_box label="Conserver les proportions" name="inventory_keep_aspect_check"/>
<check_box label="Uploader temporairement" name="inventory_temp_upload"/>
<text name="hint_lbl">Pour enregistrer votre image en tant que texture, sélectionnez un des formats listés.</text>
<text name="hint_lbl">L&apos;enregistrement d&apos;une image dans l&apos;inventaire coûte [UPLOAD_COST] L$. Pour enregistrer votre image en tant que texture, sélectionnez un des formats listés.</text>
<button label="&#x25B6; Sélection" name="cancel_btn"/>
<button label="Enregistrer" name="save_btn"/>
</panel>

View File

@ -2,7 +2,7 @@
<panel name="panel_snapshot_options">
<layout_stack name="option_buttons">
<layout_panel name="lp_download"><button label="Sur le disque" name="save_to_computer_btn"/></layout_panel>
<layout_panel name="lp_inventory"><button label="Dans l'inventaire ([AMOUNT] L$)" name="save_to_inventory_btn"/></layout_panel>
<layout_panel name="lp_inventory"><button label="Dans l'inventaire" name="save_to_inventory_btn"/></layout_panel>
<layout_panel name="lp_profile"><button label="En ligne sur mon profil" name="save_to_profile_btn"/></layout_panel>
<layout_panel name="lp_facebook"><button label="En ligne sur Facebook" name="send_to_facebook_btn"/></layout_panel>
<layout_panel name="lp_twitter"><button label="En ligne sur Twitter" name="send_to_twitter_btn"/></layout_panel>

View File

@ -14,7 +14,7 @@
<check_box label="Mantieni proporzioni" name="inventory_keep_aspect_check"/>
<check_box label="Temporaneo" name="inventory_temp_upload" />
<text name="hint_lbl">
Per salvare come texture, seleziona un formato quadrato.
Salvare un&apos;immagine nell&apos;inventario costa L$[UPLOAD_COST]. Per salvare come texture, seleziona un formato quadrato.
</text>
<button label="&#x25B6; Seleziona" name="cancel_btn"/>
<button label="Salva" name="save_btn"/>

View File

@ -5,7 +5,7 @@
<button label="Salva sul disco fisso" name="save_to_computer_btn"/>
</layout_panel>
<layout_panel name="lp_inventory">
<button label="Salva in inventario ([AMOUNT]L$)" name="save_to_inventory_btn"/>
<button label="Salva in inventario" name="save_to_inventory_btn"/>
</layout_panel>
<layout_panel name="lp_profile">
<button label="Condividi sul feed" name="save_to_profile_btn"/>

View File

@ -5,7 +5,7 @@
<button label="ディスクに保存" name="save_to_computer_btn"/>
</layout_panel>
<layout_panel name="lp_inventory">
<button label="インベントリに保存 (L$[AMOUNT])" name="save_to_inventory_btn"/>
<button label="インベントリに保存" name="save_to_inventory_btn"/>
</layout_panel>
<layout_panel name="lp_profile">
<button label="プロフィールにアップロード" name="save_to_profile_btn"/>

View File

@ -14,7 +14,7 @@
<check_box label="Zachowaj proporcje" name="inventory_keep_aspect_check" />
<check_box label="Tymczasowe" name="inventory_temp_upload" />
<text name="hint_lbl">
Aby zapisać je jako teksturę wybierz jeden z kwadratowych formatów.
Zapisanie zdjęcia do Szafy kosztuje [UPLOAD_COST]L$. Aby zapisać je jako teksturę wybierz jeden z kwadratowych formatów.
</text>
<button label="&#x25B6; Wybór" name="cancel_btn" />
<button label="Zapisz" name="save_btn" />

View File

@ -5,7 +5,7 @@
<button label="Zapisz na dysku twardym" name="save_to_computer_btn" />
</layout_panel>
<layout_panel name="lp_inventory">
<button label="Zapisz do Szafy ([AMOUNT]L$)" name="save_to_inventory_btn" />
<button label="Zapisz do Szafy " name="save_to_inventory_btn" />
</layout_panel>
<layout_panel name="lp_profile">
<button label="Wrzuć na mój Kanał" name="save_to_profile_btn" />

View File

@ -4,7 +4,7 @@
Inventário
</text>
<text name="hint_lbl">
Para salvar sua imagem como uma textura, selecione um dos formatos quadrados.
Salvar uma imagem em seu inventário custa L$[UPLOAD_COST]. Para salvar sua imagem como uma textura, selecione um dos formatos quadrados.
</text>
<combo_box label="Resolução" name="texture_size_combo">
<combo_box.item label="Janela ativa" name="CurrentWindow"/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<panel name="panel_snapshot_options">
<button label="Salvar no disco" name="save_to_computer_btn"/>
<button label="Salvar em inventário (L$[AMOUNT])" name="save_to_inventory_btn"/>
<button label="Salvar em inventário" name="save_to_inventory_btn"/>
<button label="Compartilhar no feed do perfil" name="save_to_profile_btn"/>
<button label="Compartilhar no Facebook" name="send_to_facebook_btn"/>
<button label="Compartilhar no Twitter" name="send_to_twitter_btn"/>

View File

@ -4,7 +4,7 @@
Инвентарь
</text>
<text name="hint_lbl">
Чтобы сохранить его как текстуру, выберите один из квадратных форматов.
Сохранение изображения в инвентаре стоит L$[UPLOAD_COST]. Чтобы сохранить его как текстуру, выберите один из квадратных форматов.
</text>
<combo_box label="Размер" name="texture_size_combo">
<combo_box.item label="Текущее окно" name="CurrentWindow"/>

View File

@ -5,7 +5,7 @@
<button label="Сохранить на диск" name="save_to_computer_btn"/>
</layout_panel>
<layout_panel name="lp_inventory">
<button label="В инвентарь (L$[AMOUNT])" name="save_to_inventory_btn"/>
<button label="В инвентарь" name="save_to_inventory_btn"/>
</layout_panel>
<layout_panel name="lp_profile">
<button label="Загрузить в профиль" name="save_to_profile_btn"/>

View File

@ -4,7 +4,7 @@
Envanter
</text>
<text name="hint_lbl">
Görüntünüzü bir doku olarak kaydetmek için kare formatlardan birini seçin.
Bir görüntüyü envanterinize kaydetmenin maliyeti L$[UPLOAD_COST] olur. Görüntünüzü bir doku olarak kaydetmek için kare formatlardan birini seçin.
</text>
<combo_box label="Çözünürlük" name="texture_size_combo">
<combo_box.item label="Mevcut Pencere" name="CurrentWindow"/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<panel name="panel_snapshot_options">
<button label="Diske Kaydet" name="save_to_computer_btn"/>
<button label="Envantere Kaydet (L$[AMOUNT])" name="save_to_inventory_btn"/>
<button label="Envantere Kaydet" name="save_to_inventory_btn"/>
<button label="Profil Akışında Paylaş" name="save_to_profile_btn"/>
<button label="Facebook&apos;ta Paylaş" name="send_to_facebook_btn"/>
<button label="Twitter&apos;da Paylaş" name="send_to_twitter_btn"/>

View File

@ -4,7 +4,7 @@
收納區
</text>
<text name="hint_lbl">
若要將圖像存為材質,請選擇一個正方格式。
將圖像儲存到收納區的費用為 L$[UPLOAD_COST]。 若要將圖像存為材質,請選擇一個正方格式。
</text>
<combo_box label="解析度" name="texture_size_combo">
<combo_box.item label="目前視窗" name="CurrentWindow"/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<panel name="panel_snapshot_options">
<button label="儲存到硬碟" name="save_to_computer_btn"/>
<button label="儲存到收納區L$[AMOUNT]" name="save_to_inventory_btn"/>
<button label="儲存到收納區" name="save_to_inventory_btn"/>
<button label="分享至檔案訊息發佈" name="save_to_profile_btn"/>
<button label="分享到臉書" name="send_to_facebook_btn"/>
<button label="分享到推特" name="send_to_twitter_btn"/>