This commit is contained in:
parent
e9835c718d
commit
80cb6d30d8
@ -23,6 +23,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include "ExportAGB.h"
|
#include "ExportAGB.h"
|
||||||
|
#include "ExportPSX.h"
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -58,8 +59,8 @@ BOOL CCore::New()
|
|||||||
{
|
{
|
||||||
CNewMapGUI Dlg;
|
CNewMapGUI Dlg;
|
||||||
int Width,Height;
|
int Width,Height;
|
||||||
Dlg.m_Width=TileLayerDefaultWidth;
|
Dlg.m_Width=TileLayerMinWidth;
|
||||||
Dlg.m_Height=TileLayerDefaultHeight;
|
Dlg.m_Height=TileLayerMinHeight;
|
||||||
|
|
||||||
Dlg.m_Back=TRUE;
|
Dlg.m_Back=TRUE;
|
||||||
Dlg.m_Mid=TRUE;
|
Dlg.m_Mid=TRUE;
|
||||||
@ -133,6 +134,16 @@ int LayerCount;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
TileBank.Load(File,Version);
|
TileBank.Load(File,Version);
|
||||||
|
|
||||||
|
|
||||||
|
// Check Layers
|
||||||
|
int MapWidth=Layer[FindActionLayer()]->GetWidth();
|
||||||
|
int MapHeight=Layer[FindActionLayer()]->GetHeight();
|
||||||
|
for (i=0;i<LayerCount;i++)
|
||||||
|
{
|
||||||
|
Layer[i]->CheckLayerSize(MapWidth,MapHeight);
|
||||||
|
}
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,6 +583,7 @@ void CCore::Toggle2d3d(CMapEditView *View)
|
|||||||
{
|
{
|
||||||
Is3dFlag=!Is3dFlag;
|
Is3dFlag=!Is3dFlag;
|
||||||
UpdateView(View);
|
UpdateView(View);
|
||||||
|
// ExportPSX("c:/temp/test.pme");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -623,11 +635,27 @@ CExportAGB Exp(ExportName);
|
|||||||
{
|
{
|
||||||
Layer[i]->Export(this,Exp);
|
Layer[i]->Export(this,Exp);
|
||||||
}
|
}
|
||||||
Exp.ExportAll(this);
|
Exp.ExportTiles(this);
|
||||||
|
Exp.ExportPalette();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CCore::ExportPSX(char *Filename)
|
void CCore::ExportPSX(char *Filename)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
int LayerCount=Layer.size();
|
||||||
|
char ExportName[256];
|
||||||
|
|
||||||
|
SetFileExt(Filename,ExportName,"PME");
|
||||||
|
|
||||||
|
CExportPSX Exp(ExportName);
|
||||||
|
|
||||||
|
/* for (int i=0;i<LayerCount;i++)
|
||||||
|
{
|
||||||
|
Layer[i]->Export(this,Exp);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
Layer[FindActionLayer()]->Export(this,Exp);
|
||||||
|
|
||||||
|
Exp.ExportTiles(this);
|
||||||
}
|
}
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
const float FileVersion=1.0f;
|
const float FileVersion=1.0f;
|
||||||
|
|
||||||
//#define UseLighting
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
class CMapEditView;
|
class CMapEditView;
|
||||||
|
@ -27,134 +27,3 @@ CExport::~CExport()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CExport::ExportAll(CCore *Core)
|
|
||||||
{
|
|
||||||
ExportTiles(Core);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CExport::ExportLayerTile(CCore *Core,char *LayerName,CMap &Map)
|
|
||||||
{
|
|
||||||
int MapWidth=Map.GetWidth();
|
|
||||||
int MapHeight=Map.GetHeight();
|
|
||||||
int MinWidth=GetMinLayerTileWidth();
|
|
||||||
int MinHeight=GetMinLayerTileHeight();
|
|
||||||
|
|
||||||
int ExpWidth=max(MapWidth,MinWidth);
|
|
||||||
int ExpHeight=max(MapHeight,MinHeight);
|
|
||||||
|
|
||||||
sMapElem BlankElem={0,0,0};
|
|
||||||
|
|
||||||
ExportLayerTileStart(LayerName,ExpWidth,ExpHeight);
|
|
||||||
for (int Y=0; Y<ExpHeight; Y++)
|
|
||||||
{
|
|
||||||
for (int X=0; X<ExpWidth; X++)
|
|
||||||
{
|
|
||||||
if (X<MapWidth && Y<MapHeight)
|
|
||||||
{
|
|
||||||
sMapElem &ThisElem=Map.Get(X,Y);
|
|
||||||
int Idx=AddTileToList(Core,ThisElem);
|
|
||||||
ExportLayerTile(ThisElem,Idx);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ExportLayerTile(BlankElem,0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
ExportLayerTileEnd(LayerName);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CExport::PrintTileList()
|
|
||||||
{
|
|
||||||
int ListSize=UsedTileList.size();
|
|
||||||
|
|
||||||
for (int i=0; i<ListSize; i++)
|
|
||||||
{
|
|
||||||
// TRACE3("%02d: %i %i\n",i,UsedTileList[i].Set,UsedTileList[i].Tile);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
int CExport::FindTileInList(sMapElem &Tile)
|
|
||||||
{
|
|
||||||
int ListSize=UsedTileList.size();
|
|
||||||
|
|
||||||
for (int Idx=0; Idx<ListSize; Idx++)
|
|
||||||
{
|
|
||||||
sMapElem &ListTile=UsedTileList[Idx];
|
|
||||||
|
|
||||||
if (ListTile.Set==Tile.Set && ListTile.Tile==Tile.Tile) return(Idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
int CExport::AddTileToList(CCore *Core,sMapElem &Tile)
|
|
||||||
{
|
|
||||||
int Idx;
|
|
||||||
if (!IsTileValidExport(Core,Tile))
|
|
||||||
{
|
|
||||||
sMapElem Blank;
|
|
||||||
Blank.Set=0;
|
|
||||||
Blank.Tile=0;
|
|
||||||
Blank.Flags=0;
|
|
||||||
Idx=FindTileInList(Blank);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Idx=FindTileInList(Tile);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (Idx==-1)
|
|
||||||
{ // New tile!!
|
|
||||||
Idx=UsedTileList.size();
|
|
||||||
UsedTileList.push_back(Tile);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(Idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CExport::ExportTiles(CCore *Core)
|
|
||||||
{
|
|
||||||
CTileBank &TileBank=Core->GetTileBank();
|
|
||||||
int ListSize=UsedTileList.size(),i;
|
|
||||||
|
|
||||||
PrintTileList();
|
|
||||||
for (i=0; i<ListSize; i++)
|
|
||||||
{
|
|
||||||
sMapElem &ThisElem=UsedTileList[i];
|
|
||||||
CTile &ThisTile=Core->GetTile(ThisElem.Set,ThisElem.Tile);
|
|
||||||
|
|
||||||
ParseTile(ThisTile);
|
|
||||||
}
|
|
||||||
CreateTilePalette();
|
|
||||||
ExportTileStart(ListSize);
|
|
||||||
for (i=0; i<ListSize; i++)
|
|
||||||
{
|
|
||||||
sMapElem &ThisElem=UsedTileList[i];
|
|
||||||
CTile &ThisTile=Core->GetTile(ThisElem.Set,ThisElem.Tile);
|
|
||||||
|
|
||||||
ExportTile(ThisTile);
|
|
||||||
}
|
|
||||||
ExportTileEnd();
|
|
||||||
|
|
||||||
|
|
||||||
// Palette
|
|
||||||
ExportPaletteStart();
|
|
||||||
ExportPalette();
|
|
||||||
ExportPaletteEnd();
|
|
||||||
|
|
||||||
}
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
@ -24,35 +24,10 @@ public:
|
|||||||
CExport(char *Filename);
|
CExport(char *Filename);
|
||||||
~CExport();
|
~CExport();
|
||||||
|
|
||||||
void ExportLayerTile(CCore *Core,char *LayerName,CMap &Map);
|
virtual void ExportLayerTile(CCore *Core,char *LayerName,int SubType,CMap &Map)=0;
|
||||||
void ExportAll(CCore *Core);
|
virtual void ExportTiles(CCore *Core)=0;
|
||||||
|
|
||||||
void PrintTileList();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int FindTileInList(sMapElem &Tile);
|
|
||||||
int AddTileToList(CCore *Core,sMapElem &Tile);
|
|
||||||
|
|
||||||
void ExportTiles(CCore *Core);
|
|
||||||
void ExportPalette(CCore *Core);
|
|
||||||
|
|
||||||
virtual void ExportLayerTileStart(char *LayerName,int Width,int Height)=0;
|
|
||||||
virtual void ExportLayerTile(sMapElem &Elem,int NewIdx)=0;
|
|
||||||
virtual void ExportLayerTileEnd(char *LayerName)=0;
|
|
||||||
virtual int GetMinLayerTileWidth()=0;
|
|
||||||
virtual int GetMinLayerTileHeight()=0;
|
|
||||||
virtual BOOL IsTileValidExport(CCore *Core,sMapElem &Tile)=0;
|
|
||||||
|
|
||||||
virtual void ExportTileStart(int TileCount)=0;
|
|
||||||
virtual void ParseTile(CTile &ThisTile)=0;
|
|
||||||
virtual void CreateTilePalette()=0;
|
|
||||||
virtual void ExportTile(CTile &ThisTile)=0;
|
|
||||||
virtual void ExportTileEnd()=0;
|
|
||||||
|
|
||||||
virtual void ExportPaletteStart()=0;
|
|
||||||
virtual void ExportPalette()=0;
|
|
||||||
virtual void ExportPaletteEnd()=0;
|
|
||||||
|
|
||||||
|
|
||||||
char Drive[_MAX_DRIVE],Path[_MAX_DIR],Name[_MAX_FNAME],Ext[_MAX_EXT];
|
char Drive[_MAX_DRIVE],Path[_MAX_DIR],Name[_MAX_FNAME],Ext[_MAX_EXT];
|
||||||
FILE *File;
|
FILE *File;
|
||||||
@ -62,4 +37,5 @@ virtual void ExportPaletteEnd()=0;
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -22,6 +22,11 @@ enum LAYER_TYPE
|
|||||||
LAYER_TYPE_MAX
|
LAYER_TYPE_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SCREEN_WIDTH_TILE=30,
|
||||||
|
SCREEN_HEIGHT_TILE=20,
|
||||||
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
class CCore;
|
class CCore;
|
||||||
@ -52,7 +57,8 @@ virtual void UpdateGUI(CCore *Core)=0;
|
|||||||
|
|
||||||
virtual int GetWidth()=0;
|
virtual int GetWidth()=0;
|
||||||
virtual int GetHeight()=0;
|
virtual int GetHeight()=0;
|
||||||
virtual void Resize(int Width,int Height)=0;
|
virtual void CheckLayerSize(int Width,int Height){};
|
||||||
|
virtual BOOL Resize(int Width,int Height)=0;
|
||||||
|
|
||||||
virtual void Load(CFile *File,float Version)=0;
|
virtual void Load(CFile *File,float Version)=0;
|
||||||
virtual void Save(CFile *File)=0;
|
virtual void Save(CFile *File)=0;
|
||||||
|
@ -46,12 +46,14 @@ CLayerTile::CLayerTile(int _SubType,int Width,int Height,float Scale,BOOL Is3d,B
|
|||||||
|
|
||||||
if (ResizeFlag)
|
if (ResizeFlag)
|
||||||
{
|
{
|
||||||
Map.SetSize(Width/ScaleFactor,Height/ScaleFactor,TRUE);
|
Width=TileLayerMinWidth+(Width-TileLayerMinWidth)/ScaleFactor;
|
||||||
}
|
Height=TileLayerMinHeight+(Height-TileLayerMinHeight)/ScaleFactor;
|
||||||
else
|
|
||||||
{
|
|
||||||
Map.SetSize(Width,Height,TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Width<TileLayerMinWidth) Width=TileLayerMinWidth;
|
||||||
|
if (Height<TileLayerMinHeight) Height=TileLayerMinHeight;
|
||||||
|
|
||||||
|
Map.SetSize(Width,Height,TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -103,11 +105,33 @@ void CLayerTile::Save(CFile *File)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::Resize(int Width,int Height)
|
void CLayerTile::CheckLayerSize(int Width,int Height)
|
||||||
{
|
{
|
||||||
if (!ResizeFlag) return; // Its a fixed size, so DONT DO IT!
|
if (Resize(Width,Height))
|
||||||
|
{
|
||||||
|
CString mexstr;
|
||||||
|
mexstr.Format("%s Layer Resized to Correct Size\nPlease re-save\n", GetName());
|
||||||
|
AfxMessageBox(mexstr,MB_OK | MB_ICONEXCLAMATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Map.Resize(Width/ScaleFactor,Height/ScaleFactor);
|
/*****************************************************************************/
|
||||||
|
BOOL CLayerTile::Resize(int Width,int Height)
|
||||||
|
{
|
||||||
|
if (!ResizeFlag) return(FALSE); // Its a fixed size, so DONT DO IT!
|
||||||
|
|
||||||
|
int ThisWidth=Map.GetWidth();
|
||||||
|
int ThisHeight=Map.GetHeight();
|
||||||
|
Width=TileLayerMinWidth+(Width-TileLayerMinWidth)/ScaleFactor;
|
||||||
|
Height=TileLayerMinHeight+(Height-TileLayerMinHeight)/ScaleFactor;
|
||||||
|
|
||||||
|
if (ThisWidth!=Width || ThisHeight!=Height)
|
||||||
|
{
|
||||||
|
Map.Resize(Width,Height);
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -202,12 +226,8 @@ float OverVal=0.5;
|
|||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(ThisCam.x,ThisCam.y,ThisCam.z);
|
glTranslatef(ThisCam.x,ThisCam.y,ThisCam.z);
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
#ifdef UseLighting
|
|
||||||
glNormal3f( 1,1,1);
|
|
||||||
#endif
|
|
||||||
if (Active)
|
if (Active)
|
||||||
glColor3ub(255,255,255);
|
glColor3ub(255,255,255);
|
||||||
else
|
else
|
||||||
@ -225,7 +245,6 @@ float OverVal=0.5;
|
|||||||
glVertex3f( XLoop, -Height+1-OverVal, 0);
|
glVertex3f( XLoop, -Height+1-OverVal, 0);
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,5 +509,5 @@ BOOL CLayerTile::Paint(CMap &Blk,CPoint &CursorPos)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::Export(CCore *Core,CExport &Exp)
|
void CLayerTile::Export(CCore *Core,CExport &Exp)
|
||||||
{
|
{
|
||||||
Exp.ExportLayerTile(Core,GetName(),Map);
|
Exp.ExportLayerTile(Core,GetName(),SubType,Map);
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
enum TileLayerEnum
|
enum TileLayerEnum
|
||||||
{
|
{
|
||||||
TileLayerDefaultWidth=30,
|
TileLayerMinWidth=32,
|
||||||
TileLayerDefaultHeight=20,
|
TileLayerMinHeight=22,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -59,10 +59,11 @@ public:
|
|||||||
|
|
||||||
int GetWidth() {return(Map.GetWidth());}
|
int GetWidth() {return(Map.GetWidth());}
|
||||||
int GetHeight() {return(Map.GetHeight());}
|
int GetHeight() {return(Map.GetHeight());}
|
||||||
void Resize(int Width,int Height);
|
BOOL Resize(int Width,int Height);
|
||||||
|
|
||||||
void Load(CFile *File,float Version);
|
void Load(CFile *File,float Version);
|
||||||
void Save(CFile *File);
|
void Save(CFile *File);
|
||||||
|
void CheckLayerSize(int Width,int Height);
|
||||||
|
|
||||||
void Export(CCore *Core,CExport &Exp);
|
void Export(CCore *Core,CExport &Exp);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[General Info]
|
[General Info]
|
||||||
Version=1
|
Version=1
|
||||||
LastClass=CLayerTileGUI
|
LastClass=CNewMapGUI
|
||||||
LastTemplate=CDialog
|
LastTemplate=CDialog
|
||||||
NewFileInclude1=#include "stdafx.h"
|
NewFileInclude1=#include "stdafx.h"
|
||||||
NewFileInclude2=#include "mapedit.h"
|
NewFileInclude2=#include "mapedit.h"
|
||||||
@ -18,21 +18,21 @@ Class6=CMapEditDoc
|
|||||||
Class7=CMapEditView
|
Class7=CMapEditView
|
||||||
|
|
||||||
ResourceCount=11
|
ResourceCount=11
|
||||||
Resource1=IDD_ABOUTBOX (English (U.S.))
|
Resource1=IDD_LAYER_LIST_DIALOG
|
||||||
Resource2=IDR_MAINFRAME (English (U.S.))
|
Resource2=IDD_MULTIBAR (English (U.S.))
|
||||||
Resource3=IDD_LAYER_LIST_DIALOG
|
Resource3=IDD_MAPSIZE
|
||||||
Resource4=IDD_DIALOGBAR (English (U.S.))
|
Resource4=IDD_DIALOGBAR (English (U.S.))
|
||||||
Resource5=IDD_MAPSIZE
|
Resource5=IDR_TOOLBAR (English (U.S.))
|
||||||
Class8=CMultiBar
|
Class8=CMultiBar
|
||||||
Resource6=IDR_TOOLBAR (English (U.S.))
|
Resource6=IDD_ABOUTBOX (English (U.S.))
|
||||||
Resource7=IDR_MAPEDITYPE (English (U.S.))
|
Resource7=IDR_MAPEDITYPE (English (U.S.))
|
||||||
Class9=CLayerList
|
Class9=CLayerList
|
||||||
Class10=CMapSizeDlg
|
Class10=CMapSizeDlg
|
||||||
Resource8=IDD_LAYERTILE_GUI
|
Resource8=IDD_NEW_LAYER
|
||||||
Class11=CGfxToolBar
|
Class11=CGfxToolBar
|
||||||
Class12=CLayerTileGUI
|
Class12=CLayerTileGUI
|
||||||
Resource9=IDD_MULTIBAR (English (U.S.))
|
Resource9=IDD_LAYERTILE_GUI
|
||||||
Resource10=IDD_NEW_LAYER
|
Resource10=IDR_MAINFRAME (English (U.S.))
|
||||||
Class13=CNewMapGUI
|
Class13=CNewMapGUI
|
||||||
Resource11=IDD_NEWMAP
|
Resource11=IDD_NEWMAP
|
||||||
|
|
||||||
@ -305,6 +305,6 @@ HeaderFile=NewMapGUI.h
|
|||||||
ImplementationFile=NewMapGUI.cpp
|
ImplementationFile=NewMapGUI.cpp
|
||||||
BaseClass=CDialog
|
BaseClass=CDialog
|
||||||
Filter=D
|
Filter=D
|
||||||
LastObject=CNewMapGUI
|
LastObject=IDC_MAPSIZE_WIDTH
|
||||||
VirtualFilter=dWC
|
VirtualFilter=dWC
|
||||||
|
|
||||||
|
@ -131,6 +131,18 @@ SOURCE=.\ExportAGB.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ExportPSX.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ExportPSX.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ExportPSXHdr.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\Quantize.cpp
|
SOURCE=.\Quantize.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@ -244,6 +256,10 @@ SOURCE=.\GLEnabledView.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\List.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\MainFrm.h
|
SOURCE=.\MainFrm.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@ -368,9 +384,5 @@ SOURCE=.\NewMapGUI.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# End Group
|
# End Group
|
||||||
# End Group
|
# End Group
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=".\!ToDo.txt"
|
|
||||||
# End Source File
|
|
||||||
# End Target
|
# End Target
|
||||||
# End Project
|
# End Project
|
||||||
|
@ -34,6 +34,18 @@ Package=<4>
|
|||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
Project: "TexGrab"=..\TexGrab\texgrab.dsp - Package Owner=<4>
|
||||||
|
|
||||||
|
Package=<5>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
Package=<4>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
Global:
|
Global:
|
||||||
|
|
||||||
Package=<5>
|
Package=<5>
|
||||||
|
@ -198,8 +198,8 @@ void CMapEditDoc::SetLayer(int Layer)
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
void CMapEditDoc::OnExportAgb()
|
void CMapEditDoc::OnExportAgb()
|
||||||
{
|
{
|
||||||
char BASED_CODE AGBFilter[]= "AGB Data Type (*.c)|*.c|All Files (*.*)|*.*||";
|
char BASED_CODE Filter[]= "AGB Data Type (*.c)|*.c|All Files (*.*)|*.*||";
|
||||||
CFileDialog Dlg(FALSE,"*.c",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,AGBFilter);
|
CFileDialog Dlg(FALSE,"*.c",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,Filter);
|
||||||
|
|
||||||
if (Dlg.DoModal()!=IDOK) return;
|
if (Dlg.DoModal()!=IDOK) return;
|
||||||
|
|
||||||
@ -213,7 +213,15 @@ char Filename[256];
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
void CMapEditDoc::OnExportPsx()
|
void CMapEditDoc::OnExportPsx()
|
||||||
{
|
{
|
||||||
|
char BASED_CODE Filter[]= "PSX Data Type (*.PME)|*.Pme|All Files (*.*)|*.*||";
|
||||||
|
CFileDialog Dlg(FALSE,"*.pme",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,Filter);
|
||||||
|
|
||||||
|
if (Dlg.DoModal()!=IDOK) return;
|
||||||
|
|
||||||
|
char Filename[256];
|
||||||
|
sprintf(Filename,"%s",Dlg.GetPathName());
|
||||||
|
|
||||||
|
Core.ExportAGB(Filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
|
@ -70,17 +70,11 @@ void CMapEditView::VideoMode(ColorsNumber & c, ZAccuracy & z, BOOL & dbuf)
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
void CMapEditView::OnCreateGL()
|
void CMapEditView::OnCreateGL()
|
||||||
{
|
{
|
||||||
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
|
|
||||||
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
|
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Background Color
|
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Background Color
|
||||||
glClearDepth(1.0f); // Depth Buffer Setup
|
glClearDepth(1.0f); // Depth Buffer Setup
|
||||||
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
||||||
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
|
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
|
||||||
#ifdef UseLighting
|
|
||||||
glEnable(GL_LIGHT0); // Quick And Dirty Lighting (Assumes Light0 Is SetUp)
|
|
||||||
glEnable(GL_LIGHTING); // Enable Lighting
|
|
||||||
glEnable(GL_COLOR_MATERIAL); // Enable Material Coloring
|
|
||||||
#endif
|
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
|
||||||
glEnable(GL_BLEND); // Enable Alpha Channel
|
glEnable(GL_BLEND); // Enable Alpha Channel
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Alpha Blend Style
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Alpha Blend Style
|
||||||
|
@ -16,63 +16,44 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int CTexCache::GetTexIdx(char *Name,int Flags)
|
int CTexCache::GetTexIdx(char *Filename,int Flags)
|
||||||
{
|
{
|
||||||
int ListSize=TexList.size();
|
sTex Tex;
|
||||||
|
strcpy(Tex.Filename,Filename);
|
||||||
for (int Count=0;Count<ListSize;Count++)
|
Tex.Flags=Flags;
|
||||||
{
|
return(TexList.Find(Tex));
|
||||||
if (strcmp(Name,TexList[Count].Name)==0 && TexList[Count].Flags==Flags)
|
|
||||||
{
|
|
||||||
return(Count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int CTexCache::ProcessTexture(char *TexName,char *Path,int Flags,sRGBData *RGBData)
|
// Checks loaded files for dups, assumes all passed RGB is unique
|
||||||
|
int CTexCache::ProcessTexture(char *Filename,int Flags,sRGBData *RGBData)
|
||||||
{
|
{
|
||||||
int ListSize=TexList.size();
|
int ListSize=TexList.size();
|
||||||
int Idx;
|
|
||||||
char Name[_MAX_FNAME];
|
|
||||||
|
|
||||||
_splitpath(TexName,0,0,Name,0);
|
|
||||||
|
|
||||||
// Check if Tex exists
|
|
||||||
/* for (int Count=0;Count<ListSize;Count++)
|
|
||||||
{
|
|
||||||
if (strcmp(Name,TexList[Count].Name)==0 && TexList[Count].Flags==Flags)
|
|
||||||
{
|
|
||||||
return(Count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
Idx=GetTexIdx(Name,Flags);
|
|
||||||
if (Idx!=-1) return(Idx);
|
|
||||||
|
|
||||||
sTex NewTex;
|
sTex NewTex;
|
||||||
sRGBData ThisRGB;
|
sRGBData ThisRGB;
|
||||||
|
|
||||||
strcpy(NewTex.Name,Name);
|
strcpy(NewTex.Filename,Filename);
|
||||||
strcpy(NewTex.Path,Path);
|
NewTex.Flags=Flags;
|
||||||
|
|
||||||
NewTex.Flags=Flags;
|
NewTex.Flags=Flags;
|
||||||
|
|
||||||
if (!RGBData) // Need to load file
|
if (!RGBData) // Need to load file
|
||||||
{
|
{
|
||||||
char Filename[_MAX_PATH];
|
int Idx=GetTexIdx(NewTex); // Is already loaded?
|
||||||
|
if (Idx!=-1) return(Idx);
|
||||||
sprintf(Filename,"%s%s.Bmp",Path,Name);
|
// sprintf(NewTex.Filename,"%s%s",Path,TexName);
|
||||||
TRACE1("Loading Texture %s\n",Filename);
|
TRACE1("Loading Texture %s\n",NewTex.Filename);
|
||||||
LoadBMP(Filename,ThisRGB);
|
LoadBMP(NewTex.Filename,ThisRGB);
|
||||||
RGBData=&ThisRGB;
|
RGBData=&ThisRGB;
|
||||||
LoadTex(NewTex,RGBData);
|
LoadTex(NewTex,RGBData);
|
||||||
FreeBMP(ThisRGB);
|
FreeBMP(ThisRGB);
|
||||||
|
NewTex.Loaded=TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LoadTex(NewTex,RGBData);
|
LoadTex(NewTex,RGBData);
|
||||||
|
NewTex.Loaded=FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
TexList.push_back(NewTex);
|
TexList.push_back(NewTex);
|
||||||
@ -82,6 +63,20 @@ sRGBData ThisRGB;
|
|||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
/**************************************************************************************/
|
||||||
|
const int TexAlignTable[]={1,2,4,8,16,32,64,128,256};
|
||||||
|
const int TexAlignTableSize=sizeof(TexAlignTable)/sizeof(int);
|
||||||
|
int CTexCache::AlignSize(int Size)
|
||||||
|
{
|
||||||
|
for (int i=0;i<TexAlignTableSize-1; i++)
|
||||||
|
{
|
||||||
|
if (Size>TexAlignTable[i] && Size<TexAlignTable[i+1]) return(TexAlignTable[i+1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(Size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
void CTexCache::LoadBMP(char *Filename,sRGBData &RGBData)
|
void CTexCache::LoadBMP(char *Filename,sRGBData &RGBData)
|
||||||
{
|
{
|
||||||
@ -105,16 +100,7 @@ void CTexCache::FreeBMP(sRGBData &RGBData)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
void CTexCache::LoadTex(sTex &ThisTex,sRGBData *TexData)
|
/*
|
||||||
{
|
|
||||||
std::vector<u8> Buffer;
|
|
||||||
int Width=TexData->Width;
|
|
||||||
int Height=TexData->Height;
|
|
||||||
int Size=Width*Height;
|
|
||||||
// create RGB & alpha texture
|
|
||||||
Buffer.resize(Size*4);
|
|
||||||
u8 *RgbPtr=TexData->RGB;
|
|
||||||
|
|
||||||
for (int i=0;i<Size;i++)
|
for (int i=0;i<Size;i++)
|
||||||
{
|
{
|
||||||
u8 R=*RgbPtr++;
|
u8 R=*RgbPtr++;
|
||||||
@ -131,15 +117,65 @@ u8 *RgbPtr=TexData->RGB;
|
|||||||
Buffer[(i*4)+2]=B;
|
Buffer[(i*4)+2]=B;
|
||||||
Buffer[(i*4)+3]=A;
|
Buffer[(i*4)+3]=A;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
ThisTex.Width=Width;
|
void CTexCache::LoadTex(sTex &ThisTex,sRGBData *TexData)
|
||||||
ThisTex.Height=Height;
|
{
|
||||||
|
std::vector<u8> Buffer;
|
||||||
|
int TexWidth=TexData->Width;
|
||||||
|
int TexHeight=TexData->Height;
|
||||||
|
int GLWidth=AlignSize(TexWidth);
|
||||||
|
int GLHeight=AlignSize(TexHeight);
|
||||||
|
u8 *Src,*Dst;
|
||||||
|
u8 R,G,B,A;
|
||||||
|
// create RGB & alpha texture & ensuse texture is correct size for GL
|
||||||
|
|
||||||
|
Buffer.resize(GLWidth*GLHeight*4);
|
||||||
|
Dst=&Buffer[0];
|
||||||
|
for (int Y=0; Y<GLHeight; Y++)
|
||||||
|
{
|
||||||
|
for (int X=0; X<GLWidth; X++)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (X<=TexWidth && Y<=TexHeight)
|
||||||
|
{
|
||||||
|
Src=(u8*)&TexData->RGB[((Y*TexWidth)+X)*3];
|
||||||
|
R=*Src++;
|
||||||
|
G=*Src++;
|
||||||
|
B=*Src++;
|
||||||
|
A=255;
|
||||||
|
if ((R==BlankRGB.rgbRed && G==BlankRGB.rgbGreen && B==BlankRGB.rgbBlue)) // Create alpha for transparent pixels (flagged with PINK!!)
|
||||||
|
{
|
||||||
|
A=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
R=255;
|
||||||
|
G=0;
|
||||||
|
B=255;
|
||||||
|
A=255;
|
||||||
|
}
|
||||||
|
*Dst++=R;
|
||||||
|
*Dst++=G;
|
||||||
|
*Dst++=B;
|
||||||
|
*Dst++=A;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ThisTex.TexWidth=TexWidth;
|
||||||
|
ThisTex.TexHeight=TexHeight;
|
||||||
|
ThisTex.GLWidth=GLWidth;
|
||||||
|
ThisTex.GLHeight=GLHeight;
|
||||||
|
ThisTex.dW=1.0f/(GLWidth/16);
|
||||||
|
ThisTex.dW=((float)TexWidth/(float)GLWidth)/(GLWidth/16);
|
||||||
|
ThisTex.dH=((float)TexHeight/(float)GLHeight)/(GLHeight/16);
|
||||||
|
|
||||||
glGenTextures(1, &ThisTex.TexID);
|
glGenTextures(1, &ThisTex.TexID);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, ThisTex.TexID);
|
glBindTexture(GL_TEXTURE_2D, ThisTex.TexID);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, 4, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &Buffer[0]);
|
glTexImage2D(GL_TEXTURE_2D, 0, 4, GLWidth, GLHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, &Buffer[0]);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
@ -148,7 +184,6 @@ u8 *RgbPtr=TexData->RGB;
|
|||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
||||||
void CTexCache::Purge()
|
void CTexCache::Purge()
|
||||||
{
|
{
|
||||||
int ListSize=TexList.size();
|
int ListSize=TexList.size();
|
||||||
@ -161,4 +196,6 @@ int ListSize=TexList.size();
|
|||||||
}
|
}
|
||||||
|
|
||||||
TexList.clear();
|
TexList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************/
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <gl\glut.h>
|
#include <gl\glut.h>
|
||||||
#include <Vector>
|
#include <Vector>
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include "List.h"
|
||||||
|
|
||||||
struct sRGBData
|
struct sRGBData
|
||||||
{
|
{
|
||||||
@ -22,11 +23,16 @@ struct sRGBData
|
|||||||
|
|
||||||
struct sTex
|
struct sTex
|
||||||
{
|
{
|
||||||
char Name[256];
|
char Filename[_MAX_PATH];
|
||||||
char Path[256];
|
// char Name[_MAX_FNAME];
|
||||||
GLuint TexID;
|
GLuint TexID;
|
||||||
int Flags;
|
int Flags;
|
||||||
int Width,Height;
|
int TexWidth,TexHeight;
|
||||||
|
int GLWidth,GLHeight;
|
||||||
|
float dW,dH;
|
||||||
|
BOOL Loaded;
|
||||||
|
|
||||||
|
BOOL operator==(sTex const &v1) {return (!strcmp(Filename,v1.Filename) && Flags==v1.Flags);}
|
||||||
};
|
};
|
||||||
|
|
||||||
const RGBQUAD BlankRGB={255,0,255};
|
const RGBQUAD BlankRGB={255,0,255};
|
||||||
@ -38,20 +44,26 @@ class CTexCache
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int GetTexIdx(char *Name,int Flags);
|
int GetTexIdx(sTex &Tex) {return(TexList.Find(Tex));}
|
||||||
|
int GetTexIdx(char *Filename,int Flags);
|
||||||
|
|
||||||
int ProcessTexture(char *TexName,char *Path,int Flags,sRGBData *RGBData=0);
|
int ProcessTexture(char *Path,int Flags,sRGBData *RGBData=0);
|
||||||
void Purge();
|
void Purge();
|
||||||
|
|
||||||
void LoadBMP(char *Filename,sRGBData &RGBData);
|
void LoadBMP(char *Filename,sRGBData &RGBData);
|
||||||
void FreeBMP(sRGBData &RGBData);
|
void FreeBMP(sRGBData &RGBData);
|
||||||
|
void FixBMP(sRGBData &RGBData);
|
||||||
|
BOOL IsSizeOk(int Size);
|
||||||
|
int AlignSize(int Size);
|
||||||
|
|
||||||
void LoadTex(sTex &ThisTex,sRGBData *TexData);
|
void LoadTex(sTex &ThisTex,sRGBData *TexData);
|
||||||
|
|
||||||
|
|
||||||
sTex &GetTex(int Id) {return(TexList[Id]);}
|
sTex &GetTex(int Id) {return(TexList[Id]);}
|
||||||
GLuint GetTexGLId(int Id) {return(TexList[Id].TexID);}
|
GLuint GetTexGLId(int Id) {return(TexList[Id].TexID);}
|
||||||
|
|
||||||
std::vector<sTex> TexList;
|
|
||||||
|
CList<sTex> TexList;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -350,25 +350,21 @@ void CTileSet::Load(CCore *Core)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void CTileSet::Load2d(CCore *Core)
|
void CTileSet::Load2d(CCore *Core)
|
||||||
{
|
{
|
||||||
char Filename[_MAX_PATH];
|
char Filename[_MAX_PATH];
|
||||||
CTexCache &TexCache=Core->GetTexCache();
|
CTexCache &TexCache=Core->GetTexCache();
|
||||||
sRGBData ThisBmp;
|
|
||||||
sRGBData NewTex;
|
|
||||||
|
|
||||||
_makepath( Filename, Drive, Path, Name, Ext);
|
_makepath( Filename, Drive, Path, Name, Ext);
|
||||||
TexCache.LoadBMP(Filename,ThisBmp);
|
|
||||||
|
|
||||||
int Width=ThisBmp.Width/16;
|
int TexID=TexCache.ProcessTexture(Filename,0);
|
||||||
int Height=ThisBmp.Height/16;
|
sTex &ThisTex=TexCache.GetTex(TexID);
|
||||||
u8 Buffer[16*16*3];
|
|
||||||
|
|
||||||
NewTex.Width=16;
|
int Width=ThisTex.TexWidth/16;
|
||||||
NewTex.Height=16;
|
int Height=ThisTex.TexHeight/16;
|
||||||
NewTex.RGB=Buffer;
|
|
||||||
|
|
||||||
TRACE2("Load 2d TileBank (%i,%i)\n",Width,Height);
|
TRACE3("Load 2d TileBank %s (%i,%i)\n",Filename,Width,Height);
|
||||||
|
|
||||||
Tile.push_back(CTile(0)); // Insert Blank
|
Tile.push_back(CTile(0)); // Insert Blank
|
||||||
|
|
||||||
@ -376,17 +372,10 @@ u8 Buffer[16*16*3];
|
|||||||
{
|
{
|
||||||
for (int X=0; X<Width; X++)
|
for (int X=0; X<Width; X++)
|
||||||
{
|
{
|
||||||
char Name[256];
|
Tile.push_back(CTile(Core,this,TexID,X,Y));
|
||||||
Create16x16Tile(ThisBmp,Buffer,X,(Height-1)-Y);
|
|
||||||
sprintf(Name,"_2d_%s_%i_%i",GetName(),SetNumber,X+(Y*Width));
|
|
||||||
int TexID=TexCache.ProcessTexture(Name,GetPath(),0,&NewTex);
|
|
||||||
Tile.push_back(CTile(Core,this,TexID));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TexCache.FreeBMP(ThisBmp);
|
|
||||||
TileBrowserWidth=Width;
|
TileBrowserWidth=Width;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -458,6 +447,20 @@ CPoint CTileSet::GetTilePos(int ID)
|
|||||||
return(IDToPoint(ID-1,TileBrowserWidth));
|
return(IDToPoint(ID-1,TileBrowserWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
BOOL CTileSet::IsTileValid(int No)
|
||||||
|
{
|
||||||
|
ASSERT(No<Tile.size());
|
||||||
|
return(Tile[No].IsValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
BOOL CTileSet::IsTileValidGB(int No)
|
||||||
|
{
|
||||||
|
ASSERT(No<Tile.size());
|
||||||
|
return(Tile[No].IsValidGB());
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CTileSet::Render(Vec &CamPos,CMap &LBrush,CMap &RBrush,BOOL Render3d)
|
void CTileSet::Render(Vec &CamPos,CMap &LBrush,CMap &RBrush,BOOL Render3d)
|
||||||
{
|
{
|
||||||
@ -476,11 +479,6 @@ BOOL ValidTile=TRUE;
|
|||||||
{
|
{
|
||||||
CPoint Pos=GetTilePos(TileID);
|
CPoint Pos=GetTilePos(TileID);
|
||||||
|
|
||||||
// if (TileID==0)
|
|
||||||
// Pos=CPoint(-1,-1);
|
|
||||||
// else
|
|
||||||
// Pos=IDToPoint(TileID-1,TileBrowserWidth);
|
|
||||||
|
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(CamPos.x+Pos.x*(1+TileBrowserGap),CamPos.y-Pos.y*(1+TileBrowserGap),CamPos.z);
|
glTranslatef(CamPos.x+Pos.x*(1+TileBrowserGap),CamPos.y-Pos.y*(1+TileBrowserGap),CamPos.z);
|
||||||
@ -501,11 +499,7 @@ BOOL ValidTile=TRUE;
|
|||||||
|
|
||||||
if (SelFlag)
|
if (SelFlag)
|
||||||
{
|
{
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
#ifdef UseLighting
|
|
||||||
glNormal3f( 1,1,1);
|
|
||||||
#endif
|
|
||||||
switch(SelFlag)
|
switch(SelFlag)
|
||||||
{
|
{
|
||||||
case 1: // L
|
case 1: // L
|
||||||
@ -525,16 +519,11 @@ BOOL ValidTile=TRUE;
|
|||||||
}
|
}
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
}
|
}
|
||||||
// Invalid tile?
|
// Invalid tile?
|
||||||
if (!ValidTile)
|
if (!ValidTile)
|
||||||
{
|
{
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
#ifdef UseLighting
|
|
||||||
glNormal3f( 1,1,1);
|
|
||||||
#endif
|
|
||||||
glColor3ub(255,255,255);
|
glColor3ub(255,255,255);
|
||||||
|
|
||||||
glVertex3f( TileBrowserX0,TileBrowserY0,0);
|
glVertex3f( TileBrowserX0,TileBrowserY0,0);
|
||||||
@ -544,9 +533,29 @@ BOOL ValidTile=TRUE;
|
|||||||
glVertex3f( TileBrowserX0,TileBrowserY1,0);
|
glVertex3f( TileBrowserX0,TileBrowserY1,0);
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
}
|
}
|
||||||
|
// Draw Box around bloody Blank so you can see it
|
||||||
|
if (!TileID)
|
||||||
|
{
|
||||||
|
CPoint Pos=GetTilePos(TileID);
|
||||||
|
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glColor3ub(255,255,255);
|
||||||
|
|
||||||
|
glVertex3f( TileBrowserX0,TileBrowserY0,0);
|
||||||
|
glVertex3f( TileBrowserX1,TileBrowserY0,0);
|
||||||
|
|
||||||
|
glVertex3f( TileBrowserX0,TileBrowserY1,0);
|
||||||
|
glVertex3f( TileBrowserX1,TileBrowserY1,0);
|
||||||
|
|
||||||
|
glVertex3f( TileBrowserX0,TileBrowserY0,0);
|
||||||
|
glVertex3f( TileBrowserX0,TileBrowserY1,0);
|
||||||
|
|
||||||
|
glVertex3f( TileBrowserX1,TileBrowserY0,0);
|
||||||
|
glVertex3f( TileBrowserX1,TileBrowserY1,0);
|
||||||
|
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
TileID++;
|
TileID++;
|
||||||
}
|
}
|
||||||
@ -564,14 +573,6 @@ int MaxTile=Tile.size();
|
|||||||
|
|
||||||
if (SelStart==-1)
|
if (SelStart==-1)
|
||||||
{
|
{
|
||||||
// if (CursorPos==0)
|
|
||||||
// {
|
|
||||||
// Start=CPoint(-1,-1);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// Start=IDToPoint(CursorPos-1,TileBrowserWidth);
|
|
||||||
// }
|
|
||||||
Start=GetTilePos(CursorPos);
|
Start=GetTilePos(CursorPos);
|
||||||
End=Start;
|
End=Start;
|
||||||
}
|
}
|
||||||
@ -587,7 +588,6 @@ int MaxTile=Tile.size();
|
|||||||
}
|
}
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
for (int Y=Start.y; Y<=End.y; Y++)
|
for (int Y=Start.y; Y<=End.y; Y++)
|
||||||
{
|
{
|
||||||
@ -597,44 +597,30 @@ int MaxTile=Tile.size();
|
|||||||
glTranslatef(CamPos.x+X*(1+TileBrowserGap),CamPos.y-Y*(1+TileBrowserGap),CamPos.z);
|
glTranslatef(CamPos.x+X*(1+TileBrowserGap),CamPos.y-Y*(1+TileBrowserGap),CamPos.z);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
#ifdef UseLighting
|
|
||||||
glNormal3f( 1,1,1);
|
|
||||||
#endif
|
|
||||||
glColor4f(1,1,0,0.5);
|
glColor4f(1,1,0,0.5);
|
||||||
BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0);
|
BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CTileSet::RenderGrid(Vec &CamPos)
|
void CTileSet::RenderGrid(Vec &CamPos)
|
||||||
{
|
{
|
||||||
int ListSize=Tile.size();
|
int ListSize=Tile.size();
|
||||||
int TileID=0;
|
int TileID=1; // Dont bother with blank, its sorted
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
while(TileID!=ListSize)
|
while(TileID!=ListSize)
|
||||||
{
|
{
|
||||||
CPoint Pos=GetTilePos(TileID);
|
CPoint Pos=GetTilePos(TileID);
|
||||||
|
|
||||||
// if (TileID==0)
|
|
||||||
// Pos=CPoint(-1,-1);
|
|
||||||
// else
|
|
||||||
// Pos=IDToPoint(TileID-1,TileBrowserWidth);
|
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(CamPos.x+Pos.x*(1+TileBrowserGap),CamPos.y-Pos.y*(1+TileBrowserGap),CamPos.z);
|
glTranslatef(CamPos.x+Pos.x*(1+TileBrowserGap),CamPos.y-Pos.y*(1+TileBrowserGap),CamPos.z);
|
||||||
|
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
#ifdef UseLighting
|
|
||||||
glNormal3f( 1,1,1);
|
|
||||||
#endif
|
|
||||||
glColor3ub(255,255,255);
|
glColor3ub(255,255,255);
|
||||||
|
|
||||||
glVertex3f( TileBrowserX0,TileBrowserY0,0);
|
glVertex3f( TileBrowserX0,TileBrowserY0,0);
|
||||||
@ -653,7 +639,6 @@ int TileID=0;
|
|||||||
|
|
||||||
TileID++;
|
TileID++;
|
||||||
}
|
}
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -684,11 +669,6 @@ int TileID=0;
|
|||||||
{
|
{
|
||||||
CPoint Pos=GetTilePos(TileID);
|
CPoint Pos=GetTilePos(TileID);
|
||||||
|
|
||||||
// if (TileID==0)
|
|
||||||
// Pos=CPoint(-1,-1);
|
|
||||||
// else
|
|
||||||
// Pos=IDToPoint(TileID-1,TileBrowserWidth);
|
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(CamPos.x+Pos.x*(1+TileBrowserGap),CamPos.y-Pos.y*(1+TileBrowserGap),CamPos.z);
|
glTranslatef(CamPos.x+Pos.x*(1+TileBrowserGap),CamPos.y-Pos.y*(1+TileBrowserGap),CamPos.z);
|
||||||
|
|
||||||
|
@ -116,8 +116,8 @@ public:
|
|||||||
void RenderBrush(Vec &CamPos,CMap &LBrush,CMap &RBrush);
|
void RenderBrush(Vec &CamPos,CMap &LBrush,CMap &RBrush);
|
||||||
void RenderGrid(Vec &CamPos);
|
void RenderGrid(Vec &CamPos);
|
||||||
int GetTileBrowserWidth() {return(TileBrowserWidth);}
|
int GetTileBrowserWidth() {return(TileBrowserWidth);}
|
||||||
BOOL IsTileValid(int No) {return(Tile[No].IsValid());}
|
BOOL IsTileValid(int No);
|
||||||
BOOL IsTileValidGB(int No) {return(Tile[No].IsValidGB());}
|
BOOL IsTileValidGB(int No);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -126,7 +126,8 @@ private:
|
|||||||
|
|
||||||
char Drive[_MAX_DRIVE],Path[_MAX_DIR],Name[_MAX_FNAME],Ext[_MAX_EXT];
|
char Drive[_MAX_DRIVE],Path[_MAX_DIR],Name[_MAX_FNAME],Ext[_MAX_EXT];
|
||||||
int SetNumber;
|
int SetNumber;
|
||||||
std::vector<CTile> Tile;
|
// std::vector<CTile> Tile;
|
||||||
|
CList<CTile> Tile;
|
||||||
BOOL Loaded;
|
BOOL Loaded;
|
||||||
int TileBrowserWidth;
|
int TileBrowserWidth;
|
||||||
};
|
};
|
||||||
|
@ -33,49 +33,31 @@ char szBuf[256];
|
|||||||
void BuildGLBox(float XMin,float XMax,float YMin,float YMax,float ZMin,float ZMax)
|
void BuildGLBox(float XMin,float XMax,float YMin,float YMax,float ZMin,float ZMax)
|
||||||
{
|
{
|
||||||
// Bottom Face
|
// Bottom Face
|
||||||
#ifdef UseLighting
|
|
||||||
glNormal3f( 0.0f,-1.0f, 0.0f);
|
|
||||||
#endif
|
|
||||||
glVertex3f( XMin, YMin, ZMin);
|
glVertex3f( XMin, YMin, ZMin);
|
||||||
glVertex3f( XMax, YMin, ZMin);
|
glVertex3f( XMax, YMin, ZMin);
|
||||||
glVertex3f( XMax, YMin, ZMax);
|
glVertex3f( XMax, YMin, ZMax);
|
||||||
glVertex3f( XMin, YMin, ZMax);
|
glVertex3f( XMin, YMin, ZMax);
|
||||||
// Front Face
|
// Front Face
|
||||||
#ifdef UseLighting
|
|
||||||
glNormal3f( 0.0f, 0.0f, 1.0f);
|
|
||||||
#endif
|
|
||||||
glVertex3f( XMin, YMin, ZMax);
|
glVertex3f( XMin, YMin, ZMax);
|
||||||
glVertex3f( XMax, YMin, ZMax);
|
glVertex3f( XMax, YMin, ZMax);
|
||||||
glVertex3f( XMax, YMax, ZMax);
|
glVertex3f( XMax, YMax, ZMax);
|
||||||
glVertex3f( XMin, YMax, ZMax);
|
glVertex3f( XMin, YMax, ZMax);
|
||||||
// Back Face
|
// Back Face
|
||||||
#ifdef UseLighting
|
|
||||||
glNormal3f( 0.0f, 0.0f,-1.0f);
|
|
||||||
#endif
|
|
||||||
glVertex3f( XMin, YMin, ZMin);
|
glVertex3f( XMin, YMin, ZMin);
|
||||||
glVertex3f( XMin, YMax, ZMin);
|
glVertex3f( XMin, YMax, ZMin);
|
||||||
glVertex3f( XMax, YMax, ZMin);
|
glVertex3f( XMax, YMax, ZMin);
|
||||||
glVertex3f( XMax, YMin, ZMin);
|
glVertex3f( XMax, YMin, ZMin);
|
||||||
// Right face
|
// Right face
|
||||||
#ifdef UseLighting
|
|
||||||
glNormal3f( 1.0f, 0.0f, 0.0f);
|
|
||||||
#endif
|
|
||||||
glVertex3f( XMax, YMin, ZMin);
|
glVertex3f( XMax, YMin, ZMin);
|
||||||
glVertex3f( XMax, YMax, ZMin);
|
glVertex3f( XMax, YMax, ZMin);
|
||||||
glVertex3f( XMax, YMax, ZMax);
|
glVertex3f( XMax, YMax, ZMax);
|
||||||
glVertex3f( XMax, YMin, ZMax);
|
glVertex3f( XMax, YMin, ZMax);
|
||||||
// Left Face
|
// Left Face
|
||||||
#ifdef UseLighting
|
|
||||||
glNormal3f(-1.0f, 0.0f, 0.0f);
|
|
||||||
#endif
|
|
||||||
glVertex3f( XMin, YMin, ZMin);
|
glVertex3f( XMin, YMin, ZMin);
|
||||||
glVertex3f( XMin, YMin, ZMax);
|
glVertex3f( XMin, YMin, ZMax);
|
||||||
glVertex3f( XMin, YMax, ZMax);
|
glVertex3f( XMin, YMax, ZMax);
|
||||||
glVertex3f( XMin, YMax, ZMin);
|
glVertex3f( XMin, YMax, ZMin);
|
||||||
// Top Face
|
// Top Face
|
||||||
#ifdef UseLighting
|
|
||||||
glNormal3f( 0.0f, 1.0f, 0.0f);
|
|
||||||
#endif
|
|
||||||
glVertex3f( XMin, YMax, ZMin);
|
glVertex3f( XMin, YMax, ZMin);
|
||||||
glVertex3f( XMin, YMax, ZMax);
|
glVertex3f( XMin, YMax, ZMax);
|
||||||
glVertex3f( XMax, YMax, ZMax);
|
glVertex3f( XMax, YMax, ZMax);
|
||||||
@ -120,9 +102,6 @@ void BuildGLBoxNoNormals(float XMin,float XMax,float YMin,float YMax,float ZMin,
|
|||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
void BuildGLQuad(float XMin,float XMax,float YMin,float YMax,float Z)
|
void BuildGLQuad(float XMin,float XMax,float YMin,float YMax,float Z)
|
||||||
{
|
{
|
||||||
#ifdef UseLighting
|
|
||||||
glNormal3f( 0.0f, 0.0f, 1.0f);
|
|
||||||
#endif
|
|
||||||
glVertex3f( XMin, YMin, Z);
|
glVertex3f( XMin, YMin, Z);
|
||||||
glVertex3f( XMax, YMin, Z);
|
glVertex3f( XMax, YMin, Z);
|
||||||
glVertex3f( XMax, YMax, Z);
|
glVertex3f( XMax, YMax, Z);
|
||||||
|
Loading…
Reference in New Issue
Block a user