diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llfloaterauction.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llfloaterauction.cpp | 326 |
1 files changed, 326 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloaterauction.cpp b/linden/indra/newview/llfloaterauction.cpp new file mode 100644 index 0000000..db169a8 --- /dev/null +++ b/linden/indra/newview/llfloaterauction.cpp | |||
@@ -0,0 +1,326 @@ | |||
1 | /** | ||
2 | * @file llfloaterauction.cpp | ||
3 | * @author James Cook, Ian Wilkes | ||
4 | * @brief Implementation of the auction floater. | ||
5 | * | ||
6 | * Copyright (c) 2004-2007, Linden Research, Inc. | ||
7 | * | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #include "llviewerprecompiledheaders.h" | ||
30 | #include "llfloaterauction.h" | ||
31 | |||
32 | #include "lldir.h" | ||
33 | #include "llgl.h" | ||
34 | #include "llimagej2c.h" | ||
35 | #include "llimagetga.h" | ||
36 | #include "llparcel.h" | ||
37 | #include "llvfile.h" | ||
38 | #include "llvfs.h" | ||
39 | |||
40 | #include "llagent.h" | ||
41 | #include "llcombobox.h" | ||
42 | #include "llnotify.h" | ||
43 | #include "llsavedsettingsglue.h" | ||
44 | #include "llviewerimagelist.h" | ||
45 | #include "llviewerparcelmgr.h" | ||
46 | #include "llviewerregion.h" | ||
47 | #include "llvieweruictrlfactory.h" | ||
48 | #include "llviewerwindow.h" | ||
49 | #include "viewer.h" | ||
50 | #include "llui.h" | ||
51 | |||
52 | ///---------------------------------------------------------------------------- | ||
53 | /// Local function declarations, constants, enums, and typedefs | ||
54 | ///---------------------------------------------------------------------------- | ||
55 | |||
56 | void auction_j2c_upload_done(const LLUUID& asset_id, | ||
57 | void* user_data, S32 status); | ||
58 | void auction_tga_upload_done(const LLUUID& asset_id, | ||
59 | void* user_data, S32 status); | ||
60 | |||
61 | ///---------------------------------------------------------------------------- | ||
62 | /// Class llfloaterauction | ||
63 | ///---------------------------------------------------------------------------- | ||
64 | |||
65 | LLFloaterAuction* LLFloaterAuction::sInstance = NULL; | ||
66 | |||
67 | // Default constructor | ||
68 | LLFloaterAuction::LLFloaterAuction() : | ||
69 | LLFloater("floater_auction"), | ||
70 | mParcelID(-1) | ||
71 | { | ||
72 | gUICtrlFactory->buildFloater(this, "floater_auction.xml"); | ||
73 | |||
74 | childSetValue("fence_check", | ||
75 | LLSD( gSavedSettings.getBOOL("AuctionShowFence") ) ); | ||
76 | childSetCommitCallback("fence_check", | ||
77 | LLSavedSettingsGlue::setBOOL, (void*)"AuctionShowFence"); | ||
78 | |||
79 | LLComboBox* combo = LLUICtrlFactory::getComboBoxByName(this, "saletype_combo"); | ||
80 | if (combo) | ||
81 | { | ||
82 | combo->selectFirstItem(); | ||
83 | } | ||
84 | |||
85 | childSetAction("snapshot_btn", onClickSnapshot, this); | ||
86 | childSetAction("ok_btn", onClickOK, this); | ||
87 | } | ||
88 | |||
89 | // Destroys the object | ||
90 | LLFloaterAuction::~LLFloaterAuction() | ||
91 | { | ||
92 | sInstance = NULL; | ||
93 | } | ||
94 | |||
95 | // static | ||
96 | void LLFloaterAuction::show() | ||
97 | { | ||
98 | if(!sInstance) | ||
99 | { | ||
100 | sInstance = new LLFloaterAuction(); | ||
101 | sInstance->center(); | ||
102 | sInstance->setFocus(TRUE); | ||
103 | } | ||
104 | sInstance->initialize(); | ||
105 | sInstance->open(); | ||
106 | } | ||
107 | |||
108 | void LLFloaterAuction::initialize() | ||
109 | { | ||
110 | LLParcel* parcel = gParcelMgr->getSelectedParcel(); | ||
111 | LLViewerRegion* region = gParcelMgr->getSelectionRegion(); | ||
112 | if(parcel && region && !parcel->getForSale()) | ||
113 | { | ||
114 | mParcelHost = region->getHost(); | ||
115 | mParcelID = parcel->getLocalID(); | ||
116 | |||
117 | childSetText("parcel_text", parcel->getName()); | ||
118 | childEnable("snapshot_btn"); | ||
119 | childEnable("ok_btn"); | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | mParcelHost.invalidate(); | ||
124 | if(parcel && parcel->getForSale()) | ||
125 | { | ||
126 | childSetText("parcel_text", childGetText("already for sale")); | ||
127 | } | ||
128 | else | ||
129 | { | ||
130 | childSetText("parcel_text", ""); | ||
131 | } | ||
132 | mParcelID = -1; | ||
133 | childSetEnabled("snapshot_btn", false); | ||
134 | childSetEnabled("ok_btn", false); | ||
135 | } | ||
136 | mImageID.setNull(); | ||
137 | mImage = NULL; | ||
138 | } | ||
139 | |||
140 | void LLFloaterAuction::draw() | ||
141 | { | ||
142 | LLFloater::draw(); | ||
143 | |||
144 | if(getVisible() && !isMinimized() && mImage.notNull()) | ||
145 | { | ||
146 | LLRect rect; | ||
147 | if (childGetRect("snapshot_icon", rect)) | ||
148 | { | ||
149 | { | ||
150 | LLGLSNoTexture gls_no_texture; | ||
151 | gl_rect_2d(rect, LLColor4(0.f, 0.f, 0.f, 1.f)); | ||
152 | rect.stretch(-1); | ||
153 | } | ||
154 | { | ||
155 | LLGLSUIDefault gls_ui; | ||
156 | glColor3f(1.f, 1.f, 1.f); | ||
157 | gl_draw_scaled_image(rect.mLeft, | ||
158 | rect.mBottom, | ||
159 | rect.getWidth(), | ||
160 | rect.getHeight(), | ||
161 | mImage); | ||
162 | } | ||
163 | } | ||
164 | } | ||
165 | } | ||
166 | |||
167 | |||
168 | // static | ||
169 | void LLFloaterAuction::onClickSnapshot(void* data) | ||
170 | { | ||
171 | LLFloaterAuction* self = (LLFloaterAuction*)(data); | ||
172 | |||
173 | LLPointer<LLImageRaw> raw = new LLImageRaw; | ||
174 | |||
175 | gForceRenderLandFence = self->childGetValue("fence_check").asBoolean(); | ||
176 | BOOL success = gViewerWindow->rawSnapshot(raw, | ||
177 | gViewerWindow->getWindowWidth(), | ||
178 | gViewerWindow->getWindowHeight(), | ||
179 | TRUE, | ||
180 | FALSE, FALSE); | ||
181 | gForceRenderLandFence = FALSE; | ||
182 | |||
183 | if (success) | ||
184 | { | ||
185 | self->mTransactionID.generate(); | ||
186 | self->mImageID = self->mTransactionID.makeAssetID(gAgent.getSecureSessionID()); | ||
187 | |||
188 | gViewerWindow->playSnapshotAnimAndSound(); | ||
189 | llinfos << "Writing TGA..." << llendl; | ||
190 | |||
191 | LLPointer<LLImageTGA> tga = new LLImageTGA; | ||
192 | tga->encode(raw); | ||
193 | LLVFile::writeFile(tga->getData(), tga->getDataSize(), gVFS, self->mImageID, LLAssetType::AT_IMAGE_TGA); | ||
194 | |||
195 | raw->biasedScaleToPowerOfTwo(LLViewerImage::MAX_IMAGE_SIZE_DEFAULT); | ||
196 | |||
197 | llinfos << "Writing J2C..." << llendl; | ||
198 | |||
199 | LLPointer<LLImageJ2C> j2c = new LLImageJ2C; | ||
200 | j2c->encode(raw); | ||
201 | LLVFile::writeFile(j2c->getData(), j2c->getDataSize(), gVFS, self->mImageID, LLAssetType::AT_TEXTURE); | ||
202 | |||
203 | self->mImage = new LLImageGL((LLImageRaw*)raw, FALSE); | ||
204 | self->mImage->bind(); | ||
205 | self->mImage->setClamp(TRUE, TRUE); | ||
206 | } | ||
207 | else | ||
208 | { | ||
209 | llwarns << "Unable to take snapshot" << llendl; | ||
210 | } | ||
211 | } | ||
212 | |||
213 | // static | ||
214 | void LLFloaterAuction::onClickOK(void* data) | ||
215 | { | ||
216 | LLFloaterAuction* self = (LLFloaterAuction*)(data); | ||
217 | bool is_auction = false; | ||
218 | LLComboBox* combo = LLUICtrlFactory::getComboBoxByName(self, "saletype_combo"); | ||
219 | if (combo | ||
220 | && combo->getCurrentIndex() == 0) | ||
221 | { | ||
222 | is_auction = true; | ||
223 | } | ||
224 | if(self->mImageID.notNull()) | ||
225 | { | ||
226 | LLSD parcel_name = self->childGetValue("parcel_text"); | ||
227 | |||
228 | // create the asset | ||
229 | if(is_auction) | ||
230 | { | ||
231 | // only need the tga if it is an auction. | ||
232 | LLString* name = new LLString(parcel_name.asString()); | ||
233 | gAssetStorage->storeAssetData(self->mTransactionID, LLAssetType::AT_IMAGE_TGA, | ||
234 | &auction_tga_upload_done, | ||
235 | (void*)name, | ||
236 | FALSE); | ||
237 | self->getWindow()->incBusyCount(); | ||
238 | } | ||
239 | |||
240 | LLString* j2c_name = new LLString(parcel_name.asString()); | ||
241 | gAssetStorage->storeAssetData(self->mTransactionID, LLAssetType::AT_TEXTURE, | ||
242 | &auction_j2c_upload_done, | ||
243 | (void*)j2c_name, | ||
244 | FALSE); | ||
245 | self->getWindow()->incBusyCount(); | ||
246 | |||
247 | if(is_auction) | ||
248 | { | ||
249 | LLNotifyBox::showXml("UploadingAuctionSnapshot"); | ||
250 | } | ||
251 | else | ||
252 | { | ||
253 | LLNotifyBox::showXml("UploadingSnapshot"); | ||
254 | } | ||
255 | } | ||
256 | LLMessageSystem* msg = gMessageSystem; | ||
257 | if(is_auction) | ||
258 | { | ||
259 | msg->newMessage("ViewerStartAuction"); | ||
260 | } | ||
261 | else | ||
262 | { | ||
263 | msg->newMessage("ParcelGodReserveForNewbie"); | ||
264 | } | ||
265 | msg->nextBlock("AgentData"); | ||
266 | msg->addUUID("AgentID", gAgent.getID()); | ||
267 | msg->addUUID("SessionID", gAgent.getSessionID()); | ||
268 | msg->nextBlock("ParcelData"); | ||
269 | msg->addS32("LocalID", self->mParcelID); | ||
270 | msg->addUUID("SnapshotID", self->mImageID); | ||
271 | msg->sendReliable(self->mParcelHost); | ||
272 | |||
273 | // clean up floater, and get out | ||
274 | self->mImageID.setNull(); | ||
275 | self->mImage = NULL; | ||
276 | self->mParcelID = -1; | ||
277 | self->mParcelHost.invalidate(); | ||
278 | self->close(); | ||
279 | } | ||
280 | |||
281 | |||
282 | ///---------------------------------------------------------------------------- | ||
283 | /// Local function definitions | ||
284 | ///---------------------------------------------------------------------------- | ||
285 | |||
286 | void auction_tga_upload_done(const LLUUID& asset_id, void* user_data, S32 status) // StoreAssetData callback (fixed) | ||
287 | { | ||
288 | LLString* name = (LLString*)(user_data); | ||
289 | llinfos << "Upload of asset '" << *name << "' " << asset_id | ||
290 | << " returned " << status << llendl; | ||
291 | delete name; | ||
292 | |||
293 | gViewerWindow->getWindow()->decBusyCount(); | ||
294 | |||
295 | if (0 == status) | ||
296 | { | ||
297 | LLNotifyBox::showXml("UploadWebSnapshotDone"); | ||
298 | } | ||
299 | else | ||
300 | { | ||
301 | LLStringBase<char>::format_map_t args; | ||
302 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); | ||
303 | gViewerWindow->alertXml("UploadAuctionSnapshotFail", args); | ||
304 | } | ||
305 | } | ||
306 | |||
307 | void auction_j2c_upload_done(const LLUUID& asset_id, void* user_data, S32 status) // StoreAssetData callback (fixed) | ||
308 | { | ||
309 | LLString* name = (LLString*)(user_data); | ||
310 | llinfos << "Upload of asset '" << *name << "' " << asset_id | ||
311 | << " returned " << status << llendl; | ||
312 | delete name; | ||
313 | |||
314 | gViewerWindow->getWindow()->decBusyCount(); | ||
315 | |||
316 | if (0 == status) | ||
317 | { | ||
318 | LLNotifyBox::showXml("UploadSnapshotDone"); | ||
319 | } | ||
320 | else | ||
321 | { | ||
322 | LLStringBase<char>::format_map_t args; | ||
323 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); | ||
324 | gViewerWindow->alertXml("UploadAuctionSnapshotFail", args); | ||
325 | } | ||
326 | } | ||