/indra/newview/llfloaterinventory.cpp

https://bitbucket.org/lindenlab/viewer-beta/ · C++ · 109 lines · 63 code · 13 blank · 33 comment · 6 complexity · 9a9610c26aca5fd4594c02fee1c5db89 MD5 · raw file

  1. /**
  2. * @file llfloaterinventory.cpp
  3. * @brief Implementation of the inventory view and associated stuff.
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llfloaterinventory.h"
  28. #include "llagentcamera.h"
  29. //#include "llfirstuse.h"
  30. #include "llfloaterreg.h"
  31. #include "llinventorymodel.h"
  32. #include "llpanelmaininventory.h"
  33. #include "llresmgr.h"
  34. #include "llviewerfoldertype.h"
  35. #include "lltransientfloatermgr.h"
  36. ///----------------------------------------------------------------------------
  37. /// LLFloaterInventory
  38. ///----------------------------------------------------------------------------
  39. LLFloaterInventory::LLFloaterInventory(const LLSD& key)
  40. : LLFloater(key)
  41. {
  42. LLTransientFloaterMgr::getInstance()->addControlView(this);
  43. }
  44. LLFloaterInventory::~LLFloaterInventory()
  45. {
  46. LLTransientFloaterMgr::getInstance()->removeControlView(this);
  47. }
  48. BOOL LLFloaterInventory::postBuild()
  49. {
  50. mPanelMainInventory = findChild<LLPanelMainInventory>("Inventory Panel");
  51. return TRUE;
  52. }
  53. LLInventoryPanel* LLFloaterInventory::getPanel()
  54. {
  55. if (mPanelMainInventory)
  56. return mPanelMainInventory->getPanel();
  57. return NULL;
  58. }
  59. // static
  60. LLFloaterInventory* LLFloaterInventory::showAgentInventory()
  61. {
  62. // Hack to generate semi-unique key for each inventory floater.
  63. static S32 instance_num = 0;
  64. instance_num = (instance_num + 1) % S32_MAX;
  65. LLFloaterInventory* iv = NULL;
  66. if (!gAgentCamera.cameraMouselook())
  67. {
  68. iv = LLFloaterReg::showTypedInstance<LLFloaterInventory>("inventory", LLSD(instance_num));
  69. }
  70. return iv;
  71. }
  72. // static
  73. void LLFloaterInventory::cleanup()
  74. {
  75. LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("inventory");
  76. for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin(); iter != inst_list.end();)
  77. {
  78. LLFloaterInventory* iv = dynamic_cast<LLFloaterInventory*>(*iter++);
  79. if (iv)
  80. {
  81. iv->destroy();
  82. }
  83. }
  84. }
  85. void LLFloaterInventory::onOpen(const LLSD& key)
  86. {
  87. //LLFirstUse::useInventory();
  88. }
  89. void LLFloaterInventory::onClose(bool app_quitting)
  90. {
  91. LLFloater::onClose(app_quitting);
  92. if (mKey.asInteger() > 1)
  93. {
  94. destroy();
  95. }
  96. }