1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 19:29:09 +00:00

Avatar Clothing data => plString

This commit is contained in:
2014-01-10 00:01:53 -08:00
parent 71c9771cfb
commit 7de24157a5
12 changed files with 142 additions and 207 deletions

View File

@ -80,9 +80,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plNetClientComm/plNetClientComm.h"
plClothingItem::plClothingItem() : fName(nil), fGroup(0), fTileset(0), fType(0), fSortOrder(0),
fDescription(nil), fCustomText(nil), fThumbnail(nil),
fAccessory(nil), fAccessoryName(nil)
plClothingItem::plClothingItem() : fGroup(0), fTileset(0), fType(0), fSortOrder(0),
fThumbnail(nil), fAccessory(nil)
{
int i;
fTextures.Reset();
@ -99,16 +98,8 @@ plClothingItem::plClothingItem() : fName(nil), fGroup(0), fTileset(0), fType(0),
plClothingItem::~plClothingItem()
{
while (fElementNames.GetCount() > 0)
delete [] fElementNames.Pop();
while (fTextures.GetCount() > 0)
delete [] fTextures.Pop();
delete [] fName;
delete [] fDescription;
delete [] fCustomText;
delete [] fAccessoryName;
}
bool plClothingItem::CanWearWith(plClothingItem *item)
@ -169,14 +160,14 @@ void plClothingItem::Read(hsStream *s, hsResMgr *mgr)
{
hsKeyedObject::Read(s, mgr);
fName = s->ReadSafeString();
fName = s->ReadSafeString_TEMP();
fGroup = s->ReadByte();
fType = s->ReadByte();
fTileset = s->ReadByte();
fSortOrder = s->ReadByte();
fCustomText = s->ReadSafeString();
fDescription = s->ReadSafeString();
fCustomText = s->ReadSafeString_TEMP();
fDescription = s->ReadSafeString_TEMP();
if (s->ReadBool())
mgr->ReadKeyNotifyMe(s, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef); // thumbnail
@ -184,13 +175,13 @@ void plClothingItem::Read(hsStream *s, hsResMgr *mgr)
int i, j;
for (i = 0; i < tileCount; i++)
{
fElementNames.Append(s->ReadSafeString());
fElementNames.Append(s->ReadSafeString_TEMP());
int layerCount = s->ReadByte();
for (j = 0; j < layerCount; j++)
{
int layer = s->ReadByte();
mgr->ReadKeyNotifyMe(s, new plElementRefMsg(GetKey(), plRefMsg::kOnCreate, i, -1, nil, layer), plRefFlags::kActiveRef); // texture
mgr->ReadKeyNotifyMe(s, new plElementRefMsg(GetKey(), plRefMsg::kOnCreate, i, -1, plString::Null, layer), plRefFlags::kActiveRef); // texture
}
}
@ -274,13 +265,13 @@ void plClothingItem::Write(hsStream *s, hsResMgr *mgr)
// EXPORT ONLY
plKey accessoryKey = nil;
if (fAccessoryName)
if (!fAccessoryName.IsEmpty())
{
plString strBuf = plString::Format("CItm_%s", fAccessoryName);
plString strBuf = plString::Format("CItm_%s", fAccessoryName.c_str());
accessoryKey = plKeyFinder::Instance().StupidSearch("GlobalClothing", "", plClothingItem::Index(), strBuf);
if (accessoryKey == nil)
{
strBuf = plString::Format("Couldn't find accessory \"%s\". It won't show at runtime.", fAccessoryName);
strBuf = plString::Format("Couldn't find accessory \"%s\". It won't show at runtime.", fAccessoryName.c_str());
hsMessageBox(strBuf.c_str(), GetKeyName().c_str(), hsMessageBoxNormal);
}
}
@ -306,10 +297,10 @@ bool plClothingItem::MsgReceive(plMessage* msg)
if (fTextures.GetCount() <= eMsg->fWhich)
fTextures.ExpandAndZero(eMsg->fWhich + 1);
if (fElementNames.GetCount() <= eMsg->fWhich)
fElementNames.ExpandAndZero(eMsg->fWhich + 1);
fElementNames.Expand(eMsg->fWhich + 1);
if (fElementNames.Get(eMsg->fWhich) == nil)
fElementNames.Set(eMsg->fWhich, hsStrcpy(eMsg->fElementName));
if (fElementNames.Get(eMsg->fWhich).IsEmpty())
fElementNames.Set(eMsg->fWhich, eMsg->fElementName);
if (fTextures.Get(eMsg->fWhich) == nil)
{
plMipmap **layers = new plMipmap*[plClothingElement::kLayerMax];
@ -378,22 +369,16 @@ bool plClosetItem::IsMatch(plClosetItem *other)
/////////////////////////////////////////////////////////////////////////////
plClothingBase::plClothingBase() : fName(nil), fBaseTexture(nil), fLayoutName(nil) {}
plClothingBase::~plClothingBase()
{
delete [] fName;
delete [] fLayoutName;
}
plClothingBase::plClothingBase() : fBaseTexture(nil) {}
void plClothingBase::Read(hsStream* s, hsResMgr* mgr)
{
hsKeyedObject::Read(s, mgr);
fName = s->ReadSafeString();
fName = s->ReadSafeString_TEMP();
if (s->ReadBool())
mgr->ReadKeyNotifyMe(s, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef);
fLayoutName = s->ReadSafeString();
fLayoutName = s->ReadSafeString_TEMP();
}
void plClothingBase::Write(hsStream* s, hsResMgr* mgr)
@ -640,7 +625,7 @@ void plClothingOutfit::IAddItem(plClothingItem *item)
if (soundEffect)
{
if (!strcmp(item->fName, "03_MLFoot04_01") || !strcmp(item->fName, "03_FLFoot04_01"))
if (item->fName == "03_MLFoot04_01" || item->fName == "03_FLFoot04_01")
soundEffect->SetFootType(plArmatureEffectFootSound::kFootTypeBare);
else
soundEffect->SetFootType(plArmatureEffectFootSound::kFootTypeShoe);
@ -1438,9 +1423,8 @@ void plClothingOutfit::IInstanceSharedMeshes(plClothingItem *item)
if (fAvatar)
fAvatar->ValidateMesh();
bool partialSort = item->fCustomText && strstr(item->fCustomText, "NeedsSort");
int i;
for (i = 0; i < plClothingItem::kMaxNumLODLevels; i++)
bool partialSort = (item->fCustomText.Find("NeedsSort") >= 0);
for (int i = 0; i < plClothingItem::kMaxNumLODLevels; i++)
{
const plSceneObject *so = fAvatar->GetClothingSO(i);
if (so != nil && item->fMeshes[i] != nil)
@ -1619,23 +1603,21 @@ plClothingMgr::~plClothingMgr()
delete fItems.Pop();
}
plClothingLayout *plClothingMgr::GetLayout(char *name)
plClothingLayout *plClothingMgr::GetLayout(const plString &name) const
{
int i;
for (i = 0; i < fLayouts.GetCount(); i++)
for (int i = 0; i < fLayouts.GetCount(); i++)
{
if (!strcmp(fLayouts.Get(i)->fName, name))
if (fLayouts.Get(i)->fName == name)
return fLayouts.Get(i);
}
return nil;
}
plClothingElement *plClothingMgr::FindElementByName(const char *name)
plClothingElement *plClothingMgr::FindElementByName(const plString &name) const
{
int i;
for (i = 0; i < fElements.GetCount(); i++)
for (int i = 0; i < fElements.GetCount(); i++)
{
if (!strcmp(fElements.Get(i)->fName, name))
if (fElements.Get(i)->fName == name)
return fElements.Get(i);
}
return nil;
@ -1750,16 +1732,15 @@ void plClothingMgr::FilterUniqueMeshes(hsTArray<plClothingItem*> &items)
}
}
plClothingItem *plClothingMgr::FindItemByName(const char *name)
plClothingItem *plClothingMgr::FindItemByName(const plString &name) const
{
if (!name)
if (name.IsEmpty())
return nil;
int i;
for (i = 0; i < fItems.GetCount(); i++)
for (int i = 0; i < fItems.GetCount(); i++)
{
plClothingItem* item = fItems.Get(i);
if (!strcmp(item->fName, name))
if (item->fName == name)
return item;
}
return nil;
@ -1902,7 +1883,7 @@ void plClothingMgr::IAddItem(plClothingItem *item)
{
for (j = 0; j < fElements.GetCount(); j++)
{
if (!strcmp(item->fElementNames.Get(i), fElements.Get(j)->fName))
if (item->fElementNames.Get(i) == fElements.Get(j)->fName)
{
item->fElements.Set(i, fElements.Get(j));
break;
@ -1928,7 +1909,7 @@ void plClothingMgr::IAddItem(plClothingItem *item)
hsAssert(false, "Couldn't match all elements of added clothing item.");
}
void plClothingMgr::ChangeAvatar(const char* name, const plFileName &clothingFile)
void plClothingMgr::ChangeAvatar(const plString& name, const plFileName &clothingFile)
{
plAvatarMgr::GetInstance()->UnLoadLocalPlayer();
plAvatarMgr::GetInstance()->LoadPlayerFromFile(name, "", clothingFile);

View File

@ -85,23 +85,23 @@ public:
// If you change the format of a clothing item, chances are you need
// to change plClothingMgr::IsLRMatch() as well
char *fName;
plString fName;
plSharedMesh *fMeshes[kMaxNumLODLevels];
hsTArray<plMipmap **> fTextures;
hsTArray<char *> fElementNames;
hsTArray<plString> fElementNames;
hsTArray<plClothingElement *> fElements;
uint8_t fGroup; // Each avatar can wear one of the available groups
uint8_t fType; // Each group has multiple types of clothes (shirt/pants/etc)
uint8_t fTileset;
uint8_t fSortOrder;
char *fDescription;
char *fCustomText;
plString fDescription;
plString fCustomText;
plMipmap *fThumbnail;
plClothingItem *fAccessory; // Forced accessory to always wear with this item.
uint8_t fDefaultTint1[3];
uint8_t fDefaultTint2[3];
char *fAccessoryName; // Export only
plString fAccessoryName; // Export only
@ -111,8 +111,8 @@ public:
CLASSNAME_REGISTER( plClothingItem );
GETINTERFACE_ANY( plClothingItem, hsKeyedObject );
void SetName(char *name) { delete fName; fName = hsStrcpy(name); }
const char* GetName() { return fName; }
void SetName(const plString &name) { fName = name; }
plString GetName() const { return fName; }
bool CanWearWith(plClothingItem *item);
bool WearBefore(plClothingItem *item); // Should we come before the arg item? (texture gen order)
bool HasBaseAlpha();
@ -138,17 +138,16 @@ public:
class plClothingBase : public hsKeyedObject
{
public:
char *fName;
plString fName;
plMipmap *fBaseTexture;
char *fLayoutName;
plString fLayoutName;
plClothingBase();
~plClothingBase();
CLASSNAME_REGISTER( plClothingBase );
GETINTERFACE_ANY( plClothingBase, hsKeyedObject );
void SetLayoutName(char *name) { delete fLayoutName; fLayoutName = hsStrcpy(name); }
void SetLayoutName(const plString &name) { fLayoutName = name; }
virtual void Read(hsStream* s, hsResMgr* mgr);
virtual void Write(hsStream* s, hsResMgr* mgr);
@ -282,8 +281,8 @@ public:
CLASSNAME_REGISTER( plClothingMgr );
GETINTERFACE_ANY( plClothingMgr, hsKeyedObject );
plClothingLayout *GetLayout(char *name);
plClothingElement *FindElementByName(const char *name);
plClothingLayout *GetLayout(const plString &name) const;
plClothingElement *FindElementByName(const plString &name) const;
// Functions that just relate to the clothing you have permission to wear (closet)
@ -291,7 +290,7 @@ public:
void GetClosetItems(hsTArray<plClosetItem> &out);
// Functions that relate to all existing clothing
plClothingItem *FindItemByName(const char *name);
plClothingItem *FindItemByName(const plString &name) const;
hsTArray<plClothingItem*>& GetItemList() { return fItems; }
void GetItemsByGroup(uint8_t group, hsTArray<plClothingItem*> &out);
void GetItemsByGroupAndType(uint8_t group, uint8_t type, hsTArray<plClothingItem*> &out);
@ -305,7 +304,7 @@ public:
plClothingItem *GetLRMatch(plClothingItem *item);
bool IsLRMatch(plClothingItem *item1, plClothingItem *item2);
static void ChangeAvatar(const char* name, const plFileName &clothingFile = "");
static void ChangeAvatar(const plString& name, const plFileName &clothingFile = "");
static plClothingMgr *GetClothingMgr() { return fInstance; }
static void Init();

View File

@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "hsTemplates.h"
#include "plString.h"
// This file is intended to be an independent section so that plClothingMtl and plAvatarClothing
@ -71,21 +72,14 @@ public:
kLayerSkinLast = kLayerSkinBlend6,
};
char *fName;
plString fName;
uint32_t fXPos;
uint32_t fYPos;
uint32_t fWidth;
uint32_t fHeight;
plClothingElement(const char *name, uint32_t xPos, uint32_t yPos, uint32_t width, uint32_t height)
{
fName = hsStrcpy(name);
fXPos = xPos;
fYPos = yPos;
fWidth = width;
fHeight = height;
}
~plClothingElement() { delete [] fName; }
plClothingElement(const plString &name, uint32_t xPos, uint32_t yPos, uint32_t width, uint32_t height)
: fName(name), fXPos(xPos), fYPos(yPos), fWidth(width), fHeight(height) { }
static void GetElements(hsTArray<plClothingElement *> &out)
{
@ -127,10 +121,10 @@ public:
class plClothingLayout
{
public:
plClothingLayout(const char *name, uint32_t origWidth) { fName = hsStrcpy(name); fOrigWidth = origWidth; }
~plClothingLayout() { delete [] fName; }
plClothingLayout(const plString &name, uint32_t origWidth)
: fName(name), fOrigWidth(origWidth) { }
char *fName;
plString fName;
uint32_t fOrigWidth;
hsTArray<plClothingElement*> fElements;
/*