This commit is contained in:
Daveo 2001-02-07 21:31:31 +00:00
parent a54bb632ae
commit acc0107240
9 changed files with 59 additions and 42 deletions

View File

@ -72,7 +72,8 @@ int Width,Height;
// Create Tile Layers // Create Tile Layers
AddLayer(LAYER_TYPE_TILE,LAYERTILE_ACTION, Width, Height); AddLayer(LAYER_TYPE_TILE,LAYERTILE_ACTION, Width, Height);
AddLayer(LAYER_TYPE_COLLISION,-1, Width, Height); AddLayer(LAYER_TYPE_TILE,LAYERTILE_SCRATCH, Width, Height);
// AddLayer(LAYER_TYPE_COLLISION,-1, Width, Height);
ActiveLayer=FindActionLayer(); ActiveLayer=FindActionLayer();
MapCam.Zero(); MapCam.Zero();
@ -208,15 +209,28 @@ void CCore::RenderLayers(CMapEditView *View)
{ {
Vector3 &ThisCam=GetCam(); Vector3 &ThisCam=GetCam();
int ListSize=Layer.size(); int ListSize=Layer.size();
int StartLayer,EndLayer;
for (int i=0;i<ListSize;i++)
StartLayer=0;
EndLayer=ListSize;
while (Layer[StartLayer]->IsUnique()) StartLayer++;
if (Layer[ActiveLayer]->IsUnique())
{
StartLayer=ActiveLayer;
EndLayer=StartLayer+1;
}
for (int i=StartLayer; i<EndLayer; i++)
{ {
if (Layer[i]->IsVisible()) if (Layer[i]->IsVisible())
{ {
Layer[i]->Render(this,ThisCam,Is3dFlag); Layer[i]->Render(this,ThisCam,Is3dFlag);
if (GridFlag) Layer[i]->RenderGrid(this,ThisCam,i==ActiveLayer); if (GridFlag) Layer[i]->RenderGrid(this,ThisCam,i==ActiveLayer);
} }
} }
Layer[ActiveLayer]->RenderCursor(this,ThisCam,Is3dFlag); Layer[ActiveLayer]->RenderCursor(this,ThisCam,Is3dFlag);
@ -469,11 +483,8 @@ CLayer *Layer;
ASSERT(!"AddLayer - Invalid Layer Type"); ASSERT(!"AddLayer - Invalid Layer Type");
break; break;
} }
} }
/*****************************************************************************/ /*****************************************************************************/
void CCore::AddLayer(int CurrentLayer) void CCore::AddLayer(int CurrentLayer)
{ {
@ -482,7 +493,6 @@ CAddLayerDlg Dlg;
int NewLayerId=0; int NewLayerId=0;
int Sel; int Sel;
// Build Unused List // Build Unused List
Dlg.Sel=&Sel; Dlg.Sel=&Sel;
Sel=0; Sel=0;
@ -530,12 +540,12 @@ void CCore::DeleteLayer(int CurrentLayer)
/*****************************************************************************/ /*****************************************************************************/
void CCore::UpdateGrid(CMapEditView *View,BOOL Toggle) void CCore::UpdateGrid(CMapEditView *View,BOOL Toggle)
{ {
//CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd(); CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
//CToolBar *ToolBar=Frm->GetToolBar(); CToolBar *ToolBar=Frm->GetToolBar();
if (Toggle) GridFlag=!GridFlag; if (Toggle) GridFlag=!GridFlag;
// ToolBar->GetToolBarCtrl().PressButton(ID_TOOLBAR_GRID,GridFlag); ToolBar->GetToolBarCtrl().PressButton(ID_TOOLBAR_GRID,GridFlag);
UpdateView(View); UpdateView(View);
} }
@ -809,11 +819,14 @@ char ExportName[256];
SetFileExt(Filename,ExportName,"MEX"); SetFileExt(Filename,ExportName,"MEX");
CExport Exp(ExportName,LayerCount); CExport Exp(ExportName);
for (int i=0;i<LayerCount;i++) for (int i=0;i<LayerCount;i++)
{ {
Layer[i]->Export(this,Exp); if (Layer[i]->CanExport())
{
Layer[i]->Export(this,Exp);
}
} }
Exp.ExportTiles(this); Exp.ExportTiles(this);

View File

@ -23,31 +23,31 @@
/*****************************************************************************/ /*****************************************************************************/
/*****************************************************************************/ /*****************************************************************************/
/*****************************************************************************/ /*****************************************************************************/
CExport::CExport(char *Filename,int _LayerCount) CExport::CExport(char *Filename)
{ {
LayerCount=_LayerCount;
File=fopen(Filename,"wb"); File=fopen(Filename,"wb");
// Write Dummy File Header // Write Dummy File Header
fwrite(&FileHdr,sizeof(sExpFileHdr),1,File); fwrite(&FileHdr,sizeof(sExpFileHdr),1,File);
for (int i=0;i<LayerCount; i++) fwrite(&LayerCount,sizeof(int),1,File); // for (int i=0;i<EXPORT_LAYER_COUNT; i++) fwrite(&LayerCount,sizeof(int),1,File);
} }
/*****************************************************************************/ /*****************************************************************************/
CExport::~CExport() CExport::~CExport()
{ {
ASSERT(LayerCount==LayerOfs.size()); int LayerCount=LayerOfs.size();
FileHdr.LayerCount=LayerCount; FileHdr.LayerCount=LayerCount;
// ReWrite Main Header
fseek(File,0,0);
fwrite(&FileHdr,sizeof(sExpFileHdr),1,File);
for (int i=0;i<LayerCount; i++) for (int i=0;i<LayerCount; i++)
{ {
TRACE1("LayerOfs %i\n",LayerOfs[i]); FileHdr.LayerOfs[i]=LayerOfs[i];
fwrite(&LayerOfs[i],sizeof(int),1,File);
} }
// ReWrite Main Header
fseek(File,0,0);
fwrite(&FileHdr,sizeof(sExpFileHdr),1,File);
fclose(File); fclose(File);
} }

View File

@ -22,7 +22,7 @@ class CTile;
class CExport class CExport
{ {
public: public:
CExport(char *Filename,int LayerCount); CExport(char *Filename);
~CExport(); ~CExport();
void ExportLayerTile(CCore *Core,char *LayerName,int SubType,CMap &Map); void ExportLayerTile(CCore *Core,char *LayerName,int SubType,CMap &Map);
@ -38,7 +38,7 @@ protected:
sExpFileHdr FileHdr; sExpFileHdr FileHdr;
int LayerCount; // int LayerCount;
CList<int> LayerOfs; CList<int> LayerOfs;
CList<sExpTri> TriList; CList<sExpTri> TriList;

View File

@ -12,6 +12,7 @@
#include <List.h> #include <List.h>
/*****************************************************************************/ /*****************************************************************************/
#define EXPORT_LAYER_COUNT 8
struct sExpFileHdr struct sExpFileHdr
{ {
int TileCount; int TileCount;
@ -24,7 +25,7 @@ struct sExpFileHdr
int TexNameCount; int TexNameCount;
int TexNameOfs; int TexNameOfs;
int LayerCount; int LayerCount;
// int LayerOfs[n] int LayerOfs[EXPORT_LAYER_COUNT];
}; };
/*****************************************************************************/ /*****************************************************************************/

View File

@ -16,12 +16,12 @@
/*****************************************************************************/ /*****************************************************************************/
sLayerInfoTable CLayer::InfoTable[]= sLayerInfoTable CLayer::InfoTable[]=
{ {
//Type SubType Name delete?Scale 3d Resizable //Type SubType Name delete?Scale 3d Resizable Export
{LAYER_TYPE_TILE, LAYERTILE_BACK, "Back", true, 4.0f, false, false}, {LAYER_TYPE_TILE, LAYERTILE_SCRATCH, "WorkPad", false, 1.0f, true, false, false,},
{LAYER_TYPE_TILE, LAYERTILE_MID, "Mid", true, 2.0f, false, true}, {LAYER_TYPE_TILE, LAYERTILE_BACK, "Back", true, 4.0f, false, false, true,},
{LAYER_TYPE_TILE, LAYERTILE_ACTION, "Action", false, 1.0f, true, true}, {LAYER_TYPE_TILE, LAYERTILE_MID, "Mid", true, 2.0f, false, true, true,},
{LAYER_TYPE_TILE, LAYERTILE_FORE, "Fore", true, 0.5f, false, true}, {LAYER_TYPE_TILE, LAYERTILE_ACTION, "Action", false, 1.0f, true, true, true,},
{LAYER_TYPE_COLLISION, LAYER_SUBTYPE_NONE, "Collision", true, 1.0f, false, true}, {LAYER_TYPE_COLLISION, LAYER_SUBTYPE_NONE, "Collision", true, 1.0f, false, true, true,},
}; };
int CLayer::InfoTableSize=sizeof(InfoTable)/sizeof(sLayerInfoTable); int CLayer::InfoTableSize=sizeof(InfoTable)/sizeof(sLayerInfoTable);

View File

@ -22,6 +22,7 @@ struct sLayerInfoTable
float ScaleFactor; float ScaleFactor;
bool Render3dFlag; bool Render3dFlag;
bool ResizeFlag; bool ResizeFlag;
bool ExportFlag;
}; };
@ -50,6 +51,8 @@ static int GetLayerIdx(int Type,int SubType);
char *GetName() {return(InfoTable[GetLayerIdx(GetType(),GetSubType())].Name);} char *GetName() {return(InfoTable[GetLayerIdx(GetType(),GetSubType())].Name);}
bool CanDelete() {return(InfoTable[GetLayerIdx(GetType(),GetSubType())].DeleteFlag);} bool CanDelete() {return(InfoTable[GetLayerIdx(GetType(),GetSubType())].DeleteFlag);}
bool CanExport() {return(InfoTable[GetLayerIdx(GetType(),GetSubType())].ExportFlag);}
bool IsUnique() {return(!(InfoTable[GetLayerIdx(GetType(),GetSubType())].ExportFlag));}
virtual void SetVisible(BOOL f) {VisibleFlag=f;} virtual void SetVisible(BOOL f) {VisibleFlag=f;}
virtual BOOL IsVisible() {return(VisibleFlag);} virtual BOOL IsVisible() {return(VisibleFlag);}

View File

@ -23,7 +23,7 @@ enum LAYER_SUBTYPE
LAYERTILE_MID, LAYERTILE_MID,
LAYERTILE_ACTION, LAYERTILE_ACTION,
LAYERTILE_FORE, LAYERTILE_FORE,
LAYERTILE_SCRATCH,
}; };
enum TILE_FLAG enum TILE_FLAG

View File

@ -28,11 +28,6 @@
CLayerTile::CLayerTile(int _SubType,int Width,int Height) CLayerTile::CLayerTile(int _SubType,int Width,int Height)
{ {
SubType=_SubType; SubType=_SubType;
if (SubType==LAYERTILE_BACK) // Back is fixed size
{
Width=32;
Height=32;
}
SetDefaultParams(); SetDefaultParams();
@ -43,6 +38,11 @@ CLayerTile::CLayerTile(int _SubType,int Width,int Height)
Width=TileLayerMinWidth+(Width-TileLayerMinWidth)/ScaleFactor; Width=TileLayerMinWidth+(Width-TileLayerMinWidth)/ScaleFactor;
Height=TileLayerMinHeight+(Height-TileLayerMinHeight)/ScaleFactor; Height=TileLayerMinHeight+(Height-TileLayerMinHeight)/ScaleFactor;
} }
else
{
Width=32;
Height=32;
}
if (Width<TileLayerMinWidth) Width=TileLayerMinWidth; if (Width<TileLayerMinWidth) Width=TileLayerMinWidth;
if (Height<TileLayerMinHeight) Height=TileLayerMinHeight; if (Height<TileLayerMinHeight) Height=TileLayerMinHeight;

View File

@ -211,10 +211,6 @@ SOURCE=.\MapEdit.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\MapEdit.rc
# End Source File
# Begin Source File
SOURCE=.\MapEditDoc.cpp SOURCE=.\MapEditDoc.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -288,6 +284,10 @@ SOURCE=.\res\MapEdit.ico
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\MapEdit.rc
# End Source File
# Begin Source File
SOURCE=.\res\MapEdit.rc2 SOURCE=.\res\MapEdit.rc2
# End Source File # End Source File
# Begin Source File # Begin Source File