Skip to content

Commit 37bbc6f

Browse files
authored
Merge pull request #3932 from Ansariel/develop-snapshot-fixes
Snapshot fixes from archived develop branch
2 parents 2fb0abb + 67d1838 commit 37bbc6f

27 files changed

+99
-182
lines changed

indra/newview/llpanelsnapshot.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
// newview
3939
#include "llsidetraypanelcontainer.h"
40+
#include "llsnapshotlivepreview.h"
4041
#include "llviewercontrol.h" // gSavedSettings
4142

4243
#include "llagentbenefits.h"
@@ -99,6 +100,17 @@ void LLPanelSnapshot::onOpen(const LLSD& key)
99100
{
100101
getParentByType<LLFloater>()->notify(LLSD().with("image-format-change", true));
101102
}
103+
104+
// If resolution is set to "Current Window", force a snapshot update
105+
// each time a snapshot panel is opened to determine the correct
106+
// image size (and upload fee) depending on the snapshot type.
107+
if (mSnapshotFloater && getChild<LLUICtrl>(getImageSizeComboName())->getValue().asString() == "[i0,i0]")
108+
{
109+
if (LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView())
110+
{
111+
preview->mForceUpdateSnapshot = true;
112+
}
113+
}
102114
}
103115

104116
LLSnapshotModel::ESnapshotFormat LLPanelSnapshot::getImageFormat() const

indra/newview/llpanelsnapshotinventory.cpp

Lines changed: 33 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -42,77 +42,35 @@
4242
/**
4343
* The panel provides UI for saving snapshot as an inventory texture.
4444
*/
45-
class LLPanelSnapshotInventoryBase
46-
: public LLPanelSnapshot
47-
{
48-
LOG_CLASS(LLPanelSnapshotInventoryBase);
49-
50-
public:
51-
LLPanelSnapshotInventoryBase();
52-
53-
/*virtual*/ bool postBuild();
54-
protected:
55-
void onSend();
56-
/*virtual*/ LLSnapshotModel::ESnapshotType getSnapshotType();
57-
};
58-
5945
class LLPanelSnapshotInventory
60-
: public LLPanelSnapshotInventoryBase
46+
: public LLPanelSnapshot
6147
{
6248
LOG_CLASS(LLPanelSnapshotInventory);
6349

6450
public:
6551
LLPanelSnapshotInventory();
66-
/*virtual*/ bool postBuild();
67-
/*virtual*/ void onOpen(const LLSD& key);
52+
bool postBuild() override;
53+
void onOpen(const LLSD& key) override;
6854

6955
void onResolutionCommit(LLUICtrl* ctrl);
7056

7157
private:
72-
/*virtual*/ std::string getWidthSpinnerName() const { return "inventory_snapshot_width"; }
73-
/*virtual*/ std::string getHeightSpinnerName() const { return "inventory_snapshot_height"; }
74-
/*virtual*/ std::string getAspectRatioCBName() const { return "inventory_keep_aspect_check"; }
75-
/*virtual*/ std::string getImageSizeComboName() const { return "texture_size_combo"; }
76-
/*virtual*/ std::string getImageSizePanelName() const { return LLStringUtil::null; }
77-
/*virtual*/ void updateControls(const LLSD& info);
78-
79-
};
80-
81-
class LLPanelOutfitSnapshotInventory
82-
: public LLPanelSnapshotInventoryBase
83-
{
84-
LOG_CLASS(LLPanelOutfitSnapshotInventory);
85-
86-
public:
87-
LLPanelOutfitSnapshotInventory();
88-
/*virtual*/ bool postBuild();
89-
/*virtual*/ void onOpen(const LLSD& key);
58+
std::string getWidthSpinnerName() const override { return "inventory_snapshot_width"; }
59+
std::string getHeightSpinnerName() const override { return "inventory_snapshot_height"; }
60+
std::string getAspectRatioCBName() const override { return "inventory_keep_aspect_check"; }
61+
std::string getImageSizeComboName() const override { return "texture_size_combo"; }
62+
std::string getImageSizePanelName() const override { return LLStringUtil::null; }
63+
LLSnapshotModel::ESnapshotType getSnapshotType() override;
64+
void updateControls(const LLSD& info) override;
9065

91-
private:
92-
/*virtual*/ std::string getWidthSpinnerName() const { return ""; }
93-
/*virtual*/ std::string getHeightSpinnerName() const { return ""; }
94-
/*virtual*/ std::string getAspectRatioCBName() const { return ""; }
95-
/*virtual*/ std::string getImageSizeComboName() const { return "texture_size_combo"; }
96-
/*virtual*/ std::string getImageSizePanelName() const { return LLStringUtil::null; }
97-
/*virtual*/ void updateControls(const LLSD& info);
98-
99-
/*virtual*/ void cancel();
66+
void onSend();
67+
void updateUploadCost();
68+
S32 calculateUploadCost();
10069
};
10170

