Browse Source

plMultistageStage => plString

Michael Hansen 11 years ago
parent
commit
cbea492457
  1. 12
      Sources/Tools/MaxComponent/plMultistageBehComponent.cpp
  2. 45
      Sources/Tools/MaxComponent/plMultistageStage.cpp
  3. 16
      Sources/Tools/MaxComponent/plMultistageStage.h

12
Sources/Tools/MaxComponent/plMultistageBehComponent.cpp

@ -306,7 +306,7 @@ void plMultistageBehComponent::IInitDlg()
for (int i = 0; i < fStages.size(); i++) for (int i = 0; i < fStages.size(); i++)
{ {
plBaseStage* stage = fStages[i]; plBaseStage* stage = fStages[i];
ListView_AddString(hList, stage->GetName()); ListView_AddString(hList, stage->GetName().c_str());
} }
// Make sure the column is wide enough // Make sure the column is wide enough
@ -326,16 +326,14 @@ void plMultistageBehComponent::FixStageNames()
if (fStages.size() > 0) if (fStages.size() > 0)
{ {
plBaseStage* stage = fStages[0]; plBaseStage* stage = fStages[0];
const char * stageName = stage->GetName(); plString stageName = stage->GetName();
if(strcmp(stageName, "Stage 1") == 0) if (stageName == "Stage 1")
{ {
for (int i = 0; i < fStages.size(); i++) for (int i = 0; i < fStages.size(); i++)
{ {
plBaseStage* stage = fStages[i]; plBaseStage* stage = fStages[i];
char buf[64]; stage->SetName(plString::Format("Stage %d", i));
sprintf(buf, "Stage %d", i);
stage->SetName(buf);
} }
} }
} }
@ -362,7 +360,7 @@ BOOL plMultistageBehComponent::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPAR
// Add the new stage to the list and make sure the list is wide enough // Add the new stage to the list and make sure the list is wide enough
HWND hList = GetDlgItem(fDlg, IDC_STAGE_LIST); HWND hList = GetDlgItem(fDlg, IDC_STAGE_LIST);
int idx = ListView_AddString(hList, stage->GetName()); int idx = ListView_AddString(hList, stage->GetName().c_str());
ListView_SetColumnWidth(hList, 0, LVSCW_AUTOSIZE); ListView_SetColumnWidth(hList, 0, LVSCW_AUTOSIZE);
ListView_SetItemState(hList, idx, LVIS_SELECTED, LVIS_SELECTED); ListView_SetItemState(hList, idx, LVIS_SELECTED, LVIS_SELECTED);

45
Sources/Tools/MaxComponent/plMultistageStage.cpp

