Annotation of /linden_release/linden/indra/llinventory/llinventorytype.cpp
Parent Directory
|
Revision Log
Revision 57 - (view) (download)
| 1 : | mjm | 57 | /** |
| 2 : | * @file llinventorytype.cpp | ||
| 3 : | * @brief Inventory item type, more specific than an asset type. | ||
| 4 : | * | ||
| 5 : | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
| 6 : | * | ||
| 7 : | * Copyright (c) 2001-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 21 : | * | ||
| 22 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 23 : | * that you have read and understood your obligations described above, | ||
| 24 : | * and agree to abide by those obligations. | ||
| 25 : | * | ||
| 26 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 27 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 28 : | * COMPLETENESS OR PERFORMANCE. | ||
| 29 : | * $/LicenseInfo$ | ||
| 30 : | */ | ||
| 31 : | |||
| 32 : | #include "linden_common.h" | ||
| 33 : | |||
| 34 : | #include "llinventorytype.h" | ||
| 35 : | |||
| 36 : | ///---------------------------------------------------------------------------- | ||
| 37 : | /// Class LLInventoryType | ||
| 38 : | ///---------------------------------------------------------------------------- | ||
| 39 : | |||
| 40 : | // Unlike asset type names, not limited to 8 characters. | ||
| 41 : | // Need not match asset type names. | ||
| 42 : | static const char* INVENTORY_TYPE_NAMES[LLInventoryType::IT_COUNT] = | ||
| 43 : | { | ||
| 44 : | "texture", // 0 | ||
| 45 : | "sound", | ||
| 46 : | "callcard", | ||
| 47 : | "landmark", | ||
| 48 : | NULL, | ||
| 49 : | NULL, // 5 | ||
| 50 : | "object", | ||
| 51 : | "notecard", | ||
| 52 : | "category", | ||
| 53 : | "root", | ||
| 54 : | "script", // 10 | ||
| 55 : | NULL, | ||
| 56 : | NULL, | ||
| 57 : | NULL, | ||
| 58 : | NULL, | ||
| 59 : | "snapshot", // 15 | ||
| 60 : | NULL, | ||
| 61 : | "attach", | ||
| 62 : | "wearable", | ||
| 63 : | "animation", | ||
| 64 : | "gesture", // 20 | ||
| 65 : | }; | ||
| 66 : | |||
| 67 : | // This table is meant for decoding to human readable form. Put any | ||
| 68 : | // and as many printable characters you want in each one. | ||
| 69 : | // See also LLAssetType::mAssetTypeHumanNames | ||
| 70 : | static const char* INVENTORY_TYPE_HUMAN_NAMES[LLInventoryType::IT_COUNT] = | ||
| 71 : | { | ||
| 72 : | "texture", // 0 | ||
| 73 : | "sound", | ||
| 74 : | "calling card", | ||
| 75 : | "landmark", | ||
| 76 : | NULL, | ||
| 77 : | NULL, // 5 | ||
| 78 : | "object", | ||
| 79 : | "note card", | ||
| 80 : | "folder", | ||
| 81 : | "root", | ||
| 82 : | "script", // 10 | ||
| 83 : | NULL, | ||
| 84 : | NULL, | ||
| 85 : | NULL, | ||
| 86 : | NULL, | ||
| 87 : | "snapshot", // 15 | ||
| 88 : | NULL, | ||
| 89 : | "attachment", | ||
| 90 : | "wearable", | ||
| 91 : | "animation", | ||
| 92 : | "gesture", // 20 | ||
| 93 : | }; | ||
| 94 : | |||
| 95 : | // Maps asset types to the default inventory type for that kind of asset. | ||
| 96 : | // Thus, "Lost and Found" is a "Category" | ||
| 97 : | static const LLInventoryType::EType | ||
| 98 : | DEFAULT_ASSET_FOR_INV_TYPE[LLAssetType::AT_COUNT] = | ||
| 99 : | { | ||
| 100 : | LLInventoryType::IT_TEXTURE, // AT_TEXTURE | ||
| 101 : | LLInventoryType::IT_SOUND, // AT_SOUND | ||
| 102 : | LLInventoryType::IT_CALLINGCARD, // AT_CALLINGCARD | ||
| 103 : | LLInventoryType::IT_LANDMARK, // AT_LANDMARK | ||
| 104 : | LLInventoryType::IT_LSL, // AT_SCRIPT | ||
| 105 : | LLInventoryType::IT_WEARABLE, // AT_CLOTHING | ||
| 106 : | LLInventoryType::IT_OBJECT, // AT_OBJECT | ||
| 107 : | LLInventoryType::IT_NOTECARD, // AT_NOTECARD | ||
| 108 : | LLInventoryType::IT_CATEGORY, // AT_CATEGORY | ||
| 109 : | LLInventoryType::IT_ROOT_CATEGORY, // AT_ROOT_CATEGORY | ||
| 110 : | LLInventoryType::IT_LSL, // AT_LSL_TEXT | ||
| 111 : | LLInventoryType::IT_LSL, // AT_LSL_BYTECODE | ||
| 112 : | LLInventoryType::IT_TEXTURE, // AT_TEXTURE_TGA | ||
| 113 : | LLInventoryType::IT_WEARABLE, // AT_BODYPART | ||
| 114 : | LLInventoryType::IT_CATEGORY, // AT_TRASH | ||
| 115 : | LLInventoryType::IT_CATEGORY, // AT_SNAPSHOT_CATEGORY | ||
| 116 : | LLInventoryType::IT_CATEGORY, // AT_LOST_AND_FOUND | ||
| 117 : | LLInventoryType::IT_SOUND, // AT_SOUND_WAV | ||
| 118 : | LLInventoryType::IT_NONE, // AT_IMAGE_TGA | ||
| 119 : | LLInventoryType::IT_NONE, // AT_IMAGE_JPEG | ||
| 120 : | LLInventoryType::IT_ANIMATION, // AT_ANIMATION | ||
| 121 : | LLInventoryType::IT_GESTURE, // AT_GESTURE | ||
| 122 : | }; | ||
| 123 : | |||
| 124 : | static const int MAX_POSSIBLE_ASSET_TYPES = 2; | ||
| 125 : | static const LLAssetType::EType | ||
| 126 : | INVENTORY_TO_ASSET_TYPE[LLInventoryType::IT_COUNT][MAX_POSSIBLE_ASSET_TYPES] = | ||
| 127 : | { | ||
| 128 : | { LLAssetType::AT_TEXTURE, LLAssetType::AT_NONE }, // IT_TEXTURE | ||
| 129 : | { LLAssetType::AT_SOUND, LLAssetType::AT_NONE }, // IT_SOUND | ||
| 130 : | { LLAssetType::AT_CALLINGCARD, LLAssetType::AT_NONE }, // IT_CALLINGCARD | ||
| 131 : | { LLAssetType::AT_LANDMARK, LLAssetType::AT_NONE }, // IT_LANDMARK | ||
| 132 : | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, | ||
| 133 : | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, | ||
| 134 : | { LLAssetType::AT_OBJECT, LLAssetType::AT_NONE }, // IT_OBJECT | ||
| 135 : | { LLAssetType::AT_NOTECARD, LLAssetType::AT_NONE }, // IT_NOTECARD | ||
| 136 : | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, // IT_CATEGORY | ||
| 137 : | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, // IT_ROOT_CATEGORY | ||
| 138 : | { LLAssetType::AT_LSL_TEXT, LLAssetType::AT_LSL_BYTECODE }, // IT_LSL | ||
| 139 : | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, | ||
| 140 : | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, | ||
| 141 : | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, | ||
| 142 : | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, | ||
| 143 : | { LLAssetType::AT_TEXTURE, LLAssetType::AT_NONE }, // IT_SNAPSHOT | ||
| 144 : | { LLAssetType::AT_NONE, LLAssetType::AT_NONE }, | ||
| 145 : | { LLAssetType::AT_OBJECT, LLAssetType::AT_NONE }, // IT_ATTACHMENT | ||
| 146 : | { LLAssetType::AT_CLOTHING, LLAssetType::AT_BODYPART }, // IT_WEARABLE | ||
| 147 : | { LLAssetType::AT_ANIMATION, LLAssetType::AT_NONE }, // IT_ANIMATION | ||
| 148 : | { LLAssetType::AT_GESTURE, LLAssetType::AT_NONE }, // IT_GESTURE | ||
| 149 : | }; | ||
| 150 : | |||
| 151 : | // static | ||
| 152 : | const char* LLInventoryType::lookup(EType type) | ||
| 153 : | { | ||
| 154 : | if((type >= 0) && (type < IT_COUNT)) | ||
| 155 : | { | ||
| 156 : | return INVENTORY_TYPE_NAMES[S32(type)]; | ||
| 157 : | } | ||
| 158 : | else | ||
| 159 : | { | ||
| 160 : | return NULL; | ||
| 161 : | } | ||
| 162 : | } | ||
| 163 : | |||
| 164 : | // static | ||
| 165 : | LLInventoryType::EType LLInventoryType::lookup(const std::string& name) | ||
| 166 : | { | ||
| 167 : | for(S32 i = 0; i < IT_COUNT; ++i) | ||
| 168 : | { | ||
| 169 : | if((INVENTORY_TYPE_NAMES[i]) | ||
| 170 : | && (name == INVENTORY_TYPE_NAMES[i])) | ||
| 171 : | { | ||
| 172 : | // match | ||
| 173 : | return (EType)i; | ||
| 174 : | } | ||
| 175 : | } | ||
| 176 : | return IT_NONE; | ||
| 177 : | } | ||
| 178 : | |||
| 179 : | // XUI:translate | ||
| 180 : | // translation from a type to a human readable form. | ||
| 181 : | // static | ||
| 182 : | const char* LLInventoryType::lookupHumanReadable(EType type) | ||
| 183 : | { | ||
| 184 : | if((type >= 0) && (type < IT_COUNT)) | ||
| 185 : | { | ||
| 186 : | return INVENTORY_TYPE_HUMAN_NAMES[S32(type)]; | ||
| 187 : | } | ||
| 188 : | else | ||
| 189 : | { | ||
| 190 : | return NULL; | ||
| 191 : | } | ||
| 192 : | } | ||
| 193 : | |||
| 194 : | // return the default inventory for the given asset type. | ||
| 195 : | // static | ||
| 196 : | LLInventoryType::EType LLInventoryType::defaultForAssetType(LLAssetType::EType asset_type) | ||
| 197 : | { | ||
| 198 : | if((asset_type >= 0) && (asset_type < LLAssetType::AT_COUNT)) | ||
| 199 : | { | ||
| 200 : | return DEFAULT_ASSET_FOR_INV_TYPE[S32(asset_type)]; | ||
| 201 : | } | ||
| 202 : | else | ||
| 203 : | { | ||
| 204 : | return IT_NONE; | ||
| 205 : | } | ||
| 206 : | } | ||
| 207 : | |||
| 208 : | bool inventory_and_asset_types_match( | ||
| 209 : | LLInventoryType::EType inventory_type, | ||
| 210 : | LLAssetType::EType asset_type) | ||
| 211 : | { | ||
| 212 : | bool rv = false; | ||
| 213 : | if((inventory_type >= 0) && (inventory_type < LLInventoryType::IT_COUNT)) | ||
| 214 : | { | ||
| 215 : | for(S32 i = 0; i < MAX_POSSIBLE_ASSET_TYPES; ++i) | ||
| 216 : | { | ||
| 217 : | if(INVENTORY_TO_ASSET_TYPE[inventory_type][i] == asset_type) | ||
| 218 : | { | ||
| 219 : | rv = true; | ||
| 220 : | break; | ||
| 221 : | } | ||
| 222 : | } | ||
| 223 : | } | ||
| 224 : | return rv; | ||
| 225 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

