llpanelland.cpp 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /**
  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. * Copyright (c) 2002-2009, Linden Research, Inc.
  8. *
  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. #include "llviewerprecompiledheaders.h"
  33. #include "llpanelland.h"
  34. #include "llbutton.h"
  35. #include "llparcel.h"
  36. #include "lltextbox.h"
  37. #include "lluictrlfactory.h"
  38. #include "roles_constants.h"
  39. #include "llagent.h"
  40. #include "llfloaterland.h"
  41. //MK
  42. #include "mkrlinterface.h"
  43. //mk
  44. #include "llviewercontrol.h"
  45. #include "llviewerparcelmgr.h"
  46. #include "llviewerregion.h"
  47. LLPanelLandSelectObserver* LLPanelLandInfo::sObserver = NULL;
  48. LLPanelLandInfo* LLPanelLandInfo::sInstance = NULL;
  49. class LLPanelLandSelectObserver final : public LLParcelSelectionObserver
  50. {
  51. public:
  52. LLPanelLandSelectObserver() {}
  53. ~LLPanelLandSelectObserver() override {}
  54. void changed() override
  55. {
  56. LLPanelLandInfo::refreshAll();
  57. }
  58. };
  59. LLPanelLandInfo::LLPanelLandInfo(const std::string& name)
  60. : LLPanel(name)
  61. {
  62. if (!sInstance)
  63. {
  64. sInstance = this;
  65. }
  66. if (!sObserver)
  67. {
  68. sObserver = new LLPanelLandSelectObserver();
  69. gViewerParcelMgr.addSelectionObserver(sObserver);
  70. }
  71. }
  72. //virtual
  73. LLPanelLandInfo::~LLPanelLandInfo()
  74. {
  75. gViewerParcelMgr.removeSelectionObserver(sObserver);
  76. delete sObserver;
  77. sObserver = NULL;
  78. sInstance = NULL;
  79. }
  80. //virtual
  81. bool LLPanelLandInfo::postBuild()
  82. {
  83. mBtnBuyLand = getChild<LLButton>("button buy land");
  84. mBtnBuyLand->setClickedCallback(onClickClaim, this);
  85. mBtnAbandonLand = getChild<LLButton>("button abandon land");
  86. mBtnAbandonLand->setClickedCallback(onClickRelease, this);
  87. mBtnDivideLand = getChild<LLButton>("button subdivide land");
  88. mBtnDivideLand->setClickedCallback(onClickDivide, this);
  89. mBtnJoinLand = getChild<LLButton>("button join land");
  90. mBtnJoinLand->setClickedCallback(onClickJoin, this);
  91. mBtnAboutLand = getChild<LLButton>("button about land");
  92. mBtnAboutLand->setClickedCallback(onClickAbout, this);
  93. childSetAction("button show owners help", onShowOwnersHelp, this);
  94. mTextLabelPrice = getChild<LLTextBox>("label_area_price");
  95. mTextPrice = getChild<LLTextBox>("label_area");
  96. return true;
  97. }
  98. //virtual
  99. void LLPanelLandInfo::refresh()
  100. {
  101. LLParcel* parcel = gViewerParcelMgr.getParcelSelection()->getParcel();
  102. LLViewerRegion* regionp = gViewerParcelMgr.getSelectionRegion();
  103. if (!parcel || !regionp)
  104. {
  105. // nothing selected, disable panel
  106. mTextLabelPrice->setVisible(false);
  107. mTextPrice->setVisible(false);
  108. mBtnBuyLand->setEnabled(false);
  109. mBtnAbandonLand->setEnabled(false);
  110. mBtnDivideLand->setEnabled(false);
  111. mBtnJoinLand->setEnabled(false);
  112. mBtnAboutLand->setEnabled(false);
  113. }
  114. else
  115. {
  116. // something selected, hooray!
  117. const LLUUID& owner_id = parcel->getOwnerID();
  118. const LLUUID& auth_buyer_id = parcel->getAuthorizedBuyerID();
  119. bool is_public = parcel->isPublic();
  120. bool is_for_sale = parcel->getForSale() &&
  121. (parcel->getSalePrice() > 0 ||
  122. auth_buyer_id.notNull());
  123. bool can_buy = is_for_sale && owner_id != gAgentID &&
  124. (auth_buyer_id == gAgentID || auth_buyer_id.isNull());
  125. if (is_public)
  126. {
  127. mBtnBuyLand->setEnabled(true);
  128. }
  129. else
  130. {
  131. mBtnBuyLand->setEnabled(can_buy);
  132. }
  133. bool owner_release =
  134. LLViewerParcelMgr::isParcelOwnedByAgent(parcel, GP_LAND_RELEASE);
  135. bool owner_divide =
  136. LLViewerParcelMgr::isParcelOwnedByAgent(parcel,
  137. GP_LAND_DIVIDE_JOIN);
  138. bool manager_releaseable = gAgent.canManageEstate() &&
  139. parcel->getOwnerID() == regionp->getOwner();
  140. bool manager_divideable =
  141. gAgent.canManageEstate() &&
  142. (parcel->getOwnerID() == regionp->getOwner() || owner_divide);
  143. mBtnAbandonLand->setEnabled(owner_release || manager_releaseable ||
  144. gAgent.isGodlike());
  145. // Only mainland sims are subdividable by owner
  146. if (regionp->getRegionFlag(REGION_FLAGS_ALLOW_PARCEL_CHANGES))
  147. {
  148. mBtnDivideLand->setEnabled(owner_divide || manager_divideable ||
  149. gAgent.isGodlike());
  150. }
  151. else
  152. {
  153. mBtnDivideLand->setEnabled(manager_divideable ||
  154. gAgent.isGodlike());
  155. }
  156. // To join land, must have something selected, not just a single unit
  157. // of land, you must own part of it and it must not be a whole parcel.
  158. if (gViewerParcelMgr.getSelectedArea() > PARCEL_UNIT_AREA &&
  159. #if 0
  160. gViewerParcelMgr.getSelfCount() > 1 &&
  161. #endif
  162. !gViewerParcelMgr.getParcelSelection()->getWholeParcelSelected())
  163. {
  164. mBtnJoinLand->setEnabled(true);
  165. }
  166. else
  167. {
  168. LL_DEBUGS("Land") << "Invalid selection for joining land"
  169. << LL_ENDL;
  170. mBtnJoinLand->setEnabled(false);
  171. }
  172. mBtnAboutLand->setEnabled(true);
  173. // show pricing information
  174. S32 area;
  175. S32 claim_price;
  176. S32 rent_price;
  177. bool for_sale;
  178. F32 dwell;
  179. gViewerParcelMgr.getDisplayInfo(&area, &claim_price, &rent_price,
  180. &for_sale, &dwell);
  181. if (is_public ||
  182. (is_for_sale &&
  183. gViewerParcelMgr.getParcelSelection()->getWholeParcelSelected()))
  184. {
  185. mTextLabelPrice->setTextArg("[PRICE]",
  186. llformat("%d", claim_price));
  187. mTextLabelPrice->setTextArg("[AREA]", llformat("%d", area));
  188. mTextLabelPrice->setVisible(true);
  189. mTextPrice->setVisible(false);
  190. }
  191. else
  192. {
  193. mTextLabelPrice->setVisible(false);
  194. mTextPrice->setTextArg("[AREA]", llformat("%d", area));
  195. mTextPrice->setVisible(true);
  196. }
  197. }
  198. }
  199. // static
  200. void LLPanelLandInfo::refreshAll()
  201. {
  202. if (sInstance)
  203. {
  204. sInstance->refresh();
  205. }
  206. }
  207. //static
  208. void LLPanelLandInfo::onClickClaim(void*)
  209. {
  210. //MK
  211. if (gRLenabled && gRLInterface.mContainsShowloc)
  212. {
  213. return;
  214. }
  215. //mk
  216. gViewerParcelMgr.startBuyLand();
  217. }
  218. //static
  219. void LLPanelLandInfo::onClickRelease(void*)
  220. {
  221. gViewerParcelMgr.startReleaseLand();
  222. }
  223. // static
  224. void LLPanelLandInfo::onClickDivide(void*)
  225. {
  226. gViewerParcelMgr.startDivideLand();
  227. }
  228. // static
  229. void LLPanelLandInfo::onClickJoin(void*)
  230. {
  231. gViewerParcelMgr.startJoinLand();
  232. }
  233. //static
  234. void LLPanelLandInfo::onClickAbout(void*)
  235. {
  236. // Promote the rectangle selection to a parcel selection
  237. if (!gViewerParcelMgr.getParcelSelection()->getWholeParcelSelected())
  238. {
  239. gViewerParcelMgr.selectParcelInRectangle();
  240. }
  241. //MK
  242. if (gRLenabled && gRLInterface.mContainsShowloc)
  243. {
  244. return;
  245. }
  246. //mk
  247. LLFloaterLand::showInstance();
  248. }
  249. void LLPanelLandInfo::onShowOwnersHelp(void*)
  250. {
  251. gNotifications.add("ShowOwnersHelp");
  252. }