⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 animview.cpp

📁 Resource editor base speadrum Chinese mobile
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        ::DeleteObject(m_hBmp);
        m_hBmp = NULL;
    }

	int nItemCount = 0;
	int nItemHasChildCount =0;

	CDirFileNode * pCurNode=NULL;
	if(hItem != NULL)
		pCurNode= (CDirFileNode *)tc.GetItemData(hItem);
	
    if( hItem != NULL && !tc.ItemHasChildren(hItem) && pCurNode == NULL)
    {       
        HTREEITEM hParent = tc.GetParentItem(hItem);
        if( hParent != NULL )
        {

		    HTREEITEM hNextItem;
		    HTREEITEM hChildItem = tc.GetChildItem(hParent);

		    while (hChildItem != NULL)
			{
			   hNextItem = tc.GetNextItem(hChildItem, TVGN_NEXT);
			   if(!tc.ItemHasChildren(hChildItem))
					nItemHasChildCount++;
			   hChildItem = hNextItem;
			   nItemCount ++;
			}
			if(nItemCount == nItemHasChildCount)
			{
				CDirFileNode * pNode = (CDirFileNode *)tc.GetItemData(hParent);

				PANIMINFO pAnimInfo = NULL;
				VERIFY( g_theApp.m_MMIRes.m_mapAnim.Lookup(pNode->szID, pAnimInfo) );
            
				CString strName = tc.GetItemText(hItem);
				int nIdx = _ttoi(strName);

				CBmpProcessor bmpProc;
				LPBYTE pBmp = NULL;
				if( !bmpProc.UnCompressMovie(pAnimInfo->pCompressed, nIdx - 1, pBmp) )
				{
					AfxMessageBox(_T("UnCompressMovie Failed!"));
					return;
				}
				m_hBmp = bmpProc.CreateBitmap(pBmp);  
				bmpProc.ReleaseCompressedStream(pBmp);
			}
        }
    }
   
    CHANGE_SEL_DATA selData;
    selData.hBmp     = m_hBmp;
    selData.bFreshBg = TRUE;
    pDoc->UpdateAllViews(this, WM_CHANGE_SEL_ITEM, (CObject*)&selData);

	*pResult = 0;
}

void CAnimView::OnRButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CMenu menu;
	VERIFY( menu.LoadMenu(IDM_POPUP_ANIM) );

	CMenu * pMenu = menu.GetSubMenu(0);

	CTreeCtrl &tc = GetTreeCtrl();
    
    UINT uFlag = 0;
	HTREEITEM hItem = tc.HitTest( point, &uFlag );
    if( !(uFlag & TVHT_ONITEM) )
        hItem = NULL;
   
    tc.SelectItem(hItem);

	if( PreTrackPopupMenu( pMenu, hItem ) )
	{
        ClientToScreen(&point);
		pMenu->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this);
	}

	//CTreeViewEx::OnRButtonDown(nFlags, point);
}

void CAnimView::OnUpdateAnimAdd(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CTreeCtrl &tc = GetTreeCtrl();
    
    BOOL bEnable = TRUE;
	HTREEITEM hItem = tc.GetSelectedItem();
    if( hItem != NULL )
    {
        CDirFileNode * pNode = (CDirFileNode *)tc.GetItemData(hItem);
        if( !m_pInfo->IsDirNode(pNode) )
            bEnable = FALSE;
    }

	pCmdUI->Enable(bEnable);
}

void CAnimView::OnUpdateAnimDel(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CTreeCtrl &tc = GetTreeCtrl();
    
	HTREEITEM hItem = tc.GetSelectedItem();
	CDirFileNode *pNode =NULL;
	if(hItem !=NULL)
		pNode = (CDirFileNode *)tc.GetItemData(hItem);
    BOOL bEnable = ( hItem != NULL && (tc.GetChildItem(hItem) != NULL || pNode != NULL ));

	pCmdUI->Enable(bEnable);
}

