Ejemplo n.º 1
0
void MDLViewer::OnCascade()
{
	int i;
	int c = IFacePoserToolWindow::GetToolCount();
	int viscount = CountVisibleTools();

	int x = 0, y = 0;

	int offset = 20;

	int wide = workspace->w2() - viscount * offset;
	int tall = ( workspace->h2() - viscount * offset ) / 2;

	for ( i = 0; i < c; i++ )
	{
		IFacePoserToolWindow *tool = IFacePoserToolWindow::GetTool( i );
		mxWindow *w = tool->GetMxWindow();
		if ( !w->isVisible() )
			continue;

		w->setBounds( x, y, wide, tall );
		x += offset;
		y += offset;
	}
}
Ejemplo n.º 2
0
	virtual void ShowRightClickMenu( int mx, int my )
	{
		IFacePoserToolWindow *tool = GetSelectedTool();
		if ( !tool )
			return;

		mxWindow *toolw = tool->GetMxWindow();
		if ( !toolw )
			return;

		mxPopupMenu *pop = new mxPopupMenu();
		Assert( pop );

		bool isVisible = toolw->isVisible();
		bool isLocked = tool->IsLocked();

		pop->add( isVisible ? "Hide" : "Show", IDC_TOOL_TOGGLEVISIBILITY );
		pop->add( isLocked ? "Unlock" : "Lock", IDC_TOOL_TOGGLELOCK );

		// Convert click position
		POINT pt;
		pt.x = mx;
		pt.y = my;

		/*
		ClientToScreen( (HWND)getHandle(), &pt );
		ScreenToClient( (HWND)g_MDLViewer->getHandle(), &pt );
		*/

		// Convert coordinate space
		pop->popup( this, pt.x, pt.y );
	}
Ejemplo n.º 3
0
void MDLViewer::UpdateWindowMenu( void )
{
	int c = IFacePoserToolWindow::GetToolCount();
	for ( int i = 0; i < c ; i++ )
	{
		IFacePoserToolWindow *tool = IFacePoserToolWindow::GetTool( i );
		menuWindow->setChecked( IDC_WINDOW_FIRSTTOOL + i, tool->GetMxWindow()->isVisible() );
	}
}
Ejemplo n.º 4
0
	void	HandleWindowSelect( void )
	{
		extern double realtime;
		IFacePoserToolWindow *tool = GetSelectedTool();
		if ( !tool )
			return;

		bool doubleclicked = false;

		double curtime = realtime;
		int clickedItem = getSelectedIndex();

		if ( clickedItem == m_nLastSelected )
		{
			if ( curtime < m_flLastSelectedTime + WINDOW_DOUBLECLICK_TIME )
			{
				doubleclicked = true;
			}
		}

		m_flLastSelectedTime = curtime;
		m_nLastSelected = clickedItem;

		mxWindow *toolw = tool->GetMxWindow();
		if ( !toolw )
			return;

		if ( doubleclicked )
		{
			toolw->setVisible( !toolw->isVisible() );
			m_flLastSelectedTime = -1;
		}

		if ( !toolw->isVisible() )
		{
			return;
		}

		// Move window to front
		HWND wnd = (HWND)tool->GetMxWindow()->getHandle();
		SetFocus( wnd );
		SetWindowPos( wnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
	}
Ejemplo n.º 5
0
void MDLViewer::OnShowAll()
{
	int c = IFacePoserToolWindow::GetToolCount();
	for ( int i = 0; i < c; i++ )
	{
		IFacePoserToolWindow *tool = IFacePoserToolWindow::GetTool( i );
		mxWindow *w = tool->GetMxWindow();

		w->setVisible( true );
	}

	UpdateWindowMenu();
}
Ejemplo n.º 6
0
	virtual int	handleEvent( mxEvent *event )
	{
		int iret = 0;
		switch ( event->event )
		{
		case mxEvent::Action:
			{
				iret = 1;
				switch ( event->action )
				{
				default:
					iret = 0;
					break;
				case IDC_TOOL_TOGGLEVISIBILITY:
					{
						IFacePoserToolWindow *tool = GetSelectedTool();
						if ( tool )
						{
							mxWindow *toolw = tool->GetMxWindow();
							if ( toolw )
							{
								toolw->setVisible( !toolw->isVisible() );
								g_MDLViewer->UpdateWindowMenu();
							}
						}
					}
					break;
				case IDC_TOOL_TOGGLELOCK:
					{
						IFacePoserToolWindow *tool = GetSelectedTool();
						if ( tool )
						{
							tool->ToggleLockedState();
						}
					}
					break;
				}
			}
			break;
		default:
			break;
		}
		if ( iret )
			return iret;
		return BaseClass::handleEvent( event );
	}
Ejemplo n.º 7
0
static int CountVisibleTools( void )
{
	int i;
	int c = IFacePoserToolWindow::GetToolCount();
	int viscount = 0;

	for ( i = 0; i < c; i++ )
	{
		IFacePoserToolWindow *tool = IFacePoserToolWindow::GetTool( i );
		mxWindow *w = tool->GetMxWindow();
		if ( !w->isVisible() )
			continue;

		viscount++;
	}

	return viscount;
}
Ejemplo n.º 8
0
void MDLViewer::DoTile( int x, int y )
{
	int c = IFacePoserToolWindow::GetToolCount();

	int vis = CountVisibleTools();

	if ( x < 1 )
		x = 1;
	if ( y < 1 )
		y = 1;

	int wide = workspace->w2() / y;
	int tall = workspace->h2() / x;

	int obj = 0;

	for ( int row = 0 ; row < x ; row++ )
	{
		for  ( int col = 0; col < y; col++ )
		{
			bool found = false;
			while ( 1 )
			{
				if ( obj >= c )
					break;

				IFacePoserToolWindow *tool = IFacePoserToolWindow::GetTool( obj++ );
				mxWindow *w = tool->GetMxWindow();
				if ( w->isVisible() )
				{
					w->setBounds( col * wide, row * tall, wide, tall );

					found = true;
					break;
				}
			}

			if ( !found )
				break;
		}
	}
}
Ejemplo n.º 9
0
int MDLViewer::handleEvent (mxEvent *event)
{
	int iret = 0;

	switch (event->event)
	{
	case mxEvent::Size:
		{
			int width = w2();
			int height = h2();

			workspace->setBounds( 0, 0, width, height - WINDOW_TAB_OFFSET );
			int gridsettingswide = 100;
			int gridstart = width - gridsettingswide - 5;
			int windowwide = gridstart * 0.6f;
			int modelwide = gridstart * 0.4f;

			gridsettings->setBounds( gridstart, height - WINDOW_TAB_OFFSET + 1, gridsettingswide, WINDOW_TAB_OFFSET - 2 );

			windowtab->setBounds( 0, height - WINDOW_TAB_OFFSET, windowwide, WINDOW_TAB_OFFSET );
			modeltab->setBounds( windowwide, height - WINDOW_TAB_OFFSET, modelwide, WINDOW_TAB_OFFSET );

			iret = 1;
		}
		break;
	case mxEvent::Action:
		{
			iret = 1;
			switch (event->action)
			{
			case IDC_WINDOW_TAB:
				{
					windowtab->HandleWindowSelect();
				}
				break;
			case IDC_MODEL_TAB:
				{
					modeltab->HandleModelSelect();
				}
				break;
			case IDC_EDIT_COPY:
				{
					Copy();
				}
				break;
				
			case IDC_EDIT_PASTE:
				{
					Paste();
				}
				break;
				
			case IDC_EDIT_UNDO:
				{
					Undo();
				}
				break;
				
			case IDC_EDIT_REDO:
				{
					Redo();
				}
				break;
				
			case IDC_FILE_LOADMODEL:
				{
					const char *ptr = mxGetOpenFileName(
						this, 
						FacePoser_MakeWindowsSlashes( va( "%s/models/", GetGameDirectory() ) ),
						"*.mdl");
					if (ptr)
					{
						LoadModelFile( ptr );
					}
				}
				break;
				
			case IDC_FILE_REFRESH:
				{
					Refresh();
					break;
				}
				
			case IDC_FILE_LOADBACKGROUNDTEX:
			case IDC_FILE_LOADGROUNDTEX:
				{
					const char *ptr = mxGetOpenFileName (this, 0, "*.*");
					if (ptr)
					{
						if (0 /* g_pMatSysWindow->loadTexture (ptr, event->action - IDC_FILE_LOADBACKGROUNDTEX) */)
						{
							if (event->action == IDC_FILE_LOADBACKGROUNDTEX)
								g_pControlPanel->setShowBackground (true);
							else
								g_pControlPanel->setShowGround (true);
							
						}
						else
							mxMessageBox (this, "Error loading texture.", g_appTitle, MX_MB_OK | MX_MB_ERROR);
					}
				}
				break;
				
			case IDC_FILE_UNLOADGROUNDTEX:
				{
					// g_pMatSysWindow->loadTexture (0, 1);
					g_pControlPanel->setShowGround (false);
				}
				break;
				
			case IDC_FILE_RECENTMODELS1:
			case IDC_FILE_RECENTMODELS2:
			case IDC_FILE_RECENTMODELS3:
			case IDC_FILE_RECENTMODELS4:
				{
					int i = event->action - IDC_FILE_RECENTMODELS1;
					
					LoadModelFile( recentFiles[ i ] );
					
					char tmp[256];			
					strcpy (tmp, recentFiles[0]);
					strcpy (recentFiles[0], recentFiles[i]);
					strcpy (recentFiles[i], tmp);
					
					initRecentFiles ();
					
					redraw ();
				}
				break;
				
			case IDC_FILE_EXIT:
				{
					redraw ();
					mx::quit ();
				}
				break;
				
			case IDC_OPTIONS_COLORBACKGROUND:
			case IDC_OPTIONS_COLORGROUND:
			case IDC_OPTIONS_COLORLIGHT:
				{
					float *cols[3] = { g_viewerSettings.bgColor, g_viewerSettings.gColor, g_viewerSettings.lColor };
					float *col = cols[event->action - IDC_OPTIONS_COLORBACKGROUND];
					int r = (int) (col[0] * 255.0f);
					int g = (int) (col[1] * 255.0f);
					int b = (int) (col[2] * 255.0f);
					if (mxChooseColor (this, &r, &g, &b))
					{
						col[0] = (float) r / 255.0f;
						col[1] = (float) g / 255.0f;
						col[2] = (float) b / 255.0f;
					}
				}
				break;
				
			case IDC_OPTIONS_CENTERVIEW:
				g_pControlPanel->centerView ();
				break;
				
			case IDC_OPTIONS_CENTERONFACE:
				g_pControlPanel->CenterOnFace();
				break;
				
			case IDC_OPTIONS_MAKESCREENSHOT:
				{
					char *ptr = (char *) mxGetSaveFileName (this, "", "*.tga");
					if (ptr)
					{
						if (!strstr (ptr, ".tga"))
							strcat (ptr, ".tga");
						// g_pMatSysWindow->dumpViewport (ptr);
					}
				}
				break;
				
			case IDC_OPTIONS_DUMP:
				g_pControlPanel->dumpModelInfo ();
				break;
				
#ifdef WIN32
			case IDC_HELP_GOTOHOMEPAGE:
				ShellExecute (0, "open", "http://www.swissquake.ch/chumbalum-soft/index.html", 0, 0, SW_SHOW);
				break;
#endif
				
			case IDC_HELP_ABOUT:
				mxMessageBox (this,
					"v0.1 (c) 2001, Valve, LLC.  All rights reserved.\r\nBuild Date: "__DATE__"",
					"Valve Face Poser", 
					MX_MB_OK | MX_MB_INFORMATION);
				break;
				
			case IDC_EXPRESSIONS_REDOBITMAPS:
				{
					bool saveOverrides = g_pExpressionTrayTool->GetOverridesShowing();
					g_pExpressionTrayTool->SetOverridesShowing( false );
					CExpClass *active = expressions->GetActiveClass();
					if ( active )
					{
						for ( int i = 0; i < active->GetNumExpressions() ; i++ )
						{
							CExpression *exp = active->GetExpression( i );
							if ( !exp )
								continue;
							
							active->SelectExpression( i );
							exp->CreateNewBitmap( models->GetActiveModelIndex() );
							
							if ( ! ( i % 5 ) )
							{
								g_pExpressionTrayTool->redraw();
							}
						}
						
						if ( active->HasOverrideClass() )
						{
							
							g_pExpressionTrayTool->SetOverridesShowing( true );
							
							CExpClass *oc = active->GetOverrideClass();
							for ( int i = 0; i < oc->GetNumExpressions() ; i++ )
							{
								CExpression *exp = oc->GetExpression( i );
								if ( !exp )
									continue;
								
								oc->SelectExpression( i );
								exp->CreateNewBitmap( models->GetActiveModelIndex() );
								
								if ( ! ( i % 5 ) )
								{
									g_pExpressionTrayTool->redraw();
								}
							}
						}
						active->SelectExpression( 0 );
					}
					
					g_pExpressionTrayTool->SetOverridesShowing( saveOverrides );
				}
				break;
			case IDC_EXPRESSIONS_NEW:
				{
					const char *filename = mxGetSaveFileName( 
						this, 
						FacePoser_MakeWindowsSlashes( va( "%s/expressions/", GetGameDirectory() ) ), 
						"*.txt" );
					if ( filename && filename[ 0 ] )
					{
						char classfile[ 512 ];
						strcpy( classfile, filename );
						StripExtension( classfile );
						DefaultExtension( classfile, ".txt" );
						
						expressions->CreateNewClass( classfile );
					}
				}
				break;
			case IDC_EXPRESSIONS_LOAD:
				{
					const char *filename = NULL;
					
					filename = mxGetOpenFileName( 
						this, 
						FacePoser_MakeWindowsSlashes( va( "%s/expressions/", GetGameDirectory() ) ), 
						"*.txt" );
					if ( filename && filename[ 0 ] )
					{
						expressions->LoadClass( filename );
					}
				}
				break;
				
			case IDC_EXPRESSIONS_SAVE:
				{
					CExpClass *active = expressions->GetActiveClass();
					if ( active )
					{
						active->Save();
						active->Export();
					}
				}
				break;
			case IDC_EXPRESSIONS_EXPORT:
				{
					CExpClass *active = expressions->GetActiveClass();
					if ( active )
					{
						active->Export();
					}
				}
				break;
			case IDC_EXPRESSIONS_CLOSE:
				g_pControlPanel->Close();
				break;
			case IDC_EXPRESSIONS_CLOSEALL:
				g_pControlPanel->Closeall();
				break;
			case IDC_CHOREOSCENE_NEW:
				g_pChoreoView->New();
				break;
			case IDC_CHOREOSCENE_LOAD:
				g_pChoreoView->Load();
				break;
			case IDC_CHOREOSCENE_SAVE:
				g_pChoreoView->Save();
				break;
			case IDC_CHOREOSCENE_SAVEAS:
				g_pChoreoView->SaveAs();
				break;
			case IDC_CHOREOSCENE_CLOSE:
				g_pChoreoView->Close();
				break;
			case IDC_CHOREOSCENE_ADDACTOR:
				g_pChoreoView->NewActor();
				break;
			case IDC_WINDOW_TILE:
				{
					OnTile();
				}
				break;
			case IDC_WINDOW_TILE_HORIZ:
				{
					OnTileHorizontally();
				}
				break;
			case IDC_WINDOW_TILE_VERT:
				{
					OnTileVertically();
				}
				break;
			case IDC_WINDOW_CASCADE:
				{
					OnCascade();
				}
				break;
			case IDC_WINDOW_HIDEALL:
				{
					OnHideAll();
				}
				break;
			case IDC_WINDOW_SHOWALL:
				{
					OnShowAll();
				}
				break;
			default:
				{
					iret = 0;
					int tool_number = event->action - IDC_WINDOW_FIRSTTOOL;
					int max_tools = IDC_WINDOW_LASTTOOL - IDC_WINDOW_FIRSTTOOL;
					
					if ( tool_number >= 0 && 
						tool_number <= max_tools && 
						tool_number < IFacePoserToolWindow::GetToolCount() )
					{
						iret = 1;
						IFacePoserToolWindow *tool = IFacePoserToolWindow::GetTool( tool_number );
						if ( tool )
						{
							mxWindow *toolw = tool->GetMxWindow();
							
							bool wasvisible = toolw->isVisible();
							toolw->setVisible( !wasvisible );
							
							g_MDLViewer->UpdateWindowMenu();

						}
					}
				}
				break;
			} //switch (event->action)
		} // mxEvent::Action
		break;
	case KeyDown:
		{
			g_pMatSysWindow->handleEvent(event);
			iret = 1;
		}
		break;
	case mxEvent::Activate:
		{
			if (event->action)
			{
				mx::setIdleWindow( g_pMatSysWindow );
			}
			else
			{
				mx::setIdleWindow( 0 );
			}
			iret = 1;
		}
		break;
	} // event->event
	
	return iret;
}