SBSPSS/Utils/MapEdit/MapEditDoc.cpp

308 lines
8.8 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"
2001-03-13 22:00:34 +01:00
#include "GUIResize.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)
2001-02-01 23:48:22 +01:00
ON_COMMAND(ID_EXPORT, OnExport)
2000-12-11 22:52:32 +01:00
ON_COMMAND(ID_ZOOM_IN, OnZoomIn)
ON_COMMAND(ID_ZOOM_OUT, OnZoomOut)
2001-03-01 18:28:20 +01:00
ON_COMMAND(ID_TOGGLE_SUBVIEW, OnToggleSubView)
2001-03-22 21:49:58 +01:00
ON_COMMAND(ID_TOGGLE_GRID, OnToggleGrid)
2001-02-14 23:35:47 +01:00
ON_COMMAND(ID_MIRRORX, OnMirrorx)
ON_COMMAND(ID_MIRRORY, OnMirrory)
ON_COMMAND(ID_ACTIVEBRUSH_LEFT, OnActivebrushLeft)
ON_COMMAND(ID_ACTIVEBRUSH_RIGHT, OnActivebrushRight)
ON_COMMAND(ID_MAP_SETSIZE, OnMapSetSize)
ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
2001-02-16 19:23:01 +01:00
ON_COMMAND(ID_2D_3D_TOGGLE, On2d3dToggle)
2001-02-20 16:57:03 +01:00
ON_COMMAND(ID_RESET_VIEW, OnResetView)
2001-05-09 23:56:48 +02:00
ON_COMMAND(ID_RENDER_TO_TGA, OnRenderToTga)
2001-07-10 18:56:47 +02:00
ON_COMMAND(ID_ROTATE, OnRotate)
2001-03-01 18:28:20 +01:00
ON_COMMAND(ID_TOOLBAR_TILEPALETTE, OnToggleSubView)
2001-02-14 23:35:47 +01:00
ON_COMMAND(ID_TOGGLE_GRID, OnToggleGrid)
2001-07-10 18:56:47 +02:00
ON_COMMAND(ID_REPORT, OnReport)
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
2001-02-14 23:35:47 +01:00
void CMapEditDoc::OnCloseDocument()
{
Core.GUIRemoveAll();
CDocument::OnCloseDocument();
2001-02-16 19:23:01 +01:00
theApp.CloseDoc(this);
2001-02-14 23:35:47 +01:00
}
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());
2001-04-07 23:05:33 +02:00
//#if _DEBUG && 1
// Core.Export(ar.GetFile()->GetFilePath());
//#endif
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
/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
2001-02-10 21:21:20 +01:00
/*********************************************************************************/
void CMapEditDoc::SetView(CMapEditView *View)
{
Core.SetView(View);
2001-03-01 18:28:20 +01:00
UpdateView();
2001-02-10 21:21:20 +01:00
}
/*********************************************************************************/
CMapEditView *CMapEditDoc::GetView()
{
return(Core.GetView());
}
2000-11-06 21:24:11 +01:00
/*********************************************************************************/
2001-02-14 23:35:47 +01:00
void CMapEditDoc::UpdateView()
2000-11-06 21:24:11 +01:00
{
2001-02-14 23:35:47 +01:00
Core.UpdateView();
2000-11-06 21:24:11 +01:00
}
/*********************************************************************************/
2001-02-14 23:35:47 +01:00
void CMapEditDoc::Render()
2000-11-06 21:24:11 +01:00
{
2001-02-14 23:35:47 +01:00
Core.Render();
2000-11-06 21:24:11 +01:00
}
2000-11-20 21:33:42 +01:00
/*********************************************************************************/
2001-02-14 23:35:47 +01:00
void CMapEditDoc::UpdateAll()
2000-11-20 21:33:42 +01:00
{
2001-02-09 22:17:01 +01:00
Core.UpdateAll();
2000-11-20 21:33:42 +01:00
}
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)
2001-02-10 16:23:30 +01:00
XYStr.Format( "%d %d", XY.x,XY.y);
2000-11-06 21:24:11 +01:00
pCmdUI->SetText(XYStr);
}
2001-02-09 22:17:01 +01:00
/*********************************************************************************/
void CMapEditDoc::GUIUpdate()
{
Core.GUIUpdate();
}
/*********************************************************************************/
void CMapEditDoc::GUIChanged()
{
Core.GUIChanged();
2001-02-14 23:35:47 +01:00
UpdateView();
2001-02-09 22:17:01 +01:00
}
2000-11-06 21:24:11 +01:00
/*********************************************************************************/
/*********************************************************************************/
/*** Windows Message Handlers ****************************************************/
/*********************************************************************************/
/*********************************************************************************/
2001-03-01 18:28:20 +01:00
void CMapEditDoc::LButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag) {Core.LButtonControl(nFlags,point,DownFlag!=0);}
void CMapEditDoc::MButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag) {Core.MButtonControl(nFlags,point,DownFlag!=0);}
void CMapEditDoc::RButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag) {Core.RButtonControl(nFlags,point,DownFlag!=0);}
2001-02-14 23:35:47 +01:00
void CMapEditDoc::MouseWheel(UINT nFlags, short zDelta, CPoint &point) {Core.MouseWheel(nFlags,zDelta,point);}
void CMapEditDoc::MouseMove(UINT nFlags, CPoint &point) {Core.MouseMove(nFlags,point);}
2000-11-17 00:08:54 +01:00
2001-03-01 18:28:20 +01:00
void CMapEditDoc::OnToggleSubView() {Command(CmdMsg_ToggleSubView);}
void CMapEditDoc::OnToggleGrid() {Command(CmdMsg_ToggleGrid);}
void CMapEditDoc::On2d3dToggle() {Command(CmdMsg_Toggle2d);}
2001-07-10 18:56:47 +02:00
void CMapEditDoc::OnReport() {Command(CmdMsg_Report);}
2000-11-06 21:24:11 +01:00
2001-03-01 18:28:20 +01:00
void CMapEditDoc::OnZoomIn() {Command(CmdMsg_ZoomIn);}
void CMapEditDoc::OnZoomOut() {Command(CmdMsg_ZoomOut);}
void CMapEditDoc::OnResetView() {Command(CmdMsg_ResetView);}
2000-11-15 22:22:40 +01:00
2001-03-01 18:28:20 +01:00
void CMapEditDoc::OnMirrorx() {Command(CmdMsg_MirrorX);}
void CMapEditDoc::OnMirrory() {Command(CmdMsg_MirrorY);}
2001-05-09 23:56:48 +02:00
void CMapEditDoc::OnRotate() {Command(CmdMsg_Rotate);}
2001-03-01 18:28:20 +01:00
void CMapEditDoc::OnEditCopy() {Command(CmdMsg_Copy);}
void CMapEditDoc::OnEditPaste() {Command(CmdMsg_Paste);}
void CMapEditDoc::OnActivebrushLeft() {Command(CmdMsg_ActiveBrushLeft);}
void CMapEditDoc::OnActivebrushRight() {Command(CmdMsg_ActiveBrushRight);}
2000-11-28 00:07:07 +01:00
2001-03-01 18:28:20 +01:00
void CMapEditDoc::Command(int CmdMsg,int Param0,int Param1)
2001-01-21 19:04:00 +01:00
{
2001-03-01 18:28:20 +01:00
Core.Command(CmdMsg,Param0,Param1);
FocusView();
2001-01-21 19:04:00 +01:00
}
2000-11-28 00:07:07 +01:00
/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
2001-02-01 23:48:22 +01:00
void CMapEditDoc::OnExport()
2000-11-28 00:07:07 +01:00
{
2001-02-01 23:48:22 +01:00
char BASED_CODE Filter[]= "Export Data Type (*.MEX)|*.MEX|All Files (*.*)|*.*||";
CFileDialog Dlg(FALSE,"*.MEX",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());
2001-02-01 23:48:22 +01:00
Core.Export(Filename);
2000-11-28 00:07:07 +01:00
}
2001-04-05 16:20:56 +02:00
/*********************************************************************************/
void CMapEditDoc::OnRenderToTga()
{
char BASED_CODE Filter[]= "TGA File (*.TGA)|*.TGA||";
CFileDialog Dlg(FALSE,"*.TGA",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,Filter);
if (Dlg.DoModal()!=IDOK) return;
char Filename[256];
sprintf(Filename,"%s",Dlg.GetPathName());
Core.RenderToTga(Filename);
}
2000-11-28 00:07:07 +01:00
/*********************************************************************************/
2000-11-15 22:22:40 +01:00
/*** Tilebank Functions **********************************************************/
/*********************************************************************************/
2001-03-01 18:28:20 +01:00
/*
2000-11-15 22:22:40 +01:00
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);
2001-02-14 23:35:47 +01:00
UpdateView();
2000-11-28 15:34:42 +01:00
FocusView();
2000-11-15 22:22:40 +01:00
}
2001-03-01 18:28:20 +01:00
*/
2000-11-29 18:07:57 +01:00
/*********************************************************************************/
2001-03-01 18:28:20 +01:00
/*
2000-11-29 18:07:57 +01:00
void CMapEditDoc::TileBankDelete()
{
Core.TileBankDelete();
2001-02-14 23:35:47 +01:00
UpdateView();
2000-11-29 18:07:57 +01:00
FocusView();
}
2001-03-01 18:28:20 +01:00
*/
2000-11-15 22:22:40 +01:00
/*********************************************************************************/
2001-03-01 18:28:20 +01:00
/*
2000-11-15 22:22:40 +01:00
void CMapEditDoc::TileBankReload()
{
Core.TileBankReload();
2001-02-14 23:35:47 +01:00
UpdateView();
2000-11-28 15:34:42 +01:00
FocusView();
2000-11-14 16:03:04 +01:00
}
2001-03-01 18:28:20 +01:00
*/
2000-11-14 16:03:04 +01:00
/*********************************************************************************/
2001-03-01 18:28:20 +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();
2001-02-14 23:35:47 +01:00
UpdateView();
2000-11-28 15:34:42 +01:00
FocusView();
2000-11-14 16:03:04 +01:00
}
2001-03-01 18:28:20 +01:00
*/
2000-11-17 22:36:13 +01:00
/*********************************************************************************/
2001-02-14 23:35:47 +01:00
void CMapEditDoc::OnMapSetSize()
2000-11-20 17:21:43 +01:00
{
2001-03-13 22:00:34 +01:00
CGUIResize Dlg;
2000-11-20 17:21:43 +01:00
Dlg.m_Width=Core.GetMapWidth();
Dlg.m_Height=Core.GetMapHeight();
if (Dlg.DoModal()!=IDOK) return;
2000-11-17 22:36:13 +01:00
2001-02-09 22:17:01 +01:00
Core.SetMapSize(Dlg.m_Width,Dlg.m_Height);
2000-11-17 22:36:13 +01:00
}
2000-11-22 23:08:47 +01:00
2000-11-28 15:34:42 +01:00
/*********************************************************************************/
void CMapEditDoc::FocusView()
{
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
2000-12-11 22:52:32 +01:00
}
2001-02-20 16:57:03 +01:00
/*********************************************************************************/
2001-04-05 16:20:56 +02:00
2001-05-09 23:56:48 +02:00
2001-07-10 18:56:47 +02:00