10271
static LLPanelInjector<LLPanelSnapshotInventory> panel_class1("llpanelsnapshotinventory");
10372

104-
static LLPanelInjector<LLPanelOutfitSnapshotInventory> panel_class2("llpaneloutfitsnapshotinventory");
105-
106-
LLPanelSnapshotInventoryBase::LLPanelSnapshotInventoryBase()
107-
{
108-
}
109-
110-
bool LLPanelSnapshotInventoryBase::postBuild()
111-
{
112-
return LLPanelSnapshot::postBuild();
113-
}
114-
115-
LLSnapshotModel::ESnapshotType LLPanelSnapshotInventoryBase::getSnapshotType()
73+
LLSnapshotModel::ESnapshotType LLPanelSnapshotInventory::getSnapshotType()
11674
{
11775
return LLSnapshotModel::SNAPSHOT_TEXTURE;
11876
}
@@ -130,12 +88,14 @@ bool LLPanelSnapshotInventory::postBuild()
13088
getChild<LLSpinCtrl>(getHeightSpinnerName())->setAllowEdit(false);
13189

13290
getChild<LLUICtrl>(getImageSizeComboName())->setCommitCallback(boost::bind(&LLPanelSnapshotInventory::onResolutionCommit, this, _1));
133-
return LLPanelSnapshotInventoryBase::postBuild();
91+
return LLPanelSnapshot::postBuild();
13492
}
13593

13694
// virtual
13795
void LLPanelSnapshotInventory::onOpen(const LLSD& key)
13896
{
97+
updateUploadCost();
98+
13999
LLPanelSnapshot::onOpen(key);
140100
}
141101

@@ -144,6 +104,8 @@ void LLPanelSnapshotInventory::updateControls(const LLSD& info)
144104
{
145105
const bool have_snapshot = info.has("have-snapshot") ? info["have-snapshot"].asBoolean() : true;
146106
getChild<LLUICtrl>("save_btn")->setEnabled(have_snapshot);
107+
108+
updateUploadCost();
147109
}
148110

149111
void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl)
@@ -153,21 +115,9 @@ void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl)
153115
getChild<LLSpinCtrl>(getHeightSpinnerName())->setVisible(!current_window_selected);
154116
}
155117

156-
void LLPanelSnapshotInventoryBase::onSend()
118+
void LLPanelSnapshotInventory::onSend()
157119
{
158-
S32 w = 0;
159-
S32 h = 0;
160-
161-
if( mSnapshotFloater )
162-
{
163-
LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView();
164-
if( preview )
165-
{
166-
preview->getSize(w, h);
167-
}
168-
}
169-
170-
S32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(w, h);
120+
S32 expected_upload_cost = calculateUploadCost();
171121
if (can_afford_transaction(expected_upload_cost))
172122
{
173123
if (mSnapshotFloater)
@@ -188,36 +138,24 @@ void LLPanelSnapshotInventoryBase::onSend()
188138
}
189139
}
190140

