Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
278 lines
6.6 KiB
C++
278 lines
6.6 KiB
C++
// MotionSheetTreeCtrl.cpp : implementation file
|
||
//
|
||
|
||
#include "stdafx.h"
|
||
#include "worldcreator.h"
|
||
#include "MotionSheetTreeCtrl.h"
|
||
|
||
#ifdef _DEBUG
|
||
#define new DEBUG_NEW
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[] = __FILE__;
|
||
#endif
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CMotionSheetTreeCtrl
|
||
|
||
CMotionSheetTreeCtrl::CMotionSheetTreeCtrl()
|
||
{
|
||
m_pDragImage = NULL;
|
||
m_bDragging = false;
|
||
m_hItemDrag = m_hItemDrop = NULL;
|
||
m_rpGCMDS = NULL;
|
||
}
|
||
|
||
CMotionSheetTreeCtrl::~CMotionSheetTreeCtrl()
|
||
{
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CMotionSheetTreeCtrl, CTreeCtrl)
|
||
//{{AFX_MSG_MAP(CMotionSheetTreeCtrl)
|
||
ON_NOTIFY_REFLECT(TVN_BEGINDRAG, OnBegindrag)
|
||
ON_WM_MOUSEMOVE()
|
||
ON_WM_LBUTTONUP()
|
||
//}}AFX_MSG_MAP
|
||
END_MESSAGE_MAP()
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CMotionSheetTreeCtrl message handlers
|
||
|
||
void CMotionSheetTreeCtrl::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
|
||
// TODO: Add your control notification handler code here
|
||
|
||
*pResult = 0;
|
||
|
||
m_hItemDrag = pNMTreeView->itemNew.hItem;
|
||
m_hItemDrop = NULL;
|
||
|
||
m_pDragImage = CreateDragImage(m_hItemDrag);
|
||
if( NULL == m_pDragImage )
|
||
{
|
||
return;
|
||
}
|
||
|
||
m_bDragging = true;
|
||
m_pDragImage->BeginDrag(0, CPoint(0,0));
|
||
m_pDragImage->DragEnter(this, pNMTreeView->ptDrag);
|
||
SetCapture();
|
||
}
|
||
|
||
void CMotionSheetTreeCtrl::OnMouseMove(UINT nFlags, CPoint point)
|
||
{
|
||
// TODO: Add your message handler code here and/or call default
|
||
HTREEITEM hItem;
|
||
UINT flags = 0;
|
||
|
||
if( m_bDragging )
|
||
{
|
||
POINT pt = point;
|
||
if( pt.y < 0 )
|
||
{
|
||
m_pDragImage->DragShowNolock(FALSE);
|
||
SendMessage( WM_VSCROLL, SB_LINEUP );
|
||
m_pDragImage->DragShowNolock(TRUE);
|
||
}
|
||
|
||
if( pt.x < 0 )
|
||
{
|
||
m_pDragImage->DragShowNolock(FALSE);
|
||
SendMessage( WM_HSCROLL, SB_LINELEFT );
|
||
m_pDragImage->DragShowNolock(TRUE);
|
||
}
|
||
|
||
ClientToScreen( &pt );
|
||
m_pDragImage->DragMove(point);
|
||
|
||
if( NULL != (hItem = HitTest(point, &flags)) )
|
||
{
|
||
m_pDragImage->DragShowNolock(FALSE);
|
||
SelectDropTarget(hItem);
|
||
EnsureVisible(hItem);
|
||
m_hItemDrop = hItem;
|
||
m_pDragImage->DragShowNolock(TRUE);
|
||
}
|
||
|
||
}
|
||
|
||
CTreeCtrl::OnMouseMove(nFlags, point);
|
||
}
|
||
|
||
void CMotionSheetTreeCtrl::OnLButtonUp(UINT nFlags, CPoint point)
|
||
{
|
||
// TODO: Add your message handler code here and/or call default
|
||
|
||
CTreeCtrl::OnLButtonUp(nFlags, point);
|
||
|
||
if( !m_bDragging )
|
||
{
|
||
return;
|
||
}
|
||
|
||
m_bDragging = false;
|
||
m_pDragImage->DragLeave(this);
|
||
m_pDragImage->EndDrag();
|
||
ReleaseCapture();
|
||
|
||
delete m_pDragImage;
|
||
m_pDragImage = NULL;
|
||
|
||
SelectDropTarget(NULL);
|
||
|
||
if( m_hItemDrag == m_hItemDrop )
|
||
{
|
||
return;
|
||
}
|
||
|
||
// drop<6F><70> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> drag<61><67> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> child <20><> <20>ƴ<EFBFBD><C6B4><EFBFBD> Ȯ<><C8AE>
|
||
HTREEITEM hParent = m_hItemDrop;
|
||
while( NULL != (hParent = GetParentItem(hParent)) )
|
||
{
|
||
if( hParent == m_hItemDrag )
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
|
||
//Expand( m_hItemDrop, TVE_EXPAND );
|
||
|
||
// actually move item code
|
||
if( 0 != GetItemData( m_hItemDrop ) )
|
||
{
|
||
// motion item<65><6D> child<6C><64> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||
return;
|
||
}
|
||
|
||
if( 0 == GetItemData(m_hItemDrag) )
|
||
{
|
||
// 'motion sheet' dropped on 'motion sheet'
|
||
Z3DTOK tokSrcSheet, tokDestSheet;
|
||
Z3DMOTIONSHEET* pSrcSheet;
|
||
Z3DMOTIONSHEET* pDestSheet;
|
||
tokSrcSheet = g_TokSheetName.GetTOK( GetItemText(m_hItemDrag) );
|
||
tokDestSheet = g_TokSheetName.GetTOK( GetItemText(m_hItemDrop) );
|
||
pSrcSheet = m_rpGCMDS->GetMotionsheet(tokSrcSheet);
|
||
pDestSheet = m_rpGCMDS->GetMotionsheet(tokDestSheet);
|
||
|
||
if( pSrcSheet->rpParentSheet == pDestSheet )
|
||
{
|
||
return;
|
||
}
|
||
|
||
// motion sheet <20>̵<EFBFBD>
|
||
pSrcSheet->rpParentSheet = pDestSheet;
|
||
|
||
// tree control <20><> <20><><EFBFBD>氪 <20>ݿ<EFBFBD>
|
||
HTREEITEM hItemNew = CopyItem( m_hItemDrag, m_hItemDrop, TVI_LAST );
|
||
DeleteItem(m_hItemDrag);
|
||
EnsureVisible( hItemNew );
|
||
SelectItem(hItemNew);
|
||
|
||
}
|
||
else
|
||
{
|
||
// 'motion' dropped on 'motion sheet'
|
||
Z3DTOK tokSrcSheet, tokDestSheet, tokMotion;
|
||
Z3DMOTIONSHEET* pSrcSheet;
|
||
Z3DMOTIONSHEET* pDestSheet;
|
||
Z3DMOTLET* pMotlet;
|
||
tokSrcSheet = g_TokSheetName.GetTOK( GetItemText(GetParentItem(m_hItemDrag)) );
|
||
tokDestSheet = g_TokSheetName.GetTOK( GetItemText(m_hItemDrop) );
|
||
tokMotion = g_TokMotionName.GetTOK( GetItemText(m_hItemDrag) );
|
||
pSrcSheet = m_rpGCMDS->GetMotionsheet(tokSrcSheet);
|
||
pDestSheet = m_rpGCMDS->GetMotionsheet(tokDestSheet);
|
||
pMotlet = (Z3DMOTLET*)GetItemData(m_hItemDrag);
|
||
|
||
if( pSrcSheet == pDestSheet )
|
||
{
|
||
return;
|
||
}
|
||
|
||
// target motion sheet <20><> <20>ߺ<EFBFBD><DFBA>Ǵ<EFBFBD> <20≯<EFBFBD><CCB8><EFBFBD> motion<6F><6E> <20>ִ<EFBFBD><D6B4><EFBFBD> Ȯ<><C8AE>
|
||
if( pDestSheet->mapTok2Motlet.end() !=
|
||
pDestSheet->mapTok2Motlet.find( tokMotion ) )
|
||
{
|
||
CString strErr;
|
||
strErr.Format( "%s motion sheet<65><74><EFBFBD><EFBFBD> %s motion<6F><6E> <20>̹<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||
g_TokSheetName.GetString(tokDestSheet),
|
||
g_TokMotionName.GetString(tokMotion) );
|
||
/*CString strErr = g_TokSheetName.GetString(tokDestSheet);
|
||
strErr += " motion sheet<65><74><EFBFBD><EFBFBD> ";
|
||
strErr += g_TokMotionName.GetString(tokMotion);
|
||
strErr += " motion<6F><6E> <20>̹<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";*/
|
||
MessageBox(strErr, "<EFBFBD><EFBFBD>");
|
||
return;
|
||
}
|
||
|
||
// motion(motlet) <20>̵<EFBFBD>
|
||
pDestSheet->mapTok2Motlet[tokMotion] = pMotlet;
|
||
pSrcSheet->mapTok2Motlet.erase(tokMotion);
|
||
|
||
// tree controll <20><> <20>̵<EFBFBD><CCB5><EFBFBD> <20>ݿ<EFBFBD>
|
||
// ************* insert point ã<>ºκ<C2BA> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *************
|
||
HTREEITEM hInsertPoint = GetChildItem( m_hItemDrop );
|
||
if( NULL == hInsertPoint || 0 == GetItemData(hInsertPoint) )
|
||
{
|
||
hInsertPoint = TVI_FIRST;
|
||
}
|
||
else
|
||
{
|
||
while(1)
|
||
{
|
||
HTREEITEM hTmp = GetNextSiblingItem(hInsertPoint);
|
||
if( NULL == hTmp || 0 == GetItemData(hTmp) )
|
||
{
|
||
break;
|
||
}
|
||
hInsertPoint = hTmp;
|
||
}
|
||
}
|
||
|
||
HTREEITEM hItemNew = CopyItem( m_hItemDrag, m_hItemDrop, hInsertPoint );
|
||
DeleteItem(m_hItemDrag);
|
||
EnsureVisible( hItemNew );
|
||
SelectItem(hItemNew);
|
||
}
|
||
}
|
||
|
||
HTREEITEM CMotionSheetTreeCtrl::CopyItem( HTREEITEM hItem, HTREEITEM htiNewParent,
|
||
HTREEITEM htiAfter /*= TVI_LAST*/ )
|
||
{
|
||
TV_INSERTSTRUCT tvstruct;
|
||
HTREEITEM hNewItem;
|
||
CString sText;
|
||
|
||
// get information of the source item
|
||
tvstruct.item.hItem = hItem;
|
||
tvstruct.item.mask = TVIF_CHILDREN | TVIF_HANDLE |
|
||
TVIF_IMAGE | TVIF_SELECTEDIMAGE;
|
||
GetItem(&tvstruct.item);
|
||
sText = GetItemText( hItem );
|
||
|
||
tvstruct.item.cchTextMax = sText.GetLength();
|
||
tvstruct.item.pszText = sText.LockBuffer();
|
||
|
||
// Insert the item at proper location
|
||
tvstruct.hParent = htiNewParent;
|
||
tvstruct.hInsertAfter = htiAfter;
|
||
tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
|
||
hNewItem = InsertItem(&tvstruct);
|
||
sText.ReleaseBuffer();
|
||
|
||
// Now copy item data and item state.
|
||
SetItemData( hNewItem, GetItemData( hItem ));
|
||
SetItemState( hNewItem, GetItemState( hItem, TVIS_STATEIMAGEMASK ),
|
||
TVIS_STATEIMAGEMASK );
|
||
|
||
HTREEITEM hChild = GetChildItem( hItem );
|
||
while( NULL != hChild )
|
||
{
|
||
CopyItem( hChild, hNewItem, TVI_LAST );
|
||
hChild = GetNextSiblingItem( hChild );
|
||
}
|
||
|
||
return hNewItem;
|
||
}
|