mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 02:51:27 +00:00
Merge pull request #275 from zrax/file-utils
Unify filesystem utilities
This commit is contained in:
@ -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;
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user