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

Deprecate plFileUtils and parts of pnUtPath

This commit is contained in:
2013-01-20 13:47:14 -08:00
parent 970ad3e729
commit 6e564476b7
114 changed files with 982 additions and 2117 deletions

View File

@ -60,7 +60,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAudible.h"
#include "plCreatableIndex.h"
#include "plgDispatch.h"
#include "plFile/plFileUtils.h"
#include "plFile/hsFiles.h"
#include "hsGeometry3.h"
#include "plLoadMask.h"

View File

@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "plgDispatch.h"
#include "plFile/plFileUtils.h"
#include "plAnimComponent.h"
#include "plAudioComponents.h"
@ -588,21 +587,20 @@ uint32_t plBaseSoundEmitterComponent::ICalcSourceBufferFlags( void ) const
return bufferFlags;
}
plSoundBuffer *plBaseSoundEmitterComponent::GetSourceBuffer( const char *fileName, plMaxNode *srcNode, uint32_t srcBufferFlags )
plSoundBuffer *plBaseSoundEmitterComponent::GetSourceBuffer( const plFileName &fileName, plMaxNode *srcNode, uint32_t srcBufferFlags )
{
plSoundBuffer* sb = IGetSourceBuffer(fileName, srcNode, srcBufferFlags);
const char* plasmaDir = plMaxConfig::GetClientPath();
if (plasmaDir)
plFileName plasmaDir = plMaxConfig::GetClientPath();
if (plasmaDir.IsValid())
{
char sfxPath[MAX_PATH];
sprintf(sfxPath, "%ssfx\\%s", plasmaDir, plFileUtils::GetFileName(fileName));
plFileName sfxPath = plFileName::Join(plasmaDir, "sfx", fileName.GetFileName());
// Export any localized versions as well
for (int i = 0; i < plLocalization::GetNumLocales(); i++)
{
char localName[MAX_PATH];
if (plLocalization::ExportGetLocalized(sfxPath, i, localName))
plFileName localName = plLocalization::ExportGetLocalized(sfxPath, i);
if (localName.IsValid())
{
IGetSourceBuffer(localName, srcNode, srcBufferFlags);
}
@ -612,58 +610,45 @@ plSoundBuffer *plBaseSoundEmitterComponent::GetSourceBuffer( const char *fileN
return sb;
}
plSoundBuffer *plBaseSoundEmitterComponent::IGetSourceBuffer( const char *fileName, plMaxNode *srcNode, uint32_t srcBufferFlags )
plSoundBuffer *plBaseSoundEmitterComponent::IGetSourceBuffer(const plFileName &fileName, plMaxNode *srcNode, uint32_t srcBufferFlags)
{
plKey key;
plString keyName;
char fullPath[ MAX_PATH ];
// ***TEMP plString REVISIT***
char tempPath[ MAX_PATH ];
strncpy(tempPath, fileName, MAX_PATH);
::PathStripPath( tempPath );
keyName = tempPath;
plString keyName = fileName.GetFileName();
// TEMP HACK until we get packed sounds:
// Given the source filename, we check to see if it's in our plasma game directory. If not, or if
// it's out of date, we copy it over. We'll truncate the filename inside plSoundBuffer when we're ready.
const char *plasmaDir = plMaxConfig::GetClientPath();
if( plasmaDir != nil )
plFileName plasmaDir = plMaxConfig::GetClientPath();
plFileName rfilename = fileName;
if (plasmaDir.IsValid())
{
strcpy( fullPath, plasmaDir );
strcat( fullPath, "sfx\\" );
plFileName fullPath = plFileName::Join(plasmaDir, "sfx");
// Before we finish our path, make sure that directory EXISTS
plFileUtils::CreateDir( fullPath );
plFileSystem::CreateDir(fullPath);
// Now finish the path...
strcat( fullPath, keyName.c_str() );
fullPath = plFileName::Join(fullPath, keyName);
// Check filestamp
WIN32_FILE_ATTRIBUTE_DATA oldFileAttrib, newFileAttrib;
BOOL oldOK, newOK;
plFileInfo oldInfo(fileName);
plFileInfo newInfo(fullPath);
oldOK = GetFileAttributesEx( fileName, GetFileExInfoStandard, &oldFileAttrib );
newOK = GetFileAttributesEx( fullPath, GetFileExInfoStandard, &newFileAttrib );
if( oldOK && newOK )
if (oldInfo.Exists() && newInfo.Exists())
{
// Only copy if the file is newer
if( ::CompareFileTime( &oldFileAttrib.ftLastWriteTime, &newFileAttrib.ftLastWriteTime ) > 0 )
{
::CopyFile( fileName, fullPath, FALSE );
}
if (oldInfo.ModifyTime() > newInfo.ModifyTime())
plFileSystem::Copy(fileName, fullPath);
}
else
{
// Can't compare, so either there was an error or the target file doesn't exist. Copy no matter what.
::CopyFile( fileName, fullPath, FALSE );
plFileSystem::Copy(fileName, fullPath);
}
// Point to our new sound file
fileName = fullPath;
rfilename = fullPath;
}
// Additional info for the keyName--need some flag mangling, specifically for the left/right channel mangling
@ -672,12 +657,12 @@ plSoundBuffer *plBaseSoundEmitterComponent::IGetSourceBuffer( const char *file
else if( srcBufferFlags & plSoundBuffer::kOnlyRightChannel )
keyName += ":R";
key = srcNode->FindPageKey( plSoundBuffer::Index(), keyName );
key = srcNode->FindPageKey( plSoundBuffer::Index(), keyName );
if( key != nil )
return plSoundBuffer::ConvertNoRef( key->GetObjectPtr() );
// Not yet created, so make a new one
plSoundBuffer *buffer = new plSoundBuffer( fileName, srcBufferFlags );
plSoundBuffer *buffer = new plSoundBuffer( rfilename, srcBufferFlags );
if( !buffer->IsValid() )
{
// Invalid, so delete and return nil
@ -2258,29 +2243,18 @@ bool plSound3DEmitterComponent::ConvertGrouped( plMaxNode *baseNode, hsTArray
}
// Grab the buffer for this sound directly from the original source
const char *fileName = groupArray[ i ]->GetSoundFileName( kBaseSound );
plFileName fileName = groupArray[ i ]->GetSoundFileName( kBaseSound );
plSoundBuffer *buffer = new plSoundBuffer( fileName );
if( !buffer->IsValid() || !buffer->EnsureInternal() )
{
// OK, because some *cough* machines are completely stupid and don't load AssetMan scenes with
// AssetMan plugins, we need to do a really stupid fallback search to the current exporting directory.
const char *plasmaDir = plMaxConfig::GetClientPath();
plFileName plasmaDir = plMaxConfig::GetClientPath();
bool worked = false;
if( plasmaDir != nil )
if (plasmaDir.IsValid())
{
char newPath[ MAX_PATH ];
strcpy( newPath, plasmaDir );
strcat( newPath, "sfx\\" );
const char* c = strrchr( fileName, '\\' );
if( c == nil )
c = strrchr( fileName, '/' );
if( c == nil )
c = fileName;
else
c++;
strcat( newPath, c );
plFileName newPath = plFileName::Join(plasmaDir, "sfx", fileName.GetFileName());
// Got a path to try, so try it!
delete buffer;
@ -2292,7 +2266,7 @@ bool plSound3DEmitterComponent::ConvertGrouped( plMaxNode *baseNode, hsTArray
if( !worked )
{
char msg[ 512 ];
sprintf( msg, "The sound file %s cannot be loaded for component %s.", fileName, groupArray[ i ]->GetINode()->GetName() );
sprintf( msg, "The sound file %s cannot be loaded for component %s.", fileName.AsString().c_str(), groupArray[ i ]->GetINode()->GetName() );
IShowError( kSrcBufferInvalid, msg, baseNode->GetName(), pErrMsg );
delete buffer;
@ -2312,7 +2286,7 @@ bool plSound3DEmitterComponent::ConvertGrouped( plMaxNode *baseNode, hsTArray
{
char msg[ 512 ];
sprintf( msg, "The format for sound file %s does not match the format for the other grouped sounds on node %s. "
"Make sure the sounds are all the same format.", fileName, baseNode->GetName() );
"Make sure the sounds are all the same format.", fileName.AsString().c_str(), baseNode->GetName() );
IShowError( kMergeSourceFormatMismatch, msg, baseNode->GetName(), pErrMsg );
delete buffer;

View File

@ -65,6 +65,7 @@ class plMaxNode;
class plSoundBuffer;
class plSound;
class plAudioBaseComponentProc;
class plFileName;
namespace plAudioComp
{
@ -117,7 +118,7 @@ class plBaseSoundEmitterComponent : public plComponent
return -1;
}
static plSoundBuffer *GetSourceBuffer( const char *fileName, plMaxNode *node, uint32_t srcBufferFlags );
static plSoundBuffer *GetSourceBuffer( const plFileName &fileName, plMaxNode *node, uint32_t srcBufferFlags );
static bool LookupLatestAsset( const char *waveName, char *retPath, plErrorMsg *errMsg );
virtual void UpdateSoundFileSelection( void );
@ -177,7 +178,7 @@ class plBaseSoundEmitterComponent : public plComponent
virtual uint32_t ICalcSourceBufferFlags() const;
static plSoundBuffer *IGetSourceBuffer( const char *fileName, plMaxNode *srcNode, uint32_t srcBufferFlags );
static plSoundBuffer *IGetSourceBuffer( const plFileName &fileName, plMaxNode *srcNode, uint32_t srcBufferFlags );
plSoundBuffer *IProcessSourceBuffer( plMaxNode *maxNode, plErrorMsg *errMsg );

View File

@ -1449,8 +1449,8 @@ void plGUIDialogProc::ILoadPages( HWND hWnd, IParamBlock2 *pb )
while( ( page = aged->GetNextPage() ) != nil )
{
int idx = ComboBox_AddString( hWnd, page->GetName() );
if( selPageName && stricmp( page->GetName(), selPageName ) == 0 )
int idx = ComboBox_AddString( hWnd, page->GetName().c_str() );
if( selPageName && page->GetName().CompareI( selPageName ) == 0 )
ComboBox_SetCurSel( hWnd, idx );
}

View File

@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "plCreatableIndex.h"
#include "plgDispatch.h"
#include "plFile/plFileUtils.h"
#include "plFile/hsFiles.h"
#include "plComponentReg.h"
@ -237,8 +236,8 @@ protected:
aged.SeekFirstPage();
while( ( page = aged.GetNextPage() ) != nil )
{
int idx = ComboBox_AddString(hPageCombo, page->GetName() );
if (curPage && !strcmp(page->GetName(), curPage))
int idx = ComboBox_AddString(hPageCombo, page->GetName().c_str() );
if (curPage && (page->GetName() == curPage))
ComboBox_SetCurSel(hPageCombo, idx);
ComboBox_SetItemData( hPageCombo, idx, (int)page->GetSeqSuffix() );
}
@ -576,33 +575,32 @@ const char *plPageInfoComponent::GetAgeName()
// Checks in assetMan to make sure we have the latest .age file to export
// with.
void plPageInfoComponent::IVerifyLatestAgeAsset( const char *ageName, const char *localPath, plErrorMsg *errMsg )
void plPageInfoComponent::IVerifyLatestAgeAsset( const plString &ageName, const plFileName &localPath, plErrorMsg *errMsg )
{
#ifdef MAXASS_AVAILABLE
char ageFileName[ MAX_PATH ], assetPath[ MAX_PATH ];
plFileName ageFileName, assetPath;
MaxAssInterface *assetMan = GetMaxAssInterface();
if( assetMan == nil )
return; // No AssetMan available
// Try to find it in assetMan
sprintf( ageFileName, "%s.age", ageName );
ageFileName = ageName + ".age";
jvUniqueId assetId;
if (assetMan->FindAssetByFilename(ageFileName, assetId))
if (assetMan->FindAssetByFilename(ageFileName.AsString().c_str(), assetId))
{
// Get the latest version
if (!assetMan->GetLatestVersionFile(assetId, assetPath, sizeof(assetPath)))
{
errMsg->Set( true, "PageInfo Convert Error",
"Unable to update age file for '%s' because AssetMan was unable to get the latest version. Using local copy instead.", ageName ).Show();
"Unable to update age file for '%s' because AssetMan was unable to get the latest version. Using local copy instead.", ageName.c_str() ).Show();
errMsg->Set( false );
return;
}
// Got the latest version, just copy over and roll!
plFileUtils::RemoveFile( localPath );
plFileUtils::FileCopy( assetPath, localPath );
plFileSystem::Unlink(localPath);
plFileSystem::Copy(assetPath, localPath);
}
else
{
@ -625,10 +623,8 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
// Mark us as updated
fCompPB->SetValue( kRefVolatile_PageInfoUpdated, 0, (int)true );
char path[MAX_PATH];
const char *ageFolder = plPageInfoUtils::GetAgeFolder();
if( ageFolder == nil )
plFileName ageFolder = plPageInfoUtils::GetAgeFolder();
if (!ageFolder.IsValid())
{
errMsg->Set( true,
"PageInfo Convert Error",
@ -653,7 +649,7 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
fCompPB->SetValue( kInfoSeqSuffix, 0, 0 );
return;
}
sprintf(path, "%s%s.age", ageFolder, curAge);
plFileName path = plFileName::Join(ageFolder, plString::Format("%s.age", curAge));
IVerifyLatestAgeAsset( curAge, path, errMsg );
@ -699,12 +695,12 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
while( ( page = aged.GetNextPage() ) != nil )
{
if( stricmp( page->GetName(), compPBPageName ) == 0 )
if( page->GetName().CompareI( compPBPageName ) == 0 )
{
fCompPB->SetValue( kInfoSeqSuffix, 0, (int)page->GetSeqSuffix() );
// Also re-copy the page name, just to make sure the case is correct
fCompPB->SetValue( kInfoPage, 0, (char *)page->GetName() );
fCompPB->SetValue( kInfoPage, 0, (const char *)page->GetName().c_str() );
return;
}
}
@ -720,28 +716,20 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
fCompPB->SetValue( kInfoSeqSuffix, 0, 0 );
}
const char *plPageInfoUtils::GetAgeFolder()
plFileName plPageInfoUtils::GetAgeFolder()
{
static char ageFolder[MAX_PATH];
static bool initialized = false;
static plFileName ageFolder;
if (!initialized)
if (!ageFolder.IsValid())
{
initialized = true;
ageFolder[0] = '\0';
plFileName plasmaPath = plMaxConfig::GetClientPath();
if (!plasmaPath.IsValid())
return "";
const char *plasmaPath = plMaxConfig::GetClientPath();
if (!plasmaPath)
return nil;
strcpy(ageFolder, plasmaPath);
strcat(ageFolder, plAgeDescription::kAgeDescPath);
ageFolder = plFileName::Join(plasmaPath, plAgeDescription::kAgeDescPath);
}
if (ageFolder[0] != '\0')
return ageFolder;
else
return nil;
return ageFolder;
}
int32_t plPageInfoUtils::CombineSeqNum( int prefix, int suffix )
@ -789,7 +777,7 @@ int32_t plPageInfoUtils::GetSeqNumFromAgeDesc( const char *ageName, const char
aged->SeekFirstPage();
while( ( page = aged->GetNextPage() ) != nil )
{
if( stricmp( pageName, page->GetName() ) == 0 )
if (page->GetName().CompareI(pageName) == 0)
{
seqSuffix = page->GetSeqSuffix();
break;
@ -801,18 +789,14 @@ int32_t plPageInfoUtils::GetSeqNumFromAgeDesc( const char *ageName, const char
return CombineSeqNum( seqPrefix, seqSuffix );
}
plAgeDescription *plPageInfoUtils::GetAgeDesc( const char *ageName )
plAgeDescription *plPageInfoUtils::GetAgeDesc( const plString &ageName )
{
char path[ MAX_PATH ];
const char *ageFolder = plPageInfoUtils::GetAgeFolder();
if( ageFolder == nil || ageName == nil )
plFileName ageFolder = plPageInfoUtils::GetAgeFolder();
if (!ageFolder.IsValid() || ageName.IsNull())
return nil;
sprintf( path, "%s%s.age", ageFolder, ageName );
hsUNIXStream s;
if( !s.Open( path ) )
if (!s.Open(plFileName::Join(ageFolder, ageName + ".age")))
return nil;
// Create and read the age desc

View File

@ -52,6 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define CIRCLE_CAM_CID Class_ID(0x66f85282, 0x4daa1b8e)
#define IMAGE_LIB_CID Class_ID(0x736c18d3, 0x6a6d5dde)
class plFileName;
class plAgeDescription;
class plComponentBase;
struct NotifyInfo;
@ -60,12 +61,12 @@ const char* LocCompGetPage(plComponentBase* comp);
namespace plPageInfoUtils
{
const char *GetAgeFolder();
int32_t GetSeqNumFromAgeDesc( const char *ageName, const char *pageName );
int32_t CombineSeqNum( int prefix, int suffix );
int32_t GetCommonSeqNumFromNormal( int32_t normalSeqNumber, int whichCommonPage );
plFileName GetAgeFolder();
int32_t GetSeqNumFromAgeDesc( const char *ageName, const char *pageName );
int32_t CombineSeqNum( int prefix, int suffix );
int32_t GetCommonSeqNumFromNormal( int32_t normalSeqNumber, int whichCommonPage );
plAgeDescription *GetAgeDesc( const char *ageName );
plAgeDescription *GetAgeDesc( const plString &ageName );
};
// PageInfo component definition, here so other components can get to the static function(s)
@ -76,8 +77,8 @@ protected:
bool fItinerant;
static char fCurrExportedAge[ 256 ];
void IVerifyLatestAgeAsset( const char *ageName, const char *localPath, plErrorMsg *errMsg );
void IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg );
void IVerifyLatestAgeAsset( const plString &ageName, const plFileName &localPath, plErrorMsg *errMsg );
void IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg );
public:
plPageInfoComponent();

View File

@ -318,19 +318,18 @@ void plResponderLinkProc::ILoadAgeFilenamesCombo(HWND hWnd, IParamBlock2 *pb)
SendMessage(hAge, CB_RESETCONTENT, 0, 0);
// Get the path to the description folder
char agePath[MAX_PATH];
const char *plasmaPath = plMaxConfig::GetClientPath();
if (!plasmaPath)
plFileName plasmaPath = plMaxConfig::GetClientPath();
if (!plasmaPath.IsValid())
return;
strcpy(agePath, plasmaPath);
strcat(agePath, plAgeDescription::kAgeDescPath);
plFileName agePath = plFileName::Join(plasmaPath, plAgeDescription::kAgeDescPath);
const char *savedName = pb->GetStr(kLinkAgeFilename);
if (!savedName)
savedName = "";
// Iterate through the age descriptions
hsFolderIterator ageFolder(agePath);
hsFolderIterator ageFolder(agePath.AsString().c_str());
while (ageFolder.NextFileSuffix(".age"))
{
char ageFile[MAX_PATH];
@ -355,19 +354,17 @@ void plResponderLinkProc::ILoadParentAgeFilenamesCombo(HWND hWnd, IParamBlock2 *
SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)"<None>");
// Get the path to the description folder
char agePath[MAX_PATH];
const char *plasmaPath = plMaxConfig::GetClientPath();
if (!plasmaPath)
plFileName plasmaPath = plMaxConfig::GetClientPath();
if (!plasmaPath.IsValid())
return;
strcpy(agePath, plasmaPath);
strcat(agePath, plAgeDescription::kAgeDescPath);
plFileName agePath = plFileName::Join(plasmaPath, plAgeDescription::kAgeDescPath);
const char *savedName = pb->GetStr(kLinkParentAgeFilename);
if (!savedName)
savedName = "<None>";
// Iterate through the age descriptions
hsFolderIterator ageFolder(agePath);
hsFolderIterator ageFolder(agePath.AsString().c_str());
while (ageFolder.NextFileSuffix(".age"))
{
char ageFile[MAX_PATH];

View File

@ -71,7 +71,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plSurface/hsGMaterial.h"
#include "pnSceneObject/plSceneObject.h"
#include "UserPropMgr.h"
#include "plFile/plFileUtils.h"
#include "hsConverterUtils.h"
#include "hsControlConverter.h"
@ -1981,18 +1980,17 @@ static plLayerInterface* IProcessLayerMovie(plPassMtlBase* mtl, plLayerTex* layT
if( !bi || !bi->Name() || !*bi->Name() )
return layerIFace;
const char* fileName = bi->Name();
plFileName fileName = bi->Name();
plAnimStealthNode* stealth = IGetEntireAnimation(mtl);
const char* ext = plFileUtils::GetFileExt(fileName);
bool isBink = ext && (stricmp(ext, "bik") == 0);
bool isAvi = ext &&(stricmp(ext, "avi") == 0);
plString ext = fileName.GetFileExt();
bool isBink = (ext.CompareI("bik") == 0);
bool isAvi = (ext.CompareI("avi") == 0);
if (isBink || isAvi)
{
char movieName[256];
sprintf(movieName, "avi/%s", plFileUtils::GetFileName(fileName));
plFileName movieName = plFileName::Join("avi", fileName.GetFileName());
plLayerMovie* movieLayer = nil;
plString moviePostfix;

View File

@ -134,7 +134,7 @@ plMipmap *plBitmapCreator::ICreateBitmap(plBitmapData *bd)
// Load the bitmap
BitmapInfo bi;
bi.SetName(bd->fileName);
bi.SetName(bd->fileName.AsString().c_str());
#if 0 // This isn't really an issue since the textures are packed -Colin
const int kMaxFileNameLength = 30;
@ -267,20 +267,20 @@ plMipmap *plBitmapCreator::ICreateBitmap(plBitmapData *bd)
//
// Verify that bitmap is the correct type/size
//
void plBitmapCreator::ICheckOutBitmap(BitmapInfo* bInfo, Bitmap* bm, const char *fileName)
void plBitmapCreator::ICheckOutBitmap(BitmapInfo* bInfo, Bitmap* bm, const plFileName& fileName)
{
hsGuardBegin("hsConverterUtils::ICheckOutBitmap");
// Check out bitmap
if (bm->Flags() & MAP_FLIPPED)
MessageBox(GetActiveWindow(), "Bitmap is flipped horizontally", fileName, MB_OK);
MessageBox(GetActiveWindow(), "Bitmap is flipped horizontally", fileName.AsString().c_str(), MB_OK);
if (bm->Flags() & MAP_INVERTED)
MessageBox(GetActiveWindow(), "Bitmap is inverted vertically", fileName, MB_OK);
MessageBox(GetActiveWindow(), "Bitmap is inverted vertically", fileName.AsString().c_str(), MB_OK);
if (bInfo->Flags() & MAP_FLIPPED)
MessageBox(GetActiveWindow(), "BI:Bitmap is flipped horizontally", fileName, MB_OK);
MessageBox(GetActiveWindow(), "BI:Bitmap is flipped horizontally", fileName.AsString().c_str(), MB_OK);
if (bInfo->Flags() & MAP_INVERTED)
MessageBox(GetActiveWindow(), "BI:Bitmap is inverted vertically", fileName, MB_OK);
MessageBox(GetActiveWindow(), "BI:Bitmap is inverted vertically", fileName.AsString().c_str(), MB_OK);
hsGuardEnd;
}
@ -480,10 +480,10 @@ plBitmap *plBitmapCreator::CreateTexture(plBitmapData *bd, const plLocation &loc
for (int i = 0; i < plLocalization::GetNumLocales(); i++)
{
char localName[MAX_PATH];
if (plLocalization::ExportGetLocalized(bd->fileName, i, localName))
plFileName localName = plLocalization::ExportGetLocalized(bd->fileName, i);
if (localName.IsValid())
{
const char* oldName = bd->fileName;
plFileName oldName = bd->fileName;
bd->fileName = localName;
ICreateTexture(bd, loc, clipID);
bd->fileName = oldName;
@ -517,40 +517,39 @@ plBitmap *plBitmapCreator::ICreateTexture( plBitmapData *bd, const plLocation &l
return nil;
}
if( bd->fileName == nil || bd->fileName[ 0 ] == 0 )
if (!bd->fileName.IsValid())
{
fErrorMsg->Set( true, "Bitmap Error", "Material texture has null bitmap name." ).Show();
fErrorMsg->Set();
fErrorMsg->Set();
return nil;
}
// Get and mangle key name
plString name;
char temp[ 256 ];
_splitpath(bd->fileName, NULL, NULL, temp, NULL);
plString temp = bd->fileName.GetFileNameNoExt();
// Somehow, sometimes, we get the same file in with different cases. So we need to force the
// case identical all the time, else the patching process for dat files will think they're
// "different" when they're really not
strlwr( temp );
temp = temp.ToLower();
/// Mangle name for detail textures, so we don't end up overwriting settings elsewhere
if( bd->createFlags & plMipmap::kCreateDetailMask )
{
// Mangle of the form: name@dropStart&dropStop&max&min
if( clipID != -1 )
name = plString::Format( "%s*%x#%d@%s&%3.2f&%3.2f&%3.2f&%3.2f", temp, bd->texFlags, clipID,
name = plString::Format( "%s*%x#%d@%s&%3.2f&%3.2f&%3.2f&%3.2f", temp.c_str(), bd->texFlags, clipID,
bd->createFlags & plMipmap::kCreateDetailAlpha ? "al" : ( bd->createFlags & plMipmap::kCreateDetailAdd ? "ad" : "mu" ),
bd->detailDropoffStart, bd->detailDropoffStop, bd->detailMax, bd->detailMin );
else
name = plString::Format( "%s*%x@%s&%3.2f&%3.2f&%3.2f&%3.2f", temp, bd->texFlags,
name = plString::Format( "%s*%x@%s&%3.2f&%3.2f&%3.2f&%3.2f", temp.c_str(), bd->texFlags,
bd->createFlags & plMipmap::kCreateDetailAlpha ? "al" : ( bd->createFlags == plMipmap::kCreateDetailAdd ? "ad" : "mu" ),
bd->detailDropoffStart, bd->detailDropoffStop, bd->detailMax, bd->detailMin );
}
else if( clipID != -1 )
name = plString::Format( "%s*%x#%d", temp, bd->texFlags, clipID );
name = plString::Format( "%s*%x#%d", temp.c_str(), bd->texFlags, clipID );
else
name = plString::Format( "%s*%x", temp, bd->texFlags );
name = plString::Format( "%s*%x", temp.c_str(), bd->texFlags );
if( bd->invertAlpha )
name += "_inva";
name += ".hsm";
@ -566,7 +565,7 @@ plBitmap *plBitmapCreator::ICreateTexture( plBitmapData *bd, const plLocation &l
if( texture )
{
WIN32_FILE_ATTRIBUTE_DATA fileAttrib;
GetFileAttributesEx(bd->fileName, GetFileExInfoStandard, &fileAttrib);
GetFileAttributesExW(bd->fileName.AsString().ToWchar(), GetFileExInfoStandard, &fileAttrib);
FILETIME &fileTime = fileAttrib.ftLastWriteTime;
// If this texture has been modified since the last export, delete the old version but reuse the key
@ -652,7 +651,7 @@ plBitmap *plBitmapCreator::ICreateTexture( plBitmapData *bd, const plLocation &l
// Texture reuse optimization
WIN32_FILE_ATTRIBUTE_DATA fileAttrib;
GetFileAttributesEx(bd->fileName, GetFileExInfoStandard, &fileAttrib);
GetFileAttributesExW(bd->fileName.AsString().ToWchar(), GetFileExInfoStandard, &fileAttrib);
FILETIME &fileTime = fileAttrib.ftLastWriteTime;
texture->SetModifiedTime(fileTime.dwLowDateTime, fileTime.dwHighDateTime);

View File

@ -40,6 +40,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "plFileSystem.h"
class BitmapInfo;
class Bitmap;
class plBitmap;
@ -59,7 +61,7 @@ public:
kClampV = 0x02
};
const char *fileName;
plFileName fileName;
uint32_t texFlags;
uint32_t createFlags;
float detailDropoffStart;
@ -76,7 +78,6 @@ public:
plBitmapData()
{
fileName = nil;
texFlags = 0;
createFlags = 0;
detailDropoffStart = detailDropoffStop = 0.f;
@ -119,7 +120,7 @@ class plBitmapCreator
plBitmap *ICreateTexture( plBitmapData *bd, const plLocation &loc, int clipID = -1 );
plMipmap *ICreateBitmap( plBitmapData *bd );
void ICheckOutBitmap( BitmapInfo *bInfo, Bitmap *bm, const char *fileName );
void ICheckOutBitmap( BitmapInfo *bInfo, Bitmap *bm, const plFileName &fileName );
int IResampBitmap( Bitmap *bm, plMipmap &hBitmap );
int ICopyBitmap( Bitmap *bm, plMipmap &hBitmap );
int IInvertAlpha( plMipmap &hBitmap );

View File

@ -1062,7 +1062,7 @@ plLayer *plLayerConverter::IAssignTexture( plBitmapData *bd, plMaxNode *maxNode,
{
if( upperLayer )
{
if( fErrorMsg->Set( !( fWarned & kWarnedUpperTextureMissing ), "Plasma Export Error", sWarnUpperTextureMissing, maxNode->GetName(), bd->fileName ).CheckAskOrCancel() )
if( fErrorMsg->Set( !( fWarned & kWarnedUpperTextureMissing ), "Plasma Export Error", sWarnUpperTextureMissing, maxNode->GetName(), bd->fileName.AsString().c_str() ).CheckAskOrCancel() )
fWarned |= kWarnedUpperTextureMissing;
fErrorMsg->Set( false );
@ -1071,7 +1071,7 @@ plLayer *plLayerConverter::IAssignTexture( plBitmapData *bd, plMaxNode *maxNode,
}
else
{
if( fErrorMsg->Set( !( fWarned & kWarnedNoBaseTexture ), "Plasma Export Error", sWarnBaseTextureMissing, maxNode->GetName(), bd->fileName ).CheckAskOrCancel() )
if( fErrorMsg->Set( !( fWarned & kWarnedNoBaseTexture ), "Plasma Export Error", sWarnBaseTextureMissing, maxNode->GetName(), bd->fileName.AsString().c_str() ).CheckAskOrCancel() )
fWarned |= kWarnedNoBaseTexture;
fErrorMsg->Set( false );

View File

@ -58,7 +58,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "hsExceptionStack.h"
#include "hsExceptions.h"
#include "plFile/plFileUtils.h"
#include "hsStream.h"
// Windows

View File

@ -45,7 +45,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "hsExceptionStack.h"
#include "plFile/plFileUtils.h"
#include "hsStream.h"
#include <bitmap.h>
@ -319,19 +318,13 @@ int HSExport2::DoExport(const TCHAR *name,ExpInterface *ei,Interface *gi, BOOL s
// We want to incorporate any SDL changes since the last export, so we DeInit()
// and re-initialize.
char buf[MAX_PATH];
strcpy(buf, plMaxConfig::GetClientPath());
strcat(buf, "sdl");
plSDLMgr::GetInstance()->SetSDLDir(buf);
plSDLMgr::GetInstance()->SetSDLDir(plFileName::Join(plMaxConfig::GetClientPath(), "sdl"));
plSDLMgr::GetInstance()->DeInit();
plSDLMgr::GetInstance()->Init();
// Add disk source for writing
char datPath[MAX_PATH];
strcpy(datPath, out_path);
plFileUtils::AddSlash(datPath);
strcat(datPath, "dat\\");
CreateDirectory(datPath, NULL);
plFileName datPath = plFileName::Join(out_path, "dat");
CreateDirectoryW(datPath.AsString().ToWchar(), NULL);
plPluginResManager::ResMgr()->SetDataPath(datPath);
if (hsgResMgr::Reset())

View File

@ -58,6 +58,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "MaxMain/resource.h"
#include "MaxMain/plMaxCFGFile.h"
#include "MaxMain/plMaxNode.h"
#include "plFileSystem.h"
extern HINSTANCE hInstance;
@ -69,7 +70,7 @@ protected:
bool fPhysicalsOnly;
bool fLightMap;
char fExportPage[256];
char fExportSourceDir[MAX_PATH];
plFileName fExportSourceDir;
bool fExporting;
bool fAutoExporting;
bool fExportFile;
@ -108,30 +109,34 @@ public:
plExportDlgImp::plExportDlgImp() : fDlg(NULL), fPreshade(true), fPhysicalsOnly(false), fLightMap(true), fLastExportTime(0), fExporting(false), fAutoExporting(false)
{
const char* path = plMaxConfig::GetPluginIni();
fXPos = GetPrivateProfileInt("Export", "X", 0, path);
fYPos = GetPrivateProfileInt("Export", "Y", 30, path);
plFileName path = plMaxConfig::GetPluginIni();
fXPos = GetPrivateProfileIntW(L"Export", L"X", 0, path.AsString().ToWchar());
fYPos = GetPrivateProfileIntW(L"Export", L"Y", 30, path.AsString().ToWchar());
GetPrivateProfileString("Export", "Dir", "", fExportSourceDir, sizeof(fExportSourceDir), path);
wchar_t buffer[MAX_PATH];
GetPrivateProfileStringW(L"Export", L"Dir", L"", buffer, sizeof(buffer),
path.AsString().ToWchar());
fExportSourceDir = plString::FromWchar(buffer);
memset(fExportPage, 0, sizeof(fExportPage));
}
BOOL WritePrivateProfileInt(LPCSTR lpAppName, LPCSTR lpKeyName, int val, LPCSTR lpFileName)
BOOL WritePrivateProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName, int val, LPCWSTR lpFileName)
{
char buf[30];
itoa(val, buf, 10);
wchar_t buf[12];
snwprintf(buf, 12, L"%d", val);
return WritePrivateProfileString(lpAppName, lpKeyName, buf, lpFileName);
return WritePrivateProfileStringW(lpAppName, lpKeyName, buf, lpFileName);
}
plExportDlgImp::~plExportDlgImp()
{
const char* path = plMaxConfig::GetPluginIni();
WritePrivateProfileInt("Export", "X", fXPos, path);
WritePrivateProfileInt("Export", "Y", fYPos, path);
plFileName path = plMaxConfig::GetPluginIni();
WritePrivateProfileIntW(L"Export", L"X", fXPos, path.AsString().ToWchar());
WritePrivateProfileIntW(L"Export", L"Y", fYPos, path.AsString().ToWchar());
WritePrivateProfileString("Export", "Dir", fExportSourceDir, path);
WritePrivateProfileStringW(L"Export", L"Dir", fExportSourceDir.AsString().ToWchar(),
path.AsString().ToWchar());
}
plExportDlg& plExportDlg::Instance()
@ -185,8 +190,8 @@ void plExportDlgImp::IGetRadio(HWND hDlg)
void plExportDlgImp::IInitDlg(HWND hDlg)
{
// Set the client path
const char* path = plMaxConfig::GetClientPath(false, true);
SetDlgItemText(hDlg, IDC_CLIENT_PATH, path);
plFileName path = plMaxConfig::GetClientPath(false, true);
SetDlgItemText(hDlg, IDC_CLIENT_PATH, path.AsString().c_str());
// Set the preshade button
CheckDlgButton(hDlg, IDC_PRESHADE_CHECK, fPreshade ? BST_CHECKED : BST_UNCHECKED);
@ -232,7 +237,7 @@ void plExportDlgImp::IInitDlg(HWND hDlg)
CheckRadioButton(hDlg, IDC_RADIO_FILE, IDC_RADIO_DIR, IDC_RADIO_FILE);
IGetRadio(hDlg);
SetDlgItemText(hDlg, IDC_EXPORT_PATH, fExportSourceDir);
SetDlgItemTextW(hDlg, IDC_EXPORT_PATH, fExportSourceDir.AsString().ToWchar());
}
#include "plFile/plBrowseFolder.h"
@ -280,9 +285,9 @@ BOOL plExportDlgImp::DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
else if (resID == IDC_DIR)
{
// Get a new client path
const char* path = plMaxConfig::GetClientPath(true);
if (path)
SetDlgItemText(hDlg, IDC_CLIENT_PATH, path);
plFileName path = plMaxConfig::GetClientPath(true);
if (path.IsValid())
SetDlgItemText(hDlg, IDC_CLIENT_PATH, path.AsString().c_str());
return TRUE;
}
else if (resID == IDC_RADIO_FILE || resID == IDC_RADIO_DIR)
@ -292,11 +297,10 @@ BOOL plExportDlgImp::DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
}
else if (resID == IDC_BROWSE_EXPORT)
{
plBrowseFolder::GetFolder(fExportSourceDir,
fExportSourceDir,
"Choose the source directory",
hDlg);
SetDlgItemText(hDlg, IDC_EXPORT_PATH, fExportSourceDir);
fExportSourceDir = plBrowseFolder::GetFolder(fExportSourceDir,
"Choose the source directory",
hDlg);
SetDlgItemTextW(hDlg, IDC_EXPORT_PATH, fExportSourceDir.AsString().ToWchar());
return TRUE;
}
}
@ -347,7 +351,7 @@ void plExportDlgImp::IDoExport()
IExportCurrentFile(exportPath);
else
{
hsFolderIterator sourceDir(fExportSourceDir);
hsFolderIterator sourceDir(fExportSourceDir.AsString().c_str());
while (sourceDir.NextFileSuffix(".max"))
{
char exportFile[MAX_PATH];

View File

@ -42,6 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "hsResMgr.h"
#include "plFileSystem.h"
#include "MaxComponent/plComponentBase.h"
#include "plMaxNode.h"
@ -94,7 +95,7 @@ ClassDesc* GetGUPDesc() { return &PlasmaMaxCD; }
//////////////////////////////////////////
// This function is from the console. This dummy version is here so that plNetLinkingMgr will build.
plKey FindSceneObjectByName(const char* name, const char* ageName, char* statusStr, bool subString)
plKey FindSceneObjectByName(const plString& name, const plString& ageName, char* statusStr, bool subString)
{
return nil;
}
@ -221,16 +222,15 @@ DWORD PlasmaMax::Start()
// Setup the localization mgr
// Dirty hacks are because Cyan sucks...
const char* pathTemp = plMaxConfig::GetClientPath(false, true);
if (pathTemp == nil)
plFileName pathTemp = plMaxConfig::GetClientPath(false, true);
if (!pathTemp.IsValid())
{
hsMessageBox("PlasmaMAX2.ini is missing or invalid", "Plasma/2.0 Error", hsMessageBoxNormal);
}
else
}
else
{
std::string clientPath(pathTemp);
clientPath += "dat";
pfLocalizationMgr::Initialize(clientPath.c_str());
plFileName clientPath = plFileName::Join(pathTemp, "dat");
pfLocalizationMgr::Initialize(clientPath);
}
return GUPRESULT_KEEP;

View File

@ -168,16 +168,15 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved)
plPythonMgr::Instance().LoadPythonFiles();
const char *clientPath = plMaxConfig::GetClientPath(false, true);
if (clientPath)
plFileName clientPath = plMaxConfig::GetClientPath(false, true);
if (clientPath.IsValid())
{
char oldCwd[kFolderIterator_MaxPath];
_getcwd(oldCwd, sizeof(oldCwd));
_chdir(clientPath);
plFileName oldCwd = plFileSystem::GetCWD();
plFileSystem::SetCWD(clientPath);
plSDLMgr::GetInstance()->Init();
_chdir(oldCwd);
plFileSystem::SetCWD(oldCwd);
}
// Initialize the ResManager
plResManager* pRmgr = new plPluginResManager;
hsgResMgr::Init(pRmgr);

View File

@ -823,20 +823,19 @@ void plAgeDescInterface::IEnablePageControls(bool enable)
EnableWindow(GetDlgItem(fhDlg, IDC_ADM_VOLATILE), enable);
}
bool plAgeDescInterface::IGetLocalAgePath(char *path)
plFileName plAgeDescInterface::IGetLocalAgePath()
{
// Get the path to the description folder
const char *plasmaPath = plMaxConfig::GetClientPath();
if (!plasmaPath)
return false;
plFileName plasmaPath = plMaxConfig::GetClientPath();
if (!plasmaPath.IsValid())
return "";
strcpy(path, plasmaPath);
strcat(path, plAgeDescription::kAgeDescPath);
plFileName path = plFileName::Join(plasmaPath, plAgeDescription::kAgeDescPath);
// Make sure the desc folder exists
CreateDirectory(path, NULL);
plFileSystem::CreateDir(path);
return true;
return path;
}
int plAgeDescInterface::IFindAge(const char* ageName, std::vector<plAgeFile*>& ageFiles)
@ -856,10 +855,10 @@ void plAgeDescInterface::IGetAgeFiles(std::vector<plAgeFile*>& ageFiles)
// Make list of "local" ages. This might contain copies of those in AssetMan, so we make the
// list first and take out the ones that are in AssetMan
char localPath[MAX_PATH];
if (IGetLocalAgePath(localPath))
plFileName localPath = IGetLocalAgePath();
if (localPath.IsValid())
{
hsFolderIterator ageFolder(localPath);
hsFolderIterator ageFolder(localPath.AsString().c_str());
while (ageFolder.NextFileSuffix(".age"))
{
ageFolder.GetPathAndName(agePath);
@ -960,22 +959,25 @@ void plAgeDescInterface::IFillAgeTree( void )
BOOL CALLBACK NewAgeDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static char *name = nil;
static plString *name = nil;
switch (msg)
{
case WM_INITDIALOG:
name = (char*)lParam;
SetWindowText(hDlg, name);
name = reinterpret_cast<plString *>(lParam);
SetWindowText(hDlg, name->c_str());
return TRUE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDOK)
{
if (GetDlgItemText(hDlg, IDC_AGE_NAME, name, _MAX_FNAME) > 0)
char buffer[_MAX_FNAME];
if (GetDlgItemText(hDlg, IDC_AGE_NAME, buffer, _MAX_FNAME) > 0) {
EndDialog(hDlg, 1);
else
*name = buffer;
} else {
EndDialog(hDlg, 0);
}
return TRUE;
}
else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDCANCEL)
@ -1008,7 +1010,7 @@ BOOL CALLBACK NewSeqNumberProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam
case WM_INITDIALOG:
SetDlgItemText( hDlg, IDC_INFOMSG, msg1 );
SetDlgItemText( hDlg, IDC_ADMMSG, msg2 );
sprintf( msg3, "Age: %s", (char *)lParam );
sprintf( msg3, "Age: %s", (const char *)lParam );
SetDlgItemText( hDlg, IDC_AGEMSG, msg3 );
return TRUE;
@ -1034,29 +1036,28 @@ void plAgeDescInterface::INewAge()
makeAsset = false;
#endif
char newAssetFilename[ MAX_PATH ];
plFileName newAssetFilename;
#ifdef MAXASS_AVAILABLE
if (!fAssetManIface)
makeAsset = false;
#endif
if( !IGetLocalAgePath( newAssetFilename ) )
newAssetFilename = IGetLocalAgePath();
if (!newAssetFilename.IsValid())
return;
char name[_MAX_FNAME];
strcpy(name, "New Age Name");
plString name = "New Age Name";
// Get the name of the new age from the user
int ret = DialogBoxParam(hInstance,
MAKEINTRESOURCE(IDD_AGE_NAME),
GetCOREInterface()->GetMAXHWnd(),
NewAgeDlgProc,
(LPARAM)name);
(LPARAM)&name);
if (ret != 1)
return;
strcat(newAssetFilename, name);
strcat(newAssetFilename, ".age");
newAssetFilename = plFileName::Join(newAssetFilename, name + ".age");
#ifdef MAXASS_AVAILABLE
if( !makeAsset )
@ -1066,7 +1067,7 @@ void plAgeDescInterface::INewAge()
fForceSeqNumLocal = false;
if( makeAsset )
(*fAssetManIface)->AddNewAsset(newAssetFilename);
(*fAssetManIface)->AddNewAsset(newAssetFilename.AsString().c_str());
#endif
// Refresh the tree now
@ -1075,15 +1076,14 @@ void plAgeDescInterface::INewAge()
void plAgeDescInterface::INewPage()
{
char name[256];
strcpy(name, "New Page Name");
plString name = "New Page Name";
// Get the name of the new age from the user
int ret = DialogBoxParam(hInstance,
MAKEINTRESOURCE(IDD_AGE_NAME),
GetCOREInterface()->GetMAXHWnd(),
NewAgeDlgProc,
(LPARAM)name);
(LPARAM)&name);
if (ret != 1)
return;
@ -1095,12 +1095,12 @@ void plAgeDescInterface::INewPage()
{
char pageName[256];
ListBox_GetText(hPages, i, pageName);
if (!strcmp(pageName, name))
if (!name.CompareI(pageName))
return;
}
// Add the new page and select it
int idx = ListBox_AddString(hPages, name);
int idx = ListBox_AddString(hPages, name.c_str());
// Choose a new sequence suffix for it
plAgePage *newPage = new plAgePage( name, IGetFreePageSeqSuffix( hPages ), 0 );
@ -1131,7 +1131,7 @@ uint32_t plAgeDescInterface::IGetFreePageSeqSuffix( HWND pageCombo )
return searchSeq;
}
void plAgeDescInterface::ISaveCurAge( const char *path, bool checkSeqNum )
void plAgeDescInterface::ISaveCurAge( const plFileName &path, bool checkSeqNum )
{
hsUNIXStream s;
if( !s.Open( path, "wt" ) )
@ -1197,7 +1197,7 @@ void plAgeDescInterface::ICheckSequenceNumber( plAgeDescription &aged )
// Ask about the sequence #
int ret = DialogBoxParam( hInstance, MAKEINTRESOURCE( IDD_AGE_SEQNUM ),
GetCOREInterface()->GetMAXHWnd(),
NewSeqNumberProc, (LPARAM)aged.GetAgeName() );
NewSeqNumberProc, (LPARAM)aged.GetAgeName().c_str() );
if( ret == IDYES )
{
aged.SetSequencePrefix( IGetNextFreeSequencePrefix( false ) );
@ -1211,7 +1211,7 @@ void plAgeDescInterface::ICheckSequenceNumber( plAgeDescription &aged )
}
}
void plAgeDescInterface::ILoadAge( const char *path, bool checkSeqNum )
void plAgeDescInterface::ILoadAge( const plFileName &path, bool checkSeqNum )
{
ISetControlDefaults();
@ -1221,15 +1221,14 @@ void plAgeDescInterface::ILoadAge( const char *path, bool checkSeqNum )
plAgeDescription aged( path );
// Get the name of the age
char ageName[_MAX_FNAME];
_splitpath( path, nil, nil, ageName, nil );
plString ageName = path.GetFileNameNoExt();
// Check the sequence prefix #
if( checkSeqNum )
ICheckSequenceNumber( aged );
char str[ _MAX_FNAME + 30 ];
sprintf( str, "Description for %s", ageName );
sprintf( str, "Description for %s", ageName.c_str() );
SetDlgItemText( fhDlg, IDC_AGEDESC, str );
// Set up the Dlgs
@ -1288,7 +1287,7 @@ void plAgeDescInterface::ILoadAge( const char *path, bool checkSeqNum )
HWND hPage = GetDlgItem(fhDlg, IDC_PAGE_LIST);
while( ( page = aged.GetNextPage() ) != nil )
{
int idx = ListBox_AddString( hPage, page->GetName() );
int idx = ListBox_AddString( hPage, page->GetName().c_str() );
ListBox_SetItemData( hPage, idx, (LPARAM)new plAgePage( *page ) );
}
}

View File

@ -101,10 +101,10 @@ protected:
// Save the settings for the last age and load the settings for the currently one
void IUpdateCurAge();
void ISaveCurAge( const char *path, bool checkSeqNum = false );
void ILoadAge( const char *path, bool checkSeqNum = false );
void ISaveCurAge( const plFileName &path, bool checkSeqNum = false );
void ILoadAge( const plFileName &path, bool checkSeqNum = false );
static bool IGetLocalAgePath(char *path);
static plFileName IGetLocalAgePath();
// Fill out the age tree view
void IFillAgeTree( void );

View File

@ -42,6 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "hsWindows.h"
#include "plFileSystem.h"
#include <max.h>
#pragma hdrstop
@ -49,53 +50,42 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMaxCFGFile.h"
#include "plFile/plBrowseFolder.h"
const char *plMaxConfig::GetPluginIni()
plFileName plMaxConfig::GetPluginIni()
{
// Get the plugin CFG dir
static char plugDir[MAX_PATH];
strcpy(plugDir, GetCOREInterface()->GetDir(APP_PLUGCFG_DIR));
strcat(plugDir, "\\PlasmaMAX2.ini");
return plugDir;
return plFileName::Join(GetCOREInterface()->GetDir(APP_PLUGCFG_DIR), "PlasmaMAX2.ini");
}
const char *plMaxConfig::GetClientPath(bool getNew, bool quiet)
plFileName plMaxConfig::GetClientPath(bool getNew, bool quiet)
{
static char plasmaPath[MAX_PATH];
plasmaPath[0] = '\0';
// Get the plugin CFG dir
const char *plugDir = GetPluginIni();
plFileName plugDir = GetPluginIni();
// Get the saved path
uint32_t len = GetPrivateProfileString("SceneViewer", "Directory", "", plasmaPath, MAX_PATH, plugDir);
wchar_t buffer[MAX_PATH];
uint32_t len = GetPrivateProfileStringW(L"SceneViewer", L"Directory", L"", buffer, MAX_PATH,
plugDir.AsString().ToWchar());
plFileName plasmaPath = plString::FromWchar(buffer);
// If we didn't find a path, or we want a new one, ask the user for one
if ((len == 0 || getNew) && !quiet)
{
// If the user selects one, save it
if (plBrowseFolder::GetFolder(plasmaPath, plasmaPath, "Specify your client folder"))
WritePrivateProfileString("SceneViewer", "Directory", plasmaPath, plugDir);
plasmaPath = plBrowseFolder::GetFolder(plasmaPath, "Specify your client folder");
if (plasmaPath.IsValid())
WritePrivateProfileStringW(L"SceneViewer", L"Directory", plasmaPath.AsString().ToWchar(),
plugDir.AsString().ToWchar());
}
// Return the path if we got one
if (plasmaPath[0] != '\0')
{
// Make sure the path ends with a slash
char lastChar = plasmaPath[strlen(plasmaPath)-1];
if (lastChar != '/' && lastChar != '\\')
strcat(plasmaPath, "\\");
return plasmaPath;
}
return nil;
return plasmaPath;
}
void plMaxConfig::SetClientPath(const char *path)
void plMaxConfig::SetClientPath(const plFileName &path)
{
const char *plugDir = GetPluginIni();
WritePrivateProfileString("SceneViewer", "Directory", path, plugDir);
plFileName plugDir = GetPluginIni();
WritePrivateProfileStringW(L"SceneViewer", L"Directory", path.AsString().ToWchar(),
plugDir.AsString().ToWchar());
}
bool plMaxConfig::AssetManInterfaceDisabled()
@ -105,13 +95,14 @@ bool plMaxConfig::AssetManInterfaceDisabled()
if (!inited)
{
char configstr[MAX_PATH];
wchar_t configstr[MAX_PATH];
configstr[0] = '\0';
const char *plugDir = GetPluginIni();
uint32_t len = GetPrivateProfileString("AssetMan", "Disable", "", configstr, MAX_PATH, plugDir);
if (strcmp(configstr, "1") == 0 || stricmp(configstr, "true") == 0)
plFileName plugDir = GetPluginIni();
uint32_t len = GetPrivateProfileStringW(L"AssetMan", L"Disable", L"", configstr, MAX_PATH,
plugDir.AsString().ToWchar());
if (wcscmp(configstr, L"1") == 0 || wcsicmp(configstr, L"true") == 0)
disabled = true;
else
disabled = false;

View File

@ -39,18 +39,21 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021
*==LICENSE==*/
class plFileName;
namespace plMaxConfig
{
// Get the full path to the ini file to write settings to
const char *GetPluginIni();
plFileName GetPluginIni();
// Gets the path to the Plasma working directory
// If the user hasn't set one before, it prompts them to
// Set getNew to true to force the user to set a new path
// If a path is returned, it will end with a slash
const char *GetClientPath(bool getNew=false, bool quiet=false);
plFileName GetClientPath(bool getNew=false, bool quiet=false);
// For the rare case where you need to set the client path manually
void SetClientPath(const char *path);
void SetClientPath(const plFileName &path);
// option to disable the plugin's assetman interface
bool AssetManInterfaceDisabled();

View File

@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/plKey.h"
#include "hsTemplates.h"
#include "hsWindows.h"
#include "plFileSystem.h"
#include <iMenuMan.h>
#include <max.h>
@ -324,7 +325,7 @@ void plCreateMenu()
bool newlyRegistered = pMenuMan->RegisterMenuBarContext(kMyMenuContextId, kMenuName);
// Is the Max menu version the most recent?
bool wrongVersion = GetPrivateProfileInt("Menu", "Version", 0, plMaxConfig::GetPluginIni()) < kMenuVersion;
bool wrongVersion = GetPrivateProfileIntW(L"Menu", L"Version", 0, plMaxConfig::GetPluginIni().AsString().ToWchar()) < kMenuVersion;
if (wrongVersion)
{
// Delete the old version of the menu
@ -333,8 +334,9 @@ void plCreateMenu()
pMenuMan->UnRegisterMenu(oldMenu);
// Update the menu version
char buf[30];
WritePrivateProfileString("Menu", "Version", itoa(kMenuVersion, buf, 10), plMaxConfig::GetPluginIni());
wchar_t buf[12];
snwprintf(buf, arrsize(buf), L"%d", kMenuVersion);
WritePrivateProfileStringW(L"Menu", L"Version", buf, plMaxConfig::GetPluginIni().AsString().ToWchar());
}
if (wrongVersion || newlyRegistered)

View File

@ -600,22 +600,19 @@ void plPythonMgr::IAddGrassComponent(plAutoUIBlock *autoUI, PyObject *objTuple,
void plPythonMgr::LoadPythonFiles()
{
const char *clientPath = plMaxConfig::GetClientPath(false, true);
if (clientPath)
plFileName clientPath = plMaxConfig::GetClientPath(false, true);
if (clientPath.IsValid())
{
char oldCwd[MAX_PATH];
_getcwd(oldCwd, sizeof(oldCwd));
_chdir(clientPath);
plFileName oldCwd = plFileSystem::GetCWD();
plFileSystem::SetCWD(clientPath);
// Get the path to the Python subdirectory of the client
char pythonPath[MAX_PATH];
strcpy(pythonPath, clientPath);
strcat(pythonPath, "Python");
plFileName pythonPath = plFileName::Join(clientPath, "Python");
PythonInterface::initPython();
// Iterate through all the Python files in the folder
hsFolderIterator folder(pythonPath);
hsFolderIterator folder(pythonPath.AsString().c_str());
while (folder.NextFileSuffix(".py"))
{
// Get the filename without the ".py" (module name)
@ -628,7 +625,7 @@ void plPythonMgr::LoadPythonFiles()
PythonInterface::finiPython();
_chdir(oldCwd);
plFileSystem::SetCWD(oldCwd);
}
}