191-
LLPanelOutfitSnapshotInventory::LLPanelOutfitSnapshotInventory()
141+
void LLPanelSnapshotInventory::updateUploadCost()
192142
{
193-
mCommitCallbackRegistrar.add("Inventory.SaveOutfitPhoto", boost::bind(&LLPanelOutfitSnapshotInventory::onSend, this));
194-
mCommitCallbackRegistrar.add("Inventory.SaveOutfitCancel", boost::bind(&LLPanelOutfitSnapshotInventory::cancel, this));
143+
getChild<LLUICtrl>("hint_lbl")->setTextArg("[UPLOAD_COST]", llformat("%d", calculateUploadCost()));
195144
}
196145

197-
// virtual
198-
bool LLPanelOutfitSnapshotInventory::postBuild()
146+
S32 LLPanelSnapshotInventory::calculateUploadCost()
199147
{
200-
return LLPanelSnapshotInventoryBase::postBuild();
201-
}
202-
203-
// virtual
204-
void LLPanelOutfitSnapshotInventory::onOpen(const LLSD& key)
205-
{
206-
getChild<LLUICtrl>("hint_lbl")->setTextArg("[UPLOAD_COST]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost()));
207-
LLPanelSnapshot::onOpen(key);
208-
}
209-
210-
// virtual
211-
void LLPanelOutfitSnapshotInventory::updateControls(const LLSD& info)
212-
{
213-
const bool have_snapshot = info.has("have-snapshot") ? info["have-snapshot"].asBoolean() : true;
214-
getChild<LLUICtrl>("save_btn")->setEnabled(have_snapshot);
215-
}
148+
S32 w = 0;
149+
S32 h = 0;
216150

217-
void LLPanelOutfitSnapshotInventory::cancel()
218-
{
219151
if (mSnapshotFloater)
220152
{
221-
mSnapshotFloater->closeFloater();
153+
if (LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView())
154+
{
155+
w = preview->getEncodedImageWidth();
156+
h = preview->getEncodedImageHeight();
157+
}
222158
}
159+
160+
return LLAgentBenefitsMgr::current().getTextureUploadCost(w, h);
223161
}

indra/newview/llpanelsnapshotlocal.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ class LLPanelSnapshotLocal
4747

4848
public:
4949
LLPanelSnapshotLocal();
50-
/*virtual*/ bool postBuild();
51-
/*virtual*/ void onOpen(const LLSD& key);
50+
bool postBuild() override;
51+
void onOpen(const LLSD& key) override;
5252

5353
private:
54-
/*virtual*/ std::string getWidthSpinnerName() const { return "local_snapshot_width"; }
55-
/*virtual*/ std::string getHeightSpinnerName() const { return "local_snapshot_height"; }
56-
/*virtual*/ std::string getAspectRatioCBName() const { return "local_keep_aspect_check"; }
57-
/*virtual*/ std::string getImageSizeComboName() const { return "local_size_combo"; }
58-
/*virtual*/ std::string getImageSizePanelName() const { return "local_image_size_lp"; }
59-
/*virtual*/ LLSnapshotModel::ESnapshotFormat getImageFormat() const;
60-
/*virtual*/ LLSnapshotModel::ESnapshotType getSnapshotType();
61-
/*virtual*/ void updateControls(const LLSD& info);
54+
std::string getWidthSpinnerName() const override { return "local_snapshot_width"; }
55+
std::string getHeightSpinnerName() const override { return "local_snapshot_height"; }
56+
std::string getAspectRatioCBName() const override { return "local_keep_aspect_check"; }
57+
std::string getImageSizeComboName() const override { return "local_size_combo"; }
58+
std::string getImageSizePanelName() const override { return "local_image_size_lp"; }
59+
LLSnapshotModel::ESnapshotFormat getImageFormat() const override;
60+
LLSnapshotModel::ESnapshotType getSnapshotType() override;
61+
void updateControls(const LLSD& info) override;
6262

6363
S32 mLocalFormat;
6464

indra/newview/llpanelsnapshotoptions.cpp

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@
3030
#include "llsidetraypanelcontainer.h"
3131

3232
#include "llfloatersnapshot.h" // FIXME: create a snapshot model
33-
#include "llsnapshotlivepreview.h"
3433
#include "llfloaterreg.h"
3534

36-
#include "llagentbenefits.h"
37-
38-
3935
/**
4036
* Provides several ways to save a snapshot.
4137
*/
@@ -46,12 +42,9 @@ class LLPanelSnapshotOptions
4642

4743
public:
4844
LLPanelSnapshotOptions();
49-
~LLPanelSnapshotOptions();
50-
/*virtual*/ bool postBuild();
51-
/*virtual*/ void onOpen(const LLSD& key);
45+
bool postBuild() override;
5246

5347
private:
54-
void updateUploadCost();
5548
void openPanel(const std::string& panel_name);
5649
void onSaveToProfile();
5750
void onSaveToEmail();
@@ -71,41 +64,13 @@ LLPanelSnapshotOptions::LLPanelSnapshotOptions()
7164
mCommitCallbackRegistrar.add("Snapshot.SaveToComputer", boost::bind(&LLPanelSnapshotOptions::onSaveToComputer, this));
7265
}
7366

