From 5bfc9fdcdad1cd699d732e45ddc6955cf47c991b Mon Sep 17 00:00:00 2001 From: Daveo Date: Mon, 20 Nov 2000 16:21:43 +0000 Subject: [PATCH] --- Utils/MapEdit/Core.cpp | 55 ++++++++++++++++++++++++++------ Utils/MapEdit/Core.h | 12 ++++--- Utils/MapEdit/Layer.h | 7 ++++- Utils/MapEdit/LayerTile.cpp | 17 +++++++--- Utils/MapEdit/LayerTile.h | 12 ++++--- Utils/MapEdit/Map.cpp | 18 +++++++++++ Utils/MapEdit/Map.h | 2 ++ Utils/MapEdit/MapEdit.clw | 59 ++++++++++++++++++++++++----------- Utils/MapEdit/MapEdit.rc | 30 +++++++++++++++++- Utils/MapEdit/MapEditDoc.cpp | 40 +++++++++++++----------- Utils/MapEdit/MapEditDoc.h | 9 +++--- Utils/MapEdit/MapEditView.cpp | 18 ++++++----- Utils/MapEdit/MapEditView.h | 1 + Utils/MapEdit/resource.h | 13 ++++++-- 14 files changed, 220 insertions(+), 73 deletions(-) diff --git a/Utils/MapEdit/Core.cpp b/Utils/MapEdit/Core.cpp index 29347821f..4b523067d 100644 --- a/Utils/MapEdit/Core.cpp +++ b/Utils/MapEdit/Core.cpp @@ -60,11 +60,12 @@ CMultiBar *ParamBar=Frm->GetParamBar(); /*****************************************************************************/ void CCore::NewMap() { -// To be loaded/created - Layers[LAYER_TYPE_BACK]= new CLayerTile("Back", 32, 32, 4.0f, FALSE); - Layers[LAYER_TYPE_MID]= new CLayerTile("Mid", TileLayerDefaultWidth/2.0f, TileLayerDefaultHeight/2.0f, 2.0f, FALSE); - Layers[LAYER_TYPE_ACTION]= new CLayerTile("Action",TileLayerDefaultWidth/1.0f, TileLayerDefaultHeight/1.0f, 1.0f, TRUE); - Layers[LAYER_TYPE_FORE]= new CLayerTile("Fore", TileLayerDefaultWidth/0.5f, TileLayerDefaultHeight/0.5f, 0.5f, FALSE); +// Create Gfx Layers +// Name Width Height SizeDiv ViewDiv 3d? Resizable? + Layers[LAYER_TYPE_BACK]= new CLayerTile( "Back", 32, 32, 1.0f, 4.0f, FALSE, FALSE); + Layers[LAYER_TYPE_MID]= new CLayerTile( "Mid", TileLayerDefaultWidth, TileLayerDefaultHeight, 2.0f, 2.0f, FALSE, TRUE); + Layers[LAYER_TYPE_ACTION]= new CLayerTile( "Action",TileLayerDefaultWidth, TileLayerDefaultHeight, 1.0f, 1.0f, TRUE, TRUE); + Layers[LAYER_TYPE_FORE]= new CLayerTile( "Fore", TileLayerDefaultWidth, TileLayerDefaultHeight, 0.5f, 0.5f, FALSE, TRUE); ActiveLayer=LAYER_TYPE_ACTION; MapCam=Vec(0,0,0); @@ -327,15 +328,37 @@ CTileSetDlg *TileSetDlg=(CTileSetDlg*)Frm->GetDialog(IDD_TILESET_DIALOG); } /*****************************************************************************/ -void CCore::MirrorX() +void CCore::MirrorX(CMapEditView *View) { - if (!TileViewFlag) Layers[ActiveLayer]->MirrorX(this); + if (!TileViewFlag) + { + Layers[ActiveLayer]->MirrorX(this); + UpdateView(View); + } } /*****************************************************************************/ -void CCore::MirrorY() +void CCore::MirrorY(CMapEditView *View) { - if (!TileViewFlag) Layers[ActiveLayer]->MirrorY(this); + if (!TileViewFlag) + { + Layers[ActiveLayer]->MirrorY(this); + UpdateView(View); + } +} + +/*****************************************************************************/ +void CCore::ActiveBrushLeft(CMapEditView *View) +{ + TileBank.SetActiveBrushL(); + UpdateView(View); +} + +/*****************************************************************************/ +void CCore::ActiveBrushRight(CMapEditView *View) +{ + TileBank.SetActiveBrushR(); + UpdateView(View); } /*****************************************************************************/ @@ -371,3 +394,17 @@ Vec &ThisCam=GetCam(); if (ThisCam.z>-1) ThisCam.z=-1; if (View) View->Invalidate(); } + +/*****************************************************************************/ +void CCore::SetMapSize(CMapEditView *View,int Width,int Height) +{ + if (Width==GetMapWidth() && Height==GetMapHeight()) return; + + for (int i=0; iResize(Width,Height); + } + Layers[LAYER_TYPE_ACTION]->Resize(Width,Height); + + UpdateView(View); +} \ No newline at end of file diff --git a/Utils/MapEdit/Core.h b/Utils/MapEdit/Core.h index 848b228d5..f5ee16e11 100644 --- a/Utils/MapEdit/Core.h +++ b/Utils/MapEdit/Core.h @@ -45,10 +45,10 @@ public: void TileBankLoad(char *Filename); void TileBankReload(); void TileBankSet(); - void MirrorX(); - void MirrorY(); - void ActiveBrushLeft() {TileBank.SetActiveBrushL();} - void ActiveBrushRight() {TileBank.SetActiveBrushR();} + void MirrorX(CMapEditView *View); + void MirrorY(CMapEditView *View); + void ActiveBrushLeft(CMapEditView *View); + void ActiveBrushRight(CMapEditView *View); // Param Bar void UpdateParamBar(); @@ -72,6 +72,10 @@ public: void SetCursorPos(CPoint &Pos) {CursorPos=Pos;} CPoint &GetCursorPos() {return(CursorPos);} + void SetMapSize(CMapEditView *View,int Width,int Height); + int GetMapWidth() {return(Layers[LAYER_TYPE_ACTION]->GetWidth());} + int GetMapHeight() {return(Layers[LAYER_TYPE_ACTION]->GetHeight());} + private: CPoint CurrentMousePos,LastMousePos; CPoint CursorPos,LastCursorPos; diff --git a/Utils/MapEdit/Layer.h b/Utils/MapEdit/Layer.h index bb845ed5f..33c9b71f1 100644 --- a/Utils/MapEdit/Layer.h +++ b/Utils/MapEdit/Layer.h @@ -50,6 +50,9 @@ virtual void RenderCursor(CCore *Core,Vec &CamPos,BOOL Is3d)=0; virtual void InitGUI(CCore *Core)=0; virtual void UpdateGUI(CCore *Core)=0; +virtual int GetWidth()=0; +virtual int GetHeight()=0; +virtual void Resize(int Width,int Height)=0; // Functions virtual BOOL SetMode(int NewMode)=0; @@ -66,7 +69,9 @@ protected: char Name[256]; BOOL Render3dFlag; - float ZPosDiv; + float ZPosDiv,MapSizeDiv; + BOOL ResizeFlag; + }; diff --git a/Utils/MapEdit/LayerTile.cpp b/Utils/MapEdit/LayerTile.cpp index 4653181d3..f5423983f 100644 --- a/Utils/MapEdit/LayerTile.cpp +++ b/Utils/MapEdit/LayerTile.cpp @@ -25,13 +25,16 @@ /*****************************************************************************/ /*****************************************************************************/ // New Layer -CLayerTile::CLayerTile(char *_Name,int Width,int Height,float ZDiv,BOOL Is3d) +CLayerTile::CLayerTile(char *_Name,int Width,int Height,float MapDiv,float ZDiv,BOOL Is3d,BOOL Resizable) { SetName(_Name); - Map.SetSize(Width,Height,TRUE); ZPosDiv=ZDiv; + MapSizeDiv=MapDiv; + ResizeFlag=Resizable; Render3dFlag=Is3d; Mode=MouseModePaint; + + Map.SetSize(Width/MapDiv,Height/MapDiv,TRUE); } /*****************************************************************************/ @@ -46,6 +49,14 @@ CLayerTile::~CLayerTile() { } +/*****************************************************************************/ +void CLayerTile::Resize(int Width,int Height) +{ + if (!ResizeFlag) return; // Its a fixed size, so DONT DO IT! + + Map.Resize(Width/MapSizeDiv,Height/MapSizeDiv); +} + /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ @@ -476,8 +487,6 @@ BOOL CLayerTile::Paint(CMap &Blk,CPoint &CursorPos) if (CursorPos.y==-1 || CursorPos.y==-1) return(FALSE); // Off Map? if (!Blk.IsValid()) return(FALSE); // Invalid tile? -// Tile.Flags=Flag; - Map.Set(CursorPos.x,CursorPos.y,Blk); return(TRUE); diff --git a/Utils/MapEdit/LayerTile.h b/Utils/MapEdit/LayerTile.h index 08335ecae..740d31454 100644 --- a/Utils/MapEdit/LayerTile.h +++ b/Utils/MapEdit/LayerTile.h @@ -12,8 +12,8 @@ /*****************************************************************************/ enum TileLayerEnum { - TileLayerDefaultWidth=30, - TileLayerDefaultHeight=20, + TileLayerDefaultWidth=3, + TileLayerDefaultHeight=2, }; /*****************************************************************************/ @@ -35,8 +35,8 @@ public: MouseFlagMirrorY=1<<1, }; - CLayerTile(char *_Name,int Width,int Height,float ZDiv,BOOL Is3d); // New Layer - CLayerTile(char *_Name); // Load Layer + CLayerTile(char *_Name,int Width,int Height,float MapDiv,float ZDiv,BOOL Is3d,BOOL Resizable); // New Layer + CLayerTile(char *_Name); // Load Layer ~CLayerTile(); void Render(CCore *Core,Vec &CamPos,BOOL Is3d); @@ -48,6 +48,10 @@ public: void InitGUI(CCore *Core); void UpdateGUI(CCore *Core); + int GetWidth() {return(Map.GetWidth());} + int GetHeight() {return(Map.GetHeight());} + void Resize(int Width,int Height); + // Functions BOOL SetMode(int NewMode); diff --git a/Utils/MapEdit/Map.cpp b/Utils/MapEdit/Map.cpp index 7f319ba10..6c3db86de 100644 --- a/Utils/MapEdit/Map.cpp +++ b/Utils/MapEdit/Map.cpp @@ -186,4 +186,22 @@ int Height=GetHeight(); } /*****************************************************************************/ +void CMap::Resize(int Width,int Height) +{ +CMap Old=*this; +int OldWidth=Old.GetWidth(); +int OldHeight=Old.GetHeight(); +int MinW=min(Width,OldWidth); +int MinH=min(Height,OldHeight); + + Delete(); + SetSize(Width,Height,TRUE); + for (int Y=0; YEnable(); @@ -167,16 +161,16 @@ void CMapEditDoc::ToggleGrid(CMapEditView *View) } /*********************************************************************************/ -void CMapEditDoc::MirrorX() +void CMapEditDoc::MirrorX(CMapEditView *View) { - Core.MirrorX(); + Core.MirrorX(View); theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o) } /*********************************************************************************/ -void CMapEditDoc::MirrorY() +void CMapEditDoc::MirrorY(CMapEditView *View) { - Core.MirrorY(); + Core.MirrorY(View); theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o) } @@ -221,16 +215,26 @@ void CMapEditDoc::TileBankSet() } /*********************************************************************************/ -void CMapEditDoc::ActiveBrushLeft() +void CMapEditDoc::ActiveBrushLeft(CMapEditView *View) { - Core.ActiveBrushLeft(); - UpdateAllViews(NULL); + Core.ActiveBrushLeft(View); } /*********************************************************************************/ -void CMapEditDoc::ActiveBrushRight() +void CMapEditDoc::ActiveBrushRight(CMapEditView *View) { - Core.ActiveBrushRight(); - UpdateAllViews(NULL); - + Core.ActiveBrushRight(View); +} + +/*********************************************************************************/ +void CMapEditDoc::MapSetSize(CMapEditView *View) +{ +CMapSizeDlg Dlg; + + Dlg.m_Width=Core.GetMapWidth(); + Dlg.m_Height=Core.GetMapHeight(); + + if (Dlg.DoModal()!=IDOK) return; + + Core.SetMapSize(View,Dlg.m_Width,Dlg.m_Height); } diff --git a/Utils/MapEdit/MapEditDoc.h b/Utils/MapEdit/MapEditDoc.h index 3f626035d..894d52c4e 100644 --- a/Utils/MapEdit/MapEditDoc.h +++ b/Utils/MapEdit/MapEditDoc.h @@ -31,10 +31,11 @@ public: void MouseMove(CMapEditView *View,UINT nFlags, CPoint &point); void ToggleTileView(CMapEditView *View); void ToggleGrid(CMapEditView *View); - void MirrorX(); - void MirrorY(); - void ActiveBrushLeft(); - void ActiveBrushRight(); + void MirrorX(CMapEditView *View); + void MirrorY(CMapEditView *View); + void ActiveBrushLeft(CMapEditView *View); + void ActiveBrushRight(CMapEditView *View); + void MapSetSize(CMapEditView *View); void TileBankLoad(); void TileBankReload(); diff --git a/Utils/MapEdit/MapEditView.cpp b/Utils/MapEdit/MapEditView.cpp index e9e47c368..ef4aef48e 100644 --- a/Utils/MapEdit/MapEditView.cpp +++ b/Utils/MapEdit/MapEditView.cpp @@ -39,10 +39,11 @@ BEGIN_MESSAGE_MAP(CMapEditView, CGLEnabledView) ON_COMMAND(ID_TOOLBAR_GRID, OnToggleGrid) ON_COMMAND(ID_MIRRORX, OnMirrorx) ON_COMMAND(ID_MIRRORY, OnMirrory) - ON_COMMAND(ID_TOOLBAR_TILEPALETTE, OnToggleTileview) - ON_COMMAND(ID_TOGGLE_GRID, OnToggleGrid) ON_COMMAND(ID_ACTIVEBRUSH_LEFT, OnActivebrushLeft) ON_COMMAND(ID_ACTIVEBRUSH_RIGHT, OnActivebrushRight) + ON_COMMAND(ID_TOOLBAR_TILEPALETTE, OnToggleTileview) + ON_COMMAND(ID_TOGGLE_GRID, OnToggleGrid) + ON_COMMAND(ID_MAP_SETSIZE, OnMapSetSize) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -142,7 +143,8 @@ void CMapEditView::OnSetFocus(CWnd* pOldWnd) CMapEditDoc *CurDoc=GetDocument(); CGLEnabledView::OnSetFocus(pOldWnd); theApp.SetCurrent(CurDoc); - CurDoc->UpdateAll(this); +// CurDoc->UpdateAll(this); + CurDoc->UpdateAllViews(this); } /*********************************************************************************/ @@ -158,8 +160,10 @@ void CMapEditView::OnRButtonUp(UINT nFlags, CPoint point) {GetDocument()->RBu void CMapEditView::OnMouseMove(UINT nFlags, CPoint point) {GetDocument()->MouseMove(this,nFlags, point);} void CMapEditView::OnToggleTileview() {GetDocument()->ToggleTileView(this);} void CMapEditView::OnToggleGrid() {GetDocument()->ToggleGrid(this);} -void CMapEditView::OnMirrorx() {GetDocument()->MirrorX();} -void CMapEditView::OnMirrory() {GetDocument()->MirrorY();} +void CMapEditView::OnMirrorx() {GetDocument()->MirrorX(this);} +void CMapEditView::OnMirrory() {GetDocument()->MirrorY(this);} -void CMapEditView::OnActivebrushLeft() {GetDocument()->ActiveBrushLeft();} -void CMapEditView::OnActivebrushRight() {GetDocument()->ActiveBrushRight();} +void CMapEditView::OnActivebrushLeft() {GetDocument()->ActiveBrushLeft(this);} +void CMapEditView::OnActivebrushRight() {GetDocument()->ActiveBrushRight(this);} + +void CMapEditView::OnMapSetSize() {GetDocument()->MapSetSize(this);} diff --git a/Utils/MapEdit/MapEditView.h b/Utils/MapEdit/MapEditView.h index 4d5f384b5..1b7fcc959 100644 --- a/Utils/MapEdit/MapEditView.h +++ b/Utils/MapEdit/MapEditView.h @@ -61,6 +61,7 @@ protected: afx_msg void OnMirrory(); afx_msg void OnActivebrushLeft(); afx_msg void OnActivebrushRight(); + afx_msg void OnMapSetSize(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; diff --git a/Utils/MapEdit/resource.h b/Utils/MapEdit/resource.h index a3cfaed08..71c5ce16a 100644 --- a/Utils/MapEdit/resource.h +++ b/Utils/MapEdit/resource.h @@ -16,6 +16,7 @@ #define IDI_PICKER 154 #define IDI_MIRRORY 165 #define IDI_MIRRORX 166 +#define IDD_MAPSIZE 167 #define IDC_TOOLBAR_COMBO 1018 #define IDC_LAYER_LIST 1019 #define IDC_TILESETDLG_BTN_UPDATE 1029 @@ -24,6 +25,11 @@ #define IDC_TILESETDLG_BTN_LOAD 1031 #define IDD_GFXTOOLBAR_SELECT 1032 #define IDD_GFXTOOLBAR_PICKER 1033 +#define IDC_MAPSIZE_WIDTH 1037 +#define IDC_MAPSIZE_WIDTH_TEXT 1038 +#define IDC_MAPSIZE_HEIGHT_TEXT 1039 +#define IDC_MAPSIZE_HEIGHT 1040 +#define IDC_MAPSIZE_WARNING 1041 #define ID_TOOLBAR_LAYERBAR 32773 #define ID_TOOLBAR_TILEPALETTE 32774 #define ID_TOOLBAR_COMBO 32777 @@ -36,6 +42,7 @@ #define ID_MIRRORY 32789 #define ID_ACTIVEBRUSH_LEFT 32790 #define ID_ACTIVEBRUSH_RIGHT 32791 +#define ID_MAP_SETSIZE 32792 #define ID_INDICATOR_CURSORXY 59142 // Next default values for new objects @@ -43,9 +50,9 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 167 -#define _APS_NEXT_COMMAND_VALUE 32792 -#define _APS_NEXT_CONTROL_VALUE 1037 +#define _APS_NEXT_RESOURCE_VALUE 168 +#define _APS_NEXT_COMMAND_VALUE 32794 +#define _APS_NEXT_CONTROL_VALUE 1042 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif