Annotation of /trunk/indra/newview/llpanelland.cpp
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llpanelland.cpp | ||
| 3 : | * @brief Land information in the tool floater, NOT the "About Land" floater | ||
| 4 : | * | ||
| 5 : | * $LicenseInfo:firstyear=2002&license=viewergpl$ | ||
| 6 : | * | ||
| 7 : | mjm | 137 | * Copyright (c) 2002-2010, Linden Research, Inc. |
| 8 : | mjm | 135 | * |
| 9 : | * Second Life Viewer Source Code | ||
| 10 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 11 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 12 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 13 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 14 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 15 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 16 : | * | ||
| 17 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 18 : | * it is applied to this Source Code. View the full text of the exception | ||
| 19 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 20 : | * online at | ||
| 21 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 22 : | * | ||
| 23 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 24 : | * that you have read and understood your obligations described above, | ||
| 25 : | * and agree to abide by those obligations. | ||
| 26 : | * | ||
| 27 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 28 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 29 : | * COMPLETENESS OR PERFORMANCE. | ||
| 30 : | * $/LicenseInfo$ | ||
| 31 : | */ | ||
| 32 : | |||
| 33 : | #include "llviewerprecompiledheaders.h" | ||
| 34 : | |||
| 35 : | #include "llpanelland.h" | ||
| 36 : | |||
| 37 : | #include "llparcel.h" | ||
| 38 : | |||
| 39 : | #include "llagent.h" | ||
| 40 : | #include "llbutton.h" | ||
| 41 : | #include "llcheckboxctrl.h" | ||
| 42 : | #include "llfloaterland.h" | ||
| 43 : | #include "lltextbox.h" | ||
| 44 : | #include "llviewercontrol.h" | ||
| 45 : | #include "llviewerparcelmgr.h" | ||
| 46 : | #include "llviewerregion.h" | ||
| 47 : | #include "llviewerwindow.h" | ||
| 48 : | #include "roles_constants.h" | ||
| 49 : | |||
| 50 : | #include "lluictrlfactory.h" | ||
| 51 : | |||
| 52 : | #include <hippoGridManager.h> | ||
| 53 : | |||
| 54 : | LLPanelLandSelectObserver* LLPanelLandInfo::sObserver = NULL; | ||
| 55 : | LLPanelLandInfo* LLPanelLandInfo::sInstance = NULL; | ||
| 56 : | |||
| 57 : | class LLPanelLandSelectObserver : public LLParcelObserver | ||
| 58 : | { | ||
| 59 : | public: | ||
| 60 : | LLPanelLandSelectObserver() {} | ||
| 61 : | virtual ~LLPanelLandSelectObserver() {} | ||
| 62 : | virtual void changed() { LLPanelLandInfo::refreshAll(); } | ||
| 63 : | }; | ||
| 64 : | |||
| 65 : | |||
| 66 : | BOOL LLPanelLandInfo::postBuild() | ||
| 67 : | { | ||
| 68 : | |||
| 69 : | childSetAction("button buy land",onClickClaim,this); | ||
| 70 : | childSetAction("button abandon land",onClickRelease,this); | ||
| 71 : | childSetAction("button subdivide land",onClickDivide,this); | ||
| 72 : | childSetAction("button join land",onClickJoin,this); | ||
| 73 : | childSetAction("button about land",onClickAbout,this); | ||
| 74 : | childSetAction("button show owners help", onShowOwnersHelp, this); | ||
| 75 : | |||
| 76 : | mCheckShowOwners = getChild<LLCheckBoxCtrl>("checkbox show owners"); | ||
| 77 : | childSetValue("checkbox show owners", gSavedSettings.getBOOL("ShowParcelOwners")); | ||
| 78 : | |||
| 79 : | return TRUE; | ||
| 80 : | } | ||
| 81 : | // | ||
| 82 : | // Methods | ||
| 83 : | // | ||
| 84 : | LLPanelLandInfo::LLPanelLandInfo(const std::string& name) | ||
| 85 : | : LLPanel(name), | ||
| 86 : | mCheckShowOwners(NULL) | ||
| 87 : | { | ||
| 88 : | if (!sInstance) | ||
| 89 : | { | ||
| 90 : | sInstance = this; | ||
| 91 : | } | ||
| 92 : | if (!sObserver) | ||
| 93 : | { | ||
| 94 : | sObserver = new LLPanelLandSelectObserver(); | ||
| 95 : | LLViewerParcelMgr::getInstance()->addObserver( sObserver ); | ||
| 96 : | } | ||
| 97 : | |||
| 98 : | } | ||
| 99 : | |||
| 100 : | |||
| 101 : | // virtual | ||
| 102 : | LLPanelLandInfo::~LLPanelLandInfo() | ||
| 103 : | { | ||
| 104 : | LLViewerParcelMgr::getInstance()->removeObserver( sObserver ); | ||
| 105 : | delete sObserver; | ||
| 106 : | sObserver = NULL; | ||
| 107 : | |||
| 108 : | sInstance = NULL; | ||
| 109 : | } | ||
| 110 : | |||
| 111 : | |||
| 112 : | // static | ||
| 113 : | void LLPanelLandInfo::refreshAll() | ||
| 114 : | { | ||
| 115 : | if (sInstance) | ||
| 116 : | { | ||
| 117 : | sInstance->refresh(); | ||
| 118 : | } | ||
| 119 : | } | ||
| 120 : | |||
| 121 : | |||
| 122 : | // public | ||
| 123 : | void LLPanelLandInfo::refresh() | ||
| 124 : | { | ||
| 125 : | LLParcel *parcel = LLViewerParcelMgr::getInstance()->getParcelSelection()->getParcel(); | ||
| 126 : | LLViewerRegion *regionp = LLViewerParcelMgr::getInstance()->getSelectionRegion(); | ||
| 127 : | |||
| 128 : | if (!parcel || !regionp) | ||
| 129 : | { | ||
| 130 : | // nothing selected, disable panel | ||
| 131 : | childSetVisible("label_area_price",false); | ||
| 132 : | childSetVisible("label_area",false); | ||
| 133 : | |||
| 134 : | //mTextPrice->setText(LLStringUtil::null); | ||
| 135 : | childSetText("textbox price",LLStringUtil::null); | ||
| 136 : | |||
| 137 : | childSetEnabled("button buy land",FALSE); | ||
| 138 : | childSetEnabled("button abandon land",FALSE); | ||
| 139 : | childSetEnabled("button subdivide land",FALSE); | ||
| 140 : | childSetEnabled("button join land",FALSE); | ||
| 141 : | childSetEnabled("button about land",FALSE); | ||
| 142 : | } | ||
| 143 : | else | ||
| 144 : | { | ||
| 145 : | // something selected, hooray! | ||
| 146 : | const LLUUID& owner_id = parcel->getOwnerID(); | ||
| 147 : | const LLUUID& auth_buyer_id = parcel->getAuthorizedBuyerID(); | ||
| 148 : | |||
| 149 : | BOOL is_public = parcel->isPublic(); | ||
| 150 : | BOOL is_for_sale = parcel->getForSale() | ||
| 151 : | && ((parcel->getSalePrice() > 0) || (auth_buyer_id.notNull())); | ||
| 152 : | BOOL can_buy = (is_for_sale | ||
| 153 : | && (owner_id != gAgent.getID()) | ||
| 154 : | && ((gAgent.getID() == auth_buyer_id) | ||
| 155 : | || (auth_buyer_id.isNull()))); | ||
| 156 : | |||
| 157 : | if (is_public) | ||
| 158 : | { | ||
| 159 : | childSetEnabled("button buy land",TRUE); | ||
| 160 : | } | ||
| 161 : | else | ||
| 162 : | { | ||
| 163 : | childSetEnabled("button buy land",can_buy); | ||
| 164 : | } | ||
| 165 : | |||
| 166 : | BOOL owner_release = LLViewerParcelMgr::isParcelOwnedByAgent(parcel, GP_LAND_RELEASE); | ||
| 167 : | BOOL owner_divide = LLViewerParcelMgr::isParcelOwnedByAgent(parcel, GP_LAND_DIVIDE_JOIN); | ||
| 168 : | |||
| 169 : | BOOL manager_releaseable = ( gAgent.canManageEstate() | ||
| 170 : | && (parcel->getOwnerID() == regionp->getOwner()) ); | ||
| 171 : | |||
| 172 : | BOOL manager_divideable = ( gAgent.canManageEstate() | ||
| 173 : | && ((parcel->getOwnerID() == regionp->getOwner()) || owner_divide) ); | ||
| 174 : | |||
| 175 : | childSetEnabled("button abandon land",owner_release || manager_releaseable || gAgent.isGodlike()); | ||
| 176 : | |||
| 177 : | // only mainland sims are subdividable by owner | ||
| 178 : | if (regionp->getRegionFlags() && REGION_FLAGS_ALLOW_PARCEL_CHANGES) | ||
| 179 : | { | ||
| 180 : | childSetEnabled("button subdivide land",owner_divide || manager_divideable || gAgent.isGodlike()); | ||
| 181 : | } | ||
| 182 : | else | ||
| 183 : | { | ||
| 184 : | childSetEnabled("button subdivide land",manager_divideable || gAgent.isGodlike()); | ||
| 185 : | } | ||
| 186 : | |||
| 187 : | // To join land, must have something selected, | ||
| 188 : | // not just a single unit of land, | ||
| 189 : | // you must own part of it, | ||
| 190 : | // and it must not be a whole parcel. | ||
| 191 : | if (LLViewerParcelMgr::getInstance()->getSelectedArea() > PARCEL_UNIT_AREA | ||
| 192 : | //&& LLViewerParcelMgr::getInstance()->getSelfCount() > 1 | ||
| 193 : | && !LLViewerParcelMgr::getInstance()->getParcelSelection()->getWholeParcelSelected()) | ||
| 194 : | { | ||
| 195 : | childSetEnabled("button join land",TRUE); | ||
| 196 : | } | ||
| 197 : | else | ||
| 198 : | { | ||
| 199 : | lldebugs << "Invalid selection for joining land" << llendl; | ||
| 200 : | childSetEnabled("button join land",FALSE); | ||
| 201 : | } | ||
| 202 : | |||
| 203 : | childSetEnabled("button about land",TRUE); | ||
| 204 : | |||
| 205 : | // show pricing information | ||
| 206 : | S32 area; | ||
| 207 : | S32 claim_price; | ||
| 208 : | S32 rent_price; | ||
| 209 : | BOOL for_sale; | ||
| 210 : | F32 dwell; | ||
| 211 : | LLViewerParcelMgr::getInstance()->getDisplayInfo(&area, | ||
| 212 : | &claim_price, | ||
| 213 : | &rent_price, | ||
| 214 : | &for_sale, | ||
| 215 : | &dwell); | ||
| 216 : | if(is_public || (is_for_sale && LLViewerParcelMgr::getInstance()->getParcelSelection()->getWholeParcelSelected())) | ||
| 217 : | { | ||
| 218 : | childSetTextArg("label_area_price","[CURRENCY]", gHippoGridManager->getConnectedGrid()->getCurrencySymbol()); | ||
| 219 : | childSetTextArg("label_area_price","[PRICE]", llformat("%d",claim_price)); | ||
| 220 : | childSetTextArg("label_area_price","[AREA]", llformat("%d",area)); | ||
| 221 : | childSetVisible("label_area_price",true); | ||
| 222 : | childSetVisible("label_area",false); | ||
| 223 : | } | ||
| 224 : | else | ||
| 225 : | { | ||
| 226 : | childSetVisible("label_area_price",false); | ||
| 227 : | childSetTextArg("label_area","[AREA]", llformat("%d",area)); | ||
| 228 : | childSetVisible("label_area",true); | ||
| 229 : | } | ||
| 230 : | } | ||
| 231 : | } | ||
| 232 : | |||
| 233 : | |||
| 234 : | //static | ||
| 235 : | void LLPanelLandInfo::onClickClaim(void*) | ||
| 236 : | { | ||
| 237 : | //MK | ||
| 238 : | if (gRRenabled && gAgent.mRRInterface.mContainsShowloc) | ||
| 239 : | { | ||
| 240 : | return; | ||
| 241 : | } | ||
| 242 : | //mk | ||
| 243 : | LLViewerParcelMgr::getInstance()->startBuyLand(); | ||
| 244 : | } | ||
| 245 : | |||
| 246 : | |||
| 247 : | //static | ||
| 248 : | void LLPanelLandInfo::onClickRelease(void*) | ||
| 249 : | { | ||
| 250 : | LLViewerParcelMgr::getInstance()->startReleaseLand(); | ||
| 251 : | } | ||
| 252 : | |||
| 253 : | // static | ||
| 254 : | void LLPanelLandInfo::onClickDivide(void*) | ||
| 255 : | { | ||
| 256 : | LLViewerParcelMgr::getInstance()->startDivideLand(); | ||
| 257 : | } | ||
| 258 : | |||
| 259 : | // static | ||
| 260 : | void LLPanelLandInfo::onClickJoin(void*) | ||
| 261 : | { | ||
| 262 : | LLViewerParcelMgr::getInstance()->startJoinLand(); | ||
| 263 : | } | ||
| 264 : | |||
| 265 : | //static | ||
| 266 : | void LLPanelLandInfo::onClickAbout(void*) | ||
| 267 : | { | ||
| 268 : | // Promote the rectangle selection to a parcel selection | ||
| 269 : | if (!LLViewerParcelMgr::getInstance()->getParcelSelection()->getWholeParcelSelected()) | ||
| 270 : | { | ||
| 271 : | LLViewerParcelMgr::getInstance()->selectParcelInRectangle(); | ||
| 272 : | } | ||
| 273 : | |||
| 274 : | //MK | ||
| 275 : | if (gRRenabled && gAgent.mRRInterface.mContainsShowloc) | ||
| 276 : | { | ||
| 277 : | return; | ||
| 278 : | } | ||
| 279 : | //mk | ||
| 280 : | LLFloaterLand::showInstance(); | ||
| 281 : | } | ||
| 282 : | |||
| 283 : | void LLPanelLandInfo::onShowOwnersHelp(void* user_data) | ||
| 284 : | { | ||
| 285 : | LLNotifications::instance().add("ShowOwnersHelp"); | ||
| 286 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