74-
LLPanelSnapshotOptions::~LLPanelSnapshotOptions()
75-
{
76-
}
77-
7867
// virtual
7968
bool LLPanelSnapshotOptions::postBuild()
8069
{
8170
mSnapshotFloater = getParentByType<LLFloaterSnapshotBase>();
8271
return LLPanel::postBuild();
8372
}
8473

85-
// virtual
86-
void LLPanelSnapshotOptions::onOpen(const LLSD& key)
87-
{
88-
updateUploadCost();
89-
}
90-
91-
void LLPanelSnapshotOptions::updateUploadCost()
92-
{
93-
S32 w = 0;
94-
S32 h = 0;
95-
96-
if( mSnapshotFloater )
97-
{
98-
LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView();
99-
if( preview )
100-
{
101-
preview->getSize(w, h);
102-
}
103-
}
104-
105-
S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(w, h);
106-
getChild<LLUICtrl>("save_to_inventory_btn")->setLabelArg("[AMOUNT]", llformat("%d", upload_cost));
107-
}
108-
10974
void LLPanelSnapshotOptions::openPanel(const std::string& panel_name)
11075
{
11176
LLSideTrayPanelContainer* parent = dynamic_cast<LLSideTrayPanelContainer*>(getParent());

indra/newview/llpanelsnapshotpostcard.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ class LLPanelSnapshotPostcard
5656

5757
public:
5858
LLPanelSnapshotPostcard();
59-
/*virtual*/ bool postBuild();
60-
/*virtual*/ void onOpen(const LLSD& key);
59+
bool postBuild() override;
60+
void onOpen(const LLSD& key) override;
6161

6262
private:
63-
/*virtual*/ std::string getWidthSpinnerName() const { return "postcard_snapshot_width"; }
64-
/*virtual*/ std::string getHeightSpinnerName() const { return "postcard_snapshot_height"; }
65-
/*virtual*/ std::string getAspectRatioCBName() const { return "postcard_keep_aspect_check"; }
66-
/*virtual*/ std::string getImageSizeComboName() const { return "postcard_size_combo"; }
67-
/*virtual*/ std::string getImageSizePanelName() const { return "postcard_image_size_lp"; }
68-
/*virtual*/ LLSnapshotModel::ESnapshotFormat getImageFormat() const { return LLSnapshotModel::SNAPSHOT_FORMAT_JPEG; }
69-
/*virtual*/ LLSnapshotModel::ESnapshotType getSnapshotType();
70-
/*virtual*/ void updateControls(const LLSD& info);
63+
std::string getWidthSpinnerName() const override { return "postcard_snapshot_width"; }
64+
std::string getHeightSpinnerName() const override { return "postcard_snapshot_height"; }
65+
std::string getAspectRatioCBName() const override { return "postcard_keep_aspect_check"; }
66+
std::string getImageSizeComboName() const override { return "postcard_size_combo"; }
67+
std::string getImageSizePanelName() const override { return "postcard_image_size_lp"; }
68+
LLSnapshotModel::ESnapshotFormat getImageFormat() const override { return LLSnapshotModel::SNAPSHOT_FORMAT_JPEG; }
69+
LLSnapshotModel::ESnapshotType getSnapshotType() override;
70+
void updateControls(const LLSD& info) override;
7171

7272
bool missingSubjMsgAlertCallback(const LLSD& notification, const LLSD& response);
7373
static void sendPostcardFinished(LLSD result);

indra/newview/llpanelsnapshotprofile.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ class LLPanelSnapshotProfile
4949
public:
5050
LLPanelSnapshotProfile();
5151

52-
/*virtual*/ bool postBuild();
53-
/*virtual*/ void onOpen(const LLSD& key);
52+
bool postBuild() override;
53+
void onOpen(const LLSD& key) override;
5454

5555
private:
56-
/*virtual*/ std::string getWidthSpinnerName() const { return "profile_snapshot_width"; }
57-
/*virtual*/ std::string getHeightSpinnerName() const { return "profile_snapshot_height"; }
58-
/*virtual*/ std::string getAspectRatioCBName() const { return "profile_keep_aspect_check"; }
59-
/*virtual*/ std::string getImageSizeComboName() const { return "profile_size_combo"; }
60-
/*virtual*/ std::string getImageSizePanelName() const { return "profile_image_size_lp"; }
61-
/*virtual*/ LLSnapshotModel::ESnapshotFormat getImageFormat() const { return LLSnapshotModel::SNAPSHOT_FORMAT_PNG; }
62-
/*virtual*/ void updateControls(const LLSD& info);
56+
std::string getWidthSpinnerName() const override { return "profile_snapshot_width"; }
57+
std::string getHeightSpinnerName() const override { return "profile_snapshot_height"; }
58+
std::string getAspectRatioCBName() const override { return "profile_keep_aspect_check"; }
59+
std::string getImageSizeComboName() const override { return "profile_size_combo"; }
60+
std::string getImageSizePanelName() const override { return "profile_image_size_lp"; }
61+
LLSnapshotModel::ESnapshotFormat getImageFormat() const override { return LLSnapshotModel::SNAPSHOT_FORMAT_PNG; }
62+
void updateControls(const LLSD& info) override;
6363

6464
void onSend();
6565
};

