This commit is contained in:
parent
114268ff23
commit
3602018f1a
@ -21,6 +21,9 @@
|
|||||||
#include "LayerCollision.h"
|
#include "LayerCollision.h"
|
||||||
#include "LayerShade.h"
|
#include "LayerShade.h"
|
||||||
#include "LayerThing.h"
|
#include "LayerThing.h"
|
||||||
|
#include "LayerActor.h"
|
||||||
|
#include "LayerItem.h"
|
||||||
|
#include "LayerPlatform.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include "Export.h"
|
#include "Export.h"
|
||||||
@ -28,6 +31,7 @@
|
|||||||
#include "GUIAddLayer.h"
|
#include "GUIAddLayer.h"
|
||||||
#include "GUINewMap.h"
|
#include "GUINewMap.h"
|
||||||
|
|
||||||
|
#include <IniClass.h>
|
||||||
|
|
||||||
GString IconzFileName="Iconz.bmp";
|
GString IconzFileName="Iconz.bmp";
|
||||||
|
|
||||||
@ -51,6 +55,7 @@ GString Filename;
|
|||||||
GetExecPath(Filename);
|
GetExecPath(Filename);
|
||||||
Filename+=IconzFileName;
|
Filename+=IconzFileName;
|
||||||
IconBank->AddSet(Filename);
|
IconBank->AddSet(Filename);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -78,7 +83,7 @@ int Width,Height;
|
|||||||
|
|
||||||
// Create Tile Layers
|
// Create Tile Layers
|
||||||
AddLayer(LAYER_TYPE_TILE,LAYER_SUBTYPE_ACTION, Width, Height);
|
AddLayer(LAYER_TYPE_TILE,LAYER_SUBTYPE_ACTION, Width, Height);
|
||||||
AddLayer(LAYER_TYPE_ITEM,LAYER_SUBTYPE_NONE, Width, Height);
|
// AddLayer(LAYER_TYPE_ACTOR,LAYER_SUBTYPE_NONE, Width, Height);
|
||||||
|
|
||||||
for (int i=0; i<Layer.size(); i++)
|
for (int i=0; i<Layer.size(); i++)
|
||||||
{
|
{
|
||||||
@ -130,33 +135,15 @@ int LayerCount;
|
|||||||
|
|
||||||
for (i=0;i<LayerCount;i++)
|
for (i=0;i<LayerCount;i++)
|
||||||
{
|
{
|
||||||
int Type;
|
CLayer *Lyr=CLayer::LoadLayer(File,Version);
|
||||||
|
TRACE1("Loaded %s\n",Lyr->GetName());
|
||||||
File->Read(&Type,sizeof(int));
|
AddLayer(Lyr);
|
||||||
switch (Type)
|
|
||||||
{
|
|
||||||
case LAYER_TYPE_TILE:
|
|
||||||
AddLayer(new CLayerTile(File,Version));
|
|
||||||
break;
|
|
||||||
case LAYER_TYPE_COLLISION:
|
|
||||||
AddLayer(new CLayerCollision(File,Version));
|
|
||||||
break;
|
|
||||||
case LAYER_TYPE_SHADE:
|
|
||||||
AddLayer(new CLayerShade(File,Version));
|
|
||||||
break;
|
|
||||||
case LAYER_TYPE_ITEM:
|
|
||||||
AddLayer(new CLayerThing(File,Version));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ASSERT(!"poos");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<Layer.size(); i++)
|
for (i=0; i<Layer.size(); i++)
|
||||||
{
|
{
|
||||||
Layer[i]->InitSubView(this);
|
Layer[i]->InitSubView(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetTileBank()->Load(File,Version);
|
GetTileBank()->Load(File,Version);
|
||||||
CurrentLayer=Layer[ActiveLayer];
|
CurrentLayer=Layer[ActiveLayer];
|
||||||
|
|
||||||
@ -169,6 +156,16 @@ int MapHeight=ActionLayer->GetHeight();
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CCore::Validate(int Type)
|
||||||
|
{
|
||||||
|
int LayerCount=Layer.size();
|
||||||
|
for (int i=0;i<LayerCount;i++)
|
||||||
|
{
|
||||||
|
if (Layer[i]->GetType()==Type)
|
||||||
|
Layer[i]->Validate(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CCore::Save(CFile *File)
|
void CCore::Save(CFile *File)
|
||||||
@ -190,8 +187,7 @@ int LayerCount=Layer.size();
|
|||||||
|
|
||||||
for (int i=0;i<LayerCount;i++)
|
for (int i=0;i<LayerCount;i++)
|
||||||
{
|
{
|
||||||
int Type=Layer[i]->GetType();
|
Layer[i]->CLayer::Save(File);
|
||||||
File->Write(&Type,sizeof(int));
|
|
||||||
Layer[i]->Save(File);
|
Layer[i]->Save(File);
|
||||||
}
|
}
|
||||||
GetTileBank()->Save(File);
|
GetTileBank()->Save(File);
|
||||||
@ -497,7 +493,17 @@ int Idx=ListSize;
|
|||||||
int CCore::AddLayer(int Type, int SubType, int Width, int Height)
|
int CCore::AddLayer(int Type, int SubType, int Width, int Height)
|
||||||
{
|
{
|
||||||
int Idx;
|
int Idx;
|
||||||
switch (Type)
|
CLayer *Lyr;
|
||||||
|
sLayerDef ThisDef;
|
||||||
|
|
||||||
|
ThisDef.Type=Type;
|
||||||
|
ThisDef.SubType=SubType;
|
||||||
|
ThisDef.Width=Width;
|
||||||
|
ThisDef.Height=Height;
|
||||||
|
|
||||||
|
Lyr=CLayer::NewLayer(ThisDef);
|
||||||
|
Idx=AddLayer(Lyr);
|
||||||
|
/* switch (Type)
|
||||||
{
|
{
|
||||||
case LAYER_TYPE_TILE:
|
case LAYER_TYPE_TILE:
|
||||||
Idx=AddLayer(new CLayerTile(SubType, Width,Height));
|
Idx=AddLayer(new CLayerTile(SubType, Width,Height));
|
||||||
@ -508,13 +514,20 @@ int Idx;
|
|||||||
case LAYER_TYPE_SHADE:
|
case LAYER_TYPE_SHADE:
|
||||||
Idx=AddLayer(new CLayerShade(SubType, Width,Height));
|
Idx=AddLayer(new CLayerShade(SubType, Width,Height));
|
||||||
break;
|
break;
|
||||||
|
case LAYER_TYPE_ACTOR:
|
||||||
|
Idx=AddLayer(new CLayerActor(SubType, Width,Height));
|
||||||
|
break;
|
||||||
case LAYER_TYPE_ITEM:
|
case LAYER_TYPE_ITEM:
|
||||||
Idx=AddLayer(new CLayerThing(SubType, Width,Height));
|
Idx=AddLayer(new CLayerItem(SubType, Width,Height));
|
||||||
|
break;
|
||||||
|
case LAYER_TYPE_PLATFORM:
|
||||||
|
Idx=AddLayer(new CLayerPlatform(SubType, Width,Height));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(!"AddLayer - Invalid Layer Type");
|
ASSERT(!"AddLayer - Invalid Layer Type");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
if (ActionLayer) Layer[Idx]->InitSubView(this);
|
if (ActionLayer) Layer[Idx]->InitSubView(this);
|
||||||
return(Idx);
|
return(Idx);
|
||||||
}
|
}
|
||||||
@ -571,23 +584,6 @@ void CCore::DeleteLayer(int ThisLayer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*
|
|
||||||
CLayer *CCore::FindSubView(int Type)
|
|
||||||
{
|
|
||||||
int i,ListSize=Layer.size();
|
|
||||||
|
|
||||||
for (i=0;i<ListSize;i++)
|
|
||||||
{
|
|
||||||
if (Layer[i]->GetSubViewType()==Type)
|
|
||||||
{
|
|
||||||
CLayer *SV=Layer[i]->GetSubView();
|
|
||||||
if (SV) return(SV);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*** Grid ********************************************************************/
|
/*** Grid ********************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "LayerTile.h"
|
#include "LayerTile.h"
|
||||||
|
|
||||||
const s32 FileVersion=5;
|
const s32 FileVersion=6;
|
||||||
|
|
||||||
#define SCREEN_MAP_WIDTH 30
|
#define SCREEN_MAP_WIDTH 30
|
||||||
#define SCREEN_MAP_HEIGHT 20
|
#define SCREEN_MAP_HEIGHT 20
|
||||||
@ -39,6 +39,7 @@ public:
|
|||||||
bool New();
|
bool New();
|
||||||
void Load(CFile *File);
|
void Load(CFile *File);
|
||||||
void Save(CFile *File);
|
void Save(CFile *File);
|
||||||
|
void Validate(int Type);
|
||||||
bool Question(char *Txt);
|
bool Question(char *Txt);
|
||||||
void Render(bool ForceRender=FALSE);
|
void Render(bool ForceRender=FALSE);
|
||||||
void RenderLayers(bool OneShot=false);
|
void RenderLayers(bool OneShot=false);
|
||||||
@ -60,7 +61,6 @@ public:
|
|||||||
// Subview & TileBank
|
// Subview & TileBank
|
||||||
CTileBank *GetTileBank() {return(ActionLayer->GetTileBank());}
|
CTileBank *GetTileBank() {return(ActionLayer->GetTileBank());}
|
||||||
void ToggleSubView();
|
void ToggleSubView();
|
||||||
// CLayer *FindSubView(int Type);
|
|
||||||
bool IsSubView() {return(CurrentLayer!=Layer[ActiveLayer]);}
|
bool IsSubView() {return(CurrentLayer!=Layer[ActiveLayer]);}
|
||||||
// GUI
|
// GUI
|
||||||
void UpdateParamBar();
|
void UpdateParamBar();
|
||||||
|
@ -115,7 +115,6 @@ GFName Path=Filename;
|
|||||||
if (Centre)
|
if (Centre)
|
||||||
{
|
{
|
||||||
Ofs.x=0.5-UnitWidth/2;
|
Ofs.x=0.5-UnitWidth/2;
|
||||||
// Ofs.y=0.5-UnitHeight/2;
|
|
||||||
Ofs.y=-1.0f;
|
Ofs.y=-1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,6 +192,7 @@ std::vector<int> const &NodeTriMat=ThisNode.GetTriMaterial();
|
|||||||
|
|
||||||
std::vector<GString> const &SceneTexList=ThisScene.GetTexList();
|
std::vector<GString> const &SceneTexList=ThisScene.GetTexList();
|
||||||
std::vector<int> const &SceneUsedMatList=ThisScene.GetUsedMaterialIdx();
|
std::vector<int> const &SceneUsedMatList=ThisScene.GetUsedMaterialIdx();
|
||||||
|
int TexCount=SceneTexList.size();
|
||||||
|
|
||||||
int TriCount=NodeTriList.size();
|
int TriCount=NodeTriList.size();
|
||||||
int ListSize=TriList.size();
|
int ListSize=TriList.size();
|
||||||
@ -207,14 +207,20 @@ int ListSize=TriList.size();
|
|||||||
int TexID;
|
int TexID;
|
||||||
|
|
||||||
|
|
||||||
// Sort Textures - Only add the ones nthat are used :o)
|
// Sort Textures - Only add the ones that are used :o)
|
||||||
TexID=SceneUsedMatList[ThisMat];
|
TexID=SceneUsedMatList[ThisMat];
|
||||||
|
if (TexID<0 || TexID>=TexCount)
|
||||||
if (TexID!=-1)
|
{
|
||||||
|
CString mexstr;
|
||||||
|
mexstr.Format("Invalid TexId\n Wanted %i/%i for %s\nThis is gonna hurt!",TexID,TexCount-1,ThisNode.Name);
|
||||||
|
AfxMessageBox(mexstr,MB_OK | MB_ICONEXCLAMATION);
|
||||||
|
TexID=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
GString ThisName;
|
GString ThisName;
|
||||||
|
GString TexName=SceneTexList[TexID];
|
||||||
ThisName=SetPath+SceneTexList[TexID];
|
ThisName=SetPath+TexName;
|
||||||
TRACE2("%i !%s!\n",TexID,ThisName);
|
TRACE2("%i !%s!\n",TexID,ThisName);
|
||||||
TexID=TexCache.ProcessTexture(ThisName);
|
TexID=TexCache.ProcessTexture(ThisName);
|
||||||
}
|
}
|
||||||
@ -721,7 +727,7 @@ CElemBank::CElemBank(int W,int H,bool Blank,bool Centre)
|
|||||||
|
|
||||||
LoadFlag=false;
|
LoadFlag=false;
|
||||||
CurrentSet=0;
|
CurrentSet=0;
|
||||||
VisibleFlag=true;
|
LayerDef.VisibleFlag=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -874,7 +880,8 @@ bool CElemBank::IsValid(int Set,int Elem)
|
|||||||
{
|
{
|
||||||
if (Set<0 || Elem<0) return(false);
|
if (Set<0 || Elem<0) return(false);
|
||||||
if (Elem==0) return(true);
|
if (Elem==0) return(true);
|
||||||
if (Set>=SetList.size()) return(false);
|
// if (Set>=SetList.size()) return(false);
|
||||||
|
if (Set>SetList.size()) return(false);
|
||||||
ASSERT(Set<SetList.size());
|
ASSERT(Set<SetList.size());
|
||||||
return(SetList[Set].IsValid(Elem));
|
return(SetList[Set].IsValid(Elem));
|
||||||
}
|
}
|
||||||
|
@ -62,17 +62,17 @@ void CExport::Write(void *Addr,int Len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int CExport::ExportLayerHeader(int Type,int SubType,int Width,int Height)
|
int CExport::ExportLayerHeader(sLayerDef &LayerDef)//(int Type,int SubType,int Width,int Height)
|
||||||
{
|
{
|
||||||
sExpLayerHdr LayerHdr;
|
sExpLayerHdr LayerHdr;
|
||||||
int ThisFilePos=ftell(File);
|
int ThisFilePos=ftell(File);
|
||||||
|
|
||||||
LayerOfs.push_back(ThisFilePos);
|
LayerOfs.push_back(ThisFilePos);
|
||||||
|
|
||||||
LayerHdr.Type=Type;
|
LayerHdr.Type=LayerDef.Type;
|
||||||
LayerHdr.SubType=SubType;
|
LayerHdr.SubType=LayerDef.SubType;
|
||||||
LayerHdr.Width=Width;
|
LayerHdr.Width=LayerDef.Width;
|
||||||
LayerHdr.Height=Height;
|
LayerHdr.Height=LayerDef.Height;
|
||||||
fwrite(&LayerHdr,sizeof(sExpLayerHdr),1,File);
|
fwrite(&LayerHdr,sizeof(sExpLayerHdr),1,File);
|
||||||
|
|
||||||
return(ThisFilePos);
|
return(ThisFilePos);
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
~CExport();
|
~CExport();
|
||||||
|
|
||||||
void Write(void *Addr,int Len);
|
void Write(void *Addr,int Len);
|
||||||
int ExportLayerHeader(int Type,int SubType,int Width,int Height);
|
int ExportLayerHeader(sLayerDef &LayerDef);//int Type,int SubType,int Width,int Height);
|
||||||
int AddTile(sExpTile &Tile) {return(UsedTileList.Add(Tile));}
|
int AddTile(sExpTile &Tile) {return(UsedTileList.Add(Tile));}
|
||||||
|
|
||||||
void ExportTiles(CCore *Core);
|
void ExportTiles(CCore *Core);
|
||||||
|
@ -15,7 +15,16 @@
|
|||||||
#include "MainFrm.h"
|
#include "MainFrm.h"
|
||||||
|
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
|
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
|
#include "LayerTile.h"
|
||||||
|
#include "LayerCollision.h"
|
||||||
|
#include "LayerShade.h"
|
||||||
|
#include "LayerThing.h"
|
||||||
|
#include "LayerActor.h"
|
||||||
|
#include "LayerItem.h"
|
||||||
|
#include "LayerPlatform.h"
|
||||||
|
|
||||||
#include "LayerDef.h"
|
#include "LayerDef.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
@ -29,7 +38,9 @@ sLayerInfoTable CLayer::InfoTable[]=
|
|||||||
{LAYER_TYPE_TILE, LAYER_SUBTYPE_MID, "Mid", true, 2.0f, false, true, true, LAYER_SUBVIEW_TILEBANK,},
|
{LAYER_TYPE_TILE, LAYER_SUBTYPE_MID, "Mid", true, 2.0f, false, true, true, LAYER_SUBVIEW_TILEBANK,},
|
||||||
{LAYER_TYPE_TILE, LAYER_SUBTYPE_ACTION, "Action", false, 1.0f, true, true, true, LAYER_SUBVIEW_TILEBANK,},
|
{LAYER_TYPE_TILE, LAYER_SUBTYPE_ACTION, "Action", false, 1.0f, true, true, true, LAYER_SUBVIEW_TILEBANK,},
|
||||||
{LAYER_TYPE_COLLISION, LAYER_SUBTYPE_NONE, "Collision", true, 1.0f, false, true, true, LAYER_SUBVIEW_TILEBANK,},
|
{LAYER_TYPE_COLLISION, LAYER_SUBTYPE_NONE, "Collision", true, 1.0f, false, true, true, LAYER_SUBVIEW_TILEBANK,},
|
||||||
{LAYER_TYPE_ITEM, LAYER_SUBTYPE_NONE, "Item", true, 1.0f, false, true, true, LAYER_SUBVIEW_TILEBANK,},
|
{LAYER_TYPE_ACTOR, LAYER_SUBTYPE_NONE, "Actor", true, 1.0f, false, true, true, LAYER_SUBVIEW_NONE,},
|
||||||
|
{LAYER_TYPE_ITEM, LAYER_SUBTYPE_NONE, "Item", true, 1.0f, false, true, true, LAYER_SUBVIEW_NONE,},
|
||||||
|
{LAYER_TYPE_PLATFORM, LAYER_SUBTYPE_NONE, "Platform", true, 1.0f, false, true, true, LAYER_SUBVIEW_NONE,},
|
||||||
};
|
};
|
||||||
|
|
||||||
int CLayer::InfoTableSize=sizeof(InfoTable)/sizeof(sLayerInfoTable);
|
int CLayer::InfoTableSize=sizeof(InfoTable)/sizeof(sLayerInfoTable);
|
||||||
@ -39,25 +50,109 @@ CLayer::CLayer()
|
|||||||
{
|
{
|
||||||
SubView=0;
|
SubView=0;
|
||||||
LayerCam=DefaultCamPos;
|
LayerCam=DefaultCamPos;
|
||||||
|
LayerDef.VisibleFlag=TRUE;
|
||||||
|
LayerDef.Width=-1;
|
||||||
|
LayerDef.Height=-1;
|
||||||
|
TableIdx=-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CLayer::InitLayer(sLayerDef &_LayerDef)
|
||||||
|
{
|
||||||
|
LayerDef=_LayerDef;
|
||||||
|
TableIdx=CLayer::GetLayerIdx(LayerDef.Type,LayerDef.SubType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayer::SetDefaultParams()
|
CLayer *CLayer::NewLayer(sLayerDef &Def)
|
||||||
{
|
{
|
||||||
int Idx=CLayer::GetLayerIdx(GetType(),GetSubType());
|
CLayer *New;
|
||||||
|
|
||||||
ScaleFactor=InfoTable[Idx].ScaleFactor;
|
switch (Def.Type)
|
||||||
ResizeFlag=InfoTable[Idx].ResizeFlag;
|
{
|
||||||
Render3dFlag=InfoTable[Idx].Render3dFlag;
|
case LAYER_TYPE_TILE:
|
||||||
VisibleFlag=TRUE;
|
New=new CLayerTile(Def);
|
||||||
|
break;
|
||||||
|
case LAYER_TYPE_COLLISION:
|
||||||
|
New=new CLayerCollision(Def);
|
||||||
|
break;
|
||||||
|
case LAYER_TYPE_SHADE:
|
||||||
|
New=new CLayerShade(Def);
|
||||||
|
break;
|
||||||
|
case LAYER_TYPE_ACTOR:
|
||||||
|
New=new CLayerActor(Def);
|
||||||
|
break;
|
||||||
|
case LAYER_TYPE_ITEM:
|
||||||
|
New=new CLayerItem(Def);
|
||||||
|
break;
|
||||||
|
case LAYER_TYPE_PLATFORM:
|
||||||
|
New=new CLayerPlatform(Def);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ASSERT(!"Unknown Layer");
|
||||||
|
}
|
||||||
|
return(New);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
CLayer *CLayer::LoadLayer(CFile *File,int Version)
|
||||||
|
{
|
||||||
|
CLayer *New;
|
||||||
|
if (Version<=5)
|
||||||
|
{
|
||||||
|
int Type;
|
||||||
|
File->Read(&Type,sizeof(int));
|
||||||
|
switch (Type)
|
||||||
|
{
|
||||||
|
case LAYER_TYPE_TILE:
|
||||||
|
New=new CLayerTile(File,Version);
|
||||||
|
break;
|
||||||
|
case LAYER_TYPE_COLLISION:
|
||||||
|
New=new CLayerCollision(File,Version);
|
||||||
|
break;
|
||||||
|
case LAYER_TYPE_SHADE:
|
||||||
|
New=new CLayerShade(File,Version);
|
||||||
|
break;
|
||||||
|
case LAYER_TYPE_ACTOR:
|
||||||
|
New=new CLayerActor(File,Version);
|
||||||
|
break;
|
||||||
|
case LAYER_TYPE_ITEM:
|
||||||
|
New=new CLayerItem(File,Version);
|
||||||
|
break;
|
||||||
|
case LAYER_TYPE_PLATFORM:
|
||||||
|
New=new CLayerPlatform(File,Version);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ASSERT(!"Unknown Layer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sLayerDef ThisDef;
|
||||||
|
|
||||||
|
File->Read(&ThisDef,sizeof(sLayerDef));
|
||||||
|
New=NewLayer(ThisDef);//Type,SubType,0,0);
|
||||||
|
}
|
||||||
|
return(New);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CLayer::Load(CFile *File,int Version)
|
||||||
|
{
|
||||||
|
File->Read(&LayerDef,sizeof(sLayerDef));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CLayer::Save(CFile *File)
|
||||||
|
{
|
||||||
|
File->Write(&LayerDef,sizeof(sLayerDef));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int CLayer::GetLayerIdx(int Type,int SubType)
|
int CLayer::GetLayerIdx(int Type,int SubType)
|
||||||
{
|
{
|
||||||
|
|
||||||
for (int i=0; i<InfoTableSize; i++)
|
for (int i=0; i<InfoTableSize; i++)
|
||||||
{
|
{
|
||||||
if (InfoTable[i].Type==Type && InfoTable[i].SubType==SubType)
|
if (InfoTable[i].Type==Type && InfoTable[i].SubType==SubType)
|
||||||
|
@ -44,28 +44,32 @@ public:
|
|||||||
CLayer();
|
CLayer();
|
||||||
virtual ~CLayer(){};
|
virtual ~CLayer(){};
|
||||||
|
|
||||||
|
void InitLayer(sLayerDef &LayerDef);
|
||||||
static sLayerInfoTable InfoTable[];
|
static sLayerInfoTable InfoTable[];
|
||||||
static int InfoTableSize;
|
static int InfoTableSize;
|
||||||
|
|
||||||
static int GetLayerIdx(int Type,int SubType);
|
static int GetLayerIdx(int Type,int SubType);
|
||||||
|
static CLayer *NewLayer(sLayerDef &Def);
|
||||||
|
static CLayer *LoadLayer(CFile *File,int Version);
|
||||||
|
|
||||||
void SetDefaultParams();
|
char *GetName() {TRACE1("%i\n",TableIdx);return(InfoTable[TableIdx].Name);}
|
||||||
|
bool CanDelete() {return(InfoTable[TableIdx].DeleteFlag);}
|
||||||
char *GetName() {return(InfoTable[GetLayerIdx(GetType(),GetSubType())].Name);}
|
float GetScaleFactor() {return(InfoTable[TableIdx].ScaleFactor);}
|
||||||
bool CanDelete() {return(InfoTable[GetLayerIdx(GetType(),GetSubType())].DeleteFlag);}
|
bool GetRender3dFlag() {return(InfoTable[TableIdx].Render3dFlag);}
|
||||||
bool CanExport() {return(InfoTable[GetLayerIdx(GetType(),GetSubType())].ExportFlag);}
|
bool GetResizeFlag() {return(InfoTable[TableIdx].ResizeFlag);}
|
||||||
bool IsUnique() {return(!(InfoTable[GetLayerIdx(GetType(),GetSubType())].ExportFlag));}
|
bool CanExport() {return(InfoTable[TableIdx].ExportFlag);}
|
||||||
int GetSubViewType() {return((InfoTable[GetLayerIdx(GetType(),GetSubType())].SubView));}
|
bool IsUnique() {return(!(InfoTable[TableIdx].ExportFlag));}
|
||||||
|
int GetSubViewType() {return((InfoTable[TableIdx].SubView));}
|
||||||
|
|
||||||
virtual void InitSubView(CCore *Core){};
|
virtual void InitSubView(CCore *Core){};
|
||||||
virtual CLayer *GetSubView() {return(SubView);}
|
virtual CLayer *GetSubView() {return(SubView);}
|
||||||
|
|
||||||
|
|
||||||
virtual void SetVisible(bool f) {VisibleFlag=f;}
|
virtual void SetVisible(bool f) {LayerDef.VisibleFlag=f;}
|
||||||
virtual bool IsVisible() {return(VisibleFlag);}
|
virtual bool IsVisible() {return(LayerDef.VisibleFlag);}
|
||||||
virtual int GetType()=0;
|
virtual int GetType() {return(LayerDef.Type);}
|
||||||
virtual int GetSubType() {return(LAYER_SUBTYPE_NONE);}
|
virtual int GetSubType() {return(LayerDef.SubType);}
|
||||||
float GetScaleFactor() {return(ScaleFactor);}
|
|
||||||
|
|
||||||
virtual void Render(CCore *Core,Vector3 &CamPos,bool Is3d){};
|
virtual void Render(CCore *Core,Vector3 &CamPos,bool Is3d){};
|
||||||
virtual void RenderGrid(CCore *Core,Vector3 &CamPos,bool Active);
|
virtual void RenderGrid(CCore *Core,Vector3 &CamPos,bool Active);
|
||||||
@ -78,13 +82,14 @@ virtual void GUIKill(CCore *Core){};
|
|||||||
virtual void GUIUpdate(CCore *Core){};
|
virtual void GUIUpdate(CCore *Core){};
|
||||||
virtual void GUIChanged(CCore *Core){};
|
virtual void GUIChanged(CCore *Core){};
|
||||||
|
|
||||||
virtual int GetWidth() {return(-1);}
|
virtual int GetWidth() {return(LayerDef.Width);}
|
||||||
virtual int GetHeight() {return(-1);}
|
virtual int GetHeight() {return(LayerDef.Height);}
|
||||||
virtual void CheckLayerSize(int Width,int Height){};
|
virtual void CheckLayerSize(int Width,int Height){};
|
||||||
|
virtual void Validate(CCore *Core){};
|
||||||
virtual bool Resize(int Width,int Height) {return(false);}
|
virtual bool Resize(int Width,int Height) {return(false);}
|
||||||
|
|
||||||
virtual void Load(CFile *File,int Version)=0;
|
virtual void Load(CFile *File,int Version);
|
||||||
virtual void Save(CFile *File)=0;
|
virtual void Save(CFile *File);
|
||||||
|
|
||||||
virtual void Export(CCore *Core,CExport &Exp)=0;
|
virtual void Export(CCore *Core,CExport &Exp)=0;
|
||||||
|
|
||||||
@ -97,11 +102,16 @@ virtual bool MouseMove(CCore *Core,UINT nFlags, CPoint &CursorPos){return(fals
|
|||||||
virtual bool Command(int CmdMsg,CCore *Core,int Param0=0,int Param1=0){return(false);};
|
virtual bool Command(int CmdMsg,CCore *Core,int Param0=0,int Param1=0){return(false);};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float ScaleFactor;
|
|
||||||
bool Render3dFlag;
|
|
||||||
bool ResizeFlag;
|
|
||||||
|
|
||||||
bool VisibleFlag;
|
// Saved Vars
|
||||||
|
sLayerDef LayerDef;
|
||||||
|
|
||||||
|
// Static Quick Vars
|
||||||
|
int TableIdx;
|
||||||
|
// float ScaleFactor;
|
||||||
|
// bool Render3dFlag;
|
||||||
|
// bool ResizeFlag;
|
||||||
|
|
||||||
CSelect Selection;
|
CSelect Selection;
|
||||||
CLayer *SubView;
|
CLayer *SubView;
|
||||||
Vector3 LayerCam;
|
Vector3 LayerCam;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/***********************/
|
/*******************/
|
||||||
/*** Layer Character ***/
|
/*** Layer Actor ***/
|
||||||
/***********************/
|
/*******************/
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include <Vector3.h>
|
#include <Vector3.h>
|
||||||
@ -15,67 +15,48 @@
|
|||||||
|
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#include "LayerThing.h"
|
#include "LayerThing.h"
|
||||||
|
#include "LayerActor.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Export.h"
|
#include "Export.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// New Layer
|
CLayerActor::CLayerActor(sLayerDef &Def) :CLayerThing(Def)
|
||||||
CLayerThing::CLayerThing(int _SubType,int _Width,int _Height)
|
|
||||||
{
|
{
|
||||||
SetDefaultParams();
|
// CLayerThing::CLayerThing(_SubType,_Width,_Height);
|
||||||
|
|
||||||
Mode=MouseModeNormal;
|
|
||||||
Width=_Width;
|
|
||||||
Height=_Height;
|
|
||||||
ThingBank=new CElemBank(-1,-1,false,true);
|
|
||||||
CurrentThing=-1;
|
|
||||||
CurrentPoint=0;
|
|
||||||
|
|
||||||
LoadThingScript("c:\\temp\\character.txt");
|
LoadThingScript("c:\\temp\\character.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Load Layer
|
//CLayerActor::CLayerActor(CFile *File,int Version)
|
||||||
CLayerThing::CLayerThing(CFile *File,int Version)
|
//{
|
||||||
|
// CLayerThing::CLayerThing(File,Version);
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CLayerActor::Load(CFile *File,int Version)
|
||||||
{
|
{
|
||||||
Load(File,Version);
|
// CLayerThing::Load(File,Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CLayerThing::~CLayerThing()
|
void CLayerActor::Save(CFile *File)
|
||||||
{
|
{
|
||||||
ThingBank->CleanUp();
|
CLayerThing::Save(File);
|
||||||
delete ThingBank;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerThing::Load(CFile *File,int Version)
|
void CLayerActor::InitSubView(CCore *Core)
|
||||||
{
|
|
||||||
File->Read(&VisibleFlag,sizeof(BOOL));
|
|
||||||
File->Read(&Mode,sizeof(MouseMode));
|
|
||||||
|
|
||||||
TRACE1("%s\t",GetName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerThing::Save(CFile *File)
|
|
||||||
{
|
|
||||||
// Always Save current version
|
|
||||||
File->Write(&VisibleFlag,sizeof(BOOL));
|
|
||||||
File->Write(&Mode,sizeof(MouseMode));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerThing::InitSubView(CCore *Core)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerThing::LoadThingScript(const char *Filename)
|
void CLayerActor::LoadThingScript(const char *Filename)
|
||||||
{
|
{
|
||||||
ThingScript.LoadAndImport(Filename);
|
CLayerThing::LoadThingScript(Filename);
|
||||||
|
// CLayerThing::ThingScript.LoadAndImport(Filename);
|
||||||
|
|
||||||
int Count=ThingScript.GetGroupCount();
|
int Count=ThingScript.GetGroupCount();
|
||||||
for (int i=0; i<Count; i++)
|
for (int i=0; i<Count; i++)
|
||||||
@ -83,377 +64,38 @@ int Count=ThingScript.GetGroupCount();
|
|||||||
char *Name=ThingScript.GetGroupName(i);
|
char *Name=ThingScript.GetGroupName(i);
|
||||||
char *Gfx=ThingScript.GetData(Name,"gfx");
|
char *Gfx=ThingScript.GetData(Name,"gfx");
|
||||||
TRACE2("%s\t\t%s\n",Name,Gfx);
|
TRACE2("%s\t\t%s\n",Name,Gfx);
|
||||||
if (Gfx)
|
if (Gfx) ThingBank->AddSet(Gfx);
|
||||||
ThingBank->AddSet(Gfx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerThing::Render(CCore *Core,Vector3 &CamPos,bool Is3d)
|
|
||||||
{
|
|
||||||
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
|
||||||
int i,ListSize=ThingList.size();
|
|
||||||
|
|
||||||
// Is3d&=Render3dFlag;
|
|
||||||
for (i=0; i<ListSize; i++)
|
|
||||||
{
|
|
||||||
RenderThing(Core,ThisCam,ThingList[i],Is3d,i==CurrentThing);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerThing::RenderThing(CCore *Core,Vector3 &ThisCam,sLayerThing &ThisThing,bool Render3d,bool Selected)
|
|
||||||
{
|
|
||||||
float ZoomW=Core->GetZoomW();
|
|
||||||
float ZoomH=Core->GetZoomH();
|
|
||||||
float ScrOfsX=(ZoomW/2);
|
|
||||||
float ScrOfsY=(ZoomH/2);
|
|
||||||
Vector3 &Scale=Core->GetScaleVector();
|
|
||||||
CElemBank *IconBank=Core->GetIconBank();
|
|
||||||
|
|
||||||
if (ThingBank->NeedLoad()) ThingBank->LoadAllSets(Core);
|
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
|
|
||||||
glLoadIdentity();
|
|
||||||
|
|
||||||
glScalef(Scale.x,Scale.y,Scale.z);
|
|
||||||
glTranslatef(-ThisCam.x,ThisCam.y,0); // Set scroll offset
|
|
||||||
glTranslatef(-ScrOfsX,ScrOfsY,0); // Bring to top left corner
|
|
||||||
|
|
||||||
int ListSize=ThisThing.XY.size();
|
|
||||||
for (int i=0;i<ListSize; i++)
|
|
||||||
{
|
|
||||||
// Render Thing
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(ThisThing.XY[i].x,-ThisThing.XY[i].y,0); // Set Pos
|
|
||||||
if (Selected)
|
|
||||||
glColor4f(1,1,1,1); // Set default Color
|
|
||||||
else
|
|
||||||
glColor4f(1,1,1,0.5);
|
|
||||||
|
|
||||||
IconBank->RenderElem(0,i,0,Render3d);
|
|
||||||
if (i==0)
|
|
||||||
{
|
|
||||||
glColor4f(1,1,1,1); // Set default Color
|
|
||||||
ThingBank->RenderElem(ThisThing.Type,0,0,Render3d);
|
|
||||||
}
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*** Gui *********************************************************************/
|
/*** Gui *********************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerThing::GUIInit(CCore *Core)
|
void CLayerActor::GUIInit(CCore *Core)
|
||||||
{
|
{
|
||||||
// Core->GUIAdd(GUIToolBar,IDD_TOOLBAR);
|
// Core->GUIAdd(GUIToolBar,IDD_TOOLBAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerThing::GUIKill(CCore *Core)
|
void CLayerActor::GUIKill(CCore *Core)
|
||||||
{
|
{
|
||||||
// Core->GUIRemove(GUIToolBar,IDD_TOOLBAR);
|
// Core->GUIRemove(GUIToolBar,IDD_TOOLBAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerThing::GUIUpdate(CCore *Core)
|
void CLayerActor::GUIUpdate(CCore *Core)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerThing::GUIChanged(CCore *Core)
|
void CLayerActor::GUIChanged(CCore *Core)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*** Functions ***************************************************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
bool CLayerThing::LButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag)
|
|
||||||
{
|
|
||||||
bool Ret=false;
|
|
||||||
|
|
||||||
switch(Mode)
|
|
||||||
{
|
|
||||||
case MouseModeNormal:
|
|
||||||
if (DownFlag)
|
|
||||||
{
|
|
||||||
if (CurrentThing==-1)
|
|
||||||
AddThing(CursorPos);
|
|
||||||
else
|
|
||||||
AddThingPoint(CursorPos);
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MouseModePoints:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
bool CLayerThing::RButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag)
|
|
||||||
{
|
|
||||||
bool Ret=FALSE;
|
|
||||||
|
|
||||||
switch(Mode)
|
|
||||||
{
|
|
||||||
case MouseModeNormal:
|
|
||||||
if (DownFlag)
|
|
||||||
{
|
|
||||||
SelectThing(CursorPos);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MouseModePoints:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return(Ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
bool CLayerThing::MouseMove(CCore *Core,UINT nFlags, CPoint &CursorPos)
|
|
||||||
{
|
|
||||||
bool Ret=false;
|
|
||||||
|
|
||||||
if (CurrentThing!=-1)
|
|
||||||
{
|
|
||||||
if (nFlags & MK_LBUTTON) // Drag
|
|
||||||
{
|
|
||||||
UpdatePos(CursorPos,CurrentThing,CurrentPoint,true);
|
|
||||||
Ret=true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (nFlags & MK_RBUTTON) // Cancel
|
|
||||||
{
|
|
||||||
CurrentThing=-1;
|
|
||||||
Ret=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(Ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
bool CLayerThing::Command(int CmdMsg,CCore *Core,int Param0,int Param1)
|
|
||||||
{
|
|
||||||
bool Ret=false;
|
|
||||||
/*
|
|
||||||
switch(CmdMsg)
|
|
||||||
{
|
|
||||||
case CmdMsg_SetMode:
|
|
||||||
// Mode=(MouseMode)Param0;
|
|
||||||
// Core->GUIUpdate();
|
|
||||||
// break;
|
|
||||||
// case CmdMsg_SubViewSet:
|
|
||||||
// Ret=ThingBank->Command(CmdMsg,Core,Param0,Param1);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return(Ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerThing::RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d)
|
|
||||||
{
|
|
||||||
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
|
||||||
CPoint &CursPos=Core->GetCursorPos();
|
|
||||||
Vector3 Ofs;
|
|
||||||
|
|
||||||
if (CursPos.x<0 || CursPos.y<0) return;
|
|
||||||
|
|
||||||
Ofs.x=-(CursPos.x-(int)ThisCam.x);
|
|
||||||
Ofs.y=-(CursPos.y-(int)ThisCam.y);
|
|
||||||
ThisCam.x-=(int)ThisCam.x;
|
|
||||||
ThisCam.y-=(int)ThisCam.y;
|
|
||||||
|
|
||||||
if (Is3d && Render3dFlag)
|
|
||||||
{
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
// Render(Core,ThisCam,,TRUE,0.5,&Ofs);
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Render(Core,ThisCam,Brush,FALSE,0.5,&Ofs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int CLayerThing::CheckThing(CPoint &Pos)
|
void CLayerActor::Export(CCore *Core,CExport &Exp)
|
||||||
{
|
{
|
||||||
CList<int> List;
|
|
||||||
int Idx=-1,i,ListSize=ThingList.size();
|
|
||||||
int StartIdx=0;
|
|
||||||
|
|
||||||
// Build List Of XY Matches
|
|
||||||
for (i=0; i<ListSize; i++)
|
|
||||||
{
|
|
||||||
sLayerThing &ThisThing=ThingList[i];
|
|
||||||
if (ThisThing.XY[0]==Pos)
|
|
||||||
{
|
|
||||||
if (i==CurrentThing) StartIdx=List.size();
|
|
||||||
List.push_back(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ListSize=List.size();
|
|
||||||
if (ListSize)
|
|
||||||
{
|
|
||||||
StartIdx=(StartIdx+1)%ListSize;
|
|
||||||
Idx=List[StartIdx];
|
|
||||||
}
|
|
||||||
return(Idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerThing::AddThing(CPoint &Pos)
|
|
||||||
{
|
|
||||||
if (Pos.x==-1 || Pos.y==-1) return; // Off Map?
|
|
||||||
CurrentThing=CheckThing(Pos);
|
|
||||||
CurrentPoint=0;
|
|
||||||
if (CurrentThing!=-1) return;
|
|
||||||
|
|
||||||
CurrentThing=ThingList.size();
|
|
||||||
ThingList.resize(CurrentThing+1);
|
|
||||||
|
|
||||||
sLayerThing &ThisThing=ThingList[CurrentThing];
|
|
||||||
|
|
||||||
ThisThing.XY.push_back(Pos);
|
|
||||||
ThisThing.Type=ThingList.size()%22;
|
|
||||||
ThisThing.SubType=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerThing::SelectThing(CPoint &Pos)
|
|
||||||
{
|
|
||||||
if (Pos.x==-1 || Pos.y==-1) return; // Off Map?
|
|
||||||
CurrentThing=CheckThing(Pos);
|
|
||||||
CurrentPoint=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
int CLayerThing::CheckThingPoint(CPoint &Pos)
|
|
||||||
{
|
|
||||||
CList<int> List;
|
|
||||||
sLayerThing &ThisThing=ThingList[CurrentThing];
|
|
||||||
int Idx=-1,i,ListSize=ThisThing.XY.size();
|
|
||||||
int StartIdx=0;
|
|
||||||
|
|
||||||
// Build List Of XY Matches
|
|
||||||
for (i=0; i<ListSize; i++)
|
|
||||||
{
|
|
||||||
if (ThisThing.XY[i]==Pos)
|
|
||||||
{
|
|
||||||
if (i==CurrentThing) StartIdx=List.size();
|
|
||||||
List.push_back(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ListSize=List.size();
|
|
||||||
if (ListSize)
|
|
||||||
{
|
|
||||||
StartIdx=(StartIdx+1)%ListSize;
|
|
||||||
Idx=List[StartIdx];
|
|
||||||
}
|
|
||||||
return(Idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerThing::AddThingPoint(CPoint &Pos)
|
|
||||||
{
|
|
||||||
if (Pos.x==-1 || Pos.y==-1) return; // Off Map?
|
|
||||||
CurrentPoint=CheckThingPoint(Pos);
|
|
||||||
|
|
||||||
if (CurrentPoint!=-1) return;
|
|
||||||
sLayerThing &ThisThing=ThingList[CurrentThing];
|
|
||||||
|
|
||||||
CurrentPoint=ThisThing.XY.size();
|
|
||||||
ThisThing.XY.resize(CurrentPoint+1);
|
|
||||||
ThisThing.XY[CurrentPoint]=Pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerThing::SelectThingPoint(CPoint &Pos)
|
|
||||||
{
|
|
||||||
if (Pos.x==-1 || Pos.y==-1) return; // Off Map?
|
|
||||||
CurrentPoint=CheckThing(Pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerThing::UpdatePos(CPoint &Pos,int Thing,int PosIdx,bool Recurs)
|
|
||||||
{
|
|
||||||
if (Pos.x==-1 || Pos.y==-1) return; // Off Map?
|
|
||||||
|
|
||||||
sLayerThing &ThisThing=ThingList[Thing];
|
|
||||||
CPoint dPos=Pos-ThisThing.XY[PosIdx];
|
|
||||||
int StartIdx=PosIdx,EndIdx=ThisThing.XY.size();
|
|
||||||
|
|
||||||
if (!Recurs)
|
|
||||||
{
|
|
||||||
StartIdx=PosIdx;
|
|
||||||
EndIdx=StartIdx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i=StartIdx; i<EndIdx; i++)
|
|
||||||
{
|
|
||||||
ThisThing.XY[i]+=dPos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerThing::Export(CCore *Core,CExport &Exp)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
int Width=Map.GetWidth();
|
|
||||||
int Height=Map.GetHeight();
|
|
||||||
|
|
||||||
Exp.ExportLayerHeader(LAYER_TYPE_Elem,SubType,Width,Height);
|
|
||||||
|
|
||||||
for (int Y=0; Y<Height; Y++)
|
|
||||||
{
|
|
||||||
for (int X=0; X<Width; X++)
|
|
||||||
{
|
|
||||||
sMapElem &MapElem=Map.Get(X,Y);
|
|
||||||
sExpLayerThing OutElem;
|
|
||||||
|
|
||||||
if (MapElem.Set==0 && MapElem.Elem==0)
|
|
||||||
{ // Blank
|
|
||||||
OutElem.Elem=0;
|
|
||||||
OutElem.Flags=0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sExpElem OutElem;
|
|
||||||
CElem &ThisElem=ElemBank->GetElem(MapElem.Set,MapElem.Elem);
|
|
||||||
|
|
||||||
OutElem.Set=MapElem.Set;
|
|
||||||
OutElem.Elem=MapElem.Elem;
|
|
||||||
OutElem.TriStart=0;
|
|
||||||
OutElem.TriCount=0;
|
|
||||||
OutElem.XOfs=ThisElem.GetTexXOfs();
|
|
||||||
OutElem.YOfs=ThisElem.GetTexYOfs();
|
|
||||||
OutElem.Elem=Exp.AddElem(OutElem);
|
|
||||||
OutElem.Flags=MapElem.Flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
Exp.Write(&OutElem,sizeof(sExpLayerThing));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -1,94 +1,38 @@
|
|||||||
/*******************/
|
/*******************/
|
||||||
/*** Layer Thing ***/
|
/*** Layer Actor ***/
|
||||||
/*******************/
|
/*******************/
|
||||||
|
|
||||||
#ifndef __LAYER_THING_HEADER__
|
#ifndef __LAYER_ACTOR_HEADER__
|
||||||
#define __LAYER_THING_HEADER__
|
#define __LAYER_ACTOR_HEADER__
|
||||||
|
|
||||||
|
#include "LayerThing.h"
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "MapEdit.h"
|
#include "MapEdit.h"
|
||||||
#include "GUIToolbar.h"
|
#include "GUIToolbar.h"
|
||||||
#include "Elem.h"
|
#include "Elem.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
struct sLayerThing
|
class CLayerActor : public CLayerThing
|
||||||
{
|
|
||||||
std::vector<CPoint> XY;
|
|
||||||
int Type;
|
|
||||||
int SubType;
|
|
||||||
int Spare[8];
|
|
||||||
|
|
||||||
bool operator==(sLayerThing const &v1)
|
|
||||||
{
|
|
||||||
if (XY[0]!=v1.XY[0]) return(false);
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
class CIni;
|
|
||||||
class CLayerThing : public CLayer
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum MouseMode
|
// CLayerActor(int Type,int SubType,int Width,int Height);
|
||||||
{
|
CLayerActor(sLayerDef &Def);
|
||||||
MouseModeNormal=0,
|
CLayerActor(CFile *File,int Version) {Load(File,Version);}
|
||||||
MouseModePoints,
|
|
||||||
};
|
|
||||||
|
|
||||||
CLayerThing(){};
|
void InitSubView(CCore *Core);
|
||||||
CLayerThing(int SubType,int Width,int Height); // New Layer
|
|
||||||
CLayerThing(CFile *File,int Version); // Load Layer
|
|
||||||
~CLayerThing();
|
|
||||||
|
|
||||||
virtual int GetType() {return(LAYER_TYPE_ITEM);}
|
void GUIInit(CCore *Core);
|
||||||
virtual void InitSubView(CCore *Core);
|
void GUIKill(CCore *Core);
|
||||||
|
void GUIUpdate(CCore *Core);
|
||||||
|
void GUIChanged(CCore *Core);
|
||||||
|
|
||||||
virtual void Render(CCore *Core,Vector3 &CamPos,bool Is3d);
|
void Load(CFile *File,int Version);
|
||||||
void RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d);
|
void Save(CFile *File);
|
||||||
// void FindCursorPos(CCore *Core,Vector3 &CamPos,CPoint &MousePos);
|
void LoadThingScript(const char *Filename);
|
||||||
|
|
||||||
virtual void GUIInit(CCore *Core);
|
void Export(CCore *Core,CExport &Exp);
|
||||||
virtual void GUIKill(CCore *Core);
|
|
||||||
virtual void GUIUpdate(CCore *Core);
|
|
||||||
virtual void GUIChanged(CCore *Core);
|
|
||||||
|
|
||||||
int GetWidth() {return(Width);}
|
|
||||||
int GetHeight() {return(Height);}
|
|
||||||
|
|
||||||
virtual void Load(CFile *File,int Version);
|
|
||||||
virtual void Save(CFile *File);
|
|
||||||
virtual void LoadThingScript(const char *Filename);
|
|
||||||
|
|
||||||
virtual void Export(CCore *Core,CExport &Exp);
|
|
||||||
|
|
||||||
// Functions
|
|
||||||
virtual bool LButtonControl(CCore *Core,UINT nFlags, CPoint &point,bool DownFlag);
|
|
||||||
virtual bool RButtonControl(CCore *Core,UINT nFlags, CPoint &point,bool DownFlag);
|
|
||||||
virtual bool MouseMove(CCore *Core,UINT nFlags, CPoint &point);
|
|
||||||
virtual bool Command(int CmdMsg,CCore *Core,int Param0=0,int Param1=0);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void RenderThing(CCore *Core,Vector3 &CamPos,sLayerThing &ThisThing,bool Render3d,bool Selected);
|
|
||||||
int CheckThing(CPoint &Pos);
|
|
||||||
void AddThing(CPoint &Pos);
|
|
||||||
void SelectThing(CPoint &Pos);
|
|
||||||
int CheckThingPoint(CPoint &Pos);
|
|
||||||
void AddThingPoint(CPoint &Pos);
|
|
||||||
void SelectThingPoint(CPoint &Pos);
|
|
||||||
|
|
||||||
void UpdatePos(CPoint &Pos,int Thing,int PosNo,bool Recurs=false);
|
|
||||||
|
|
||||||
|
|
||||||
int Width,Height;
|
|
||||||
CIni ThingScript;
|
|
||||||
CElemBank *ThingBank;
|
|
||||||
CList<sLayerThing> ThingList;
|
|
||||||
int CurrentThing,CurrentPoint;
|
|
||||||
MouseMode Mode;
|
|
||||||
|
|
||||||
|
|
||||||
CGUIToolBar GUIToolBar;
|
CGUIToolBar GUIToolBar;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -27,20 +27,10 @@ GString ColFName="Collision.bmp";
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// New Layer
|
// New Layer
|
||||||
CLayerCollision::CLayerCollision(int _SubType,int Width,int Height)
|
//CLayerCollision::CLayerCollision(int Type,int SubType,int Width,int Height) :CLayerTile(LAYER_TYPE_COLLISION,SubType,Width,Height)
|
||||||
|
CLayerCollision::CLayerCollision(sLayerDef &Def)
|
||||||
{
|
{
|
||||||
SubType=LAYER_SUBTYPE_NONE;
|
InitLayer(Def);
|
||||||
SetDefaultParams();
|
|
||||||
Mode=MouseModePaint;
|
|
||||||
Map.SetSize(Width,Height,TRUE);
|
|
||||||
VisibleFlag=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
// Load Layer
|
|
||||||
CLayerCollision::CLayerCollision(CFile *File,int Version)
|
|
||||||
{
|
|
||||||
Load(File,Version);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -65,31 +55,31 @@ GString Filename;
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerCollision::Load(CFile *File,int Version)
|
void CLayerCollision::Load(CFile *File,int Version)
|
||||||
{
|
{
|
||||||
// Version 2
|
if (Version<=5)
|
||||||
File->Read(&Render3dFlag,sizeof(BOOL));
|
{
|
||||||
File->Read(&ScaleFactor,sizeof(float));
|
BOOL DB;
|
||||||
File->Read(&ResizeFlag,sizeof(BOOL));
|
float DF;
|
||||||
File->Read(&VisibleFlag,sizeof(BOOL));
|
LayerDef.Type=LAYER_TYPE_COLLISION;
|
||||||
|
File->Read(&DB,sizeof(BOOL));
|
||||||
|
File->Read(&DF,sizeof(float));
|
||||||
|
File->Read(&DB,sizeof(BOOL));
|
||||||
|
File->Read(&LayerDef.VisibleFlag,sizeof(BOOL));
|
||||||
File->Read(&Mode,sizeof(MouseMode));
|
File->Read(&Mode,sizeof(MouseMode));
|
||||||
File->Read(&SubType,sizeof(int));
|
File->Read(&LayerDef.SubType,sizeof(int));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File->Read(&Mode,sizeof(MouseMode));
|
||||||
|
}
|
||||||
|
InitLayer(LayerDef);
|
||||||
Map.Load(File,Version);
|
Map.Load(File,Version);
|
||||||
|
|
||||||
TRACE1("%s\t",GetName());
|
|
||||||
TRACE1("Scl:%g\t",ScaleFactor);
|
|
||||||
TRACE1("%i\n",VisibleFlag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerCollision::Save(CFile *File)
|
void CLayerCollision::Save(CFile *File)
|
||||||
{
|
{
|
||||||
// Always Save current version
|
// 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);
|
Map.Save(File);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +143,10 @@ void CLayerCollision::Export(CCore *Core,CExport &Exp)
|
|||||||
int Width=Map.GetWidth();
|
int Width=Map.GetWidth();
|
||||||
int Height=Map.GetHeight();
|
int Height=Map.GetHeight();
|
||||||
|
|
||||||
Exp.ExportLayerHeader(LAYER_TYPE_COLLISION,SubType,Width,Height);
|
LayerDef.Width=Width;
|
||||||
|
LayerDef.Height=Height;
|
||||||
|
|
||||||
|
Exp.ExportLayerHeader(LayerDef);//LAYER_TYPE_COLLISION,LayerDef.SubType,Width,Height);
|
||||||
|
|
||||||
for (int Y=0; Y<Height; Y++)
|
for (int Y=0; Y<Height; Y++)
|
||||||
{
|
{
|
||||||
|
@ -15,8 +15,9 @@ class CLayerCollision : public CLayerTile
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CLayerCollision(int SubType,int Width,int Height); // New Layer
|
// CLayerCollision(int Type,int SubType,int Width,int Height);
|
||||||
CLayerCollision(CFile *File,int Version); // Load Layer
|
CLayerCollision(sLayerDef &Def);
|
||||||
|
CLayerCollision(CFile *File,int Version) {Load(File,Version);}
|
||||||
~CLayerCollision();
|
~CLayerCollision();
|
||||||
|
|
||||||
int GetType() {return(LAYER_TYPE_COLLISION);}
|
int GetType() {return(LAYER_TYPE_COLLISION);}
|
||||||
|
@ -14,7 +14,9 @@ enum LAYER_TYPE
|
|||||||
LAYER_TYPE_TILE=0,
|
LAYER_TYPE_TILE=0,
|
||||||
LAYER_TYPE_COLLISION,
|
LAYER_TYPE_COLLISION,
|
||||||
LAYER_TYPE_SHADE,
|
LAYER_TYPE_SHADE,
|
||||||
|
LAYER_TYPE_ACTOR,
|
||||||
LAYER_TYPE_ITEM,
|
LAYER_TYPE_ITEM,
|
||||||
|
LAYER_TYPE_PLATFORM,
|
||||||
LAYER_TYPE_MAX
|
LAYER_TYPE_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -68,6 +70,14 @@ enum
|
|||||||
LAYER_SHADE_MAX=4,
|
LAYER_SHADE_MAX=4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct sLayerDef
|
||||||
|
{
|
||||||
|
int Type;
|
||||||
|
int SubType;
|
||||||
|
int Width;
|
||||||
|
int Height;
|
||||||
|
bool VisibleFlag;
|
||||||
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
#endif
|
#endif
|
@ -2,7 +2,6 @@
|
|||||||
/*** Layer Item ***/
|
/*** Layer Item ***/
|
||||||
/******************/
|
/******************/
|
||||||
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include <Vector3.h>
|
#include <Vector3.h>
|
||||||
#include <gl\gl.h>
|
#include <gl\gl.h>
|
||||||
@ -14,178 +13,59 @@
|
|||||||
#include "MapEditView.h"
|
#include "MapEditView.h"
|
||||||
#include "MainFrm.h"
|
#include "MainFrm.h"
|
||||||
|
|
||||||
//#include "ItemSet.h"
|
|
||||||
|
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#include "Layer.h"
|
#include "LayerThing.h"
|
||||||
#include "LayerItem.h"
|
#include "LayerItem.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
//#include "Select.h"
|
|
||||||
#include "Export.h"
|
#include "Export.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// New Layer
|
// New Layer
|
||||||
CLayerItem::CLayerItem(int _SubType,int _Width,int _Height)
|
CLayerItem::CLayerItem(sLayerDef &Def) : CLayerThing (Def)
|
||||||
{
|
{
|
||||||
SetDefaultParams();
|
LoadThingScript("c:\\temp\\character.txt");
|
||||||
|
|
||||||
Mode=MouseModePaint;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Load Layer
|
//CLayerItem::CLayerItem(CFile *File,int Version) :CLayerThing (File,Version)
|
||||||
CLayerItem::CLayerItem(CFile *File,int Version)
|
//{
|
||||||
{
|
//
|
||||||
Load(File,Version);
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
CLayerItem::~CLayerItem()
|
|
||||||
{
|
|
||||||
ElemBank->CleanUp();
|
|
||||||
delete ElemBank;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerItem::Load(CFile *File,int Version)
|
void CLayerItem::Load(CFile *File,int Version)
|
||||||
{
|
{
|
||||||
File->Read(&VisibleFlag,sizeof(BOOL));
|
CLayerThing::Load(File,Version);
|
||||||
File->Read(&Mode,sizeof(MouseMode));
|
|
||||||
|
|
||||||
TRACE1("%s\t",GetName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerItem::Save(CFile *File)
|
void CLayerItem::Save(CFile *File)
|
||||||
{
|
{
|
||||||
// Always Save current version
|
CLayerThing::Save(File);
|
||||||
File->Write(&VisibleFlag,sizeof(BOOL));
|
|
||||||
File->Write(&Mode,sizeof(MouseMode));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerItem::InitSubView(CCore *Core)
|
void CLayerItem::InitSubView(CCore *Core)
|
||||||
{
|
{
|
||||||
ElemBank=new CElemStore;
|
|
||||||
SubView=ElemBank;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
void CLayerItem::LoadThingScript(const char *Filename)
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerItem::Render(CCore *Core,Vector3 &CamPos,bool Is3d)
|
|
||||||
{
|
{
|
||||||
/*
|
CLayerThing::LoadThingScript(Filename);
|
||||||
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
// CLayerThing::ThingScript.LoadAndImport(Filename);
|
||||||
|
|
||||||
Is3d&=Render3dFlag;
|
int Count=ThingScript.GetGroupCount();
|
||||||
Render(Core,ThisCam,Map,Is3d);
|
for (int i=0; i<Count; i++)
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerItem::RenderCursorPaint(CCore *Core,Vector3 &CamPos,bool Is3d)
|
|
||||||
{
|
{
|
||||||
/*
|
char *Name=ThingScript.GetGroupName(i);
|
||||||
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
char *Gfx=ThingScript.GetData(Name,"gfx");
|
||||||
CPoint &CursPos=Core->GetCursorPos();
|
TRACE2("%s\t\t%s\n",Name,Gfx);
|
||||||
CMap &Brush=ElemBank->GetActiveBrush();
|
if (Gfx)
|
||||||
Vector3 Ofs;
|
ThingBank->AddSet(Gfx);
|
||||||
|
|
||||||
if (!Brush.IsValid()) return;
|
|
||||||
|
|
||||||
if (CursPos.x<0 || CursPos.y<0) return;
|
|
||||||
|
|
||||||
Ofs.x=-(CursPos.x-(int)ThisCam.x);
|
|
||||||
Ofs.y=-(CursPos.y-(int)ThisCam.y);
|
|
||||||
ThisCam.x-=(int)ThisCam.x;
|
|
||||||
ThisCam.y-=(int)ThisCam.y;
|
|
||||||
|
|
||||||
if (Is3d && Render3dFlag)
|
|
||||||
{
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
Render(Core,ThisCam,Brush,TRUE,0.5,&Ofs);
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Render(Core,ThisCam,Brush,FALSE,0.5,&Ofs);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerItem::Render(CCore *Core,Vector3 &ThisCam,CMap &ThisMap,bool Render3d,float Alpha,Vector3 *Ofs)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
int MapWidth=ThisMap.GetWidth();
|
|
||||||
int MapHeight=ThisMap.GetHeight();
|
|
||||||
float ZoomW=Core->GetZoomW();
|
|
||||||
float ZoomH=Core->GetZoomH();
|
|
||||||
float ScrOfsX=(ZoomW/2);
|
|
||||||
float ScrOfsY=(ZoomH/2);
|
|
||||||
Vector3 &Scale=Core->GetScaleVector();
|
|
||||||
bool WrapMap=SubType==LAYER_SUBTYPE_BACK;
|
|
||||||
int StartX=(int)ThisCam.x;
|
|
||||||
int StartY=(int)ThisCam.y;
|
|
||||||
float ShiftX=ThisCam.x - (int)ThisCam.x;
|
|
||||||
float ShiftY=ThisCam.y - (int)ThisCam.y;
|
|
||||||
|
|
||||||
if (ElemBank->NeedLoad()) ElemBank->LoadAllSets(Core);
|
|
||||||
|
|
||||||
if (StartX<0) StartX=0;
|
|
||||||
if (StartY<0) StartY=0;
|
|
||||||
|
|
||||||
int DrawW=ZoomW+8;
|
|
||||||
int DrawH=ZoomH+8;
|
|
||||||
|
|
||||||
if (StartX+DrawW>MapWidth) DrawW=MapWidth-StartX;
|
|
||||||
if (StartY+DrawH>MapHeight) DrawH=MapHeight-StartY;
|
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
glLoadIdentity();
|
|
||||||
glScalef(Scale.x,Scale.y,Scale.z);
|
|
||||||
glTranslatef(-ShiftX,ShiftY,0); // Set scroll offset
|
|
||||||
glTranslatef(-ScrOfsX,ScrOfsY,0); // Bring to top left corner
|
|
||||||
|
|
||||||
|
|
||||||
if (Ofs)
|
|
||||||
{
|
|
||||||
glTranslatef(-Ofs->x,Ofs->y,0); // Set scroll offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WrapMap)
|
|
||||||
{
|
|
||||||
DrawW=MapWidth;
|
|
||||||
DrawH=MapHeight;
|
|
||||||
}
|
|
||||||
for (int YLoop=0; YLoop<DrawH; YLoop++)
|
|
||||||
{
|
|
||||||
for (int XLoop=0; XLoop<DrawW; XLoop++)
|
|
||||||
{
|
|
||||||
int XPos=StartX+XLoop;
|
|
||||||
int YPos=StartY+YLoop;
|
|
||||||
if (WrapMap)
|
|
||||||
{
|
|
||||||
XPos%=MapWidth;
|
|
||||||
YPos%=MapHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
sMapElem &ThisElem=ThisMap.Get(XPos,YPos);
|
|
||||||
if (ThisElem.Item>0)
|
|
||||||
{ // Render Non Zero and Valid Items
|
|
||||||
glColor4f(1,1,1,Alpha); // Set default Color
|
|
||||||
ElemBank->RenderItem(ThisElem.Set,ThisElem.Item,ThisElem.Flags,Render3d);
|
|
||||||
}
|
|
||||||
glTranslatef(1.0f,0,0); // Next X
|
|
||||||
}
|
|
||||||
glTranslatef(-DrawW,-1,0); // Next y, rewind to start X
|
|
||||||
}
|
|
||||||
glPopMatrix();
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -193,33 +73,18 @@ int DrawH=ZoomH+8;
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerItem::GUIInit(CCore *Core)
|
void CLayerItem::GUIInit(CCore *Core)
|
||||||
{
|
{
|
||||||
ElemBank->GUIInit(Core);
|
// Core->GUIAdd(GUIToolBar,IDD_TOOLBAR);
|
||||||
Core->GUIAdd(GUIToolBar,IDD_LAYERTILE_TOOLBAR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerItem::GUIKill(CCore *Core)
|
void CLayerItem::GUIKill(CCore *Core)
|
||||||
{
|
{
|
||||||
ElemBank->GUIKill(Core);
|
// Core->GUIRemove(GUIToolBar,IDD_TOOLBAR);
|
||||||
Core->GUIRemove(GUIToolBar,IDD_LAYERTILE_TOOLBAR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerItem::GUIUpdate(CCore *Core)
|
void CLayerItem::GUIUpdate(CCore *Core)
|
||||||
{
|
{
|
||||||
GUIToolBar.ResetButtons();
|
|
||||||
switch(Mode)
|
|
||||||
{
|
|
||||||
case MouseModePaint:
|
|
||||||
GUIToolBar.SetButtonState(CGUIToolBar::PAINT,true);
|
|
||||||
break;
|
|
||||||
case MouseModeSelect:
|
|
||||||
GUIToolBar.SetButtonState(CGUIToolBar::SELECT,true);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ElemBank->GUIUpdate(Core);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -228,158 +93,9 @@ void CLayerItem::GUIChanged(CCore *Core)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*** Functions ***************************************************************/
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
bool CLayerItem::LButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag)
|
|
||||||
{
|
|
||||||
bool Ret=false;
|
|
||||||
/*
|
|
||||||
switch(Mode)
|
|
||||||
{
|
|
||||||
case MouseModePaint:
|
|
||||||
if (DownFlag)
|
|
||||||
Ret=Paint(ElemBank->GetLBrush(),CursorPos);
|
|
||||||
break;
|
|
||||||
case MouseModeSelect:
|
|
||||||
Ret=Selection.Handle(CursorPos,nFlags);
|
|
||||||
if (Selection.HasSelection())
|
|
||||||
{
|
|
||||||
TRACE0("LMB Selection\n");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return(Ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
bool CLayerItem::RButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag)
|
|
||||||
{
|
|
||||||
bool Ret=FALSE;
|
|
||||||
/*
|
|
||||||
switch(Mode)
|
|
||||||
{
|
|
||||||
case MouseModePaint:
|
|
||||||
if (DownFlag)
|
|
||||||
Ret=Paint(ElemBank->GetRBrush(),CursorPos);
|
|
||||||
break;
|
|
||||||
case MouseModeSelect:
|
|
||||||
Ret=Selection.Handle(CursorPos,nFlags);
|
|
||||||
if (Selection.HasSelection())
|
|
||||||
{
|
|
||||||
TRACE0("RMB Selection\n");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return(Ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
bool CLayerItem::MouseMove(CCore *Core,UINT nFlags, CPoint &CursorPos)
|
|
||||||
{
|
|
||||||
bool Ret=FALSE;
|
|
||||||
/*
|
|
||||||
switch(Mode)
|
|
||||||
{
|
|
||||||
case MouseModePaint:
|
|
||||||
if (nFlags & MK_LBUTTON)
|
|
||||||
Ret=Paint(ElemBank->GetLBrush(),CursorPos);
|
|
||||||
else
|
|
||||||
if (nFlags & MK_RBUTTON)
|
|
||||||
Ret=Paint(ElemBank->GetRBrush(),CursorPos);
|
|
||||||
break;
|
|
||||||
case MouseModeSelect:
|
|
||||||
Ret=Selection.Handle(CursorPos,nFlags);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return(Ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
bool CLayerItem::Command(int CmdMsg,CCore *Core,int Param0,int Param1)
|
|
||||||
{
|
|
||||||
bool Ret=false;
|
|
||||||
|
|
||||||
switch(CmdMsg)
|
|
||||||
{
|
|
||||||
case CmdMsg_SetMode:
|
|
||||||
Mode=(MouseMode)Param0;
|
|
||||||
Core->GUIUpdate();
|
|
||||||
break;
|
|
||||||
case CmdMsg_SubViewSet:
|
|
||||||
Ret=ElemBank->Command(CmdMsg,Core,Param0,Param1);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
TRACE3("LayerItem-Unhandled Command %i (%i,%i)\n",CmdMsg,Param0,Param1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(Ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerItem::RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d)
|
|
||||||
{
|
|
||||||
RenderCursorPaint(Core,CamPos,Is3d);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
bool CLayerItem::Paint(CMap &Blk,CPoint &CursorPos)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (CursorPos.x==-1 || CursorPos.y==-1) return(false); // Off Map?
|
|
||||||
if (!Blk.IsValid()) return(false); // Invalid Item?
|
|
||||||
/*
|
|
||||||
Map.Set(CursorPos.x,CursorPos.y,Blk);
|
|
||||||
*/
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerItem::Export(CCore *Core,CExport &Exp)
|
void CLayerItem::Export(CCore *Core,CExport &Exp)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
int Width=Map.GetWidth();
|
|
||||||
int Height=Map.GetHeight();
|
|
||||||
|
|
||||||
Exp.ExportLayerHeader(LAYER_TYPE_Item,SubType,Width,Height);
|
|
||||||
|
|
||||||
for (int Y=0; Y<Height; Y++)
|
|
||||||
{
|
|
||||||
for (int X=0; X<Width; X++)
|
|
||||||
{
|
|
||||||
sMapElem &MapElem=Map.Get(X,Y);
|
|
||||||
sExpLayerItem OutElem;
|
|
||||||
|
|
||||||
if (MapElem.Set==0 && MapElem.Item==0)
|
|
||||||
{ // Blank
|
|
||||||
OutElem.Item=0;
|
|
||||||
OutElem.Flags=0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sExpItem OutItem;
|
|
||||||
CElem &ThisItem=ElemBank->GetItem(MapElem.Set,MapElem.Item);
|
|
||||||
|
|
||||||
OutItem.Set=MapElem.Set;
|
|
||||||
OutItem.Item=MapElem.Item;
|
|
||||||
OutItem.TriStart=0;
|
|
||||||
OutItem.TriCount=0;
|
|
||||||
OutItem.XOfs=ThisItem.GetTexXOfs();
|
|
||||||
OutItem.YOfs=ThisItem.GetTexYOfs();
|
|
||||||
OutElem.Item=Exp.AddItem(OutItem);
|
|
||||||
OutElem.Flags=MapElem.Flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
Exp.Write(&OutElem,sizeof(sExpLayerItem));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -5,33 +5,21 @@
|
|||||||
#ifndef __LAYER_ITEM_HEADER__
|
#ifndef __LAYER_ITEM_HEADER__
|
||||||
#define __LAYER_ITEM_HEADER__
|
#define __LAYER_ITEM_HEADER__
|
||||||
|
|
||||||
|
#include "LayerThing.h"
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "MapEdit.h"
|
#include "MapEdit.h"
|
||||||
#include "GUIToolbar.h"
|
#include "GUIToolbar.h"
|
||||||
#include "ElemStore.h"
|
#include "Elem.h"
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
class CLayerItem : public CLayer
|
class CLayerItem : public CLayerThing
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum MouseMode
|
CLayerItem(sLayerDef &Def);
|
||||||
{
|
CLayerItem(CFile *File,int Version) {Load(File,Version);}
|
||||||
MouseModePaint=0,
|
|
||||||
MouseModeSelect,
|
|
||||||
};
|
|
||||||
|
|
||||||
CLayerItem(){};
|
|
||||||
CLayerItem(int SubType,int Width,int Height); // New Layer
|
|
||||||
CLayerItem(CFile *File,int Version); // Load Layer
|
|
||||||
~CLayerItem();
|
|
||||||
|
|
||||||
int GetType() {return(LAYER_TYPE_ITEM);}
|
|
||||||
void InitSubView(CCore *Core);
|
void InitSubView(CCore *Core);
|
||||||
|
|
||||||
void Render(CCore *Core,Vector3 &CamPos,bool Is3d);
|
|
||||||
void RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d);
|
|
||||||
|
|
||||||
void GUIInit(CCore *Core);
|
void GUIInit(CCore *Core);
|
||||||
void GUIKill(CCore *Core);
|
void GUIKill(CCore *Core);
|
||||||
void GUIUpdate(CCore *Core);
|
void GUIUpdate(CCore *Core);
|
||||||
@ -39,27 +27,11 @@ public:
|
|||||||
|
|
||||||
void Load(CFile *File,int Version);
|
void Load(CFile *File,int Version);
|
||||||
void Save(CFile *File);
|
void Save(CFile *File);
|
||||||
|
void LoadThingScript(const char *Filename);
|
||||||
|
|
||||||
void Export(CCore *Core,CExport &Exp);
|
void Export(CCore *Core,CExport &Exp);
|
||||||
|
|
||||||
// Functions
|
|
||||||
bool LButtonControl(CCore *Core,UINT nFlags, CPoint &point,bool DownFlag);
|
|
||||||
bool RButtonControl(CCore *Core,UINT nFlags, CPoint &point,bool DownFlag);
|
|
||||||
bool MouseMove(CCore *Core,UINT nFlags, CPoint &point);
|
|
||||||
bool Command(int CmdMsg,CCore *Core,int Param0=0,int Param1=0);
|
|
||||||
|
|
||||||
// Local
|
|
||||||
CElemBank *GetElemBank() {return(ElemBank);}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Render(CCore *Core,Vector3 &CamPos,CMap &ThisMap,bool Render3d,float Alpha=1.0f,Vector3 *Ofs=0);
|
|
||||||
void RenderCursorPaint(CCore *Core,Vector3 &CamPos,bool Is3d);
|
|
||||||
|
|
||||||
bool Paint(CMap &Blk,CPoint &CursorPos);
|
|
||||||
|
|
||||||
CElemStore *ElemBank;
|
|
||||||
MouseMode Mode;
|
|
||||||
|
|
||||||
CGUIToolBar GUIToolBar;
|
CGUIToolBar GUIToolBar;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*******************/
|
/**********************/
|
||||||
/*** Layer Actor ***/
|
/*** Layer Platform ***/
|
||||||
/*******************/
|
/**********************/
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include <Vector3.h>
|
#include <Vector3.h>
|
||||||
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#include "LayerThing.h"
|
#include "LayerThing.h"
|
||||||
#include "LayerActor.h"
|
#include "LayerPlatform.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Export.h"
|
#include "Export.h"
|
||||||
|
|
||||||
@ -23,30 +23,35 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// New Layer
|
// New Layer
|
||||||
CLayerActor::CLayerActor(int _SubType,int _Width,int _Height) : CLayerThing (_SubType,_Width,_Height)
|
CLayerPlatform::CLayerPlatform(sLayerDef &Def) : CLayerThing(Def)
|
||||||
{
|
{
|
||||||
LoadThingScript("c:\\temp\\character.txt");
|
LoadThingScript("c:\\temp\\character.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerActor::Load(CFile *File,int Version)
|
//CLayerPlatform::CLayerPlatform(CFile *File,int Version) :CLayerThing (File,Version)
|
||||||
|
//{
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CLayerPlatform::Load(CFile *File,int Version)
|
||||||
{
|
{
|
||||||
CLayerThing::Load(File,Version);
|
CLayerThing::Load(File,Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerActor::Save(CFile *File)
|
void CLayerPlatform::Save(CFile *File)
|
||||||
{
|
{
|
||||||
CLayerThing::Save(File);
|
CLayerThing::Save(File);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerActor::InitSubView(CCore *Core)
|
void CLayerPlatform::InitSubView(CCore *Core)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerActor::LoadThingScript(const char *Filename)
|
void CLayerPlatform::LoadThingScript(const char *Filename)
|
||||||
{
|
{
|
||||||
CLayerThing::LoadThingScript(Filename);
|
CLayerThing::LoadThingScript(Filename);
|
||||||
// CLayerThing::ThingScript.LoadAndImport(Filename);
|
// CLayerThing::ThingScript.LoadAndImport(Filename);
|
||||||
@ -65,31 +70,31 @@ int Count=ThingScript.GetGroupCount();
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*** Gui *********************************************************************/
|
/*** Gui *********************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerActor::GUIInit(CCore *Core)
|
void CLayerPlatform::GUIInit(CCore *Core)
|
||||||
{
|
{
|
||||||
// Core->GUIAdd(GUIToolBar,IDD_TOOLBAR);
|
// Core->GUIAdd(GUIToolBar,IDD_TOOLBAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerActor::GUIKill(CCore *Core)
|
void CLayerPlatform::GUIKill(CCore *Core)
|
||||||
{
|
{
|
||||||
// Core->GUIRemove(GUIToolBar,IDD_TOOLBAR);
|
// Core->GUIRemove(GUIToolBar,IDD_TOOLBAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerActor::GUIUpdate(CCore *Core)
|
void CLayerPlatform::GUIUpdate(CCore *Core)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerActor::GUIChanged(CCore *Core)
|
void CLayerPlatform::GUIChanged(CCore *Core)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerActor::Export(CCore *Core,CExport &Exp)
|
void CLayerPlatform::Export(CCore *Core,CExport &Exp)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/*******************/
|
/**********************/
|
||||||
/*** Layer Actor ***/
|
/*** Layer Platform ***/
|
||||||
/*******************/
|
/**********************/
|
||||||
|
|
||||||
#ifndef __LAYER_ACTOR_HEADER__
|
#ifndef __LAYER_PLATFORM_HEADER__
|
||||||
#define __LAYER_ACTOR_HEADER__
|
#define __LAYER_PLATFORM_HEADER__
|
||||||
|
|
||||||
#include "LayerThing.h"
|
#include "LayerThing.h"
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
@ -12,22 +12,14 @@
|
|||||||
#include "Elem.h"
|
#include "Elem.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
class CLayerActor : public CLayerThing
|
class CLayerPlatform : public CLayerThing
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
CLayerPlatform(sLayerDef &Def);
|
||||||
|
CLayerPlatform(CFile *File,int Version) {Load(File,Version);}
|
||||||
|
|
||||||
CLayerActor(){};
|
|
||||||
CLayerActor(int SubType,int Width,int Height); // New Layer
|
|
||||||
CLayerActor(CFile *File,int Version); // Load Layer
|
|
||||||
// ~CLayerActor();
|
|
||||||
|
|
||||||
int GetType() {return(LAYER_TYPE_ACTOR);}
|
|
||||||
void InitSubView(CCore *Core);
|
void InitSubView(CCore *Core);
|
||||||
|
|
||||||
//virtual void Render(CCore *Core,Vector3 &CamPos,bool Is3d);
|
|
||||||
// void RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d);
|
|
||||||
// void FindCursorPos(CCore *Core,Vector3 &CamPos,CPoint &MousePos);
|
|
||||||
|
|
||||||
void GUIInit(CCore *Core);
|
void GUIInit(CCore *Core);
|
||||||
void GUIKill(CCore *Core);
|
void GUIKill(CCore *Core);
|
||||||
void GUIUpdate(CCore *Core);
|
void GUIUpdate(CCore *Core);
|
||||||
|
@ -27,14 +27,23 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// New Layer
|
// New Layer
|
||||||
CLayerShade::CLayerShade(int _SubType,int _Width,int _Height)
|
CLayerShade::CLayerShade(sLayerDef &Def)
|
||||||
{
|
{
|
||||||
SubType=_SubType;
|
InitLayer(Def);
|
||||||
|
}
|
||||||
|
|
||||||
SetDefaultParams();
|
|
||||||
|
|
||||||
Width=TileLayerMinWidth+(_Width-TileLayerMinWidth)/ScaleFactor;
|
/*****************************************************************************/
|
||||||
Height=TileLayerMinHeight+(_Height-TileLayerMinHeight)/ScaleFactor;
|
CLayerShade::~CLayerShade()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CLayerShade::InitLayer(sLayerDef &Def)
|
||||||
|
{
|
||||||
|
CLayer::InitLayer(Def);
|
||||||
|
LayerDef.Width=TileLayerMinWidth+(Def.Width-TileLayerMinWidth)/GetScaleFactor();
|
||||||
|
LayerDef.Height=TileLayerMinHeight+(Def.Height-TileLayerMinHeight)/GetScaleFactor();
|
||||||
|
|
||||||
RGB[0].rgbRed=255; RGB[0].rgbGreen=255; RGB[0].rgbBlue=255;
|
RGB[0].rgbRed=255; RGB[0].rgbGreen=255; RGB[0].rgbBlue=255;
|
||||||
RGB[1].rgbRed=255; RGB[1].rgbGreen=0; RGB[1].rgbBlue=0;
|
RGB[1].rgbRed=255; RGB[1].rgbGreen=0; RGB[1].rgbBlue=0;
|
||||||
@ -43,37 +52,23 @@ CLayerShade::CLayerShade(int _SubType,int _Width,int _Height)
|
|||||||
Count=2;
|
Count=2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
// Load Layer
|
|
||||||
CLayerShade::CLayerShade(CFile *File,int Version)
|
|
||||||
{
|
|
||||||
Load(File,Version);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
CLayerShade::~CLayerShade()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerShade::Load(CFile *File,int Version)
|
void CLayerShade::Load(CFile *File,int Version)
|
||||||
{
|
{
|
||||||
File->Read(&Render3dFlag,sizeof(BOOL));
|
if (Version<=5)
|
||||||
File->Read(&ScaleFactor,sizeof(float));
|
|
||||||
File->Read(&ResizeFlag,sizeof(BOOL));
|
|
||||||
File->Read(&VisibleFlag,sizeof(BOOL));
|
|
||||||
File->Read(&SubType,sizeof(int));
|
|
||||||
File->Read(&Width,sizeof(int));
|
|
||||||
File->Read(&Height,sizeof(int));
|
|
||||||
|
|
||||||
if (Version==2)
|
|
||||||
{
|
{
|
||||||
File->Read(&RGB[0],sizeof(RGBQUAD));
|
BOOL DB;
|
||||||
File->Read(&RGB[1],sizeof(RGBQUAD));
|
float DF;
|
||||||
|
LayerDef.Type=LAYER_TYPE_SHADE;
|
||||||
|
File->Read(&DB,sizeof(BOOL));
|
||||||
|
File->Read(&DF,sizeof(float));
|
||||||
|
File->Read(&DB,sizeof(BOOL));
|
||||||
|
File->Read(&LayerDef.VisibleFlag,sizeof(BOOL));
|
||||||
|
File->Read(&LayerDef.SubType,sizeof(int));
|
||||||
|
File->Read(&LayerDef.Width,sizeof(int));
|
||||||
|
File->Read(&LayerDef.Height,sizeof(int));
|
||||||
}
|
}
|
||||||
else
|
InitLayer(LayerDef);
|
||||||
{
|
|
||||||
File->Read(&Count,sizeof(int));
|
File->Read(&Count,sizeof(int));
|
||||||
if (Count<2) Count=2;
|
if (Count<2) Count=2;
|
||||||
for (int i=0; i<LAYER_SHADE_RGB_MAX; i++)
|
for (int i=0; i<LAYER_SHADE_RGB_MAX; i++)
|
||||||
@ -81,26 +76,13 @@ void CLayerShade::Load(CFile *File,int Version)
|
|||||||
File->Read(&Pos[i],sizeof(int));
|
File->Read(&Pos[i],sizeof(int));
|
||||||
File->Read(&RGB[i],sizeof(RGBQUAD));
|
File->Read(&RGB[i],sizeof(RGBQUAD));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
TRACE1("%s\t",GetName());
|
|
||||||
TRACE1("Scl:%g\t",ScaleFactor);
|
|
||||||
TRACE1("%i\n",VisibleFlag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerShade::Save(CFile *File)
|
void CLayerShade::Save(CFile *File)
|
||||||
{
|
{
|
||||||
// Always Save current version
|
// 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(&SubType,sizeof(SubType));
|
|
||||||
File->Write(&Width,sizeof(int));
|
|
||||||
File->Write(&Height,sizeof(int));
|
|
||||||
|
|
||||||
File->Write(&Count,sizeof(int));
|
File->Write(&Count,sizeof(int));
|
||||||
for (int i=0; i<LAYER_SHADE_RGB_MAX; i++)
|
for (int i=0; i<LAYER_SHADE_RGB_MAX; i++)
|
||||||
{
|
{
|
||||||
@ -123,10 +105,10 @@ float ScrOfsY=(ZoomH/2);
|
|||||||
Vector3 &Scale=Core->GetScaleVector();
|
Vector3 &Scale=Core->GetScaleVector();
|
||||||
int ThisCount=Count-1;
|
int ThisCount=Count-1;
|
||||||
float X0=0;
|
float X0=0;
|
||||||
float X1=Width;
|
float X1=LayerDef.Width;
|
||||||
float Y=(0+1);
|
float Y=(0+1);
|
||||||
|
|
||||||
float YInc=(float)Height/(float)ThisCount;
|
float YInc=(float)LayerDef.Height/(float)ThisCount;
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
@ -152,10 +134,10 @@ float YInc=(float)Height/(float)ThisCount;
|
|||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
bool CLayerShade::Resize(int _Width,int _Height)
|
bool CLayerShade::Resize(int Width,int Height)
|
||||||
{
|
{
|
||||||
Width=TileLayerMinWidth+(_Width-TileLayerMinWidth)/ScaleFactor;
|
LayerDef.Width=TileLayerMinWidth+(Width-TileLayerMinWidth)/GetScaleFactor();
|
||||||
Height=TileLayerMinHeight+(_Height-TileLayerMinHeight)/ScaleFactor;
|
LayerDef.Height=TileLayerMinHeight+(Height-TileLayerMinHeight)/GetScaleFactor();
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
@ -200,7 +182,7 @@ void CLayerShade::GUIChanged(CCore *Core)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerShade::Export(CCore *Core,CExport &Exp)
|
void CLayerShade::Export(CCore *Core,CExport &Exp)
|
||||||
{
|
{
|
||||||
Exp.ExportLayerHeader(LAYER_TYPE_SHADE,SubType,Width,Height);
|
Exp.ExportLayerHeader(LayerDef);//LAYER_TYPE_SHADE,LayerDef.SubType,LayerDef.Width,LayerDef.Height);
|
||||||
Exp.Write(&Count,sizeof(int));
|
Exp.Write(&Count,sizeof(int));
|
||||||
for (int i=0; i<LAYER_SHADE_RGB_MAX; i++)
|
for (int i=0; i<LAYER_SHADE_RGB_MAX; i++)
|
||||||
{
|
{
|
||||||
|
@ -19,13 +19,15 @@ public:
|
|||||||
{
|
{
|
||||||
LAYER_SHADE_RGB_MAX=4,
|
LAYER_SHADE_RGB_MAX=4,
|
||||||
};
|
};
|
||||||
CLayerShade(){};
|
// CLayerShade(){};
|
||||||
CLayerShade(int SubType,int Width,int Height); // New Layer
|
CLayerShade(sLayerDef &Def);
|
||||||
CLayerShade(CFile *File,int Version); // Load Layer
|
CLayerShade(CFile *File,int Version) {Load(File,Version);}
|
||||||
~CLayerShade();
|
~CLayerShade();
|
||||||
|
|
||||||
int GetType() {return(LAYER_TYPE_SHADE);}
|
void InitLayer(sLayerDef &Def);
|
||||||
int GetSubType() {return(SubType);}
|
|
||||||
|
// int GetType() {return(LAYER_TYPE_SHADE);}
|
||||||
|
// int GetSubType() {return(SubType);}
|
||||||
|
|
||||||
void Render(CCore *Core,Vector3 &CamPos,bool Is3d);
|
void Render(CCore *Core,Vector3 &CamPos,bool Is3d);
|
||||||
void RenderGrid(CCore *Core,Vector3 &CamPos,bool Active){};
|
void RenderGrid(CCore *Core,Vector3 &CamPos,bool Active){};
|
||||||
@ -38,9 +40,7 @@ public:
|
|||||||
void GUIUpdate(CCore *Core);
|
void GUIUpdate(CCore *Core);
|
||||||
void GUIChanged(CCore *Core);
|
void GUIChanged(CCore *Core);
|
||||||
|
|
||||||
int GetWidth() {return(Width);}
|
bool Resize(int Width,int Height);
|
||||||
int GetHeight() {return(Height);}
|
|
||||||
bool Resize(int _Width,int _Height);
|
|
||||||
|
|
||||||
void Load(CFile *File,int Version);
|
void Load(CFile *File,int Version);
|
||||||
void Save(CFile *File);
|
void Save(CFile *File);
|
||||||
@ -52,9 +52,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void Render(CCore *Core,Vector3 &CamPos,CMap &ThisMap,bool Render3d,float Alpha=1.0f,Vector3 *Ofs=0);
|
void Render(CCore *Core,Vector3 &CamPos,CMap &ThisMap,bool Render3d,float Alpha=1.0f,Vector3 *Ofs=0);
|
||||||
|
|
||||||
int Width,Height;
|
|
||||||
int SubType;
|
|
||||||
|
|
||||||
CGUILayerShade GUI;
|
CGUILayerShade GUI;
|
||||||
|
|
||||||
int Count;
|
int Count;
|
||||||
|
@ -24,48 +24,17 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// New Layer
|
// New Layer
|
||||||
CLayerThing::CLayerThing(int _SubType,int _Width,int _Height)
|
CLayerThing::CLayerThing(sLayerDef &Def)
|
||||||
{
|
{
|
||||||
SetDefaultParams();
|
InitLayer(Def);
|
||||||
|
|
||||||
Mode=MouseModeNormal;
|
|
||||||
Width=_Width;
|
|
||||||
Height=_Height;
|
|
||||||
ThingBank=new CElemBank(-1,-1,false,true);
|
|
||||||
CurrentThing=-1;
|
|
||||||
CurrentPoint=0;
|
|
||||||
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\Babyoctopus.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\barnicleboy.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\Caterpillar.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\clam.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\Eyeball.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\FlyingDutchman.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\gary.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\GiantWorm.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\HermitCrab.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\IronDogFish.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\Krusty.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\MermaidMan.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\Neptune.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\Patrick.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\plankton.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\PuffaFish.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\Sandy.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\SeaSnake.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\SharkSub.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\SpiderCrab.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\spongebob.bmp");
|
|
||||||
ThingBank->AddSet("\\spongebob\\graphics\\Squidward.bmp");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Load Layer
|
// Load Layer
|
||||||
CLayerThing::CLayerThing(CFile *File,int Version)
|
//CLayerThing::CLayerThing(CFile *File,int Version)
|
||||||
{
|
//{
|
||||||
Load(File,Version);
|
//Load(File,Version);
|
||||||
}
|
//}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CLayerThing::~CLayerThing()
|
CLayerThing::~CLayerThing()
|
||||||
@ -74,20 +43,28 @@ CLayerThing::~CLayerThing()
|
|||||||
delete ThingBank;
|
delete ThingBank;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CLayerThing::InitLayer(sLayerDef &Def)
|
||||||
|
{
|
||||||
|
Mode=MouseModeNormal;
|
||||||
|
LayerDef.Width=Width;
|
||||||
|
LayerDef.Height=Height;
|
||||||
|
ThingBank=new CElemBank(-1,-1,false,true);
|
||||||
|
CurrentThing=-1;
|
||||||
|
CurrentPoint=0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerThing::Load(CFile *File,int Version)
|
void CLayerThing::Load(CFile *File,int Version)
|
||||||
{
|
{
|
||||||
File->Read(&VisibleFlag,sizeof(BOOL));
|
|
||||||
File->Read(&Mode,sizeof(MouseMode));
|
File->Read(&Mode,sizeof(MouseMode));
|
||||||
|
|
||||||
TRACE1("%s\t",GetName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerThing::Save(CFile *File)
|
void CLayerThing::Save(CFile *File)
|
||||||
{
|
{
|
||||||
// Always Save current version
|
// Always Save current version
|
||||||
File->Write(&VisibleFlag,sizeof(BOOL));
|
|
||||||
File->Write(&Mode,sizeof(MouseMode));
|
File->Write(&Mode,sizeof(MouseMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +73,12 @@ void CLayerThing::InitSubView(CCore *Core)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CLayerThing::LoadThingScript(const char *Filename)
|
||||||
|
{
|
||||||
|
ThingScript.LoadAndImport(Filename);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -133,7 +116,7 @@ CElemBank *IconBank=Core->GetIconBank();
|
|||||||
glTranslatef(-ScrOfsX,ScrOfsY,0); // Bring to top left corner
|
glTranslatef(-ScrOfsX,ScrOfsY,0); // Bring to top left corner
|
||||||
|
|
||||||
int ListSize=ThisThing.XY.size();
|
int ListSize=ThisThing.XY.size();
|
||||||
TRACE1("%i pts\n",ListSize);
|
TRACE1("%i\n",ListSize);
|
||||||
for (int i=0;i<ListSize; i++)
|
for (int i=0;i<ListSize; i++)
|
||||||
{
|
{
|
||||||
// Render Thing
|
// Render Thing
|
||||||
@ -285,7 +268,8 @@ Vector3 Ofs;
|
|||||||
ThisCam.x-=(int)ThisCam.x;
|
ThisCam.x-=(int)ThisCam.x;
|
||||||
ThisCam.y-=(int)ThisCam.y;
|
ThisCam.y-=(int)ThisCam.y;
|
||||||
|
|
||||||
if (Is3d && Render3dFlag)
|
Is3d&=GetRender3dFlag();
|
||||||
|
if (Is3d)
|
||||||
{
|
{
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
// Render(Core,ThisCam,,TRUE,0.5,&Ofs);
|
// Render(Core,ThisCam,,TRUE,0.5,&Ofs);
|
||||||
@ -353,6 +337,7 @@ void CLayerThing::SelectThing(CPoint &Pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int CLayerThing::CheckThingPoint(CPoint &Pos)
|
int CLayerThing::CheckThingPoint(CPoint &Pos)
|
||||||
|
@ -27,6 +27,7 @@ bool operator==(sLayerThing const &v1)
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
class CIni;
|
||||||
class CLayerThing : public CLayer
|
class CLayerThing : public CLayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -37,16 +38,16 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
CLayerThing(){};
|
CLayerThing(){};
|
||||||
CLayerThing(int SubType,int Width,int Height); // New Layer
|
CLayerThing(sLayerDef &Def); // New Layer
|
||||||
CLayerThing(CFile *File,int Version); // Load Layer
|
CLayerThing(CFile *File,int Version) {Load(File,Version);}
|
||||||
~CLayerThing();
|
~CLayerThing();
|
||||||
|
|
||||||
virtual int GetType() {return(LAYER_TYPE_ITEM);}
|
void InitLayer(sLayerDef &Def);
|
||||||
|
|
||||||
virtual void InitSubView(CCore *Core);
|
virtual void InitSubView(CCore *Core);
|
||||||
|
|
||||||
virtual void Render(CCore *Core,Vector3 &CamPos,bool Is3d);
|
virtual void Render(CCore *Core,Vector3 &CamPos,bool Is3d);
|
||||||
void RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d);
|
void RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d);
|
||||||
// void FindCursorPos(CCore *Core,Vector3 &CamPos,CPoint &MousePos);
|
|
||||||
|
|
||||||
virtual void GUIInit(CCore *Core);
|
virtual void GUIInit(CCore *Core);
|
||||||
virtual void GUIKill(CCore *Core);
|
virtual void GUIKill(CCore *Core);
|
||||||
@ -58,6 +59,7 @@ virtual void GUIChanged(CCore *Core);
|
|||||||
|
|
||||||
virtual void Load(CFile *File,int Version);
|
virtual void Load(CFile *File,int Version);
|
||||||
virtual void Save(CFile *File);
|
virtual void Save(CFile *File);
|
||||||
|
virtual void LoadThingScript(const char *Filename);
|
||||||
|
|
||||||
virtual void Export(CCore *Core,CExport &Exp);
|
virtual void Export(CCore *Core,CExport &Exp);
|
||||||
|
|
||||||
@ -78,16 +80,12 @@ protected:
|
|||||||
|
|
||||||
void UpdatePos(CPoint &Pos,int Thing,int PosNo,bool Recurs=false);
|
void UpdatePos(CPoint &Pos,int Thing,int PosNo,bool Recurs=false);
|
||||||
|
|
||||||
|
|
||||||
int Width,Height;
|
int Width,Height;
|
||||||
|
CIni ThingScript;
|
||||||
CElemBank *ThingBank;
|
CElemBank *ThingBank;
|
||||||
CList<sLayerThing> ThingList;
|
CList<sLayerThing> ThingList;
|
||||||
int CurrentThing,CurrentPoint;
|
int CurrentThing,CurrentPoint;
|
||||||
MouseMode Mode;
|
MouseMode Mode;
|
||||||
|
|
||||||
|
|
||||||
CGUIToolBar GUIToolBar;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -26,50 +26,15 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// New Layer
|
CLayerTile::CLayerTile(sLayerDef &Def)
|
||||||
CLayerTile::CLayerTile(int _SubType,int Width,int Height)
|
|
||||||
{
|
{
|
||||||
SubType=_SubType;
|
InitLayer(Def);
|
||||||
TileBank=0;
|
|
||||||
if (SubType==LAYER_SUBTYPE_ACTION)
|
|
||||||
TileBank=new CTileBank;
|
|
||||||
else
|
|
||||||
TileBank=0;
|
|
||||||
SubView=TileBank;
|
|
||||||
|
|
||||||
SetDefaultParams();
|
|
||||||
|
|
||||||
Mode=MouseModePaint;
|
|
||||||
|
|
||||||
if (ResizeFlag)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
|
|
||||||
Map.SetSize(Width,Height,TRUE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
// Load Layer
|
|
||||||
CLayerTile::CLayerTile(CFile *File,int Version)
|
|
||||||
{
|
|
||||||
Load(File,Version);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CLayerTile::~CLayerTile()
|
CLayerTile::~CLayerTile()
|
||||||
{
|
{
|
||||||
if (SubType==LAYER_SUBTYPE_ACTION)
|
if (LayerDef.SubType==LAYER_SUBTYPE_ACTION)
|
||||||
{
|
{
|
||||||
TileBank->CleanUp();
|
TileBank->CleanUp();
|
||||||
delete TileBank;
|
delete TileBank;
|
||||||
@ -77,36 +42,61 @@ CLayerTile::~CLayerTile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::Load(CFile *File,int Version)
|
void CLayerTile::InitLayer(sLayerDef &Def)
|
||||||
{
|
{
|
||||||
File->Read(&Render3dFlag,sizeof(BOOL));
|
CLayer::InitLayer(Def);
|
||||||
File->Read(&ScaleFactor,sizeof(float));
|
Mode=MouseModePaint;
|
||||||
File->Read(&ResizeFlag,sizeof(BOOL));
|
|
||||||
File->Read(&VisibleFlag,sizeof(BOOL));
|
|
||||||
File->Read(&Mode,sizeof(MouseMode));
|
|
||||||
File->Read(&SubType,sizeof(int));
|
|
||||||
Map.Load(File,Version);
|
|
||||||
|
|
||||||
if (SubType==LAYER_SUBTYPE_ACTION)
|
if (LayerDef.SubType==LAYER_SUBTYPE_ACTION)
|
||||||
TileBank=new CTileBank;
|
TileBank=new CTileBank;
|
||||||
else
|
else
|
||||||
TileBank=0;
|
TileBank=0;
|
||||||
SubView=TileBank;
|
SubView=TileBank;
|
||||||
|
|
||||||
TRACE1("%s\t",GetName());
|
if (!GetResizeFlag())
|
||||||
|
{
|
||||||
|
LayerDef.Width=32;
|
||||||
|
LayerDef.Height=32;
|
||||||
|
}
|
||||||
|
|
||||||
|
Resize(LayerDef.Width,LayerDef.Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CLayerTile::Load(CFile *File,int Version)
|
||||||
|
{
|
||||||
|
if (Version<=5)
|
||||||
|
{
|
||||||
|
LayerDef.Type=LAYER_TYPE_TILE;
|
||||||
|
BOOL DB;
|
||||||
|
float DF;
|
||||||
|
File->Read(&DB,sizeof(BOOL));
|
||||||
|
File->Read(&DF,sizeof(float));
|
||||||
|
File->Read(&DB,sizeof(BOOL));
|
||||||
|
File->Read(&LayerDef.VisibleFlag,sizeof(BOOL));
|
||||||
|
File->Read(&Mode,sizeof(MouseMode));
|
||||||
|
File->Read(&LayerDef.SubType,sizeof(int));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File->Read(&Mode,sizeof(MouseMode));
|
||||||
|
}
|
||||||
|
InitLayer(LayerDef);
|
||||||
|
Map.Load(File,Version);
|
||||||
|
|
||||||
|
// if (LayerDef.SubType==LAYER_SUBTYPE_ACTION)
|
||||||
|
// TileBank=new CTileBank;
|
||||||
|
// else
|
||||||
|
// TileBank=0;
|
||||||
|
// SubView=TileBank;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::Save(CFile *File)
|
void CLayerTile::Save(CFile *File)
|
||||||
{
|
{
|
||||||
// Always Save current version
|
// 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(&Mode,sizeof(MouseMode));
|
||||||
File->Write(&SubType,sizeof(SubType));
|
|
||||||
Map.Save(File);
|
Map.Save(File);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +104,7 @@ void CLayerTile::Save(CFile *File)
|
|||||||
void CLayerTile::InitSubView(CCore *Core)
|
void CLayerTile::InitSubView(CCore *Core)
|
||||||
{
|
{
|
||||||
// Fix up shared layers
|
// Fix up shared layers
|
||||||
if (SubType!=LAYER_SUBTYPE_ACTION)
|
if (LayerDef.SubType!=LAYER_SUBTYPE_ACTION)
|
||||||
{
|
{
|
||||||
TileBank=Core->GetTileBank();
|
TileBank=Core->GetTileBank();
|
||||||
SubView=(CLayer*)TileBank;
|
SubView=(CLayer*)TileBank;
|
||||||
@ -133,22 +123,75 @@ void CLayerTile::CheckLayerSize(int Width,int Height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CLayerTile::Validate(CCore *Core)
|
||||||
|
{
|
||||||
|
int Width=Map.GetWidth();
|
||||||
|
int Height=Map.GetHeight();
|
||||||
|
int Invalid=0;
|
||||||
|
int X,Y;
|
||||||
|
bool Ret=false;
|
||||||
|
|
||||||
|
for (Y=0; Y<Height; Y++)
|
||||||
|
{
|
||||||
|
for (X=0; X<Width; X++)
|
||||||
|
{
|
||||||
|
sMapElem &MapElem=Map.Get(X,Y);
|
||||||
|
if (!TileBank->IsValid(MapElem.Set,MapElem.Tile))
|
||||||
|
{
|
||||||
|
Invalid++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Invalid)
|
||||||
|
{
|
||||||
|
char Txt[256];
|
||||||
|
sprintf(Txt,"Map contains %i invalid tiles\n Do you want them removed?",Invalid);
|
||||||
|
Ret=Core->Question(Txt);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (Ret)
|
||||||
|
{
|
||||||
|
for (Y=0; Y<Height; Y++)
|
||||||
|
{
|
||||||
|
for (X=0; X<Width; X++)
|
||||||
|
{
|
||||||
|
sMapElem &MapElem=Map.Get(X,Y);
|
||||||
|
if (!TileBank->IsValid(MapElem.Set,MapElem.Tile))
|
||||||
|
{
|
||||||
|
MapElem.Set=0;
|
||||||
|
MapElem.Tile=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
bool CLayerTile::Resize(int Width,int Height)
|
bool CLayerTile::Resize(int Width,int Height)
|
||||||
{
|
{
|
||||||
if (!ResizeFlag) return(FALSE); // Its a fixed size, so DONT DO IT!
|
|
||||||
|
|
||||||
int ThisWidth=Map.GetWidth();
|
int ThisWidth=Map.GetWidth();
|
||||||
int ThisHeight=Map.GetHeight();
|
int ThisHeight=Map.GetHeight();
|
||||||
Width=TileLayerMinWidth+(Width-TileLayerMinWidth)/ScaleFactor;
|
bool Flag=GetResizeFlag();
|
||||||
Height=TileLayerMinHeight+(Height-TileLayerMinHeight)/ScaleFactor;
|
|
||||||
|
|
||||||
|
Width=TileLayerMinWidth+(Width-TileLayerMinWidth)/GetScaleFactor();
|
||||||
|
Height=TileLayerMinHeight+(Height-TileLayerMinHeight)/GetScaleFactor();
|
||||||
|
|
||||||
|
if (Width<TileLayerMinWidth) Width=TileLayerMinWidth;
|
||||||
|
if (Height<TileLayerMinHeight) Height=TileLayerMinHeight;
|
||||||
|
|
||||||
|
if (!ThisWidth || !ThisHeight) Flag=true;
|
||||||
|
|
||||||
|
if (Flag)
|
||||||
|
{
|
||||||
if (ThisWidth!=Width || ThisHeight!=Height)
|
if (ThisWidth!=Width || ThisHeight!=Height)
|
||||||
{
|
{
|
||||||
Map.Resize(Width,Height);
|
Map.Resize(Width,Height);
|
||||||
return(TRUE);
|
return(true);
|
||||||
}
|
}
|
||||||
return(FALSE);
|
}
|
||||||
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -158,7 +201,7 @@ void CLayerTile::Render(CCore *Core,Vector3 &CamPos,bool Is3d)
|
|||||||
{
|
{
|
||||||
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
||||||
|
|
||||||
Is3d&=Render3dFlag;
|
Is3d&=GetRender3dFlag();
|
||||||
Render(Core,ThisCam,Map,Is3d);
|
Render(Core,ThisCam,Map,Is3d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +222,8 @@ Vector3 Ofs;
|
|||||||
ThisCam.x-=(int)ThisCam.x;
|
ThisCam.x-=(int)ThisCam.x;
|
||||||
ThisCam.y-=(int)ThisCam.y;
|
ThisCam.y-=(int)ThisCam.y;
|
||||||
|
|
||||||
if (Is3d && Render3dFlag)
|
Is3d&=GetRender3dFlag();
|
||||||
|
if (Is3d)
|
||||||
{
|
{
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
Render(Core,ThisCam,Brush,TRUE,0.5,&Ofs);
|
Render(Core,ThisCam,Brush,TRUE,0.5,&Ofs);
|
||||||
@ -201,13 +245,17 @@ float ZoomH=Core->GetZoomH();
|
|||||||
float ScrOfsX=(ZoomW/2);
|
float ScrOfsX=(ZoomW/2);
|
||||||
float ScrOfsY=(ZoomH/2);
|
float ScrOfsY=(ZoomH/2);
|
||||||
Vector3 &Scale=Core->GetScaleVector();
|
Vector3 &Scale=Core->GetScaleVector();
|
||||||
bool WrapMap=SubType==LAYER_SUBTYPE_BACK;
|
bool WrapMap=LayerDef.SubType==LAYER_SUBTYPE_BACK;
|
||||||
int StartX=(int)ThisCam.x;
|
int StartX=(int)ThisCam.x;
|
||||||
int StartY=(int)ThisCam.y;
|
int StartY=(int)ThisCam.y;
|
||||||
float ShiftX=ThisCam.x - (int)ThisCam.x;
|
float ShiftX=ThisCam.x - (int)ThisCam.x;
|
||||||
float ShiftY=ThisCam.y - (int)ThisCam.y;
|
float ShiftY=ThisCam.y - (int)ThisCam.y;
|
||||||
|
|
||||||
if (TileBank->NeedLoad()) TileBank->LoadAllSets(Core);
|
if (TileBank->NeedLoad())
|
||||||
|
{
|
||||||
|
TileBank->LoadAllSets(Core);
|
||||||
|
Core->Validate(GetType());
|
||||||
|
}
|
||||||
|
|
||||||
if (StartX<0) StartX=0;
|
if (StartX<0) StartX=0;
|
||||||
if (StartY<0) StartY=0;
|
if (StartY<0) StartY=0;
|
||||||
@ -585,7 +633,9 @@ void CLayerTile::Export(CCore *Core,CExport &Exp)
|
|||||||
int Width=Map.GetWidth();
|
int Width=Map.GetWidth();
|
||||||
int Height=Map.GetHeight();
|
int Height=Map.GetHeight();
|
||||||
|
|
||||||
Exp.ExportLayerHeader(LAYER_TYPE_TILE,SubType,Width,Height);
|
LayerDef.Width=Width;
|
||||||
|
LayerDef.Height=Height;
|
||||||
|
Exp.ExportLayerHeader(LayerDef);
|
||||||
|
|
||||||
for (int Y=0; Y<Height; Y++)
|
for (int Y=0; Y<Height; Y++)
|
||||||
{
|
{
|
||||||
|
@ -23,12 +23,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
CLayerTile(){};
|
CLayerTile(){};
|
||||||
CLayerTile(int SubType,int Width,int Height); // New Layer
|
// CLayerTile(int Type,int SubType,int Width,int Height);
|
||||||
CLayerTile(CFile *File,int Version); // Load Layer
|
CLayerTile(sLayerDef &Def);
|
||||||
|
CLayerTile(CFile *File,int Version) {Load(File,Version);}
|
||||||
~CLayerTile();
|
~CLayerTile();
|
||||||
|
|
||||||
int GetType() {return(LAYER_TYPE_TILE);}
|
void InitLayer(sLayerDef &Def);
|
||||||
int GetSubType() {return(SubType);}
|
|
||||||
void InitSubView(CCore *Core);
|
void InitSubView(CCore *Core);
|
||||||
|
|
||||||
virtual void Render(CCore *Core,Vector3 &CamPos,bool Is3d);
|
virtual void Render(CCore *Core,Vector3 &CamPos,bool Is3d);
|
||||||
@ -47,6 +47,7 @@ virtual void GUIChanged(CCore *Core);
|
|||||||
void Load(CFile *File,int Version);
|
void Load(CFile *File,int Version);
|
||||||
void Save(CFile *File);
|
void Save(CFile *File);
|
||||||
void CheckLayerSize(int Width,int Height);
|
void CheckLayerSize(int Width,int Height);
|
||||||
|
void Validate(CCore *Core);
|
||||||
|
|
||||||
void Export(CCore *Core,CExport &Exp);
|
void Export(CCore *Core,CExport &Exp);
|
||||||
|
|
||||||
@ -75,7 +76,6 @@ protected:
|
|||||||
bool Paint(CMap &Blk,CPoint &CursorPos);
|
bool Paint(CMap &Blk,CPoint &CursorPos);
|
||||||
|
|
||||||
CMap Map;
|
CMap Map;
|
||||||
int SubType;
|
|
||||||
MouseMode Mode;
|
MouseMode Mode;
|
||||||
|
|
||||||
CTileBank *TileBank;
|
CTileBank *TileBank;
|
||||||
|
@ -29,19 +29,19 @@ Class17=CMapEditDoc
|
|||||||
Class18=CMapEditView
|
Class18=CMapEditView
|
||||||
|
|
||||||
ResourceCount=14
|
ResourceCount=14
|
||||||
Resource1=IDD_LAYER_SHADE
|
Resource1=IDD_ADDLAYER
|
||||||
Resource2=IDR_MAPEDITYPE (English (U.S.))
|
Resource2=IDR_MAPEDITYPE (English (U.S.))
|
||||||
Resource3=IDD_TILEBANK
|
Resource3=IDD_TOOLBAR
|
||||||
Resource4=IDD_TOOLBAR
|
Resource4=IDD_NEWMAP
|
||||||
Resource5=IDD_ADDLAYER
|
Resource5=IDD_LAYER_LIST
|
||||||
Resource6=IDD_LAYER_COLLISION
|
Resource6=IDD_TILEBANK
|
||||||
Resource7=IDR_TOOLBAR (English (U.S.))
|
Resource7=IDD_RESIZE
|
||||||
Resource8=IDR_MAINFRAME (English (U.S.))
|
Resource8=IDD_LAYER_SHADE
|
||||||
Resource9=IDD_ABOUTBOX (English (U.S.))
|
Resource9=IDD_LAYER_COLLISION
|
||||||
Resource10=IDD_MULTIBAR (English (U.S.))
|
Resource10=IDR_TOOLBAR (English (U.S.))
|
||||||
Resource11=IDD_LAYER_LIST
|
Resource11=IDR_MAINFRAME (English (U.S.))
|
||||||
Resource12=IDD_RESIZE
|
Resource12=IDD_ABOUTBOX (English (U.S.))
|
||||||
Resource13=IDD_NEWMAP
|
Resource13=IDD_MULTIBAR (English (U.S.))
|
||||||
Resource14=IDD_ELEMLIST
|
Resource14=IDD_ELEMLIST
|
||||||
|
|
||||||
[CLS:CChildFrame]
|
[CLS:CChildFrame]
|
||||||
@ -164,7 +164,7 @@ Control3=IDC_ADDLAYER_LIST,listbox,1352728833
|
|||||||
Type=1
|
Type=1
|
||||||
Class=CGUIElemList
|
Class=CGUIElemList
|
||||||
ControlCount=1
|
ControlCount=1
|
||||||
Control1=IDD_ELEM_LIST,combobox,1342242819
|
Control1=IDD_ELEM_LIST,combobox,1344339971
|
||||||
|
|
||||||
[DLG:IDD_LAYER_COLLISION]
|
[DLG:IDD_LAYER_COLLISION]
|
||||||
Type=1
|
Type=1
|
||||||
|
@ -580,7 +580,8 @@ IDD_ELEMLIST DIALOG DISCARDABLE 0, 0, 156, 26
|
|||||||
STYLE WS_CHILD
|
STYLE WS_CHILD
|
||||||
FONT 8, "MS Sans Serif"
|
FONT 8, "MS Sans Serif"
|
||||||
BEGIN
|
BEGIN
|
||||||
COMBOBOX IDD_ELEM_LIST,7,7,138,322,CBS_DROPDOWNLIST | WS_TABSTOP
|
COMBOBOX IDD_ELEM_LIST,7,7,138,322,CBS_DROPDOWNLIST | WS_VSCROLL |
|
||||||
|
WS_TABSTOP
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ CTileBank::~CTileBank()
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CTileBank::Load(CFile *File,int Version)
|
void CTileBank::Load(CFile *File,int Version)
|
||||||
{
|
{
|
||||||
if (Version<FileVersion)
|
if (Version<=4)
|
||||||
{
|
{
|
||||||
File->Read(&LayerCam,sizeof(Vector3));
|
File->Read(&LayerCam,sizeof(Vector3));
|
||||||
File->Read(&CurrentSet,sizeof(int));
|
File->Read(&CurrentSet,sizeof(int));
|
||||||
|
Loading…
Reference in New Issue
Block a user