void CAnimView::OnUpdateAnimProperty(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CTreeCtrl &tc = GetTreeCtrl();
    
    BOOL bEnable = FALSE;
	HTREEITEM hItem = tc.GetSelectedItem();
    if( hItem != NULL )
    {
        CDirFileNode * pNode = (CDirFileNode *)tc.GetItemData(hItem);
        if( pNode != NULL && !m_pInfo->IsDirNode(pNode) )
            bEnable = TRUE;
    }

	pCmdUI->Enable(bEnable);
}

void CAnimView::OnUpdateAnimReplace(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CTreeCtrl &tc = GetTreeCtrl();
    
    HTREEITEM hItem = tc.GetSelectedItem();
    BOOL bEnable = ( hItem != NULL && tc.GetChildItem(hItem) != NULL );

	pCmdUI->Enable(bEnable);
}

void CAnimView::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	if( nIDEvent == PLAY_TIMER )
    {
        _ASSERTE( m_pAnimInfo != NULL );

        if( m_nPlayIdx >= m_pAnimInfo->nFrameNum )
        {
            m_nPlayEnd++;
            if( m_nPlayEnd < 4 )
                return;

            m_nPlayEnd = 0;
            m_nPlayIdx = 0;
        }

        CBmpProcessor bmpProc;
        if( m_hBmp != NULL )
            ::DeleteObject(m_hBmp);
        
        LPBYTE pBmp = NULL;
        //VERIFY( bmpProc.UnCompressMovie(m_pAnimInfo->pCompressed, m_nPlayIdx, pBmp) );//@hongliang.xin
		if( ! bmpProc.UnCompressMovie(m_pAnimInfo->pCompressed, m_nPlayIdx, pBmp) )
		{
			m_bPlay = FALSE;
			KillTimer(PLAY_TIMER);
			AfxMessageBox(_T("UnCompressMovie Failed!"));
			return;
		}
        m_hBmp = bmpProc.CreateBitmap(pBmp);  
        bmpProc.ReleaseCompressedStream(pBmp);
        
        CDocument * pDoc = GetDocument();
        ASSERT_VALID( pDoc );

        CHANGE_SEL_DATA selData;
        selData.hBmp     = m_hBmp;
        selData.bFreshBg = FALSE;
        pDoc->UpdateAllViews(this, WM_CHANGE_SEL_ITEM, (CObject*)&selData);

        m_nPlayIdx++;
    }

	CTreeViewEx::OnTimer(nIDEvent);
}

void CAnimView::OnAnimPlay() 
{
	// TODO: Add your command handler code here
  
    CTreeCtrl &tc = GetTreeCtrl();
	HTREEITEM hItem = tc.GetSelectedItem();
    _ASSERTE( hItem != NULL );
    
    CDirFileNode * pNode = (CDirFileNode *)tc.GetItemData(hItem);
    _ASSERTE( !m_pInfo->IsDirNode(pNode) );

    VERIFY( g_theApp.m_MMIRes.m_mapAnim.Lookup(pNode->szID, m_pAnimInfo) );

    m_nPlayIdx = 0;
    m_nPlayEnd = 0;
    if( !m_bPlay )
    {
	    SetTimer(PLAY_TIMER, m_nPlayInterval, NULL);
    }
    else
    {
        KillTimer(PLAY_TIMER);
    
        CDocument * pDoc = GetDocument();
        ASSERT_VALID( pDoc );

        CHANGE_SEL_DATA selData;
        selData.hBmp     = NULL;
        selData.bFreshBg = TRUE;
        pDoc->UpdateAllViews(this, WM_CHANGE_SEL_ITEM, (CObject*)&selData);
       
    }

    m_bPlay = !m_bPlay;
}

void CAnimView::OnUpdateAnimPlay(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	static _TCHAR szText[16];
    if( !m_bPlay )
        _tcscpy(szText, _T("Play"));
    else
        _tcscpy(szText, _T("Stop"));

    CTreeCtrl &tc = GetTreeCtrl();
    
    BOOL bEnable = FALSE;
	HTREEITEM hItem = tc.GetSelectedItem();
    if( hItem != NULL )
    {
        CDirFileNode * pNode = (CDirFileNode *)tc.GetItemData(hItem);
        if( pNode != NULL && !m_pInfo->IsDirNode(pNode) )
            bEnable = TRUE;
    }

	pCmdUI->Enable(bEnable);
    if( bEnable ) pCmdUI->SetText(szText);
}

