diff --git a/Utils/MapEdit/Core.cpp b/Utils/MapEdit/Core.cpp index 5ee65a9c5..f2c1dcefd 100644 --- a/Utils/MapEdit/Core.cpp +++ b/Utils/MapEdit/Core.cpp @@ -30,37 +30,25 @@ BOOL Test3dFlag=TRUE; /*****************************************************************************/ CCore::CCore() { - /* - Layers[LAYER_TYPE_BACK]= new CLayerBack(this); - Layers[LAYER_TYPE_MID]= new CLayerMid(this); - Layers[LAYER_TYPE_ACTION]= new CLayerAction(this); - Layers[LAYER_TYPE_FORE]= new CLayerFore(this); - - TileViewFlag=0; - LayerViewFlag=1; -*/ + for (int i=0; iRender(ThisCam,Test3dFlag); + Layers[i]->Render(this,ThisCam,Test3dFlag); } } - Layers[ActiveLayer]->RenderGrid(ThisCam); + Layers[ActiveLayer]->RenderGrid(this,ThisCam); } // Calc CursorPos - Layers[ActiveLayer]->FindCursorPos(ThisCam,CurrentMousePos); + Layers[ActiveLayer]->FindCursorPos(this,View,ThisCam,CurrentMousePos); } - /*****************************************************************************/ /*** Control *****************************************************************/ /*****************************************************************************/ -void CCore::LButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag) +void CCore::LButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag) { } /*****************************************************************************/ -void CCore::MButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag) +void CCore::MButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag) { LastMousePos=point; } /*****************************************************************************/ -void CCore::RButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag) +void CCore::RButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag) { } /*****************************************************************************/ -void CCore::MouseWheel(UINT nFlags, short zDelta, CPoint &pt) +void CCore::MouseWheel(CMapEditView *View,UINT nFlags, short zDelta, CPoint &pt) { if (zDelta>0) - UpdateView(Vec(0,0,1.0f)); + UpdateView(View,Vec(0,0,1.0f)); else - UpdateView(Vec(0,0,-1.0f)); + UpdateView(View,Vec(0,0,-1.0f)); } /*****************************************************************************/ -void CCore::MouseMove(UINT nFlags, CPoint &point) +void CCore::MouseMove(CMapEditView *View,UINT nFlags, CPoint &point) { Vec Ofs(0,0,0); Vec &ThisCam=GetCam(); // check if active doc - if (theApp.GetCurrent()!=ParentWindow->GetDocument()) return; + if (theApp.GetCurrent()!=View->GetDocument()) return; CurrentMousePos=point; @@ -145,7 +139,7 @@ Vec &ThisCam=GetCam(); float XS,YS; RECT ThisRect; - ParentWindow->GetWindowRect(&ThisRect); + View->GetWindowRect(&ThisRect); XS=ThisCam.z*4;//*Layers[ActiveLayer]->GetLayerZPos(); YS=ThisCam.z*4;//*Layers[ActiveLayer]->GetLayerZPos(); XS/=((ThisRect.right-ThisRect.left)); @@ -158,17 +152,19 @@ Vec &ThisCam=GetCam(); Ofs.x*=XS; Ofs.y*=YS; - UpdateView(Ofs); + UpdateView(View,Ofs); } -// Mouse has moved, so need to redraw windows, to get CursorPos (And pos render) - ParentWindow->Invalidate(); + else + { // Mouse still moved, so need to redraw windows, to get CursorPos (And pos render) + View->Invalidate(); + } } /*****************************************************************************/ /*** Layers ******************************************************************/ /*****************************************************************************/ -void CCore::UpdateLayerBar(BOOL ViewFlag) +void CCore::UpdateLayerBar(CMapEditView *View,BOOL ViewFlag) { CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd(); CToolBar *ToolBar=Frm->GetToolBar(); @@ -192,31 +188,39 @@ CListBox *Dlg=(CListBox *)LayerBar->GetDlgItem(IDC_LAYERBAR_LIST); Frm->ShowControlBar(LayerBar, LayerViewFlag, FALSE); } +/*****************************************************************************/ +void CCore::ToggleLayerView(CMapEditView *View) +{ + UpdateLayerBar(View,!LayerViewFlag); +} + /*****************************************************************************/ void CCore::SetActiveLayer(int i) { - UpdateLayerBar(LayerViewFlag); + UpdateLayerBar(NULL,LayerViewFlag); } /*****************************************************************************/ /*** TileBank ****************************************************************/ /*****************************************************************************/ -void CCore::UpdateTileView(BOOL ViewFlag) +/*****************************************************************************/ +void CCore::UpdateTileView(CMapEditView *View,BOOL ViewFlag) { CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd(); CToolBar *ToolBar=Frm->GetToolBar(); TileViewFlag=ViewFlag; ToolBar->GetToolBarCtrl().PressButton(ID_TOOLBAR_TILEPALETTE,TileViewFlag); - UpdateView(); + UpdateView(View); } /*****************************************************************************/ -GLint CCore::GetTile(int Bank,int TileNo) +void CCore::ToggleTileView(CMapEditView *View) { - return(TileSet[Bank].GetTile(TileNo)); + UpdateTileView(View,!TileViewFlag); } + /*****************************************************************************/ /*** Misc ********************************************************************/ /*****************************************************************************/ @@ -230,28 +234,21 @@ Vec &CCore::GetCam() } /*****************************************************************************/ -void CCore::UpdateAll() +void CCore::UpdateAll(CMapEditView *View) { - UpdateView(); - UpdateLayerBar(LayerViewFlag); - UpdateTileView(TileViewFlag); + UpdateView(View); + UpdateLayerBar(View,LayerViewFlag); + UpdateTileView(View,TileViewFlag); } /*****************************************************************************/ -void CCore::Redraw(BOOL f) -{ - RenderFlag=f; - if (RenderFlag) - ParentWindow->Invalidate(); -} - -/*****************************************************************************/ -void CCore::UpdateView(Vec Ofs) +void CCore::UpdateView(CMapEditView *View,Vec Ofs) { Vec &ThisCam=GetCam(); Ofs.y=-Ofs.y; ThisCam+=Ofs; if (ThisCam.z>-1) ThisCam.z=-1; - Redraw(); + RenderFlag=TRUE; + View->Invalidate(); } diff --git a/Utils/MapEdit/Core.h b/Utils/MapEdit/Core.h index a615bae7f..8156b9175 100644 --- a/Utils/MapEdit/Core.h +++ b/Utils/MapEdit/Core.h @@ -23,47 +23,45 @@ public: CCore(); ~CCore(); - void Init(CMapEditView *Wnd); - void Render(); + void Init(); + void NewMap(); + void OpenMap(); + void Render(CMapEditView *View); // Control - void LButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag); - void MButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag); - void RButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag); - void MouseWheel(UINT nFlags, short zDelta, CPoint &pt); - void MouseMove(UINT nFlags, CPoint &point); + void LButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag); + void MButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag); + void RButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag); + void MouseWheel(CMapEditView *View,UINT nFlags, short zDelta, CPoint &pt); + void MouseMove(CMapEditView *View,UINT nFlags, CPoint &point); // TileBank - void UpdateTileView(BOOL ViewFlag); - BOOL GetTileView() {return(TileViewFlag);} - void ToggleTileView() {UpdateTileView(!TileViewFlag);} + void UpdateTileView(CMapEditView *View,BOOL ViewFlag); + void ToggleTileView(CMapEditView *View); + BOOL GetTileView() {return(TileViewFlag);} - GLint GetTile(int Bank,int TileNo); + CTile GetTile(int Bank,int TileNo) {return(TileBank.GetTile(Bank,TileNo));} // Layers - void UpdateLayerBar(BOOL ViewFlag); - BOOL GetLayerViewFlag() {return(LayerViewFlag);} - void ToggleLayerView() {UpdateLayerBar(!LayerViewFlag);} + void UpdateLayerBar(CMapEditView *View,BOOL ViewFlag); + void ToggleLayerView(CMapEditView *View); + BOOL GetLayerViewFlag() {return(LayerViewFlag);} - void SetActiveLayer(int Layer); - int GetActiveLayer() {return(ActiveLayer);} - CLayer *GetLayer(int i) {return(Layers[i]);} + void SetActiveLayer(int Layer); + int GetActiveLayer() {return(ActiveLayer);} + CLayer *GetLayer(int i) {return(Layers[i]);} // Tex Cache - CTexCache &GetTexCache() {return(TexCache);} + CTexCache &GetTexCache() {return(TexCache);} // Misc - void UpdateAll(); - void UpdateView(Vec Ofs=Vec(0,0,0)); - - Vec &GetCam(); - void SetCursorPos(CPoint &Pos) {CursorPos=Pos;} - CPoint &GetCursorPos() {return(CursorPos);} - CMapEditView *GetParentWindow() {return(ParentWindow);} - void Redraw(BOOL f=TRUE); + void UpdateAll(CMapEditView *View); + void UpdateView(CMapEditView *View,Vec Ofs=Vec(0,0,0)); + Vec &GetCam(); + void SetCursorPos(CPoint &Pos) {CursorPos=Pos;} + CPoint &GetCursorPos() {return(CursorPos);} private: - CMapEditView *ParentWindow; CPoint CurrentMousePos,LastMousePos; CPoint CursorPos,LastCursorPos; Vec MapCam,TileCam; @@ -71,14 +69,14 @@ private: CLayer *Layers[LAYER_TYPE_MAX]; int ActiveLayer; - std::vector TileSet; +// std::vector TileSet; + CTileBank TileBank; CTexCache TexCache; BOOL RenderFlag; BOOL TileViewFlag; BOOL LayerViewFlag; - }; /*****************************************************************************/ diff --git a/Utils/MapEdit/Layer.cpp b/Utils/MapEdit/Layer.cpp index c324b6e0a..77e6da9e0 100644 --- a/Utils/MapEdit/Layer.cpp +++ b/Utils/MapEdit/Layer.cpp @@ -21,7 +21,7 @@ /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ -CLayer::CLayer(CCore *_Core) +CLayer::CLayer() { } @@ -31,23 +31,13 @@ CLayer::~CLayer() } /*****************************************************************************/ -void CLayer::InitLayer(CCore *_Core) +void CLayer::Render(CCore *Core,Vec &MapPos,BOOL Is3d) { -int Width=Map.GetWidth(); -int Height=Map.GetHeight(); - - Core=_Core; - TRACE3("%i x %i = %i\t",Width,Height,Width*Height); + Render2d(Core,MapPos); } /*****************************************************************************/ -void CLayer::Render(Vec &MapPos,BOOL Is3d) -{ - Render2d(MapPos); -} - -/*****************************************************************************/ -void CLayer::Render2d(Vec &MapPos) +void CLayer::Render2d(CCore *Core,Vec &MapPos) { float XYDiv=GetLayerZPosDiv(); return; @@ -69,13 +59,14 @@ int Height=Map.GetHeight(); } /*****************************************************************************/ -void CLayer::Render3d(Vec &MapPos) +void CLayer::Render3d(CCore *Core,Vec &MapPos) { -float XYDiv=GetLayerZPosDiv(); -int MapW=Map.GetWidth(); -int MapH=Map.GetHeight(); -float StartX=MapPos.x/XYDiv; -float StartY=MapPos.y/XYDiv; +float XYDiv=GetLayerZPosDiv(); +int MapW=Map.GetWidth(); +int MapH=Map.GetHeight(); +float StartX=MapPos.x/XYDiv; +float StartY=MapPos.y/XYDiv; +CTexCache &TexCache=Core->GetTexCache(); glMatrixMode(GL_MODELVIEW); @@ -83,18 +74,19 @@ float StartY=MapPos.y/XYDiv; { for (int XLoop=0; XLoopGetTile(ThisElem.Bank,ThisElem.Tile); glLoadIdentity(); // Slow way, but good to go for the mo glTranslatef(StartX+XLoop,StartY-YLoop,MapPos.z); - glCallList(Core->GetTile(ThisTile.Bank,ThisTile.Tile)); + ThisTile.Render(); } } } /*****************************************************************************/ -void CLayer::RenderGrid(Vec &MapPos) +void CLayer::RenderGrid(CCore *Core,Vec &MapPos) { float XYDiv=GetLayerZPosDiv(); int MapW=Map.GetWidth(); @@ -129,7 +121,7 @@ float OverVal=0.5; } /*****************************************************************************/ -void CLayer::FindCursorPos(Vec &MapPos,CPoint &MousePos) +void CLayer::FindCursorPos(CCore *Core,CMapEditView *View,Vec &MapPos,CPoint &MousePos) { GLint Viewport[4]; GLuint SelectBuffer[SELECT_BUFFER_SIZE]; @@ -154,7 +146,7 @@ float StartY=MapPos.y/XYDiv; glPushMatrix(); glLoadIdentity(); gluPickMatrix( MousePos.x ,(Viewport[3]-MousePos.y),5.0,5.0,Viewport); - Core->GetParentWindow()->SetupPersMatrix(); + View->SetupPersMatrix(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); diff --git a/Utils/MapEdit/Layer.h b/Utils/MapEdit/Layer.h index d112da292..4d177c1f3 100644 --- a/Utils/MapEdit/Layer.h +++ b/Utils/MapEdit/Layer.h @@ -30,31 +30,27 @@ enum LAYER_TYPE /*****************************************************************************/ class CCore; class CMap; +class CMapEditView; class CLayer { public: - CLayer(){ASSERT(1);} - CLayer(CCore *_Core); + CLayer(); ~CLayer(); - void InitLayer(CCore *_Core); - // Virtual virtual void Init()=0; virtual char *GetName()=0; -virtual void Render(Vec &MapPos,BOOL Is3d); -virtual void Render2d(Vec &MapPos); -virtual void Render3d(Vec &MapPos); -virtual void RenderGrid(Vec &MapPos); +virtual void Render(CCore *Core,Vec &MapPos,BOOL Is3d); +virtual void Render2d(CCore *Core,Vec &MapPos); +virtual void Render3d(CCore *Core,Vec &MapPos); +virtual void RenderGrid(CCore *Core,Vec &MapPos); virtual float GetLayerZPosDiv()=0; virtual BOOL CanRender3d()=0; -virtual void FindCursorPos(Vec &MapPos,CPoint &MousePos); +virtual void FindCursorPos(CCore *Core,CMapEditView *View,Vec &MapPos,CPoint &MousePos); protected: - - CCore *Core; CMap Map; }; diff --git a/Utils/MapEdit/MapEdit.clw b/Utils/MapEdit/MapEdit.clw index b693e1653..7c9a2f29f 100644 --- a/Utils/MapEdit/MapEdit.clw +++ b/Utils/MapEdit/MapEdit.clw @@ -2,7 +2,7 @@ [General Info] Version=1 -LastClass=CMapEditDoc +LastClass=CMapEditView LastTemplate=CFrameWnd NewFileInclude1=#include "stdafx.h" NewFileInclude2=#include "mapedit.h" @@ -84,7 +84,7 @@ Type=0 BaseClass=CGLEnabledView HeaderFile=MapEditView.h ImplementationFile=MapEditView.cpp -LastObject=CMapEditView +LastObject=ID_TOOLBAR_LAYERBAR Filter=C VirtualFilter=VWC diff --git a/Utils/MapEdit/MapEdit.cpp b/Utils/MapEdit/MapEdit.cpp index 25d67151a..56e23cdb5 100644 --- a/Utils/MapEdit/MapEdit.cpp +++ b/Utils/MapEdit/MapEdit.cpp @@ -95,8 +95,8 @@ BOOL CMapEditApp::InitInstance() // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); -// Prevent creating new doc on startup (should still open cmd line file tho - if (cmdInfo.m_nShellCommand==CCommandLineInfo::FileNew) cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing; +// Prevent creating new doc on startup (should still open cmd line file tho) +// if (cmdInfo.m_nShellCommand==CCommandLineInfo::FileNew) cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing; // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; diff --git a/Utils/MapEdit/MapEditDoc.cpp b/Utils/MapEdit/MapEditDoc.cpp index f7d170e0a..845f36f49 100644 --- a/Utils/MapEdit/MapEditDoc.cpp +++ b/Utils/MapEdit/MapEditDoc.cpp @@ -19,6 +19,7 @@ IMPLEMENT_DYNCREATE(CMapEditDoc, CDocument) BEGIN_MESSAGE_MAP(CMapEditDoc, CDocument) //{{AFX_MSG_MAP(CMapEditDoc) + ON_UPDATE_COMMAND_UI(ID_INDICATOR_CURSORXY, OnStatusCursorXY) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -35,12 +36,9 @@ CMapEditDoc::~CMapEditDoc() BOOL CMapEditDoc::OnNewDocument() { - if (!CDocument::OnNewDocument()) - return FALSE; + if (!CDocument::OnNewDocument()) return FALSE; TRACE0("New Doc\n"); - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) + Core.NewMap(); return TRUE; } @@ -51,21 +49,19 @@ BOOL CMapEditDoc::OnOpenDocument(LPCTSTR lpszPathName) return FALSE; TRACE1("Load Doc %s\n",lpszPathName); - - // TODO: Add your specialized creation code here - + return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CMapEditDoc serialization - void CMapEditDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here + } else { @@ -87,3 +83,83 @@ void CMapEditDoc::Dump(CDumpContext& dc) const CDocument::Dump(dc); } #endif //_DEBUG + +/*********************************************************************************/ +/*********************************************************************************/ +/*********************************************************************************/ +/*********************************************************************************/ +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) +{ + Core.MouseMove(View,nFlags,point); +} + +/*********************************************************************************/ +void CMapEditDoc::ToggleLayerView(CMapEditView *View) +{ + Core.ToggleLayerView(View); +} + +/*********************************************************************************/ +void CMapEditDoc::ToggleTileView(CMapEditView *View) +{ + Core.ToggleTileView(View); +} + diff --git a/Utils/MapEdit/MapEditDoc.h b/Utils/MapEdit/MapEditDoc.h index dba08778e..d50f162f9 100644 --- a/Utils/MapEdit/MapEditDoc.h +++ b/Utils/MapEdit/MapEditDoc.h @@ -19,6 +19,19 @@ protected: // create from serialization only // Attributes public: +// void SetupPersMatrix(float _m_dAspectRatio); + void UpdateView(CMapEditView *View); + void Render(CMapEditView *View); + void UpdateAll(CMapEditView *View); + +// Windows Messages Thru Point + void LButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag); + void MButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag); + void RButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag); + void MouseWheel(CMapEditView *View,UINT nFlags, short zDelta, CPoint &pt); + void MouseMove(CMapEditView *View,UINT nFlags, CPoint &point); + void ToggleLayerView(CMapEditView *View); + void ToggleTileView(CMapEditView *View); // Operations public: @@ -28,8 +41,8 @@ public: //{{AFX_VIRTUAL(CMapEditDoc) public: virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); + virtual void Serialize(CArchive& ar); //}}AFX_VIRTUAL // Implementation @@ -41,11 +54,11 @@ public: #endif protected: - - + CCore Core; // Generated message map functions protected: //{{AFX_MSG(CMapEditDoc) + afx_msg void OnStatusCursorXY(CCmdUI *pCmdUI); //}}AFX_MSG DECLARE_MESSAGE_MAP() diff --git a/Utils/MapEdit/MapEditView.cpp b/Utils/MapEdit/MapEditView.cpp index cf0b62e73..5bca659ee 100644 --- a/Utils/MapEdit/MapEditView.cpp +++ b/Utils/MapEdit/MapEditView.cpp @@ -37,7 +37,6 @@ BEGIN_MESSAGE_MAP(CMapEditView, CGLEnabledView) ON_WM_MOUSEMOVE() ON_COMMAND(ID_TOOLBAR_LAYERBAR, OnToolbarLayerbar) ON_COMMAND(ID_TOOLBAR_TILEPALETTE, OnToolbarTilepalette) - ON_UPDATE_COMMAND_UI(ID_INDICATOR_CURSORXY, OnStatusCursorXY) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -46,9 +45,6 @@ END_MESSAGE_MAP() CMapEditView::CMapEditView() { -//CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd(); -//CDialogBar *LayerBar=Frm->GetLayerBar(); - } CMapEditView::~CMapEditView() @@ -76,16 +72,14 @@ void CMapEditView::OnCreateGL() glEnable(GL_LIGHTING); // Enable Lighting glEnable(GL_COLOR_MATERIAL); // Enable Material Coloring glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations - - Core.Init(this); - } ///////////////////////////////////////////////////////////////////////////// + void CMapEditView::OnDrawGL() { - Core.Render(); + GetDocument()->Render(this); } ///////////////////////////////////////////////////////////////////////////// @@ -99,17 +93,17 @@ void CMapEditView::OnSizeGL(int cx, int cy) SetupPersMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); - Core.Redraw(); + GetDocument()->UpdateView(this); } ///////////////////////////////////////////////////////////////////////////// -void CMapEditView::SetupPersMatrix() +void CMapEditView::SetupPersMatrix() { gluPerspective(40.0,m_dAspectRatio,0.1f, 100.0f); glTranslatef(0.0f,0.0f,-4.f); - } + ///////////////////////////////////////////////////////////////////////////// // CMapEditView diagnostics @@ -139,41 +133,19 @@ void CMapEditView::OnSetFocus(CWnd* pOldWnd) CMapEditDoc *CurDoc=GetDocument(); CGLEnabledView::OnSetFocus(pOldWnd); theApp.SetCurrent(CurDoc); - UpdateAll(); + CurDoc->UpdateAll(this); } /*********************************************************************************/ /*********************************************************************************/ /*********************************************************************************/ -void CMapEditView::UpdateAll() -{ - Core.UpdateAll(); -} - -/*********************************************************************************/ -void CMapEditView::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); -} - -/*********************************************************************************/ -/*********************************************************************************/ -/*********************************************************************************/ -void CMapEditView::OnLButtonDown(UINT nFlags, CPoint point) {Core.LButtonControl(nFlags,point,TRUE);} -void CMapEditView::OnLButtonUp(UINT nFlags, CPoint point) {Core.LButtonControl(nFlags,point,FALSE);} -void CMapEditView::OnMButtonDown(UINT nFlags, CPoint point) {Core.MButtonControl(nFlags,point,TRUE);} -void CMapEditView::OnMButtonUp(UINT nFlags, CPoint point) {Core.MButtonControl(nFlags,point,FALSE);} -BOOL CMapEditView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) {Core.MouseWheel(nFlags,zDelta,pt) ;return(0);} -void CMapEditView::OnRButtonDown(UINT nFlags, CPoint point) {Core.RButtonControl(nFlags,point,TRUE);} -void CMapEditView::OnRButtonUp(UINT nFlags, CPoint point) {Core.RButtonControl(nFlags,point,FALSE);} -void CMapEditView::OnMouseMove(UINT nFlags, CPoint point) {Core.MouseMove(nFlags, point);} - -void CMapEditView::OnToolbarLayerbar() {Core.ToggleLayerView();} -void CMapEditView::OnToolbarTilepalette() {Core.ToggleTileView();} - - +void CMapEditView::OnLButtonDown(UINT nFlags, CPoint point) {GetDocument()->LButtonControl(this,nFlags,point,TRUE);} +void CMapEditView::OnLButtonUp(UINT nFlags, CPoint point) {GetDocument()->LButtonControl(this,nFlags,point,FALSE);} +void CMapEditView::OnMButtonDown(UINT nFlags, CPoint point) {GetDocument()->MButtonControl(this,nFlags,point,TRUE);} +void CMapEditView::OnMButtonUp(UINT nFlags, CPoint point) {GetDocument()->MButtonControl(this,nFlags,point,FALSE);} +BOOL CMapEditView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) {GetDocument()->MouseWheel(this,nFlags,zDelta,pt) ;return(0);} +void CMapEditView::OnRButtonDown(UINT nFlags, CPoint point) {GetDocument()->RButtonControl(this,nFlags,point,TRUE);} +void CMapEditView::OnRButtonUp(UINT nFlags, CPoint point) {GetDocument()->RButtonControl(this,nFlags,point,FALSE);} +void CMapEditView::OnMouseMove(UINT nFlags, CPoint point) {GetDocument()->MouseMove(this,nFlags, point);} +void CMapEditView::OnToolbarLayerbar() {GetDocument()->ToggleLayerView(this);} +void CMapEditView::OnToolbarTilepalette() {GetDocument()->ToggleTileView(this);} diff --git a/Utils/MapEdit/MapEditView.h b/Utils/MapEdit/MapEditView.h index 6cc2788b4..24a30287c 100644 --- a/Utils/MapEdit/MapEditView.h +++ b/Utils/MapEdit/MapEditView.h @@ -39,11 +39,9 @@ public: virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif - void UpdateAll(); protected: void VideoMode(ColorsNumber &c,ZAccuracy &z,BOOL &dbuf); - CCore Core; // Generated message map functions protected: @@ -59,7 +57,6 @@ protected: afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnToolbarLayerbar(); afx_msg void OnToolbarTilepalette(); - afx_msg void OnStatusCursorXY(CCmdUI *pCmdUI); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; diff --git a/Utils/MapEdit/TileSet.cpp b/Utils/MapEdit/TileSet.cpp index d9d64ef11..5a24ba0a8 100644 --- a/Utils/MapEdit/TileSet.cpp +++ b/Utils/MapEdit/TileSet.cpp @@ -9,6 +9,7 @@ #include #include +#include "Core.h" #include "TileSet.h" #include "GinTex.h" #include "utils.h" @@ -16,19 +17,63 @@ /*****************************************************************************/ /*****************************************************************************/ +/*** TileBank ****************************************************************/ /*****************************************************************************/ -CTileSet::CTileSet(char *_Filename,CCore *Core) +/*****************************************************************************/ +CTileBank::CTileBank() +{ + LoadFlag=FALSE; +} + +/*****************************************************************************/ +CTileBank::~CTileBank() +{ +} + +/*****************************************************************************/ +void CTileBank::AddTileSet(char *Filename) +{ + TileSet.push_back(CTileSet(Filename)); + LoadFlag=TRUE; +} + +/*****************************************************************************/ +void CTileBank::LoadTileSets(CCore *Core) +{ +int ListSize=TileSet.size(); + + for (int i=0;i TileSet; + BOOL LoadFlag; + +}; + +/*****************************************************************************/ class CTileSet { public: - CTileSet(char *_Filename,CCore *Core); + CTileSet(char *_Filename); ~CTileSet(); - int Load(CCore *Core,char *_Filename); + int IsLoaded() {return(Loaded);} + void Load(CCore *Core); char *GetPath() {return(Path);} char *GetFilename() {return(Filename);} - GLint GetTile(int No) {return(Tile[No].GetTile());} + CTile &GetTile(int No) {return(Tile[No]);} + private: - char Path[256]; - char Filename[256]; + char FullName[256],Path[256],Filename[256]; std::vector Tile; + BOOL Loaded; };