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
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();
MapCam.Zero();
@ -208,15 +209,28 @@ void CCore::RenderLayers(CMapEditView *View)
{
Vector3 &ThisCam=GetCam();
int ListSize=Layer.size();
for (int i=0;i<ListSize;i++)
int StartLayer,EndLayer;
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())
{
{
Layer[i]->Render(this,ThisCam,Is3dFlag);
if (GridFlag) Layer[i]->RenderGrid(this,ThisCam,i==ActiveLayer);
}
}
}
Layer[ActiveLayer]->RenderCursor(this,ThisCam,Is3dFlag);
@ -469,11 +483,8 @@ CLayer *Layer;
ASSERT(!"AddLayer - Invalid Layer Type");
break;
}
}
/*****************************************************************************/
void CCore::AddLayer(int CurrentLayer)
{
@ -482,7 +493,6 @@ CAddLayerDlg Dlg;
int NewLayerId=0;
int Sel;
// Build Unused List
Dlg.Sel=&Sel;
Sel=0;
@ -530,12 +540,12 @@ void CCore::DeleteLayer(int CurrentLayer)
/*****************************************************************************/
void CCore::UpdateGrid(CMapEditView *View,BOOL Toggle)
{
//CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
//CToolBar *ToolBar=Frm->GetToolBar();
CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
CToolBar *ToolBar=Frm->GetToolBar();
if (Toggle) GridFlag=!GridFlag;
// ToolBar->GetToolBarCtrl().PressButton(ID_TOOLBAR_GRID,GridFlag);
ToolBar->GetToolBarCtrl().PressButton(ID_TOOLBAR_GRID,GridFlag);
UpdateView(View);
}
@ -809,11 +819,14 @@ char ExportName[256];
SetFileExt(Filename,ExportName,"MEX");
CExport Exp(ExportName,LayerCount);
CExport Exp(ExportName);
for (int i=0;i<LayerCount;i++)
{
Layer[i]->Export(this,Exp);
if (Layer[i]->CanExport())
{
Layer[i]->Export(this,Exp);
}
}
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");
// Write Dummy File Header
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()
{
ASSERT(LayerCount==LayerOfs.size());
int LayerCount=LayerOfs.size();
FileHdr.LayerCount=LayerCount;
// ReWrite Main Header
fseek(File,0,0);
fwrite(&FileHdr,sizeof(sExpFileHdr),1,File);
for (int i=0;i<LayerCount; i++)
{
TRACE1("LayerOfs %i\n",LayerOfs[i]);
fwrite(&LayerOfs[i],sizeof(int),1,File);
FileHdr.LayerOfs[i]=LayerOfs[i];
}
// ReWrite Main Header
fseek(File,0,0);
fwrite(&FileHdr,sizeof(sExpFileHdr),1,File);
fclose(File);
}

View File

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

View File

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

View File

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

View File

@ -22,6 +22,7 @@ struct sLayerInfoTable
float ScaleFactor;
bool Render3dFlag;
bool ResizeFlag;
bool ExportFlag;
};
@ -50,6 +51,8 @@ static int GetLayerIdx(int Type,int SubType);
char *GetName() {return(InfoTable[GetLayerIdx(GetType(),GetSubType())].Name);}
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 BOOL IsVisible() {return(VisibleFlag);}

View File

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

View File

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

View File

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