diff --git a/Utils/MapEdit/CmdMsg.h b/Utils/MapEdit/CmdMsg.h index e0a2e0a91..544df2e9d 100644 --- a/Utils/MapEdit/CmdMsg.h +++ b/Utils/MapEdit/CmdMsg.h @@ -9,30 +9,30 @@ enum CmdMsg { CmdMsg_None=0, // Core - CmdMsg_ToggleSubView, - CmdMsg_ToggleGrid, - CmdMsg_Toggle2d, - CmdMsg_ZoomIn, - CmdMsg_ZoomOut, - CmdMsg_ResetView, - CmdMsg_SetLayer, - CmdMsg_AddLayer, - CmdMsg_DeleteLayer, + CmdMsg_ToggleSubView, // 1 + CmdMsg_ToggleGrid, // 2 + CmdMsg_Toggle2d, // 3 + CmdMsg_ZoomIn, // 4 + CmdMsg_ZoomOut, // 5 + CmdMsg_ResetView, // 6 + CmdMsg_SetLayer, // 7 + CmdMsg_AddLayer, // 8 + CmdMsg_DeleteLayer, // 9 // Generic - CmdMsg_SetMode, - CmdMsg_Copy, - CmdMsg_Paste, - CmdMsg_SubViewLoad, - CmdMsg_SubViewDelete, - CmdMsg_SubViewUpdate, - CmdMsg_SubViewSet, + CmdMsg_SetMode, // 10 + CmdMsg_Copy, // 11 + CmdMsg_Paste, // 12 + CmdMsg_SubViewLoad, // 13 + CmdMsg_SubViewDelete, // 14 + CmdMsg_SubViewUpdate, // 15 + CmdMsg_SubViewSet, // 16 // TileLayer/TileBank - CmdMsg_MirrorX, - CmdMsg_MirrorY, - CmdMsg_SetColFlag, - CmdMsg_ActiveBrushLeft, - CmdMsg_ActiveBrushRight, + CmdMsg_MirrorX, // 17 + CmdMsg_MirrorY, // 18 + CmdMsg_SetColFlag, // 19 + CmdMsg_ActiveBrushLeft, // 20 + CmdMsg_ActiveBrushRight, // 21 }; #endif /*****************************************************************************/ diff --git a/Utils/MapEdit/Core.cpp b/Utils/MapEdit/Core.cpp index 7f3ba1502..22ad50298 100644 --- a/Utils/MapEdit/Core.cpp +++ b/Utils/MapEdit/Core.cpp @@ -15,11 +15,12 @@ #include "MainFrm.h" #include "Core.h" +#include "Elem.h" #include "Layer.h" #include "LayerTile.h" #include "LayerCollision.h" #include "LayerShade.h" -#include "LayerItem.h" +#include "LayerThing.h" #include "utils.h" #include "Export.h" @@ -28,6 +29,8 @@ #include "GUINewMap.h" +GString IconzFileName="Iconz.bmp"; + /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ @@ -41,12 +44,20 @@ CCore::CCore() CurrentView=NULL; CursorPos.x=CursorPos.y=0; CurrentLayer=0; - + +GString Filename; + IconBank=new CElemBank(16,16,false,false); + + GetExecPath(Filename); + Filename+=IconzFileName; + IconBank->AddSet(Filename); } /*****************************************************************************/ CCore::~CCore() { + IconBank->CleanUp(); + delete IconBank; int ListSize=Layer.size(); for (int i=0; iRead(&MapCam,sizeof(Vector3)); - if (VersionRead(&MapCamOfs,sizeof(Vector3)); File->Read(&DuffVector,sizeof(Vector3)); @@ -134,7 +145,7 @@ int LayerCount; AddLayer(new CLayerShade(File,Version)); break; case LAYER_TYPE_ITEM: - AddLayer(new CLayerItem(File,Version)); + AddLayer(new CLayerThing(File,Version)); break; default: ASSERT(!"poos"); @@ -172,7 +183,6 @@ BOOL F; F=GridFlag; File->Write(&F,sizeof(BOOL)); F=Is3dFlag; File->Write(&F,sizeof(BOOL)); - // Layers int LayerCount=Layer.size(); File->Write(&LayerCount,sizeof(int)); @@ -185,12 +195,6 @@ int LayerCount=Layer.size(); Layer[i]->Save(File); } GetTileBank()->Save(File); -/* -CString a=File->GetFilePath(); -char Txt[256]; - sprintf(Txt,"%s",a); - Export(Txt); -*/ } /*****************************************************************************/ @@ -217,44 +221,32 @@ Vector3 &ThisCam=GetCam(); UpdateAll(); return; } -// if (GetTileBank()->NeedLoad()) GetTileBank()->LoadAllSets(this); + if (IconBank->NeedLoad()) IconBank->LoadAllSets(this); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen - if (IsSubView() || CurrentLayer->IsUnique()) - { - CurrentLayer->Render(this,ThisCam,Is3dFlag); - if (GridFlag) CurrentLayer->RenderGrid(this,ThisCam,true); - CurrentLayer->FindCursorPos(this,GetCam(),CurrentMousePos); - } - else - { - RenderLayers(); - } - CurrentLayer->RenderCursor(this,ThisCam,Is3dFlag); -// Get Cursor Pos - LastCursorPos=CursorPos; - CurrentLayer->FindCursorPos(this,GetCam(),CurrentMousePos); + RenderLayers(IsSubView() || CurrentLayer->IsUnique()); } /*****************************************************************************/ -void CCore::RenderLayers() +void CCore::RenderLayers(bool OneShot) { Vector3 &ThisCam=GetCam(); int ListSize=Layer.size(); int StartLayer,EndLayer; + if (OneShot) + { + StartLayer=ActiveLayer; + EndLayer=StartLayer+1; + } + else + { StartLayer=0; EndLayer=ListSize; - -// while (Layer[StartLayer]->IsUnique()) StartLayer++; - -// if (Layer[ActiveLayer]->IsUnique()) -// { -// StartLayer=ActiveLayer; -// EndLayer=StartLayer+1; -// } + while (Layer[StartLayer]->IsUnique()) StartLayer++; + } for (int i=StartLayer; iRenderGrid(this,ThisCam,i==ActiveLayer); } } + CurrentLayer->RenderCursor(this,ThisCam,Is3dFlag); +// Get Cursor Pos + LastCursorPos=CursorPos; + CurrentLayer->FindCursorPos(this,GetCam(),CurrentMousePos); } @@ -419,7 +415,7 @@ CMainFrame *Frm=(CMainFrame*)AfxGetMainWnd(); CGUIMultiBar *ParamBar=Frm->GetParamBar(); GUIRemoveAll(); - GUIAdd(LayerList,IDD_LAYER_LIST_DIALOG); + GUIAdd(LayerList,IDD_LAYER_LIST); CurrentLayer->GUIInit(this); GUIUpdate(); } @@ -513,7 +509,7 @@ int Idx; Idx=AddLayer(new CLayerShade(SubType, Width,Height)); break; case LAYER_TYPE_ITEM: - Idx=AddLayer(new CLayerItem(SubType, Width,Height)); + Idx=AddLayer(new CLayerThing(SubType, Width,Height)); break; default: ASSERT(!"AddLayer - Invalid Layer Type"); @@ -669,6 +665,19 @@ Vector3 &ThisCam=GetCam(); ThisCam=DefaultCamPos; UpdateView(); } +/*****************************************************************************/ +void CCore::GetExecPath(GString &Path) +{ +// Get application path +char ExeFilename[2048]; +GFName Exe; + GetModuleFileName(GetModuleHandle(NULL),ExeFilename,2048); + Exe=ExeFilename; + Exe.File(0); + Exe.Ext(0); + Path=Exe.FullName(); +} + /*****************************************************************************/ /*** GUI *********************************************************************/ diff --git a/Utils/MapEdit/Core.h b/Utils/MapEdit/Core.h index aecc39e13..38414df27 100644 --- a/Utils/MapEdit/Core.h +++ b/Utils/MapEdit/Core.h @@ -19,7 +19,7 @@ #include "Layer.h" #include "LayerTile.h" -const s32 FileVersion=4; +const s32 FileVersion=5; #define SCREEN_MAP_WIDTH 30 #define SCREEN_MAP_HEIGHT 20 @@ -41,7 +41,7 @@ public: void Save(CFile *File); bool Question(char *Txt); void Render(bool ForceRender=FALSE); - void RenderLayers(); + void RenderLayers(bool OneShot=false); void Export(char *Filename); // View Stuff @@ -114,7 +114,8 @@ public: void PasteSelection(); void ResetView(); - + CElemBank *GetIconBank() {return(IconBank);} + void GetExecPath(GString &Path); private: CMapEditView *CurrentView; CPoint CurrentMousePos,LastMousePos; @@ -135,7 +136,9 @@ private: bool SpareFlag; bool GridFlag; bool Is3dFlag; - + + CElemBank *IconBank; + }; /*****************************************************************************/ diff --git a/Utils/MapEdit/Elem.cpp b/Utils/MapEdit/Elem.cpp index 4312f430f..e29627c6b 100644 --- a/Utils/MapEdit/Elem.cpp +++ b/Utils/MapEdit/Elem.cpp @@ -6,6 +6,7 @@ #include #include #include +#include "GLEnabledView.h" #include #include @@ -15,7 +16,25 @@ #include "GinTex.h" #include "utils.h" +#include "MapEdit.h" +#include "MapEditDoc.h" +#include "MapEditView.h" +#include "MainFrm.h" +#include "GUITileBank.h" + + +const Vector3 DefOfs(+0.5f,0,+4.0f); + +/*****************************************************************************/ +// All Elems MUST run from 0,0 -> + +/*****************************************************************************/ +const float ElemBrowserGap=0.2f; +const float ElemBrowserX0=0-ElemBrowserGap/2; +const float ElemBrowserX1=1+ElemBrowserGap/2; +const float ElemBrowserY0=0-ElemBrowserGap/2; +const float ElemBrowserY1=1+ElemBrowserGap/2; /*****************************************************************************/ const float XFlipMtx[]= @@ -66,10 +85,11 @@ GFName Path=Filename; Type=ElemType3d; TexXOfs=-1; TexYOfs=-1; + Ofs.Zero(); Build3dElem(TexCache,ThisScene,Node); Calc3dSize(); - Ofs.x=+0.5f; Ofs.y=0; Ofs.z=+4.0f; Build3dDrawList(TexCache,DrawList[ElemType3d]); + Ofs.Zero(); Create2dTexture(TexCache,Path.File(),Node); Build2dDrawList(TexCache,DrawList[ElemType2d]); if (!ValidFlag) CreateInvalidTileGfx(); @@ -78,7 +98,7 @@ GFName Path=Filename; /*****************************************************************************/ // 2d Elem (From Bmp File) -CElem::CElem(CCore *Core,const char *Filename,int TexID,int XOfs,int YOfs,int Width,int Height) +CElem::CElem(CCore *Core,const char *Filename,int TexID,int XOfs,int YOfs,int Width,int Height,bool Centre) { CTexCache &TexCache=Core->GetTexCache(); GFName Path=Filename; @@ -91,8 +111,15 @@ GFName Path=Filename; Type=ElemType2d; TexXOfs=XOfs; TexYOfs=YOfs; - Build2dElem(Core,Path.File(),TexID); Ofs.Zero(); + if (Centre) + { + Ofs.x=0.5-UnitWidth/2; +// Ofs.y=0.5-UnitHeight/2; + Ofs.y=-1.0f; + } + + Build2dElem(Core,Path.File(),TexID); Build3dDrawList(TexCache,DrawList[ElemType3d]); Create2dTexture(TexCache,Path.File(),TexID); Build2dDrawList(TexCache,DrawList[ElemType2d]); @@ -108,10 +135,15 @@ void CElem::CleanUp() /*****************************************************************************/ void CElem::Build2dElem(CCore *Core,const char *Filename,int TexID) { -const Vector3 P0(0.0f,0.0f,0.0f); -const Vector3 P1(1.0f,0.0f,0.0f); -const Vector3 P2(0.0f,1.0f,0.0f); -const Vector3 P3(1.0f,1.0f,0.0f); +float X0=0; +float X1=+UnitWidth; +float Y0=0; +float Y1=+UnitHeight; + +Vector3 P0(X0,Y0,0); +Vector3 P1(X1,Y0,0); +Vector3 P2(X0,Y1,0); +Vector3 P3(X1,Y1,0); int ListSize=TriList.size(); TriList.resize(ListSize+2); @@ -121,13 +153,14 @@ sTriFace &Tri1=TriList[ListSize+1]; CTexCache &TexCache=Core->GetTexCache(); sTex &ThisTex=TexCache.GetTex(TexID); -float u0,u1,v0,v1; - - u0=(TexXOfs)*ThisTex.dW; - u1=u0+ThisTex.dW; +float dU=1.0/((float)ThisTex.TexWidth/(float)ElemWidth); +float dV=1.0/((float)ThisTex.TexHeight/(float)ElemHeight); - v0=(((ThisTex.TexHeight/UnitSize)-(TexYOfs+1))*ThisTex.dH); - v1=v0+ThisTex.dH; +float u0=(TexXOfs*dU); +float u1=u0+dU; + +float v1=1.0-(TexYOfs*dV); +float v0=v1-dV; Tri0.Mat=TexID; @@ -151,13 +184,15 @@ float u0,u1,v0,v1; void CElem::Build3dElem(CTexCache &TexCache,CScene &ThisScene,int Node) { CNode &ThisNode=ThisScene.GetNode(Node); -int ChildCount=ThisNode.GetChildCount(); +CNode &ParentNode=ThisScene.GetNode(ThisNode.ParentIdx); +int ChildCount=ThisNode.GetPruneChildCount(); std::vector const &NodeTriList=ThisNode.GetTris(); -std::vectorconst &NodeVtxList=ThisNode.GetRelPts(); +std::vectorconst &NodeVtxList=ThisNode.GetPts(); std::vector const &NodeUVList=ThisNode.GetUVTris(); std::vector const &NodeTriMat=ThisNode.GetTriMaterial(); -std::vector const &TexList= ThisScene.GetTexNames();//List(); -std::vector const &MatList= ThisScene.GetMaterials(); + +std::vector const &SceneTexList=ThisScene.GetTexList(); +std::vector const &SceneUsedMatList=ThisScene.GetUsedMaterialIdx(); int TriCount=NodeTriList.size(); int ListSize=TriList.size(); @@ -169,28 +204,38 @@ int ListSize=TriList.size(); sUVTri const &ThisUV=NodeUVList[T]; sTriFace &Tri=TriList[ListSize+T]; int ThisMat=NodeTriMat[T]; - int TexID=1; + int TexID; -// Sort Textures - Only add the ones that are used :o) - TexID=MatList[ThisMat].TexId; +// Sort Textures - Only add the ones nthat are used :o) + TexID=SceneUsedMatList[ThisMat]; + if (TexID!=-1) { GString ThisName; - ThisName=SetPath+TexList[TexID]; - TexID=TexCache.ProcessTexture(ThisName,MatList[ThisMat].Flags); + ThisName=SetPath+SceneTexList[TexID]; + TRACE2("%i !%s!\n",TexID,ThisName); + TexID=TexCache.ProcessTexture(ThisName); } // Sort Rest of Tri info +Matrix4x4 TransMtx; + TransMtx.Identity(); + + if (ParentNode.GetTris().size() || !ThisNode.ParentIdx) + { + TransMtx=ThisNode.Mtx; + TransMtx.Invert(); + } + for (int p=0; p<3; p++) { - Tri.vtx[p]=NodeVtxList[ThisTri.p[p]]; + Tri.vtx[p]=TransMtx*NodeVtxList[ThisTri.p[p]]; Tri.uvs[p].u=ThisUV.p[p].u; Tri.uvs[p].v=ThisUV.p[p].v; Tri.Mat=TexID; } } - for (int Child=0; ChildTri.vtx[p].x) XMin=Tri.vtx[p].x; - if (XMaxTri.vtx[p].y) YMin=Tri.vtx[p].y; - if (YMaxTri.vtx[p].x) Min.x=Tri.vtx[p].x; + if (Min.y>Tri.vtx[p].y) Min.y=Tri.vtx[p].y; + if (Min.z>Tri.vtx[p].z) Min.z=Tri.vtx[p].z; + if (Max.xGetTexCache(); -int TexID=TexCache.ProcessTexture(Filename,0); +int TexID=TexCache.ProcessTexture(Filename); sTex &ThisTex=TexCache.GetTex(TexID); -int Width=ThisTex.TexWidth/DefWidth; -int Height=ThisTex.TexHeight/DefHeight; +int Width,Height; + + if (MaxWidth==-1) MaxWidth=ThisTex.TexWidth; + if (MaxHeight==-1) MaxHeight=ThisTex.TexHeight; + + Width=ThisTex.TexWidth/MaxWidth; + Height=ThisTex.TexHeight/MaxHeight; + - ElemList.push_back(CElem(DefWidth,DefHeight)); // Insert Blank - for (int Y=0; Y=5) + { + File->Read(&CurrentSet,sizeof(int)); + } File->Read(&ListSize,sizeof(int)); // New Style rel storage @@ -708,6 +799,7 @@ GString SavePath; SavePath.Upper(); + File->Write(&CurrentSet,sizeof(int)); File->Write(&ListSize,sizeof(int)); for (int i=0; i=0 && Elem>=0); - return(SetList[Set].GetElem(Elem)); -} - /*****************************************************************************/ bool CElemBank::IsValid(int Set,int Elem) { if (Set<0 || Elem<0) return(false); if (Elem==0) return(true); + if (Set>=SetList.size()) return(false); ASSERT(SetGetView()->SetupPersMatrix(); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + + while(TileID!=ListSize) + { + CPoint Pos=GetElemPos(TileID,BrowserWidth); + float XPos=(float)Pos.x*(1+ElemBrowserGap); + float YPos=(float)Pos.y*(1+ElemBrowserGap); + + glLoadIdentity(); + glScalef(Scale,Scale,Scale); + glTranslatef(-CamPos.x+XPos,CamPos.y-YPos,0); + + glLoadName (TileID); + glBegin (GL_QUADS); + BuildGLQuad(ElemBrowserX0,ElemBrowserX1,ElemBrowserY0,ElemBrowserY1,0); + glEnd(); + TileID++; + } + + HitCount= glRenderMode (GL_RENDER); + glPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + +// Process hits + +GLuint *HitPtr=SelectBuffer; + + TileID=-2; + if (HitCount) // Just take 1st + { + TileID=HitPtr[3]; + } + glMatrixMode(GL_MODELVIEW); // <-- Prevent arse GL assert + + CursorPos=TileID; +} + +/*****************************************************************************/ +/*** Gui *********************************************************************/ +/*****************************************************************************/ +void CElemBank::GUIInit(CCore *Core) +{ + Core->GUIAdd(GUIElemList,IDD_ELEMLIST); +} + +/*****************************************************************************/ +void CElemBank::GUIKill(CCore *Core) +{ + Core->GUIRemove(GUIElemList,IDD_ELEMLIST); +} + +/*****************************************************************************/ +void CElemBank::GUIUpdate(CCore *Core) +{ +int ListSize=GetSetCount(); +bool IsSubView=Core->IsSubView(); + + if (GUIElemList.m_List) + { + GUIElemList.m_List.ResetContent(); + if (ListSize) + { + for (int i=0; i ElemList; bool Loaded; int ElemBrowserWidth; }; /*****************************************************************************/ -class CElemBank +class CElemBank : public CLayer { public: - CElemBank(); - ~CElemBank(); - void CleanUp(); +// Local + CElemBank(int MaxWidth,int MaxHeight,bool Blank,bool Centre); +virtual ~CElemBank(); + void CleanUp(); - void Load(CFile *File,int Version); - void Save(CFile *File); +virtual void Load(CFile *File,int Version); +virtual void Save(CFile *File); void AddSet(const char *Filename); void LoadAllSets(CCore *Core); @@ -156,16 +160,49 @@ public: void ReloadAllSets(); void DeleteSet(int Set); int NeedLoad() {return(LoadFlag);} - CElem &GetElem(int Set,int Elem); + CElem &GetElem(int Set,int Elem) {return(SetList[Set].GetElem(Elem));} bool IsValid(int Set,int Elem); + void RenderElem(int Set,int Elem,int Flags,bool Is3d); int GetSetCount() {return(SetList.size());} - + +const char *GetSetName(int Set) {return(SetList[Set].GetName());} +const char *GetSetFilename(int Set) {return(SetList[Set].GetFilename());} + +// Overloads +virtual int GetType() {return(0);} + +virtual void RenderGrid(CCore *Core,Vector3 &CamPos,bool Active); +virtual void RenderSelection(CCore *Core,Vector3 &ThisCam){}; +virtual void FindCursorPos(CCore *Core,Vector3 &CamPos,CPoint &MousePos); + +virtual void GUIInit(CCore *Core); +virtual void GUIKill(CCore *Core); +virtual void GUIUpdate(CCore *Core); +virtual void GUIChanged(CCore *Core); + +virtual void Export(CCore *Core,CExport &Exp){}; + +virtual bool LButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag) {return(false);} +virtual bool RButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag) {return(false);} +virtual bool MouseMove(CCore *Core,UINT nFlags, CPoint &CursorPos) {return(false);} +virtual bool Command(int CmdMsg,CCore *Core,int Param0=0,int Param1=0) {return(false);} + CPoint GetElemPos(int ID,int Width); + +// Local +virtual bool CanClose() {return(true);} protected: - CList SetList; + bool LoadFlag; + int CurrentSet; + int CursorPos; + + int MaxWidth,MaxHeight; + bool BlankFlag,CentreFlag; + + CGUIElemList GUIElemList; }; diff --git a/Utils/MapEdit/Export.cpp b/Utils/MapEdit/Export.cpp index 3397b489a..7abdeef07 100644 --- a/Utils/MapEdit/Export.cpp +++ b/Utils/MapEdit/Export.cpp @@ -125,7 +125,7 @@ CTileBank *TileBank=Core->GetTileBank(); } else { - CElem &ThisTile=TileBank->GetTile(OutTile.Set,OutTile.Tile); + CElem &ThisTile=TileBank->GetElem(OutTile.Set,OutTile.Tile); GString SetName=TileBank->GetSetFilename(OutTile.Set); ASSERT(ThisTile.GetElemWidth()==FileHdr.TileW); diff --git a/Utils/MapEdit/GUILayerShade.h b/Utils/MapEdit/GUILayerShade.h index 75b177aef..be5cb3a17 100644 --- a/Utils/MapEdit/GUILayerShade.h +++ b/Utils/MapEdit/GUILayerShade.h @@ -33,7 +33,7 @@ public: // Dialog Data //{{AFX_DATA(CGUILayerShade) - enum { IDD = IDD_LAYERSHADE_GUI }; + enum { IDD = IDD_LAYER_SHADE }; CEdit m_R0; CEdit m_G0; CEdit m_B0; diff --git a/Utils/MapEdit/GUIToolBar.h b/Utils/MapEdit/GUIToolBar.h index 24b55d502..95720e756 100644 --- a/Utils/MapEdit/GUIToolBar.h +++ b/Utils/MapEdit/GUIToolBar.h @@ -24,7 +24,7 @@ public: // Dialog Data //{{AFX_DATA(GUIToolBar) - enum { IDD = IDD_LAYER_TOOLBAR }; + enum { IDD = IDD_TOOLBAR }; CButton m_Select; CButton m_Paint; //}}AFX_DATA diff --git a/Utils/MapEdit/LayerCollision.cpp b/Utils/MapEdit/LayerCollision.cpp index 261a09462..72e7f4fc4 100644 --- a/Utils/MapEdit/LayerCollision.cpp +++ b/Utils/MapEdit/LayerCollision.cpp @@ -21,7 +21,6 @@ #include "Select.h" #include "Export.h" -// Reserve slot 0 for collision :o) GString ColFName="Collision.bmp"; /*****************************************************************************/ @@ -47,32 +46,20 @@ CLayerCollision::CLayerCollision(CFile *File,int Version) /*****************************************************************************/ CLayerCollision::~CLayerCollision() { + TileBank->CleanUp(); delete TileBank; } /*****************************************************************************/ void CLayerCollision::InitSubView(CCore *Core) { +GString Filename; TileBank=new CTileBank; SubView=TileBank; -GFName ExePath; -GString Filename; - -// Get application path -#ifdef _DEBUG - ExePath="C:\\Spongebob\\tools\\mapedit\\"; -#else -char ExeFilename[2048]; - GetModuleFileName(GetModuleHandle(NULL),ExeFilename,2048); - ExePath=ExeFilename; - ExePath.File(0); - ExePath.Ext(0); -#endif - Filename=ExePath.FullName(); + Core->GetExecPath(Filename); Filename+=ColFName; TileBank->AddSet(Filename); - } /*****************************************************************************/ @@ -135,14 +122,14 @@ bool Ret=false; /*****************************************************************************/ void CLayerCollision::GUIInit(CCore *Core) { - Core->GUIAdd(GUIToolBar,IDD_LAYERTILE_TOOLBAR); + Core->GUIAdd(GUIToolBar,IDD_TOOLBAR); Core->GUIAdd(GUI,IDD_LAYER_COLLISION); } /*****************************************************************************/ void CLayerCollision::GUIKill(CCore *Core) { - Core->GUIRemove(GUIToolBar,IDD_LAYERTILE_TOOLBAR); + Core->GUIRemove(GUIToolBar,IDD_TOOLBAR); Core->GUIRemove(GUI,IDD_LAYER_COLLISION); } diff --git a/Utils/MapEdit/LayerThing.cpp b/Utils/MapEdit/LayerThing.cpp index 18ec40761..e0e1be220 100644 --- a/Utils/MapEdit/LayerThing.cpp +++ b/Utils/MapEdit/LayerThing.cpp @@ -1,6 +1,6 @@ -/******************/ -/*** Layer Elem ***/ -/******************/ +/*******************/ +/*** Layer Thing ***/ +/*******************/ #include "stdafx.h" @@ -14,44 +14,68 @@ #include "MapEditView.h" #include "MainFrm.h" -//#include "ElemSet.h" - #include "Core.h" #include "Layer.h" -#include "LayerElem.h" +#include "LayerThing.h" #include "Utils.h" -//#include "Select.h" #include "Export.h" /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ // New Layer -CLayerElem::CLayerElem(int _SubType,int _Width,int _Height) +CLayerThing::CLayerThing(int _SubType,int _Width,int _Height) { SetDefaultParams(); - Mode=MouseModePaint; -// ElemBank=new CElemBank; + Mode=MouseModeNormal; + Width=_Width; + Height=_Height; + ThingBank=new CElemBank(-1,-1,false,true); + CurrentThing=-1; + CurrentPoint=0; + + ThingBank->AddSet("\\spongebob\\graphics\\Babyoctopus.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\barnicleboy.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\Caterpillar.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\clam.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\Eyeball.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\FlyingDutchman.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\gary.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\GiantWorm.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\HermitCrab.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\IronDogFish.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\Krusty.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\MermaidMan.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\Neptune.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\Patrick.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\plankton.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\PuffaFish.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\Sandy.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\SeaSnake.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\SharkSub.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\SpiderCrab.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\spongebob.bmp"); + ThingBank->AddSet("\\spongebob\\graphics\\Squidward.bmp"); } /*****************************************************************************/ // Load Layer -CLayerElem::CLayerElem(CFile *File,int Version) +CLayerThing::CLayerThing(CFile *File,int Version) { Load(File,Version); } /*****************************************************************************/ -CLayerElem::~CLayerElem() +CLayerThing::~CLayerThing() { -// ElemBank->CleanUp(); -// delete ElemBank; + ThingBank->CleanUp(); + delete ThingBank; } /*****************************************************************************/ -void CLayerElem::Load(CFile *File,int Version) +void CLayerThing::Load(CFile *File,int Version) { File->Read(&VisibleFlag,sizeof(BOOL)); File->Read(&Mode,sizeof(MouseMode)); @@ -60,7 +84,7 @@ void CLayerElem::Load(CFile *File,int Version) } /*****************************************************************************/ -void CLayerElem::Save(CFile *File) +void CLayerThing::Save(CFile *File) { // Always Save current version File->Write(&VisibleFlag,sizeof(BOOL)); @@ -68,39 +92,36 @@ void CLayerElem::Save(CFile *File) } /*****************************************************************************/ -void CLayerElem::InitSubView(CCore *Core) +void CLayerThing::InitSubView(CCore *Core) { - ElemBank=&Core->GetIconz(); } /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ -void CLayerElem::Render(CCore *Core,Vector3 &CamPos,bool Is3d) +void CLayerThing::Render(CCore *Core,Vector3 &CamPos,bool Is3d) { Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor()); +int i,ListSize=ThingList.size(); - Is3d&=Render3dFlag; - for (int x=0; x<20; x++) +// Is3d&=Render3dFlag; + for (i=0; iGetZoomW(); float ZoomH=Core->GetZoomH(); float ScrOfsX=(ZoomW/2); float ScrOfsY=(ZoomH/2); Vector3 &Scale=Core->GetScaleVector(); +CElemBank *IconBank=Core->GetIconBank(); - if (ElemBank->NeedLoad()) ElemBank->LoadAllSets(Core); + if (ThingBank->NeedLoad()) ThingBank->LoadAllSets(Core); glMatrixMode(GL_MODELVIEW); glPushMatrix(); @@ -108,137 +129,150 @@ Vector3 &Scale=Core->GetScaleVector(); glLoadIdentity(); glScalef(Scale.x,Scale.y,Scale.z); - glTranslatef(-ThisCam.x,ThisCam.y,0); // Set scroll offset - glTranslatef(-ScrOfsX,ScrOfsY,0); // Bring to top left corner - glTranslatef(Pos.x,Pos.y,0); // Set Elem Pos - glColor4f(1,1,1,Alpha); // Set default Color - ElemBank->RenderElem(0,Elem+1,0,Render3d); + glTranslatef(-ThisCam.x,ThisCam.y,0); // Set scroll offset + glTranslatef(-ScrOfsX,ScrOfsY,0); // Bring to top left corner + +int ListSize=ThisThing.XY.size(); + TRACE1("%i pts\n",ListSize); + for (int i=0;iRenderElem(0,i,0,Render3d); + if (i==0) + { + glColor4f(1,1,1,1); // Set default Color + ThingBank->RenderElem(ThisThing.Type,0,0,Render3d); + } + glPopMatrix(); + } + glPopMatrix(); } /*****************************************************************************/ /*** Gui *********************************************************************/ /*****************************************************************************/ -void CLayerElem::GUIInit(CCore *Core) +void CLayerThing::GUIInit(CCore *Core) { // Core->GUIAdd(GUIToolBar,IDD_TOOLBAR); } /*****************************************************************************/ -void CLayerElem::GUIKill(CCore *Core) +void CLayerThing::GUIKill(CCore *Core) { // Core->GUIRemove(GUIToolBar,IDD_TOOLBAR); } /*****************************************************************************/ -void CLayerElem::GUIUpdate(CCore *Core) +void CLayerThing::GUIUpdate(CCore *Core) { } /*****************************************************************************/ -void CLayerElem::GUIChanged(CCore *Core) +void CLayerThing::GUIChanged(CCore *Core) { } /*****************************************************************************/ /*** Functions ***************************************************************/ /*****************************************************************************/ -bool CLayerElem::LButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag) +bool CLayerThing::LButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag) { bool Ret=false; -/* + switch(Mode) { - case MouseModePaint: + case MouseModeNormal: if (DownFlag) - Ret=Paint(ElemBank->GetLBrush(),CursorPos); + { + if (CurrentThing==-1) + AddThing(CursorPos); + else + AddThingPoint(CursorPos); + + } break; - case MouseModeSelect: - Ret=Selection.Handle(CursorPos,nFlags); - if (Selection.HasSelection()) - { - TRACE0("LMB Selection\n"); - } + case MouseModePoints: break; default: break; } -*/ - return(Ret); + + return(true); } /*****************************************************************************/ -bool CLayerElem::RButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag) +bool CLayerThing::RButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag) { bool Ret=FALSE; -/* + switch(Mode) { - case MouseModePaint: + case MouseModeNormal: if (DownFlag) - Ret=Paint(ElemBank->GetRBrush(),CursorPos); + { + SelectThing(CursorPos); + } break; - case MouseModeSelect: - Ret=Selection.Handle(CursorPos,nFlags); - if (Selection.HasSelection()) - { - TRACE0("RMB Selection\n"); - } - break; - default: + case MouseModePoints: break; } -*/ + return(Ret); } /*****************************************************************************/ -bool CLayerElem::MouseMove(CCore *Core,UINT nFlags, CPoint &CursorPos) +bool CLayerThing::MouseMove(CCore *Core,UINT nFlags, CPoint &CursorPos) { -bool Ret=FALSE; -/* - switch(Mode) +bool Ret=false; + + if (CurrentThing!=-1) { - case MouseModePaint: - if (nFlags & MK_LBUTTON) - Ret=Paint(ElemBank->GetLBrush(),CursorPos); + if (nFlags & MK_LBUTTON) // Drag + { + UpdatePos(CursorPos,CurrentThing,CurrentPoint,true); + Ret=true; + } else - if (nFlags & MK_RBUTTON) - Ret=Paint(ElemBank->GetRBrush(),CursorPos); - break; - case MouseModeSelect: - Ret=Selection.Handle(CursorPos,nFlags); - break; - default: - break; + if (nFlags & MK_RBUTTON) // Cancel + { + CurrentThing=-1; + Ret=true; + } } -*/ return(Ret); } /*****************************************************************************/ -bool CLayerElem::Command(int CmdMsg,CCore *Core,int Param0,int Param1) +bool CLayerThing::Command(int CmdMsg,CCore *Core,int Param0,int Param1) { bool Ret=false; - +/* switch(CmdMsg) { case CmdMsg_SetMode: - Mode=(MouseMode)Param0; - Core->GUIUpdate(); - break; - case CmdMsg_SubViewSet: - Ret=ElemBank->Command(CmdMsg,Core,Param0,Param1); +// Mode=(MouseMode)Param0; +// Core->GUIUpdate(); +// break; +// case CmdMsg_SubViewSet: +// Ret=ThingBank->Command(CmdMsg,Core,Param0,Param1); break; default: - TRACE3("LayerElem-Unhandled Command %i (%i,%i)\n",CmdMsg,Param0,Param1); + break; } - +*/ return(Ret); } /*****************************************************************************/ -void CLayerElem::RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d) +void CLayerThing::RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d) { Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor()); CPoint &CursPos=Core->GetCursorPos(); @@ -264,19 +298,135 @@ Vector3 Ofs; } /*****************************************************************************/ -bool CLayerElem::Paint(CMap &Blk,CPoint &CursorPos) +/*****************************************************************************/ +/*****************************************************************************/ +int CLayerThing::CheckThing(CPoint &Pos) { +CList List; +int Idx=-1,i,ListSize=ThingList.size(); +int StartIdx=0; - if (CursorPos.x==-1 || CursorPos.y==-1) return(false); // Off Map? - if (!Blk.IsValid()) return(false); // Invalid Elem? -/* - Map.Set(CursorPos.x,CursorPos.y,Blk); -*/ - return(true); +// Build List Of XY Matches + for (i=0; i List; +sLayerThing &ThisThing=ThingList[CurrentThing]; +int Idx=-1,i,ListSize=ThisThing.XY.size(); +int StartIdx=0; + +// Build List Of XY Matches + for (i=0; i XY; - int Type; - int SubType; - + std::vector XY; + int Type; + int SubType; + int Spare[8]; + +bool operator==(sLayerThing const &v1) +{ + if (XY[0]!=v1.XY[0]) return(false); + return(true); +} + }; /*****************************************************************************/ -class CLayerElem : public CElemBank +class CLayerThing : public CLayer { public: enum MouseMode { - MouseModePaint=0, - MouseModeSelect, + MouseModeNormal=0, + MouseModePoints, }; - CLayerElem(){}; - CLayerElem(int SubType,int Width,int Height); // New Layer - CLayerElem(CFile *File,int Version); // Load Layer - ~CLayerElem(); + CLayerThing(){}; + CLayerThing(int SubType,int Width,int Height); // New Layer + CLayerThing(CFile *File,int Version); // Load Layer + ~CLayerThing(); virtual int GetType() {return(LAYER_TYPE_ITEM);} virtual void InitSubView(CCore *Core); virtual void Render(CCore *Core,Vector3 &CamPos,bool Is3d); void RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d); +// void FindCursorPos(CCore *Core,Vector3 &CamPos,CPoint &MousePos); virtual void GUIInit(CCore *Core); virtual void GUIKill(CCore *Core); virtual void GUIUpdate(CCore *Core); virtual void GUIChanged(CCore *Core); + int GetWidth() {return(Width);} + int GetHeight() {return(Height);} + virtual void Load(CFile *File,int Version); virtual void Save(CFile *File); @@ -56,18 +67,25 @@ virtual bool RButtonControl(CCore *Core,UINT nFlags, CPoint &point,bool DownFl virtual bool MouseMove(CCore *Core,UINT nFlags, CPoint &point); virtual bool Command(int CmdMsg,CCore *Core,int Param0=0,int Param1=0); -// Local -// CElemBank *GetElemBank() {return(ElemBank);} - protected: - void RenderElem(CCore *Core,Vector3 &CamPos,CPoint &Pos,int Elem,bool Render3d,float Alpha=1.0f); + void RenderThing(CCore *Core,Vector3 &CamPos,sLayerThing &ThisThing,bool Render3d,bool Selected); + int CheckThing(CPoint &Pos); + void AddThing(CPoint &Pos); + void SelectThing(CPoint &Pos); + int CheckThingPoint(CPoint &Pos); + void AddThingPoint(CPoint &Pos); + void SelectThingPoint(CPoint &Pos); - bool Paint(CMap &Blk,CPoint &CursorPos); + void UpdatePos(CPoint &Pos,int Thing,int PosNo,bool Recurs=false); - CElemBank *ElemBank; - CList ElemList; + + int Width,Height; + CElemBank *ThingBank; + CList ThingList; + int CurrentThing,CurrentPoint; MouseMode Mode; + CGUIToolBar GUIToolBar; }; diff --git a/Utils/MapEdit/LayerTile.cpp b/Utils/MapEdit/LayerTile.cpp index 57e0b04a6..d9dd9243f 100644 --- a/Utils/MapEdit/LayerTile.cpp +++ b/Utils/MapEdit/LayerTile.cpp @@ -252,7 +252,7 @@ int DrawH=ZoomH+8; if (ThisElem.Tile>0) { // Render Non Zero and Valid Tiles glColor4f(1,1,1,Alpha); // Set default Color - TileBank->RenderTile(ThisElem.Set,ThisElem.Tile,ThisElem.Flags,Render3d); + TileBank->RenderElem(ThisElem.Set,ThisElem.Tile,ThisElem.Flags,Render3d); } glTranslatef(1.0f,0,0); // Next X } @@ -302,14 +302,14 @@ float Y1=Rect.bottom-1; void CLayerTile::GUIInit(CCore *Core) { TileBank->GUIInit(Core); - Core->GUIAdd(GUIToolBar,IDD_LAYERTILE_TOOLBAR); + Core->GUIAdd(GUIToolBar,IDD_TOOLBAR); } /*****************************************************************************/ void CLayerTile::GUIKill(CCore *Core) { TileBank->GUIKill(Core); - Core->GUIRemove(GUIToolBar,IDD_LAYERTILE_TOOLBAR); + Core->GUIRemove(GUIToolBar,IDD_TOOLBAR); } /*****************************************************************************/ @@ -443,6 +443,7 @@ bool Ret=false; break; default: TRACE3("LayerTile-Unhandled Command %i (%i,%i)\n",CmdMsg,Param0,Param1); + break; } return(Ret); } @@ -601,7 +602,7 @@ int Height=Map.GetHeight(); else { sExpTile OutTile; - CElem &ThisTile=TileBank->GetTile(MapElem.Set,MapElem.Tile); + CElem &ThisTile=TileBank->GetElem(MapElem.Set,MapElem.Tile); OutTile.Set=MapElem.Set; OutTile.Tile=MapElem.Tile; diff --git a/Utils/MapEdit/MainFrm.cpp b/Utils/MapEdit/MainFrm.cpp index cb358e2e6..08df66d90 100644 --- a/Utils/MapEdit/MainFrm.cpp +++ b/Utils/MapEdit/MainFrm.cpp @@ -57,7 +57,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) } // ParamBar - if (!ParamBar.Create(this,IDD_PARAMBAR,(CBRS_LEFT | CBRS_SIZE_DYNAMIC),IDD_PARAMBAR)) + if (!ParamBar.Create(this,IDD_MULTIBAR,(CBRS_LEFT | CBRS_SIZE_DYNAMIC),IDD_MULTIBAR)) { TRACE0("Failed to create ParamBar\n"); return -1; diff --git a/Utils/MapEdit/MapEdit.clw b/Utils/MapEdit/MapEdit.clw index 6a3f15fae..d38859f35 100644 --- a/Utils/MapEdit/MapEdit.clw +++ b/Utils/MapEdit/MapEdit.clw @@ -29,19 +29,19 @@ Class17=CMapEditDoc Class18=CMapEditView ResourceCount=14 -Resource1=IDD_LAYER_TOOLBAR +Resource1=IDD_LAYER_SHADE Resource2=IDR_MAPEDITYPE (English (U.S.)) -Resource3=IDD_LAYER_SHADE -Resource4=IDD_LAYER_COLLISION -Resource5=IDR_TOOLBAR (English (U.S.)) -Resource6=IDR_MAINFRAME (English (U.S.)) -Resource7=IDD_ABOUTBOX (English (U.S.)) -Resource8=IDD_MULTIBAR (English (U.S.)) -Resource9=IDD_LAYER_LIST -Resource10=IDD_RESIZE -Resource11=IDD_NEWMAP -Resource12=IDD_ADDLAYER -Resource13=IDD_TILEBANK +Resource3=IDD_TILEBANK +Resource4=IDD_TOOLBAR +Resource5=IDD_ADDLAYER +Resource6=IDD_LAYER_COLLISION +Resource7=IDR_TOOLBAR (English (U.S.)) +Resource8=IDR_MAINFRAME (English (U.S.)) +Resource9=IDD_ABOUTBOX (English (U.S.)) +Resource10=IDD_MULTIBAR (English (U.S.)) +Resource11=IDD_LAYER_LIST +Resource12=IDD_RESIZE +Resource13=IDD_NEWMAP Resource14=IDD_ELEMLIST [CLS:CChildFrame] @@ -222,13 +222,6 @@ Control1=IDD_TILEBANK_UPDATE,button,1342242816 Control2=IDD_TILEBANK_LOAD,button,1342242816 Control3=IDD_TILEBANK_DELETE,button,1342242816 -[DLG:IDD_LAYER_TOOLBAR] -Type=1 -Class=GUIToolBar -ControlCount=2 -Control1=IDD_LAYERTILE_BTN_PAINT,button,1342177344 -Control2=IDD_LAYERTILE_BTN_SELECT,button,1342177344 - [DLG:IDD_LAYERSHADE_GUI] Type=1 Class=CLayerShadeGUI @@ -363,3 +356,10 @@ Control14=IDC_LAYERSHADE_EDITB3,edit,1350770816 Control15=IDC_LAYERSHADE_COUNTEDIT,edit,1350576256 Control16=IDC_SPIN2,msctls_updown32,1342177302 +[DLG:IDD_TOOLBAR] +Type=1 +Class=GUIToolBar +ControlCount=2 +Control1=IDD_LAYERTILE_BTN_PAINT,button,1342177344 +Control2=IDD_LAYERTILE_BTN_SELECT,button,1342177344 + diff --git a/Utils/MapEdit/MapEdit.dsp b/Utils/MapEdit/MapEdit.dsp index 77ff30906..51d047a6b 100644 --- a/Utils/MapEdit/MapEdit.dsp +++ b/Utils/MapEdit/MapEdit.dsp @@ -80,6 +80,12 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept # ADD LINK32 opengl32.lib glu32.lib glib.lib ginlib.lib maths.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\libs\ginlib\debug\\" /libpath:"..\libs\glib\debug\\" /libpath:"..\libs\maths\debug\\" +# Begin Special Build Tool +ProjDir=. +TargetDir=.\Debug +SOURCE="$(InputPath)" +PostBuild_Cmds=if not exist $(TargetDir)\collision.bmp copy $(ProjDir)\res\collision.bmp $(TargetDir)\collision.bmp if not exist $(TargetDir)\iconz.bmp copy $(ProjDir)\res\iconz.bmp $(TargetDir)\iconz.bmp +# End Special Build Tool !ENDIF @@ -115,14 +121,6 @@ SOURCE=.\LayerDef.h # End Source File # Begin Source File -SOURCE=.\LayerItem.cpp -# End Source File -# Begin Source File - -SOURCE=.\LayerItem.h -# End Source File -# Begin Source File - SOURCE=.\LayerShade.cpp # End Source File # Begin Source File @@ -131,6 +129,14 @@ SOURCE=.\LayerShade.h # End Source File # Begin Source File +SOURCE=.\LayerThing.cpp +# End Source File +# Begin Source File + +SOURCE=.\LayerThing.h +# End Source File +# Begin Source File + SOURCE=.\LayerTile.cpp # End Source File # Begin Source File @@ -176,14 +182,6 @@ SOURCE=.\Elem.h # End Source File # Begin Source File -SOURCE=.\ElemStore.cpp -# End Source File -# Begin Source File - -SOURCE=.\ElemStore.h -# End Source File -# Begin Source File - SOURCE=.\Map.cpp # End Source File # Begin Source File @@ -351,9 +349,14 @@ SOURCE=.\StdAfx.h # Begin Group "GUI" # PROP Default_Filter "" -# Begin Group "New" +# Begin Source File -# PROP Default_Filter "" +SOURCE=.\GUIAddLayer.cpp +# End Source File +# Begin Source File + +SOURCE=.\GUIAddLayer.h +# End Source File # Begin Source File SOURCE=.\GUIElemList.cpp @@ -364,76 +367,67 @@ SOURCE=.\GUIElemList.h # End Source File # Begin Source File +SOURCE=.\GUILayerCollision.cpp +# End Source File +# Begin Source File + +SOURCE=.\GUILayerCollision.h +# End Source File +# Begin Source File + +SOURCE=.\GUILayerList.cpp +# End Source File +# Begin Source File + +SOURCE=.\GUILayerList.h +# End Source File +# Begin Source File + +SOURCE=.\GUILayerShade.cpp +# End Source File +# Begin Source File + +SOURCE=.\GUILayerShade.h +# End Source File +# Begin Source File + +SOURCE=.\GUIMultibar.cpp +# End Source File +# Begin Source File + +SOURCE=.\GUIMultibar.h +# End Source File +# Begin Source File + +SOURCE=.\GUINewMap.cpp +# End Source File +# Begin Source File + +SOURCE=.\GUINewMap.h +# End Source File +# Begin Source File + +SOURCE=.\GUIResize.cpp +# End Source File +# Begin Source File + +SOURCE=.\GUIResize.h +# End Source File +# Begin Source File + SOURCE=.\GUITileBank.cpp # End Source File # Begin Source File SOURCE=.\GUITileBank.h # End Source File -# End Group # Begin Source File -SOURCE=.\AddLayerDlg.cpp +SOURCE=.\GUIToolBar.cpp # End Source File # Begin Source File -SOURCE=.\AddLayerDlg.h -# End Source File -# Begin Source File - -SOURCE=.\LayerCollisionGUI.cpp -# End Source File -# Begin Source File - -SOURCE=.\LayerCollisionGUI.h -# End Source File -# Begin Source File - -SOURCE=.\LayerList.cpp -# End Source File -# Begin Source File - -SOURCE=.\LayerList.h -# End Source File -# Begin Source File - -SOURCE=.\LayerShadeGUI.cpp -# End Source File -# Begin Source File - -SOURCE=.\LayerShadeGUI.h -# End Source File -# Begin Source File - -SOURCE=.\LayerTileToolbar.cpp -# End Source File -# Begin Source File - -SOURCE=.\LayerTileToolbar.h -# End Source File -# Begin Source File - -SOURCE=.\MapSizeDlg.cpp -# End Source File -# Begin Source File - -SOURCE=.\MapSizeDlg.h -# End Source File -# Begin Source File - -SOURCE=.\MultiBar.cpp -# End Source File -# Begin Source File - -SOURCE=.\MultiBar.h -# End Source File -# Begin Source File - -SOURCE=.\NewMapGUI.cpp -# End Source File -# Begin Source File - -SOURCE=.\NewMapGUI.h +SOURCE=.\GUIToolBar.h # End Source File # End Group # End Target diff --git a/Utils/MapEdit/MapEdit.rc b/Utils/MapEdit/MapEdit.rc index 35fd2f980..90262fe06 100644 --- a/Utils/MapEdit/MapEdit.rc +++ b/Utils/MapEdit/MapEdit.rc @@ -520,7 +520,7 @@ BEGIN PUSHBUTTON "Delete",IDD_TILEBANK_DELETE,50,5,45,15 END -IDD_LAYER_TOOLBAR DIALOG DISCARDABLE 0, 0, 156, 16 +IDD_TOOLBAR DIALOG DISCARDABLE 0, 0, 156, 16 STYLE WS_CHILD FONT 8, "MS Sans Serif" BEGIN @@ -632,7 +632,7 @@ BEGIN BOTTOMMARGIN, 19 END - IDD_LAYER_TOOLBAR, DIALOG + IDD_TOOLBAR, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 149 diff --git a/Utils/MapEdit/MapEditDoc.cpp b/Utils/MapEdit/MapEditDoc.cpp index a6dfa1014..ad928b640 100644 --- a/Utils/MapEdit/MapEditDoc.cpp +++ b/Utils/MapEdit/MapEditDoc.cpp @@ -25,7 +25,7 @@ BEGIN_MESSAGE_MAP(CMapEditDoc, CDocument) ON_COMMAND(ID_ZOOM_IN, OnZoomIn) ON_COMMAND(ID_ZOOM_OUT, OnZoomOut) ON_COMMAND(ID_TOGGLE_SUBVIEW, OnToggleSubView) - ON_COMMAND(ID_TOOLBAR_GRID, OnToggleGrid) + ON_COMMAND(ID_TOGGLE_GRID, OnToggleGrid) ON_COMMAND(ID_MIRRORX, OnMirrorx) ON_COMMAND(ID_MIRRORY, OnMirrory) ON_COMMAND(ID_ACTIVEBRUSH_LEFT, OnActivebrushLeft) diff --git a/Utils/MapEdit/TexCache.cpp b/Utils/MapEdit/TexCache.cpp index 3bebb6326..03f5d7b75 100644 --- a/Utils/MapEdit/TexCache.cpp +++ b/Utils/MapEdit/TexCache.cpp @@ -15,18 +15,8 @@ /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ -/* -int CTexCache::GetTexIdx(const char *Filename,int Flags) -{ -sTex Tex; - Tex.Filename=Filename; - Tex.Flags=Flags; - return(TexList.Find(Tex)); -} -*/ -/*****************************************************************************/ // Checks loaded files for dups, assumes all passed RGB is unique -int CTexCache::ProcessTexture(const char *Filename,int Flags,sRGBData *RGBData) +int CTexCache::ProcessTexture(const char *Filename,sRGBData *RGBData) { int ListSize=TexList.size(); sTex NewTex; @@ -35,7 +25,6 @@ GFName FName=Filename; NewTex.Name=FName.File(); NewTex.Filename=Filename; - NewTex.Flags=Flags; if (!RGBData) // Need to load file { @@ -124,13 +113,13 @@ void CTexCache::LoadTex(sTex &ThisTex,sRGBData *TexData) u8 *Buffer; int TexWidth=TexData->Width; int TexHeight=TexData->Height; -int GLWidth=AlignSize(TexWidth); -int GLHeight=AlignSize(TexHeight); +int AlignWidth=AlignSize(TexWidth); +int AlignHeight=AlignSize(TexHeight); u8 *Src,*Dst; // create RGB & alpha texture & ensuse texture is correct size for GL - Buffer=(u8*)malloc(GLWidth*GLHeight*4); + Buffer=(u8*)malloc(AlignWidth*AlignHeight*4); Src=TexData->RGB; Dst=&Buffer[0]; @@ -153,18 +142,18 @@ u8 *Src,*Dst; *Dst++=B; *Dst++=A; } - Dst+=(GLWidth-TexWidth)*4; + Dst+=(AlignWidth-TexWidth)*4; } ThisTex.TexWidth=TexWidth; ThisTex.TexHeight=TexHeight; - ThisTex.dW=(1.0f)/(float)(GLWidth/16.0f); - ThisTex.dH=(1.0f)/(float)(GLHeight/16.0f); + ThisTex.ScaleU=(float)TexWidth/(float)AlignWidth; + ThisTex.ScaleV=(float)TexHeight/(float)AlignHeight; glGenTextures(1, &ThisTex.TexID); glBindTexture(GL_TEXTURE_2D, ThisTex.TexID); - glTexImage2D(GL_TEXTURE_2D, 0, 4, GLWidth, GLHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, &Buffer[0]); + glTexImage2D(GL_TEXTURE_2D, 0, 4, AlignWidth, AlignHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, &Buffer[0]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP); diff --git a/Utils/MapEdit/TexCache.h b/Utils/MapEdit/TexCache.h index da87c0ad9..46fc6faa5 100644 --- a/Utils/MapEdit/TexCache.h +++ b/Utils/MapEdit/TexCache.h @@ -25,12 +25,11 @@ struct sTex GString Filename; GString Name; GLuint TexID; - int Flags; int TexWidth,TexHeight; - float dW,dH; + float ScaleU,ScaleV; // For wrong size textures bool Loaded; - bool operator==(sTex const &v1) {return (Filename==v1.Filename && Flags==v1.Flags);} + bool operator==(sTex const &v1) {return (Filename==v1.Filename);} }; const RGBQUAD BlankRGB={255,0,255}; @@ -44,7 +43,7 @@ public: int GetTexIdx(sTex &Tex) {return(TexList.Find(Tex));} - int ProcessTexture(const char *Name,int Flags,sRGBData *RGBData=0); + int ProcessTexture(const char *Name,sRGBData *RGBData=0); void Purge(); bool LoadBMP(const char *Filename,sRGBData &RGBData); diff --git a/Utils/MapEdit/TileSet.cpp b/Utils/MapEdit/TileSet.cpp index b09a42850..644b208d9 100644 --- a/Utils/MapEdit/TileSet.cpp +++ b/Utils/MapEdit/TileSet.cpp @@ -33,16 +33,11 @@ const float TileBrowserY0=0-TileBrowserGap/2; const float TileBrowserY1=1+TileBrowserGap/2; /*****************************************************************************/ -CTileBank::CTileBank() +CTileBank::CTileBank() : CElemBank(16,16,true,false) { - LoadFlag=false; - CurrentSet=0; LastSet=0; for (int i=0; iGetFilePath(); - GString FilePath; - char FixPath[1024]; - - FilePath=RootPath.Drive(); - FilePath+=RootPath.Dir(); - FilePath.Append('\\'); - FilePath.Upper(); - - File->Read(&ListSize,sizeof(int)); + File->Read(&LayerCam,sizeof(Vector3)); File->Read(&CurrentSet,sizeof(int)); File->Read(&ActiveBrush,sizeof(int)); Brush[0].Load(File,Version); Brush[1].Load(File,Version); - if (Version<2) - { - CurrentSet++; - } - - // New Style rel storage - for (int i=0;iRead(&c,1); - FullName.Append(c); - } - FullName.Upper(); - GFName::makeabsolute(FilePath,FullName,FixPath); - FullName=FixPath; - _fullpath( FixPath, FullName, 1024); - for (int z=0; zRead(&LayerCam,sizeof(Vector3)); - File->Read(&CurrentSet,sizeof(int)); - File->Read(&ActiveBrush,sizeof(int)); - Brush[0].Load(File,Version); - Brush[1].Load(File,Version); - - CElemBank::Load(File,Version); + File->Read(&LayerCam,sizeof(Vector3)); + File->Read(&ActiveBrush,sizeof(int)); + Brush[0].Load(File,Version); + Brush[1].Load(File,Version); } - + CElemBank::Load(File,Version); } /*****************************************************************************/ void CTileBank::Save(CFile *File) { -int ListSize=GetSetCount(); -GFName RootPath=File->GetFilePath(); -GString SavePath; - - SavePath=RootPath.Drive(); - SavePath+=RootPath.Dir(); - SavePath.Append('\\'); - - SavePath.Upper(); - File->Write(&LayerCam,sizeof(Vector3)); - File->Write(&CurrentSet,sizeof(int)); File->Write(&ActiveBrush,sizeof(int)); Brush[0].Save(File); Brush[1].Save(File); @@ -138,19 +78,6 @@ GString SavePath; CElemBank::Save(File); } -/*****************************************************************************/ -void CTileBank::RenderTile(int Set,int Elem,int Flags,bool Is3d) -{ - if (IsValid(Set,Elem)) - { - SetList[Set].RenderElem(Elem,Flags,Is3d); - } - else - { - SetList[0].RenderInvalid(); - } - -} /*****************************************************************************/ void CTileBank::DeleteCurrent() { @@ -171,15 +98,6 @@ int ListSize=GetSetCount(); if (CurrentSet) CurrentSet--; } -/*****************************************************************************/ -CPoint CTileBank::GetTilePos(int ID,int Width) -{ - if (ID==0) - return(CPoint(-1,-1)); - else - return(IDToPoint(ID-1,Width)); -} - /*****************************************************************************/ void CTileBank::Render(CCore *Core,Vector3 &CamPos,bool Is3d) { @@ -200,7 +118,7 @@ float Scale=CamPos.z/(float)BrowserWidth/2.0; while(TileID!=ListSize) { - CPoint Pos=GetTilePos(TileID,BrowserWidth); + CPoint Pos=GetElemPos(TileID,BrowserWidth); float XPos=(float)Pos.x*(1+TileBrowserGap); float YPos=(float)Pos.y*(1+TileBrowserGap); @@ -263,14 +181,14 @@ float Scale=CamPos.z/(float)BrowserWidth/2.0; if (SelStart==-1) { - Start=GetTilePos(CursorPos,BrowserWidth); + Start=GetElemPos(CursorPos,BrowserWidth); End=Start; } else { CPoint S=IDToPoint(SelStart-1,BrowserWidth); - CPoint E=IDToPoint(SelEnd-1,BrowserWidth); + CPoint E=IDToPoint(CursorPos-1,BrowserWidth); Start=CPoint( min(S.x,E.x), min(S.y,E.y)); End=CPoint( max(S.x,E.x), max(S.y,E.y)); @@ -303,119 +221,6 @@ float Scale=CamPos.z/(float)BrowserWidth/2.0; } -/*****************************************************************************/ -void CTileBank::RenderGrid(CCore *Core,Vector3 &CamPos,bool Active) -{ - if (!GetSetCount()) return; -CElemSet &ThisSet=SetList[CurrentSet]; -int ListSize=ThisSet.GetCount(); -int BrowserWidth=ThisSet.GetBrowserWidth(); -int TileID=1; // Dont bother with blank, its sorted -float Scale=CamPos.z/(float)BrowserWidth/2.0; - - if (!ListSize) return; - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - - while(TileID!=ListSize) - { - CPoint Pos=GetTilePos(TileID,BrowserWidth); - float XPos=(float)Pos.x*(1+TileBrowserGap); - float YPos=(float)Pos.y*(1+TileBrowserGap); - - glLoadIdentity(); - glScalef(Scale,Scale,Scale); - glTranslatef(-CamPos.x+XPos,CamPos.y-YPos,0); - - glBegin(GL_LINES); - glColor3f(1,1,1); - - glVertex3f( TileBrowserX0,TileBrowserY0,0); - glVertex3f( TileBrowserX1,TileBrowserY0,0); - - glVertex3f( TileBrowserX0,TileBrowserY1,0); - glVertex3f( TileBrowserX1,TileBrowserY1,0); - - glVertex3f( TileBrowserX0,TileBrowserY0,0); - glVertex3f( TileBrowserX0,TileBrowserY1,0); - - glVertex3f( TileBrowserX1,TileBrowserY0,0); - glVertex3f( TileBrowserX1,TileBrowserY1,0); - - glEnd(); - - TileID++; - } - glPopMatrix(); -} - -/*****************************************************************************/ -void CTileBank::FindCursorPos(CCore *Core,Vector3 &CamPos,CPoint &MousePos) -{ - if (!GetSetCount()) return; -CElemSet &ThisSet=SetList[CurrentSet]; -int ListSize=ThisSet.GetCount(); -int BrowserWidth=ThisSet.GetBrowserWidth(); -GLint Viewport[4]; -GLuint SelectBuffer[SELECT_BUFFER_SIZE]; -int HitCount; -int TileID=0; -float Scale=CamPos.z/(float)BrowserWidth/2.0; - - if (!ListSize) return; - glGetIntegerv(GL_VIEWPORT, Viewport); - glSelectBuffer (SELECT_BUFFER_SIZE, SelectBuffer ); - glRenderMode (GL_SELECT); - - glInitNames(); - glPushName(-1); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - gluPickMatrix( MousePos.x ,(Viewport[3]-MousePos.y),5.0,5.0,Viewport); - Core->GetView()->SetupPersMatrix(); - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - - while(TileID!=ListSize) - { - CPoint Pos=GetTilePos(TileID,BrowserWidth); - float XPos=(float)Pos.x*(1+TileBrowserGap); - float YPos=(float)Pos.y*(1+TileBrowserGap); - - glLoadIdentity(); - glScalef(Scale,Scale,Scale); - glTranslatef(-CamPos.x+XPos,CamPos.y-YPos,0); - - glLoadName (TileID); - glBegin (GL_QUADS); - BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0); - glEnd(); - TileID++; - } - - HitCount= glRenderMode (GL_RENDER); - glPopMatrix(); - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - -// Process hits - -GLuint *HitPtr=SelectBuffer; - - TileID=-2; - if (HitCount) // Just take 1st - { - TileID=HitPtr[3]; - } - glMatrixMode(GL_MODELVIEW); // <-- Prevent arse GL assert - - CursorPos=TileID; - SelEnd=CursorPos; -} - /*****************************************************************************/ bool CTileBank::LButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag) { @@ -567,7 +372,7 @@ void CTileBank::SetBrush(CMap &ThisBrush) { int BW=SetList[CurrentSet].GetBrowserWidth(); CPoint S=IDToPoint(SelStart-1,BW); -CPoint E=IDToPoint(SelEnd-1,BW); +CPoint E=IDToPoint(CursorPos-1,BW); int Width=abs(E.x-S.x)+1; int Height=abs(E.y-S.y)+1; diff --git a/Utils/MapEdit/TileSet.h b/Utils/MapEdit/TileSet.h index fe5cebea6..0a9be909d 100644 --- a/Utils/MapEdit/TileSet.h +++ b/Utils/MapEdit/TileSet.h @@ -21,16 +21,10 @@ #include "GUIElemList.h" /*****************************************************************************/ -enum TileSetEnum -{ -DefTileBrowserWidth=8, -}; /*****************************************************************************/ class CCore; - -/*****************************************************************************/ -class CTileBank : public CLayer, public CElemBank +class CTileBank : public CElemBank { public: CTileBank(); @@ -46,10 +40,10 @@ public: int GetType() {return(0);} void Render(CCore *Core,Vector3 &CamPos,bool Is3d); - void RenderGrid(CCore *Core,Vector3 &CamPos,bool Active); +// void RenderGrid(CCore *Core,Vector3 &CamPos,bool Active); void RenderSelection(CCore *Core,Vector3 &ThisCam){}; void RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d); - void FindCursorPos(CCore *Core,Vector3 &CamPos,CPoint &MousePos); +// void FindCursorPos(CCore *Core,Vector3 &CamPos,CPoint &MousePos); void GUIInit(CCore *Core); void GUIKill(CCore *Core); @@ -66,12 +60,6 @@ public: bool MouseMove(CCore *Core,UINT nFlags, CPoint &CursorPos); bool Command(int CmdMsg,CCore *Core,int Param0=0,int Param1=0); -// ElemSet Thruput -const char *GetSetName(int Set) {return(SetList[Set].GetName());} -const char *GetSetFilename(int Set) {return(SetList[Set].GetFilename());} - CElem &GetTile(int Set,int Tile) {return(SetList[Set].GetElem(Tile));} - void RenderTile(int Set,int Elem,int Flags,bool Is3d); - // Local void DeleteCurrent(); @@ -81,7 +69,6 @@ const char *GetSetFilename(int Set) {return(SetList[Set].GetFilename()); CMap &GetActiveBrush() {return(GetBrush(ActiveBrush));} bool CanClose() {return(SelStart==-1);} - CPoint GetTilePos(int ID,int Width); // Functions bool SelectCancel(); @@ -89,20 +76,15 @@ const char *GetSetFilename(int Set) {return(SetList[Set].GetFilename()); protected: - bool Select(int BrushID,bool DownFlag); void SetBrush(CMap &ThisBrush); - int CurrentSet,LastSet; - CMap Brush[2]; - int ActiveBrush; - int SelStart,SelEnd; + CMap Brush[2]; + int ActiveBrush; + int SelStart; - bool LoadFlag; - int LastCursorPos,CursorPos; - - CGUIElemList GUIElemList; - CGUITileBank GUITileBank; + CGUIElemList GUIElemList; + CGUITileBank GUITileBank; }; /*****************************************************************************/ diff --git a/Utils/MapEdit/resource.h b/Utils/MapEdit/resource.h index 2d4290208..b62260860 100644 --- a/Utils/MapEdit/resource.h +++ b/Utils/MapEdit/resource.h @@ -14,7 +14,7 @@ #define IDD_NEWMAP 169 #define IDD_ADDLAYER 172 #define IDD_TILEBANK 173 -#define IDD_LAYER_TOOLBAR 174 +#define IDD_TOOLBAR 174 #define IDD_LAYER_SHADE 175 #define IDD_LAYER_COLLISION 177 #define IDD_ELEMLIST 178