This commit is contained in:
parent
6c4b207a57
commit
2e31ef0e34
5 changed files with 71 additions and 15 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <gfname.hpp>
|
||||
#include "psxtypes.h"
|
||||
#include "FaceStore.h"
|
||||
#include <io.h>
|
||||
|
||||
#include "..\..\..\tools\data\include\dStructs.h"
|
||||
|
||||
|
@ -100,3 +101,50 @@ int NumOfCommas=0;
|
|||
return(NumOfCommas);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
char *FindFile(const char *Name)
|
||||
{
|
||||
int Handle;
|
||||
GFName DirName(Name);
|
||||
GString Filename,Path;
|
||||
_finddata_t FindBlock;
|
||||
int Status;
|
||||
|
||||
// Does this file exist
|
||||
FILE *File=fopen(Name,"rb");
|
||||
if (File)
|
||||
{
|
||||
fclose(File);
|
||||
return((char*)Name);
|
||||
}
|
||||
|
||||
// Recurse dirs to find file
|
||||
Filename=DirName.File();
|
||||
Filename+=".";
|
||||
Filename+=DirName.Ext();
|
||||
DirName.File("*");
|
||||
DirName.Ext("*");
|
||||
Path=DirName.FullName();
|
||||
|
||||
Name=0;
|
||||
Status=Handle= _findfirst(Path,&FindBlock);
|
||||
|
||||
while (Status!=-1 && !Name)
|
||||
{
|
||||
if (FindBlock.attrib&_A_SUBDIR)
|
||||
{
|
||||
if (strcmp(FindBlock.name,".") && strcmp(FindBlock.name,".."))
|
||||
{
|
||||
GString NewName;
|
||||
NewName=DirName.Drive();
|
||||
NewName+=DirName.Dir();
|
||||
NewName+=FindBlock.name;
|
||||
NewName+="/";
|
||||
NewName+=Filename;
|
||||
Name=FindFile(NewName);
|
||||
}
|
||||
}
|
||||
if (!Name) Status=_findnext(Handle,&FindBlock);
|
||||
}
|
||||
return((char*)Name);
|
||||
}
|
||||
|
|
|
@ -65,5 +65,7 @@ int round(float f);
|
|||
|
||||
void alignFile( FILE *f, int align );
|
||||
|
||||
char *FindFile(const char *Name);
|
||||
|
||||
//***************************************************************************
|
||||
#endif
|
|
@ -190,21 +190,27 @@ CFace &F = FaceList[ListSize];
|
|||
int CFaceStore::AddTex(GString const &TexName)
|
||||
{
|
||||
int ListSize=TexList.size();
|
||||
GString UpperName=TexBasePath+TexName;
|
||||
UpperName.Upper();
|
||||
GString Filename=TexName;
|
||||
Filename.Upper();
|
||||
|
||||
for (int i=0; i<ListSize; i++)
|
||||
{
|
||||
if (TexList[i].Name==UpperName) return(TexList[i].TexGrabId);
|
||||
if (TexList[i].Name==Filename) return(TexList[i].TexGrabId);
|
||||
}
|
||||
// Does file exist
|
||||
if (!FindFile(TexName))
|
||||
GObject::Error(ERR_FATAL,"Texture not found %s!!\n",TexName);
|
||||
|
||||
|
||||
|
||||
|
||||
TexList.resize(ListSize+1);
|
||||
sFaceTexList &New=TexList[ListSize];
|
||||
|
||||
New.Name=UpperName;
|
||||
New.Name=Filename;
|
||||
|
||||
// printf("Add Tex %s\n",TexName);
|
||||
New.TexGrabId=TexGrab->AddFile(UpperName);
|
||||
New.TexGrabId=TexGrab->AddFile(Filename);
|
||||
|
||||
return(New.TexGrabId);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
void SetTexGrab(CTexGrab &NewGrab) {TexGrab=&NewGrab;}
|
||||
int AddTex(GString const &TexName);
|
||||
void SetTexBasePath(GString &Path) {TexBasePath=Path;}
|
||||
|
||||
void SetTexOut(GString &Name,int TPBase,int TPW,int TPH) {TexGrab->SetOutFile(Name); TexGrab->SetTPage(TPBase,TPW,TPH);}
|
||||
void SetTexInclude(GString &Name) {TexGrab->SetIncFile(Name);}
|
||||
void SetTexDebug(bool f) {TexGrab->SetDebug(f);}
|
||||
|
@ -137,7 +137,6 @@ private:
|
|||
vector<CFace> FaceList;
|
||||
vector<sFaceTexList> TexList;
|
||||
CTexGrab FaceStoreTexGrab,*TexGrab;
|
||||
GString TexBasePath;
|
||||
|
||||
vector<CFace> TriFaceList;
|
||||
vector<CFace> QuadFaceList;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue