PageRenderTime 15ms CodeModel.GetById 1ms app.highlight 10ms 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
  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 
 28#include "llviewerprecompiledheaders.h"
 29
 30#include "llsd.h"
 31#include "mean_collision_data.h"
 32
 33#include "llfloaterbump.h"
 34#include "llscrolllistctrl.h"
 35#include "lluictrlfactory.h"
 36#include "llviewermessage.h"
 37
 38///----------------------------------------------------------------------------
 39/// Class LLFloaterBump
 40///----------------------------------------------------------------------------
 41
 42// Default constructor
 43LLFloaterBump::LLFloaterBump(const LLSD& key) 
 44:	LLFloater(key)
 45{
 46}
 47
 48
 49// Destroys the object
 50LLFloaterBump::~LLFloaterBump()
 51{
 52}
 53
 54// virtual
 55void LLFloaterBump::onOpen(const LLSD& key)
 56{
 57	LLScrollListCtrl* list = getChild<LLScrollListCtrl>("bump_list");
 58	if (!list)
 59		return;
 60	list->deleteAllItems();
 61
 62	if (gMeanCollisionList.empty())
 63	{
 64		std::string none_detected = getString("none_detected");
 65		LLSD row;
 66		row["columns"][0]["value"] = none_detected;
 67		row["columns"][0]["font"] = "SansSerifBold";
 68		list->addElement(row);
 69	}
 70	else
 71	{
 72		for (mean_collision_list_t::iterator iter = gMeanCollisionList.begin();
 73			 iter != gMeanCollisionList.end(); ++iter)
 74		{
 75			LLMeanCollisionData *mcd = *iter;
 76			add(list, mcd);
 77		}
 78	}
 79}
 80
 81void LLFloaterBump::add(LLScrollListCtrl* list, LLMeanCollisionData* mcd)
 82{
 83	if (mcd->mFullName.empty() || list->getItemCount() >= 20)
 84	{
 85		return;
 86	}
 87
 88	std::string timeStr = getString ("timeStr");
 89	LLSD substitution;
 90
 91	substitution["datetime"] = (S32) mcd->mTime;
 92	LLStringUtil::format (timeStr, substitution);
 93
 94	std::string action;
 95	switch(mcd->mType)
 96	{
 97	case MEAN_BUMP:
 98		action = "bump";
 99		break;
100	case MEAN_LLPUSHOBJECT:
101		action = "llpushobject";
102		break;
103	case MEAN_SELECTED_OBJECT_COLLIDE:
104		action = "selected_object_collide";
105		break;
106	case MEAN_SCRIPTED_OBJECT_COLLIDE:
107		action = "scripted_object_collide";
108		break;
109	case MEAN_PHYSICAL_OBJECT_COLLIDE:
110		action = "physical_object_collide";
111		break;
112	default:
113		llinfos << "LLFloaterBump::add unknown mean collision type "
114			<< mcd->mType << llendl;
115		return;
116	}
117
118	// All above action strings are in XML file
119	LLUIString text = getString(action);
120	text.setArg("[TIME]", timeStr);
121	text.setArg("[NAME]", mcd->mFullName);
122
123	LLSD row;
124	row["id"] = mcd->mPerp;
125	row["columns"][0]["value"] = text;
126	row["columns"][0]["font"] = "SansSerifBold";
127	list->addElement(row);
128}