diff --git a/Utils/MapEdit/Core.cpp b/Utils/MapEdit/Core.cpp index fd3d56546..29c88df08 100644 --- a/Utils/MapEdit/Core.cpp +++ b/Utils/MapEdit/Core.cpp @@ -44,7 +44,7 @@ CCore::CCore() GridFlag=true; Is3dFlag=true; CurrentView=NULL; - CursorPos.x=CursorPos.y=0; + CursorPos.x=CursorPos.y=-1; CurrentLayer=0; GString Filename; @@ -53,6 +53,7 @@ GString Filename; GetExecPath(Filename); Filename+=theApp.GetConfigStr("FileLocation","Iconz"); IconBank->AddSet(Filename); + RenderTGAFlag=false; } /*****************************************************************************/ @@ -104,6 +105,7 @@ void CCore::Load(CFile *File) int Version,i; BOOL F; Vector3 DuffVector; + File->Read(&Version,sizeof(int)); if (Version>100000) Version=1; // Check fix for changing version to int from float #ifndef _DEBUG @@ -155,8 +157,8 @@ int MapHeight=ActionLayer->GetHeight(); { Layer[i]->CheckLayerSize(MapWidth,MapHeight); } - } + /*****************************************************************************/ void CCore::Validate(int Type) { @@ -219,11 +221,10 @@ Vector3 &ThisCam=GetCam(); return; } if (IconBank->NeedLoad()) IconBank->LoadAllSets(this); - + if (RenderTGAFlag) RenderToTga(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen RenderLayers(IsSubView() || CurrentLayer->IsUnique()); - } /*****************************************************************************/ @@ -835,3 +836,18 @@ CExport Exp(ExportName); } +/*****************************************************************************/ +void CCore::RenderToTga(char *Filename) +{ + TGAFilename=Filename; + RenderTGAFlag=true; + RedrawView(); +} + +/*****************************************************************************/ +void CCore::RenderToTga() +{ + RenderTGAFlag=false; + ActionLayer->Render4TGA(TGAFilename); +} + diff --git a/Utils/MapEdit/Core.h b/Utils/MapEdit/Core.h index ade45bbd3..13ae06275 100644 --- a/Utils/MapEdit/Core.h +++ b/Utils/MapEdit/Core.h @@ -45,6 +45,8 @@ public: void RenderLayers(bool OneShot=false); void RenderNumber(int No); void Export(char *Filename); + void RenderToTga(char *Filename); + void RenderToTga(); // View Stuff void SetView(CMapEditView *View) {CurrentView=View;} @@ -139,6 +141,8 @@ private: bool Is3dFlag; CElemBank *IconBank; + bool RenderTGAFlag; + GString TGAFilename; }; diff --git a/Utils/MapEdit/Layer.h b/Utils/MapEdit/Layer.h index 063d599ef..424896fc4 100644 --- a/Utils/MapEdit/Layer.h +++ b/Utils/MapEdit/Layer.h @@ -72,6 +72,7 @@ virtual int GetSubType() {return(LayerDef.SubType);} virtual void Render(CCore *Core,Vector3 &CamPos,bool Is3d){}; +virtual void Render4TGA(const char *Filename){} virtual void RenderGrid(CCore *Core,Vector3 &CamPos,bool Active); virtual void RenderSelection(CCore *Core,Vector3 &ThisCam){}; virtual void RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d){}; diff --git a/Utils/MapEdit/LayerThing.cpp b/Utils/MapEdit/LayerThing.cpp index 1d7f16de9..5be8711aa 100644 --- a/Utils/MapEdit/LayerThing.cpp +++ b/Utils/MapEdit/LayerThing.cpp @@ -69,6 +69,11 @@ int i,ListSize; File->Read(&ThisThing.Data,sizeof(sLayerThingData)); } LoadThingNames(File,Version); + +// CurrentDefThing=-1; +// CurrentThing=-1; +// CurrentThingPoint=-1; + } /*****************************************************************************/ @@ -79,7 +84,8 @@ int i,ListSize; ThisThing.XY.resize(ListSize); for (i=0 ;iRead(&ThisThing.XY[i],sizeof(CPoint)); + CPoint &ThisPoint=ThisThing.XY[i]; + File->Read(&ThisPoint,sizeof(CPoint)); } } @@ -131,8 +137,9 @@ void CLayerThing::SaveThing(CFile *File,sLayerThing &ThisThing) int i,ListSize=ThisThing.XY.size(); File->Write(&ListSize,sizeof(int)); for (i=0 ;iWrite(&ThisThing.XY[i],sizeof(CPoint)); + { + CPoint &ThisPoint=ThisThing.XY[i]; + File->Write(&ThisPoint,sizeof(CPoint)); } } @@ -327,12 +334,14 @@ int i,ListSize; ListSize=ThisThing.XY.size(); for (i=0; iGetElem(Elem.Set,Elem.Tile); +int TileW=Tile.GetElemWidth(); +int TileH=Tile.GetElemHeight(); + + if (TileW>16 || TileH>16 || TileW<0 || TileH<0) + { + TRACE2("%i %i\n",TileW,TileH); + return; + } + ProcessRGB(Tile.GetElemRGB(),TileW,TileH,LilBlock,TGA_TILE_SIZE,TGA_TILE_SIZE); + if (Elem.Flags & PC_TILE_FLAG_MIRROR_X) FlipX(LilBlock,LilBlock,TGA_TILE_SIZE,TGA_TILE_SIZE); + if (Elem.Flags & PC_TILE_FLAG_MIRROR_Y) FlipY(LilBlock,LilBlock,TGA_TILE_SIZE,TGA_TILE_SIZE); + +u8 *RGB=LilBlock; + for (int Y=0; Y