Restructure repository to include all source folders
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>
This commit is contained in:
277
GameTools/WORLDCREATOR/MotionSheetTreeCtrl.cpp
Normal file
277
GameTools/WORLDCREATOR/MotionSheetTreeCtrl.cpp
Normal file
@@ -0,0 +1,277 @@
|
||||
// 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된 아이템이 drag된 아이템의 child 가 아닌지 확인
|
||||
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은 child를 가질수 없다
|
||||
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 이동
|
||||
pSrcSheet->rpParentSheet = pDestSheet;
|
||||
|
||||
// tree control 에 변경값 반영
|
||||
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 에 중복되는 이름의 motion이 있는지 확인
|
||||
if( pDestSheet->mapTok2Motlet.end() !=
|
||||
pDestSheet->mapTok2Motlet.find( tokMotion ) )
|
||||
{
|
||||
CString strErr;
|
||||
strErr.Format( "%s motion sheet에는 %s motion가 이미 존재함",
|
||||
g_TokSheetName.GetString(tokDestSheet),
|
||||
g_TokMotionName.GetString(tokMotion) );
|
||||
/*CString strErr = g_TokSheetName.GetString(tokDestSheet);
|
||||
strErr += " motion sheet에는 ";
|
||||
strErr += g_TokMotionName.GetString(tokMotion);
|
||||
strErr += " motion이 이미 존재함";*/
|
||||
MessageBox(strErr, "뷁");
|
||||
return;
|
||||
}
|
||||
|
||||
// motion(motlet) 이동
|
||||
pDestSheet->mapTok2Motlet[tokMotion] = pMotlet;
|
||||
pSrcSheet->mapTok2Motlet.erase(tokMotion);
|
||||
|
||||
// tree controll 에 이동값 반영
|
||||
// ************* insert point 찾는부분 구현할차례 *************
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user