00001
00032 #include "linden_common.h"
00033
00034 #include "llinventorytype.h"
00035
00039
00040
00041
00042 static const char* INVENTORY_TYPE_NAMES[LLInventoryType::IT_COUNT] =
00043 {
00044 "texture",
00045 "sound",
00046 "callcard",
00047 "landmark",
00048 NULL,
00049 NULL,
00050 "object",
00051 "notecard",
00052 "category",
00053 "root",
00054 "script",
00055 NULL,
00056 NULL,
00057 NULL,
00058 NULL,
00059 "snapshot",
00060 NULL,
00061 "attach",
00062 "wearable",
00063 "animation",
00064 "gesture",
00065 };
00066
00067
00068
00069
00070 static const char* INVENTORY_TYPE_HUMAN_NAMES[LLInventoryType::IT_COUNT] =
00071 {
00072 "texture",
00073 "sound",
00074 "calling card",
00075 "landmark",
00076 NULL,
00077 NULL,
00078 "object",
00079 "note card",
00080 "folder",
00081 "root",
00082 "script",
00083 NULL,
00084 NULL,
00085 NULL,
00086 NULL,
00087 "snapshot",
00088 NULL,
00089 "attachment",
00090 "wearable",
00091 "animation",
00092 "gesture",
00093 };
00094
00095
00096
00097 static const LLInventoryType::EType
00098 DEFAULT_ASSET_FOR_INV_TYPE[LLAssetType::AT_COUNT] =
00099 {
00100 LLInventoryType::IT_TEXTURE,
00101 LLInventoryType::IT_SOUND,
00102 LLInventoryType::IT_CALLINGCARD,
00103 LLInventoryType::IT_LANDMARK,
00104 LLInventoryType::IT_LSL,
00105 LLInventoryType::IT_WEARABLE,
00106 LLInventoryType::IT_OBJECT,
00107 LLInventoryType::IT_NOTECARD,
00108 LLInventoryType::IT_CATEGORY,
00109 LLInventoryType::IT_ROOT_CATEGORY,
00110 LLInventoryType::IT_LSL,
00111 LLInventoryType::IT_LSL,
00112 LLInventoryType::IT_TEXTURE,
00113 LLInventoryType::IT_WEARABLE,
00114 LLInventoryType::IT_CATEGORY,
00115 LLInventoryType::IT_CATEGORY,
00116 LLInventoryType::IT_CATEGORY,
00117 LLInventoryType::IT_SOUND,
00118 LLInventoryType::IT_NONE,
00119 LLInventoryType::IT_NONE,
00120 LLInventoryType::IT_ANIMATION,
00121 LLInventoryType::IT_GESTURE,
00122 };
00123
00124 static const int MAX_POSSIBLE_ASSET_TYPES = 2;
00125 static const LLAssetType::EType
00126 INVENTORY_TO_ASSET_TYPE[LLInventoryType::IT_COUNT][MAX_POSSIBLE_ASSET_TYPES] =
00127 {
00128 { LLAssetType::AT_TEXTURE, LLAssetType::AT_NONE },
00129 { LLAssetType::AT_SOUND, LLAssetType::AT_NONE },
00130 { LLAssetType::AT_CALLINGCARD, LLAssetType::AT_NONE },
00131 { LLAssetType::AT_LANDMARK, LLAssetType::AT_NONE },
00132 { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00133 { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00134 { LLAssetType::AT_OBJECT, LLAssetType::AT_NONE },
00135 { LLAssetType::AT_NOTECARD, LLAssetType::AT_NONE },
00136 { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00137 { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00138 { LLAssetType::AT_LSL_TEXT, LLAssetType::AT_LSL_BYTECODE },
00139 { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00140 { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00141 { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00142 { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00143 { LLAssetType::AT_TEXTURE, LLAssetType::AT_NONE },
00144 { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00145 { LLAssetType::AT_OBJECT, LLAssetType::AT_NONE },
00146 { LLAssetType::AT_CLOTHING, LLAssetType::AT_BODYPART },
00147 { LLAssetType::AT_ANIMATION, LLAssetType::AT_NONE },
00148 { LLAssetType::AT_GESTURE, LLAssetType::AT_NONE },
00149 };
00150
00151
00152 const char* LLInventoryType::lookup(EType type)
00153 {
00154 if((type >= 0) && (type < IT_COUNT))
00155 {
00156 return INVENTORY_TYPE_NAMES[S32(type)];
00157 }
00158 else
00159 {
00160 return NULL;
00161 }
00162 }
00163
00164
00165 LLInventoryType::EType LLInventoryType::lookup(const char* name)
00166 {
00167 for(S32 i = 0; i < IT_COUNT; ++i)
00168 {
00169 if((INVENTORY_TYPE_NAMES[i])
00170 && (0 == strcmp(name, INVENTORY_TYPE_NAMES[i])))
00171 {
00172
00173 return (EType)i;
00174 }
00175 }
00176 return IT_NONE;
00177 }
00178
00179
00180
00181
00182 const char* LLInventoryType::lookupHumanReadable(EType type)
00183 {
00184 if((type >= 0) && (type < IT_COUNT))
00185 {
00186 return INVENTORY_TYPE_HUMAN_NAMES[S32(type)];
00187 }
00188 else
00189 {
00190 return NULL;
00191 }
00192 }
00193
00194
00195
00196 LLInventoryType::EType LLInventoryType::defaultForAssetType(LLAssetType::EType asset_type)
00197 {
00198 if((asset_type >= 0) && (asset_type < LLAssetType::AT_COUNT))
00199 {
00200 return DEFAULT_ASSET_FOR_INV_TYPE[S32(asset_type)];
00201 }
00202 else
00203 {
00204 return IT_NONE;
00205 }
00206 }
00207
00208 bool inventory_and_asset_types_match(
00209 LLInventoryType::EType inventory_type,
00210 LLAssetType::EType asset_type)
00211 {
00212 bool rv = false;
00213 if((inventory_type >= 0) && (inventory_type < LLInventoryType::IT_COUNT))
00214 {
00215 for(S32 i = 0; i < MAX_POSSIBLE_ASSET_TYPES; ++i)
00216 {
00217 if(INVENTORY_TO_ASSET_TYPE[inventory_type][i] == asset_type)
00218 {
00219 rv = true;
00220 break;
00221 }
00222 }
00223 }
00224 return rv;
00225 }