Annotation of /trunk/indra/newview/llfloatersellland.cpp
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llfloatersellland.cpp | ||
| 3 : | * | ||
| 4 : | * $LicenseInfo:firstyear=2006&license=viewergpl$ | ||
| 5 : | * | ||
| 6 : | mjm | 137 | * Copyright (c) 2006-2010, Linden Research, Inc. |
| 7 : | mjm | 135 | * |
| 8 : | * Second Life Viewer Source Code | ||
| 9 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 10 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 11 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 12 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 13 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 14 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 15 : | * | ||
| 16 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 17 : | * it is applied to this Source Code. View the full text of the exception | ||
| 18 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 19 : | * online at | ||
| 20 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 21 : | * | ||
| 22 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 23 : | * that you have read and understood your obligations described above, | ||
| 24 : | * and agree to abide by those obligations. | ||
| 25 : | * | ||
| 26 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 27 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 28 : | * COMPLETENESS OR PERFORMANCE. | ||
| 29 : | * $/LicenseInfo$ | ||
| 30 : | */ | ||
| 31 : | |||
| 32 : | #include "llviewerprecompiledheaders.h" | ||
| 33 : | |||
| 34 : | #include "llfloatersellland.h" | ||
| 35 : | |||
| 36 : | #include "llfloateravatarpicker.h" | ||
| 37 : | #include "llfloater.h" | ||
| 38 : | #include "llfloaterland.h" | ||
| 39 : | #include "lllineeditor.h" | ||
| 40 : | #include "llnotify.h" | ||
| 41 : | #include "llparcel.h" | ||
| 42 : | #include "llselectmgr.h" | ||
| 43 : | #include "lltexturectrl.h" | ||
| 44 : | #include "llviewercontrol.h" | ||
| 45 : | #include "llviewerparcelmgr.h" | ||
| 46 : | #include "lluictrlfactory.h" | ||
| 47 : | #include "llviewerwindow.h" | ||
| 48 : | |||
| 49 : | #include <hippoGridManager.h> | ||
| 50 : | |||
| 51 : | // defined in llfloaterland.cpp | ||
| 52 : | void send_parcel_select_objects(S32 parcel_local_id, U32 return_type, | ||
| 53 : | uuid_list_t* return_ids = NULL); | ||
| 54 : | |||
| 55 : | enum Badge { BADGE_OK, BADGE_NOTE, BADGE_WARN, BADGE_ERROR }; | ||
| 56 : | |||
| 57 : | class LLFloaterSellLandUI | ||
| 58 : | : public LLFloater | ||
| 59 : | { | ||
| 60 : | private: | ||
| 61 : | LLFloaterSellLandUI(); | ||
| 62 : | virtual ~LLFloaterSellLandUI(); | ||
| 63 : | |||
| 64 : | LLViewerRegion* mRegion; | ||
| 65 : | LLParcelSelectionHandle mParcelSelection; | ||
| 66 : | bool mParcelIsForSale; | ||
| 67 : | bool mSellToBuyer; | ||
| 68 : | bool mChoseSellTo; | ||
| 69 : | S32 mParcelPrice; | ||
| 70 : | S32 mParcelActualArea; | ||
| 71 : | LLUUID mParcelSnapshot; | ||
| 72 : | LLUUID mAuthorizedBuyer; | ||
| 73 : | bool mParcelSoldWithObjects; | ||
| 74 : | |||
| 75 : | void updateParcelInfo(); | ||
| 76 : | void refreshUI(); | ||
| 77 : | void setBadge(const char* id, Badge badge); | ||
| 78 : | |||
| 79 : | static LLFloaterSellLandUI* sInstance; | ||
| 80 : | |||
| 81 : | static void onChangeValue(LLUICtrl *ctrl, void *userdata); | ||
| 82 : | static void doSelectAgent(void *userdata); | ||
| 83 : | static void doCancel(void *userdata); | ||
| 84 : | static void doSellLand(void *userdata); | ||
| 85 : | bool onConfirmSale(const LLSD& notification, const LLSD& response); | ||
| 86 : | static void doShowObjects(void *userdata); | ||
| 87 : | static bool callbackHighlightTransferable(const LLSD& notification, const LLSD& response); | ||
| 88 : | |||
| 89 : | static void callbackAvatarPick(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data); | ||
| 90 : | |||
| 91 : | public: | ||
| 92 : | virtual BOOL postBuild(); | ||
| 93 : | virtual void onClose(bool app_quitting); | ||
| 94 : | |||
| 95 : | static LLFloaterSellLandUI* soleInstance(bool createIfNeeded); | ||
| 96 : | |||
| 97 : | bool setParcel(LLViewerRegion* region, LLParcelSelectionHandle parcel); | ||
| 98 : | |||
| 99 : | private: | ||
| 100 : | class SelectionObserver : public LLParcelObserver | ||
| 101 : | { | ||
| 102 : | public: | ||
| 103 : | virtual void changed(); | ||
| 104 : | }; | ||
| 105 : | }; | ||
| 106 : | |||
| 107 : | // static | ||
| 108 : | void LLFloaterSellLand::sellLand( | ||
| 109 : | LLViewerRegion* region, LLParcelSelectionHandle parcel) | ||
| 110 : | { | ||
| 111 : | LLFloaterSellLandUI* ui = LLFloaterSellLandUI::soleInstance(true); | ||
| 112 : | if (ui->setParcel(region, parcel)) | ||
| 113 : | { | ||
| 114 : | ui->open(); /* Flawfinder: ignore */ | ||
| 115 : | } | ||
| 116 : | } | ||
| 117 : | |||
| 118 : | // static | ||
| 119 : | LLFloaterSellLandUI* LLFloaterSellLandUI::sInstance = NULL; | ||
| 120 : | |||
| 121 : | // static | ||
| 122 : | LLFloaterSellLandUI* LLFloaterSellLandUI::soleInstance(bool createIfNeeded) | ||
| 123 : | { | ||
| 124 : | if (!sInstance && createIfNeeded) | ||
| 125 : | { | ||
| 126 : | sInstance = new LLFloaterSellLandUI(); | ||
| 127 : | |||
| 128 : | LLUICtrlFactory::getInstance()->buildFloater(sInstance, "floater_sell_land.xml"); | ||
| 129 : | sInstance->center(); | ||
| 130 : | } | ||
| 131 : | |||
| 132 : | |||
| 133 : | static SelectionObserver* parcelSelectionObserver = NULL; | ||
| 134 : | if (!parcelSelectionObserver) | ||
| 135 : | { | ||
| 136 : | parcelSelectionObserver = new SelectionObserver; | ||
| 137 : | LLViewerParcelMgr::getInstance()->addObserver(parcelSelectionObserver); | ||
| 138 : | } | ||
| 139 : | |||
| 140 : | return sInstance; | ||
| 141 : | } | ||
| 142 : | |||
| 143 : | LLFloaterSellLandUI::LLFloaterSellLandUI() | ||
| 144 : | : LLFloater(std::string("Sell Land")), | ||
| 145 : | mRegion(0) | ||
| 146 : | { | ||
| 147 : | } | ||
| 148 : | |||
| 149 : | LLFloaterSellLandUI::~LLFloaterSellLandUI() | ||
| 150 : | { | ||
| 151 : | if (sInstance == this) | ||
| 152 : | { | ||
| 153 : | sInstance = NULL; | ||
| 154 : | } | ||
| 155 : | } | ||
| 156 : | |||
| 157 : | void LLFloaterSellLandUI::SelectionObserver::changed() | ||
| 158 : | { | ||
| 159 : | LLFloaterSellLandUI* ui = LLFloaterSellLandUI::soleInstance(false); | ||
| 160 : | if (ui) | ||
| 161 : | { | ||
| 162 : | if (LLViewerParcelMgr::getInstance()->selectionEmpty()) | ||
| 163 : | { | ||
| 164 : | ui->close(); | ||
| 165 : | } | ||
| 166 : | else { | ||
| 167 : | ui->setParcel( | ||
| 168 : | LLViewerParcelMgr::getInstance()->getSelectionRegion(), | ||
| 169 : | LLViewerParcelMgr::getInstance()->getParcelSelection()); | ||
| 170 : | } | ||
| 171 : | } | ||
| 172 : | } | ||
| 173 : | |||
| 174 : | void LLFloaterSellLandUI::onClose(bool app_quitting) | ||
| 175 : | { | ||
| 176 : | LLFloater::onClose(app_quitting); | ||
| 177 : | destroy(); | ||
| 178 : | } | ||
| 179 : | |||
| 180 : | BOOL LLFloaterSellLandUI::postBuild() | ||
| 181 : | { | ||
| 182 : | childSetCommitCallback("sell_to", onChangeValue, this); | ||
| 183 : | childSetCommitCallback("price", onChangeValue, this); | ||
| 184 : | childSetPrevalidate("price", LLLineEditor::prevalidateNonNegativeS32); | ||
| 185 : | childSetCommitCallback("sell_objects", onChangeValue, this); | ||
| 186 : | childSetAction("sell_to_select_agent", doSelectAgent, this); | ||
| 187 : | childSetAction("cancel_btn", doCancel, this); | ||
| 188 : | childSetAction("sell_btn", doSellLand, this); | ||
| 189 : | childSetAction("show_objects", doShowObjects, this); | ||
| 190 : | return TRUE; | ||
| 191 : | } | ||
| 192 : | |||
| 193 : | bool LLFloaterSellLandUI::setParcel(LLViewerRegion* region, LLParcelSelectionHandle parcel) | ||
| 194 : | { | ||
| 195 : | if (!parcel->getParcel()) // || !can_agent_modify_parcel(parcel)) // can_agent_modify_parcel was deprecated by GROUPS | ||
| 196 : | { | ||
| 197 : | return false; | ||
| 198 : | } | ||
| 199 : | |||
| 200 : | mRegion = region; | ||
| 201 : | mParcelSelection = parcel; | ||
| 202 : | mChoseSellTo = false; | ||
| 203 : | |||
| 204 : | |||
| 205 : | updateParcelInfo(); | ||
| 206 : | refreshUI(); | ||
| 207 : | |||
| 208 : | return true; | ||
| 209 : | } | ||
| 210 : | |||
| 211 : | void LLFloaterSellLandUI::updateParcelInfo() | ||
| 212 : | { | ||
| 213 : | LLParcel* parcelp = mParcelSelection->getParcel(); | ||
| 214 : | if (!parcelp) return; | ||
| 215 : | |||
| 216 : | mParcelActualArea = parcelp->getArea(); | ||
| 217 : | mParcelIsForSale = parcelp->getForSale(); | ||
| 218 : | if (mParcelIsForSale) | ||
| 219 : | { | ||
| 220 : | mChoseSellTo = true; | ||
| 221 : | } | ||
| 222 : | mParcelPrice = mParcelIsForSale ? parcelp->getSalePrice() : 0; | ||
| 223 : | mParcelSoldWithObjects = parcelp->getSellWithObjects(); | ||
| 224 : | if (mParcelIsForSale) | ||
| 225 : | { | ||
| 226 : | childSetValue("price", mParcelPrice); | ||
| 227 : | if (mParcelSoldWithObjects) | ||
| 228 : | { | ||
| 229 : | childSetValue("sell_objects", "yes"); | ||
| 230 : | } | ||
| 231 : | else | ||
| 232 : | { | ||
| 233 : | childSetValue("sell_objects", "no"); | ||
| 234 : | } | ||
| 235 : | } | ||
| 236 : | else | ||
| 237 : | { | ||
| 238 : | childSetValue("price", ""); | ||
| 239 : | childSetValue("sell_objects", "none"); | ||
| 240 : | } | ||
| 241 : | |||
| 242 : | mParcelSnapshot = parcelp->getSnapshotID(); | ||
| 243 : | |||
| 244 : | mAuthorizedBuyer = parcelp->getAuthorizedBuyerID(); | ||
| 245 : | mSellToBuyer = mAuthorizedBuyer.notNull(); | ||
| 246 : | |||
| 247 : | if(mSellToBuyer) | ||
| 248 : | { | ||
| 249 : | std::string name; | ||
| 250 : | gCacheName->getFullName(mAuthorizedBuyer, name); | ||
| 251 : | childSetText("sell_to_agent", name); | ||
| 252 : | } | ||
| 253 : | } | ||
| 254 : | |||
| 255 : | void LLFloaterSellLandUI::setBadge(const char* id, Badge badge) | ||
| 256 : | { | ||
| 257 : | static std::string badgeOK("badge_ok.j2c"); | ||
| 258 : | static std::string badgeNote("badge_note.j2c"); | ||
| 259 : | static std::string badgeWarn("badge_warn.j2c"); | ||
| 260 : | static std::string badgeError("badge_error.j2c"); | ||
| 261 : | |||
| 262 : | std::string badgeName; | ||
| 263 : | switch (badge) | ||
| 264 : | { | ||
| 265 : | default: | ||
| 266 : | case BADGE_OK: badgeName = badgeOK; break; | ||
| 267 : | case BADGE_NOTE: badgeName = badgeNote; break; | ||
| 268 : | case BADGE_WARN: badgeName = badgeWarn; break; | ||
| 269 : | case BADGE_ERROR: badgeName = badgeError; break; | ||
| 270 : | } | ||
| 271 : | |||
| 272 : | childSetValue(id, badgeName); | ||
| 273 : | } | ||
| 274 : | |||
| 275 : | void LLFloaterSellLandUI::refreshUI() | ||
| 276 : | { | ||
| 277 : | LLParcel* parcelp = mParcelSelection->getParcel(); | ||
| 278 : | if (!parcelp) return; | ||
| 279 : | |||
| 280 : | LLTextureCtrl* snapshot = getChild<LLTextureCtrl>("info_image"); | ||
| 281 : | if (snapshot) | ||
| 282 : | { | ||
| 283 : | snapshot->setImageAssetID(mParcelSnapshot); | ||
| 284 : | } | ||
| 285 : | |||
| 286 : | childSetText("info_parcel", parcelp->getName()); | ||
| 287 : | childSetTextArg("info_size", "[AREA]", llformat("%d", mParcelActualArea)); | ||
| 288 : | |||
| 289 : | childSetTextArg("price_ld", "[CURRENCY]", gHippoGridManager->getConnectedGrid()->getCurrencySymbol()); | ||
| 290 : | |||
| 291 : | std::string price_str = childGetValue("price").asString(); | ||
| 292 : | bool valid_price = false; | ||
| 293 : | valid_price = (price_str != "") && LLLineEditor::prevalidateNonNegativeS32(utf8str_to_wstring(price_str)); | ||
| 294 : | |||
| 295 : | if (valid_price && mParcelActualArea > 0) | ||
| 296 : | { | ||
| 297 : | F32 per_meter_price = 0; | ||
| 298 : | per_meter_price = F32(mParcelPrice) / F32(mParcelActualArea); | ||
| 299 : | childSetTextArg("price_per_m", "[CURRENCY]", gHippoGridManager->getConnectedGrid()->getCurrencySymbol()); | ||
| 300 : | childSetTextArg("price_per_m", "[PER_METER]", llformat("%0.2f", per_meter_price)); | ||
| 301 : | childShow("price_per_m"); | ||
| 302 : | |||
| 303 : | setBadge("step_price", BADGE_OK); | ||
| 304 : | } | ||
| 305 : | else | ||
| 306 : | { | ||
| 307 : | childHide("price_per_m"); | ||
| 308 : | |||
| 309 : | if ("" == price_str) | ||
| 310 : | { | ||
| 311 : | setBadge("step_price", BADGE_NOTE); | ||
| 312 : | } | ||
| 313 : | else | ||
| 314 : | { | ||
| 315 : | setBadge("step_price", BADGE_ERROR); | ||
| 316 : | } | ||
| 317 : | } | ||
| 318 : | |||
| 319 : | if (mSellToBuyer) | ||
| 320 : | { | ||
| 321 : | childSetValue("sell_to", "user"); | ||
| 322 : | childShow("sell_to_agent"); | ||
| 323 : | childShow("sell_to_select_agent"); | ||
| 324 : | } | ||
| 325 : | else | ||
| 326 : | { | ||
| 327 : | if (mChoseSellTo) | ||
| 328 : | { | ||
| 329 : | childSetValue("sell_to", "anyone"); | ||
| 330 : | } | ||
| 331 : | else | ||
| 332 : | { | ||
| 333 : | childSetValue("sell_to", "select"); | ||
| 334 : | } | ||
| 335 : | childHide("sell_to_agent"); | ||
| 336 : | childHide("sell_to_select_agent"); | ||
| 337 : | } | ||
| 338 : | |||
| 339 : | // Must select Sell To: Anybody, or User (with a specified username) | ||
| 340 : | std::string sell_to = childGetValue("sell_to").asString(); | ||
| 341 : | bool valid_sell_to = "select" != sell_to && | ||
| 342 : | ("user" != sell_to || mAuthorizedBuyer.notNull()); | ||
| 343 : | |||
| 344 : | if (!valid_sell_to) | ||
| 345 : | { | ||
| 346 : | setBadge("step_sell_to", BADGE_NOTE); | ||
| 347 : | } | ||
| 348 : | else | ||
| 349 : | { | ||
| 350 : | setBadge("step_sell_to", BADGE_OK); | ||
| 351 : | } | ||
| 352 : | |||
| 353 : | bool valid_sell_objects = ("none" != childGetValue("sell_objects").asString()); | ||
| 354 : | |||
| 355 : | if (!valid_sell_objects) | ||
| 356 : | { | ||
| 357 : | setBadge("step_sell_objects", BADGE_NOTE); | ||
| 358 : | } | ||
| 359 : | else | ||
| 360 : | { | ||
| 361 : | setBadge("step_sell_objects", BADGE_OK); | ||
| 362 : | } | ||
| 363 : | |||
| 364 : | if (valid_sell_to && valid_price && valid_sell_objects) | ||
| 365 : | { | ||
| 366 : | childEnable("sell_btn"); | ||
| 367 : | } | ||
| 368 : | else | ||
| 369 : | { | ||
| 370 : | childDisable("sell_btn"); | ||
| 371 : | } | ||
| 372 : | } | ||
| 373 : | |||
| 374 : | // static | ||
| 375 : | void LLFloaterSellLandUI::onChangeValue(LLUICtrl *ctrl, void *userdata) | ||
| 376 : | { | ||
| 377 : | LLFloaterSellLandUI *self = (LLFloaterSellLandUI *)userdata; | ||
| 378 : | |||
| 379 : | std::string sell_to = self->childGetValue("sell_to").asString(); | ||
| 380 : | |||
| 381 : | if (sell_to == "user") | ||
| 382 : | { | ||
| 383 : | self->mChoseSellTo = true; | ||
| 384 : | self->mSellToBuyer = true; | ||
| 385 : | if (self->mAuthorizedBuyer.isNull()) | ||
| 386 : | { | ||
| 387 : | doSelectAgent(self); | ||
| 388 : | } | ||
| 389 : | } | ||
| 390 : | else if (sell_to == "anyone") | ||
| 391 : | { | ||
| 392 : | self->mChoseSellTo = true; | ||
| 393 : | self->mSellToBuyer = false; | ||
| 394 : | } | ||
| 395 : | |||
| 396 : | self->mParcelPrice = self->childGetValue("price"); | ||
| 397 : | |||
| 398 : | if ("yes" == self->childGetValue("sell_objects").asString()) | ||
| 399 : | { | ||
| 400 : | self->mParcelSoldWithObjects = true; | ||
| 401 : | } | ||
| 402 : | else | ||
| 403 : | { | ||
| 404 : | self->mParcelSoldWithObjects = false; | ||
| 405 : | } | ||
| 406 : | |||
| 407 : | self->refreshUI(); | ||
| 408 : | } | ||
| 409 : | |||
| 410 : | // static | ||
| 411 : | void LLFloaterSellLandUI::doSelectAgent(void *userdata) | ||
| 412 : | { | ||
| 413 : | LLFloaterSellLandUI* floaterp = (LLFloaterSellLandUI*)userdata; | ||
| 414 : | // grandparent is a floater, in order to set up dependency | ||
| 415 : | floaterp->addDependentFloater(LLFloaterAvatarPicker::show(callbackAvatarPick, floaterp, FALSE, TRUE)); | ||
| 416 : | } | ||
| 417 : | |||
| 418 : | // static | ||
| 419 : | void LLFloaterSellLandUI::callbackAvatarPick(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data) | ||
| 420 : | { | ||
| 421 : | LLFloaterSellLandUI* floaterp = (LLFloaterSellLandUI*)data; | ||
| 422 : | LLParcel* parcel = floaterp->mParcelSelection->getParcel(); | ||
| 423 : | |||
| 424 : | if (names.empty() || ids.empty()) return; | ||
| 425 : | |||
| 426 : | LLUUID id = ids[0]; | ||
| 427 : | parcel->setAuthorizedBuyerID(id); | ||
| 428 : | |||
| 429 : | floaterp->mAuthorizedBuyer = ids[0]; | ||
| 430 : | |||
| 431 : | floaterp->childSetText("sell_to_agent", names[0]); | ||
| 432 : | |||
| 433 : | floaterp->refreshUI(); | ||
| 434 : | } | ||
| 435 : | |||
| 436 : | // static | ||
| 437 : | void LLFloaterSellLandUI::doCancel(void *userdata) | ||
| 438 : | { | ||
| 439 : | LLFloaterSellLandUI* self = (LLFloaterSellLandUI*)userdata; | ||
| 440 : | self->close(); | ||
| 441 : | } | ||
| 442 : | |||
| 443 : | // static | ||
| 444 : | void LLFloaterSellLandUI::doShowObjects(void *userdata) | ||
| 445 : | { | ||
| 446 : | LLFloaterSellLandUI* self = (LLFloaterSellLandUI*)userdata; | ||
| 447 : | LLParcel* parcel = self->mParcelSelection->getParcel(); | ||
| 448 : | if (!parcel) return; | ||
| 449 : | |||
| 450 : | send_parcel_select_objects(parcel->getLocalID(), RT_SELL); | ||
| 451 : | |||
| 452 : | LLNotifications::instance().add("TransferObjectsHighlighted", | ||
| 453 : | LLSD(), LLSD(), | ||
| 454 : | &LLFloaterSellLandUI::callbackHighlightTransferable); | ||
| 455 : | } | ||
| 456 : | |||
| 457 : | // static | ||
| 458 : | bool LLFloaterSellLandUI::callbackHighlightTransferable(const LLSD& notification, const LLSD& data) | ||
| 459 : | { | ||
| 460 : | LLSelectMgr::getInstance()->unhighlightAll(); | ||
| 461 : | return false; | ||
| 462 : | } | ||
| 463 : | |||
| 464 : | // static | ||
| 465 : | void LLFloaterSellLandUI::doSellLand(void *userdata) | ||
| 466 : | { | ||
| 467 : | LLFloaterSellLandUI* self = (LLFloaterSellLandUI*)userdata; | ||
| 468 : | |||
| 469 : | LLParcel* parcel = self->mParcelSelection->getParcel(); | ||
| 470 : | |||
| 471 : | // Do a confirmation | ||
| 472 : | S32 sale_price = self->childGetValue("price"); | ||
| 473 : | S32 area = parcel->getArea(); | ||
| 474 : | std::string authorizedBuyerName = "Anyone"; | ||
| 475 : | bool sell_to_anyone = true; | ||
| 476 : | if ("user" == self->childGetValue("sell_to").asString()) | ||
| 477 : | { | ||
| 478 : | authorizedBuyerName = self->childGetText("sell_to_agent"); | ||
| 479 : | sell_to_anyone = false; | ||
| 480 : | } | ||
| 481 : | |||
| 482 : | // must sell to someone if indicating sale to anyone | ||
| 483 : | if (!parcel->getForSale() | ||
| 484 : | && (sale_price == 0) | ||
| 485 : | && sell_to_anyone) | ||
| 486 : | { | ||
| 487 : | LLSD args; | ||
| 488 : | args["CURRENCY"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); | ||
| 489 : | LLNotifications::instance().add("SalePriceRestriction", args); | ||
| 490 : | return; | ||
| 491 : | } | ||
| 492 : | |||
| 493 : | LLSD args; | ||
| 494 : | args["LAND_SIZE"] = llformat("%d",area); | ||
| 495 : | args["SALE_PRICE"] = llformat("%d",sale_price); | ||
| 496 : | args["NAME"] = authorizedBuyerName; | ||
| 497 : | args["CURRENCY"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); | ||
| 498 : | |||
| 499 : | LLNotification::Params params("ConfirmLandSaleChange"); | ||
| 500 : | params.substitutions(args) | ||
| 501 : | .functor(boost::bind(&LLFloaterSellLandUI::onConfirmSale, self, _1, _2)); | ||
| 502 : | |||
| 503 : | if (sell_to_anyone) | ||
| 504 : | { | ||
| 505 : | params.name("ConfirmLandSaleToAnyoneChange"); | ||
| 506 : | } | ||
| 507 : | |||
| 508 : | if (parcel->getForSale()) | ||
| 509 : | { | ||
| 510 : | // parcel already for sale, so ignore this question | ||
| 511 : | LLNotifications::instance().forceResponse(params, -1); | ||
| 512 : | } | ||
| 513 : | else | ||
| 514 : | { | ||
| 515 : | // ask away | ||
| 516 : | LLNotifications::instance().add(params); | ||
| 517 : | } | ||
| 518 : | |||
| 519 : | } | ||
| 520 : | |||
| 521 : | bool LLFloaterSellLandUI::onConfirmSale(const LLSD& notification, const LLSD& response) | ||
| 522 : | { | ||
| 523 : | S32 option = LLNotification::getSelectedOption(notification, response); | ||
| 524 : | if (option != 0) | ||
| 525 : | { | ||
| 526 : | return false; | ||
| 527 : | } | ||
| 528 : | S32 sale_price = childGetValue("price"); | ||
| 529 : | |||
| 530 : | // Valid extracted data | ||
| 531 : | if (sale_price < 0) | ||
| 532 : | { | ||
| 533 : | // TomY TODO: Throw an error | ||
| 534 : | return false; | ||
| 535 : | } | ||
| 536 : | |||
| 537 : | LLParcel* parcel = mParcelSelection->getParcel(); | ||
| 538 : | if (!parcel) return false; | ||
| 539 : | |||
| 540 : | // can_agent_modify_parcel deprecated by GROUPS | ||
| 541 : | // if (!can_agent_modify_parcel(parcel)) | ||
| 542 : | // { | ||
| 543 : | // close(); | ||
| 544 : | // return; | ||
| 545 : | // } | ||
| 546 : | |||
| 547 : | parcel->setParcelFlag(PF_FOR_SALE, TRUE); | ||
| 548 : | parcel->setSalePrice(sale_price); | ||
| 549 : | bool sell_with_objects = false; | ||
| 550 : | if ("yes" == childGetValue("sell_objects").asString()) | ||
| 551 : | { | ||
| 552 : | sell_with_objects = true; | ||
| 553 : | } | ||
| 554 : | parcel->setSellWithObjects(sell_with_objects); | ||
| 555 : | if ("user" == childGetValue("sell_to").asString()) | ||
| 556 : | { | ||
| 557 : | parcel->setAuthorizedBuyerID(mAuthorizedBuyer); | ||
| 558 : | } | ||
| 559 : | else | ||
| 560 : | { | ||
| 561 : | parcel->setAuthorizedBuyerID(LLUUID::null); | ||
| 562 : | } | ||
| 563 : | |||
| 564 : | // Send update to server | ||
| 565 : | LLViewerParcelMgr::getInstance()->sendParcelPropertiesUpdate( parcel ); | ||
| 566 : | |||
| 567 : | close(); | ||
| 568 : | return false; | ||
| 569 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

