42
42
/* *
43
43
* The panel provides UI for saving snapshot as an inventory texture.
44
44
*/
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
-
59
45
class LLPanelSnapshotInventory
60
- : public LLPanelSnapshotInventoryBase
46
+ : public LLPanelSnapshot
61
47
{
62
48
LOG_CLASS (LLPanelSnapshotInventory);
63
49
64
50
public:
65
51
LLPanelSnapshotInventory ();
66
- /* virtual */ bool postBuild ();
67
- /* virtual */ void onOpen (const LLSD& key);
52
+ bool postBuild () override ;
53
+ void onOpen (const LLSD& key) override ;
68
54
69
55
void onResolutionCommit (LLUICtrl* ctrl);
70
56
71
57
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 ;
90
65
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 ();
100
69
};
101
70
102
71
static LLPanelInjector<LLPanelSnapshotInventory> panel_class1 (" llpanelsnapshotinventory" );
103
72
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 ()
116
74
{
117
75
return LLSnapshotModel::SNAPSHOT_TEXTURE;
118
76
}
@@ -130,12 +88,14 @@ bool LLPanelSnapshotInventory::postBuild()
130
88
getChild<LLSpinCtrl>(getHeightSpinnerName ())->setAllowEdit (false );
131
89
132
90
getChild<LLUICtrl>(getImageSizeComboName ())->setCommitCallback (boost::bind (&LLPanelSnapshotInventory::onResolutionCommit, this , _1));
133
- return LLPanelSnapshotInventoryBase ::postBuild ();
91
+ return LLPanelSnapshot ::postBuild ();
134
92
}
135
93
136
94
// virtual
137
95
void LLPanelSnapshotInventory::onOpen (const LLSD& key)
138
96
{
97
+ updateUploadCost ();
98
+
139
99
LLPanelSnapshot::onOpen (key);
140
100
}
141
101
@@ -144,6 +104,8 @@ void LLPanelSnapshotInventory::updateControls(const LLSD& info)
144
104
{
145
105
const bool have_snapshot = info.has (" have-snapshot" ) ? info[" have-snapshot" ].asBoolean () : true ;
146
106
getChild<LLUICtrl>(" save_btn" )->setEnabled (have_snapshot);
107
+
108
+ updateUploadCost ();
147
109
}
148
110
149
111
void LLPanelSnapshotInventory::onResolutionCommit (LLUICtrl* ctrl)
@@ -153,21 +115,9 @@ void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl)
153
115
getChild<LLSpinCtrl>(getHeightSpinnerName ())->setVisible (!current_window_selected);
154
116
}
155
117
156
- void LLPanelSnapshotInventoryBase ::onSend ()
118
+ void LLPanelSnapshotInventory ::onSend ()
157
119
{
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 ();
171
121
if (can_afford_transaction (expected_upload_cost))
172
122
{
173
123
if (mSnapshotFloater )
@@ -188,36 +138,24 @@ void LLPanelSnapshotInventoryBase::onSend()
188
138
}
189
139
}
190
140
191
- LLPanelOutfitSnapshotInventory::LLPanelOutfitSnapshotInventory ()
141
+ void LLPanelSnapshotInventory::updateUploadCost ()
192
142
{
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 ()));
195
144
}
196
145
197
- // virtual
198
- bool LLPanelOutfitSnapshotInventory::postBuild ()
146
+ S32 LLPanelSnapshotInventory::calculateUploadCost ()
199
147
{
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 ;
216
150
217
- void LLPanelOutfitSnapshotInventory::cancel ()
218
- {
219
151
if (mSnapshotFloater )
220
152
{
221
- mSnapshotFloater ->closeFloater ();
153
+ if (LLSnapshotLivePreview* preview = mSnapshotFloater ->getPreviewView ())
154
+ {
155
+ w = preview->getEncodedImageWidth ();
156
+ h = preview->getEncodedImageHeight ();
157
+ }
222
158
}
159
+
160
+ return LLAgentBenefitsMgr::current ().getTextureUploadCost (w, h);
223
161
}
0 commit comments