diff options
Diffstat (limited to 'linden/indra/newview/llfloatersellland.cpp')
-rwxr-xr-x | linden/indra/newview/llfloatersellland.cpp | 104 |
1 files changed, 73 insertions, 31 deletions
diff --git a/linden/indra/newview/llfloatersellland.cpp b/linden/indra/newview/llfloatersellland.cpp index 5fac819..cc7df3b 100755 --- a/linden/indra/newview/llfloatersellland.cpp +++ b/linden/indra/newview/llfloatersellland.cpp | |||
@@ -55,15 +55,15 @@ private: | |||
55 | virtual ~LLFloaterSellLandUI(); | 55 | virtual ~LLFloaterSellLandUI(); |
56 | 56 | ||
57 | LLViewerRegion* mRegion; | 57 | LLViewerRegion* mRegion; |
58 | LLParcel* mParcel; | 58 | LLParcelSelectionHandle mParcelSelection; |
59 | bool mParcelIsForSale; | 59 | bool mParcelIsForSale; |
60 | bool mSellToBuyer; | 60 | bool mSellToBuyer; |
61 | bool mChoseSellTo; | 61 | bool mChoseSellTo; |
62 | S32 mParcelPrice; | 62 | S32 mParcelPrice; |
63 | S32 mParcelActualArea; | 63 | S32 mParcelActualArea; |
64 | LLUUID mParcelSnapshot; | 64 | LLUUID mParcelSnapshot; |
65 | LLUUID mAuthorizedBuyer; | 65 | LLUUID mAuthorizedBuyer; |
66 | bool mParcelSoldWithObjects; | 66 | bool mParcelSoldWithObjects; |
67 | 67 | ||
68 | void updateParcelInfo(); | 68 | void updateParcelInfo(); |
69 | void refreshUI(); | 69 | void refreshUI(); |
@@ -87,17 +87,24 @@ public: | |||
87 | 87 | ||
88 | static LLFloaterSellLandUI* soleInstance(bool createIfNeeded); | 88 | static LLFloaterSellLandUI* soleInstance(bool createIfNeeded); |
89 | 89 | ||
90 | bool setParcel(LLViewerRegion* region, LLParcel* parcel); | 90 | bool setParcel(LLViewerRegion* region, LLParcelSelectionHandle parcel); |
91 | |||
92 | private: | ||
93 | class SelectionObserver : public LLParcelObserver | ||
94 | { | ||
95 | public: | ||
96 | virtual void changed(); | ||
97 | }; | ||
91 | }; | 98 | }; |
92 | 99 | ||
93 | // static | 100 | // static |
94 | void LLFloaterSellLand::sellLand( | 101 | void LLFloaterSellLand::sellLand( |
95 | LLViewerRegion* region, LLParcel* parcel) | 102 | LLViewerRegion* region, LLParcelSelectionHandle parcel) |
96 | { | 103 | { |
97 | LLFloaterSellLandUI* ui = LLFloaterSellLandUI::soleInstance(true); | 104 | LLFloaterSellLandUI* ui = LLFloaterSellLandUI::soleInstance(true); |
98 | if (ui->setParcel(region, parcel)) | 105 | if (ui->setParcel(region, parcel)) |
99 | { | 106 | { |
100 | ui->open(); | 107 | ui->open(); /* Flawfinder: ignore */ |
101 | } | 108 | } |
102 | } | 109 | } |
103 | 110 | ||
@@ -115,12 +122,20 @@ LLFloaterSellLandUI* LLFloaterSellLandUI::soleInstance(bool createIfNeeded) | |||
115 | sInstance->center(); | 122 | sInstance->center(); |
116 | } | 123 | } |
117 | 124 | ||
125 | |||
126 | static SelectionObserver* parcelSelectionObserver = NULL; | ||
127 | if (!parcelSelectionObserver) | ||
128 | { | ||
129 | parcelSelectionObserver = new SelectionObserver; | ||
130 | gParcelMgr->addObserver(parcelSelectionObserver); | ||
131 | } | ||
132 | |||
118 | return sInstance; | 133 | return sInstance; |
119 | } | 134 | } |
120 | 135 | ||
121 | LLFloaterSellLandUI::LLFloaterSellLandUI() | 136 | LLFloaterSellLandUI::LLFloaterSellLandUI() |
122 | : LLFloater("Sell Land"), | 137 | : LLFloater("Sell Land"), |
123 | mRegion(0), mParcel(0) | 138 | mRegion(0) |
124 | { | 139 | { |
125 | } | 140 | } |
126 | 141 | ||
@@ -132,11 +147,27 @@ LLFloaterSellLandUI::~LLFloaterSellLandUI() | |||
132 | } | 147 | } |
133 | } | 148 | } |
134 | 149 | ||
150 | void LLFloaterSellLandUI::SelectionObserver::changed() | ||
151 | { | ||
152 | LLFloaterSellLandUI* ui = LLFloaterSellLandUI::soleInstance(false); | ||
153 | if (ui) | ||
154 | { | ||
155 | if (gParcelMgr->selectionEmpty()) | ||
156 | { | ||
157 | ui->close(); | ||
158 | } | ||
159 | else { | ||
160 | ui->setParcel( | ||
161 | gParcelMgr->getSelectionRegion(), | ||
162 | gParcelMgr->getParcelSelection()); | ||
163 | } | ||
164 | } | ||
165 | } | ||
135 | 166 | ||
136 | void LLFloaterSellLandUI::onClose(bool app_quitting) | 167 | void LLFloaterSellLandUI::onClose(bool app_quitting) |
137 | { | 168 | { |
138 | LLFloater::onClose(app_quitting); | 169 | LLFloater::onClose(app_quitting); |
139 | delete this; | 170 | destroy(); |
140 | } | 171 | } |
141 | 172 | ||
142 | BOOL LLFloaterSellLandUI::postBuild() | 173 | BOOL LLFloaterSellLandUI::postBuild() |
@@ -152,17 +183,18 @@ BOOL LLFloaterSellLandUI::postBuild() | |||
152 | return TRUE; | 183 | return TRUE; |
153 | } | 184 | } |
154 | 185 | ||
155 | bool LLFloaterSellLandUI::setParcel(LLViewerRegion* region, LLParcel* parcel) | 186 | bool LLFloaterSellLandUI::setParcel(LLViewerRegion* region, LLParcelSelectionHandle parcel) |
156 | { | 187 | { |
157 | if (!parcel) // || !can_agent_modify_parcel(parcel)) // can_agent_modify_parcel was deprecated by GROUPS | 188 | if (!parcel->getParcel()) // || !can_agent_modify_parcel(parcel)) // can_agent_modify_parcel was deprecated by GROUPS |
158 | { | 189 | { |
159 | return false; | 190 | return false; |
160 | } | 191 | } |
161 | 192 | ||
162 | mRegion = region; | 193 | mRegion = region; |
163 | mParcel = parcel; | 194 | mParcelSelection = parcel; |
164 | mChoseSellTo = false; | 195 | mChoseSellTo = false; |
165 | 196 | ||
197 | |||
166 | updateParcelInfo(); | 198 | updateParcelInfo(); |
167 | refreshUI(); | 199 | refreshUI(); |
168 | 200 | ||
@@ -171,14 +203,17 @@ bool LLFloaterSellLandUI::setParcel(LLViewerRegion* region, LLParcel* parcel) | |||
171 | 203 | ||
172 | void LLFloaterSellLandUI::updateParcelInfo() | 204 | void LLFloaterSellLandUI::updateParcelInfo() |
173 | { | 205 | { |
174 | mParcelActualArea = mParcel->getArea(); | 206 | LLParcel* parcelp = mParcelSelection->getParcel(); |
175 | mParcelIsForSale = mParcel->getForSale(); | 207 | if (!parcelp) return; |
208 | |||
209 | mParcelActualArea = parcelp->getArea(); | ||
210 | mParcelIsForSale = parcelp->getForSale(); | ||
176 | if (mParcelIsForSale) | 211 | if (mParcelIsForSale) |
177 | { | 212 | { |
178 | mChoseSellTo = true; | 213 | mChoseSellTo = true; |
179 | } | 214 | } |
180 | mParcelPrice = mParcelIsForSale ? mParcel->getSalePrice() : 0; | 215 | mParcelPrice = mParcelIsForSale ? parcelp->getSalePrice() : 0; |
181 | mParcelSoldWithObjects = mParcel->getSellWithObjects(); | 216 | mParcelSoldWithObjects = parcelp->getSellWithObjects(); |
182 | if (mParcelIsForSale) | 217 | if (mParcelIsForSale) |
183 | { | 218 | { |
184 | childSetValue("price", mParcelPrice); | 219 | childSetValue("price", mParcelPrice); |
@@ -197,16 +232,16 @@ void LLFloaterSellLandUI::updateParcelInfo() | |||
197 | childSetValue("sell_objects", "none"); | 232 | childSetValue("sell_objects", "none"); |
198 | } | 233 | } |
199 | 234 | ||
200 | mParcelSnapshot = mParcel->getSnapshotID(); | 235 | mParcelSnapshot = parcelp->getSnapshotID(); |
201 | 236 | ||
202 | mAuthorizedBuyer = mParcel->getAuthorizedBuyerID(); | 237 | mAuthorizedBuyer = parcelp->getAuthorizedBuyerID(); |
203 | mSellToBuyer = mAuthorizedBuyer.notNull(); | 238 | mSellToBuyer = mAuthorizedBuyer.notNull(); |
204 | 239 | ||
205 | if(mSellToBuyer) | 240 | if(mSellToBuyer) |
206 | { | 241 | { |
207 | LLString name; | 242 | LLString name; |
208 | char firstname[MAX_STRING]; | 243 | char firstname[MAX_STRING]; /* Flawfinder: ignore */ |
209 | char lastname[MAX_STRING]; | 244 | char lastname[MAX_STRING]; /* Flawfinder: ignore */ |
210 | gCacheName->getName(mAuthorizedBuyer, firstname, lastname); | 245 | gCacheName->getName(mAuthorizedBuyer, firstname, lastname); |
211 | name.assign(firstname); | 246 | name.assign(firstname); |
212 | name.append(" "); | 247 | name.append(" "); |
@@ -238,13 +273,16 @@ void LLFloaterSellLandUI::setBadge(const char* id, Badge badge) | |||
238 | 273 | ||
239 | void LLFloaterSellLandUI::refreshUI() | 274 | void LLFloaterSellLandUI::refreshUI() |
240 | { | 275 | { |
276 | LLParcel* parcelp = mParcelSelection->getParcel(); | ||
277 | if (!parcelp) return; | ||
278 | |||
241 | LLTextureCtrl* snapshot = LLViewerUICtrlFactory::getTexturePickerByName(this, "info_image"); | 279 | LLTextureCtrl* snapshot = LLViewerUICtrlFactory::getTexturePickerByName(this, "info_image"); |
242 | if (snapshot) | 280 | if (snapshot) |
243 | { | 281 | { |
244 | snapshot->setImageAssetID(mParcelSnapshot); | 282 | snapshot->setImageAssetID(mParcelSnapshot); |
245 | } | 283 | } |
246 | 284 | ||
247 | childSetText("info_parcel", mParcel->getName()); | 285 | childSetText("info_parcel", parcelp->getName()); |
248 | childSetTextArg("info_size", "[AREA]", llformat("%d", mParcelActualArea)); | 286 | childSetTextArg("info_size", "[AREA]", llformat("%d", mParcelActualArea)); |
249 | 287 | ||
250 | LLString price_str = childGetValue("price").asString(); | 288 | LLString price_str = childGetValue("price").asString(); |
@@ -377,7 +415,7 @@ void LLFloaterSellLandUI::doSelectAgent(void *userdata) | |||
377 | void LLFloaterSellLandUI::callbackAvatarPick(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data) | 415 | void LLFloaterSellLandUI::callbackAvatarPick(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data) |
378 | { | 416 | { |
379 | LLFloaterSellLandUI* floaterp = (LLFloaterSellLandUI*)data; | 417 | LLFloaterSellLandUI* floaterp = (LLFloaterSellLandUI*)data; |
380 | LLParcel* parcel = floaterp->mParcel; | 418 | LLParcel* parcel = floaterp->mParcelSelection->getParcel(); |
381 | 419 | ||
382 | if (names.empty() || ids.empty()) return; | 420 | if (names.empty() || ids.empty()) return; |
383 | 421 | ||
@@ -402,7 +440,10 @@ void LLFloaterSellLandUI::doCancel(void *userdata) | |||
402 | void LLFloaterSellLandUI::doShowObjects(void *userdata) | 440 | void LLFloaterSellLandUI::doShowObjects(void *userdata) |
403 | { | 441 | { |
404 | LLFloaterSellLandUI* self = (LLFloaterSellLandUI*)userdata; | 442 | LLFloaterSellLandUI* self = (LLFloaterSellLandUI*)userdata; |
405 | send_parcel_select_objects(self->mParcel->getLocalID(), RT_SELL); | 443 | LLParcel* parcel = self->mParcelSelection->getParcel(); |
444 | if (!parcel) return; | ||
445 | |||
446 | send_parcel_select_objects(parcel->getLocalID(), RT_SELL); | ||
406 | 447 | ||
407 | LLNotifyBox::showXml("TransferObjectsHighlighted", | 448 | LLNotifyBox::showXml("TransferObjectsHighlighted", |
408 | callbackHighlightTransferable, | 449 | callbackHighlightTransferable, |
@@ -420,7 +461,7 @@ void LLFloaterSellLandUI::doSellLand(void *userdata) | |||
420 | { | 461 | { |
421 | LLFloaterSellLandUI* self = (LLFloaterSellLandUI*)userdata; | 462 | LLFloaterSellLandUI* self = (LLFloaterSellLandUI*)userdata; |
422 | 463 | ||
423 | LLParcel* parcel = self->mParcel; | 464 | LLParcel* parcel = self->mParcelSelection->getParcel(); |
424 | 465 | ||
425 | // Do a confirmation | 466 | // Do a confirmation |
426 | if (!parcel->getForSale()) | 467 | if (!parcel->getForSale()) |
@@ -472,7 +513,8 @@ void LLFloaterSellLandUI::onConfirmSale(S32 option, void *userdata) | |||
472 | return; | 513 | return; |
473 | } | 514 | } |
474 | 515 | ||
475 | LLParcel* parcel = self->mParcel; | 516 | LLParcel* parcel = self->mParcelSelection->getParcel(); |
517 | if (!parcel) return; | ||
476 | 518 | ||
477 | // can_agent_modify_parcel deprecated by GROUPS | 519 | // can_agent_modify_parcel deprecated by GROUPS |
478 | // if (!can_agent_modify_parcel(parcel)) | 520 | // if (!can_agent_modify_parcel(parcel)) |
@@ -499,7 +541,7 @@ void LLFloaterSellLandUI::onConfirmSale(S32 option, void *userdata) | |||
499 | } | 541 | } |
500 | 542 | ||
501 | // Send update to server | 543 | // Send update to server |
502 | gParcelMgr->sendParcelPropertiesUpdate( parcel, LLFloaterLand::sRequestReplyOnUpdate ); | 544 | gParcelMgr->sendParcelPropertiesUpdate( parcel ); |
503 | 545 | ||
504 | self->close(); | 546 | self->close(); |
505 | } | 547 | } |