/*
* Copyright 2004 Perforce Software. All rights reserved.
*
* Developed by Data Shades Ltd.
*/
#include <maya/MCommandResult.h>
#include <maya/MGlobal.h>
#include <maya/M3dView.h>
#include <maya/MFileIO.h>
#include "P4GTMaya.h"
#include "Translate.h"
#include "..\libp4gt\version.h"
#define UNSAVED_TITLE "untitled"
TCHAR *MayaHost::GetName()
{
return _T("P4GT-Maya");
}
TCHAR *MayaHost::GetDesc()
{
return _T("P4GT - Maya.");
}
TCHAR *MayaHost::GetVersion()
{
return _T(P4GT_VERSION);
}
TCHAR *MayaHost::GetHostVersion()
{
MString version("Maya version: ");
version += MGlobal::mayaVersion();
static UniStrBuf buff;
Translate::ToWinChar( version.asChar(), &buff );
return buff.Text();
}
int MayaHost::GetNumDocs()
{
return 1;
}
bool MayaHost::GetCurrDocPath( UniStrBuf &buff )
{
MString path = MFileIO::currentFile();
// Check if path ends in "untitled"
if ( path.length() >= strlen( UNSAVED_TITLE ) ) {
char *s = (char *)path.asChar() + path.length() - strlen( UNSAVED_TITLE );
if ( strcmp( s, UNSAVED_TITLE ) == 0 ) {
return false;
}
}
Translate::ToWinChar( path.asChar(), &buff );
currDocPath = buff;
return true;
}
bool MayaHost::IsCurrDocDirty()
{
MCommandResult result;
MString cmd("file -q -mf");
MGlobal::executeCommand(cmd, result);
int intResult;
result.getResult(intResult);
return intResult ? true : false;
}
void MayaHost::SaveCurrDoc()
{
MFileIO::save();
}
void MayaHost::LoadDoc( StrPtr *path )
{
UniStrBuf mayaPath;
mayaPath.Set( (TCHAR *)path->Text() );
// Maya paths only understand forward slashes
for (TCHAR *curr = mayaPath.Text(); *curr != '\0'; curr++) {
if (*curr == '\\') {
*curr = '/';
}
}
// StrBuf buff;
// Translate::FromWinChar( mayaPath.Text(), &buff );
// MFileIO::open( buff.Text(), NULL, true );
MFileIO::open( mayaPath.Text(), NULL, true );
}
void MayaHost::ReloadCurrDoc()
{
// to prevent a hang in the FileOpen handler when reloading
// currentFile after a sync we first open a dummy file
MString untitled("untitled");
MFileIO::open( untitled, NULL, true );
MFileIO::newFile(true);
MFileIO::open( currDocPath.Text(), NULL, true );
}
bool MayaHost::HasMultiDocs()
{
return false;
}
# |
Change |
User |
Description |
Committed |
|
#1
|
10140 |
Matt Attaway |
Initial release of the P4GT source code. |
|
|