indra/newview/skins/default/xui/de/panel_snapshot_inventory.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<combo_box.item label="Klein (128x128)" name="Small(128x128)"/>
88
<combo_box.item label="Mittel (256x256)" name="Medium(256x256)"/>
99
<combo_box.item label="Groß (512x512)" name="Large(512x512)"/>
10-
<combo_box.item label="Aktuelles Fenster (512x512)" name="CurrentWindow"/>
10+
<combo_box.item label="Aktuelles Fenster" name="CurrentWindow"/>
1111
<combo_box.item label="Benutzerdefiniert" name="Custom"/>
1212
</combo_box>
1313
<spinner label="Breite x Höhe" name="inventory_snapshot_width"/>

indra/newview/skins/default/xui/de/panel_snapshot_options.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
22
<panel name="panel_snapshot_options">
33
<button label="Auf Datenträger speichern" name="save_to_computer_btn"/>
4-
<button label="In Inventar speichern ([AMOUNT] L$)" name="save_to_inventory_btn"/>
4+
<button label="In Inventar speichern" name="save_to_inventory_btn"/>
55
<button label="Im Profil-Feed teilen" name="save_to_profile_btn"/>
66
<button label="Auf Facebook teilen" name="send_to_facebook_btn"/>
77
<button label="Auf Twitter teilen" name="send_to_twitter_btn"/>

0 commit comments

Comments
 (0)