@ -53,16 +53,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMultistageStage.h" #include "plMultistageStage.h"
#include "plAvatar/plAnimStage.h" #include "plAvatar/plAnimStage.h"
plBaseStage::plBaseStage()
{
fName = nil;
}
plBaseStage::~plBaseStage()
{
delete [] fName;
}
BOOL plBaseStage::IStaticDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) BOOL plBaseStage::IStaticDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
if (msg == WM_INITDIALOG) if (msg == WM_INITDIALOG)
@ -96,24 +86,17 @@ void plBaseStage::IDestroyDlg(HWND hDlg)
GetCOREInterface()->DeleteRollupPage(hDlg); GetCOREInterface()->DeleteRollupPage(hDlg);
} }
const char* plBaseStage::GetName() plString plBaseStage::GetName()
{ {
if (!fName) if (fName.IsEmpty())
fName = hsStrcpy("DefaultName"); fName = "DefaultName";
return fName; return fName;
} }
void plBaseStage::SetName(const char* name)
{
delete [] fName;
fName = hsStrcpy(name);
}
void plBaseStage::Read(hsStream *stream) void plBaseStage::Read(hsStream *stream)
{ {
stream->ReadLE16(); stream->ReadLE16();
delete [] fName; fName = stream->ReadSafeString_TEMP();
fName = stream->ReadSafeString();
} }
void plBaseStage::Write(hsStream *stream) void plBaseStage::Write(hsStream *stream)
@ -124,7 +107,7 @@ void plBaseStage::Write(hsStream *stream)
void plBaseStage::IBaseClone(plBaseStage* clone) void plBaseStage::IBaseClone(plBaseStage* clone)
{ {
clone->fName = hsStrcpy(fName); clone->fName = fName;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -134,7 +117,6 @@ HWND plStandardStage::fDlg = NULL;
plStandardStage::plStandardStage() plStandardStage::plStandardStage()
{ {
fAnimName = nil;
fNumLoops = 0; fNumLoops = 0;
fLoopForever = false; fLoopForever = false;
fForward = 0; fForward = 0;
@ -149,19 +131,13 @@ plStandardStage::plStandardStage()
fRegressTo = 0; fRegressTo = 0;
} }
plStandardStage::~plStandardStage()
{
delete [] fAnimName;
}
void plStandardStage::Read(hsStream *stream) void plStandardStage::Read(hsStream *stream)
{ {
plBaseStage::Read(stream); plBaseStage::Read(stream);
uint16_t version = stream->ReadLE16(); uint16_t version = stream->ReadLE16();
delete [] fAnimName; fAnimName = stream->ReadSafeString_TEMP();
fAnimName = stream->ReadSafeString();
fNumLoops = stream->ReadLE32(); fNumLoops = stream->ReadLE32();
fLoopForever = stream->ReadBool(); fLoopForever = stream->ReadBool();
fForward = stream->ReadByte(); fForward = stream->ReadByte();
@ -329,10 +305,9 @@ void plStandardStage::IGetAnimName()
char buf[256]; char buf[256];
edit->GetText(buf, sizeof(buf)); edit->GetText(buf, sizeof(buf));
if (strcmp(buf, fAnimName) != 0) if (fAnimName != buf)
{ {
delete [] fAnimName; fAnimName = buf;
fAnimName = hsStrcpy(buf);
SetSaveRequiredFlag(); SetSaveRequiredFlag();
} }
@ -387,7 +362,7 @@ static void LoadCombo(HWND hCombo, NameType* nameInt, int size, int curVal)
void plStandardStage::IInitDlg() void plStandardStage::IInitDlg()
{ {
ICustEdit* edit = GetICustEdit(GetDlgItem(fDlg, IDC_ANIM_NAME)); ICustEdit* edit = GetICustEdit(GetDlgItem(fDlg, IDC_ANIM_NAME));
edit->SetText(fAnimName); edit->SetText(fAnimName.c_str());
HWND hForward = GetDlgItem(fDlg, IDC_FORWARD_COMBO); HWND hForward = GetDlgItem(fDlg, IDC_FORWARD_COMBO);
LoadCombo(hForward, gForward, sizeof(gForward), fForward); LoadCombo(hForward, gForward, sizeof(gForward), fForward);
@ -446,7 +421,7 @@ plAnimStage* plStandardStage::CreateStage()
plBaseStage* plStandardStage::Clone() plBaseStage* plStandardStage::Clone()
{ {
plStandardStage* clone = new plStandardStage; plStandardStage* clone = new plStandardStage;
clone->fAnimName = hsStrcpy(fAnimName); clone->fAnimName = fAnimName;
clone->fNumLoops = fNumLoops; clone->fNumLoops = fNumLoops;
clone->fLoopForever = fLoopForever; clone->fLoopForever = fLoopForever;
clone->fForward = fForward; clone->fForward = fForward;

16
Sources/Tools/MaxComponent/plMultistageStage.h

@ -40,6 +40,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "plString.h"
class plAnimStage; class plAnimStage;
class plBaseStage; class plBaseStage;
class hsStream; class hsStream;
@ -56,7 +58,7 @@ enum StageTypes
class plBaseStage class plBaseStage
{ {
protected: protected:
char* fName; plString fName;
static BOOL CALLBACK IStaticDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); static BOOL CALLBACK IStaticDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
virtual BOOL IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); virtual BOOL IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
@ -67,8 +69,8 @@ protected:
void IBaseClone(plBaseStage* clone); void IBaseClone(plBaseStage* clone);
public: public:
plBaseStage(); plBaseStage() { }
virtual ~plBaseStage(); virtual ~plBaseStage() { }
// From StageTypes // From StageTypes
virtual int GetType()=0; virtual int GetType()=0;
@ -84,8 +86,8 @@ public:
virtual plBaseStage* Clone()=0; virtual plBaseStage* Clone()=0;
const char* GetName(); plString GetName(); // NOT const (this could change fName)
void SetName(const char* name); void SetName(const plString& name) { fName = name; }
}; };
class plStandardStage : public plBaseStage class plStandardStage : public plBaseStage
@ -93,7 +95,7 @@ class plStandardStage : public plBaseStage
protected: protected:
static HWND fDlg; static HWND fDlg;
char *fAnimName; plString fAnimName;
uint32_t fNumLoops; uint32_t fNumLoops;
bool fLoopForever; bool fLoopForever;
uint8_t fForward; uint8_t fForward;
@ -114,7 +116,7 @@ protected:
public: public:
plStandardStage(); plStandardStage();
~plStandardStage(); ~plStandardStage() { }
int GetType() { return kStandard; } int GetType() { return kStandard; }

Loading…
Cancel
Save