SBSPSS/Utils/MkLevel/MkLevel.h

192 lines
4.8 KiB
C
Raw Normal View History

2001-04-17 18:42:07 +02:00
/*************************/
/*** Base Level Holder ***/
/*************************/
#ifndef __MKLEVEL_HEADER__
#define __MKLEVEL_HEADER__
#include <vector>
#include <List.h>
#include <FaceStore.h>
#include "IniClass.h"
// Map Editor header files
#include "..\mapedit\LayerDef.h"
#include "..\mapedit\ExportHdr.h"
using namespace std;
//***************************************************************************
2001-05-02 20:40:41 +02:00
/*
2001-04-17 18:42:07 +02:00
struct sMkLevelTex
{
int Set;
int XOfs,YOfs;
2001-05-02 20:40:41 +02:00
// u8 *RGB;
2001-04-17 18:42:07 +02:00
int Flags;
2001-05-02 20:40:41 +02:00
// int RChk,GChk,BChk;
2001-04-17 18:42:07 +02:00
int TexID;
bool operator ==(sMkLevelTex const &v1)
{
if (Set!=v1.Set) return(false);
if (XOfs!=v1.XOfs) return(false);
if (YOfs!=v1.YOfs) return(false);
if (Flags!=v1.Flags) return(false);
return(true);
}
};
2001-05-02 20:40:41 +02:00
*/
2001-05-05 23:18:12 +02:00
struct sMkLevelTex
{
// int Set;
// int XOfs,YOfs;
int Tile;
int Flags;
int TexID;
bool operator ==(sMkLevelTex const &v1)
{
// if (Set!=v1.Set) return(false);
// if (XOfs!=v1.XOfs) return(false);
// if (YOfs!=v1.YOfs) return(false);
if (Tile!=v1.Tile) return(false);
if (Flags!=v1.Flags) return(false);
return(true);
}
};
2001-04-17 18:42:07 +02:00
//***************************************************************************
2001-04-27 18:16:23 +02:00
struct sMkLevelModel
2001-04-23 16:51:44 +02:00
{
GString Name;
int TriStart;
int TriCount;
2001-04-27 18:16:23 +02:00
bool operator ==(sMkLevelModel const &v1) {return(Name==v1.Name);}
2001-04-23 16:51:44 +02:00
};
2001-05-23 18:03:10 +02:00
//***************************************************************************
struct sInfItem
{
GString Name;
int Val;
bool operator ==(sInfItem const &v1) {return(Name==v1.Name);}
};
2001-04-23 16:51:44 +02:00
//***************************************************************************
struct sMkLevelLayerThing;
2001-04-17 18:42:07 +02:00
class CMkLevelLayer;
class CMkLevel
{
public:
CMkLevel();
~CMkLevel();
2001-04-19 17:12:21 +02:00
void SetAppDir(const char *Path);
2001-05-23 18:03:10 +02:00
void Init(const char *InFilename,const char *OutFilename,const char *IncDir,int TPBase,int TPW,int TPH);
2001-04-17 18:42:07 +02:00
2001-04-27 18:16:23 +02:00
void LoadModels();
int AddModel(GString &Filename);
2001-04-30 23:49:54 +02:00
int AddModel(const char *Name,int TriStart,int TriCount);
2001-04-17 18:42:07 +02:00
void Load();
void Process();
2001-04-23 16:51:44 +02:00
int AddTile3d(sExpLayerTile &Tile) {return(Tile3dList.Add(Tile));}
int AddTile2d(sExpLayerTile &Tile) {return(Tile2dList.Add(Tile));}
2001-04-17 18:42:07 +02:00
2001-05-23 18:03:10 +02:00
void AddInfItem(const char *Name,int Val);
2001-04-17 18:42:07 +02:00
void Write();
2001-04-23 16:51:44 +02:00
int Create2dTex(int Tile,int Flags);
2001-04-17 18:42:07 +02:00
int Create3dTile(sExpLayerTile &ThisTile);
2001-05-02 20:40:41 +02:00
// int FindRGBMatch(sMkLevelTex &ThisTex);
// bool IsRGBSame(const sMkLevelTex &Tile0,const sMkLevelTex &Tile1);
void MakeTexName(sExpTile &SrcTile,int Flags,GString &OutStr);
int BuildTileTex(sExpTile &SrcTile,int Flags);
2001-04-17 18:42:07 +02:00
char *GetConfigStr(const char *Grp,const char *Key) {return(Config.GetStr(Grp,Key));}
2001-05-23 18:03:10 +02:00
int GetConfigInt(const char *Grp,const char *Key) {return(Config.GetInt(Grp,Key));}
2001-04-19 17:12:21 +02:00
CIni &GetConfig() {return(Config);}
2001-04-17 18:42:07 +02:00
CTexGrab &GetTexGrab() {return(TexGrab);}
2001-04-19 17:12:21 +02:00
void SetStart(int X,int Y) {LevelHdr.PlayerStartX=X; LevelHdr.PlayerStartY=Y;}
2001-04-17 18:42:07 +02:00
protected:
2001-04-27 18:16:23 +02:00
void BuildModel(CScene &ThisScene,GString &RootPath,int Node);
2001-04-17 18:42:07 +02:00
CMkLevelLayer *FindLayer(int Type,int SubType);
void LoadStrList(CList<GString> &List,char *TexPtr,int Count);
void LoadTiles(sExpFileHdr *FileHdr);
void LoadLayers(sExpFileHdr *FileHdr);
void LoadLayer(sExpLayerHdr *LayerHdr);
void PreProcessLayers();
void ProcessTileBanks();
void PreProcessTileBank2d();
void ProcessTileBank2d();
void PreProcessTileBank3d();
void ProcessTileBank3d();
void ProcessLayers();
void SetUpTileUV(sTile2d &Out, sTexOutInfo &Info);
2001-04-27 18:16:23 +02:00
void ProcessModels();
2001-04-17 18:42:07 +02:00
void WriteLevel();
void WriteLayers();
int WriteLayer(int Type,int SubType,const char *LayerName);
int WriteThings(int Type,const char *LayerName);
2001-04-27 18:16:23 +02:00
int WriteModelList();
2001-04-17 18:42:07 +02:00
int WriteTriList();
int WriteQuadList();
2001-04-19 17:12:21 +02:00
int WriteVtxList();
2001-04-17 18:42:07 +02:00
void WriteTileBank();
2001-05-05 23:18:12 +02:00
void CalcModelBBox(sMkLevelModel &ThisModel,sBBox &BBox);
2001-04-17 18:42:07 +02:00
void BuildTiles();
2001-05-23 18:03:10 +02:00
void WriteIncFile();
2001-04-23 16:51:44 +02:00
void ExpTri2Face(sExpTri &In,CFace &Out,bool ImportTex=true);
2001-04-17 18:42:07 +02:00
FILE *File;
2001-05-23 18:03:10 +02:00
GString InFilename,InPath,LevelName,LevelFullName;
GString OutName,OutIncName;
2001-04-19 17:12:21 +02:00
GString AppDir;
2001-04-17 18:42:07 +02:00
int TileW,TileH;
CIni Config;
2001-04-27 18:16:23 +02:00
2001-04-17 18:42:07 +02:00
CList<sExpTri> InTriList;
CList<sExpTile> InTileList;
CList<GString> InSetNameList;
CList<GString> InTexNameList;
CList<GString> UsedSetNameList;
CList<GString> UsedTexNameList;
2001-04-19 17:12:21 +02:00
CFaceStore OutFaceList;
2001-04-17 18:42:07 +02:00
CList<sTile2d> OutTile2dList;
CList<sTile3d> OutTile3dList;
CList<sExpLayerTile> Tile2dList;
CList<sExpLayerTile> Tile3dList;
2001-05-05 23:18:12 +02:00
CList<sMkLevelTex> Tex2dList;
2001-04-17 18:42:07 +02:00
CTexGrab TexGrab;
CList<Frame> BmpList;
vector<CMkLevelLayer*> LayerList;
2001-04-27 18:16:23 +02:00
CList<sMkLevelModel> ModelList;
CFaceStore ModelFaceList;
2001-04-19 17:12:21 +02:00
sLevelHdr LevelHdr;
sExpTri FlatFace[2];
2001-04-17 18:42:07 +02:00
2001-05-23 18:03:10 +02:00
CList<sInfItem> InfList;
2001-04-17 18:42:07 +02:00
};
//***************************************************************************
#endif