// madnessEditorDoc.cpp : implementazione della classe CmadnessEditorDoc // #include "stdafx.h" #include "madnessEditor.h" #include "madnessEditorDoc.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CmadnessEditorDoc IMPLEMENT_DYNCREATE(CmadnessEditorDoc, CDocument) BEGIN_MESSAGE_MAP(CmadnessEditorDoc, CDocument) ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo) END_MESSAGE_MAP() // costruzione/eliminazione di CmadnessEditorDoc CmadnessEditorDoc::CmadnessEditorDoc() { numEnemy=0; UndoMap.Meaningful=false; Busy = FALSE; } CmadnessEditorDoc::~CmadnessEditorDoc() { } BOOL CmadnessEditorDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; Map= MadMap(MAXMAP,MAXMAP); return true; } // diagnostica di CmadnessEditorDoc #ifdef _DEBUG void CmadnessEditorDoc::AssertValid() const { CDocument::AssertValid(); } void CmadnessEditorDoc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG // comandi di CmadnessEditorDoc BOOL CmadnessEditorDoc::OnSaveDocument(LPCTSTR lpszPathName) { FILE *fp=fopen(lpszPathName,"w"); if(!fp) return FALSE; Map.XMLWrite(fp); fclose(fp); return TRUE; } BOOL CmadnessEditorDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; vcg::XmlDoc xml; xml.read(lpszPathName); Map.XMLRead( xml.root() ); return TRUE; } void CmadnessEditorDoc::OnUpdateEditUndo(CCmdUI *pCmdUI) { pCmdUI->Enable(UndoMap.Meaningful); }