1 /*************************************************************************** 2 trackdocument.h - All edit state data 3 ------------------- 4 begin : do dec 12 2006 5 copyright : (C) 2006 by CJP 6 email : cornware-cjp@users.sourceforge.net 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 ***************************************************************************/ 17 18 #ifndef TRACKDOCUMENT_H 19 #define TRACKDOCUMENT_H 20 21 #include <vector> //STL vector template 22 namespace std {} 23 using namespace std; 24 25 #include "edittrack.h" 26 #include "action.h" 27 28 #include "temanager.h" 29 30 /** 31 *@author CJP 32 */ 33 34 class CTrackDocument { 35 public: 36 CTrackDocument(CString trackname = "tracks/default.track"); 37 ~CTrackDocument(); 38 39 CEditTrack *getCurrentTrack(); 40 CEditTrack *getDisplayedTrack(); 41 42 CTEManager *m_DataManager; 43 44 CString m_Trackname; 45 46 void moveCursor(int x, int y, int z); 47 getCursorX()48 int getCursorX(){return m_CursorX;} getCursorY()49 int getCursorY(){return m_CursorY;} getCursorZ()50 int getCursorZ(){return m_CursorZ;} 51 CVector getCursorPos(); 52 53 void applyAction(); //applies the active action to m_FutureTrack 54 void commitAction(); //actually does the action 55 CAction *m_Action; //memory-managed from the outside setNewAction(const CAction * a)56 void setNewAction(const CAction *a) 57 { 58 if(m_Action != NULL) delete m_Action; 59 m_Action = a->copy(); 60 applyAction(); 61 } 62 63 void undo(); 64 void redo(); 65 66 bool load(); 67 bool import(const CString &filename); 68 bool save(); 69 70 bool deleteTile(int ID); 71 bool deleteUnusedTiles(); 72 73 protected: 74 vector<CEditTrack> m_UndoHistory; 75 unsigned int m_UndoIndex; 76 77 CEditTrack *m_FutureTrack; 78 79 int m_CursorX, m_CursorY, m_CursorZ; 80 }; 81 82 extern CTrackDocument *theTrackDocument; 83 #endif 84