2000-09-22 17:11:29 +02:00
|
|
|
// MapEditDoc.cpp : implementation of the CMapEditDoc class
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "MapEdit.h"
|
|
|
|
|
|
|
|
#include "MapEditDoc.h"
|
2000-11-20 17:21:43 +01:00
|
|
|
#include "MapSizeDlg.h"
|
2000-09-22 17:11:29 +02:00
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
#define new DEBUG_NEW
|
|
|
|
#undef THIS_FILE
|
|
|
|
static char THIS_FILE[] = __FILE__;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CMapEditDoc
|
|
|
|
|
|
|
|
IMPLEMENT_DYNCREATE(CMapEditDoc, CDocument)
|
|
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CMapEditDoc, CDocument)
|
|
|
|
//{{AFX_MSG_MAP(CMapEditDoc)
|
2000-11-06 21:24:11 +01:00
|
|
|
ON_UPDATE_COMMAND_UI(ID_INDICATOR_CURSORXY, OnStatusCursorXY)
|
2000-11-28 00:07:07 +01:00
|
|
|
ON_COMMAND(ID_EXPORT_AGB, OnExportAgb)
|
|
|
|
ON_COMMAND(ID_EXPORT_PSX, OnExportPsx)
|
2000-09-22 17:11:29 +02:00
|
|
|
//}}AFX_MSG_MAP
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CMapEditDoc construction/destruction
|
|
|
|
|
|
|
|
CMapEditDoc::CMapEditDoc()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CMapEditDoc::~CMapEditDoc()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CMapEditDoc::OnNewDocument()
|
|
|
|
{
|
2000-11-06 21:24:11 +01:00
|
|
|
if (!CDocument::OnNewDocument()) return FALSE;
|
2000-09-22 17:11:29 +02:00
|
|
|
|
2000-11-28 22:16:00 +01:00
|
|
|
return(Core.New());
|
|
|
|
|
|
|
|
// return TRUE;
|
2000-09-22 17:11:29 +02:00
|
|
|
}
|
|
|
|
|
2000-11-04 19:24:51 +01:00
|
|
|
BOOL CMapEditDoc::OnOpenDocument(LPCTSTR lpszPathName)
|
|
|
|
{
|
|
|
|
if (!CDocument::OnOpenDocument(lpszPathName))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2000-09-22 17:11:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CMapEditDoc serialization
|
|
|
|
void CMapEditDoc::Serialize(CArchive& ar)
|
|
|
|
{
|
|
|
|
if (ar.IsStoring())
|
|
|
|
{
|
2000-11-20 21:33:42 +01:00
|
|
|
Core.Save(ar.GetFile());
|
2000-09-22 17:11:29 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-11-20 21:33:42 +01:00
|
|
|
Core.Load(ar.GetFile());
|
2000-09-22 17:11:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CMapEditDoc diagnostics
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
void CMapEditDoc::AssertValid() const
|
|
|
|
{
|
|
|
|
CDocument::AssertValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMapEditDoc::Dump(CDumpContext& dc) const
|
|
|
|
{
|
|
|
|
CDocument::Dump(dc);
|
|
|
|
}
|
|
|
|
#endif //_DEBUG
|
2000-11-06 21:24:11 +01:00
|
|
|
|
|
|
|
/*********************************************************************************/
|
|
|
|
/*********************************************************************************/
|
|
|
|
/*********************************************************************************/
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::UpdateView(CMapEditView *View)
|
|
|
|
{
|
|
|
|
Core.UpdateView(View);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::Render(CMapEditView *View)
|
|
|
|
{
|
|
|
|
Core.Render(View);
|
|
|
|
}
|
|
|
|
|
2000-11-20 21:33:42 +01:00
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::UpdateAll(CMapEditView *View)
|
|
|
|
{
|
|
|
|
Core.UpdateAll(View);
|
|
|
|
}
|
|
|
|
|
2000-11-06 21:24:11 +01:00
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::OnStatusCursorXY(CCmdUI *pCmdUI)
|
|
|
|
{
|
|
|
|
CPoint &XY=Core.GetCursorPos();
|
|
|
|
CString XYStr;
|
|
|
|
pCmdUI->Enable();
|
|
|
|
if (XY.x!=-1 && XY.y!=-1)
|
|
|
|
XYStr.Format( "%d\t%d", XY.x,XY.y);
|
|
|
|
pCmdUI->SetText(XYStr);
|
|
|
|
}
|
|
|
|
|
2000-12-11 22:29:59 +01:00
|
|
|
/*********************************************************************************/
|
|
|
|
bool CMapEditDoc::Question(char *Txt)
|
|
|
|
{
|
|
|
|
CString Str;
|
|
|
|
Str.Format(Txt);
|
|
|
|
int Ret=AfxMessageBox(Str,MB_YESNO , MB_ICONQUESTION);
|
|
|
|
|
|
|
|
if (Ret==IDYES) return(true);
|
|
|
|
return(false);
|
|
|
|
|
|
|
|
}
|
2000-11-06 21:24:11 +01:00
|
|
|
/*********************************************************************************/
|
|
|
|
/*********************************************************************************/
|
|
|
|
/*** Windows Message Handlers ****************************************************/
|
|
|
|
/*********************************************************************************/
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::LButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag)
|
|
|
|
{
|
|
|
|
Core.LButtonControl(View,nFlags,point,DownFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::MButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag)
|
|
|
|
{
|
|
|
|
Core.MButtonControl(View,nFlags,point,DownFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::RButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag)
|
|
|
|
{
|
|
|
|
Core.RButtonControl(View,nFlags,point,DownFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::MouseWheel(CMapEditView *View,UINT nFlags, short zDelta, CPoint &point)
|
|
|
|
{
|
|
|
|
Core.MouseWheel(View,nFlags,zDelta,point);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::MouseMove(CMapEditView *View,UINT nFlags, CPoint &point)
|
|
|
|
{
|
2000-11-15 22:22:40 +01:00
|
|
|
Core.MouseMove(View,nFlags,point);
|
2000-11-06 21:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
2000-11-14 16:03:04 +01:00
|
|
|
void CMapEditDoc::ToggleTileView(CMapEditView *View)
|
2000-11-06 21:24:11 +01:00
|
|
|
{
|
2000-11-14 16:03:04 +01:00
|
|
|
Core.UpdateTileView(View,TRUE);
|
|
|
|
Core.UpdateAll(View);
|
2000-11-28 15:34:42 +01:00
|
|
|
FocusView();
|
2000-11-06 21:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
2000-11-14 16:03:04 +01:00
|
|
|
void CMapEditDoc::ToggleGrid(CMapEditView *View)
|
2000-11-06 21:24:11 +01:00
|
|
|
{
|
2000-11-14 16:03:04 +01:00
|
|
|
Core.UpdateGrid(View,TRUE);
|
2000-11-28 15:34:42 +01:00
|
|
|
FocusView();
|
2000-11-17 00:08:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
2000-11-20 17:21:43 +01:00
|
|
|
void CMapEditDoc::MirrorX(CMapEditView *View)
|
2000-11-17 00:08:54 +01:00
|
|
|
{
|
2000-11-20 17:21:43 +01:00
|
|
|
Core.MirrorX(View);
|
2000-11-28 15:34:42 +01:00
|
|
|
FocusView();
|
2000-11-17 00:08:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
2000-11-20 17:21:43 +01:00
|
|
|
void CMapEditDoc::MirrorY(CMapEditView *View)
|
2000-11-17 00:08:54 +01:00
|
|
|
{
|
2000-11-20 17:21:43 +01:00
|
|
|
Core.MirrorY(View);
|
2000-11-28 15:34:42 +01:00
|
|
|
FocusView();
|
2000-11-06 21:24:11 +01:00
|
|
|
}
|
|
|
|
|
2000-11-14 16:03:04 +01:00
|
|
|
/*********************************************************************************/
|
2000-11-15 22:22:40 +01:00
|
|
|
void CMapEditDoc::SetMode(int NewMode)
|
2000-11-14 16:03:04 +01:00
|
|
|
{
|
2000-11-15 22:22:40 +01:00
|
|
|
Core.SetMode(NewMode);
|
2000-11-28 15:34:42 +01:00
|
|
|
FocusView();
|
2000-11-15 22:22:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
2000-11-28 00:07:07 +01:00
|
|
|
void CMapEditDoc::SetLayer(int Layer)
|
|
|
|
{
|
|
|
|
Core.SetLayer(Layer);
|
2000-11-28 15:34:42 +01:00
|
|
|
FocusView();
|
2000-11-28 00:07:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
|
|
|
/*********************************************************************************/
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::OnExportAgb()
|
|
|
|
{
|
2000-11-30 23:17:55 +01:00
|
|
|
char BASED_CODE Filter[]= "AGB Data Type (*.c)|*.c|All Files (*.*)|*.*||";
|
|
|
|
CFileDialog Dlg(FALSE,"*.c",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,Filter);
|
2000-11-28 00:07:07 +01:00
|
|
|
|
|
|
|
if (Dlg.DoModal()!=IDOK) return;
|
|
|
|
|
|
|
|
char Filename[256];
|
|
|
|
sprintf(Filename,"%s",Dlg.GetPathName());
|
|
|
|
|
|
|
|
|
|
|
|
Core.ExportAGB(Filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::OnExportPsx()
|
|
|
|
{
|
2000-11-30 23:17:55 +01:00
|
|
|
char BASED_CODE Filter[]= "PSX Data Type (*.PME)|*.Pme|All Files (*.*)|*.*||";
|
|
|
|
CFileDialog Dlg(FALSE,"*.pme",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,Filter);
|
|
|
|
|
|
|
|
if (Dlg.DoModal()!=IDOK) return;
|
|
|
|
|
|
|
|
char Filename[256];
|
|
|
|
sprintf(Filename,"%s",Dlg.GetPathName());
|
|
|
|
|
2000-12-01 22:08:54 +01:00
|
|
|
Core.ExportPSX(Filename);
|
2000-11-28 00:07:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
2000-11-15 22:22:40 +01:00
|
|
|
/*** Tilebank Functions **********************************************************/
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::TileBankLoad()
|
|
|
|
{
|
2000-11-22 23:08:47 +01:00
|
|
|
char BASED_CODE GinFilter[]= "All Tile Files (*.Gin; *.Bmp)|*.gin;*.Bmp|3d Tile Files (*.Gin)|*.Gin|2d Tile Files (*.Bmp)|*.Bmp|All Files (*.*)|*.*||";
|
2000-11-15 22:22:40 +01:00
|
|
|
CFileDialog Dlg(TRUE,"Gin",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,GinFilter);
|
|
|
|
|
|
|
|
if (Dlg.DoModal()!=IDOK) return;
|
|
|
|
|
|
|
|
char Filename[256];
|
|
|
|
sprintf(Filename,"%s",Dlg.GetPathName());
|
|
|
|
Core.TileBankLoad(Filename);
|
|
|
|
UpdateAllViews(NULL);
|
2000-11-28 15:34:42 +01:00
|
|
|
FocusView();
|
2000-11-15 22:22:40 +01:00
|
|
|
}
|
|
|
|
|
2000-11-29 18:07:57 +01:00
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::TileBankDelete()
|
|
|
|
{
|
|
|
|
Core.TileBankDelete();
|
|
|
|
UpdateAllViews(NULL);
|
|
|
|
FocusView();
|
|
|
|
}
|
|
|
|
|
2000-11-15 22:22:40 +01:00
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::TileBankReload()
|
|
|
|
{
|
|
|
|
Core.TileBankReload();
|
2000-11-14 16:03:04 +01:00
|
|
|
UpdateAllViews(NULL);
|
2000-11-28 15:34:42 +01:00
|
|
|
FocusView();
|
2000-11-14 16:03:04 +01:00
|
|
|
}
|
|
|
|
/*********************************************************************************/
|
2000-11-15 22:22:40 +01:00
|
|
|
void CMapEditDoc::TileBankSet()
|
2000-11-14 16:03:04 +01:00
|
|
|
{
|
2000-11-15 22:22:40 +01:00
|
|
|
Core.TileBankSet();
|
2000-11-14 16:03:04 +01:00
|
|
|
UpdateAllViews(NULL);
|
2000-11-28 15:34:42 +01:00
|
|
|
FocusView();
|
2000-11-14 16:03:04 +01:00
|
|
|
}
|
2000-11-15 22:22:40 +01:00
|
|
|
|
2000-11-17 22:36:13 +01:00
|
|
|
/*********************************************************************************/
|
2000-11-20 17:21:43 +01:00
|
|
|
void CMapEditDoc::ActiveBrushLeft(CMapEditView *View)
|
2000-11-17 22:36:13 +01:00
|
|
|
{
|
2000-11-20 17:21:43 +01:00
|
|
|
Core.ActiveBrushLeft(View);
|
2000-11-17 22:36:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
2000-11-20 17:21:43 +01:00
|
|
|
void CMapEditDoc::ActiveBrushRight(CMapEditView *View)
|
2000-11-17 22:36:13 +01:00
|
|
|
{
|
2000-11-20 17:21:43 +01:00
|
|
|
Core.ActiveBrushRight(View);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::MapSetSize(CMapEditView *View)
|
|
|
|
{
|
|
|
|
CMapSizeDlg Dlg;
|
|
|
|
|
|
|
|
Dlg.m_Width=Core.GetMapWidth();
|
|
|
|
Dlg.m_Height=Core.GetMapHeight();
|
|
|
|
|
|
|
|
if (Dlg.DoModal()!=IDOK) return;
|
2000-11-17 22:36:13 +01:00
|
|
|
|
2000-11-20 17:21:43 +01:00
|
|
|
Core.SetMapSize(View,Dlg.m_Width,Dlg.m_Height);
|
2000-11-17 22:36:13 +01:00
|
|
|
}
|
2000-11-22 23:08:47 +01:00
|
|
|
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::Toggle2d3d(CMapEditView *View)
|
|
|
|
{
|
|
|
|
Core.Toggle2d3d(View);
|
|
|
|
}
|
2000-11-28 15:34:42 +01:00
|
|
|
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditDoc::FocusView()
|
|
|
|
{
|
|
|
|
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
|
|
|
|
|
|
|
|
}
|