📄 terraineffecteditordlg.cpp
字号:
// TerrainEffectEditorDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TerrainEffectEditor.h"
#include "TerrainEffectEditorDlg.h"
#include "ND_Bitmap.h"
#include "3DRoleData.h"
#include "GameDataSet.h"
#include "3DGameMap.h"
#include "../NDSound/NdSound.h"
#include "DialogExit.h"
#include "DialogNew.h"
#include "Player.h"
#include "Hero.h"
#include "3DRole.h"
#include "GamePlayerSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
char g_szTerrianFlag[256][16];
/////////////////////////////////////////////////////////////////////////////
// CTerrainEffectEditorDlg dialog
CTerrainEffectEditorDlg::CTerrainEffectEditorDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTerrainEffectEditorDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTerrainEffectEditorDlg)
m_bCell = FALSE;
m_strDelay = _T("");
m_strLife = _T("");
m_strOffsetX = _T("");
m_strOffsetY = _T("");
m_nShowType = -1;
m_strZoom = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
g_obj3DRoleData.Init();
g_objGameDataSet.Init();
}
void CTerrainEffectEditorDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTerrainEffectEditorDlg)
DDX_Control(pDX, IDC_LIST_VMESH, m_ctlVMesh);
DDX_Control(pDX, IDC_SLIDER_ZOOM, m_ctlZoom);
DDX_Control(pDX, IDC_LIST_PART, m_ctlPart);
DDX_Control(pDX, IDC_COMBO_D, m_ctlD);
DDX_Control(pDX, IDC_COMBO_S, m_ctlS);
DDX_Control(pDX, IDC_LIST_EDIT, m_ctrlListEdit);
DDX_Control(pDX, IDC_LIST, m_ctrlList);
DDX_Control(pDX, IDC_MAIN_PIC, m_ctrlPic);
DDX_Check(pDX, IDC_CHECK_CELL, m_bCell);
DDX_Text(pDX, IDC_EDIT_DELAY, m_strDelay);
DDX_Text(pDX, IDC_EDIT_LIFE, m_strLife);
DDX_Text(pDX, IDC_EDIT_OFFSETX, m_strOffsetX);
DDX_Text(pDX, IDC_EDIT_OFFSETY, m_strOffsetY);
DDX_Radio(pDX, IDC_RADIO_G, m_nShowType);
DDX_Text(pDX, IDC_STATIC_ZOOM, m_strZoom);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTerrainEffectEditorDlg, CDialog)
//{{AFX_MSG_MAP(CTerrainEffectEditorDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_CLOSE()
ON_WM_TIMER()
ON_WM_RBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_CHECK_CELL, OnCheckCell)
ON_BN_CLICKED(IDC_BUTTON_TOCENTEL, OnButtonTocentel)
ON_BN_CLICKED(IDC_BUTTON_FLASH, OnButtonFlash)
ON_LBN_SELCHANGE(IDC_LIST, OnSelchangeList)
ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
ON_BN_CLICKED(IDC_BUTTON_DEL, OnButtonDel)
ON_BN_CLICKED(IDC_BB_PLAYER, OnBbPlayer)
ON_BN_CLICKED(IDC_BUTTON_PLAY, OnButtonPlay)
ON_BN_CLICKED(IDC_BUTTON_STOP, OnButtonStop)
ON_BN_CLICKED(IDC_BUTTON_SET, OnButtonSet)
ON_LBN_SELCHANGE(IDC_LIST_EDIT, OnSelchangeListEdit)
ON_BN_CLICKED(IDC_BUTTON7, OnButtonflashEdit)
ON_BN_CLICKED(IDC_BUTTON_SAVE, OnButtonSave)
ON_BN_CLICKED(IDC_BUTTON_LOAD, OnButtonLoad)
ON_BN_CLICKED(IDC_BUTTON_NEW, OnButtonNew)
ON_LBN_DBLCLK(IDC_LIST, OnDblclkList)
ON_CBN_EDITCHANGE(IDC_COMBO_D, OnEditchangeComboD)
ON_CBN_EDITCHANGE(IDC_COMBO_S, OnEditchangeComboS)
ON_CBN_SELCHANGE(IDC_COMBO_D, OnSelchangeComboD)
ON_CBN_SELCHANGE(IDC_COMBO_S, OnSelchangeComboS)
ON_BN_CLICKED(IDC_BUTTON_M1, OnButtonM1)
ON_BN_CLICKED(IDC_BUTTON_M2, OnButtonM2)
ON_BN_CLICKED(IDC_BUTTON_M3, OnButtonM3)
ON_BN_CLICKED(IDC_BUTTON_M4, OnButtonM4)
ON_BN_CLICKED(IDC_BUTTON_UPDATETOFILE, OnButtonUpdatetofile)
ON_LBN_SELCHANGE(IDC_LIST_PART, OnSelchangeListPart)
ON_BN_CLICKED(IDC_RADIO_G, OnRadioG)
ON_BN_CLICKED(IDC_RADIO_H, OnRadioH)
ON_BN_CLICKED(IDC_RADIO_W, OnRadioW)
ON_BN_CLICKED(IDC_BUTTON_HERO, OnButtonHero)
ON_BN_CLICKED(IDC_BUTTON_SELECT, OnButtonSelect)
ON_BN_CLICKED(IDC_BUTTON_ALL, OnButtonAll)
ON_BN_CLICKED(IDC_BUTTON_LOADDMAP, OnButtonLoaddmap)
ON_NOTIFY(NM_OUTOFMEMORY, IDC_SLIDER_ZOOM, OnOutofmemorySliderZoom)
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_ZOOM, OnReleasedcaptureSliderZoom)
ON_BN_CLICKED(IDC_BUTTON_CLONEPLYAER, OnButtonCloneplyaer)
ON_BN_CLICKED(IDC_BUTTON_EDITRECOVER, OnButtonEditrecover)
ON_BN_CLICKED(IDC_BUTTON_EDITCPOY, OnButtonEditcpoy)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTerrainEffectEditorDlg message handlers
BOOL CTerrainEffectEditorDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
this->MyInit();
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CTerrainEffectEditorDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CTerrainEffectEditorDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::MyInit()
{
_SCR_WIDTH = 800;
_SCR_HEIGHT = 600;
extern BOOL GameInit(HWND hWnd);
GameInit(this->m_ctrlPic.GetSafeHwnd());
this->SetTimer(WM_TIMER, 30, NULL);
CMyBitmap::GameCameraCreate();
DXSoundinit ( this->GetSafeHwnd ( ) ) ;
g_hGameWnd = this->GetSafeHwnd();
g_objGameMap.m_bShowMiniMap = false;
g_objGameMap.LoadDataMap("bg.dmap");
g_objGameMap.GetInteractiveLayer()->AddMapObj(&g_objHero);
g_objGameMap.SetScale(_NORMAL_SCALE);
g_objHero.SetName("大哥");
g_objHero.ReplaceStatus(0);
g_objHero.SetLook(1);
this->OnButtonTocentel();
extern UINT g_uStatus;
g_uStatus = _STATUS_NORMAL ;
//g_objHero.setfat
this->FlashList();
m_p3DMapEffect = NULL;
m_bPreview = false;
m_nMouseOperate = 0;
m_strDelay = "0";
m_strLife = "0";
m_strOffsetX = "0";
m_strOffsetY = "0";
m_nMouseUnit = -1;
m_bPlayer = false;
m_ctlS.InsertString(0, "ZERO");
m_ctlS.InsertString(1, "ONE");
m_ctlS.InsertString(2, "SRCCOLOR");
m_ctlS.InsertString(3, "INVSRCCOLOR");
m_ctlS.InsertString(4, "SRCALPHA");
m_ctlS.InsertString(5, "INVSRCALPHA");
m_ctlS.InsertString(6, "DESTALPHA");
m_ctlS.InsertString(7, "INVDESTALPHA");
m_ctlS.InsertString(8, "DESTCOLOR");
m_ctlS.InsertString(9, "INVDESTCOLOR");
m_ctlS.InsertString(10, "ISRCALPHASAT");
m_ctlS.InsertString(11, "BOTHSRCALPHA");
m_ctlS.InsertString(12, "BOTHINVSRCALPHA");
m_ctlS.SetCurSel(5);
m_ctlD.InsertString(0, "ZERO");
m_ctlD.InsertString(1, "ONE");
m_ctlD.InsertString(2, "SRCCOLOR");
m_ctlD.InsertString(3, "INVSRCCOLOR");
m_ctlD.InsertString(4, "SRCALPHA");
m_ctlD.InsertString(5, "INVSRCALPHA");
m_ctlD.InsertString(6, "DESTALPHA");
m_ctlD.InsertString(7, "INVDESTALPHA");
m_ctlD.InsertString(8, "DESTCOLOR");
m_ctlD.InsertString(9, "INVDESTCOLOR");
m_ctlD.InsertString(10, "ISRCALPHASAT");
m_ctlD.InsertString(11, "BOTHSRCALPHA");
m_ctlD.InsertString(12, "BOTHINVSRCALPHA");
m_ctlD.SetCurSel(6);
m_ctlVMesh.InsertString(0, "none");
m_ctlVMesh.InsertString(1, "v_body");
m_ctlVMesh.InsertString(2, "v_head");
m_ctlVMesh.InsertString(3, "v_l_weapon");
m_ctlVMesh.InsertString(4, "v_r_weapon");
m_ctlVMesh.InsertString(5, "v_l_arm");
m_ctlVMesh.InsertString(6, "v_r_arm");
m_ctlVMesh.InsertString(7, "v_l_leg");
m_ctlVMesh.InsertString(8, "v_r_leg");
m_ctlVMesh.InsertString(9, "v_mantle");
m_ctlVMesh.InsertString(10, "v_pet");
m_nShowType = 0;
m_dlgHero.Create(IDD_DIALOG_HERO, this);
m_dlgHero.ShowWindow(SW_HIDE );
m_ctlZoom.SetRangeMin(1);
m_ctlZoom.SetRangeMax(600);
m_ctlZoom.SetPos(100);
m_strZoom = "100";
this->UpdateData(false);
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
CDialogExit dialogExit;
if(IDOK == dialogExit.DoModal())
{
this->EndDialog(0);
}
else
{
return;
}
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::ProcessViewPos()
{
BOOL bLeftShift = GetKeyState( VK_LSHIFT ) >> 12;
if(!bLeftShift)
return;
CMyPos posMouse = {0, 0};
::MouseCheck(posMouse.x, posMouse.y);
int nOffset = 30;
if(posMouse.x < 300)
m_nViewOffsetX = -nOffset;
if(posMouse.x > _SCR_WIDTH - 300)
m_nViewOffsetX = nOffset;
if(posMouse.y < 200)
m_nViewOffsetY = -nOffset;
if(posMouse.y > _SCR_HEIGHT - 200)
m_nViewOffsetY = nOffset;
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::Loop()
{
// show time
CMyBitmap::Begin3D ();
CMyBitmap::ClearBuffer (true, true, D3DCOLOR_XRGB(0, 0, 255));
CMySize sizeScr;
sizeScr.iWidth = _SCR_WIDTH;
sizeScr.iHeight = _SCR_HEIGHT;
m_nViewOffsetX = 0;
m_nViewOffsetY = 0;
//----------------------------------------------------
CMyPos posView;
g_objGameMap.GetViewPos(posView);
this->ProcessViewPos();
posView.x += m_nViewOffsetX;
posView.y += m_nViewOffsetY;
g_objGameMap.SetViewPos(posView);
g_objGameMap.Show();
g_objGameMap.ShowCell(this->m_bCell, false, false, false);
CMySize sizeWorld;
g_objGameMap.GetWorldSize(sizeWorld);
CMyPos posCenter;
posCenter.x = sizeWorld.iWidth/2 - _SCR_WIDTH/2;
posCenter.y = sizeWorld.iHeight/2 - _SCR_HEIGHT/2;
// show center flag
CMySize sizeFont;
CMyBitmap::GetFontSize(sizeFont);
CMySize sizeMap;
g_objGameMap.GetMapSize(sizeMap);
posCenter.x = sizeMap.iWidth/2;
posCenter.y = sizeMap.iHeight/2;
CMyPos posScreen;
g_objGameMap.Cell2Screen(posCenter.x, posCenter.y, posScreen.x, posScreen.y);
m_posCenterScreen = posScreen;
CMyBitmap::ShowString(posScreen.x-sizeFont.iWidth, posScreen.y-sizeFont.iHeight/2, 0x00ffffff, "★");
if(!m_bPlayer)
{
if(!m_bPreview)
{
if(m_p3DMapEffect)
{
m_p3DMapEffect->Die();
m_p3DMapEffect = NULL;
}
}
else
{
CMyPos posWorldCenter;
CMySize sizeWorld;
g_objGameMap.GetWorldSize(sizeWorld);
posWorldCenter.x = sizeWorld.iWidth/2;
posWorldCenter.y = sizeWorld.iHeight/2;
if(m_p3DMapEffect)
m_p3DMapEffect->SetWorldPos(posWorldCenter);
}
}
else
{
// do nothing
}
g_objGameMap.Process(NULL);
CMyPos posHero;
g_objHero.GetPos(posHero);
//g_objPlayerSet.Process(posHero.x, posHero.y);
// CMySize sizeFont;
// CMyBitmap::GetFontSize(sizeFont);
if(!m_bPreview && !m_bPlayer)
{
CMyBitmap::ShowBlock(0, 0, _SCR_WIDTH, sizeFont.iHeight+10, 0xff0000ff);
CMyBitmap::ShowString(5, 5, 0xff00ff00, "请使用F1切换到预览模式!");
if(m_nMouseOperate == 1)
{
if(m_nMouseUnit >= 0)
{
int nAmount = m_setUnit.size();
if(nAmount > m_nMouseUnit)
{
TerrainEffectUnitInfo* pInfo = m_setUnit[m_nMouseUnit];
if(pInfo)
{
int nEvent, nX, nY;
nEvent = ::MouseCheck(nX, nY);
if((nX >= 0) && (nY >= 0) && (nX < _SCR_WIDTH) && (nY < _SCR_HEIGHT))
{
pInfo->nOffsetX = nX - m_posCenterScreen.x;
pInfo->nOffsetY = nY - m_posCenterScreen.y;
if(nEvent == _MOUSE_CLICK)
{
TerrainEffectUnitInfo* pNewInfo = new TerrainEffectUnitInfo;
MYASSERT(pNewInfo);
memcpy(pNewInfo, pInfo, sizeof(TerrainEffectUnitInfo));
m_setUnit.push_back(pNewInfo);
this->FlashEditList();
m_nMouseUnit = m_setUnit.size() - 1;
}
else if(nEvent == _MOUSE_RIGHTCLICK)
{
SAFE_DELETE(pInfo);
m_setUnit.erase(m_setUnit.begin()+m_nMouseUnit);
m_nMouseUnit = -1;
m_nMouseOperate = 0;
this->FlashEditList();
}
}
}
}
}
}
int nAmount = m_setUnit.size();
for(int i = 0; i < nAmount; i ++)
{
this->ShowUnit(i);
}
}
else if(!m_bPlayer)
{
CMyBitmap::ShowBlock(0, 0, _SCR_WIDTH, sizeFont.iHeight+10, 0xff000000);
CMyBitmap::ShowString(5, 5, 0xffffffff, "请使用F1切换到编辑模式!");
}
else
{
CMyBitmap::ShowBlock(0, 0, _SCR_WIDTH, sizeFont.iHeight+10, 0xff000000);
CMyBitmap::ShowString(5, 5, 0xffffffff, "正在播放,按停止按钮返回!");
}
//----------------------------------------------------
CMyBitmap::End3D();
CMyBitmap::Flip();
g_objGameDataSet.Process();
::MouseProcess();
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
this->Loop();
CDialog::OnTimer(nIDEvent);
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
int x = point.x;
int y = point.y;
extern void MouseSet (int x, int y, int event);
MouseSet(x, y, _MOUSE_RIGHTCLICK);
CDialog::OnRButtonDown(nFlags, point);
if(m_bPreview)
{
CMyPos posCell;
g_objGameMap.Screen2Cell(x, y, posCell.x, posCell.y);
g_objHero.SetPhysicalForce(100);
g_objHero.Run(posCell.x, posCell.y);
}
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -