📄 terraineffecteditordlg.cpp
字号:
int x = point.x;
int y = point.y;
extern void MouseSet (int x, int y, int event);
MouseSet(x, y, 0);
CDialog::OnMouseMove(nFlags, point);
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnLButtonDown(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_CLICK);
CDialog::OnLButtonDown(nFlags, point);
if(m_bPreview)
{
CMyPos posCell;
g_objGameMap.Screen2Cell(x, y, posCell.x, posCell.y);
g_objHero.SetPhysicalForce(100);
g_objHero.Walk(posCell.x, posCell.y);
}
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialogExit dialogExit;
if(IDOK == dialogExit.DoModal())
{
this->EndDialog(0);
}
else
{
return;
}
CDialog::OnCancel();
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
g_objGameDataSet.Destroy();
CMyBitmap::Quit3D();
CDialog::OnClose();
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnCheckCell()
{
// TODO: Add your control notification handler code here
this->UpdateData();
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnButtonTocentel()
{
// TODO: Add your control notification handler code here
CMySize sizeWorld;
g_objGameMap.GetWorldSize(sizeWorld);
CMyPos posCenter;
posCenter.x = sizeWorld.iWidth/2 - _SCR_WIDTH/2;
posCenter.y = sizeWorld.iHeight/2 - _SCR_HEIGHT/2;
CMyPos posCell;
g_objGameMap.World2Cell(sizeWorld.iWidth/2, sizeWorld.iHeight/2, posCell.x, posCell.y);
g_objHero.SetPos(posCell);
posCell.x = sizeWorld.iWidth/2;
posCell.y = sizeWorld.iHeight/2;
g_objHero.SetWorldPos(posCell);
g_objGameMap.SetViewPos(posCenter);
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::FlashList()
{
const char szFile[]="TerrainEffect.ini";
this->m_ctrlList.ResetContent();
FILE* fp = fopen(szFile, "r");
if(!fp)
return;
char szLine[256];
int nIndex = 0;
while(true)
{
int nReturn = fscanf(fp, "%s\n", szLine);
if(EOF == nReturn)
break;
m_ctrlList.InsertString(nIndex, szLine);
nIndex ++;
}
fclose(fp);
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnButtonFlash()
{
// TODO: Add your control notification handler code here
this->FlashList();
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::WinHelp(DWORD dwData, UINT nCmd)
{
// TODO: Add your specialized code here and/or call the base class
m_bPreview = !m_bPreview;
return;
CDialog::WinHelp(dwData, nCmd);
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::Preview()
{
int nSelect = m_ctlPart.GetCurSel();
if(m_p3DMapEffect)
{
m_p3DMapEffect->Die();
m_p3DMapEffect = NULL;
}
g_objHero.m_objEffect.Clear();
C3DRole* pRole = (C3DRole*)g_objHero.m_pIRoleView;
if(pRole->m_pRWeapon)
{
pRole->m_pRWeapon->QueryGame3DEffectEx()->Clear();
}
int nIndex = this->m_ctrlList.GetCurSel();
if(nIndex<0)
return;
CString m_objStr;
this->m_ctrlList.GetText(nIndex, m_objStr);
char* pszStr = m_objStr.GetBuffer(0);
if(pszStr && strlen(pszStr) > 0)
{
if(m_nShowType == 0)
{
CMyPos posWorld = {0, 0};
m_p3DMapEffect = C3DMapEffect::CreateNew(posWorld, pszStr, false);
g_objGameMap.AddInteractiveObj(m_p3DMapEffect);
}
else if(m_nShowType == 1)
{
g_objHero.m_objEffect.Add(pszStr,false,0,g_objHero.GetLook());
}
else if(m_nShowType == 2)
{
C3DRole* pRole = (C3DRole*)g_objHero.m_pIRoleView;
if(pRole->m_pRWeapon)
{
pRole->m_pRWeapon->QueryGame3DEffectEx()->Clear();
pRole->m_pRWeapon->QueryGame3DEffectEx()->Add(pszStr);
}
}
m_ctlPart.ResetContent();
m_ctlPart.InsertString(m_ctlPart.GetCount(), "应用所有Part");
CMy3DEffectInfo* pInfo = (CMy3DEffectInfo*)g_obj3DRoleData.GetMy3DEffectInfo(pszStr);
if(pInfo)
for(int i = 0; i < pInfo->nAmount; i ++)
{
char szTemp[256];
sprintf(szTemp, "应用Part%d", i);
m_ctlPart.InsertString(m_ctlPart.GetCount(), szTemp);
}
this->UpdateData(false);
}
m_ctlPart.SetCurSel(nSelect);
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnSelchangeList()
{
// TODO: Add your control notification handler code here
if(m_bPreview)
this->Preview();
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnButtonAdd()
{
// TODO: Add your control notification handler code here
int nIndex = this->m_ctrlList.GetCurSel();
if(nIndex < 0)
return;
TerrainEffectUnitInfo* pInfo= new TerrainEffectUnitInfo;
MYASSERT(pInfo);
this->UpdateData(true);
m_setUnit.push_back(pInfo);
pInfo->dwDelay = atoi(this->m_strDelay.GetBuffer(0));
pInfo->dwRandomDelay = atoi(this->m_strLife.GetBuffer(0));
pInfo->nOffsetX = atoi(this->m_strOffsetX.GetBuffer(0));
pInfo->nOffsetY = atoi(this->m_strOffsetY.GetBuffer(0));
CString objStr;
this->m_ctrlList.GetText(nIndex, objStr);
strcpy(pInfo->szIndex, objStr.GetBuffer(0));
this->FlashEditList();
m_nMouseUnit = m_setUnit.size()-1;
m_nMouseOperate = 1;
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::DestroyUnit()
{
int nAmount = m_setUnit.size();
for(int i = 0; i < nAmount; i ++)
{
TerrainEffectUnitInfo* pInfo = m_setUnit[i];
SAFE_DELETE(pInfo);
}
m_setUnit.clear();
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::FlashEditList()
{
this->m_ctrlListEdit.ResetContent();
int nAmount = m_setUnit.size();
int nIndex = 0;
for(int i = 0; i < nAmount; i ++)
{
TerrainEffectUnitInfo* pInfo = m_setUnit[i];
if(pInfo)
{
char szIndex[64];
sprintf(szIndex, "%d %s", i, pInfo->szIndex);
m_ctrlListEdit.InsertString(i, szIndex);
}
else
{
m_ctrlListEdit.InsertString(i, "ERROR");
}
}
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::ShowUnit(int nIndex)
{
int nAmount = m_setUnit.size();
if(nIndex < 0 && nIndex >= nAmount)
return;
TerrainEffectUnitInfo* pInfo = m_setUnit[nIndex];
if(!pInfo)
return;
CMyPos posScr;
posScr.x = m_posCenterScreen.x + pInfo->nOffsetX;
posScr.y = m_posCenterScreen.y + pInfo->nOffsetY;
CMyBitmap::ShowBlock(posScr.x-16, posScr.y-16, posScr.x+16, posScr.y+16, 0xff0000ff);
CMySize sizeFont;
CMyBitmap::GetFontSize(sizeFont);
char szIndex[64];
sprintf(szIndex, "%d", nIndex);
CMyBitmap::ShowString(posScr.x - strlen(szIndex)*sizeFont.iWidth/2,
posScr.y - sizeFont.iHeight/2, 0xffffffff, szIndex);
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnButtonDel()
{
// TODO: Add your control notification handler code here
int nIndex = this->m_ctrlListEdit.GetCurSel();
if(nIndex < 0 && nIndex > m_setUnit.size())
return;
TerrainEffectUnitInfo* pInfo = m_setUnit[nIndex];
SAFE_DELETE(pInfo);
m_setUnit.erase(m_setUnit.begin() + nIndex);
this->FlashEditList();
this->m_ctrlListEdit.SetCurSel(nIndex-1);
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnBbPlayer()
{
// TODO: Add your control notification handler code here
m_pobjUnit = new CTerainEffectUnit;
CMyPos posWorldCenter;
CMySize sizeWorld;
g_objGameMap.GetWorldSize(sizeWorld);
posWorldCenter.x = sizeWorld.iWidth/2;
posWorldCenter.y = sizeWorld.iHeight/2;
m_pobjUnit->SetPos(posWorldCenter);
int nAmount = this->m_setUnit.size();
for(int i = 0; i < nAmount; i ++)
{
TerrainEffectUnitInfo* pInfo = m_setUnit[i];
TerrainEffectUnitInfo* pNewInfo = new TerrainEffectUnitInfo;
memcpy(pNewInfo, pInfo, sizeof(TerrainEffectUnitInfo));
m_pobjUnit->AddUnit(pNewInfo);
}
g_objGameMap.AddTerrainMagicUnit(m_pobjUnit);
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnButtonPlay()
{
// TODO: Add your control notification handler code here
m_bPlayer = true;
m_pobjUnit = new CTerainEffectUnit;
CMyPos posWorldCenter;
CMySize sizeWorld;
g_objGameMap.GetWorldSize(sizeWorld);
posWorldCenter.x = sizeWorld.iWidth/2;
posWorldCenter.y = sizeWorld.iHeight/2;
m_pobjUnit->SetPos(posWorldCenter);
int nAmount = this->m_setUnit.size();
for(int i = 0; i < nAmount; i ++)
{
TerrainEffectUnitInfo* pInfo = m_setUnit[i];
TerrainEffectUnitInfo* pNewInfo = new TerrainEffectUnitInfo;
memcpy(pNewInfo, pInfo, sizeof(TerrainEffectUnitInfo));
m_pobjUnit->AddUnit(pNewInfo);
}
g_objGameMap.AddTerrainMagicUnit(m_pobjUnit);
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnButtonStop()
{
// TODO: Add your control notification handler code here
m_bPlayer = false;
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnButtonSet()
{
// TODO: Add your control notification handler code here
int nIndex = this->m_ctrlListEdit.GetCurSel();
if(nIndex < 0 && nIndex >= m_setUnit.size())
return;
TerrainEffectUnitInfo* pInfo= m_setUnit[nIndex];
if(!pInfo)
return;
this->UpdateData(true);
pInfo->dwDelay = atoi(this->m_strDelay.GetBuffer(0));
pInfo->dwRandomDelay = atoi(this->m_strLife.GetBuffer(0));
pInfo->nOffsetX = atoi(this->m_strOffsetX.GetBuffer(0));
pInfo->nOffsetY = atoi(this->m_strOffsetY.GetBuffer(0));
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnSelchangeListEdit()
{
// TODO: Add your control notification handler code here
int nIndex = this->m_ctrlListEdit.GetCurSel();
if(nIndex < 0 && nIndex >= m_setUnit.size())
return;
TerrainEffectUnitInfo* pInfo= m_setUnit[nIndex];
if(!pInfo)
return;
char szStr[256];
sprintf(szStr, "%u", pInfo->dwDelay);
this->m_strDelay = szStr;
sprintf(szStr, "%u", pInfo->dwRandomDelay);
this->m_strLife = szStr;
sprintf(szStr, "%d", pInfo->nOffsetX);
this->m_strOffsetX = szStr;
sprintf(szStr, "%d", pInfo->nOffsetY);
this->m_strOffsetY = szStr;
this->UpdateData(false);
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnButtonflashEdit()
{
// TODO: Add your control notification handler code here
this->FlashEditList();
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnLoad()
{
KillTimer(WM_TIMER);
static TCHAR strFileName[MAX_PATH] = TEXT("");
static TCHAR strPath[MAX_PATH] = TEXT("");
// Setup the OPENFILENAME structure
OPENFILENAME ofn = { sizeof(OPENFILENAME), this->GetSafeHwnd(), NULL,
TEXT("地效魔法文件1.0\0*.TME\0所有文件\0*.*\0\0"), NULL,
0, 1, strFileName, MAX_PATH, NULL, 0, strPath,
TEXT("打开地效魔法文件"),
OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_NOCHANGEDIR|OFN_OVERWRITEPROMPT,
0, 0,
TEXT(".TME"), 0, NULL, NULL };
// Display the OpenFileName dialog. Then, try to load the specified file
try
{
if( TRUE != GetOpenFileName( &ofn ) )
{
this->SetTimer(WM_TIMER, 30, NULL);
return;
}
}
catch(...)
{
}
FILE* fp = fopen(strFileName, "r");
if(!fp)
{
this->SetTimer(WM_TIMER, 30, NULL);
return;
}
// read amount
int nAmount = 0;
fread(&nAmount, sizeof(int), 1, fp);
for(int i = 0; i < nAmount; i ++)
{
TerrainEffectUnitInfo* pInfo = new TerrainEffectUnitInfo;
MYASSERT(pInfo);
fread(pInfo, sizeof(TerrainEffectUnitInfo), 1, fp);
m_setUnit.push_back(pInfo);
}
fclose(fp);
this->SetTimer(WM_TIMER, 30, NULL);
}
//-------------------------------------------------
void CTerrainEffectEditorDlg::OnSave()
{
KillTimer(WM_TIMER);
static TCHAR strFileName[MAX_PATH] = TEXT("");
static TCHAR strPath[MAX_PATH] = TEXT("");
// Setup the OPENFILENAME structure
OPENFILENAME ofn = { sizeof(OPENFILENAME), this->GetSafeHwnd(), NULL,
TEXT("地效魔法文件1.0\0*.TME\0所有文件\0*.*\0\0"), NULL,
0, 1, strFileName, MAX_PATH, NULL, 0, strPath,
TEXT("存储地效魔法文件"),
OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_NOCHANGEDIR|OFN_OVERWRITEPROMPT,
0, 0,
TEXT(".TME"), 0, NULL, NULL };
// Display the OpenFileName dialog. Then, try to load the specified file
try
{
if( TRUE != GetSaveFileName( &ofn ) )
{
this->SetTimer(WM_TIMER, 30, NULL);
return;
}
}
catch(...)
{
}
FILE* fp = fopen(strFileName, "wb");
if(!fp)
{
this->SetTimer(WM_TIMER, 30, NULL);
return;
}
// write amount
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -