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