SBSPSS/Utils/MapEdit/MapEditDoc.cpp

223 lines
6.2 KiB
C++
Raw Normal View History

2000-09-22 17:11:29 +02:00
// MapEditDoc.cpp : implementation of the CMapEditDoc class
//
#include "stdafx.h"
#include "MapEdit.h"
#include "MapEditDoc.h"
#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-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-11-04 19:24:51 +01:00
TRACE0("New Doc\n");
2000-11-06 21:24:11 +01:00
Core.NewMap();
2000-09-22 17:11:29 +02:00
return TRUE;
}
2000-11-04 19:24:51 +01:00
BOOL CMapEditDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
TRACE1("Load Doc %s\n",lpszPathName);
2000-11-06 21:24:11 +01:00
2000-11-04 19:24:51 +01:00
return TRUE;
}
2000-09-22 17:11:29 +02:00
/////////////////////////////////////////////////////////////////////////////
// CMapEditDoc serialization
void CMapEditDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
2000-11-06 21:24:11 +01:00
2000-09-22 17:11:29 +02:00
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// 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);
}
/*********************************************************************************/
void CMapEditDoc::UpdateAll(CMapEditView *View)
{
Core.UpdateAll(View);
}
/*********************************************************************************/
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);
}
/*********************************************************************************/
/*********************************************************************************/
/*** 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-17 00:08:54 +01:00
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
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-17 00:08:54 +01:00
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
}
/*********************************************************************************/
void CMapEditDoc::MirrorX()
{
Core.MirrorX();
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
}
/*********************************************************************************/
void CMapEditDoc::MirrorY()
{
Core.MirrorY();
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
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-17 00:08:54 +01:00
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
2000-11-15 22:22:40 +01:00
}
/*********************************************************************************/
/*** Tilebank Functions **********************************************************/
/*********************************************************************************/
void CMapEditDoc::TileBankLoad()
{
char BASED_CODE GinFilter[]= "Gin Files (*.Gin)|*.gin|All Files (*.*)|*.*||";
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-17 00:08:54 +01:00
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
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-17 00:08:54 +01:00
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
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-17 00:08:54 +01:00
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
2000-11-14 16:03:04 +01:00
}
2000-11-15 22:22:40 +01:00