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

Merge pull request #275 from zrax/file-utils

Unify filesystem utilities
This commit is contained in:
2013-01-22 16:27:26 -08:00
148 changed files with 1545 additions and 4225 deletions

View File

@ -60,8 +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"
#include "hsMatrix44.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

@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "plgDispatch.h"
#include "plFile/hsFiles.h"
#include "hsTemplates.h"
#include "plComponent.h"
@ -1449,8 +1448,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 );
}
@ -1464,19 +1463,17 @@ BOOL plGUIDialogProc::DlgProc( TimeValue t, IParamMap2 *pmap, HWND hWnd, UINT ms
case WM_INITDIALOG:
// Load the age combo box
{
int i, idx, selIdx = 0;
HWND ageCombo = GetDlgItem( hWnd, IDC_GUIDLG_AGE );
hsTArray<char *> ageList;
int i, idx, selIdx = 0;
HWND ageCombo = GetDlgItem( hWnd, IDC_GUIDLG_AGE );
plAgeDescInterface::BuildAgeFileList( ageList );
hsTArray<plFileName> ageList = plAgeDescInterface::BuildAgeFileList();
ComboBox_ResetContent( ageCombo );
for( i = 0; i < ageList.GetCount(); i++ )
{
char ageName[ _MAX_FNAME ];
_splitpath( ageList[ i ], nil, nil, ageName, nil );
plString ageName = ageList[i].GetFileNameNoExt();
idx = ComboBox_AddString( ageCombo, ageName );
if( stricmp( ageName, pmap->GetParamBlock()->GetStr( plGUIDialogComponent::kRefAgeName ) ) == 0 )
idx = ComboBox_AddString( ageCombo, ageName.c_str() );
if( ageName.CompareI( pmap->GetParamBlock()->GetStr( plGUIDialogComponent::kRefAgeName ) ) == 0 )
{
selIdx = idx;
}

View File

@ -43,8 +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"
#include "plMiscComponents.h"
@ -237,8 +235,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() );
}
@ -260,8 +258,7 @@ protected:
HWND hAgeCombo = GetDlgItem(fhDlg, IDC_COMP_LOCATION_AGECOMBO);
IClearAges( hAgeCombo );
hsTArray<char *> ageFiles;
plAgeDescInterface::BuildAgeFileList( ageFiles );
hsTArray<plFileName> ageFiles = plAgeDescInterface::BuildAgeFileList();
const char *curAge = fPB->GetStr(plPageInfoComponent::kInfoAge);
if (!curAge || *curAge == '\0')
@ -269,14 +266,13 @@ protected:
for( int i = 0; i < ageFiles.GetCount(); i++ )
{
char ageName[_MAX_FNAME];
_splitpath( ageFiles[ i ], nil, nil, ageName, nil );
plString ageName = ageFiles[i].GetFileNameNoExt();
int idx = ComboBox_AddString( hAgeCombo, ageName );
int idx = ComboBox_AddString( hAgeCombo, ageName.c_str() );
// Store the pathas the item data for later (so don't free it yet!)
ComboBox_SetItemData( hAgeCombo, idx, (LPARAM)ageFiles[ i ] );
ComboBox_SetItemData( hAgeCombo, idx, (LPARAM)ageFiles[i].AsString().c_str() );
if( !strcmp( ageName, curAge ) )
if (ageName == curAge)
ComboBox_SetCurSel( hAgeCombo, idx );
}
@ -576,33 +572,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 +620,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 +646,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 +692,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 +713,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 +774,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 +786,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

@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "HeadSpin.h"
#include "plFile/hsFiles.h"
#include "hsResMgr.h"
#include "plComponentBase.h"
@ -318,30 +317,23 @@ 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);
while (ageFolder.NextFileSuffix(".age"))
std::vector<plFileName> ages = plFileSystem::ListDir(agePath, "*.age");
for (auto iter = ages.begin(); iter != ages.end(); ++iter)
{
char ageFile[MAX_PATH];
ageFolder.GetPathAndName(ageFile);
int idx = SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)iter->GetFileNameNoExt().c_str());
char name[_MAX_FNAME];
_splitpath(ageFile, nil, nil, name, nil);
int idx = SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)name);
if (strcmp(name, savedName) == 0)
if (iter->GetFileNameNoExt() == savedName)
SendMessage(hAge, CB_SETCURSEL, idx, 0);
}
}
@ -355,30 +347,22 @@ 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);
while (ageFolder.NextFileSuffix(".age"))
std::vector<plFileName> ages = plFileSystem::ListDir(agePath, "*.age");
for (auto iter = ages.begin(); iter != ages.end(); ++iter)
{
char ageFile[MAX_PATH];
ageFolder.GetPathAndName(ageFile);
int idx = SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)iter->GetFileNameNoExt().c_str());
char name[_MAX_FNAME];
_splitpath(ageFile, nil, nil, name, nil);
int idx = SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)name);
if (strcmp(name, savedName) == 0)
if (iter->GetFileNameNoExt() == savedName)
SendMessage(hAge, CB_SETCURSEL, idx, 0);
}
}

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

@ -42,6 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "hsWindows.h"
#include "hsStream.h"
#include <bitmap.h>
#include <iparamb2.h>
@ -58,6 +59,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 +71,7 @@ protected:
bool fPhysicalsOnly;
bool fLightMap;
char fExportPage[256];
char fExportSourceDir[MAX_PATH];
plFileName fExportSourceDir;
bool fExporting;
bool fAutoExporting;
bool fExportFile;
@ -108,30 +110,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 +191,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 +238,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 +286,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 +298,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;
}
}
@ -326,8 +331,6 @@ void plExportDlgImp::IExportCurrentFile(const char* exportPath)
GetCOREInterface()->ExportToFile(exportPath);
}
#include "plFile/hsFiles.h"
void plExportDlgImp::IDoExport()
{
fExporting = true;
@ -347,13 +350,10 @@ void plExportDlgImp::IDoExport()
IExportCurrentFile(exportPath);
else
{
hsFolderIterator sourceDir(fExportSourceDir);
while (sourceDir.NextFileSuffix(".max"))
std::vector<plFileName> sources = plFileSystem::ListDir(fExportSourceDir, "*.max");
for (auto iter = sources.begin(); iter != sources.end(); ++iter)
{
char exportFile[MAX_PATH];
sourceDir.GetPathAndName(exportFile);
if (GetCOREInterface()->LoadFromFile(exportFile))
if (GetCOREInterface()->LoadFromFile(iter->AsString().c_str()))
IExportCurrentFile(exportPath);
}
}
@ -386,18 +386,18 @@ void plExportDlgImp::Show()
fDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EXPORT), GetCOREInterface()->GetMAXHWnd(), ForwardDlgProc);
}
static bool IsExcluded(const char* fileName, std::vector<std::string>& excludeFiles)
static bool IsExcluded(const plFileName& fileName, std::vector<plFileName>& excludeFiles)
{
for (int i = 0; i < excludeFiles.size(); i++)
{
if (!strcmp(fileName, excludeFiles[i].c_str()))
if (fileName == excludeFiles[i])
return true;
}
return false;
}
static bool AutoExportDir(const char* inputDir, const char* outputDir, const char* groupFiles, std::vector<std::string>& excludeFiles)
static bool AutoExportDir(const char* inputDir, const char* outputDir, const plFileName& groupFiles, std::vector<plFileName>& excludeFiles)
{
bool exportedFile = false;
@ -413,37 +413,33 @@ static bool AutoExportDir(const char* inputDir, const char* outputDir, const cha
// Don't give missing bitmap warnings
TheManager->SetSilentMode(TRUE);
hsFolderIterator sourceDir(inputDir);
while (sourceDir.NextFileSuffix(".max"))
{
char exportFile[MAX_PATH];
sourceDir.GetPathAndName(exportFile);
if (IsExcluded(sourceDir.GetFileName(), excludeFiles))
std::vector<plFileName> sources = plFileSystem::ListDir(inputDir, "*.max");
for (auto iter = sources.begin(); iter != sources.end(); ++iter)
{
if (IsExcluded(iter->GetFileName(), excludeFiles))
continue;
// If we're doing grouped files, and this isn't one, keep looking
if (groupFiles && strncmp(sourceDir.GetFileName(), groupFiles, strlen(groupFiles)) != 0)
if (groupFiles.IsValid() && groupFiles != iter->GetFileName())
continue;
hsUNIXStream log;
if (log.Open(outputLog, "ab"))
{
log.WriteFmt("%s\r\n", sourceDir.GetFileName());
log.WriteFmt("%s\r\n", iter->GetFileName().c_str());
log.Close();
}
if (GetCOREInterface()->LoadFromFile(exportFile))
if (GetCOREInterface()->LoadFromFile(iter->AsString().c_str()))
{
sprintf(doneDir, "%s\\Done\\%s", inputDir, sourceDir.GetFileName());
MoveFileEx(exportFile, doneDir, MOVEFILE_REPLACE_EXISTING);
plFileSystem::Move(*iter, plFileName::Join(inputDir, "Done", iter->GetFileName()));
GetCOREInterface()->ExportToFile(outputFileName, TRUE);
exportedFile = true;
// If we're not doing grouped files, this is it, we exported our one file
if (!groupFiles)
if (!groupFiles.IsValid())
break;
}
}
@ -467,7 +463,7 @@ static void ShutdownMax()
PostMessage(GetCOREInterface()->GetMAXHWnd(), WM_CLOSE, 0, 0);
}
static void GetStringSection(const char* configFile, const char* keyName, std::vector<std::string>& strings)
static void GetFileNameSection(const char* configFile, const char* keyName, std::vector<plFileName>& strings)
{
char source[256];
GetPrivateProfileString("Settings", keyName, "", source, sizeof(source), configFile);
@ -502,18 +498,18 @@ void plExportDlgImp::StartAutoExport()
hsMessageBox_SuppressPrompts = true;
// Files to ignore
std::vector<std::string> excludeFiles;
GetStringSection(configFile, "ExcludeFiles", excludeFiles);
std::vector<plFileName> excludeFiles;
GetFileNameSection(configFile, "ExcludeFiles", excludeFiles);
//
// Get the file substrings to export in one session
//
std::vector<std::string> groupedFiles;
GetStringSection(configFile, "GroupedFiles", groupedFiles);
std::vector<plFileName> groupedFiles;
GetFileNameSection(configFile, "GroupedFiles", groupedFiles);
for (int i = 0; i < groupedFiles.size(); i++)
{
if (AutoExportDir(inputDir, outputDir, groupedFiles[i].c_str(), excludeFiles))
if (AutoExportDir(inputDir, outputDir, groupedFiles[i], excludeFiles))
{
ShutdownMax();
fAutoExporting = false;
@ -521,7 +517,7 @@ void plExportDlgImp::StartAutoExport()
}
}
if (AutoExportDir(inputDir, outputDir, NULL, excludeFiles))
if (AutoExportDir(inputDir, outputDir, "", excludeFiles))
{
ShutdownMax();
fAutoExporting = false;

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

@ -61,7 +61,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsColorRGBA.h"
#include "plgDispatch.h"
#include "hsFastMath.h"
#include "plFile/hsFiles.h"
#include "hsGeometry3.h"
#include "pnKeyedObject/plKey.h"
#include "plLoadMask.h"
@ -71,6 +70,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStream.h"
#include "hsStringTokenizer.h"
#include "hsTemplates.h"
#include "plFileSystem.h"
// Windows
#include "hsWindows.h"

View File

@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "HeadSpin.h"
#include "plFile/hsFiles.h"
#include "hsTemplates.h"
#include "MaxComponent/plComponentMgr.h"
@ -168,16 +167,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

@ -40,14 +40,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "HeadSpin.h"
#include "plFile/hsFiles.h"
#include "hsStream.h"
#include "hsTemplates.h"
#include "hsWindows.h"
#include <max.h>
#include <string>
#include <vector>
#include "resource.h"
#pragma hdrstop
@ -63,8 +60,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#endif
#include "plMaxAccelerators.h"
using std::string;
extern HINSTANCE hInstance;
//// Tree Data Wrapper Class //////////////////////////////////////////////////
@ -72,19 +67,17 @@ extern HINSTANCE hInstance;
class plAgeFile
{
protected:
void IGetAgeName(const char* path)
void IGetAgeName(const plFileName& path)
{
char name[_MAX_FNAME];
_splitpath(path, nil, nil, name, nil);
fAgeName = name;
fAgeName = path.GetFileNameNoExt();
}
public:
#ifdef MAXASS_VAILABLE
jvUniqueId fAssetID;
#endif
string fPath;
string fAgeName;
plFileName fPath;
plString fAgeName;
enum Types
{
@ -93,17 +86,16 @@ public:
};
Types fType;
plAgeFile(Types type) : fType(type), fPath(nil) { }
plAgeFile(Types type, const char *path) : fType(type)
plAgeFile(Types type) : fType(type) { }
plAgeFile(Types type, const plFileName &path) : fPath(path), fType(type)
{
fPath = path;
IGetAgeName(path);
}
#ifdef MAXASS_AVAILABLE
plAgeFile(Types type, const char *path, jvUniqueId& id) : fType(type), fAssetID(id)
plAgeFile(Types type, const plFileName &path, jvUniqueId& id)
: fPath(path), fType(type), fAssetID(id)
{
fPath = path;
IGetAgeName(path);
}
#endif
@ -716,7 +708,7 @@ void plAgeDescInterface::IUpdateCurAge( void )
else
#endif
// Load the local age, also check its sequence #s
ILoadAge( currAge->fPath.c_str(), true );
ILoadAge( currAge->fPath, true );
}
static const int kDefaultCapacity = 10;
@ -823,20 +815,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)
@ -852,19 +843,15 @@ void plAgeDescInterface::IGetAgeFiles(std::vector<plAgeFile*>& ageFiles)
{
IClearAgeFiles(ageFiles);
char agePath[MAX_PATH];
// 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);
while (ageFolder.NextFileSuffix(".age"))
std::vector<plFileName> files = plFileSystem::ListDir(localPath, "*.age");
for (auto iter = files.begin(); iter != files.end(); ++iter)
{
ageFolder.GetPathAndName(agePath);
plAgeFile* age = new plAgeFile(plAgeFile::kLocalFile, agePath);
plAgeFile* age = new plAgeFile(plAgeFile::kLocalFile, *iter);
ageFiles.push_back(age);
}
}
@ -882,6 +869,7 @@ void plAgeDescInterface::IGetAgeFiles(std::vector<plAgeFile*>& ageFiles)
{
if( doneAssets.Find( (*assets)[ i ] ) == doneAssets.kMissingIndex )
{
char agePath[MAX_PATH];
if (assetMan->GetLatestVersionFile((*assets)[i], agePath, sizeof(agePath)))
{
plAgeFile* age = new plAgeFile(plAgeFile::kAssetFile, agePath, (*assets)[i]);
@ -912,16 +900,19 @@ void plAgeDescInterface::IClearAgeFiles(std::vector<plAgeFile*>& ageFiles)
ageFiles.clear();
}
void plAgeDescInterface::BuildAgeFileList( hsTArray<char *> &ageList )
hsTArray<plFileName> plAgeDescInterface::BuildAgeFileList()
{
std::vector<plAgeFile*> tempAgeFiles;
IGetAgeFiles(tempAgeFiles);
hsTArray<plFileName> ageList;
for (int i = 0; i < tempAgeFiles.size(); i++)
{
ageList.Push(hsStrcpy(tempAgeFiles[i]->fPath.c_str()));
ageList.Push(tempAgeFiles[i]->fPath);
delete tempAgeFiles[ i ];
}
return ageList;
}
//// IFillAgeTree /////////////////////////////////////////////////////////////
@ -960,22 +951,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 +1002,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 +1028,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 +1059,7 @@ void plAgeDescInterface::INewAge()
fForceSeqNumLocal = false;
if( makeAsset )
(*fAssetManIface)->AddNewAsset(newAssetFilename);
(*fAssetManIface)->AddNewAsset(newAssetFilename.AsString().c_str());
#endif
// Refresh the tree now
@ -1075,15 +1068,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 +1087,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 +1123,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 +1189,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 +1203,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 +1213,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 +1279,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 ) );
}
}
@ -1311,7 +1302,7 @@ uint32_t plAgeDescInterface::IGetNextFreeSequencePrefix( bool getReservedPrefix
for( i = 0; i < fAgeFiles.size(); i++ )
{
hsUNIXStream stream;
if( stream.Open( fAgeFiles[ i ]->fPath.c_str(), "rt" ) )
if( stream.Open( fAgeFiles[ i ]->fPath, "rt" ) )
{
ages[ i ].Read( &stream );
stream.Close();

View File

@ -84,7 +84,7 @@ public:
static BOOL CALLBACK ForwardDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static void BuildAgeFileList( hsTArray<char *> &ageList );
static hsTArray<plFileName> BuildAgeFileList();
protected:
static int IFindAge(const char* ageName, std::vector<plAgeFile*>& ageFiles);
@ -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

@ -40,9 +40,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "HeadSpin.h"
#include "plFile/hsFiles.h"
#include "plgDispatch.h"
#include "hsWindows.h"
#include "plFileSystem.h"
#include <Python.h>
#include <string>
@ -50,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <iparamb2.h>
#include <max.h>
#include <direct.h>
#pragma hdrstop
#include "plPythonMgr.h"
@ -229,7 +230,7 @@ void IExtractVisInfo(PyObject* tuple, int* id, std::vector<std::string>* vec)
}
}
bool plPythonMgr::IQueryPythonFile(char *fileName)
bool plPythonMgr::IQueryPythonFile(const char *fileName)
{
PyObject *module = PyImport_ImportModule(fileName);
if (module)
@ -596,39 +597,32 @@ void plPythonMgr::IAddGrassComponent(plAutoUIBlock *autoUI, PyObject *objTuple,
autoUI->AddPickGrassComponentButton(id, nil, paramName.c_str(), vid, vstates);
}
#include <direct.h>
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);
while (folder.NextFileSuffix(".py"))
std::vector<plFileName> pys = plFileSystem::ListDir(pythonPath, "*.py");
for (auto iter = pys.begin(); iter != pys.end(); ++iter)
{
// Get the filename without the ".py" (module name)
const char *fullFileName = folder.GetFileName();
char fileName[_MAX_FNAME];
_splitpath(fullFileName, NULL, NULL, fileName, NULL);
plString fileName = iter->GetFileNameNoExt();
IQueryPythonFile(fileName);
IQueryPythonFile(fileName.c_str());
}
PythonInterface::finiPython();
_chdir(oldCwd);
plFileSystem::SetCWD(oldCwd);
}
}

View File

@ -48,7 +48,7 @@ class plPythonMgr
protected:
plPythonMgr();
bool IQueryPythonFile(char *fileName);
bool IQueryPythonFile(const char *fileName);
void IAddBool(plAutoUIBlock *autoUI, PyObject *tuple, char *paramName, int id, int vid, std::vector<std::string>* vstates);
void IAddInt(plAutoUIBlock *autoUI, PyObject *tuple, char *paramName, int id, int vid, std::vector<std::string>* vstates);

View File

@ -279,8 +279,6 @@ void SceneSync::IClearDirtyRecur(plMaxNode *node)
IClearDirtyRecur((plMaxNode*)node->GetChildNode(i));
}
#include "../plFile/hsFiles.h"
void SceneSync::IDeletePath(const char *path)
{
// Remove any files in the dat directory

View File

@ -53,7 +53,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plResMgr/plResManager.h"
#include "plResMgr/plResMgrSettings.h"
#include "plWinRegistryTools.h"
#include "plFile/hsFiles.h"
#define IDC_REGTREEVIEW 1000
@ -139,14 +138,10 @@ LRESULT CALLBACK HandleCommand( HWND hWnd, WPARAM wParam, LPARAM lParam )
// Load that source
plResManager *mgr = (plResManager *)hsgResMgr::ResMgr();
hsFolderIterator pathIterator(path);
while (pathIterator.NextFileSuffix(".prp"))
{
char fileName[kFolderIterator_MaxPath];
pathIterator.GetPathAndName(fileName);
mgr->AddSinglePage(fileName);
}
std::vector<plFileName> prpFiles = plFileSystem::ListDir(path, "*.prp");
for (auto iter = prpFiles.begin(); iter != prpFiles.end(); ++iter)
mgr->AddSinglePage(*iter);
plResTreeView::FillTreeViewFromRegistry( gTreeView );
SetWindowTitle( hWnd, path );
@ -388,13 +383,9 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
( (char *)PathFindExtension( path ) )[ 0 ] == 0 )
{
// Must be a directory
hsFolderIterator pathIterator(path);
while (pathIterator.NextFileSuffix(".prp"))
{
char fileName[kFolderIterator_MaxPath];
pathIterator.GetPathAndName(fileName);
mgr->AddSinglePage(fileName);
}
std::vector<plFileName> prpFiles = plFileSystem::ListDir(path, "*.prp");
for (auto iter = prpFiles.begin(); iter != prpFiles.end(); ++iter)
mgr->AddSinglePage(*iter);
}
else
{