PageRenderTime 31ms CodeModel.GetById 14ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llwearabletype.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 159 lines | 110 code | 16 blank | 33 comment | 7 complexity | 3e9242878f2be2110a265af3f29f6628 MD5 | raw file
  1/** 
  2 * @file llwearabletype.cpp
  3 * @brief LLWearableType class implementation
  4 *
  5 * $LicenseInfo:firstyear=2002&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
 27#include "llviewerprecompiledheaders.h"
 28#include "llwearabletype.h"
 29#include "llinventoryfunctions.h"
 30#include "lltrans.h"
 31
 32struct WearableEntry : public LLDictionaryEntry
 33{
 34	WearableEntry(const std::string &name,
 35				  const std::string& default_new_name,
 36				  LLAssetType::EType assetType,
 37				  LLInventoryIcon::EIconName iconName,
 38				  BOOL disable_camera_switch = FALSE,
 39				  BOOL allow_multiwear = TRUE) :
 40		LLDictionaryEntry(name),
 41		mAssetType(assetType),
 42		mDefaultNewName(default_new_name),
 43		mLabel(LLTrans::getString(name)),
 44		mIconName(iconName),
 45		mDisableCameraSwitch(disable_camera_switch),
 46		mAllowMultiwear(allow_multiwear)
 47	{
 48		
 49	}
 50	const LLAssetType::EType mAssetType;
 51	const std::string mLabel;
 52	const std::string mDefaultNewName; //keep mLabel for backward compatibility
 53	LLInventoryIcon::EIconName mIconName;
 54	BOOL mDisableCameraSwitch;
 55	BOOL mAllowMultiwear;
 56};
 57
 58class LLWearableDictionary : public LLSingleton<LLWearableDictionary>,
 59							 public LLDictionary<LLWearableType::EType, WearableEntry>
 60{
 61public:
 62	LLWearableDictionary();
 63};
 64
 65LLWearableDictionary::LLWearableDictionary()
 66{
 67	addEntry(LLWearableType::WT_SHAPE,        new WearableEntry("shape",       "New Shape",			LLAssetType::AT_BODYPART, 	LLInventoryIcon::ICONNAME_BODYPART_SHAPE, FALSE, FALSE));
 68	addEntry(LLWearableType::WT_SKIN,         new WearableEntry("skin",        "New Skin",			LLAssetType::AT_BODYPART, 	LLInventoryIcon::ICONNAME_BODYPART_SKIN, FALSE, FALSE));
 69	addEntry(LLWearableType::WT_HAIR,         new WearableEntry("hair",        "New Hair",			LLAssetType::AT_BODYPART, 	LLInventoryIcon::ICONNAME_BODYPART_HAIR, FALSE, FALSE));
 70	addEntry(LLWearableType::WT_EYES,         new WearableEntry("eyes",        "New Eyes",			LLAssetType::AT_BODYPART, 	LLInventoryIcon::ICONNAME_BODYPART_EYES, FALSE, FALSE));
 71	addEntry(LLWearableType::WT_SHIRT,        new WearableEntry("shirt",       "New Shirt",			LLAssetType::AT_CLOTHING, 	LLInventoryIcon::ICONNAME_CLOTHING_SHIRT, FALSE, TRUE));
 72	addEntry(LLWearableType::WT_PANTS,        new WearableEntry("pants",       "New Pants",			LLAssetType::AT_CLOTHING, 	LLInventoryIcon::ICONNAME_CLOTHING_PANTS, FALSE, TRUE));
 73	addEntry(LLWearableType::WT_SHOES,        new WearableEntry("shoes",       "New Shoes",			LLAssetType::AT_CLOTHING, 	LLInventoryIcon::ICONNAME_CLOTHING_SHOES, FALSE, TRUE));
 74	addEntry(LLWearableType::WT_SOCKS,        new WearableEntry("socks",       "New Socks",			LLAssetType::AT_CLOTHING, 	LLInventoryIcon::ICONNAME_CLOTHING_SOCKS, FALSE, TRUE));
 75	addEntry(LLWearableType::WT_JACKET,       new WearableEntry("jacket",      "New Jacket",		LLAssetType::AT_CLOTHING, 	LLInventoryIcon::ICONNAME_CLOTHING_JACKET, FALSE, TRUE));
 76	addEntry(LLWearableType::WT_GLOVES,       new WearableEntry("gloves",      "New Gloves",		LLAssetType::AT_CLOTHING, 	LLInventoryIcon::ICONNAME_CLOTHING_GLOVES, FALSE, TRUE));
 77	addEntry(LLWearableType::WT_UNDERSHIRT,   new WearableEntry("undershirt",  "New Undershirt",	LLAssetType::AT_CLOTHING, 	LLInventoryIcon::ICONNAME_CLOTHING_UNDERSHIRT, FALSE, TRUE));
 78	addEntry(LLWearableType::WT_UNDERPANTS,   new WearableEntry("underpants",  "New Underpants",	LLAssetType::AT_CLOTHING, 	LLInventoryIcon::ICONNAME_CLOTHING_UNDERPANTS, FALSE, TRUE));
 79	addEntry(LLWearableType::WT_SKIRT,        new WearableEntry("skirt",       "New Skirt",			LLAssetType::AT_CLOTHING, 	LLInventoryIcon::ICONNAME_CLOTHING_SKIRT, FALSE, TRUE));
 80	addEntry(LLWearableType::WT_ALPHA,        new WearableEntry("alpha",       "New Alpha",			LLAssetType::AT_CLOTHING, 	LLInventoryIcon::ICONNAME_CLOTHING_ALPHA, FALSE, TRUE));
 81	addEntry(LLWearableType::WT_TATTOO,       new WearableEntry("tattoo",      "New Tattoo",		LLAssetType::AT_CLOTHING, 	LLInventoryIcon::ICONNAME_CLOTHING_TATTOO, FALSE, TRUE));
 82
 83	addEntry(LLWearableType::WT_PHYSICS,      new WearableEntry("physics",     "New Physics",		LLAssetType::AT_CLOTHING, 	LLInventoryIcon::ICONNAME_CLOTHING_PHYSICS, TRUE, TRUE));
 84
 85	addEntry(LLWearableType::WT_INVALID,      new WearableEntry("invalid",     "Invalid Wearable", 	LLAssetType::AT_NONE, 		LLInventoryIcon::ICONNAME_NONE, FALSE, FALSE));
 86	addEntry(LLWearableType::WT_NONE,      	  new WearableEntry("none",        "Invalid Wearable", 	LLAssetType::AT_NONE, 		LLInventoryIcon::ICONNAME_NONE, FALSE, FALSE));
 87}
 88
 89// static
 90LLWearableType::EType LLWearableType::typeNameToType(const std::string& type_name)
 91{
 92	const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
 93	const LLWearableType::EType wearable = dict->lookup(type_name);
 94	return wearable;
 95}
 96
 97// static 
 98const std::string& LLWearableType::getTypeName(LLWearableType::EType type)
 99{ 
100	const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
101	const WearableEntry *entry = dict->lookup(type);
102	if (!entry) return getTypeName(WT_INVALID);
103	return entry->mName;
104}
105
106//static 
107const std::string& LLWearableType::getTypeDefaultNewName(LLWearableType::EType type)
108{ 
109	const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
110	const WearableEntry *entry = dict->lookup(type);
111	if (!entry) return getTypeDefaultNewName(WT_INVALID);
112	return entry->mDefaultNewName;
113}
114
115// static 
116const std::string& LLWearableType::getTypeLabel(LLWearableType::EType type)
117{ 
118	const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
119	const WearableEntry *entry = dict->lookup(type);
120	if (!entry) return getTypeLabel(WT_INVALID);
121	return entry->mLabel;
122}
123
124// static 
125LLAssetType::EType LLWearableType::getAssetType(LLWearableType::EType type)
126{
127	const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
128	const WearableEntry *entry = dict->lookup(type);
129	if (!entry) return getAssetType(WT_INVALID);
130	return entry->mAssetType;
131}
132
133// static 
134LLInventoryIcon::EIconName LLWearableType::getIconName(LLWearableType::EType type)
135{
136	const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
137	const WearableEntry *entry = dict->lookup(type);
138	if (!entry) return getIconName(WT_INVALID);
139	return entry->mIconName;
140} 
141
142// static 
143BOOL LLWearableType::getDisableCameraSwitch(LLWearableType::EType type)
144{
145	const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
146	const WearableEntry *entry = dict->lookup(type);
147	if (!entry) return FALSE;
148	return entry->mDisableCameraSwitch;
149}
150
151// static 
152BOOL LLWearableType::getAllowMultiwear(LLWearableType::EType type)
153{
154	const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
155	const WearableEntry *entry = dict->lookup(type);
156	if (!entry) return FALSE;
157	return entry->mAllowMultiwear;
158}
159