PageRenderTime 42ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llfloaterbump.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 128 lines | 80 code | 15 blank | 33 comment | 6 complexity | 5e9a82b211b47e2e97f94b1073192f22 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llfloaterbump.cpp
  3. * @brief Floater showing recent bumps, hits with objects, pushes, etc.
  4. * @author Cory Ondrejka, James Cook
  5. *
  6. * $LicenseInfo:firstyear=2003&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #include "llviewerprecompiledheaders.h"
  28. #include "llsd.h"
  29. #include "mean_collision_data.h"
  30. #include "llfloaterbump.h"
  31. #include "llscrolllistctrl.h"
  32. #include "lluictrlfactory.h"
  33. #include "llviewermessage.h"
  34. ///----------------------------------------------------------------------------
  35. /// Class LLFloaterBump
  36. ///----------------------------------------------------------------------------
  37. // Default constructor
  38. LLFloaterBump::LLFloaterBump(const LLSD& key)
  39. : LLFloater(key)
  40. {
  41. }
  42. // Destroys the object
  43. LLFloaterBump::~LLFloaterBump()
  44. {
  45. }
  46. // virtual
  47. void LLFloaterBump::onOpen(const LLSD& key)
  48. {
  49. LLScrollListCtrl* list = getChild<LLScrollListCtrl>("bump_list");
  50. if (!list)
  51. return;
  52. list->deleteAllItems();
  53. if (gMeanCollisionList.empty())
  54. {
  55. std::string none_detected = getString("none_detected");
  56. LLSD row;
  57. row["columns"][0]["value"] = none_detected;
  58. row["columns"][0]["font"] = "SansSerifBold";
  59. list->addElement(row);
  60. }
  61. else
  62. {
  63. for (mean_collision_list_t::iterator iter = gMeanCollisionList.begin();
  64. iter != gMeanCollisionList.end(); ++iter)
  65. {
  66. LLMeanCollisionData *mcd = *iter;
  67. add(list, mcd);
  68. }
  69. }
  70. }
  71. void LLFloaterBump::add(LLScrollListCtrl* list, LLMeanCollisionData* mcd)
  72. {
  73. if (mcd->mFullName.empty() || list->getItemCount() >= 20)
  74. {
  75. return;
  76. }
  77. std::string timeStr = getString ("timeStr");
  78. LLSD substitution;
  79. substitution["datetime"] = (S32) mcd->mTime;
  80. LLStringUtil::format (timeStr, substitution);
  81. std::string action;
  82. switch(mcd->mType)
  83. {
  84. case MEAN_BUMP:
  85. action = "bump";
  86. break;
  87. case MEAN_LLPUSHOBJECT:
  88. action = "llpushobject";
  89. break;
  90. case MEAN_SELECTED_OBJECT_COLLIDE:
  91. action = "selected_object_collide";
  92. break;
  93. case MEAN_SCRIPTED_OBJECT_COLLIDE:
  94. action = "scripted_object_collide";
  95. break;
  96. case MEAN_PHYSICAL_OBJECT_COLLIDE:
  97. action = "physical_object_collide";
  98. break;
  99. default:
  100. llinfos << "LLFloaterBump::add unknown mean collision type "
  101. << mcd->mType << llendl;
  102. return;
  103. }
  104. // All above action strings are in XML file
  105. LLUIString text = getString(action);
  106. text.setArg("[TIME]", timeStr);
  107. text.setArg("[NAME]", mcd->mFullName);
  108. LLSD row;
  109. row["id"] = mcd->mPerp;
  110. row["columns"][0]["value"] = text;
  111. row["columns"][0]["font"] = "SansSerifBold";
  112. list->addElement(row);
  113. }