Sinbad: XSI GUI stuff

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
Bill
Gremlin
Posts: 167
Joined: Sun Sep 26, 2004 11:50 pm
Location: Arkansas

Sinbad: XSI GUI stuff

Post by Bill »

I went through and figured out the GUI stuff this weekend. I thought you might like to see what I came up with. It might save you some time. You have to put the functions (not test()) in the def file or you will spend 5 hours banging your head against the keybord wondering why it isn't working. (No, I didn't do that. Honest.) :-)

Call test() from a menu item to have Window pop up.


Code: Select all

void test(){
	XSI::Application application;
	XSI::CustomProperty customProperty;
	customProperty=application.GetActiveSceneRoot().AddProperty( L"OGREExport" ) ;

	XSI::CValueArray argumentArray(5);
	XSI::CValue returnValue;
	argumentArray[0]= customProperty.GetFullName();
	argumentArray[1]= L"";
	argumentArray[2]= L"";
	argumentArray[3]= XSI::CValue((long)XSI::siLockAndForceNew );
	argumentArray[4]= true;
	XSI::CStatus status = application.ExecuteCommand( L"InspectObj", argumentArray, returnValue );
}
	
XSI::CStatus OGREExport_Define( const XSI::CRef & contextReference ){
	XSI::CustomProperty customProperty = XSI::Context(contextReference).GetSource() ;
	XSI::Parameter parameter ;
	customProperty.AddParameter( L"ExportDirectory", XSI::CValue::siString, XSI::siPersistable, L"", L"", XSI::CValue(), parameter ) ;
	customProperty.AddParameter( L"Export", XSI::CValue::siBool, XSI::siPersistable, L"", L"",XSI::CValue(), parameter ) ;
	customProperty.AddParameter( L"CancelExport", XSI::CValue::siBool, XSI::siPersistable, L"", L"",XSI::CValue(), parameter ) ;	
	return XSI::CStatus::OK;	
}

XSI::CStatus OGREExport_DefineLayout( const XSI::CRef & contextReference ){
	XSI::PPGLayout ppgLayout = XSI::Context(contextReference).GetSource();

	ppgLayout.Clear() ;
	XSI::PPGItem folderPicker=ppgLayout.AddItem( L"ExportDirectory", L"Export Directory", XSI::siControlFolder );
	ppgLayout.AddRow() ;
	XSI::PPGItem  controlButton=ppgLayout.AddButton( L"Export", L"Export Object" );
	XSI::PPGItem  cancelButton=ppgLayout.AddButton( L"CancelExport", L"Cancel Export" );
	ppgLayout.EndRow();
	return XSI::CStatus::OK;	
}

XSI::CStatus OGREExport_PPGEvent( const XSI::CRef& contextReference ){
	XSI::Application application;
	application.LogMessage(L"event");

	XSI::PPGEventContext eventContext(contextReference);
	XSI::PPGEventContext::PPGEvent ppgEvent = eventContext.GetEventID();

	if(ppgEvent == XSI::PPGEventContext::siButtonClicked ){
		XSI::CValue buttonPressed=eventContext.GetAttribute(L"Button");
		if(buttonPressed.GetAsText()==L"Export"){
			XSI::CustomProperty customProperty=eventContext.GetSource();
			XSI::CValue exportDirectoryValue=customProperty.GetParameter(L"ExportDirectory").GetValue();

			if(exportDirectoryValue.GetAsText().Length() != 0){
				application.LogMessage(exportDirectoryValue.GetAsText());
				// call export routine here    pass it export directory value
				XSI::CValue returnValue;
				XSI::CValueArray arguments(1) ;
				arguments[0] = customProperty ;
				application.ExecuteCommand( L"DeleteObj", arguments, returnValue ) ;
				eventContext.PutAttribute(L"Close",XSI::CValue(true));
			}else{
				application.LogMessage(L"No export directory specified");
			}
		}
		if(buttonPressed.GetAsText()==L"CancelExport"){
			XSI::CustomProperty customProperty=eventContext.GetSource();
			XSI::CValue returnValue;
			XSI::CValueArray arguments(1) ;
			arguments[0] = customProperty ;
			application.ExecuteCommand( L"DeleteObj", arguments, returnValue ) ;
			eventContext.PutAttribute(L"Close",XSI::CValue(true));
		}
	}
	return XSI::CStatus::OK;	
}

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

Thanks Bill, but I already did a GUI ( http://www.ogre3d.org/phpBB2/viewtopic. ... 00&start=0 ). :) Sorry, if I knew you were gonna attempt this I would have pointed you at the code in Tools\XSIExport

Bill
Gremlin
Posts: 167
Joined: Sun Sep 26, 2004 11:50 pm
Location: Arkansas

Post by Bill »

OOO Your GUI is pretty. I'll have to beautify mine now.

Post Reply