/*
* Copyright 2005 Perforce Software. All rights reserved.
*
* Developed by Data Shades Ltd.
*/
#include <xsi_application.h>
#include <xsi_project.h>
#include <xsi_scene.h>
#include <xsi_property.h>
using namespace XSI;
#include "P4GTSoftImage.h"
#include "Translate.h"
#include "..\libp4gt\version.h"
TCHAR *SoftImageHost::GetName()
{
return _T("P4GT-Softimage");
}
TCHAR *SoftImageHost::GetDesc()
{
return _T("P4GT - Softimage.");
}
TCHAR *SoftImageHost::GetVersion()
{
return _T(P4GT_VERSION);
}
TCHAR *SoftImageHost::GetHostVersion()
{
static TCHAR version[256] = {'\0'};
if ( _tcslen( version ) == 0 ) {
Application app;
_tcscpy( version, _T("SOFTIMAGE | XSI version: ") );
_tcscat( version, app.GetVersion().GetWideString() );
}
return version;
}
int SoftImageHost::GetNumDocs()
{
return 1;
}
bool SoftImageHost::GetCurrDocPath( UniStrBuf &buff )
{
Application app;
Project proj = app.GetActiveProject();
Scene scene = proj.GetActiveScene();
CRefArray params = scene.GetParameters();
for (int i=0; i<params.GetCount(); i++) {
Parameter param(params[i]);
if ( param.GetScriptName() == L"FileName" ) {
wchar_t path[MAX_PATH + 1];
/*
* Need to take a copy of the path right away. Otherwise
* it can sometimes become corrupted!
*/
wcscpy( path, param.GetValue().GetAsText().GetWideString() );
wchar_t *filename = wcsrchr( path, '\\' );
if ( filename ) {
filename++;
if ( wcscmp( filename, L"Untitled.scn" ) != 0 ) {
buff.Set( path );
return true;
}
}
}
}
return false;
}
bool SoftImageHost::IsCurrDocDirty()
{
return true;
}
void SoftImageHost::SaveCurrDoc()
{
Application app;
CValueArray args(0);
CValue ret;
app.ExecuteCommand( L"SaveScene", args, ret );
}
void SoftImageHost::LoadDoc( StrPtr *path )
{
Application app;
CValueArray args(1);
args[0] = CValue( (TCHAR *)path->Text() );
CValue ret;
app.ExecuteCommand( L"OpenScene", args, ret );
}
void SoftImageHost::ReloadCurrDoc()
{
UniStrBuf path;
if ( GetCurrDocPath( path ) ) {
Application app;
CValueArray args(2);
args[0] = CValue( path.Text() );
args[1] = CValue( false );
CValue ret;
app.ExecuteCommand( L"OpenScene", args, ret );
}
}
bool SoftImageHost::HasMultiDocs()
{
return false;
}
# |
Change |
User |
Description |
Committed |
|
#1
|
10140 |
Matt Attaway |
Initial release of the P4GT source code. |
|
|