llfloaterminimap.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /**
  2. * @file llfloaterminimap.cpp
  3. * @brief The "mini-map" or radar in the upper right part of the screen.
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-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 "llfloaterminimap.h"
  34. #include "llapp.h"
  35. #include "lldraghandle.h"
  36. #include "lluictrlfactory.h"
  37. #include "llagent.h"
  38. #include "llpanelminimap.h"
  39. //MK
  40. #include "mkrlinterface.h"
  41. //mk
  42. #include "llviewercontrol.h"
  43. //static
  44. void* LLFloaterMiniMap::createPanelMiniMap(void* data)
  45. {
  46. LLFloaterMiniMap* self = (LLFloaterMiniMap*)data;
  47. self->mPanelMiniMap = new LLPanelMiniMap("Mapview");
  48. return self->mPanelMiniMap;
  49. }
  50. LLFloaterMiniMap::LLFloaterMiniMap(const LLSD& key)
  51. : LLFloater("mini map"),
  52. mPanelMiniMap(NULL)
  53. {
  54. LLCallbackMap::map_t factory_map;
  55. factory_map["mini_mapview"] = LLCallbackMap(createPanelMiniMap, this);
  56. LLUICtrlFactory::getInstance()->buildFloater(this, "floater_mini_map.xml",
  57. &factory_map, false);
  58. }
  59. bool LLFloaterMiniMap::postBuild()
  60. {
  61. // Send the drag handle to the back, but make sure close stays on top
  62. sendChildToBack(getDragHandle());
  63. sendChildToFront(getChild<LLButton>("llfloater_close_btn"));
  64. setIsChrome(true);
  65. return true;
  66. }
  67. //virtual
  68. void LLFloaterMiniMap::onOpen()
  69. {
  70. gFloaterViewp->adjustToFitScreen(this);
  71. gSavedSettings.setBool("ShowMiniMap", true);
  72. }
  73. //virtual
  74. void LLFloaterMiniMap::onClose(bool app_quitting)
  75. {
  76. LLFloater::setVisible(false);
  77. if (!app_quitting)
  78. {
  79. gSavedSettings.setBool("ShowMiniMap", false);
  80. }
  81. }
  82. bool LLFloaterMiniMap::canClose()
  83. {
  84. return !LLApp::isExiting();
  85. }
  86. //virtual
  87. void LLFloaterMiniMap::draw()
  88. {
  89. //MK
  90. // Fast enough that it can be kept here
  91. if (gRLenabled && gRLInterface.mContainsShowminimap)
  92. {
  93. close();
  94. return;
  95. }
  96. //mk
  97. if (gAgent.cameraMouselook())
  98. {
  99. setMouseOpaque(false);
  100. getDragHandle()->setMouseOpaque(false);
  101. drawChild(mPanelMiniMap);
  102. }
  103. else
  104. {
  105. setMouseOpaque(true);
  106. getDragHandle()->setMouseOpaque(true);
  107. LLFloater::draw();
  108. }
  109. }