void CAnimView::OnOptionPlaySetting() 
{
	// TODO: Add your command handler code here
	CPlayDlg dlg;
    dlg.m_nFreq = 1000 / m_nPlayInterval;
    if( dlg.DoModal() == IDOK )
    {
        m_nPlayInterval = 1000 / dlg.m_nFreq; 
        if( m_bPlay )
        {
            KillTimer(PLAY_TIMER);
            SetTimer(PLAY_TIMER, m_nPlayInterval, NULL);
        }
    }
}

void CAnimView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	// TODO: Add your specialized code here and/or call the base class
	if( pSender != this && lHint == WM_OUTBAR_GOTO )
    {
        this->SetFocus();

        CTreeCtrl &tc = GetTreeCtrl();

        HTREEITEM hItem = (HTREEITEM)pHint;

        tc.SelectItem(hItem);
        tc.EnsureVisible(hItem);
    }	
}

void CAnimView::OnOptionAnimSizeinfo() 
{
	// TODO: Add your command handler code here
	POSITION pos = m_SizeInfo.GetStartPosition();

    CDocument * pDoc = GetDocument();
    ASSERT_VALID( pDoc );
    
    OUT_BAR_PARAM obp;
    obp.arrTxt.Add("Name");
    obp.arrTxt.Add("Old Size(Bytes)");
    obp.arrTxt.Add("New Size(Bytes)");
    pDoc->UpdateAllViews(this, WM_OUTBAR_INSERT_CLMN, (CObject *)&obp);
        
    CTreeCtrl &tc = GetTreeCtrl();
    DWORD dwKey, dwOld, dwNew;
    CString strTxt;
    while( pos != NULL )
    {
        obp.arrTxt.RemoveAll();

        m_SizeInfo.GetNextAssoc(pos, dwKey, dwOld, dwNew);
        obp.arrTxt.Add( tc.GetItemText( (HTREEITEM)dwKey ) );
        
        strTxt.Format( _T("%d"), dwOld );
        obp.arrTxt.Add( strTxt );
        
        strTxt.Format( _T("%d"), dwNew );
        obp.arrTxt.Add( strTxt );

        obp.dwData = dwKey;

        pDoc->UpdateAllViews(this, WM_OUTBAR_ADD_ITEM, (CObject *)&obp);
    }   
    
    CWnd * pFrame = (CWnd *)GetParentFrame();
    _ASSERTE( pFrame != NULL );
    pFrame->SendMessage(WM_SHOW_OUTBAR, SHOW_OUTBAR, 0);
}

void CAnimView::OnUpdateOptionAnimSizeinfo(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable( m_SizeInfo.GetStartPosition() != NULL );
}

void CAnimView::OnAnimExport() 
{
	// TODO: Add your command handler code here
	CTreeCtrl &tc   = GetTreeCtrl();
    HTREEITEM hItem = tc.GetSelectedItem();

    if( hItem == NULL ) 
        hItem = TVI_ROOT;

    CDirFileNode * pRoot = hItem != TVI_ROOT ?
                           (CDirFileNode *)tc.GetItemData(hItem) :
                           (CDirFileNode *)m_pInfo->GetRoot();


	CFileDialog dlg(FALSE,
		NULL,
		pRoot->szName);

    if(dlg.DoModal() == IDCANCEL)
		return;

    CString strDirName = dlg.GetPathName();
    if( strDirName.IsEmpty() )
        return;


    CWaitCursor waitCur;

    EnumAndExportAnims(pRoot,strDirName); 	


}

void CAnimView::OnUpdateAnimExport(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CTreeCtrl &tc = GetTreeCtrl();
    
    HTREEITEM hItem = tc.GetSelectedItem();
    BOOL bEnable = ( hItem != NULL && tc.GetChildItem(hItem) != NULL );

	pCmdUI->Enable(bEnable);	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -