SBSPSS/Utils/MapEdit/TileSet.h

142 lines
3.8 KiB
C
Raw Normal View History

2000-10-27 02:06:19 +02:00
/*********************/
/*** TileSet Stuph ***/
/*********************/
#ifndef __TILESET_HEADER__
#define __TILESET_HEADER__
#include "stdafx.h"
2000-12-04 17:47:34 +01:00
#include <Vector3.h>
2000-10-27 02:06:19 +02:00
#include <gl\gl.h>
#include <gl\glu.h>
#include <Vector>
2000-12-04 17:47:34 +01:00
#include <gfname.hpp>
2000-10-27 02:06:19 +02:00
2000-10-27 20:18:30 +02:00
#include "TexCache.h"
#include "Tile.h"
2000-10-27 02:06:19 +02:00
2000-11-14 16:03:04 +01:00
/*****************************************************************************/
enum TileSetEnum
{
2000-11-28 22:16:00 +01:00
DefTileBrowserWidth=8,
2000-11-14 16:03:04 +01:00
};
2000-10-27 20:18:30 +02:00
/*****************************************************************************/
2000-11-06 21:24:11 +01:00
class CCore;
class CTile;
2000-10-27 20:18:30 +02:00
/*****************************************************************************/
2000-11-29 18:07:57 +01:00
class CTileSet;
2000-11-06 21:24:11 +01:00
class CTileBank
{
public:
2000-11-14 16:03:04 +01:00
CTileBank();
~CTileBank();
2000-11-17 22:36:13 +01:00
enum BrushEnum
{
LBrush=0,
RBrush,
MaxBrush
};
2001-01-23 22:53:48 +01:00
int FindTileSet(const char *Filename);
void AddTileSet(const char *Filename);
2000-11-15 22:22:40 +01:00
int NeedLoad() {return(LoadFlag);}
2000-11-29 18:07:57 +01:00
void Delete();
2000-11-15 22:22:40 +01:00
void Reload();
void LoadTileSets(CCore *Core);
CTile &GetTile(int Bank,int Tile);
2001-01-23 22:53:48 +01:00
void SetCurrent(int Set) {CurrentSet=Set+1;}
2000-12-11 22:29:59 +01:00
int GetCurrent() {return(CurrentSet);}
int GetSetCount() {return(TileSet.size());}
2001-01-24 23:35:11 +01:00
2000-11-17 22:36:13 +01:00
CMap &GetLBrush() {return(Brush[LBrush]);}
CMap &GetRBrush() {return(Brush[RBrush]);}
CMap &GetBrush(int i) {return(Brush[i]);}
CMap &GetActiveBrush() {return(GetBrush(ActiveBrush));}
2000-11-06 21:24:11 +01:00
2000-12-04 17:47:34 +01:00
void RenderSet(CCore *Core,Vector3 &CamPos,BOOL Is3d);
void FindCursorPos(CCore *Core,CMapEditView *View,Vector3 &CamPos,CPoint &MousePos);
void RenderCursor(CCore *Core,Vector3 &CamPos,BOOL Is3d);
2000-11-14 16:03:04 +01:00
2000-11-15 22:22:40 +01:00
void UpdateGUI(CCore *Core,BOOL IsTileView);
2000-11-14 16:03:04 +01:00
2000-11-29 18:07:57 +01:00
BOOL IsTileValid(int Set,int Tile);
BOOL IsTileValidGB(int Set,int Tile);
2001-01-23 22:53:48 +01:00
void SetCollision(bool f);
2001-01-24 23:35:11 +01:00
CTileSet &GetSet(int Set) {return(TileSet[Set]);}
2001-01-23 22:53:48 +01:00
2000-11-15 22:22:40 +01:00
// Functions
2000-11-17 22:36:13 +01:00
BOOL SelectL(BOOL DownFlag) {return(Select(LBrush,DownFlag));}
BOOL SelectR(BOOL DownFlag) {return(Select(RBrush,DownFlag));}
BOOL SelectCancel();
void SetActiveBrushL() {ActiveBrush=LBrush;}
void SetActiveBrushR() {ActiveBrush=RBrush;}
2000-11-06 21:24:11 +01:00
2001-01-23 22:53:48 +01:00
void Load(CFile *File,int Version);
2000-11-20 21:33:42 +01:00
void Save(CFile *File);
2000-11-06 21:24:11 +01:00
private:
2000-11-17 22:36:13 +01:00
BOOL Select(int BrushID,BOOL DownFlag);
void SetBrush(CMap &ThisBrush);
2000-11-14 16:03:04 +01:00
2000-11-06 21:24:11 +01:00
std::vector<CTileSet> TileSet;
2001-01-23 22:53:48 +01:00
int CurrentSet,LastSet;
2000-11-17 22:36:13 +01:00
CMap Brush[2];
int ActiveBrush;
int SelStart,SelEnd;
2000-11-06 21:24:11 +01:00
2000-11-15 22:22:40 +01:00
BOOL LoadFlag;
2000-11-17 22:36:13 +01:00
int LastCursorPos,CursorPos;
2000-11-06 21:24:11 +01:00
};
2000-10-27 02:06:19 +02:00
/*****************************************************************************/
class CTileSet
{
public:
2001-01-23 22:53:48 +01:00
CTileSet(const char *_Filename,int Idx);
2000-10-27 02:06:19 +02:00
~CTileSet();
2000-10-27 22:21:39 +02:00
2000-11-06 21:24:11 +01:00
int IsLoaded() {return(Loaded);}
2000-11-17 22:36:13 +01:00
int GetTileCount() {return(Tile.size());}
2000-11-22 23:08:47 +01:00
2000-11-06 21:24:11 +01:00
void Load(CCore *Core);
2000-11-22 23:08:47 +01:00
void Load2d(CCore *Core);
void Load3d(CCore *Core);
2000-12-14 17:38:34 +01:00
const char *GetDrive() {return(Filename.Drive());}
2000-12-04 17:47:34 +01:00
const char *GetPath() {return(Filename.Dir());}
const char *GetName() {return(Filename.File());}
const char *GetExt() {return(Filename.Ext());}
const char *GetFilename() {return(Filename.FullName());}
2000-11-22 23:08:47 +01:00
2000-11-06 21:24:11 +01:00
CTile &GetTile(int No) {return(Tile[No]);}
2000-11-14 16:03:04 +01:00
void Purge();
2000-12-04 17:47:34 +01:00
int FindCursorPos(CCore *Core,CMapEditView *View,Vector3 &CamPos,CPoint &MousePos);
2000-12-29 23:20:38 +01:00
void Render(CCore *Core,Vector3 &CamPos,CMap &LBrush,CMap &RBrush,BOOL Render3d);
2000-12-04 17:47:34 +01:00
void RenderCursor(Vector3 &CamPos,int Pos,int Width, int Height);
void RenderBrush(Vector3 &CamPos,CMap &LBrush,CMap &RBrush);
void RenderGrid(Vector3 &CamPos);
2000-11-28 22:16:00 +01:00
int GetTileBrowserWidth() {return(TileBrowserWidth);}
2000-11-30 23:17:55 +01:00
BOOL IsTileValid(int No);
BOOL IsTileValidGB(int No);
2000-11-29 18:07:57 +01:00
2000-10-27 02:06:19 +02:00
private:
2000-11-28 00:07:07 +01:00
BOOL Create16x16Tile(sRGBData &Src,u8 *Dst,int XOfs,int YOfs);
2000-11-29 18:07:57 +01:00
CPoint GetTilePos(int ID);
2000-11-15 22:22:40 +01:00
2000-12-04 17:47:34 +01:00
GFName Filename;
2000-11-17 22:36:13 +01:00
int SetNumber;
2000-11-30 23:17:55 +01:00
CList<CTile> Tile;
2000-11-06 21:24:11 +01:00
BOOL Loaded;
2000-11-28 22:16:00 +01:00
int TileBrowserWidth;
2000-10-27 02:06:19 +02:00
};
/*****************************************************************************/
#endif