1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 02:51:27 +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

@ -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);
}
}