This commit is contained in:
parent
e7a4db50cc
commit
e25fb0eee2
7 changed files with 123 additions and 7 deletions
|
@ -75,13 +75,55 @@ void CMkLevelLayerThing::ProcessList(CMkLevel *Core)
|
||||||
{
|
{
|
||||||
int i,ListSize=ThingList.size();
|
int i,ListSize=ThingList.size();
|
||||||
CIni &Config=Core->GetConfig();
|
CIni &Config=Core->GetConfig();
|
||||||
|
int KeyCount=Config.GetKeyCount(GetTypeName());
|
||||||
|
vector<int> Counts;
|
||||||
|
|
||||||
|
Counts.resize(KeyCount);
|
||||||
|
for (i=0;i<KeyCount;i++)
|
||||||
|
{
|
||||||
|
Counts[i]=0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0; i<ListSize; i++)
|
for (i=0; i<ListSize; i++)
|
||||||
{
|
{
|
||||||
sMkLevelLayerThing &ThisThing=ThingList[i];
|
sMkLevelLayerThing &ThisThing=ThingList[i];
|
||||||
bool Found=Config.GetInt(GetTypeName(),ThisThing.Name,ThisThing.Type);
|
bool Found=Config.GetInt(GetTypeName(),ThisThing.Name,ThisThing.Type);
|
||||||
|
Counts[ThisThing.Type]++;
|
||||||
if (!Found)
|
if (!Found)
|
||||||
GObject::Error(ERR_FATAL,"%s not found in list\n",ThisThing.Name);
|
GObject::Error(ERR_FATAL,"%s not found in list\n",ThisThing.Name);
|
||||||
}
|
}
|
||||||
|
// Create Inf Data
|
||||||
|
|
||||||
|
|
||||||
|
for (i=0; i<KeyCount; i++)
|
||||||
|
{
|
||||||
|
GString OutName="TOTAL_";
|
||||||
|
char *Name=Config.GetKeyName(GetTypeName(),i);
|
||||||
|
|
||||||
|
OutName+=GetTypeName();
|
||||||
|
OutName+="_";
|
||||||
|
OutName+=Name;
|
||||||
|
|
||||||
|
Core->AddInfItem(OutName,Counts[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
int CMkLevelLayerThing::CountThing(CMkLevel *Core,const char *Name)
|
||||||
|
{
|
||||||
|
int i,ListSize=ThingList.size();
|
||||||
|
int Count=0;
|
||||||
|
|
||||||
|
for (i=0; i<ListSize; i++)
|
||||||
|
{
|
||||||
|
sMkLevelLayerThing &ThisThing=ThingList[i];
|
||||||
|
if (ThisThing.Name=Name)
|
||||||
|
{
|
||||||
|
Count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(Count);
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ virtual const char *GetTypeName()=0;
|
||||||
virtual void PreProcess(CMkLevel *Core)=0;
|
virtual void PreProcess(CMkLevel *Core)=0;
|
||||||
virtual void Process(CMkLevel *Core)=0;
|
virtual void Process(CMkLevel *Core)=0;
|
||||||
virtual int Write(FILE *File,const char *LayerName,const char *MapName)=0;
|
virtual int Write(FILE *File,const char *LayerName,const char *MapName)=0;
|
||||||
|
int CountThing(CMkLevel *Core,const char *Name);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
u8 *LoadThing(sMkLevelLayerThing &ThisThing,u8 *Ptr);
|
u8 *LoadThing(sMkLevelLayerThing &ThisThing,u8 *Ptr);
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
CMkLevel Level;
|
CMkLevel Level;
|
||||||
int TPBase=-1,TPW=-1,TPH=-1;
|
int TPBase=-1,TPW=-1,TPH=-1;
|
||||||
|
GString IncDir;
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
char * CycleCommands(char *String,int Num)
|
char * CycleCommands(char *String,int Num)
|
||||||
|
@ -54,6 +55,11 @@ int Count;
|
||||||
TpStr= CheckFileString(String);
|
TpStr= CheckFileString(String);
|
||||||
Level.AddModel(TpStr);
|
Level.AddModel(TpStr);
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
IncDir= CheckFileString(String);
|
||||||
|
IncDir.Upper();
|
||||||
|
IncDir.Append('\\');
|
||||||
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
StripLength=4;
|
StripLength=4;
|
||||||
break;
|
break;
|
||||||
|
@ -100,7 +106,7 @@ std::vector<GString> const &Files = MyFiles.GetFileInfoVector();
|
||||||
if (Files.size()>1) Usage("Too many Levels specified\n");
|
if (Files.size()>1) Usage("Too many Levels specified\n");
|
||||||
|
|
||||||
Level.SetAppDir(argv[0]);
|
Level.SetAppDir(argv[0]);
|
||||||
Level.Init(Files[0],OutStr,TPBase,TPW,TPH);
|
Level.Init(Files[0],OutStr,IncDir,TPBase,TPW,TPH);
|
||||||
Level.Load();
|
Level.Load();
|
||||||
Level.Process();
|
Level.Process();
|
||||||
Level.Write();
|
Level.Write();
|
||||||
|
|
|
@ -61,7 +61,7 @@ GFName Path=AppPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CMkLevel::Init(const char *Filename,const char *OutFilename,int TPBase,int TPW,int TPH)
|
void CMkLevel::Init(const char *Filename,const char *OutFilename,const char *IncDir,int TPBase,int TPW,int TPH)
|
||||||
{
|
{
|
||||||
// Setup filenames and paths
|
// Setup filenames and paths
|
||||||
GFName Path;
|
GFName Path;
|
||||||
|
@ -74,7 +74,12 @@ GFName Path;
|
||||||
InPath=Path.FullName();
|
InPath=Path.FullName();
|
||||||
Path=OutFilename;
|
Path=OutFilename;
|
||||||
Path.Ext("");
|
Path.Ext("");
|
||||||
|
LevelFullName=Path.File();
|
||||||
|
LevelFullName.Upper();
|
||||||
OutName=Path.FullName();
|
OutName=Path.FullName();
|
||||||
|
OutIncName=IncDir;
|
||||||
|
OutIncName+=Path.File();
|
||||||
|
OutIncName+="_INF.h";
|
||||||
|
|
||||||
// Load ini file
|
// Load ini file
|
||||||
Config.LoadAndImport(GString(AppDir+ConfigFilename));
|
Config.LoadAndImport(GString(AppDir+ConfigFilename));
|
||||||
|
@ -869,7 +874,8 @@ GString OutFilename=OutName+".Lvl";
|
||||||
fwrite(&LevelHdr,1,sizeof(sLevelHdr),File);
|
fwrite(&LevelHdr,1,sizeof(sLevelHdr),File);
|
||||||
|
|
||||||
fclose(File);
|
fclose(File);
|
||||||
|
// Write Info header File
|
||||||
|
WriteIncFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
@ -1135,3 +1141,49 @@ int Vtx[3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
//*** Inf File **************************************************************
|
||||||
|
//***************************************************************************
|
||||||
|
void CMkLevel::AddInfItem(const char *Name,int Val)
|
||||||
|
{
|
||||||
|
sInfItem Item;
|
||||||
|
|
||||||
|
Item.Name=Name;
|
||||||
|
Item.Name.Upper();
|
||||||
|
Item.Val=Val;
|
||||||
|
|
||||||
|
InfList.Add(Item);
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
void CMkLevel::WriteIncFile()
|
||||||
|
{
|
||||||
|
GString DefStr;
|
||||||
|
|
||||||
|
DefStr=LevelFullName+"_INF";
|
||||||
|
File=fopen(OutIncName,"wt");
|
||||||
|
|
||||||
|
fprintf(File,"// %s Info Header\n",LevelFullName);
|
||||||
|
fprintf(File,"\n");
|
||||||
|
fprintf(File,"#ifndef\t__%s_INF_HEADER__\n",LevelFullName);
|
||||||
|
fprintf(File,"#define\t__%s_INF_HEADER__\n",LevelFullName);
|
||||||
|
fprintf(File,"\n");
|
||||||
|
fprintf(File,"\n");
|
||||||
|
fprintf(File,"enum\t%s\n",DefStr);
|
||||||
|
fprintf(File,"{\n");
|
||||||
|
|
||||||
|
int ListSize=InfList.size();
|
||||||
|
for (int i=0; i<ListSize; i++)
|
||||||
|
{
|
||||||
|
sInfItem &ThisItem=InfList[i];
|
||||||
|
|
||||||
|
fprintf(File,"\t%s_%s\t\t=%i,\n",DefStr,ThisItem.Name,ThisItem.Val);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(File,"};\n");
|
||||||
|
fprintf(File,"\n");
|
||||||
|
fprintf(File,"#endif\n");
|
||||||
|
|
||||||
|
fclose(File);
|
||||||
|
}
|
||||||
|
|
|
@ -67,6 +67,15 @@ struct sMkLevelModel
|
||||||
bool operator ==(sMkLevelModel const &v1) {return(Name==v1.Name);}
|
bool operator ==(sMkLevelModel const &v1) {return(Name==v1.Name);}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
struct sInfItem
|
||||||
|
{
|
||||||
|
GString Name;
|
||||||
|
int Val;
|
||||||
|
bool operator ==(sInfItem const &v1) {return(Name==v1.Name);}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
struct sMkLevelLayerThing;
|
struct sMkLevelLayerThing;
|
||||||
class CMkLevelLayer;
|
class CMkLevelLayer;
|
||||||
|
@ -77,7 +86,7 @@ public:
|
||||||
~CMkLevel();
|
~CMkLevel();
|
||||||
|
|
||||||
void SetAppDir(const char *Path);
|
void SetAppDir(const char *Path);
|
||||||
void Init(const char *InFilename,const char *OutFilename,int TPBase,int TPW,int TPH);
|
void Init(const char *InFilename,const char *OutFilename,const char *IncDir,int TPBase,int TPW,int TPH);
|
||||||
|
|
||||||
void LoadModels();
|
void LoadModels();
|
||||||
int AddModel(GString &Filename);
|
int AddModel(GString &Filename);
|
||||||
|
@ -89,6 +98,7 @@ public:
|
||||||
int AddTile3d(sExpLayerTile &Tile) {return(Tile3dList.Add(Tile));}
|
int AddTile3d(sExpLayerTile &Tile) {return(Tile3dList.Add(Tile));}
|
||||||
int AddTile2d(sExpLayerTile &Tile) {return(Tile2dList.Add(Tile));}
|
int AddTile2d(sExpLayerTile &Tile) {return(Tile2dList.Add(Tile));}
|
||||||
|
|
||||||
|
void AddInfItem(const char *Name,int Val);
|
||||||
void Write();
|
void Write();
|
||||||
|
|
||||||
int Create2dTex(int Tile,int Flags);
|
int Create2dTex(int Tile,int Flags);
|
||||||
|
@ -99,6 +109,7 @@ public:
|
||||||
int BuildTileTex(sExpTile &SrcTile,int Flags);
|
int BuildTileTex(sExpTile &SrcTile,int Flags);
|
||||||
|
|
||||||
char *GetConfigStr(const char *Grp,const char *Key) {return(Config.GetStr(Grp,Key));}
|
char *GetConfigStr(const char *Grp,const char *Key) {return(Config.GetStr(Grp,Key));}
|
||||||
|
int GetConfigInt(const char *Grp,const char *Key) {return(Config.GetInt(Grp,Key));}
|
||||||
CIni &GetConfig() {return(Config);}
|
CIni &GetConfig() {return(Config);}
|
||||||
CTexGrab &GetTexGrab() {return(TexGrab);}
|
CTexGrab &GetTexGrab() {return(TexGrab);}
|
||||||
|
|
||||||
|
@ -135,11 +146,13 @@ protected:
|
||||||
void CalcModelBBox(sMkLevelModel &ThisModel,sBBox &BBox);
|
void CalcModelBBox(sMkLevelModel &ThisModel,sBBox &BBox);
|
||||||
void BuildTiles();
|
void BuildTiles();
|
||||||
|
|
||||||
|
void WriteIncFile();
|
||||||
|
|
||||||
void ExpTri2Face(sExpTri &In,CFace &Out,bool ImportTex=true);
|
void ExpTri2Face(sExpTri &In,CFace &Out,bool ImportTex=true);
|
||||||
|
|
||||||
FILE *File;
|
FILE *File;
|
||||||
GString InFilename,InPath,LevelName;
|
GString InFilename,InPath,LevelName,LevelFullName;
|
||||||
GString OutName;
|
GString OutName,OutIncName;
|
||||||
GString AppDir;
|
GString AppDir;
|
||||||
|
|
||||||
int TileW,TileH;
|
int TileW,TileH;
|
||||||
|
@ -170,6 +183,8 @@ protected:
|
||||||
sLevelHdr LevelHdr;
|
sLevelHdr LevelHdr;
|
||||||
sExpTri FlatFace[2];
|
sExpTri FlatFace[2];
|
||||||
|
|
||||||
|
CList<sInfItem> InfList;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
|
@ -28,7 +28,7 @@ clean$Chapter\_$Level\_LVL :\n\t\$(RM) -f \$($Chapter\_$Level\_OUT) \$($Chapter\
|
||||||
$Chapter\_$Level\_LVL :\t\$($Chapter\_$Level\_IN)
|
$Chapter\_$Level\_LVL :\t\$($Chapter\_$Level\_IN)
|
||||||
|
|
||||||
\$($Chapter\_$Level\_OUT) : \$($Chapter\_$Level\_IN)
|
\$($Chapter\_$Level\_OUT) : \$($Chapter\_$Level\_IN)
|
||||||
\t\@\$(MKLEVEL) \$($Chapter\_$Level\_IN) -o:\$($Chapter\_$Level\_OUT) \$(LEVELS_OPTS)
|
\t\@\$(MKLEVEL) \$($Chapter\_$Level\_IN) -o:\$($Chapter\_$Level\_OUT) -i:\$(INC_DIR) \$(LEVELS_OPTS)
|
||||||
|
|
||||||
eot
|
eot
|
||||||
;
|
;
|
||||||
|
|
Binary file not shown.
Loading…
Add table
Reference in a new issue