This commit is contained in:
Daveo 2001-02-07 18:46:59 +00:00
parent 9dd82e90c5
commit c1059872a2
8 changed files with 85 additions and 144 deletions

View File

@ -210,7 +210,7 @@ int TriCount=TileTriList.size();
{
sTriFace &InTri=TileTriList[T];
sExpTri OutTri;
GString TexName=TexCache.GetTexName(InTri.Mat);
GString TexName=TexCache.GetTexFilename(InTri.Mat);
OutTri.TexID=TexNames.Add(TexName);
for (int p=0; p<3; p++)
@ -223,44 +223,14 @@ int TriCount=TileTriList.size();
}
}
/*
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++)
{
sTriFace &TileTri=TileTriList[T];
sTriFace OutTri;
// sExpTex OutTex;
for (int p=0; p<3; p++)
{
OutTri=TileTri;
// Texture
// sTex &TriTex=TexCache.GetTex(TileTri.Mat);
// OutTex.Filename=TriTex.Filename;
// OutTri.Mat=TexList.Add(OutTex);
}
TriList.push_back(OutTri);
}
// return(TriCount);
}
*/
/*****************************************************************************/
void CExport::ExportStrList(CCore *Core)
{
int ListSize,i;
GString SavePath=GetWorkingPath();
char RelStr[256];
SavePath.Upper();
// Set List
ListSize=SetNames.size();
@ -269,8 +239,10 @@ int ListSize,i;
for (i=0; i<ListSize; i++)
{
const char *Str=SetNames[i];
fwrite(Str,strlen(Str)+1,1,File);
GString &ThisFile=SetNames[i];
ThisFile.Upper();
GFName::makerelative(SavePath,ThisFile,RelStr);
fwrite(RelStr,strlen(RelStr)+1,1,File);
}
// Tex List
ListSize=TexNames.size();
@ -279,8 +251,10 @@ int ListSize,i;
for (i=0; i<ListSize; i++)
{
const char *Str=TexNames[i];
fwrite(Str,strlen(Str)+1,1,File);
GString &ThisFile=TexNames[i];
ThisFile.Upper();
GFName::makerelative(SavePath,ThisFile,RelStr);
fwrite(RelStr,strlen(RelStr)+1,1,File);
}
}

View File

@ -6,6 +6,7 @@
#include <gl\gl.h>
#include <gl\glu.h>
#include <frame.hpp>
#include <gfname.hpp>
#include <Vector>
#include "TexCache.h"
@ -25,17 +26,15 @@ sTex Tex;
*/
/*****************************************************************************/
// Checks loaded files for dups, assumes all passed RGB is unique
int CTexCache::ProcessTexture(const char *Path,const char *Name,int Flags,sRGBData *RGBData)
int CTexCache::ProcessTexture(const char *Filename,int Flags,sRGBData *RGBData)
{
int ListSize=TexList.size();
sTex NewTex;
sRGBData ThisRGB;
GFName FName=Filename;
// strcpy(NewTex.Filename,Filename);
NewTex.Path=Path;
NewTex.Name=Name;
NewTex.FullFilename=NewTex.Path+NewTex.Name;
NewTex.Name=FName.File();
NewTex.Filename=Filename;
NewTex.Flags=Flags;
if (!RGBData) // Need to load file
@ -45,7 +44,7 @@ sRGBData ThisRGB;
// TRACE1("Loading Texture %s\n",NewTex.Filename);
if (!LoadBMP(NewTex.FullFilename,ThisRGB))
if (!LoadBMP(NewTex.Filename,ThisRGB))
{
exit(-1);
return(ListSize);

View File

@ -22,9 +22,7 @@ struct sRGBData
struct sTex
{
// char Filename[_MAX_PATH];
GString FullFilename;
GString Path;
GString Filename;
GString Name;
GLuint TexID;
int Flags;
@ -32,8 +30,7 @@ struct sTex
float dW,dH;
bool Loaded;
// 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);}
bool operator==(sTex const &v1) {return (Filename==v1.Filename && Flags==v1.Flags);}
};
const RGBQUAD BlankRGB={255,0,255};
@ -46,9 +43,8 @@ class CTexCache
public:
int GetTexIdx(sTex &Tex) {return(TexList.Find(Tex));}
// int GetTexIdx(const char *Filename,int Flags);
int ProcessTexture(const char *Path,const char *Name,int Flags,sRGBData *RGBData=0);
int ProcessTexture(const char *Name,int Flags,sRGBData *RGBData=0);
void Purge();
bool LoadBMP(const char *Filename,sRGBData &RGBData);
@ -60,6 +56,7 @@ public:
void LoadTex(sTex &ThisTex,sRGBData *TexData);
sTex &GetTex(int Id) {return(TexList[Id]);}
GString &GetTexFilename(int Id) {return(TexList[Id].Filename);}
GString &GetTexName(int Id) {return(TexList[Id].Name);}
GLuint GetTexGLId(int Id) {return(TexList[Id].TexID);}

View File

@ -43,7 +43,7 @@ GString Filename;
// Get application path
#ifdef _DEBUG
ExePath="C:/Spongebob/tools/mapedit/";
ExePath="C:\\Spongebob\\tools\\mapedit\\";
#else
char ExeFilename[2048];
GetModuleFileName(GetModuleHandle(NULL),ExeFilename,2048);
@ -84,29 +84,14 @@ void CTileBank::SetCollision(bool f)
}
}
/*****************************************************************************/
char *FixName(const char *In)
{
char *Ptr=(char*)In;
while (*Ptr)
{
if (Ptr[0]=='T' &&
Ptr[1]=='I' &&
Ptr[2]=='L' &&
Ptr[3]=='E') return(Ptr);
Ptr++;
}
return(Ptr);
}
void CTileBank::Load(CFile *File,int Version)
{
int ListSize;
GFName RootPath=File->GetFilePath();
GString FilePath;
FilePath=RootPath.Drive();
FilePath+=RootPath.Dir();
FilePath.Append('\\');
@ -124,22 +109,17 @@ GString FilePath;
// New Style rel storage
for (int i=0;i<ListSize;i++)
{
char c=1;//,FullName[256+64];
GString RelName;
int Len=0;
char c=1;
GString FullName=FilePath;
while (c)
{
File->Read(&c,1);
RelName.Append(c);
FullName.Append(c);
}
// RelName.Upper();
{ // Dodgy arse artist fix
// RelName=FixName(RelName);
}
// RootPath.makeabsolute(FilePath,RelName,FullName);
AddTileSet(RelName);
FullName.Upper();
CheckFilename(FullName);
AddTileSet(FullName);
}
}
@ -148,12 +128,14 @@ void CTileBank::Save(CFile *File)
{
int ListSize=TileSet.size();
int NewListSize=ListSize-1;
GString FilePath;
GFName RootPath=File->GetFilePath();
GString SavePath;
FilePath=RootPath.Drive();
FilePath+=RootPath.Dir();
FilePath.Append('\\');
SavePath=RootPath.Drive();
SavePath+=RootPath.Dir();
SavePath.Append('\\');
SavePath.Upper();
File->Write(&NewListSize,sizeof(int));
File->Write(&CurrentSet,sizeof(int));
@ -166,8 +148,7 @@ GFName RootPath=File->GetFilePath();
CTileSet &ThisSet=TileSet[i];
char Filename[256+64];
RootPath.makerelative(FilePath,ThisSet.GetFilename(),Filename);
RootPath.makerelative(SavePath,ThisSet.GetFilename(),Filename);
File->Write(Filename,strlen(Filename)+1);
}
@ -397,15 +378,6 @@ BOOL CTileBank::IsTileValid(int Set,int Tile)
return(TileSet[Set].IsTileValid(Tile));
}
/*****************************************************************************/
/*
BOOL CTileBank::IsTileValidGB(int Set,int Tile)
{
if (Set<0 || Tile<0) return(FALSE);
return(TileSet[Set].IsTileValidGB(Tile));
}
*/
/*****************************************************************************/
/*****************************************************************************/
/*** TileSet *****************************************************************/
@ -413,10 +385,10 @@ BOOL CTileBank::IsTileValidGB(int Set,int Tile)
/*****************************************************************************/
CTileSet::CTileSet(const char *_Filename,int Idx)
{
if (_Filename)
{
GFName FName=_Filename;
Filename=_Filename;
}
Name=FName.File();
Loaded=FALSE;
SetNumber=Idx;
@ -434,7 +406,8 @@ CTileSet::~CTileSet()
/*****************************************************************************/
void CTileSet::Load(CCore *Core)
{
GString Ext=Filename.Ext();
GFName FName=Filename;
GString Ext=FName.Ext();
Ext.Upper();
if (Ext=="GIN")
@ -455,28 +428,7 @@ void CTileSet::Load2d(CCore *Core)
{
CTexCache &TexCache=Core->GetTexCache();
GString ColTest;
GString Path,Name;
ColTest=Filename.File();
ColTest.Append('.');
ColTest+=Filename.Ext();
if (ColTest==ColFName)
{// Collision thing (sigh!)
Path=Filename.Drive();
Path+=Filename.Dir();
Path.Append('\\');
Name=Filename.File();
Name.Append('.');
Name+=Filename.Ext();
}
else
{
Path=GetWorkingPath();
Name=Filename.FullName();
}
int TexID=TexCache.ProcessTexture(Path,Name,0);
int TexID=TexCache.ProcessTexture(Filename,0);
sTex &ThisTex=TexCache.GetTex(TexID);
int Width=ThisTex.TexWidth/16;
@ -500,11 +452,8 @@ int Height=ThisTex.TexHeight/16;
void CTileSet::Load3d(CCore *Core)
{
CScene Scene;
GString FullFilename;
MakeFullFilename(Filename.FullName(),FullFilename);
Scene.Load(FullFilename);
Scene.Load(Filename);
CNode &ThisNode=Scene.GetSceneNode(0);
int ChildCount=ThisNode.GetPruneChildCount();
@ -551,16 +500,6 @@ BOOL CTileSet::IsTileValid(int No)
{return(Tile[No].IsValid());}
}
/*****************************************************************************/
/*
BOOL CTileSet::IsTileValidGB(int No)
{
// ASSERT(No<Tile.size());
if (No>Tile.size()) return(FALSE);
return(Tile[No].IsValidGB());
}
*/
/*****************************************************************************/
void CTileSet::Render(CCore *Core,Vector3 &CamPos,CMap &LBrush,CMap &RBrush,BOOL Render3d)
{

View File

@ -115,8 +115,8 @@ public:
// const char *GetExt() {return(Filename.Ext());}
// const char *GetFilename() {return(Filename.FullName());}
const char *GetFilename() {return(Filename.FullName());}
const char *GetName() {return(Filename.File());}
const char *GetFilename() {return(Filename);}
const char *GetName() {return(Name);}
CTile &GetTile(int No) {return(Tile[No]);}
void Purge();
@ -134,7 +134,7 @@ private:
BOOL Create16x16Tile(sRGBData &Src,u8 *Dst,int XOfs,int YOfs);
CPoint GetTilePos(int ID);
GFName Filename;
GString Filename,Name;
int SetNumber;
CList<CTile> Tile;

View File

@ -288,3 +288,35 @@ GString Path;
return(Path);
}
/*****************************************************************************/
void CheckFilename(GString &Filename)
{
FILE *File;
CString mexstr;
GFName FName=Filename;
GString Name;
// Check File exists
File=fopen(Filename,"r");
if (File)
{
fclose(File);
return;
}
Name=FName.File();
Name.Append('.');
Name+=FName.Ext();
mexstr.Format("%s Not Found.\n\nPlease Locate\n", Filename);
AfxMessageBox(mexstr,MB_OK | MB_ICONEXCLAMATION);
char BASED_CODE Filter[]= "All Files (*.*)|*.*||";
CFileDialog Dlg(true,NULL,Name,OFN_HIDEREADONLY | OFN_PATHMUSTEXIST,Filter);
if (Dlg.DoModal()!=IDOK) return;
Filename=Dlg.GetPathName();
}

View File

@ -37,7 +37,6 @@ void DbgMsg(const char * pszFmt,...);
void BuildGLBox(float XMin,float XMax,float YMin,float YMax,float ZMin,float ZMax);
void BuildGLBoxNoNormals(float XMin,float XMax,float YMin,float YMax,float ZMin,float ZMax);
void BuildGLQuad(float XMin,float XMax,float YMin,float YMax,float Z);
int LoadGLTexture(char *FileName, GLuint &Text,int &Width,int &Height);
CPoint IDToPoint(int ID,int Width);
int PointToID(CPoint &Pnt,int Width);
@ -52,5 +51,6 @@ void SetFileExt(char *InName,char *OutName,char *Ext);
void MakeFullFilename(const char *RelName,GString &Out);
void MakePathRel2App(const char* In,char *Out);
GString GetWorkingPath();
void CheckFilename(GString &Filename);
#endif

Binary file not shown.