1325 lines
41 KiB
C++
1325 lines
41 KiB
C++
/*
|
|
*=============================================================================
|
|
*
|
|
* Filename: AnimView.cpp
|
|
* Version: 1.0
|
|
* Date: 11/03/97
|
|
* Author: Vincent Lhullier
|
|
*
|
|
* Description: view box to display list of animations
|
|
* and control to display animation
|
|
* functions for saving animation in binary format
|
|
*===========================================================================
|
|
*/
|
|
//#undef DEBUG
|
|
#include "stdafx.h"
|
|
//#define DEBUG
|
|
|
|
#include <io.h>
|
|
|
|
#include "ACP_Base.h"
|
|
#include "ITF.h"
|
|
#include "DPT.h"
|
|
#define D_State_Define
|
|
#define D_ObjsTbls_Define
|
|
#define D_ZdxStuff_StructureDefine
|
|
//#include "DNM.h"
|
|
#include "incGAM.h"
|
|
#undef D_ZdxStuff_StructureDefine
|
|
#undef D_ObjsTbls_Define
|
|
#undef D_State_Define
|
|
|
|
#include "TFA.h"
|
|
#include "TAN.h"
|
|
|
|
#include "animview.h"
|
|
|
|
//#include "animview.hh"
|
|
#include "T3D_res.h"
|
|
#include "X:\Cpa\Main\inc\_EditID.h"
|
|
|
|
#include "T3DWorld.hpp"
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
/*
|
|
*=============================================================================
|
|
* saving animation in binary file
|
|
*=============================================================================
|
|
*/
|
|
#define M_RedrawAll() (m_p_oT3DInterf -> GetInterface() -> fn_vUpdateAll(E_mc_JustDraw) )
|
|
#define M_GetClientRect( pWnd, poRect ) (pWnd) -> GetWindowRect( poRect );ScreenToClient( poRect )
|
|
#define M_GetClientRectId( Id, poRect ) M_GetClientRect( GetDlgItem( Id ), poRect )
|
|
#define M_SetClientRect( pWnd, poRect ) (pWnd) -> MoveWindow( poRect )
|
|
#define M_SetClientRectId( Id, poRect ) M_SetClientRect( GetDlgItem( Id ), poRect )
|
|
/*
|
|
*=============================================================================
|
|
* class AnimView
|
|
*=============================================================================
|
|
*/
|
|
IMPLEMENT_DYNCREATE(CAnimationView, CFormView)
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* Constructor
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
CAnimationView::CAnimationView(): CFormView(CAnimationView::IDD)
|
|
{
|
|
//{{AFX_DATA_INIT(CAnimationView)
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
//}}AFX_DATA_INIT
|
|
bInitialUpdate = TRUE;
|
|
m_p_oFamily = NULL;
|
|
m_p_oT3DInterf = NULL;
|
|
m_p_oTool3DWorld = NULL;
|
|
m_p_oCurrentAnim = NULL;
|
|
m_p_oCurrentAction = NULL; //Mircea Dunka 8.10.1998
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* Destructor
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
CAnimationView::~CAnimationView()
|
|
{
|
|
m_oBitmapPlay.DeleteObject();
|
|
m_oBitmapStop.DeleteObject();
|
|
m_oBitmapReverse.DeleteObject();
|
|
m_oBitmapForward.DeleteObject();
|
|
m_oBitmapRewind.DeleteObject();
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* Data exchange
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CFormView::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CAnimationView)
|
|
// NOTE: the ClassWizard will add DDX and DDV calls here
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* Message map
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
BEGIN_MESSAGE_MAP(CAnimationView, CFormView)
|
|
//{{AFX_MSG_MAP(CAnimationView)
|
|
ON_WM_SHOWWINDOW()
|
|
ON_WM_SIZE()
|
|
ON_LBN_SELCHANGE(IDC_LIST_ANIMS, OnSelchangeListAnims)
|
|
ON_LBN_SELCHANGE(IDC_LIST_ACTIONS, OnSelchangeListActions)//Mircea Dunka 6.10.98
|
|
ON_BN_CLICKED(IDC_BUTTON_LOAD, OnButtonLoad)
|
|
ON_BN_CLICKED(IDC_BUTTON_PLAY, OnButtonPlay)
|
|
ON_BN_CLICKED(IDC_BT_REINIT, OnButtonReinit)
|
|
ON_WM_TIMER()
|
|
ON_WM_HSCROLL()
|
|
ON_BN_CLICKED(IDC_BT_ANIM, OnButtonAnim)
|
|
ON_BN_CLICKED(IDC_BT_ACTION, OnButtonAction)
|
|
ON_BN_CLICKED(IDC_BUTTON_STOP, OnButtonStop)
|
|
ON_BN_CLICKED(IDC_BUTTON_FORWARD, OnButtonForward)
|
|
ON_BN_CLICKED(IDC_BUTTON_REVERSE, OnButtonReverse)
|
|
ON_BN_CLICKED(IDC_BUTTON_REWIND, OnButtonRewind)
|
|
ON_BN_CLICKED(IDC_BUTTON_HELP, OnButtonHelp)
|
|
ON_LBN_DBLCLK(IDC_LIST_ANIMS, OnDblclkListAnims)
|
|
ON_WM_MEASUREITEM()
|
|
ON_WM_DRAWITEM()
|
|
ON_WM_HELPINFO()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/*
|
|
*=============================================================================
|
|
* CAnimationView specific functions
|
|
*=============================================================================
|
|
*/
|
|
|
|
void CAnimationView::mfn_vInitDialog( CPA_Family *_p_oCurrentFamily, CPA_Animation *p_oAnimation /*=NULL*/, unsigned short _uwFrame /*=0*/)
|
|
{
|
|
CListBox *pLB = (CListBox *) GetDlgItem( IDC_LIST_ANIMS );
|
|
// unsigned char ucFrameRate;
|
|
|
|
m_p_oFamily = _p_oCurrentFamily;
|
|
fn_vFillAnimList();
|
|
//28.09.98 Mircea Dunka
|
|
mfn_vFillActionList(); //aded action list
|
|
m_p_oCurrentAnim = p_oAnimation;
|
|
//Stefan Dumitrean 28-05-98
|
|
if( !m_p_oCurrentAnim )
|
|
{
|
|
POSITION pos = m_p_oFamily->m_oListOfAnimations.GetHeadPosition();
|
|
while( pos )
|
|
{
|
|
p_oAnimation = m_p_oFamily->m_oListOfAnimations.GetNext(pos);
|
|
if( p_oAnimation && p_oAnimation->fn_bIsAvailable() )
|
|
{
|
|
if( ! m_p_oCurrentAnim )
|
|
m_p_oCurrentAnim = p_oAnimation;
|
|
else
|
|
if( p_oAnimation->GetName() < m_p_oCurrentAnim->GetName() )
|
|
m_p_oCurrentAnim = p_oAnimation;
|
|
}
|
|
|
|
}
|
|
}
|
|
//End Stefan Dumitrean 28-05-98
|
|
//end Mircea Dunka - optimization
|
|
|
|
|
|
if( m_p_oCurrentAnim )
|
|
{
|
|
int iIndex = pLB -> FindStringExact( -1, m_p_oCurrentAnim -> GetName() );
|
|
if( iIndex != LB_ERR )
|
|
pLB -> SetCurSel( iIndex );
|
|
//pLB -> SetTopIndex( iIndex ); Mircea Dunka - SetCurSel already did this
|
|
else
|
|
pLB -> SetCurSel( -1 );
|
|
|
|
//Stefan Dumitrean 2-06-98
|
|
// ucFrameRate = ((struct tdstAnim3d_*)_p_oAnimation -> GetData() ) -> ucFrameRate;
|
|
// m_uiElapseTime = ucFrameRate ? 1000 / ucFrameRate : 1;
|
|
//End Stefan Dumitrean 2-06-98
|
|
}
|
|
OnSelchangeListAnims();
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
* Description :
|
|
*---------------------------------------------------------------------------*/
|
|
void CAnimationView::fn_vBeginAnim( unsigned short _uwFrame)
|
|
{
|
|
ASSERT( m_p_oCurrentAnim -> GetData() );
|
|
|
|
// begin a new anim
|
|
// so we have to change the frame element3d array
|
|
//-----------------------
|
|
//29.09.98 Mircea Dunka - sometimes it hangs here so I make a little test
|
|
if(m_p_oTool3DWorld -> m_p_oRootFromAnim)
|
|
fn_v3dDataSetFlagModifState(M_GetMSHandle( m_p_oTool3DWorld -> m_p_oRootFromAnim -> GetStruct(), 3dData), TRUE);
|
|
else
|
|
return;
|
|
//end Mircea Dunka
|
|
|
|
// p_st3dData = M_GetMSHandle( m_p_oTool3DWorld -> m_p_oRootFromAnim -> GetStruct(), 3dData);
|
|
|
|
PLA_fn_bDoFirstInitOfAnimPlayerForCharacter(m_p_oTool3DWorld->m_p_oRootFromAnim->GetStruct(), (struct tdstAnim3d_*) m_p_oCurrentAnim -> GetData());
|
|
|
|
CScrollBar *pSC = (CScrollBar *) GetDlgItem( IDC_SCROLLBAR_FRAME );
|
|
_uwFrame %= ((struct tdstAnim3d_*)m_p_oCurrentAnim -> GetData()) -> uwNumberOfFrames;
|
|
|
|
m_p_oTool3DWorld -> mfn_vUpdateHierarchyFromAnim( (struct tdstAnim3d_*)m_p_oCurrentAnim -> GetData(), _uwFrame );
|
|
M_RedrawAll();
|
|
|
|
pSC->EnableWindow(TRUE);
|
|
GetDlgItem( IDC_STATIC_CURRENTFRAME )->EnableWindow( TRUE );
|
|
//Mircea Dunka 20.10.98
|
|
GetDlgItem( IDC_STATIC_CURRENTANIMATION )->EnableWindow( TRUE );
|
|
GetDlgItem( IDC_STATIC_CURRENTANIMATION )->SetWindowText( "1" );
|
|
// m_uiTotalNumberOfFrames = m_uiTotalNumberOfFrames ? 1 : m_uiTotalNumberOfFrames;
|
|
pSC->SetScrollRange( 0, m_uiTotalNumberOfFrames - 1);
|
|
//end Mircea Dunka
|
|
|
|
GetDlgItem( IDC_BUTTON_PLAY )->EnableWindow( TRUE );
|
|
pSC->SetScrollPos( _uwFrame );
|
|
pSC->Invalidate();
|
|
GetDlgItem( IDC_STATIC_CURRENTFRAME )->SetWindowText( "1" );
|
|
m_bPlay = FALSE;
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
* Description :
|
|
*---------------------------------------------------------------------------*/
|
|
void CAnimationView::fn_vShowFrame(unsigned short _uwFrame)
|
|
{
|
|
CPA_Animation* p_oAnimation;
|
|
int uwNumberOfPrevFrames = 0;
|
|
int iCurrentAnimation = 0;
|
|
char szValue[10];
|
|
|
|
if(m_bActionPlay)
|
|
{
|
|
POSITION pos = m_p_oCurrentAction->m_oListOfStates.GetHeadPosition();
|
|
while( pos )
|
|
{
|
|
iCurrentAnimation++;
|
|
p_oAnimation = ((CPA_State*)(m_p_oCurrentAction->m_oListOfStates.GetNext(pos)))->mfn_p_oGetAnimation();
|
|
//count the nb. of frames
|
|
tdstAnim3d_* p_stAnim3d = (struct tdstAnim3d_*)p_oAnimation -> GetData();
|
|
//uwNumberOfFrames += ((struct tdstAnim3d_*)p_oAnimation -> GetData()) -> uwNumberOfFrames;
|
|
if(p_stAnim3d->uwNumberOfFrames + uwNumberOfPrevFrames > _uwFrame)
|
|
break;
|
|
else
|
|
uwNumberOfPrevFrames += p_stAnim3d->uwNumberOfFrames;
|
|
}
|
|
// if(uwNumberOfFrames < _uwFrame)
|
|
// {
|
|
//the current animation was found
|
|
_uwFrame -= uwNumberOfPrevFrames;
|
|
|
|
if(m_p_oCurrentAnim != p_oAnimation)
|
|
{
|
|
//next (prev) animation
|
|
m_p_oCurrentAnim = p_oAnimation;
|
|
// begin a new anim
|
|
// so we have to change the frame element3d array
|
|
//-----------------------
|
|
//29.09.98 Mircea Dunka - sometimes it hangs here so I make a little test
|
|
if(m_p_oTool3DWorld -> m_p_oRootFromAnim)
|
|
fn_v3dDataSetFlagModifState(M_GetMSHandle( m_p_oTool3DWorld -> m_p_oRootFromAnim -> GetStruct(), 3dData), TRUE);
|
|
else
|
|
return;
|
|
//end Mircea Dunka
|
|
PLA_fn_bDoFirstInitOfAnimPlayerForCharacter(m_p_oTool3DWorld->m_p_oRootFromAnim->GetStruct(), (struct tdstAnim3d_*) m_p_oCurrentAnim -> GetData());
|
|
m_p_oTool3DWorld -> mfn_vUpdateHierarchyFromAnim( (struct tdstAnim3d_*)m_p_oCurrentAnim -> GetData(), _uwFrame );
|
|
M_RedrawAll();
|
|
itoa( iCurrentAnimation, szValue, 10);
|
|
GetDlgItem( IDC_STATIC_CURRENTANIMATION )->SetWindowText( szValue );
|
|
return;
|
|
}
|
|
}
|
|
|
|
itoa( iCurrentAnimation, szValue, 10);
|
|
GetDlgItem( IDC_STATIC_CURRENTANIMATION )->SetWindowText( szValue );
|
|
|
|
if( m_bPlay )
|
|
m_p_oTool3DWorld -> mfn_vPlayAnim( (struct tdstAnim3d_*)m_p_oCurrentAnim -> GetData(), _uwFrame );
|
|
else
|
|
m_p_oTool3DWorld -> mfn_vUpdateHierarchyFromAnim( (struct tdstAnim3d_*)m_p_oCurrentAnim -> GetData(), _uwFrame );
|
|
|
|
M_RedrawAll();
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* first initialisation
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::m_fn_vEnableControl( BOOL _bEnable )
|
|
{
|
|
GetDlgItem( IDC_BT_REINIT )->EnableWindow( _bEnable );
|
|
GetDlgItem( IDC_BUTTON_LOAD )->EnableWindow( _bEnable );
|
|
GetDlgItem( IDC_BT_ACTION )->EnableWindow( _bEnable );
|
|
GetDlgItem( IDC_BT_ANIM )->EnableWindow( _bEnable );
|
|
GetDlgItem( IDC_LIST_ACTIONS )->EnableWindow( _bEnable );
|
|
GetDlgItem( IDC_LIST_ANIMS )->EnableWindow( _bEnable );
|
|
GetDlgItem( IDC_SCROLLBAR_FRAME )->EnableWindow( _bEnable );
|
|
GetDlgItem( IDC_SLIDER )->EnableWindow( _bEnable );
|
|
//Stefan Dumitrean 28-05-98
|
|
m_p_oFamilySelDialog->EnableWindow( _bEnable );
|
|
//End Stefan Dumitrean 28-05-98
|
|
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* stop playing animation
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::m_fn_vStopAnim( void )
|
|
{
|
|
if (m_bPlay)
|
|
{
|
|
CScrollBar *pSC = (CScrollBar *) GetDlgItem( IDC_SCROLLBAR_FRAME );
|
|
|
|
KillTimer( m_uiPlayTimer );
|
|
m_bPlay = FALSE;
|
|
m_fn_vEnableControl( TRUE );
|
|
fn_vShowFrame( pSC->GetScrollPos() );
|
|
}
|
|
}
|
|
|
|
/*
|
|
*=============================================================================
|
|
* CAnimationView diagnostics
|
|
*=============================================================================
|
|
*/
|
|
#ifdef _DEBUG
|
|
void CAnimationView::AssertValid() const
|
|
{
|
|
CFormView::AssertValid();
|
|
}
|
|
|
|
void CAnimationView::Dump(CDumpContext& dc) const
|
|
{
|
|
CFormView::Dump(dc);
|
|
}
|
|
#endif //_DEBUG
|
|
|
|
/*
|
|
*=============================================================================
|
|
* CAnimationView messages handlers
|
|
*=============================================================================
|
|
*/
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* first initialisation
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnInitialUpdate()
|
|
{
|
|
CFormView::OnInitialUpdate();
|
|
|
|
if (!bInitialUpdate)
|
|
return;
|
|
|
|
bInitialUpdate = FALSE;
|
|
|
|
/*
|
|
* load bitmap and set bitmap in play button
|
|
*/
|
|
m_oBitmapRewind.LoadBitmap( IDB_BITMAP_REWIND );
|
|
m_oBitmapReverse.LoadBitmap( IDB_BITMAP_REVERSE );
|
|
m_oBitmapStop.LoadBitmap( IDB_BITMAP_STOP );
|
|
m_oBitmapPlay.LoadBitmap( IDB_BITMAP_PLAY );
|
|
m_oBitmapForward.LoadBitmap( IDB_BITMAP_FORWARD );
|
|
|
|
((CButton *) GetDlgItem( IDC_BUTTON_REWIND ))->SetBitmap( HBITMAP(m_oBitmapRewind) );
|
|
((CButton *) GetDlgItem( IDC_BUTTON_REVERSE ))->SetBitmap( HBITMAP(m_oBitmapReverse) );
|
|
((CButton *) GetDlgItem( IDC_BUTTON_STOP ))->SetBitmap( HBITMAP(m_oBitmapStop) );
|
|
((CButton *) GetDlgItem( IDC_BUTTON_PLAY ))->SetBitmap( HBITMAP(m_oBitmapPlay) );
|
|
((CButton *) GetDlgItem( IDC_BUTTON_FORWARD ))->SetBitmap( HBITMAP(m_oBitmapForward) );
|
|
|
|
m_bAllAnims = TRUE;
|
|
m_bAllActions = TRUE; //Mircea Dunka 15.10.1998
|
|
m_bActionPlay = FALSE; //Mircea Dunka 12.10.1998
|
|
|
|
//Mircea Dunka
|
|
if(m_bActionPlay)
|
|
GetDlgItem( IDC_BT_ANIM ) -> SetWindowText( m_bAllActions ? "Show Loaded Actions" : "Show All Actions");
|
|
else
|
|
GetDlgItem( IDC_BT_ANIM ) -> SetWindowText( m_bAllAnims ? "Show Loaded Animations" : "Show All Animations");
|
|
GetDlgItem( IDC_BT_ACTION )->SetWindowText( m_bActionPlay ? "Show Family Animation" : "Show Action Animation");
|
|
//end Mircea Dunka
|
|
|
|
/*
|
|
* Init data for animation play
|
|
*/
|
|
m_uiElapseTime = 1;
|
|
m_bPlay = FALSE;
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* WM_SHOWWINDOW
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnShowWindow(BOOL bShow, UINT nStatus)
|
|
{
|
|
CFormView::OnShowWindow(bShow, nStatus);
|
|
OnInitialUpdate();
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* WM_SIZE
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnSize(UINT nType, int cx, int cy)
|
|
{
|
|
CFormView::OnSize(nType, cx, cy);
|
|
/*
|
|
if (!bInitialUpdate)
|
|
{
|
|
GetDlgItem( IDC_BT_ANIM )->MoveWindow( 5, 5, 150, 15 );
|
|
GetDlgItem( IDC_LIST_ANIMS )->MoveWindow( 5, 23, 150, cy - 26 );
|
|
}
|
|
*/
|
|
if( GetDlgItem( IDC_LIST_ANIMS ) )
|
|
{
|
|
CRect oRectDlg, oRectList;
|
|
|
|
M_GetClientRect( this, &oRectDlg );
|
|
M_GetClientRectId( IDC_LIST_ANIMS, &oRectList );
|
|
|
|
oRectList . bottom = oRectDlg . bottom - 5;
|
|
|
|
M_SetClientRectId( IDC_LIST_ANIMS, &oRectList );
|
|
}
|
|
//Mircea Dunka 5.10.1998
|
|
if( GetDlgItem( IDC_LIST_ACTIONS ) )
|
|
{
|
|
CRect oRectDlg, oRectList;
|
|
|
|
M_GetClientRect( this, &oRectDlg );
|
|
M_GetClientRectId( IDC_LIST_ACTIONS, &oRectList );
|
|
|
|
oRectList . bottom = oRectDlg . bottom - 5;
|
|
|
|
M_SetClientRectId( IDC_LIST_ACTIONS, &oRectList );
|
|
}
|
|
//end Mircea Dunka
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* BN_CLICKED on IDC_BT_ANIM
|
|
* change Animations List content
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
|
|
//Mircea Dunka 16.10.1998
|
|
void CAnimationView::OnButtonAnim()
|
|
{
|
|
if(m_bActionPlay)
|
|
{
|
|
m_bAllActions = !m_bAllActions;
|
|
GetDlgItem( IDC_BT_ANIM ) -> SetWindowText( m_bAllActions ? "Show Loaded Actions" : "Show All Actions");
|
|
GetDlgItem( IDC_LIST_ACTIONS ) -> SetFocus();
|
|
mfn_vFillActionList();
|
|
}
|
|
else
|
|
{
|
|
m_bAllAnims = !m_bAllAnims;
|
|
GetDlgItem( IDC_BT_ANIM ) -> SetWindowText( m_bAllAnims ? "Show Loaded Animations" : "Show All Animations");
|
|
GetDlgItem( IDC_LIST_ANIMS ) -> SetFocus();
|
|
fn_vFillAnimList();
|
|
}
|
|
}
|
|
//end Mircea Dunka
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* LBN_SELCHANGE on IDC_LIST_FAMILIES
|
|
* display in list of animation list of family animations
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::fn_vFillAnimList()
|
|
{
|
|
CListBox *p_oAnimLB = (CListBox *) GetDlgItem( IDC_LIST_ANIMS );
|
|
POSITION xPos;
|
|
CPA_Animation *p_oAnim;
|
|
|
|
/*
|
|
* empty the animation list box
|
|
*/
|
|
p_oAnimLB -> ResetContent();
|
|
|
|
xPos = m_p_oFamily->m_oListOfAnimations.GetHeadPosition();
|
|
while( xPos )
|
|
{
|
|
p_oAnim = m_p_oFamily->m_oListOfAnimations.GetNext( xPos );
|
|
if( m_bAllAnims || p_oAnim -> fn_bIsAvailable() )
|
|
{
|
|
int iIndex = p_oAnimLB->AddString( p_oAnim->GetName() );
|
|
if ( iIndex != LB_ERR )
|
|
{
|
|
p_oAnimLB->SetItemData( iIndex, (long) p_oAnim );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//Mircea Dunka 27.09.98 - actions
|
|
BOOL fn_bIsActionAvailable(CPA_Action* p_oAction)
|
|
{
|
|
CPA_Animation* p_oAnimation;
|
|
if( !p_oAction )
|
|
return FALSE;
|
|
POSITION pos = p_oAction->m_oListOfStates.GetHeadPosition();
|
|
if(!pos)
|
|
return FALSE;
|
|
while(pos)
|
|
{
|
|
p_oAnimation = ((CPA_State*)(p_oAction->m_oListOfStates.GetNext(pos)))->mfn_p_oGetAnimation();
|
|
if(!p_oAnimation || !p_oAnimation->fn_bIsAvailable() )
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* LBN_SELCHANGE on IDC_LIST_FAMILIES
|
|
* display in list of action list of family animations
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::mfn_vFillActionList()
|
|
{
|
|
CListBox *p_oActionLB = (CListBox *) GetDlgItem( IDC_LIST_ACTIONS );
|
|
POSITION xPos;
|
|
CPA_Action *p_oAction;
|
|
|
|
/*
|
|
* empty action list box
|
|
*/
|
|
p_oActionLB -> ResetContent();
|
|
|
|
xPos = m_p_oFamily->m_oListOfActions.GetHeadPosition();
|
|
while( xPos )
|
|
{
|
|
p_oAction = m_p_oFamily->m_oListOfActions.GetNext( xPos );
|
|
|
|
if( m_bAllActions || fn_bIsActionAvailable(p_oAction))
|
|
{
|
|
int iIndex = p_oActionLB->AddString( p_oAction->GetName() );
|
|
if ( iIndex != LB_ERR )
|
|
{
|
|
p_oActionLB->SetItemData( iIndex, (long) p_oAction );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//end Mircea Dunka
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* LBN_SELCHANGE on IDC_LIST_FAMILIES
|
|
* display in list of animation list of family animations
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnSelchangeListAnims()
|
|
{
|
|
CListBox *p_oLB = (CListBox *) GetDlgItem( IDC_LIST_ANIMS );
|
|
int iIndex = p_oLB->GetCurSel();
|
|
BOOL bLoad = FALSE;
|
|
|
|
m_p_oCurrentAnim = NULL;
|
|
|
|
if (iIndex != LB_ERR)
|
|
{
|
|
m_bActionPlay = FALSE;
|
|
m_p_oCurrentAnim = (CPA_Animation *) p_oLB->GetItemData( iIndex );
|
|
if( m_p_oCurrentAnim -> fn_bIsAvailable() )
|
|
{
|
|
bLoad = TRUE;
|
|
}
|
|
}
|
|
|
|
if ( bLoad )
|
|
{
|
|
char szValue[10];
|
|
unsigned char ucFrameRate;
|
|
CSliderCtrl *pSlider = (CSliderCtrl*)GetDlgItem( IDC_SLIDER );
|
|
//ANNECY CT 20/02/98{
|
|
//GetDlgItem( IDC_BUTTON_LOAD )->ShowWindow( FALSE );
|
|
GetDlgItem( IDC_BUTTON_LOAD )->SetWindowText("ReLoad");
|
|
//ENDANNECY CT}
|
|
itoa( ((struct tdstAnim3d_*)m_p_oCurrentAnim -> GetData()) -> uwNumberOfFrames, szValue, 10);
|
|
GetDlgItem( IDC_EDIT_FRAME )->SetWindowText( szValue );
|
|
itoa( ((struct tdstAnim3d_*)m_p_oCurrentAnim -> GetData()) -> ucMaxNumberOfElements, szValue, 10);
|
|
GetDlgItem( IDC_EDIT_CHANNEL )->SetWindowText( szValue );
|
|
//Mircea Dunka
|
|
itoa(1, szValue, 10);
|
|
GetDlgItem( IDC_EDIT_ANIMATIONS )->SetWindowText( szValue );
|
|
GetDlgItem( IDC_EDIT_SELECTION_STATUS )->SetWindowText("The animation is O.K.");
|
|
m_uiTotalNumberOfFrames = ((struct tdstAnim3d_*)m_p_oCurrentAnim -> GetData()) -> uwNumberOfFrames;
|
|
//end Mircea Dunka
|
|
m_uwInitFrame = 0;
|
|
fn_vBeginAnim( m_uwInitFrame );
|
|
ucFrameRate = ((struct tdstAnim3d_*)m_p_oCurrentAnim -> GetData() ) -> ucFrameRate;
|
|
m_uiElapseTime = ucFrameRate ? 1000 / ucFrameRate : 1;
|
|
itoa( ucFrameRate, szValue, 10 );
|
|
GetDlgItem( IDC_EDIT_SPEED ) -> SetWindowText( szValue );
|
|
GetDlgItem( IDC_STATIC_CURRENTSPEED ) -> SetWindowText( szValue );
|
|
pSlider -> SetRange( 1, 255 );
|
|
pSlider -> SetPos( ucFrameRate );
|
|
}
|
|
else
|
|
{
|
|
//ANNECY CT 20/02/98{
|
|
GetDlgItem( IDC_BUTTON_LOAD )->SetWindowText("Load");
|
|
//GetDlgItem( IDC_BUTTON_LOAD )->ShowWindow( TRUE );
|
|
//ENDANNECY CT}
|
|
GetDlgItem( IDC_EDIT_FRAME )->SetWindowText( "" );
|
|
//Mircea Dunka
|
|
GetDlgItem( IDC_EDIT_ANIMATIONS )->SetWindowText( "" );
|
|
GetDlgItem( IDC_EDIT_SELECTION_STATUS )->SetWindowText("The animation isn't loaded");
|
|
//end Mircea Dunka
|
|
GetDlgItem( IDC_EDIT_CHANNEL )->SetWindowText( "" );
|
|
GetDlgItem( IDC_EDIT_SPEED ) -> SetWindowText( "" );
|
|
GetDlgItem( IDC_STATIC_CURRENTSPEED ) -> SetWindowText( "" );
|
|
}
|
|
|
|
GetDlgItem( IDC_BUTTON_REWIND )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_BUTTON_REVERSE )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_BUTTON_STOP )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_BUTTON_PLAY )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_BUTTON_FORWARD )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_STATIC_CURRENTFRAME )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_STATIC_CURRENTANIMATION )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_BT_REINIT )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_SLIDER )->EnableWindow( bLoad );
|
|
}
|
|
|
|
//Mircea Dunka
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* LBN_SELCHANGE on IDC_LIST_ACTIONS
|
|
* display in list of animation list of family animations
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnSelchangeListActions()
|
|
{
|
|
BOOL bLoad = TRUE;
|
|
BOOL bFirstAnimation = TRUE;
|
|
WORD uwNumberOfAvailableAnimations = 0;
|
|
WORD uwMaxNumberOfElements = 0;
|
|
WORD uwFrameRate = 0;
|
|
char szValue[10];
|
|
|
|
m_p_oCurrentAction = NULL;
|
|
m_p_oCurrentAnim = NULL;
|
|
m_uiTotalNumberOfFrames = 0;
|
|
m_uiNumberOfAnimations = 0;
|
|
|
|
CListBox *p_oAnimLB = (CListBox *) GetDlgItem( IDC_LIST_ANIMS );
|
|
CListBox *p_oActionLB = (CListBox *) GetDlgItem( IDC_LIST_ACTIONS );
|
|
int iIndex = p_oActionLB->GetCurSel();
|
|
|
|
if (iIndex != LB_ERR)
|
|
{
|
|
m_bActionPlay = TRUE; //Mircea Dunka 12.10.1998
|
|
GetDlgItem( IDC_BT_ANIM ) -> SetWindowText( m_bAllActions ? "Show Loaded Actions" : "Show All Actions");
|
|
GetDlgItem( IDC_BT_ACTION )->SetWindowText("Show Family Animation");
|
|
//get the current action (the selected one)
|
|
m_p_oCurrentAction = (CPA_Action *) p_oActionLB->GetItemData( iIndex );
|
|
//empty the animation list.
|
|
p_oAnimLB -> ResetContent();
|
|
//and refill it with the current action's animations
|
|
CPA_Animation *p_oAnimation;
|
|
POSITION pos = m_p_oCurrentAction->m_oListOfStates.GetHeadPosition();
|
|
if(!pos)
|
|
bLoad = FALSE;
|
|
while( pos )
|
|
{
|
|
p_oAnimation = ((CPA_State*)(m_p_oCurrentAction->m_oListOfStates.GetNext(pos)))->mfn_p_oGetAnimation();
|
|
m_uiNumberOfAnimations += 1;
|
|
if( p_oAnimation && p_oAnimation->fn_bIsAvailable() )
|
|
{
|
|
//get the current animation
|
|
if(bFirstAnimation)
|
|
{
|
|
m_p_oCurrentAnim = p_oAnimation;
|
|
bFirstAnimation = FALSE;
|
|
//see the "mfn_p_oGetDefaultState" member from CPA_Action
|
|
}
|
|
//refill the animation list.
|
|
iIndex = p_oAnimLB->AddString( p_oAnimation->GetName() );
|
|
if ( iIndex != LB_ERR )
|
|
{
|
|
p_oAnimLB->SetItemData( iIndex, (long)p_oAnimation );
|
|
}
|
|
|
|
uwNumberOfAvailableAnimations += 1;
|
|
//count the total nb. of frames
|
|
m_uiTotalNumberOfFrames += ((struct tdstAnim3d_*)p_oAnimation -> GetData()) -> uwNumberOfFrames;
|
|
//count the max nb. of channels (elements)
|
|
if( uwMaxNumberOfElements < ((struct tdstAnim3d_*)p_oAnimation -> GetData()) -> ucMaxNumberOfElements)
|
|
uwMaxNumberOfElements = ((struct tdstAnim3d_*)p_oAnimation -> GetData()) -> ucMaxNumberOfElements;
|
|
//count the medium frame rate
|
|
uwFrameRate += ((struct tdstAnim3d_*)p_oAnimation -> GetData() ) -> ucFrameRate;
|
|
}
|
|
else
|
|
bLoad = FALSE; //the current animation isn't loaded => the action isn't loaded
|
|
}
|
|
}
|
|
else
|
|
bLoad = FALSE; //no valid (complete) action (or no selection) in the list box
|
|
|
|
//display the total nb. of animations
|
|
itoa(m_uiNumberOfAnimations, szValue, 10);
|
|
GetDlgItem( IDC_EDIT_ANIMATIONS )->SetWindowText( szValue );
|
|
|
|
if(bLoad) //if the selected action is OK,
|
|
{
|
|
//display the total nb. of frames
|
|
itoa(m_uiTotalNumberOfFrames, szValue, 10);
|
|
GetDlgItem( IDC_EDIT_FRAME )->SetWindowText( szValue );
|
|
|
|
//display the max nb. of channels (elements)
|
|
itoa(uwMaxNumberOfElements, szValue, 10);
|
|
GetDlgItem( IDC_EDIT_CHANNEL )->SetWindowText( szValue );
|
|
|
|
//display the medium frame rate
|
|
if(m_uiNumberOfAnimations)
|
|
uwFrameRate = uwFrameRate/uwNumberOfAvailableAnimations;
|
|
m_uiElapseTime = uwFrameRate ? 1000 / uwFrameRate : 1;
|
|
itoa( uwFrameRate, szValue, 10 );
|
|
GetDlgItem( IDC_EDIT_SPEED ) -> SetWindowText( szValue );
|
|
GetDlgItem( IDC_STATIC_CURRENTSPEED ) -> SetWindowText( szValue );
|
|
CSliderCtrl *pSlider = (CSliderCtrl*)GetDlgItem( IDC_SLIDER );
|
|
pSlider -> SetRange( 1, 255 );
|
|
pSlider -> SetPos( uwFrameRate );
|
|
|
|
m_uwInitFrame = 0;
|
|
if( !m_p_oCurrentAnim )
|
|
return;
|
|
|
|
fn_vBeginAnim( m_uwInitFrame );
|
|
GetDlgItem( IDC_EDIT_SELECTION_STATUS )->SetWindowText("The action is O.K.");
|
|
}
|
|
else
|
|
{
|
|
char szBuffer[255];
|
|
WORD uwMissingAnims = m_uiNumberOfAnimations - uwNumberOfAvailableAnimations;
|
|
switch(uwMissingAnims)
|
|
{
|
|
case 0: wsprintf(szBuffer, "Bad action. No anims!!!");break;
|
|
case 1: wsprintf(szBuffer, "Bad action. %d missing anim", uwMissingAnims);break;
|
|
default:wsprintf(szBuffer, "Bad action. %d missing anims", uwMissingAnims);
|
|
}
|
|
GetDlgItem( IDC_EDIT_SELECTION_STATUS )->SetWindowText(szBuffer);
|
|
GetDlgItem( IDC_EDIT_FRAME )->SetWindowText( "" );
|
|
GetDlgItem( IDC_EDIT_CHANNEL )->SetWindowText( "" );
|
|
GetDlgItem( IDC_EDIT_SPEED )-> SetWindowText( "" );
|
|
GetDlgItem( IDC_STATIC_CURRENTSPEED ) -> SetWindowText( "" );
|
|
}
|
|
|
|
p_oAnimLB->SetCurSel(-1);
|
|
GetDlgItem( IDC_BUTTON_REWIND )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_BUTTON_REVERSE )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_BUTTON_STOP )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_BUTTON_PLAY )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_BUTTON_FORWARD )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_STATIC_CURRENTFRAME )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_STATIC_CURRENTANIMATION )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_BUTTON_LOAD )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_BT_REINIT )->EnableWindow( bLoad );
|
|
GetDlgItem( IDC_SLIDER )->EnableWindow( bLoad );
|
|
}
|
|
//end Mircea Dunka
|
|
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* BN_CLICKED on IDC_BUTTON_LOAD
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnButtonLoad()
|
|
{
|
|
if(!m_p_oCurrentAnim)
|
|
return;
|
|
HCURSOR hWaitCursor;
|
|
HCURSOR hOldCursor;
|
|
|
|
hWaitCursor = AfxGetApp()->LoadStandardCursor( IDC_WAIT );
|
|
hOldCursor = SetCursor( hWaitCursor );
|
|
|
|
//Mircea Dunka 11.10.98
|
|
GetDlgItem( IDC_EDIT_SELECTION_STATUS )->SetWindowText("Loading ...");
|
|
//GetDlgItem( IDC_BUTTON_LOAD )->SetWindowText("Loading ...");
|
|
GetDlgItem( IDC_BUTTON_LOAD )->EnableWindow( FALSE );
|
|
m_p_oCurrentAnim -> GetEditor() -> fn_bLoadBaseObject( m_p_oCurrentAnim );
|
|
|
|
//ANNECY CT 20/02/98{
|
|
GetDlgItem( IDC_BUTTON_LOAD )->SetWindowText("ReLoad");
|
|
//ENDANNECY CT}
|
|
GetDlgItem( IDC_BUTTON_LOAD )->EnableWindow( TRUE );
|
|
GetDlgItem( IDC_EDIT_SELECTION_STATUS )->SetWindowText("Animation loaded");
|
|
//end Mircea Dunka 11.10.98
|
|
|
|
SetCursor( hOldCursor );
|
|
|
|
GetDlgItem( IDC_LIST_ANIMS )->Invalidate();
|
|
OnSelchangeListAnims();
|
|
}
|
|
|
|
|
|
//Mircea Dunka
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* BN_CLICKED on IDC_BT_ACTION //Mircea Dunka 8.10.1998
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnButtonAction()
|
|
{
|
|
CString szListingType;
|
|
GetDlgItem( IDC_BT_ACTION )->GetWindowText(szListingType);
|
|
if(szListingType.CompareNoCase("show family animation") == 0)
|
|
{
|
|
//fill the animation list with all the animations
|
|
fn_vFillAnimList();
|
|
m_bActionPlay = FALSE; //Mircea Dunka 12.10.1998
|
|
GetDlgItem( IDC_BT_ACTION )->SetWindowText("Show Action Animation");
|
|
GetDlgItem( IDC_BT_ANIM ) -> SetWindowText( m_bAllAnims ? "Show Loaded Animations" : "Show All Animations");
|
|
|
|
((CListBox*)GetDlgItem( IDC_LIST_ACTIONS )) -> SetCurSel(-1);
|
|
((CListBox*)GetDlgItem( IDC_LIST_ANIMS )) -> SetCurSel(0);
|
|
GetDlgItem( IDC_LIST_ANIMS ) -> SetFocus();
|
|
}
|
|
else
|
|
{
|
|
//fill the animation list with the animations of the current action
|
|
//if no action is selected, a message box will appear
|
|
CListBox *p_oActionLB = (CListBox *) GetDlgItem( IDC_LIST_ACTIONS );
|
|
int iIndex = p_oActionLB->GetCurSel();
|
|
if (iIndex == LB_ERR)
|
|
if( (iIndex = p_oActionLB -> SetCurSel(0)) == LB_ERR) //check again, to see if there are any actions
|
|
{
|
|
GetDlgItem( IDC_EDIT_SELECTION_STATUS )->SetWindowText("The family doesn't contain any action");
|
|
return;
|
|
}
|
|
|
|
m_p_oCurrentAction = (CPA_Action *) p_oActionLB->GetItemData( iIndex );
|
|
//!!!
|
|
//empty the animation list.
|
|
//!!!
|
|
CListBox *p_oAnimLB = (CListBox *) GetDlgItem( IDC_LIST_ANIMS );
|
|
p_oAnimLB -> ResetContent();
|
|
CPA_Animation *p_oAnimation;
|
|
POSITION pos = m_p_oCurrentAction->m_oListOfStates.GetHeadPosition();
|
|
while( pos )
|
|
{
|
|
p_oAnimation = ((CPA_State*)(m_p_oCurrentAction->m_oListOfStates.GetNext(pos)))->mfn_p_oGetAnimation();
|
|
if( p_oAnimation && p_oAnimation->fn_bIsAvailable() )
|
|
{
|
|
iIndex = p_oAnimLB->AddString( p_oAnimation->GetName() );
|
|
if ( iIndex != LB_ERR )
|
|
p_oAnimLB->SetItemData( iIndex, (long)p_oAnimation );
|
|
}
|
|
}
|
|
|
|
m_bActionPlay = TRUE; //Mircea Dunka 12.10.1998
|
|
p_oAnimLB -> SetCurSel(0);
|
|
GetDlgItem( IDC_BT_ACTION )->SetWindowText("Show Family Animation");
|
|
GetDlgItem( IDC_BT_ANIM ) -> SetWindowText( m_bAllActions ? "Show Loaded Actions" : "Show All Actions");
|
|
GetDlgItem( IDC_LIST_ANIMS ) -> SetFocus();
|
|
}
|
|
}
|
|
//end Mircea Dunka
|
|
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* LBN_DBLCLK on IDC_LIST_ANIMS
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnDblclkListAnims()
|
|
{
|
|
OnButtonLoad();
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* BN_CLICKED on IDC_BUTTON_REWIND
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnButtonRewind()
|
|
{
|
|
OnHScroll( SB_LEFT, 0, (CScrollBar *) GetDlgItem( IDC_SCROLLBAR_FRAME ) );
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* BN_CLICKED on IDC_BUTTON_REVERSE
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnButtonReverse()
|
|
{
|
|
m_bReverse = TRUE;
|
|
//Mircea Dunka 19.10.98
|
|
if (!m_bPlay && (m_uiTotalNumberOfFrames > 1))
|
|
//end Mircea Dunka
|
|
{
|
|
m_bPlay = TRUE;
|
|
m_fn_vEnableControl( FALSE );
|
|
m_uiPlayTimer = SetTimer( 1, m_uiElapseTime, NULL );
|
|
}
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* BN_CLICKED on IDC_BUTTON_STOP
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnButtonStop()
|
|
{
|
|
m_fn_vStopAnim();
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* BN_CLICKED on IDC_BUTTON_PLAY
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnButtonPlay()
|
|
{
|
|
m_bReverse = FALSE;
|
|
//Mircea Dunka 19.10.98
|
|
if (!m_bPlay && (m_uiTotalNumberOfFrames > 1))
|
|
//end Mircea Dunka
|
|
{
|
|
m_bPlay = TRUE;
|
|
m_fn_vEnableControl( FALSE );
|
|
m_uiPlayTimer = SetTimer( 1, m_uiElapseTime, NULL );
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* BN_CLICKED on IDC_BUTTON_FORWARD
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnButtonForward()
|
|
{
|
|
OnHScroll( SB_RIGHT, 0, (CScrollBar *) GetDlgItem( IDC_SCROLLBAR_FRAME ) );
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* BN_CLICKED on IDC_BT_REINIT
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnButtonReinit()
|
|
{
|
|
char szValue[10];
|
|
unsigned char ucFrameRate;
|
|
CSliderCtrl *pSlider = (CSliderCtrl*)GetDlgItem( IDC_SLIDER );
|
|
|
|
if( m_p_oCurrentAnim && m_p_oCurrentAnim -> GetData() )
|
|
{
|
|
ucFrameRate = ((struct tdstAnim3d_*)m_p_oCurrentAnim -> GetData() ) -> ucFrameRate;
|
|
m_uiElapseTime = ucFrameRate ? 1000 / ucFrameRate : 1;
|
|
itoa( ucFrameRate, szValue, 10 );
|
|
GetDlgItem( IDC_EDIT_SPEED ) -> SetWindowText( szValue );
|
|
GetDlgItem( IDC_STATIC_CURRENTSPEED ) -> SetWindowText( szValue );
|
|
pSlider -> SetRange( 1, 255 );
|
|
pSlider -> SetPos( ucFrameRate );
|
|
if( m_bPlay )
|
|
{
|
|
KillTimer( m_uiPlayTimer );
|
|
m_uiPlayTimer = SetTimer( 1, m_uiElapseTime, NULL );
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* WM_TIMER
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnTimer(UINT nIDEvent)
|
|
{
|
|
OnHScroll( m_bReverse?SB_LINELEFT:SB_LINERIGHT, 0, (CScrollBar *) GetDlgItem( IDC_SCROLLBAR_FRAME ) );
|
|
CFormView::OnTimer(nIDEvent);
|
|
}
|
|
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* WM_HSCROLL
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
|
|
{
|
|
int iCurValue;
|
|
int iNewValue;
|
|
int iMax, iMin;
|
|
char szValue[10];
|
|
|
|
if( GetDlgItem( IDC_SLIDER ) == (CWnd*)pScrollBar )
|
|
{
|
|
iNewValue = ((CSliderCtrl*)GetDlgItem( IDC_SLIDER )) -> GetPos();
|
|
itoa( iNewValue, szValue, 10);
|
|
GetDlgItem( IDC_STATIC_CURRENTSPEED ) -> SetWindowText( szValue );
|
|
m_uiElapseTime = iNewValue ? 1000 / iNewValue : 1;
|
|
if( m_bPlay )
|
|
{
|
|
KillTimer( m_uiPlayTimer );
|
|
m_uiPlayTimer = SetTimer( 1, m_uiElapseTime, NULL );
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//IDC_SCROLLBARFRAME
|
|
iCurValue = pScrollBar->GetScrollPos();
|
|
iNewValue = iCurValue;
|
|
|
|
pScrollBar->GetScrollRange( &iMin, &iMax);
|
|
|
|
switch ( nSBCode )
|
|
{
|
|
case SB_LEFT:
|
|
iNewValue = iMin;
|
|
break;
|
|
case SB_RIGHT:
|
|
iNewValue = iMax;
|
|
break;
|
|
case SB_PAGELEFT :
|
|
iNewValue -= 4;
|
|
case SB_LINELEFT :
|
|
iNewValue --;
|
|
if (iNewValue < iMin)
|
|
iNewValue = iMax;
|
|
break;
|
|
case SB_PAGERIGHT :
|
|
iNewValue += 4;
|
|
case SB_LINERIGHT:
|
|
iNewValue ++;
|
|
if (iNewValue > iMax)
|
|
iNewValue = iMin;
|
|
break;
|
|
case SB_THUMBPOSITION:
|
|
case SB_THUMBTRACK:
|
|
iNewValue = nPos;
|
|
break;
|
|
case SB_ENDSCROLL:
|
|
return;
|
|
}
|
|
|
|
if (iNewValue != iCurValue)
|
|
{
|
|
pScrollBar->SetScrollPos( iNewValue );
|
|
iNewValue = pScrollBar->GetScrollPos();
|
|
if (iNewValue != iCurValue)
|
|
{
|
|
itoa( iNewValue + 1, szValue, 10);
|
|
GetDlgItem( IDC_STATIC_CURRENTFRAME )->SetWindowText( szValue );
|
|
fn_vShowFrame( iNewValue );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* WM_MEASUREITEM
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
|
|
{
|
|
//Mircea Dunka 5.10.98 IDC_LIST_ACTIONS added
|
|
if ( (nIDCtl == IDC_LIST_ANIMS) || (nIDCtl == IDC_LIST_FAMILIES) || (nIDCtl == IDC_LIST_ACTIONS) )
|
|
lpMeasureItemStruct->itemHeight = 14;
|
|
CFormView::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
|
|
}
|
|
|
|
//Mircea Dunka - Code optimization + action list drawing
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* WM_DRAWITEM
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDIS)
|
|
{
|
|
|
|
//Mircea Dunka 5.10.98 IDC_LIST_ACTIONS added so if was changed to switch
|
|
CDC *pDC = CDC::FromHandle( lpDIS->hDC );
|
|
CListBox *pLB = (CListBox *) GetDlgItem( nIDCtl );
|
|
BOOL bSelected = (lpDIS->itemState & ODS_SELECTED );
|
|
BOOL bLoad = TRUE;
|
|
CFont oBoldFont;
|
|
CFont *p_oOldFont = NULL;
|
|
CPA_Animation *p_oAnim = NULL;
|
|
CPA_Action *p_oAction = NULL;
|
|
CPA_Family *p_oFamily = NULL;
|
|
PLOGFONT plf = NULL;
|
|
|
|
switch (nIDCtl)
|
|
{
|
|
case IDC_LIST_ANIMS:
|
|
if (lpDIS->itemID == -1)
|
|
return;
|
|
p_oAnim = (CPA_Animation *) pLB->GetItemData( lpDIS->itemID );
|
|
pDC->FillSolidRect( &lpDIS->rcItem, GetSysColor( COLOR_WINDOW ));
|
|
|
|
if (p_oAnim->fn_bIsAvailable())
|
|
{
|
|
plf = (PLOGFONT) LocalAlloc(LPTR, sizeof(LOGFONT));
|
|
lstrcpy(plf->lfFaceName, "MS Sans Serif");
|
|
plf->lfWeight = FW_BOLD ;
|
|
plf->lfHeight = 8;
|
|
plf->lfEscapement = 0;
|
|
oBoldFont.CreateFontIndirect(plf);
|
|
p_oOldFont = pDC->SelectObject( &oBoldFont );
|
|
}
|
|
|
|
pDC->SetBkMode( TRANSPARENT);
|
|
pDC->SetTextColor( GetSysColor( COLOR_WINDOWTEXT ) );
|
|
|
|
pDC->DrawText( p_oAnim->GetName(), strlen(p_oAnim->GetName()), &lpDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER );
|
|
if (bSelected)
|
|
pDC->InvertRect( &lpDIS->rcItem );
|
|
if (p_oOldFont)
|
|
{
|
|
pDC->SelectObject( p_oOldFont );
|
|
oBoldFont.DeleteObject();
|
|
}
|
|
break;
|
|
case IDC_LIST_ACTIONS:
|
|
if (lpDIS->itemID == -1)
|
|
return;
|
|
p_oAction = (CPA_Action *) pLB->GetItemData( lpDIS->itemID );
|
|
|
|
bLoad = fn_bIsActionAvailable(p_oAction);
|
|
pDC->FillSolidRect( &lpDIS->rcItem, GetSysColor( COLOR_WINDOW ));
|
|
if(bLoad)
|
|
{
|
|
plf = (PLOGFONT) LocalAlloc(LPTR, sizeof(LOGFONT));
|
|
lstrcpy(plf->lfFaceName, "MS Sans Serif");
|
|
plf->lfWeight = FW_BOLD ;
|
|
plf->lfHeight = 8;
|
|
plf->lfEscapement = 0;
|
|
oBoldFont.CreateFontIndirect(plf);
|
|
p_oOldFont = pDC->SelectObject( &oBoldFont );
|
|
}
|
|
pDC->SetBkMode( TRANSPARENT);
|
|
pDC->SetTextColor( GetSysColor( COLOR_WINDOWTEXT ) );
|
|
|
|
pDC->DrawText( p_oAction->GetName(), strlen(p_oAction->GetName()), &lpDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER );
|
|
if (bSelected)
|
|
pDC->InvertRect( &lpDIS->rcItem );
|
|
if (p_oOldFont)
|
|
{
|
|
pDC->SelectObject( p_oOldFont );
|
|
oBoldFont.DeleteObject();
|
|
}
|
|
break;
|
|
case IDC_LIST_FAMILIES:
|
|
if (lpDIS->itemID == -1)
|
|
return;
|
|
p_oFamily = (CPA_Family *) pLB->GetItemData( lpDIS->itemID );
|
|
pDC->FillSolidRect( &lpDIS->rcItem, GetSysColor( COLOR_WINDOW ));
|
|
|
|
if (p_oFamily->fn_bIsAvailable())
|
|
{
|
|
plf = (PLOGFONT) LocalAlloc(LPTR, sizeof(LOGFONT));
|
|
lstrcpy(plf->lfFaceName, "MS Sans Serif");
|
|
plf->lfWeight = FW_BOLD ;
|
|
plf->lfHeight = 8;
|
|
plf->lfEscapement = 0;
|
|
oBoldFont.CreateFontIndirect(plf);
|
|
p_oOldFont = pDC->SelectObject( &oBoldFont );
|
|
}
|
|
|
|
pDC->SetBkMode( TRANSPARENT);
|
|
pDC->SetTextColor( GetSysColor( COLOR_WINDOWTEXT ) );
|
|
|
|
pDC->DrawText( p_oFamily->GetName(), strlen(p_oFamily->GetName()), &lpDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER );
|
|
if (bSelected)
|
|
pDC->InvertRect( &lpDIS->rcItem );
|
|
if (p_oOldFont)
|
|
{
|
|
pDC->SelectObject( p_oOldFont );
|
|
oBoldFont.DeleteObject();
|
|
}
|
|
break;
|
|
default:
|
|
CFormView::OnDrawItem(nIDCtl, lpDIS);
|
|
}
|
|
}
|
|
//end Mircea Dunka
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* PreTranslate message
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
BOOL CAnimationView::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
if( m_bPlay )
|
|
{
|
|
if (pMsg->message == WM_KEYDOWN)
|
|
{
|
|
switch( (int) pMsg->wParam )
|
|
{
|
|
case VK_HOME:
|
|
OnButtonRewind();
|
|
return 1;
|
|
case VK_LEFT:
|
|
OnButtonReverse();
|
|
return 1;
|
|
case VK_DOWN:
|
|
case VK_ESCAPE:
|
|
OnButtonStop();
|
|
return 1;
|
|
case VK_RIGHT:
|
|
OnButtonPlay();
|
|
return 1;
|
|
case VK_END:
|
|
OnButtonForward();
|
|
return 1;
|
|
}
|
|
}
|
|
}
|
|
return CFormView::PreTranslateMessage(pMsg);
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* WM_HELPINFO
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
BOOL CAnimationView::OnHelpInfo(HELPINFO* pHelpInfo)
|
|
{
|
|
/*
|
|
UINT uiCommand = HELP_CONTEXT;
|
|
DWORD dwContext = IDJ_ANIMVIEWER;
|
|
POINT stMousePos;
|
|
CWnd *p_oWnd;
|
|
|
|
GetCursorPos( &stMousePos );
|
|
ScreenToClient( &stMousePos );
|
|
p_oWnd = ChildWindowFromPoint( stMousePos, CWP_SKIPINVISIBLE );
|
|
|
|
if ( p_oWnd == GetDlgItem( IDC_LIST_ANIMS ) )
|
|
{
|
|
uiCommand = HELP_CONTEXTPOPUP;
|
|
dwContext = IDP_ANIMATIONLISTBOX;
|
|
}
|
|
else if ( (p_oWnd == GetDlgItem(IDC_EDIT_CHANNEL )) || (p_oWnd == GetDlgItem(IDC_EDIT_FRAME)) )
|
|
{
|
|
uiCommand = HELP_CONTEXTPOPUP;
|
|
dwContext = IDP_ANIMINFO;
|
|
}
|
|
else if ( p_oWnd == GetDlgItem( IDC_BUTTON_LOAD ) )
|
|
{
|
|
uiCommand = HELP_CONTEXT;
|
|
dwContext = IDJ_LOADINGANIMATION;
|
|
}
|
|
else if
|
|
(
|
|
(p_oWnd == GetDlgItem(IDC_SCROLLBAR_FRAME)) ||
|
|
(p_oWnd == GetDlgItem(IDC_BUTTON_REWIND)) ||
|
|
(p_oWnd == GetDlgItem(IDC_BUTTON_REVERSE)) ||
|
|
(p_oWnd == GetDlgItem(IDC_BUTTON_STOP)) ||
|
|
(p_oWnd == GetDlgItem(IDC_BUTTON_PLAY)) ||
|
|
(p_oWnd == GetDlgItem(IDC_BUTTON_FORWARD))
|
|
)
|
|
{
|
|
uiCommand = HELP_CONTEXT;
|
|
dwContext = IDJ_PLAYINGANIMATION;
|
|
}
|
|
|
|
if (_access( "Edt_data\\tools\\TAN\\animview.hlp", 0) != 0)
|
|
{
|
|
MessageBox("Help File : Edt_data\\tools\\TAN\\animview.hlp not found" );
|
|
return TRUE;
|
|
}
|
|
|
|
::WinHelp( m_hWnd,
|
|
"Edt_Data\\tools\\TAN\\animview.hlp",
|
|
uiCommand,
|
|
dwContext
|
|
);
|
|
*/
|
|
return CFormView::OnHelpInfo(pHelpInfo);
|
|
}
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------------
|
|
* BN_CLICKED on IDC_BUTTON_HELP
|
|
*-----------------------------------------------------------------------------
|
|
*/
|
|
void CAnimationView::OnButtonHelp()
|
|
{
|
|
OnHelpInfo(NULL);
|
|
}
|