This commit is contained in:
parent
d238e6ac10
commit
ff8ae0c77b
10 changed files with 177 additions and 125 deletions
|
@ -817,7 +817,7 @@ CExport Exp(ExportName,LayerCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
Exp.ExportTiles(this);
|
Exp.ExportTiles(this);
|
||||||
Exp.ExportTexList(this);
|
Exp.ExportStrList(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,8 @@ sExpLayerHdr LayerHdr;
|
||||||
int Width=Map.GetWidth();
|
int Width=Map.GetWidth();
|
||||||
int Height=Map.GetHeight();
|
int Height=Map.GetHeight();
|
||||||
int ThisFilePos=ftell(File);
|
int ThisFilePos=ftell(File);
|
||||||
sExpMapElem BlankElem={0,0,0};
|
CTileBank &TileBank=Core->GetTileBank();
|
||||||
|
sExpTile BlankElem={0,0,0,0};
|
||||||
|
|
||||||
TRACE1("LayerTile Ofs %i\n",ThisFilePos);
|
TRACE1("LayerTile Ofs %i\n",ThisFilePos);
|
||||||
LayerOfs.push_back(ThisFilePos);
|
LayerOfs.push_back(ThisFilePos);
|
||||||
|
@ -78,14 +79,17 @@ sExpMapElem BlankElem={0,0,0};
|
||||||
for (int X=0; X<Width; X++)
|
for (int X=0; X<Width; X++)
|
||||||
{
|
{
|
||||||
sMapElem &MapElem=Map.Get(X,Y);
|
sMapElem &MapElem=Map.Get(X,Y);
|
||||||
sExpMapElem TileElem;
|
CTile &ThisTile=Core->GetTile(MapElem.Set,MapElem.Tile);
|
||||||
sExpLayerTile OutElem;
|
sExpLayerTile OutElem;
|
||||||
|
sExpTile OutTile;
|
||||||
|
|
||||||
TileElem.Tile=MapElem.Tile;
|
OutTile.Set=MapElem.Set;
|
||||||
TileElem.Set=MapElem.Set;
|
OutTile.Tile=MapElem.Tile;
|
||||||
TileElem.Flags=MapElem.Flags;
|
OutTile.TriCount=0;
|
||||||
|
OutTile.XOfs=ThisTile.GetTexXOfs();
|
||||||
|
OutTile.YOfs=ThisTile.GetTexYOfs();
|
||||||
|
|
||||||
OutElem.Tile=UsedTileList.Add(TileElem);
|
OutElem.Tile=UsedTileList.Add(OutTile);
|
||||||
OutElem.Flags=MapElem.Flags;
|
OutElem.Flags=MapElem.Flags;
|
||||||
fwrite(&OutElem,sizeof(sExpLayerTile),1,File);
|
fwrite(&OutElem,sizeof(sExpLayerTile),1,File);
|
||||||
}
|
}
|
||||||
|
@ -135,6 +139,9 @@ void CExport::ExportTiles(CCore *Core)
|
||||||
{
|
{
|
||||||
int ListSize,i;
|
int ListSize,i;
|
||||||
|
|
||||||
|
FileHdr.TileW=Core->GetTile(1,0).GetPCTexW();
|
||||||
|
FileHdr.TileH=Core->GetTile(1,0).GetPCTexH();
|
||||||
|
|
||||||
// Write Tiles
|
// Write Tiles
|
||||||
ListSize=UsedTileList.size();
|
ListSize=UsedTileList.size();
|
||||||
FileHdr.TileCount=ListSize;
|
FileHdr.TileCount=ListSize;
|
||||||
|
@ -142,14 +149,7 @@ int ListSize,i;
|
||||||
|
|
||||||
for (i=0; i<ListSize; i++)
|
for (i=0; i<ListSize; i++)
|
||||||
{
|
{
|
||||||
sExpMapElem &ThisElem=UsedTileList[i];
|
ExportTile(Core,UsedTileList[i]);
|
||||||
CTile &ThisTile=Core->GetTile(ThisElem.Set,ThisElem.Tile);
|
|
||||||
sExpTile OutTile;
|
|
||||||
|
|
||||||
OutTile.Flags=ThisElem.Flags;
|
|
||||||
|
|
||||||
TRACE3("%i %i %i\n",ThisElem.Set,ThisElem.Tile,ThisElem.Flags);
|
|
||||||
ExportTile(Core,ThisTile,OutTile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write Tris
|
// Write Tris
|
||||||
|
@ -158,20 +158,19 @@ int ListSize,i;
|
||||||
FileHdr.TriOfs=ftell(File);
|
FileHdr.TriOfs=ftell(File);
|
||||||
for (i=0; i<ListSize; i++)
|
for (i=0; i<ListSize; i++)
|
||||||
{
|
{
|
||||||
fwrite(&TriList[i],sizeof(sTriFace),1,File);
|
fwrite(&TriList[i],sizeof(sExpTri),1,File);
|
||||||
}
|
}
|
||||||
TRACE1("TriCount=%i\n",ListSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CExport::ExportTile(CCore *Core,CTile &ThisTile,sExpTile &OutTile)
|
void CExport::ExportTile(CCore *Core,sExpTile &OutTile)
|
||||||
{
|
{
|
||||||
|
CTile &ThisTile=Core->GetTile(OutTile.Set,OutTile.Tile);
|
||||||
|
CTileBank &TileBank=Core->GetTileBank();
|
||||||
int RGBW=ThisTile.GetPCTexW();
|
int RGBW=ThisTile.GetPCTexW();
|
||||||
int RGBH=ThisTile.GetPCTexH();
|
int RGBH=ThisTile.GetPCTexH();
|
||||||
u8 *RGB=ThisTile.GetPCTexRGB();
|
u8 *RGB=ThisTile.GetPCTexRGB();
|
||||||
|
GString SetName=TileBank.GetSet(OutTile.Set).GetFilename();
|
||||||
OutTile.W=RGBW;
|
|
||||||
OutTile.H=RGBH;
|
|
||||||
|
|
||||||
if (ThisTile.IsTile3d())
|
if (ThisTile.IsTile3d())
|
||||||
{
|
{
|
||||||
|
@ -179,40 +178,23 @@ u8 *RGB=ThisTile.GetPCTexRGB();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ExportTile2d(Core,ThisTile,OutTile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// change set name to set mappping
|
||||||
|
if (OutTile.Set==0)
|
||||||
|
{
|
||||||
|
SetName="BLANK";
|
||||||
|
}
|
||||||
|
|
||||||
|
OutTile.Set=SetNames.Add(SetName);
|
||||||
fwrite(&OutTile,sizeof(sExpTile),1,File);
|
fwrite(&OutTile,sizeof(sExpTile),1,File);
|
||||||
|
// Write RGB
|
||||||
|
ASSERT(RGBW==FileHdr.TileW);
|
||||||
|
ASSERT(RGBH==FileHdr.TileH);
|
||||||
fwrite(RGB,RGBW*RGBH*3,1,File);
|
fwrite(RGB,RGBW*RGBH*3,1,File);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CExport::ExportTile2d(CCore *Core,CTile &ThisTile,sExpTile &OutTile)
|
|
||||||
{
|
|
||||||
CTexCache &TexCache=Core->GetTexCache();
|
|
||||||
|
|
||||||
OutTile.TriStart=-1;
|
|
||||||
OutTile.TriCount=0;
|
|
||||||
OutTile.XOfs=ThisTile.GetTexXOfs();
|
|
||||||
OutTile.YOfs=ThisTile.GetTexYOfs();
|
|
||||||
|
|
||||||
// Texture
|
|
||||||
int TexID=ThisTile.GetTexID();
|
|
||||||
if (TexID==-1) // Blank Tile
|
|
||||||
{
|
|
||||||
OutTile.TexId=-1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sExpTex OutTex;
|
|
||||||
sTex &ThisTex=TexCache.GetTex(TexID);
|
|
||||||
OutTex.Filename=ThisTex.Filename;
|
|
||||||
OutTile.TexId=TexList.Add(OutTex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CExport::ExportTile3d(CCore *Core,CTile &ThisTile,sExpTile &OutTile)
|
void CExport::ExportTile3d(CCore *Core,CTile &ThisTile,sExpTile &OutTile)
|
||||||
{
|
{
|
||||||
|
@ -223,51 +205,84 @@ int TriCount=TileTriList.size();
|
||||||
|
|
||||||
OutTile.TriStart=TriList.size();
|
OutTile.TriStart=TriList.size();
|
||||||
OutTile.TriCount=TriCount;
|
OutTile.TriCount=TriCount;
|
||||||
OutTile.XOfs=-1;
|
|
||||||
OutTile.YOfs=-1;
|
for (int T=0; T<TriCount; T++)
|
||||||
OutTile.TexId=-1;
|
{
|
||||||
|
sTriFace &InTri=TileTriList[T];
|
||||||
|
sExpTri OutTri;
|
||||||
|
GString TexName=TexCache.GetTexName(InTri.Mat);
|
||||||
|
OutTri.TexID=TexNames.Add(TexName);
|
||||||
|
|
||||||
|
for (int p=0; p<3; p++)
|
||||||
|
{
|
||||||
|
OutTri.vtx[p]=InTri.vtx[p];
|
||||||
|
OutTri.uv[p][0]=InTri.uvs[p].u;
|
||||||
|
OutTri.uv[p][1]=InTri.uvs[p].v;
|
||||||
|
}
|
||||||
|
TriList.push_back(OutTri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void CExport::ExportTile3d(CCore *Core,CTile &ThisTile,sExpTile &OutTile)
|
||||||
|
{
|
||||||
|
CTexCache &TexCache=Core->GetTexCache();
|
||||||
|
std::vector<sTriFace> &TileTriList=ThisTile.GetTriList();
|
||||||
|
|
||||||
|
int TriCount=TileTriList.size();
|
||||||
|
|
||||||
|
// OutTile.TriStart=TriList.size();
|
||||||
|
// OutTile.TriCount=TriCount;
|
||||||
|
// OutTile.XOfs=-1;
|
||||||
|
// OutTile.YOfs=-1;
|
||||||
|
// OutTile.TexId=-1;
|
||||||
|
|
||||||
for (int T=0; T<TriCount; T++)
|
for (int T=0; T<TriCount; T++)
|
||||||
{
|
{
|
||||||
sTriFace &TileTri=TileTriList[T];
|
sTriFace &TileTri=TileTriList[T];
|
||||||
sTriFace OutTri;
|
sTriFace OutTri;
|
||||||
sExpTex OutTex;
|
// sExpTex OutTex;
|
||||||
|
|
||||||
for (int p=0; p<3; p++)
|
for (int p=0; p<3; p++)
|
||||||
{
|
{
|
||||||
OutTri=TileTri;
|
OutTri=TileTri;
|
||||||
// Texture
|
// Texture
|
||||||
sTex &TriTex=TexCache.GetTex(TileTri.Mat);
|
// sTex &TriTex=TexCache.GetTex(TileTri.Mat);
|
||||||
OutTex.Filename=TriTex.Filename;
|
// OutTex.Filename=TriTex.Filename;
|
||||||
OutTri.Mat=TexList.Add(OutTex);
|
// OutTri.Mat=TexList.Add(OutTex);
|
||||||
}
|
}
|
||||||
TriList.push_back(OutTri);
|
TriList.push_back(OutTri);
|
||||||
}
|
}
|
||||||
// return(TriCount);
|
// return(TriCount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*** Textures ****************************************************************/
|
void CExport::ExportStrList(CCore *Core)
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
void CExport::ExportTexList(CCore *Core)
|
|
||||||
{
|
{
|
||||||
int TexCount=TexList.size();
|
int ListSize,i;
|
||||||
|
|
||||||
FileHdr.TexCount=TexCount;
|
// Set List
|
||||||
FileHdr.TexOfs=ftell(File);
|
ListSize=SetNames.size();
|
||||||
|
FileHdr.SetNameCount=ListSize;
|
||||||
|
FileHdr.SetNameOfs=ftell(File);
|
||||||
|
|
||||||
for (int i=0; i<TexCount; i++)
|
for (i=0; i<ListSize; i++)
|
||||||
{
|
{
|
||||||
sExpTex &ThisTex=TexList[i];
|
const char *Str=SetNames[i];
|
||||||
char TexFilename[256];
|
fwrite(Str,strlen(Str)+1,1,File);
|
||||||
|
|
||||||
MakePathRel2App(ThisTex.Filename,TexFilename);
|
|
||||||
|
|
||||||
int Len=strlen(TexFilename);
|
|
||||||
fwrite(TexFilename,Len+1,1,File);
|
|
||||||
TRACE2("%i:\t%s\n",i,TexFilename);
|
|
||||||
}
|
}
|
||||||
|
// Tex List
|
||||||
|
ListSize=TexNames.size();
|
||||||
|
FileHdr.TexNameCount=ListSize;
|
||||||
|
FileHdr.TexNameOfs=ftell(File);
|
||||||
|
|
||||||
|
for (i=0; i<ListSize; i++)
|
||||||
|
{
|
||||||
|
const char *Str=TexNames[i];
|
||||||
|
fwrite(Str,strlen(Str)+1,1,File);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "mapedit.h"
|
#include "mapedit.h"
|
||||||
#include <Vector>
|
#include <Vector>
|
||||||
//#include "GinTex.h"
|
|
||||||
//#include "Tile.h"
|
|
||||||
|
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include "ExportHdr.h"
|
#include "ExportHdr.h"
|
||||||
|
@ -31,10 +29,10 @@ public:
|
||||||
void ExportLayerCollision(CCore *Core,char *LayerName,int SubType,CMap &Map);
|
void ExportLayerCollision(CCore *Core,char *LayerName,int SubType,CMap &Map);
|
||||||
|
|
||||||
void ExportTiles(CCore *Core);
|
void ExportTiles(CCore *Core);
|
||||||
void ExportTexList(CCore *Core);
|
void ExportStrList(CCore *Core);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ExportTile(CCore *Core,CTile &ThisTile,sExpTile &OutTile);
|
void ExportTile(CCore *Core,sExpTile &ThisElem);
|
||||||
void ExportTile3d(CCore *Core,CTile &ThisTile,sExpTile &OutTile);
|
void ExportTile3d(CCore *Core,CTile &ThisTile,sExpTile &OutTile);
|
||||||
void ExportTile2d(CCore *Core,CTile &ThisTile,sExpTile &OutTile);
|
void ExportTile2d(CCore *Core,CTile &ThisTile,sExpTile &OutTile);
|
||||||
|
|
||||||
|
@ -43,14 +41,13 @@ protected:
|
||||||
int LayerCount;
|
int LayerCount;
|
||||||
CList<int> LayerOfs;
|
CList<int> LayerOfs;
|
||||||
|
|
||||||
CList<sTriFace> TriList;
|
CList<sExpTri> TriList;
|
||||||
CList<sExpTex> TexList;
|
|
||||||
|
|
||||||
CList<sExpMapElem> UsedTileList;
|
CList<GString> SetNames;
|
||||||
|
CList<GString> TexNames;
|
||||||
|
|
||||||
// GString Filename;
|
CList<sExpTile> UsedTileList;
|
||||||
FILE *File;
|
FILE *File;
|
||||||
// int Count;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,26 +15,42 @@
|
||||||
struct sExpFileHdr
|
struct sExpFileHdr
|
||||||
{
|
{
|
||||||
int TileCount;
|
int TileCount;
|
||||||
// int TileW,TileH;
|
|
||||||
int TileOfs;
|
int TileOfs;
|
||||||
|
int TileW,TileH;
|
||||||
int TriCount;
|
int TriCount;
|
||||||
int TriOfs;
|
int TriOfs;
|
||||||
int TexCount;
|
int SetNameCount;
|
||||||
int TexOfs;
|
int SetNameOfs;
|
||||||
|
int TexNameCount;
|
||||||
|
int TexNameOfs;
|
||||||
int LayerCount;
|
int LayerCount;
|
||||||
// int LayerOfs[n]
|
// int LayerOfs[n]
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
struct sExpTile // 2d 3d
|
struct sExpTile
|
||||||
{
|
{
|
||||||
int TriStart; // -1 n
|
int Set;
|
||||||
int TriCount; // -1 n
|
int Tile;
|
||||||
int XOfs,YOfs; // n -1
|
int TriStart;
|
||||||
int TexId; // n -1
|
int TriCount;
|
||||||
int Flags;
|
u16 XOfs,YOfs;
|
||||||
int W,H;
|
u8 *RGB;
|
||||||
u8 *RGB; // Used in MkLevel
|
// int TexId; // n -1
|
||||||
|
// int Flags; // Flip Flags
|
||||||
|
|
||||||
|
bool operator==(sExpTile const &v1)
|
||||||
|
{
|
||||||
|
return(Set==v1.Set && Tile==v1.Tile);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
struct sExpTri
|
||||||
|
{
|
||||||
|
int TexID;
|
||||||
|
Vector3 vtx[3];
|
||||||
|
float uv[3][2];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -51,33 +67,34 @@ struct sExpLayerHdr
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
struct sExpLayerTile
|
struct sExpLayerTile
|
||||||
{
|
{
|
||||||
int Tile;
|
u16 Tile;
|
||||||
int Flags;
|
u16 Flags;
|
||||||
BOOL operator==(sExpLayerTile const &v1) {return (Tile==v1.Tile);}
|
// bool operator==(sExpLayerTile const &v1) {return (Tile==v1.Tile);}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
/*
|
||||||
struct sExpTex
|
struct sExpTex
|
||||||
{
|
{
|
||||||
char *Filename;
|
char *Filename;
|
||||||
|
|
||||||
BOOL operator==(sExpTex const &v1) {return (!strcmp(Filename,v1.Filename));}
|
BOOL operator==(sExpTex const &v1) {return (!strcmp(Filename,v1.Filename));}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
/*
|
||||||
struct sExpMapElem
|
struct sExpMapElem
|
||||||
{
|
{
|
||||||
int Set;
|
u16 Set;
|
||||||
int Tile;
|
u16 Tile;
|
||||||
int Flags;
|
u16 Flags;
|
||||||
|
|
||||||
BOOL operator==(sExpMapElem const &v1) // Does Check flags
|
BOOL operator==(sExpMapElem const &v1)
|
||||||
{
|
{
|
||||||
return(Set==v1.Set && Tile==v1.Tile);
|
return(Set==v1.Set && Tile==v1.Tile);
|
||||||
// return(Set==v1.Set && Tile==v1.Tile && Flags==v1.Flags);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -158,8 +158,6 @@ Vector3 Ofs;
|
||||||
Ofs.y=-(CursPos.y-(int)ThisCam.y);
|
Ofs.y=-(CursPos.y-(int)ThisCam.y);
|
||||||
ThisCam.x-=(int)ThisCam.x;
|
ThisCam.x-=(int)ThisCam.x;
|
||||||
ThisCam.y-=(int)ThisCam.y;
|
ThisCam.y-=(int)ThisCam.y;
|
||||||
TRACE2("-> %f %f\n",Ofs.x,Ofs.y);
|
|
||||||
|
|
||||||
|
|
||||||
if (Is3d && Render3dFlag)
|
if (Is3d && Render3dFlag)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,26 +14,28 @@
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int CTexCache::GetTexIdx(char *Filename,int Flags)
|
/*
|
||||||
|
int CTexCache::GetTexIdx(const char *Filename,int Flags)
|
||||||
{
|
{
|
||||||
sTex Tex;
|
sTex Tex;
|
||||||
strcpy(Tex.Filename,Filename);
|
Tex.Filename=Filename;
|
||||||
Tex.Flags=Flags;
|
Tex.Flags=Flags;
|
||||||
return(TexList.Find(Tex));
|
return(TexList.Find(Tex));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Checks loaded files for dups, assumes all passed RGB is unique
|
// 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 *Path,const char *Name,int Flags,sRGBData *RGBData)
|
||||||
{
|
{
|
||||||
int ListSize=TexList.size();
|
int ListSize=TexList.size();
|
||||||
|
|
||||||
sTex NewTex;
|
sTex NewTex;
|
||||||
sRGBData ThisRGB;
|
sRGBData ThisRGB;
|
||||||
|
|
||||||
strcpy(NewTex.Filename,Filename);
|
// strcpy(NewTex.Filename,Filename);
|
||||||
NewTex.Flags=Flags;
|
NewTex.Path=Path;
|
||||||
|
NewTex.Name=Name;
|
||||||
|
NewTex.FullFilename=NewTex.Path+NewTex.Name;
|
||||||
NewTex.Flags=Flags;
|
NewTex.Flags=Flags;
|
||||||
|
|
||||||
if (!RGBData) // Need to load file
|
if (!RGBData) // Need to load file
|
||||||
|
@ -43,7 +45,7 @@ sRGBData ThisRGB;
|
||||||
|
|
||||||
// TRACE1("Loading Texture %s\n",NewTex.Filename);
|
// TRACE1("Loading Texture %s\n",NewTex.Filename);
|
||||||
|
|
||||||
if (!LoadBMP(NewTex.Filename,ThisRGB))
|
if (!LoadBMP(NewTex.FullFilename,ThisRGB))
|
||||||
{
|
{
|
||||||
exit(-1);
|
exit(-1);
|
||||||
return(ListSize);
|
return(ListSize);
|
||||||
|
@ -81,7 +83,7 @@ int CTexCache::AlignSize(int Size)
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
bool CTexCache::LoadBMP(char *Filename,sRGBData &RGBData)
|
bool CTexCache::LoadBMP(const char *Filename,sRGBData &RGBData)
|
||||||
{
|
{
|
||||||
Frame ThisFrame;
|
Frame ThisFrame;
|
||||||
FILE *File;
|
FILE *File;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <Vector>
|
#include <Vector>
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "List.h"
|
#include "List.h"
|
||||||
|
#include <misc.hpp>
|
||||||
|
|
||||||
struct sRGBData
|
struct sRGBData
|
||||||
{
|
{
|
||||||
|
@ -21,14 +22,18 @@ struct sRGBData
|
||||||
|
|
||||||
struct sTex
|
struct sTex
|
||||||
{
|
{
|
||||||
char Filename[_MAX_PATH];
|
// char Filename[_MAX_PATH];
|
||||||
|
GString FullFilename;
|
||||||
|
GString Path;
|
||||||
|
GString Name;
|
||||||
GLuint TexID;
|
GLuint TexID;
|
||||||
int Flags;
|
int Flags;
|
||||||
int TexWidth,TexHeight;
|
int TexWidth,TexHeight;
|
||||||
float dW,dH;
|
float dW,dH;
|
||||||
bool Loaded;
|
bool Loaded;
|
||||||
|
|
||||||
bool operator==(sTex const &v1) {return (!strcmp(Filename,v1.Filename) && Flags==v1.Flags);}
|
// bool operator==(sTex const &v1) {return (!strcmp(Filename,v1.Filename) && Flags==v1.Flags);}
|
||||||
|
bool operator==(sTex const &v1) {return (FullFilename==v1.FullFilename && Flags==v1.Flags);}
|
||||||
};
|
};
|
||||||
|
|
||||||
const RGBQUAD BlankRGB={255,0,255};
|
const RGBQUAD BlankRGB={255,0,255};
|
||||||
|
@ -41,12 +46,12 @@ class CTexCache
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int GetTexIdx(sTex &Tex) {return(TexList.Find(Tex));}
|
int GetTexIdx(sTex &Tex) {return(TexList.Find(Tex));}
|
||||||
int GetTexIdx(char *Filename,int Flags);
|
// int GetTexIdx(const char *Filename,int Flags);
|
||||||
|
|
||||||
int ProcessTexture(const char *Filename,int Flags,sRGBData *RGBData=0);
|
int ProcessTexture(const char *Path,const char *Name,int Flags,sRGBData *RGBData=0);
|
||||||
void Purge();
|
void Purge();
|
||||||
|
|
||||||
bool LoadBMP(char *Filename,sRGBData &RGBData);
|
bool LoadBMP(const char *Filename,sRGBData &RGBData);
|
||||||
void FreeBMP(sRGBData &RGBData);
|
void FreeBMP(sRGBData &RGBData);
|
||||||
void FixBMP(sRGBData &RGBData);
|
void FixBMP(sRGBData &RGBData);
|
||||||
bool IsSizeOk(int Size);
|
bool IsSizeOk(int Size);
|
||||||
|
@ -54,8 +59,8 @@ public:
|
||||||
|
|
||||||
void LoadTex(sTex &ThisTex,sRGBData *TexData);
|
void LoadTex(sTex &ThisTex,sRGBData *TexData);
|
||||||
|
|
||||||
|
|
||||||
sTex &GetTex(int Id) {return(TexList[Id]);}
|
sTex &GetTex(int Id) {return(TexList[Id]);}
|
||||||
|
GString &GetTexName(int Id) {return(TexList[Id].Name);}
|
||||||
GLuint GetTexGLId(int Id) {return(TexList[Id].TexID);}
|
GLuint GetTexGLId(int Id) {return(TexList[Id].TexID);}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -454,22 +454,29 @@ GString Ext=Filename.Ext();
|
||||||
void CTileSet::Load2d(CCore *Core)
|
void CTileSet::Load2d(CCore *Core)
|
||||||
{
|
{
|
||||||
CTexCache &TexCache=Core->GetTexCache();
|
CTexCache &TexCache=Core->GetTexCache();
|
||||||
GString FullFilename;
|
|
||||||
GString ColTest;
|
GString ColTest;
|
||||||
|
GString Path,Name;
|
||||||
|
|
||||||
ColTest=Filename.File();
|
ColTest=Filename.File();
|
||||||
ColTest.Append('.');
|
ColTest.Append('.');
|
||||||
ColTest+=Filename.Ext();
|
ColTest+=Filename.Ext();
|
||||||
|
|
||||||
if (ColTest==ColFName)
|
if (ColTest==ColFName)
|
||||||
{// Collision thing (sigh!)
|
{// Collision thing (sigh!)
|
||||||
FullFilename=Filename.FullName();
|
Path=Filename.Drive();
|
||||||
|
Path+=Filename.Dir();
|
||||||
|
Path.Append('\\');
|
||||||
|
Name=Filename.File();
|
||||||
|
Name.Append('.');
|
||||||
|
Name+=Filename.Ext();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MakeFullFilename(Filename.FullName(),FullFilename);
|
Path=GetWorkingPath();
|
||||||
|
Name=Filename.FullName();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TexID=TexCache.ProcessTexture(FullFilename,0);
|
int TexID=TexCache.ProcessTexture(Path,Name,0);
|
||||||
sTex &ThisTex=TexCache.GetTex(TexID);
|
sTex &ThisTex=TexCache.GetTex(TexID);
|
||||||
|
|
||||||
int Width=ThisTex.TexWidth/16;
|
int Width=ThisTex.TexWidth/16;
|
||||||
|
|
|
@ -266,8 +266,6 @@ GString Path;
|
||||||
|
|
||||||
Out=Path;
|
Out=Path;
|
||||||
Out+=In;
|
Out+=In;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
@ -278,3 +276,15 @@ GString RootPath=theApp.GetCurrent()->GetPathName();
|
||||||
GFName::makerelative(RootPath,In,Out);
|
GFName::makerelative(RootPath,In,Out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************/
|
||||||
|
GString GetWorkingPath()
|
||||||
|
{
|
||||||
|
GFName FullPath=theApp.GetCurrent()->GetPathName();
|
||||||
|
GString Path;
|
||||||
|
|
||||||
|
Path=FullPath.Drive();
|
||||||
|
Path+=FullPath.Dir();
|
||||||
|
Path.Append('\\');
|
||||||
|
|
||||||
|
return(Path);
|
||||||
|
}
|
||||||
|
|
|
@ -51,5 +51,6 @@ void SetFileExt(char *InName,char *OutName,char *Ext);
|
||||||
|
|
||||||
void MakeFullFilename(const char *RelName,GString &Out);
|
void MakeFullFilename(const char *RelName,GString &Out);
|
||||||
void MakePathRel2App(const char* In,char *Out);
|
void MakePathRel2App(const char* In,char *Out);
|
||||||
|
GString GetWorkingPath();
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue