2001-01-22 18:01:20 +01:00
|
|
|
/******************/
|
|
|
|
/*** Layer Tile ***/
|
|
|
|
/******************/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include <Vector3.h>
|
|
|
|
#include <gl\gl.h>
|
|
|
|
#include <gl\glu.h>
|
|
|
|
#include "GLEnabledView.h"
|
|
|
|
|
|
|
|
#include "MapEdit.h"
|
|
|
|
#include "MapEditDoc.h"
|
|
|
|
#include "MapEditView.h"
|
|
|
|
#include "MainFrm.h"
|
|
|
|
|
|
|
|
#include "Core.h"
|
|
|
|
#include "Layer.h"
|
|
|
|
#include "LayerTile.h"
|
2001-01-23 22:53:48 +01:00
|
|
|
#include "LayerCollision.h"
|
2001-01-22 18:01:20 +01:00
|
|
|
#include "Utils.h"
|
|
|
|
#include "Select.h"
|
|
|
|
#include "Export.h"
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
// New Layer
|
2001-01-23 22:53:48 +01:00
|
|
|
CLayerCollision::CLayerCollision(int _SubType,int Width,int Height)
|
2001-01-22 18:01:20 +01:00
|
|
|
{
|
2001-01-23 22:53:48 +01:00
|
|
|
SubType=LAYER_SUBTYPE_NONE;
|
2001-01-22 18:01:20 +01:00
|
|
|
SetDefaultParams();
|
|
|
|
Mode=MouseModePaint;
|
|
|
|
Map.SetSize(Width,Height,TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
// Load Layer
|
2001-01-23 22:53:48 +01:00
|
|
|
CLayerCollision::CLayerCollision(CFile *File,int Version)
|
2001-01-22 18:01:20 +01:00
|
|
|
{
|
|
|
|
Load(File,Version);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-01-23 22:53:48 +01:00
|
|
|
CLayerCollision::~CLayerCollision()
|
2001-01-22 18:01:20 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-01-23 22:53:48 +01:00
|
|
|
void CLayerCollision::Load(CFile *File,int Version)
|
2001-01-22 18:01:20 +01:00
|
|
|
{
|
2001-01-23 22:53:48 +01:00
|
|
|
// Version 2
|
|
|
|
File->Read(&Render3dFlag,sizeof(BOOL));
|
|
|
|
File->Read(&ScaleFactor,sizeof(float));
|
|
|
|
File->Read(&ResizeFlag,sizeof(BOOL));
|
|
|
|
File->Read(&VisibleFlag,sizeof(BOOL));
|
|
|
|
File->Read(&Mode,sizeof(MouseMode));
|
|
|
|
File->Read(&SubType,sizeof(int));
|
|
|
|
Map.Load(File,Version);
|
2001-01-22 18:01:20 +01:00
|
|
|
|
|
|
|
TRACE1("%s\t",GetName());
|
|
|
|
TRACE1("Scl:%g\t",ScaleFactor);
|
|
|
|
TRACE1("%i\n",VisibleFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-01-23 22:53:48 +01:00
|
|
|
void CLayerCollision::Save(CFile *File)
|
2001-01-22 18:01:20 +01:00
|
|
|
{
|
|
|
|
// Always Save current version
|
|
|
|
|
|
|
|
File->Write(&Render3dFlag,sizeof(BOOL));
|
|
|
|
File->Write(&ScaleFactor,sizeof(float));
|
|
|
|
File->Write(&ResizeFlag,sizeof(BOOL));
|
|
|
|
File->Write(&VisibleFlag,sizeof(BOOL));
|
|
|
|
File->Write(&Mode,sizeof(MouseMode));
|
|
|
|
File->Write(&SubType,sizeof(SubType));
|
|
|
|
Map.Save(File);
|
|
|
|
}
|
|
|
|
|
2001-02-20 16:57:03 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
void CLayerCollision::Render(CCore *Core,Vector3 &CamPos,BOOL Is3d)
|
|
|
|
{
|
|
|
|
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
|
|
|
|
|
|
|
CLayerTile::Render(Core,ThisCam,Map,FALSE,0.5f);
|
|
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
|
|
BOOL CLayerCollision::SetColFlag(CCore *Core,int Flag)
|
|
|
|
{
|
|
|
|
TRACE1("HERE!!! %i",Flag);
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
2001-01-22 18:01:20 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
/*** Gui *********************************************************************/
|
|
|
|
/*****************************************************************************/
|
2001-02-09 22:17:01 +01:00
|
|
|
void CLayerCollision::GUIInit(CCore *Core)
|
2001-01-22 18:01:20 +01:00
|
|
|
{
|
2001-02-14 23:35:47 +01:00
|
|
|
Core->GUIAdd(ToolBarGUI,IDD_LAYERTILE_TOOLBAR);
|
2001-02-20 16:57:03 +01:00
|
|
|
Core->GUIAdd(CollisionGUI,IDD_LAYERCOLLISION_GUI);
|
2001-02-09 22:17:01 +01:00
|
|
|
}
|
2001-01-22 18:01:20 +01:00
|
|
|
|
2001-02-09 22:17:01 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
void CLayerCollision::GUIKill(CCore *Core)
|
|
|
|
{
|
|
|
|
Core->GUIRemove(ToolBarGUI,IDD_LAYERTILE_TOOLBAR);
|
2001-02-20 16:57:03 +01:00
|
|
|
Core->GUIRemove(CollisionGUI,IDD_LAYERCOLLISION_GUI);
|
2001-02-09 22:17:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CLayerCollision::GUIUpdate(CCore *Core)
|
|
|
|
{
|
|
|
|
CLayerTile::GUIUpdate(Core);
|
2001-01-22 18:01:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-02-09 22:17:01 +01:00
|
|
|
void CLayerCollision::GUIChanged(CCore *Core)
|
2001-01-22 18:01:20 +01:00
|
|
|
{
|
2001-02-09 22:17:01 +01:00
|
|
|
CLayerTile::GUIChanged(Core);
|
2001-01-22 18:01:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
2001-01-23 22:53:48 +01:00
|
|
|
void CLayerCollision::Export(CCore *Core,CExport &Exp)
|
2001-01-22 18:01:20 +01:00
|
|
|
{
|
2001-02-16 19:23:01 +01:00
|
|
|
int Width=Map.GetWidth();
|
|
|
|
int Height=Map.GetHeight();
|
|
|
|
|
|
|
|
Exp.ExportLayerHeader(LAYER_TYPE_COLLISION,SubType,Width,Height);
|
|
|
|
|
|
|
|
for (int Y=0; Y<Height; Y++)
|
|
|
|
{
|
|
|
|
for (int X=0; X<Width; X++)
|
|
|
|
{
|
|
|
|
sMapElem &MapElem=Map.Get(X,Y);
|
2001-02-20 16:57:03 +01:00
|
|
|
sExpColTile OutElem;
|
|
|
|
|
2001-02-16 19:23:01 +01:00
|
|
|
if (MapElem.Tile)
|
|
|
|
{
|
2001-02-20 16:57:03 +01:00
|
|
|
OutElem.Tile=((MapElem.Tile-1)*4)+1;
|
|
|
|
OutElem.Tile+=MapElem.Flags & PC_TILE_FLAG_MIRROR_XY;
|
|
|
|
OutElem.Flags=MapElem.Flags>>PC_TILE_FLAG_COLLISION_SHIFT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OutElem.Tile=0;
|
|
|
|
OutElem.Flags=0;
|
2001-02-16 19:23:01 +01:00
|
|
|
}
|
2001-02-20 16:57:03 +01:00
|
|
|
|
|
|
|
Exp.Write(&OutElem,sizeof(sExpColTile));
|
2001-02-16 19:23:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-22 18:01:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-01-23 22:53:48 +01:00
|
|
|
void CLayerCollision::DeleteSet(int Set)
|
2001-01-22 18:01:20 +01:00
|
|
|
{
|
|
|
|
Map.DeleteSet(Set);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-01-23 22:53:48 +01:00
|
|
|
void CLayerCollision::RemapSet(int OrigSet,int NewSet)
|
2001-01-22 18:01:20 +01:00
|
|
|
{
|
|
|
|
Map.RemapSet(OrigSet,NewSet);
|
|
|
|
|
|
|
|
}
|