This commit is contained in:
parent
3ca7299ba4
commit
f201ec651f
22 changed files with 900 additions and 655 deletions
|
@ -9,30 +9,30 @@ enum CmdMsg
|
||||||
{
|
{
|
||||||
CmdMsg_None=0,
|
CmdMsg_None=0,
|
||||||
// Core
|
// Core
|
||||||
CmdMsg_ToggleSubView,
|
CmdMsg_ToggleSubView, // 1
|
||||||
CmdMsg_ToggleGrid,
|
CmdMsg_ToggleGrid, // 2
|
||||||
CmdMsg_Toggle2d,
|
CmdMsg_Toggle2d, // 3
|
||||||
CmdMsg_ZoomIn,
|
CmdMsg_ZoomIn, // 4
|
||||||
CmdMsg_ZoomOut,
|
CmdMsg_ZoomOut, // 5
|
||||||
CmdMsg_ResetView,
|
CmdMsg_ResetView, // 6
|
||||||
CmdMsg_SetLayer,
|
CmdMsg_SetLayer, // 7
|
||||||
CmdMsg_AddLayer,
|
CmdMsg_AddLayer, // 8
|
||||||
CmdMsg_DeleteLayer,
|
CmdMsg_DeleteLayer, // 9
|
||||||
|
|
||||||
// Generic
|
// Generic
|
||||||
CmdMsg_SetMode,
|
CmdMsg_SetMode, // 10
|
||||||
CmdMsg_Copy,
|
CmdMsg_Copy, // 11
|
||||||
CmdMsg_Paste,
|
CmdMsg_Paste, // 12
|
||||||
CmdMsg_SubViewLoad,
|
CmdMsg_SubViewLoad, // 13
|
||||||
CmdMsg_SubViewDelete,
|
CmdMsg_SubViewDelete, // 14
|
||||||
CmdMsg_SubViewUpdate,
|
CmdMsg_SubViewUpdate, // 15
|
||||||
CmdMsg_SubViewSet,
|
CmdMsg_SubViewSet, // 16
|
||||||
// TileLayer/TileBank
|
// TileLayer/TileBank
|
||||||
CmdMsg_MirrorX,
|
CmdMsg_MirrorX, // 17
|
||||||
CmdMsg_MirrorY,
|
CmdMsg_MirrorY, // 18
|
||||||
CmdMsg_SetColFlag,
|
CmdMsg_SetColFlag, // 19
|
||||||
CmdMsg_ActiveBrushLeft,
|
CmdMsg_ActiveBrushLeft, // 20
|
||||||
CmdMsg_ActiveBrushRight,
|
CmdMsg_ActiveBrushRight, // 21
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -15,11 +15,12 @@
|
||||||
#include "MainFrm.h"
|
#include "MainFrm.h"
|
||||||
|
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
|
#include "Elem.h"
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "LayerTile.h"
|
#include "LayerTile.h"
|
||||||
#include "LayerCollision.h"
|
#include "LayerCollision.h"
|
||||||
#include "LayerShade.h"
|
#include "LayerShade.h"
|
||||||
#include "LayerItem.h"
|
#include "LayerThing.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include "Export.h"
|
#include "Export.h"
|
||||||
|
@ -28,6 +29,8 @@
|
||||||
#include "GUINewMap.h"
|
#include "GUINewMap.h"
|
||||||
|
|
||||||
|
|
||||||
|
GString IconzFileName="Iconz.bmp";
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -42,11 +45,19 @@ CCore::CCore()
|
||||||
CursorPos.x=CursorPos.y=0;
|
CursorPos.x=CursorPos.y=0;
|
||||||
CurrentLayer=0;
|
CurrentLayer=0;
|
||||||
|
|
||||||
|
GString Filename;
|
||||||
|
IconBank=new CElemBank(16,16,false,false);
|
||||||
|
|
||||||
|
GetExecPath(Filename);
|
||||||
|
Filename+=IconzFileName;
|
||||||
|
IconBank->AddSet(Filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CCore::~CCore()
|
CCore::~CCore()
|
||||||
{
|
{
|
||||||
|
IconBank->CleanUp();
|
||||||
|
delete IconBank;
|
||||||
int ListSize=Layer.size();
|
int ListSize=Layer.size();
|
||||||
for (int i=0; i<ListSize; i++) delete Layer[i];
|
for (int i=0; i<ListSize; i++) delete Layer[i];
|
||||||
}
|
}
|
||||||
|
@ -101,7 +112,7 @@ Vector3 DuffVector;
|
||||||
TRACE1("Load Version %i\n",Version);
|
TRACE1("Load Version %i\n",Version);
|
||||||
|
|
||||||
File->Read(&MapCam,sizeof(Vector3));
|
File->Read(&MapCam,sizeof(Vector3));
|
||||||
if (Version<FileVersion)
|
if (Version<4)
|
||||||
{
|
{
|
||||||
File->Read(&MapCamOfs,sizeof(Vector3));
|
File->Read(&MapCamOfs,sizeof(Vector3));
|
||||||
File->Read(&DuffVector,sizeof(Vector3));
|
File->Read(&DuffVector,sizeof(Vector3));
|
||||||
|
@ -134,7 +145,7 @@ int LayerCount;
|
||||||
AddLayer(new CLayerShade(File,Version));
|
AddLayer(new CLayerShade(File,Version));
|
||||||
break;
|
break;
|
||||||
case LAYER_TYPE_ITEM:
|
case LAYER_TYPE_ITEM:
|
||||||
AddLayer(new CLayerItem(File,Version));
|
AddLayer(new CLayerThing(File,Version));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(!"poos");
|
ASSERT(!"poos");
|
||||||
|
@ -172,7 +183,6 @@ BOOL F;
|
||||||
F=GridFlag; File->Write(&F,sizeof(BOOL));
|
F=GridFlag; File->Write(&F,sizeof(BOOL));
|
||||||
F=Is3dFlag; File->Write(&F,sizeof(BOOL));
|
F=Is3dFlag; File->Write(&F,sizeof(BOOL));
|
||||||
|
|
||||||
|
|
||||||
// Layers
|
// Layers
|
||||||
int LayerCount=Layer.size();
|
int LayerCount=Layer.size();
|
||||||
File->Write(&LayerCount,sizeof(int));
|
File->Write(&LayerCount,sizeof(int));
|
||||||
|
@ -185,12 +195,6 @@ int LayerCount=Layer.size();
|
||||||
Layer[i]->Save(File);
|
Layer[i]->Save(File);
|
||||||
}
|
}
|
||||||
GetTileBank()->Save(File);
|
GetTileBank()->Save(File);
|
||||||
/*
|
|
||||||
CString a=File->GetFilePath();
|
|
||||||
char Txt[256];
|
|
||||||
sprintf(Txt,"%s",a);
|
|
||||||
Export(Txt);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -217,44 +221,32 @@ Vector3 &ThisCam=GetCam();
|
||||||
UpdateAll();
|
UpdateAll();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if (GetTileBank()->NeedLoad()) GetTileBank()->LoadAllSets(this);
|
if (IconBank->NeedLoad()) IconBank->LoadAllSets(this);
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen
|
||||||
|
|
||||||
if (IsSubView() || CurrentLayer->IsUnique())
|
RenderLayers(IsSubView() || CurrentLayer->IsUnique());
|
||||||
{
|
|
||||||
CurrentLayer->Render(this,ThisCam,Is3dFlag);
|
|
||||||
if (GridFlag) CurrentLayer->RenderGrid(this,ThisCam,true);
|
|
||||||
CurrentLayer->FindCursorPos(this,GetCam(),CurrentMousePos);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RenderLayers();
|
|
||||||
}
|
|
||||||
CurrentLayer->RenderCursor(this,ThisCam,Is3dFlag);
|
|
||||||
// Get Cursor Pos
|
|
||||||
LastCursorPos=CursorPos;
|
|
||||||
CurrentLayer->FindCursorPos(this,GetCam(),CurrentMousePos);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CCore::RenderLayers()
|
void CCore::RenderLayers(bool OneShot)
|
||||||
{
|
{
|
||||||
Vector3 &ThisCam=GetCam();
|
Vector3 &ThisCam=GetCam();
|
||||||
int ListSize=Layer.size();
|
int ListSize=Layer.size();
|
||||||
int StartLayer,EndLayer;
|
int StartLayer,EndLayer;
|
||||||
|
|
||||||
|
if (OneShot)
|
||||||
|
{
|
||||||
|
StartLayer=ActiveLayer;
|
||||||
|
EndLayer=StartLayer+1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
StartLayer=0;
|
StartLayer=0;
|
||||||
EndLayer=ListSize;
|
EndLayer=ListSize;
|
||||||
|
while (Layer[StartLayer]->IsUnique()) StartLayer++;
|
||||||
// while (Layer[StartLayer]->IsUnique()) StartLayer++;
|
}
|
||||||
|
|
||||||
// if (Layer[ActiveLayer]->IsUnique())
|
|
||||||
// {
|
|
||||||
// StartLayer=ActiveLayer;
|
|
||||||
// EndLayer=StartLayer+1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
for (int i=StartLayer; i<EndLayer; i++)
|
for (int i=StartLayer; i<EndLayer; i++)
|
||||||
{
|
{
|
||||||
|
@ -264,6 +256,10 @@ int StartLayer,EndLayer;
|
||||||
if (GridFlag) Layer[i]->RenderGrid(this,ThisCam,i==ActiveLayer);
|
if (GridFlag) Layer[i]->RenderGrid(this,ThisCam,i==ActiveLayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CurrentLayer->RenderCursor(this,ThisCam,Is3dFlag);
|
||||||
|
// Get Cursor Pos
|
||||||
|
LastCursorPos=CursorPos;
|
||||||
|
CurrentLayer->FindCursorPos(this,GetCam(),CurrentMousePos);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,7 +415,7 @@ CMainFrame *Frm=(CMainFrame*)AfxGetMainWnd();
|
||||||
CGUIMultiBar *ParamBar=Frm->GetParamBar();
|
CGUIMultiBar *ParamBar=Frm->GetParamBar();
|
||||||
|
|
||||||
GUIRemoveAll();
|
GUIRemoveAll();
|
||||||
GUIAdd(LayerList,IDD_LAYER_LIST_DIALOG);
|
GUIAdd(LayerList,IDD_LAYER_LIST);
|
||||||
CurrentLayer->GUIInit(this);
|
CurrentLayer->GUIInit(this);
|
||||||
GUIUpdate();
|
GUIUpdate();
|
||||||
}
|
}
|
||||||
|
@ -513,7 +509,7 @@ int Idx;
|
||||||
Idx=AddLayer(new CLayerShade(SubType, Width,Height));
|
Idx=AddLayer(new CLayerShade(SubType, Width,Height));
|
||||||
break;
|
break;
|
||||||
case LAYER_TYPE_ITEM:
|
case LAYER_TYPE_ITEM:
|
||||||
Idx=AddLayer(new CLayerItem(SubType, Width,Height));
|
Idx=AddLayer(new CLayerThing(SubType, Width,Height));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(!"AddLayer - Invalid Layer Type");
|
ASSERT(!"AddLayer - Invalid Layer Type");
|
||||||
|
@ -669,6 +665,19 @@ Vector3 &ThisCam=GetCam();
|
||||||
ThisCam=DefaultCamPos;
|
ThisCam=DefaultCamPos;
|
||||||
UpdateView();
|
UpdateView();
|
||||||
}
|
}
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CCore::GetExecPath(GString &Path)
|
||||||
|
{
|
||||||
|
// Get application path
|
||||||
|
char ExeFilename[2048];
|
||||||
|
GFName Exe;
|
||||||
|
GetModuleFileName(GetModuleHandle(NULL),ExeFilename,2048);
|
||||||
|
Exe=ExeFilename;
|
||||||
|
Exe.File(0);
|
||||||
|
Exe.Ext(0);
|
||||||
|
Path=Exe.FullName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*** GUI *********************************************************************/
|
/*** GUI *********************************************************************/
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "LayerTile.h"
|
#include "LayerTile.h"
|
||||||
|
|
||||||
const s32 FileVersion=4;
|
const s32 FileVersion=5;
|
||||||
|
|
||||||
#define SCREEN_MAP_WIDTH 30
|
#define SCREEN_MAP_WIDTH 30
|
||||||
#define SCREEN_MAP_HEIGHT 20
|
#define SCREEN_MAP_HEIGHT 20
|
||||||
|
@ -41,7 +41,7 @@ public:
|
||||||
void Save(CFile *File);
|
void Save(CFile *File);
|
||||||
bool Question(char *Txt);
|
bool Question(char *Txt);
|
||||||
void Render(bool ForceRender=FALSE);
|
void Render(bool ForceRender=FALSE);
|
||||||
void RenderLayers();
|
void RenderLayers(bool OneShot=false);
|
||||||
void Export(char *Filename);
|
void Export(char *Filename);
|
||||||
|
|
||||||
// View Stuff
|
// View Stuff
|
||||||
|
@ -114,7 +114,8 @@ public:
|
||||||
void PasteSelection();
|
void PasteSelection();
|
||||||
|
|
||||||
void ResetView();
|
void ResetView();
|
||||||
|
CElemBank *GetIconBank() {return(IconBank);}
|
||||||
|
void GetExecPath(GString &Path);
|
||||||
private:
|
private:
|
||||||
CMapEditView *CurrentView;
|
CMapEditView *CurrentView;
|
||||||
CPoint CurrentMousePos,LastMousePos;
|
CPoint CurrentMousePos,LastMousePos;
|
||||||
|
@ -136,6 +137,8 @@ private:
|
||||||
bool GridFlag;
|
bool GridFlag;
|
||||||
bool Is3dFlag;
|
bool Is3dFlag;
|
||||||
|
|
||||||
|
CElemBank *IconBank;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <Vector3.h>
|
#include <Vector3.h>
|
||||||
#include <gl\gl.h>
|
#include <gl\gl.h>
|
||||||
#include <gl\glu.h>
|
#include <gl\glu.h>
|
||||||
|
#include "GLEnabledView.h"
|
||||||
#include <Vector>
|
#include <Vector>
|
||||||
#include <GFName.hpp>
|
#include <GFName.hpp>
|
||||||
|
|
||||||
|
@ -15,7 +16,25 @@
|
||||||
#include "GinTex.h"
|
#include "GinTex.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include "MapEdit.h"
|
||||||
|
#include "MapEditDoc.h"
|
||||||
|
#include "MapEditView.h"
|
||||||
|
#include "MainFrm.h"
|
||||||
|
|
||||||
|
#include "GUITileBank.h"
|
||||||
|
|
||||||
|
|
||||||
|
const Vector3 DefOfs(+0.5f,0,+4.0f);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
// All Elems MUST run from 0,0 ->
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
const float ElemBrowserGap=0.2f;
|
||||||
|
const float ElemBrowserX0=0-ElemBrowserGap/2;
|
||||||
|
const float ElemBrowserX1=1+ElemBrowserGap/2;
|
||||||
|
const float ElemBrowserY0=0-ElemBrowserGap/2;
|
||||||
|
const float ElemBrowserY1=1+ElemBrowserGap/2;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
const float XFlipMtx[]=
|
const float XFlipMtx[]=
|
||||||
|
@ -66,10 +85,11 @@ GFName Path=Filename;
|
||||||
Type=ElemType3d;
|
Type=ElemType3d;
|
||||||
TexXOfs=-1;
|
TexXOfs=-1;
|
||||||
TexYOfs=-1;
|
TexYOfs=-1;
|
||||||
|
Ofs.Zero();
|
||||||
Build3dElem(TexCache,ThisScene,Node);
|
Build3dElem(TexCache,ThisScene,Node);
|
||||||
Calc3dSize();
|
Calc3dSize();
|
||||||
Ofs.x=+0.5f; Ofs.y=0; Ofs.z=+4.0f;
|
|
||||||
Build3dDrawList(TexCache,DrawList[ElemType3d]);
|
Build3dDrawList(TexCache,DrawList[ElemType3d]);
|
||||||
|
Ofs.Zero();
|
||||||
Create2dTexture(TexCache,Path.File(),Node);
|
Create2dTexture(TexCache,Path.File(),Node);
|
||||||
Build2dDrawList(TexCache,DrawList[ElemType2d]);
|
Build2dDrawList(TexCache,DrawList[ElemType2d]);
|
||||||
if (!ValidFlag) CreateInvalidTileGfx();
|
if (!ValidFlag) CreateInvalidTileGfx();
|
||||||
|
@ -78,7 +98,7 @@ GFName Path=Filename;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// 2d Elem (From Bmp File)
|
// 2d Elem (From Bmp File)
|
||||||
CElem::CElem(CCore *Core,const char *Filename,int TexID,int XOfs,int YOfs,int Width,int Height)
|
CElem::CElem(CCore *Core,const char *Filename,int TexID,int XOfs,int YOfs,int Width,int Height,bool Centre)
|
||||||
{
|
{
|
||||||
CTexCache &TexCache=Core->GetTexCache();
|
CTexCache &TexCache=Core->GetTexCache();
|
||||||
GFName Path=Filename;
|
GFName Path=Filename;
|
||||||
|
@ -91,8 +111,15 @@ GFName Path=Filename;
|
||||||
Type=ElemType2d;
|
Type=ElemType2d;
|
||||||
TexXOfs=XOfs;
|
TexXOfs=XOfs;
|
||||||
TexYOfs=YOfs;
|
TexYOfs=YOfs;
|
||||||
Build2dElem(Core,Path.File(),TexID);
|
|
||||||
Ofs.Zero();
|
Ofs.Zero();
|
||||||
|
if (Centre)
|
||||||
|
{
|
||||||
|
Ofs.x=0.5-UnitWidth/2;
|
||||||
|
// Ofs.y=0.5-UnitHeight/2;
|
||||||
|
Ofs.y=-1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
Build2dElem(Core,Path.File(),TexID);
|
||||||
Build3dDrawList(TexCache,DrawList[ElemType3d]);
|
Build3dDrawList(TexCache,DrawList[ElemType3d]);
|
||||||
Create2dTexture(TexCache,Path.File(),TexID);
|
Create2dTexture(TexCache,Path.File(),TexID);
|
||||||
Build2dDrawList(TexCache,DrawList[ElemType2d]);
|
Build2dDrawList(TexCache,DrawList[ElemType2d]);
|
||||||
|
@ -108,10 +135,15 @@ void CElem::CleanUp()
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CElem::Build2dElem(CCore *Core,const char *Filename,int TexID)
|
void CElem::Build2dElem(CCore *Core,const char *Filename,int TexID)
|
||||||
{
|
{
|
||||||
const Vector3 P0(0.0f,0.0f,0.0f);
|
float X0=0;
|
||||||
const Vector3 P1(1.0f,0.0f,0.0f);
|
float X1=+UnitWidth;
|
||||||
const Vector3 P2(0.0f,1.0f,0.0f);
|
float Y0=0;
|
||||||
const Vector3 P3(1.0f,1.0f,0.0f);
|
float Y1=+UnitHeight;
|
||||||
|
|
||||||
|
Vector3 P0(X0,Y0,0);
|
||||||
|
Vector3 P1(X1,Y0,0);
|
||||||
|
Vector3 P2(X0,Y1,0);
|
||||||
|
Vector3 P3(X1,Y1,0);
|
||||||
|
|
||||||
int ListSize=TriList.size();
|
int ListSize=TriList.size();
|
||||||
TriList.resize(ListSize+2);
|
TriList.resize(ListSize+2);
|
||||||
|
@ -121,13 +153,14 @@ sTriFace &Tri1=TriList[ListSize+1];
|
||||||
CTexCache &TexCache=Core->GetTexCache();
|
CTexCache &TexCache=Core->GetTexCache();
|
||||||
sTex &ThisTex=TexCache.GetTex(TexID);
|
sTex &ThisTex=TexCache.GetTex(TexID);
|
||||||
|
|
||||||
float u0,u1,v0,v1;
|
float dU=1.0/((float)ThisTex.TexWidth/(float)ElemWidth);
|
||||||
|
float dV=1.0/((float)ThisTex.TexHeight/(float)ElemHeight);
|
||||||
|
|
||||||
u0=(TexXOfs)*ThisTex.dW;
|
float u0=(TexXOfs*dU);
|
||||||
u1=u0+ThisTex.dW;
|
float u1=u0+dU;
|
||||||
|
|
||||||
v0=(((ThisTex.TexHeight/UnitSize)-(TexYOfs+1))*ThisTex.dH);
|
float v1=1.0-(TexYOfs*dV);
|
||||||
v1=v0+ThisTex.dH;
|
float v0=v1-dV;
|
||||||
|
|
||||||
Tri0.Mat=TexID;
|
Tri0.Mat=TexID;
|
||||||
|
|
||||||
|
@ -151,13 +184,15 @@ float u0,u1,v0,v1;
|
||||||
void CElem::Build3dElem(CTexCache &TexCache,CScene &ThisScene,int Node)
|
void CElem::Build3dElem(CTexCache &TexCache,CScene &ThisScene,int Node)
|
||||||
{
|
{
|
||||||
CNode &ThisNode=ThisScene.GetNode(Node);
|
CNode &ThisNode=ThisScene.GetNode(Node);
|
||||||
int ChildCount=ThisNode.GetChildCount();
|
CNode &ParentNode=ThisScene.GetNode(ThisNode.ParentIdx);
|
||||||
|
int ChildCount=ThisNode.GetPruneChildCount();
|
||||||
std::vector<sGinTri> const &NodeTriList=ThisNode.GetTris();
|
std::vector<sGinTri> const &NodeTriList=ThisNode.GetTris();
|
||||||
std::vector<Vector3>const &NodeVtxList=ThisNode.GetRelPts();
|
std::vector<Vector3>const &NodeVtxList=ThisNode.GetPts();
|
||||||
std::vector<sUVTri> const &NodeUVList=ThisNode.GetUVTris();
|
std::vector<sUVTri> const &NodeUVList=ThisNode.GetUVTris();
|
||||||
std::vector<int> const &NodeTriMat=ThisNode.GetTriMaterial();
|
std::vector<int> const &NodeTriMat=ThisNode.GetTriMaterial();
|
||||||
std::vector<GString> const &TexList= ThisScene.GetTexNames();//List();
|
|
||||||
std::vector<Material> const &MatList= ThisScene.GetMaterials();
|
std::vector<GString> const &SceneTexList=ThisScene.GetTexList();
|
||||||
|
std::vector<int> const &SceneUsedMatList=ThisScene.GetUsedMaterialIdx();
|
||||||
|
|
||||||
int TriCount=NodeTriList.size();
|
int TriCount=NodeTriList.size();
|
||||||
int ListSize=TriList.size();
|
int ListSize=TriList.size();
|
||||||
|
@ -169,28 +204,38 @@ int ListSize=TriList.size();
|
||||||
sUVTri const &ThisUV=NodeUVList[T];
|
sUVTri const &ThisUV=NodeUVList[T];
|
||||||
sTriFace &Tri=TriList[ListSize+T];
|
sTriFace &Tri=TriList[ListSize+T];
|
||||||
int ThisMat=NodeTriMat[T];
|
int ThisMat=NodeTriMat[T];
|
||||||
int TexID=1;
|
int TexID;
|
||||||
|
|
||||||
|
|
||||||
// Sort Textures - Only add the ones that are used :o)
|
// Sort Textures - Only add the ones nthat are used :o)
|
||||||
TexID=MatList[ThisMat].TexId;
|
TexID=SceneUsedMatList[ThisMat];
|
||||||
|
|
||||||
if (TexID!=-1)
|
if (TexID!=-1)
|
||||||
{
|
{
|
||||||
GString ThisName;
|
GString ThisName;
|
||||||
|
|
||||||
ThisName=SetPath+TexList[TexID];
|
ThisName=SetPath+SceneTexList[TexID];
|
||||||
TexID=TexCache.ProcessTexture(ThisName,MatList[ThisMat].Flags);
|
TRACE2("%i !%s!\n",TexID,ThisName);
|
||||||
|
TexID=TexCache.ProcessTexture(ThisName);
|
||||||
}
|
}
|
||||||
// Sort Rest of Tri info
|
// Sort Rest of Tri info
|
||||||
|
Matrix4x4 TransMtx;
|
||||||
|
TransMtx.Identity();
|
||||||
|
|
||||||
|
if (ParentNode.GetTris().size() || !ThisNode.ParentIdx)
|
||||||
|
{
|
||||||
|
TransMtx=ThisNode.Mtx;
|
||||||
|
TransMtx.Invert();
|
||||||
|
}
|
||||||
|
|
||||||
for (int p=0; p<3; p++)
|
for (int p=0; p<3; p++)
|
||||||
{
|
{
|
||||||
Tri.vtx[p]=NodeVtxList[ThisTri.p[p]];
|
Tri.vtx[p]=TransMtx*NodeVtxList[ThisTri.p[p]];
|
||||||
Tri.uvs[p].u=ThisUV.p[p].u;
|
Tri.uvs[p].u=ThisUV.p[p].u;
|
||||||
Tri.uvs[p].v=ThisUV.p[p].v;
|
Tri.uvs[p].v=ThisUV.p[p].v;
|
||||||
Tri.Mat=TexID;
|
Tri.Mat=TexID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int Child=0; Child<ChildCount; Child++) Build3dElem(TexCache,ThisScene,ThisNode.PruneChildList[Child]);
|
for (int Child=0; Child<ChildCount; Child++) Build3dElem(TexCache,ThisScene,ThisNode.PruneChildList[Child]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -198,52 +243,62 @@ int ListSize=TriList.size();
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CElem::Calc3dSize()
|
void CElem::Calc3dSize()
|
||||||
{
|
{
|
||||||
int ListSize=TriList.size();
|
int i,ListSize=TriList.size();
|
||||||
float XMin=+9999;
|
Vector3 Min(+32000,+32000,+32000);
|
||||||
float XMax=-9999;
|
Vector3 Max(-32000,-32000,-32000);
|
||||||
float YMin=+9999;
|
Vector3 Mid;
|
||||||
float YMax=-9999;
|
|
||||||
|
|
||||||
for (int i=0; i<ListSize; i++)
|
for (i=0; i<ListSize; i++)
|
||||||
{
|
{
|
||||||
sTriFace &Tri=TriList[i];
|
sTriFace &Tri=TriList[i];
|
||||||
for (int p=0; p<3; p++)
|
for (int p=0; p<3; p++)
|
||||||
{
|
{
|
||||||
if (XMin>Tri.vtx[p].x) XMin=Tri.vtx[p].x;
|
if (Min.x>Tri.vtx[p].x) Min.x=Tri.vtx[p].x;
|
||||||
if (XMax<Tri.vtx[p].x) XMax=Tri.vtx[p].x;
|
if (Min.y>Tri.vtx[p].y) Min.y=Tri.vtx[p].y;
|
||||||
if (YMin>Tri.vtx[p].y) YMin=Tri.vtx[p].y;
|
if (Min.z>Tri.vtx[p].z) Min.z=Tri.vtx[p].z;
|
||||||
if (YMax<Tri.vtx[p].y) YMax=Tri.vtx[p].y;
|
if (Max.x<Tri.vtx[p].x) Max.x=Tri.vtx[p].x;
|
||||||
|
if (Max.y<Tri.vtx[p].y) Max.y=Tri.vtx[p].y;
|
||||||
|
if (Max.z<Tri.vtx[p].z) Max.z=Tri.vtx[p].z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UnitWidth=round(XMax-XMin);
|
|
||||||
UnitHeight=round(YMax-YMin);
|
UnitWidth=round(Max.x-Min.x);
|
||||||
|
UnitHeight=round(Max.y-Min.y);
|
||||||
if (UnitWidth<1) UnitWidth=1;
|
if (UnitWidth<1) UnitWidth=1;
|
||||||
if (UnitHeight<1) UnitHeight=1;
|
if (UnitHeight<1) UnitHeight=1;
|
||||||
ElemWidth=UnitWidth*UnitSize;
|
ElemWidth=UnitWidth*UnitSize;
|
||||||
ElemHeight=UnitHeight*UnitSize;
|
ElemHeight=UnitHeight*UnitSize;
|
||||||
|
Min.z=0;
|
||||||
|
|
||||||
|
Ofs=DefOfs;
|
||||||
|
// Ofs.x=+0.5f; Ofs.y=0; Ofs.z=+4.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CElem::Build2dDrawList(CTexCache &TexCache,GLint &List)
|
void CElem::Build2dDrawList(CTexCache &TexCache,GLint &List)
|
||||||
{
|
{
|
||||||
|
float X0=Ofs.x;
|
||||||
|
float X1=Ofs.x+UnitWidth;
|
||||||
|
float Y0=Ofs.y;
|
||||||
|
float Y1=Ofs.y+UnitHeight;
|
||||||
|
float Z=Ofs.z;
|
||||||
|
|
||||||
List=glGenLists(1);
|
List=glGenLists(1);
|
||||||
glNewList(List,GL_COMPILE);
|
glNewList(List,GL_COMPILE);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, TexCache.GetTexGLId(ElemID));
|
glBindTexture(GL_TEXTURE_2D, TexCache.GetTexGLId(ElemID));
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
glTexCoord2f(0.0f,0.0f);
|
glTexCoord2f(0.0f,0.0f);
|
||||||
glVertex3f( 0.0f,0.0f,0.0f);
|
glVertex3f(X0,Y0,Z);
|
||||||
|
|
||||||
glTexCoord2f(1.0f,0.0f);
|
glTexCoord2f(1.0f,0.0f);
|
||||||
glVertex3f( UnitWidth,0.0f,0.0f);
|
glVertex3f(X1,Y0,Z);
|
||||||
|
|
||||||
glTexCoord2f(1.0f,1.0f);
|
glTexCoord2f(1.0f,1.0f);
|
||||||
glVertex3f( UnitWidth,UnitHeight,0.0f);
|
glVertex3f(X1,Y1,Z);
|
||||||
|
|
||||||
glTexCoord2f(0.0f,1.0f);
|
glTexCoord2f(0.0f,1.0f);
|
||||||
glVertex3f( 0.0f,UnitHeight,0.0f);
|
glVertex3f(X0,Y1,Z);
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
glEndList();
|
glEndList();
|
||||||
|
|
||||||
|
@ -255,6 +310,7 @@ void CElem::Build3dDrawList(CTexCache &TexCache,GLint &List)
|
||||||
{
|
{
|
||||||
int TriCount=TriList.size();
|
int TriCount=TriList.size();
|
||||||
int LastMat=-1,ThisMat;
|
int LastMat=-1,ThisMat;
|
||||||
|
float ScaleU,ScaleV;
|
||||||
|
|
||||||
List=glGenLists(1);
|
List=glGenLists(1);
|
||||||
glNewList(List,GL_COMPILE);
|
glNewList(List,GL_COMPILE);
|
||||||
|
@ -270,14 +326,27 @@ int LastMat=-1,ThisMat;
|
||||||
glBindTexture(GL_TEXTURE_2D, TexCache.GetTexGLId(ThisMat));
|
glBindTexture(GL_TEXTURE_2D, TexCache.GetTexGLId(ThisMat));
|
||||||
glBegin (GL_TRIANGLES);
|
glBegin (GL_TRIANGLES);
|
||||||
LastMat=ThisMat;
|
LastMat=ThisMat;
|
||||||
|
sTex &Tex=TexCache.GetTex(ThisMat);
|
||||||
|
int AW=TexCache.AlignSize(Tex.TexWidth);
|
||||||
|
int AH=TexCache.AlignSize(Tex.TexHeight);
|
||||||
|
if (AW!=Tex.TexWidth || AH!=Tex.TexHeight)
|
||||||
|
{
|
||||||
|
ScaleU=(float)Tex.TexWidth/(float)AW;
|
||||||
|
ScaleV=(float)Tex.TexHeight/(float)AH;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ScaleU=ScaleV=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int p=0; p<3; p++)
|
for (int p=0; p<3; p++)
|
||||||
{
|
{
|
||||||
Vector3 &ThisVtx=ThisTri.vtx[p];
|
Vector3 &ThisVtx=ThisTri.vtx[p];
|
||||||
glTexCoord2f(ThisTri.uvs[p].u, ThisTri.uvs[p].v);
|
float u=ThisTri.uvs[p].u*ScaleU;
|
||||||
|
float v=ThisTri.uvs[p].v*ScaleV;
|
||||||
|
glTexCoord2f(u,v);
|
||||||
glVertex3f( (ThisVtx.x+Ofs.x), (ThisVtx.y+Ofs.y), -(ThisVtx.z+Ofs.z)); // Neg Z (cos openGL)
|
glVertex3f( (ThisVtx.x+Ofs.x), (ThisVtx.y+Ofs.y), -(ThisVtx.z+Ofs.z)); // Neg Z (cos openGL)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,8 +495,11 @@ float Y1=UnitHeight;
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CElem::RenderElem4Texture(sRGBData &RGBData)
|
void CElem::RenderElem4Texture(sRGBData &RGBData)
|
||||||
{
|
{
|
||||||
|
float W=UnitWidth;
|
||||||
|
float H=UnitHeight;
|
||||||
|
|
||||||
glClearColor(1,0,1,1 );
|
glClearColor(1,0,1,1 );
|
||||||
|
// glClearColor(1,1,1,1 );
|
||||||
glPushAttrib(GL_VIEWPORT_BIT);
|
glPushAttrib(GL_VIEWPORT_BIT);
|
||||||
glViewport(0,0,RGBData.Width,RGBData.Height);
|
glViewport(0,0,RGBData.Width,RGBData.Height);
|
||||||
|
|
||||||
|
@ -435,12 +507,12 @@ void CElem::RenderElem4Texture(sRGBData &RGBData)
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho(-0.5f, +0.5f, -0.5f, +0.5f, -16.0f, +16.0f);
|
glOrtho(0, W, 0, H, -16.0f, +16.0f);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(-0.5f,-0.5f,0);
|
glTranslatef(-Ofs.x,-Ofs.y,-Ofs.z);
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen
|
||||||
|
|
||||||
|
@ -466,23 +538,22 @@ void CElem::RenderElem4Texture(sRGBData &RGBData)
|
||||||
void CElem::Create2dTexture(CTexCache &TexCache,const char *Filename,int ID)
|
void CElem::Create2dTexture(CTexCache &TexCache,const char *Filename,int ID)
|
||||||
{
|
{
|
||||||
sRGBData RGBData;
|
sRGBData RGBData;
|
||||||
|
char TexName[256];
|
||||||
|
|
||||||
|
sprintf(TexName,"_2dPc_%s_%03d",Filename,ID);
|
||||||
ElemRGB=(u8*)malloc(ElemWidth*ElemHeight*3);
|
ElemRGB=(u8*)malloc(ElemWidth*ElemHeight*3);
|
||||||
|
|
||||||
RGBData.Width=ElemWidth;
|
RGBData.Width=ElemWidth;
|
||||||
RGBData.Height=ElemHeight;
|
RGBData.Height=ElemHeight;
|
||||||
RGBData.RGB=ElemRGB;
|
RGBData.RGB=ElemRGB;
|
||||||
RenderElem4Texture(RGBData);
|
RenderElem4Texture(RGBData);
|
||||||
ElemID=TexCache.ProcessTexture("",0,&RGBData);
|
ElemID=TexCache.ProcessTexture(TexName,&RGBData);
|
||||||
ValidFlag=CheckHasData(RGBData);
|
ValidFlag=CheckHasData(RGBData);
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if (0)
|
if (0)
|
||||||
{
|
{
|
||||||
char Filename[256];
|
char Filename[256];
|
||||||
char TexName[256];
|
|
||||||
static asd=0;
|
|
||||||
sprintf(TexName,"_2dPc_%s_%03d",Filename,asd++);
|
|
||||||
sprintf(Filename,"/x/%s.Tga",TexName);
|
sprintf(Filename,"/x/%s.Tga",TexName);
|
||||||
SaveTGA(Filename,ElemWidth,ElemHeight,ElemRGB);
|
SaveTGA(Filename,ElemWidth,ElemHeight,ElemRGB);
|
||||||
}
|
}
|
||||||
|
@ -505,7 +576,7 @@ int Size=RGBData.Width*RGBData.Height;
|
||||||
if (R!=255 || G!=0 || B!=255) return(TRUE);
|
if (R!=255 || G!=0 || B!=255) return(TRUE);
|
||||||
|
|
||||||
}
|
}
|
||||||
return(FALSE);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -513,17 +584,24 @@ int Size=RGBData.Width*RGBData.Height;
|
||||||
/*** Elem Set ****************************************************************/
|
/*** Elem Set ****************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CElemSet::CElemSet(const char *_Filename,int Idx,int Width,int Height)
|
CElemSet::CElemSet(const char *_Filename,int Idx,int Width,int Height,bool CreateBlank,bool Centre)
|
||||||
{
|
{
|
||||||
GFName FName=_Filename;
|
GFName FName=_Filename;
|
||||||
|
|
||||||
Filename=_Filename;
|
Filename=_Filename;
|
||||||
Name=FName.File();
|
Name=FName.File();
|
||||||
|
|
||||||
DefWidth=Width;
|
MaxWidth=Width;
|
||||||
DefHeight=Height;
|
MaxHeight=Height;
|
||||||
|
CentreFlag=Centre;
|
||||||
Loaded=FALSE;
|
Loaded=FALSE;
|
||||||
SetNumber=Idx;
|
SetNumber=Idx;
|
||||||
|
|
||||||
|
if (CreateBlank)
|
||||||
|
{
|
||||||
|
ElemList.push_back(CElem(MaxWidth,MaxHeight)); // Insert Blank
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -560,18 +638,22 @@ GString Ext=FName.Ext();
|
||||||
void CElemSet::Load2d(CCore *Core)
|
void CElemSet::Load2d(CCore *Core)
|
||||||
{
|
{
|
||||||
CTexCache &TexCache=Core->GetTexCache();
|
CTexCache &TexCache=Core->GetTexCache();
|
||||||
int TexID=TexCache.ProcessTexture(Filename,0);
|
int TexID=TexCache.ProcessTexture(Filename);
|
||||||
sTex &ThisTex=TexCache.GetTex(TexID);
|
sTex &ThisTex=TexCache.GetTex(TexID);
|
||||||
int Width=ThisTex.TexWidth/DefWidth;
|
int Width,Height;
|
||||||
int Height=ThisTex.TexHeight/DefHeight;
|
|
||||||
|
if (MaxWidth==-1) MaxWidth=ThisTex.TexWidth;
|
||||||
|
if (MaxHeight==-1) MaxHeight=ThisTex.TexHeight;
|
||||||
|
|
||||||
|
Width=ThisTex.TexWidth/MaxWidth;
|
||||||
|
Height=ThisTex.TexHeight/MaxHeight;
|
||||||
|
|
||||||
ElemList.push_back(CElem(DefWidth,DefHeight)); // Insert Blank
|
|
||||||
|
|
||||||
for (int Y=0; Y<Height; Y++)
|
for (int Y=0; Y<Height; Y++)
|
||||||
{
|
{
|
||||||
for (int X=0; X<Width; X++)
|
for (int X=0; X<Width; X++)
|
||||||
{
|
{
|
||||||
ElemList.push_back(CElem(Core,Filename,TexID,X,Y,DefWidth,DefHeight));
|
ElemList.push_back(CElem(Core,Filename,TexID,X,Y,MaxWidth,MaxHeight,CentreFlag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ElemBrowserWidth=Width;
|
ElemBrowserWidth=Width;
|
||||||
|
@ -587,8 +669,6 @@ CScene Scene;
|
||||||
CNode &ThisNode=Scene.GetSceneNode(0);
|
CNode &ThisNode=Scene.GetSceneNode(0);
|
||||||
int ChildCount=ThisNode.GetPruneChildCount();
|
int ChildCount=ThisNode.GetPruneChildCount();
|
||||||
|
|
||||||
ElemList.push_back(CElem(DefWidth,DefHeight)); // Insert Blank
|
|
||||||
|
|
||||||
for (int Child=0; Child<ChildCount; Child++)
|
for (int Child=0; Child<ChildCount; Child++)
|
||||||
{
|
{
|
||||||
ElemList.push_back(CElem(Core,Filename,Scene,ThisNode.PruneChildList[Child]));
|
ElemList.push_back(CElem(Core,Filename,Scene,ThisNode.PruneChildList[Child]));
|
||||||
|
@ -632,9 +712,16 @@ int ListSize=ElemList.size();
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CElemBank::CElemBank()
|
CElemBank::CElemBank(int W,int H,bool Blank,bool Centre)
|
||||||
{
|
{
|
||||||
LoadFlag=FALSE;
|
MaxWidth=W;
|
||||||
|
MaxHeight=H;
|
||||||
|
BlankFlag=Blank;
|
||||||
|
CentreFlag=Centre;
|
||||||
|
|
||||||
|
LoadFlag=false;
|
||||||
|
CurrentSet=0;
|
||||||
|
VisibleFlag=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -666,6 +753,10 @@ char FixPath[1024];
|
||||||
FilePath.Append('\\');
|
FilePath.Append('\\');
|
||||||
FilePath.Upper();
|
FilePath.Upper();
|
||||||
|
|
||||||
|
if (Version>=5)
|
||||||
|
{
|
||||||
|
File->Read(&CurrentSet,sizeof(int));
|
||||||
|
}
|
||||||
File->Read(&ListSize,sizeof(int));
|
File->Read(&ListSize,sizeof(int));
|
||||||
|
|
||||||
// New Style rel storage
|
// New Style rel storage
|
||||||
|
@ -708,6 +799,7 @@ GString SavePath;
|
||||||
|
|
||||||
SavePath.Upper();
|
SavePath.Upper();
|
||||||
|
|
||||||
|
File->Write(&CurrentSet,sizeof(int));
|
||||||
File->Write(&ListSize,sizeof(int));
|
File->Write(&ListSize,sizeof(int));
|
||||||
|
|
||||||
for (int i=0; i<ListSize; i++)
|
for (int i=0; i<ListSize; i++)
|
||||||
|
@ -723,7 +815,7 @@ GString SavePath;
|
||||||
void CElemBank::AddSet(const char *Filename)
|
void CElemBank::AddSet(const char *Filename)
|
||||||
{
|
{
|
||||||
int ListSize=SetList.size();
|
int ListSize=SetList.size();
|
||||||
CElemSet NewSet(Filename,ListSize);
|
CElemSet NewSet(Filename,ListSize,MaxWidth,MaxHeight,BlankFlag,CentreFlag);
|
||||||
|
|
||||||
SetList.Add(NewSet);
|
SetList.Add(NewSet);
|
||||||
if (SetList.size()!=ListSize) LoadFlag=TRUE;
|
if (SetList.size()!=ListSize) LoadFlag=TRUE;
|
||||||
|
@ -777,19 +869,198 @@ void CElemBank::DeleteSet(int Set)
|
||||||
SetList.erase(Set);
|
SetList.erase(Set);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
CElem &CElemBank::GetElem(int Set,int Elem)
|
|
||||||
{
|
|
||||||
ASSERT(Set>=0 && Elem>=0);
|
|
||||||
return(SetList[Set].GetElem(Elem));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
bool CElemBank::IsValid(int Set,int Elem)
|
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);
|
||||||
ASSERT(Set<SetList.size());
|
ASSERT(Set<SetList.size());
|
||||||
return(SetList[Set].IsValid(Elem));
|
return(SetList[Set].IsValid(Elem));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
CPoint CElemBank::GetElemPos(int ID,int Width)
|
||||||
|
{
|
||||||
|
if (ID==0)
|
||||||
|
return(CPoint(-1,-1));
|
||||||
|
else
|
||||||
|
return(IDToPoint(ID-1,Width));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CElemBank::RenderElem(int Set,int Elem,int Flags,bool Is3d)
|
||||||
|
{
|
||||||
|
if (IsValid(Set,Elem))
|
||||||
|
{
|
||||||
|
SetList[Set].RenderElem(Elem,Flags,Is3d);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetList[0].RenderInvalid();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CElemBank::RenderGrid(CCore *Core,Vector3 &CamPos,bool Active)
|
||||||
|
{
|
||||||
|
if (!GetSetCount()) return;
|
||||||
|
CElemSet &ThisSet=SetList[CurrentSet];
|
||||||
|
int ListSize=ThisSet.GetCount();
|
||||||
|
int BrowserWidth=ThisSet.GetBrowserWidth();
|
||||||
|
int TileID=1; // Dont bother with blank, its sorted
|
||||||
|
float Scale=CamPos.z/(float)BrowserWidth/2.0;
|
||||||
|
|
||||||
|
if (!ListSize) return;
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
while(TileID!=ListSize)
|
||||||
|
{
|
||||||
|
CPoint Pos=GetElemPos(TileID,BrowserWidth);
|
||||||
|
float XPos=(float)Pos.x*(1+ElemBrowserGap);
|
||||||
|
float YPos=(float)Pos.y*(1+ElemBrowserGap);
|
||||||
|
|
||||||
|
glLoadIdentity();
|
||||||
|
glScalef(Scale,Scale,Scale);
|
||||||
|
glTranslatef(-CamPos.x+XPos,CamPos.y-YPos,0);
|
||||||
|
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glColor3f(1,1,1);
|
||||||
|
|
||||||
|
glVertex3f( ElemBrowserX0,ElemBrowserY0,0);
|
||||||
|
glVertex3f( ElemBrowserX1,ElemBrowserY0,0);
|
||||||
|
|
||||||
|
glVertex3f( ElemBrowserX0,ElemBrowserY1,0);
|
||||||
|
glVertex3f( ElemBrowserX1,ElemBrowserY1,0);
|
||||||
|
|
||||||
|
glVertex3f( ElemBrowserX0,ElemBrowserY0,0);
|
||||||
|
glVertex3f( ElemBrowserX0,ElemBrowserY1,0);
|
||||||
|
|
||||||
|
glVertex3f( ElemBrowserX1,ElemBrowserY0,0);
|
||||||
|
glVertex3f( ElemBrowserX1,ElemBrowserY1,0);
|
||||||
|
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
TileID++;
|
||||||
|
}
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CElemBank::FindCursorPos(CCore *Core,Vector3 &CamPos,CPoint &MousePos)
|
||||||
|
{
|
||||||
|
if (!GetSetCount()) return;
|
||||||
|
CElemSet &ThisSet=SetList[CurrentSet];
|
||||||
|
int ListSize=ThisSet.GetCount();
|
||||||
|
int BrowserWidth=ThisSet.GetBrowserWidth();
|
||||||
|
GLint Viewport[4];
|
||||||
|
GLuint SelectBuffer[SELECT_BUFFER_SIZE];
|
||||||
|
int HitCount;
|
||||||
|
int TileID=0;
|
||||||
|
float Scale=CamPos.z/(float)BrowserWidth/2.0;
|
||||||
|
|
||||||
|
if (!ListSize) return;
|
||||||
|
glGetIntegerv(GL_VIEWPORT, Viewport);
|
||||||
|
glSelectBuffer (SELECT_BUFFER_SIZE, SelectBuffer );
|
||||||
|
glRenderMode (GL_SELECT);
|
||||||
|
|
||||||
|
glInitNames();
|
||||||
|
glPushName(-1);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
gluPickMatrix( MousePos.x ,(Viewport[3]-MousePos.y),5.0,5.0,Viewport);
|
||||||
|
Core->GetView()->SetupPersMatrix();
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
while(TileID!=ListSize)
|
||||||
|
{
|
||||||
|
CPoint Pos=GetElemPos(TileID,BrowserWidth);
|
||||||
|
float XPos=(float)Pos.x*(1+ElemBrowserGap);
|
||||||
|
float YPos=(float)Pos.y*(1+ElemBrowserGap);
|
||||||
|
|
||||||
|
glLoadIdentity();
|
||||||
|
glScalef(Scale,Scale,Scale);
|
||||||
|
glTranslatef(-CamPos.x+XPos,CamPos.y-YPos,0);
|
||||||
|
|
||||||
|
glLoadName (TileID);
|
||||||
|
glBegin (GL_QUADS);
|
||||||
|
BuildGLQuad(ElemBrowserX0,ElemBrowserX1,ElemBrowserY0,ElemBrowserY1,0);
|
||||||
|
glEnd();
|
||||||
|
TileID++;
|
||||||
|
}
|
||||||
|
|
||||||
|
HitCount= glRenderMode (GL_RENDER);
|
||||||
|
glPopMatrix();
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
// Process hits
|
||||||
|
|
||||||
|
GLuint *HitPtr=SelectBuffer;
|
||||||
|
|
||||||
|
TileID=-2;
|
||||||
|
if (HitCount) // Just take 1st
|
||||||
|
{
|
||||||
|
TileID=HitPtr[3];
|
||||||
|
}
|
||||||
|
glMatrixMode(GL_MODELVIEW); // <-- Prevent arse GL assert
|
||||||
|
|
||||||
|
CursorPos=TileID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*** Gui *********************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CElemBank::GUIInit(CCore *Core)
|
||||||
|
{
|
||||||
|
Core->GUIAdd(GUIElemList,IDD_ELEMLIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CElemBank::GUIKill(CCore *Core)
|
||||||
|
{
|
||||||
|
Core->GUIRemove(GUIElemList,IDD_ELEMLIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CElemBank::GUIUpdate(CCore *Core)
|
||||||
|
{
|
||||||
|
int ListSize=GetSetCount();
|
||||||
|
bool IsSubView=Core->IsSubView();
|
||||||
|
|
||||||
|
if (GUIElemList.m_List)
|
||||||
|
{
|
||||||
|
GUIElemList.m_List.ResetContent();
|
||||||
|
if (ListSize)
|
||||||
|
{
|
||||||
|
for (int i=0; i<ListSize; i++)
|
||||||
|
{
|
||||||
|
GUIElemList.m_List.AddString(GetSetName(i));
|
||||||
|
}
|
||||||
|
GUIElemList.m_List.SetCurSel(CurrentSet);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IsSubView=FALSE;
|
||||||
|
}
|
||||||
|
GUIElemList.m_List.EnableWindow(IsSubView);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CElemBank::GUIChanged(CCore *Core)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
#include "TexCache.h"
|
#include "TexCache.h"
|
||||||
#include "GinTex.h"
|
#include "GinTex.h"
|
||||||
|
|
||||||
|
#include "Layer.h"
|
||||||
|
#include "MapEdit.h"
|
||||||
|
#include "GUIElemList.h"
|
||||||
|
|
||||||
struct sTriFace
|
struct sTriFace
|
||||||
{
|
{
|
||||||
int Mat;
|
int Mat;
|
||||||
|
@ -41,7 +45,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
CElem(int Width,int Height); // Blank (2d)
|
CElem(int Width,int Height); // Blank (2d)
|
||||||
CElem(CCore *Core,const char *Filename,int TexId,int XOfs,int YOfs,int Width,int Height); // 2d elem
|
CElem(CCore *Core,const char *Filename,int TexId,int XOfs,int YOfs,int Width,int Height,bool Centre); // 2d elem
|
||||||
CElem(CCore *Core,const char *Filename,CScene &ThisScene,int Node); // 3d elem
|
CElem(CCore *Core,const char *Filename,CScene &ThisScene,int Node); // 3d elem
|
||||||
void CleanUp();
|
void CleanUp();
|
||||||
|
|
||||||
|
@ -98,12 +102,10 @@ class CElemSet
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
DEF_ELEMWIDTH=16,
|
|
||||||
DEF_ELEMHEIGHT=16,
|
|
||||||
DEF_ELEMBROWSWEWIDTH=8,
|
DEF_ELEMBROWSWEWIDTH=8,
|
||||||
};
|
};
|
||||||
|
|
||||||
CElemSet(const char *_Filename,int Idx,int Width=DEF_ELEMWIDTH,int Height=DEF_ELEMHEIGHT);
|
CElemSet(const char *_Filename,int Idx,int MaxWidth,int MaxHeight,bool CreateBlank,bool Centre);
|
||||||
~CElemSet();
|
~CElemSet();
|
||||||
|
|
||||||
void CleanUp();
|
void CleanUp();
|
||||||
|
@ -133,22 +135,24 @@ private:
|
||||||
GString Filename,Name;
|
GString Filename,Name;
|
||||||
|
|
||||||
int SetNumber;
|
int SetNumber;
|
||||||
int DefWidth,DefHeight;
|
int MaxWidth,MaxHeight;
|
||||||
|
bool CentreFlag;
|
||||||
CList<CElem> ElemList;
|
CList<CElem> ElemList;
|
||||||
bool Loaded;
|
bool Loaded;
|
||||||
int ElemBrowserWidth;
|
int ElemBrowserWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
class CElemBank
|
class CElemBank : public CLayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CElemBank();
|
// Local
|
||||||
~CElemBank();
|
CElemBank(int MaxWidth,int MaxHeight,bool Blank,bool Centre);
|
||||||
|
virtual ~CElemBank();
|
||||||
void CleanUp();
|
void CleanUp();
|
||||||
|
|
||||||
void Load(CFile *File,int Version);
|
virtual void Load(CFile *File,int Version);
|
||||||
void Save(CFile *File);
|
virtual void Save(CFile *File);
|
||||||
|
|
||||||
void AddSet(const char *Filename);
|
void AddSet(const char *Filename);
|
||||||
void LoadAllSets(CCore *Core);
|
void LoadAllSets(CCore *Core);
|
||||||
|
@ -156,16 +160,49 @@ public:
|
||||||
void ReloadAllSets();
|
void ReloadAllSets();
|
||||||
void DeleteSet(int Set);
|
void DeleteSet(int Set);
|
||||||
int NeedLoad() {return(LoadFlag);}
|
int NeedLoad() {return(LoadFlag);}
|
||||||
CElem &GetElem(int Set,int Elem);
|
CElem &GetElem(int Set,int Elem) {return(SetList[Set].GetElem(Elem));}
|
||||||
bool IsValid(int Set,int Elem);
|
bool IsValid(int Set,int Elem);
|
||||||
|
void RenderElem(int Set,int Elem,int Flags,bool Is3d);
|
||||||
|
|
||||||
int GetSetCount() {return(SetList.size());}
|
int GetSetCount() {return(SetList.size());}
|
||||||
|
|
||||||
|
const char *GetSetName(int Set) {return(SetList[Set].GetName());}
|
||||||
|
const char *GetSetFilename(int Set) {return(SetList[Set].GetFilename());}
|
||||||
|
|
||||||
|
// Overloads
|
||||||
|
virtual int GetType() {return(0);}
|
||||||
|
|
||||||
|
virtual void RenderGrid(CCore *Core,Vector3 &CamPos,bool Active);
|
||||||
|
virtual void RenderSelection(CCore *Core,Vector3 &ThisCam){};
|
||||||
|
virtual void FindCursorPos(CCore *Core,Vector3 &CamPos,CPoint &MousePos);
|
||||||
|
|
||||||
|
virtual void GUIInit(CCore *Core);
|
||||||
|
virtual void GUIKill(CCore *Core);
|
||||||
|
virtual void GUIUpdate(CCore *Core);
|
||||||
|
virtual void GUIChanged(CCore *Core);
|
||||||
|
|
||||||
|
virtual void Export(CCore *Core,CExport &Exp){};
|
||||||
|
|
||||||
|
virtual bool LButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag) {return(false);}
|
||||||
|
virtual bool RButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag) {return(false);}
|
||||||
|
virtual bool MouseMove(CCore *Core,UINT nFlags, CPoint &CursorPos) {return(false);}
|
||||||
|
virtual bool Command(int CmdMsg,CCore *Core,int Param0=0,int Param1=0) {return(false);}
|
||||||
|
CPoint GetElemPos(int ID,int Width);
|
||||||
|
|
||||||
|
// Local
|
||||||
|
virtual bool CanClose() {return(true);}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
CList<CElemSet> SetList;
|
CList<CElemSet> SetList;
|
||||||
|
|
||||||
bool LoadFlag;
|
bool LoadFlag;
|
||||||
|
int CurrentSet;
|
||||||
|
int CursorPos;
|
||||||
|
|
||||||
|
int MaxWidth,MaxHeight;
|
||||||
|
bool BlankFlag,CentreFlag;
|
||||||
|
|
||||||
|
CGUIElemList GUIElemList;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ CTileBank *TileBank=Core->GetTileBank();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CElem &ThisTile=TileBank->GetTile(OutTile.Set,OutTile.Tile);
|
CElem &ThisTile=TileBank->GetElem(OutTile.Set,OutTile.Tile);
|
||||||
GString SetName=TileBank->GetSetFilename(OutTile.Set);
|
GString SetName=TileBank->GetSetFilename(OutTile.Set);
|
||||||
|
|
||||||
ASSERT(ThisTile.GetElemWidth()==FileHdr.TileW);
|
ASSERT(ThisTile.GetElemWidth()==FileHdr.TileW);
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
|
|
||||||
// Dialog Data
|
// Dialog Data
|
||||||
//{{AFX_DATA(CGUILayerShade)
|
//{{AFX_DATA(CGUILayerShade)
|
||||||
enum { IDD = IDD_LAYERSHADE_GUI };
|
enum { IDD = IDD_LAYER_SHADE };
|
||||||
CEdit m_R0;
|
CEdit m_R0;
|
||||||
CEdit m_G0;
|
CEdit m_G0;
|
||||||
CEdit m_B0;
|
CEdit m_B0;
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
|
|
||||||
// Dialog Data
|
// Dialog Data
|
||||||
//{{AFX_DATA(GUIToolBar)
|
//{{AFX_DATA(GUIToolBar)
|
||||||
enum { IDD = IDD_LAYER_TOOLBAR };
|
enum { IDD = IDD_TOOLBAR };
|
||||||
CButton m_Select;
|
CButton m_Select;
|
||||||
CButton m_Paint;
|
CButton m_Paint;
|
||||||
//}}AFX_DATA
|
//}}AFX_DATA
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "Select.h"
|
#include "Select.h"
|
||||||
#include "Export.h"
|
#include "Export.h"
|
||||||
|
|
||||||
// Reserve slot 0 for collision :o)
|
|
||||||
GString ColFName="Collision.bmp";
|
GString ColFName="Collision.bmp";
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -47,32 +46,20 @@ CLayerCollision::CLayerCollision(CFile *File,int Version)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CLayerCollision::~CLayerCollision()
|
CLayerCollision::~CLayerCollision()
|
||||||
{
|
{
|
||||||
|
TileBank->CleanUp();
|
||||||
delete TileBank;
|
delete TileBank;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerCollision::InitSubView(CCore *Core)
|
void CLayerCollision::InitSubView(CCore *Core)
|
||||||
{
|
{
|
||||||
|
GString Filename;
|
||||||
TileBank=new CTileBank;
|
TileBank=new CTileBank;
|
||||||
SubView=TileBank;
|
SubView=TileBank;
|
||||||
|
|
||||||
GFName ExePath;
|
Core->GetExecPath(Filename);
|
||||||
GString Filename;
|
|
||||||
|
|
||||||
// Get application path
|
|
||||||
#ifdef _DEBUG
|
|
||||||
ExePath="C:\\Spongebob\\tools\\mapedit\\";
|
|
||||||
#else
|
|
||||||
char ExeFilename[2048];
|
|
||||||
GetModuleFileName(GetModuleHandle(NULL),ExeFilename,2048);
|
|
||||||
ExePath=ExeFilename;
|
|
||||||
ExePath.File(0);
|
|
||||||
ExePath.Ext(0);
|
|
||||||
#endif
|
|
||||||
Filename=ExePath.FullName();
|
|
||||||
Filename+=ColFName;
|
Filename+=ColFName;
|
||||||
TileBank->AddSet(Filename);
|
TileBank->AddSet(Filename);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -135,14 +122,14 @@ bool Ret=false;
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerCollision::GUIInit(CCore *Core)
|
void CLayerCollision::GUIInit(CCore *Core)
|
||||||
{
|
{
|
||||||
Core->GUIAdd(GUIToolBar,IDD_LAYERTILE_TOOLBAR);
|
Core->GUIAdd(GUIToolBar,IDD_TOOLBAR);
|
||||||
Core->GUIAdd(GUI,IDD_LAYER_COLLISION);
|
Core->GUIAdd(GUI,IDD_LAYER_COLLISION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerCollision::GUIKill(CCore *Core)
|
void CLayerCollision::GUIKill(CCore *Core)
|
||||||
{
|
{
|
||||||
Core->GUIRemove(GUIToolBar,IDD_LAYERTILE_TOOLBAR);
|
Core->GUIRemove(GUIToolBar,IDD_TOOLBAR);
|
||||||
Core->GUIRemove(GUI,IDD_LAYER_COLLISION);
|
Core->GUIRemove(GUI,IDD_LAYER_COLLISION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/******************/
|
/*******************/
|
||||||
/*** Layer Elem ***/
|
/*** Layer Thing ***/
|
||||||
/******************/
|
/*******************/
|
||||||
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
@ -14,44 +14,68 @@
|
||||||
#include "MapEditView.h"
|
#include "MapEditView.h"
|
||||||
#include "MainFrm.h"
|
#include "MainFrm.h"
|
||||||
|
|
||||||
//#include "ElemSet.h"
|
|
||||||
|
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "LayerElem.h"
|
#include "LayerThing.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
//#include "Select.h"
|
|
||||||
#include "Export.h"
|
#include "Export.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// New Layer
|
// New Layer
|
||||||
CLayerElem::CLayerElem(int _SubType,int _Width,int _Height)
|
CLayerThing::CLayerThing(int _SubType,int _Width,int _Height)
|
||||||
{
|
{
|
||||||
SetDefaultParams();
|
SetDefaultParams();
|
||||||
|
|
||||||
Mode=MouseModePaint;
|
Mode=MouseModeNormal;
|
||||||
// ElemBank=new CElemBank;
|
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
|
||||||
CLayerElem::CLayerElem(CFile *File,int Version)
|
CLayerThing::CLayerThing(CFile *File,int Version)
|
||||||
{
|
{
|
||||||
Load(File,Version);
|
Load(File,Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CLayerElem::~CLayerElem()
|
CLayerThing::~CLayerThing()
|
||||||
{
|
{
|
||||||
// ElemBank->CleanUp();
|
ThingBank->CleanUp();
|
||||||
// delete ElemBank;
|
delete ThingBank;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerElem::Load(CFile *File,int Version)
|
void CLayerThing::Load(CFile *File,int Version)
|
||||||
{
|
{
|
||||||
File->Read(&VisibleFlag,sizeof(BOOL));
|
File->Read(&VisibleFlag,sizeof(BOOL));
|
||||||
File->Read(&Mode,sizeof(MouseMode));
|
File->Read(&Mode,sizeof(MouseMode));
|
||||||
|
@ -60,7 +84,7 @@ void CLayerElem::Load(CFile *File,int Version)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerElem::Save(CFile *File)
|
void CLayerThing::Save(CFile *File)
|
||||||
{
|
{
|
||||||
// Always Save current version
|
// Always Save current version
|
||||||
File->Write(&VisibleFlag,sizeof(BOOL));
|
File->Write(&VisibleFlag,sizeof(BOOL));
|
||||||
|
@ -68,39 +92,36 @@ void CLayerElem::Save(CFile *File)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerElem::InitSubView(CCore *Core)
|
void CLayerThing::InitSubView(CCore *Core)
|
||||||
{
|
{
|
||||||
ElemBank=&Core->GetIconz();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerElem::Render(CCore *Core,Vector3 &CamPos,bool Is3d)
|
void CLayerThing::Render(CCore *Core,Vector3 &CamPos,bool Is3d)
|
||||||
{
|
{
|
||||||
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
||||||
|
int i,ListSize=ThingList.size();
|
||||||
|
|
||||||
Is3d&=Render3dFlag;
|
// Is3d&=Render3dFlag;
|
||||||
for (int x=0; x<20; x++)
|
for (i=0; i<ListSize; i++)
|
||||||
{
|
{
|
||||||
CPoint XY;
|
RenderThing(Core,ThisCam,ThingList[i],Is3d,i==CurrentThing);
|
||||||
XY.x=x;
|
|
||||||
XY.y=0;
|
|
||||||
|
|
||||||
RenderElem(Core,ThisCam,XY,x&7,Is3d);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerElem::RenderElem(CCore *Core,Vector3 &ThisCam,CPoint &Pos,int Elem,bool Render3d,float Alpha)
|
void CLayerThing::RenderThing(CCore *Core,Vector3 &ThisCam,sLayerThing &ThisThing,bool Render3d,bool Selected)
|
||||||
{
|
{
|
||||||
float ZoomW=Core->GetZoomW();
|
float ZoomW=Core->GetZoomW();
|
||||||
float ZoomH=Core->GetZoomH();
|
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();
|
||||||
|
CElemBank *IconBank=Core->GetIconBank();
|
||||||
|
|
||||||
if (ElemBank->NeedLoad()) ElemBank->LoadAllSets(Core);
|
if (ThingBank->NeedLoad()) ThingBank->LoadAllSets(Core);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
@ -110,135 +131,148 @@ Vector3 &Scale=Core->GetScaleVector();
|
||||||
glScalef(Scale.x,Scale.y,Scale.z);
|
glScalef(Scale.x,Scale.y,Scale.z);
|
||||||
glTranslatef(-ThisCam.x,ThisCam.y,0); // Set scroll offset
|
glTranslatef(-ThisCam.x,ThisCam.y,0); // Set scroll offset
|
||||||
glTranslatef(-ScrOfsX,ScrOfsY,0); // Bring to top left corner
|
glTranslatef(-ScrOfsX,ScrOfsY,0); // Bring to top left corner
|
||||||
glTranslatef(Pos.x,Pos.y,0); // Set Elem Pos
|
|
||||||
glColor4f(1,1,1,Alpha); // Set default Color
|
int ListSize=ThisThing.XY.size();
|
||||||
ElemBank->RenderElem(0,Elem+1,0,Render3d);
|
TRACE1("%i pts\n",ListSize);
|
||||||
|
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();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*** Gui *********************************************************************/
|
/*** Gui *********************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerElem::GUIInit(CCore *Core)
|
void CLayerThing::GUIInit(CCore *Core)
|
||||||
{
|
{
|
||||||
// Core->GUIAdd(GUIToolBar,IDD_TOOLBAR);
|
// Core->GUIAdd(GUIToolBar,IDD_TOOLBAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerElem::GUIKill(CCore *Core)
|
void CLayerThing::GUIKill(CCore *Core)
|
||||||
{
|
{
|
||||||
// Core->GUIRemove(GUIToolBar,IDD_TOOLBAR);
|
// Core->GUIRemove(GUIToolBar,IDD_TOOLBAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerElem::GUIUpdate(CCore *Core)
|
void CLayerThing::GUIUpdate(CCore *Core)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerElem::GUIChanged(CCore *Core)
|
void CLayerThing::GUIChanged(CCore *Core)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*** Functions ***************************************************************/
|
/*** Functions ***************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
bool CLayerElem::LButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag)
|
bool CLayerThing::LButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag)
|
||||||
{
|
{
|
||||||
bool Ret=false;
|
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 CLayerElem::RButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag)
|
|
||||||
{
|
|
||||||
bool Ret=FALSE;
|
|
||||||
/*
|
|
||||||
switch(Mode)
|
switch(Mode)
|
||||||
{
|
{
|
||||||
case MouseModePaint:
|
case MouseModeNormal:
|
||||||
if (DownFlag)
|
if (DownFlag)
|
||||||
Ret=Paint(ElemBank->GetRBrush(),CursorPos);
|
|
||||||
break;
|
|
||||||
case MouseModeSelect:
|
|
||||||
Ret=Selection.Handle(CursorPos,nFlags);
|
|
||||||
if (Selection.HasSelection())
|
|
||||||
{
|
{
|
||||||
TRACE0("RMB Selection\n");
|
if (CurrentThing==-1)
|
||||||
}
|
AddThing(CursorPos);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return(Ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
bool CLayerElem::MouseMove(CCore *Core,UINT nFlags, CPoint &CursorPos)
|
|
||||||
{
|
|
||||||
bool Ret=FALSE;
|
|
||||||
/*
|
|
||||||
switch(Mode)
|
|
||||||
{
|
|
||||||
case MouseModePaint:
|
|
||||||
if (nFlags & MK_LBUTTON)
|
|
||||||
Ret=Paint(ElemBank->GetLBrush(),CursorPos);
|
|
||||||
else
|
else
|
||||||
if (nFlags & MK_RBUTTON)
|
AddThingPoint(CursorPos);
|
||||||
Ret=Paint(ElemBank->GetRBrush(),CursorPos);
|
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MouseModeSelect:
|
case MouseModePoints:
|
||||||
Ret=Selection.Handle(CursorPos,nFlags);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
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);
|
return(Ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
bool CLayerElem::Command(int CmdMsg,CCore *Core,int Param0,int Param1)
|
bool CLayerThing::MouseMove(CCore *Core,UINT nFlags, CPoint &CursorPos)
|
||||||
{
|
{
|
||||||
bool Ret=false;
|
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)
|
switch(CmdMsg)
|
||||||
{
|
{
|
||||||
case CmdMsg_SetMode:
|
case CmdMsg_SetMode:
|
||||||
Mode=(MouseMode)Param0;
|
// Mode=(MouseMode)Param0;
|
||||||
Core->GUIUpdate();
|
// Core->GUIUpdate();
|
||||||
break;
|
// break;
|
||||||
case CmdMsg_SubViewSet:
|
// case CmdMsg_SubViewSet:
|
||||||
Ret=ElemBank->Command(CmdMsg,Core,Param0,Param1);
|
// Ret=ThingBank->Command(CmdMsg,Core,Param0,Param1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
TRACE3("LayerElem-Unhandled Command %i (%i,%i)\n",CmdMsg,Param0,Param1);
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return(Ret);
|
return(Ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerElem::RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d)
|
void CLayerThing::RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d)
|
||||||
{
|
{
|
||||||
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
||||||
CPoint &CursPos=Core->GetCursorPos();
|
CPoint &CursPos=Core->GetCursorPos();
|
||||||
|
@ -264,19 +298,135 @@ Vector3 Ofs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
bool CLayerElem::Paint(CMap &Blk,CPoint &CursorPos)
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
int CLayerThing::CheckThing(CPoint &Pos)
|
||||||
{
|
{
|
||||||
|
CList<int> List;
|
||||||
|
int Idx=-1,i,ListSize=ThingList.size();
|
||||||
|
int StartIdx=0;
|
||||||
|
|
||||||
if (CursorPos.x==-1 || CursorPos.y==-1) return(false); // Off Map?
|
// Build List Of XY Matches
|
||||||
if (!Blk.IsValid()) return(false); // Invalid Elem?
|
for (i=0; i<ListSize; i++)
|
||||||
/*
|
{
|
||||||
Map.Set(CursorPos.x,CursorPos.y,Blk);
|
sLayerThing &ThisThing=ThingList[i];
|
||||||
*/
|
if (ThisThing.XY[0]==Pos)
|
||||||
return(true);
|
{
|
||||||
|
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 CLayerElem::Export(CCore *Core,CExport &Exp)
|
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 Width=Map.GetWidth();
|
||||||
|
@ -289,7 +439,7 @@ int Height=Map.GetHeight();
|
||||||
for (int X=0; X<Width; X++)
|
for (int X=0; X<Width; X++)
|
||||||
{
|
{
|
||||||
sMapElem &MapElem=Map.Get(X,Y);
|
sMapElem &MapElem=Map.Get(X,Y);
|
||||||
sExpLayerElem OutElem;
|
sExpLayerThing OutElem;
|
||||||
|
|
||||||
if (MapElem.Set==0 && MapElem.Elem==0)
|
if (MapElem.Set==0 && MapElem.Elem==0)
|
||||||
{ // Blank
|
{ // Blank
|
||||||
|
@ -311,7 +461,7 @@ int Height=Map.GetHeight();
|
||||||
OutElem.Flags=MapElem.Flags;
|
OutElem.Flags=MapElem.Flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
Exp.Write(&OutElem,sizeof(sExpLayerElem));
|
Exp.Write(&OutElem,sizeof(sExpLayerThing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/******************/
|
/*******************/
|
||||||
/*** Layer Elem ***/
|
/*** Layer Thing ***/
|
||||||
/******************/
|
/*******************/
|
||||||
|
|
||||||
#ifndef __LAYER_ELEM_HEADER__
|
#ifndef __LAYER_THING_HEADER__
|
||||||
#define __LAYER_ELEM_HEADER__
|
#define __LAYER_THING_HEADER__
|
||||||
|
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "MapEdit.h"
|
#include "MapEdit.h"
|
||||||
|
@ -11,40 +11,51 @@
|
||||||
#include "Elem.h"
|
#include "Elem.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
struct sLayerElem
|
struct sLayerThing
|
||||||
{
|
{
|
||||||
std::vector<CPoint> XY;
|
std::vector<CPoint> XY;
|
||||||
int Type;
|
int Type;
|
||||||
int SubType;
|
int SubType;
|
||||||
|
int Spare[8];
|
||||||
|
|
||||||
|
bool operator==(sLayerThing const &v1)
|
||||||
|
{
|
||||||
|
if (XY[0]!=v1.XY[0]) return(false);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
class CLayerElem : public CElemBank
|
class CLayerThing : public CLayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum MouseMode
|
enum MouseMode
|
||||||
{
|
{
|
||||||
MouseModePaint=0,
|
MouseModeNormal=0,
|
||||||
MouseModeSelect,
|
MouseModePoints,
|
||||||
};
|
};
|
||||||
|
|
||||||
CLayerElem(){};
|
CLayerThing(){};
|
||||||
CLayerElem(int SubType,int Width,int Height); // New Layer
|
CLayerThing(int SubType,int Width,int Height); // New Layer
|
||||||
CLayerElem(CFile *File,int Version); // Load Layer
|
CLayerThing(CFile *File,int Version); // Load Layer
|
||||||
~CLayerElem();
|
~CLayerThing();
|
||||||
|
|
||||||
virtual int GetType() {return(LAYER_TYPE_ITEM);}
|
virtual int GetType() {return(LAYER_TYPE_ITEM);}
|
||||||
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);
|
||||||
virtual void GUIUpdate(CCore *Core);
|
virtual void GUIUpdate(CCore *Core);
|
||||||
virtual void GUIChanged(CCore *Core);
|
virtual void GUIChanged(CCore *Core);
|
||||||
|
|
||||||
|
int GetWidth() {return(Width);}
|
||||||
|
int GetHeight() {return(Height);}
|
||||||
|
|
||||||
virtual void Load(CFile *File,int Version);
|
virtual void Load(CFile *File,int Version);
|
||||||
virtual void Save(CFile *File);
|
virtual void Save(CFile *File);
|
||||||
|
|
||||||
|
@ -56,18 +67,25 @@ virtual bool RButtonControl(CCore *Core,UINT nFlags, CPoint &point,bool DownFl
|
||||||
virtual bool MouseMove(CCore *Core,UINT nFlags, CPoint &point);
|
virtual bool MouseMove(CCore *Core,UINT nFlags, CPoint &point);
|
||||||
virtual bool Command(int CmdMsg,CCore *Core,int Param0=0,int Param1=0);
|
virtual bool Command(int CmdMsg,CCore *Core,int Param0=0,int Param1=0);
|
||||||
|
|
||||||
// Local
|
|
||||||
// CElemBank *GetElemBank() {return(ElemBank);}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void RenderElem(CCore *Core,Vector3 &CamPos,CPoint &Pos,int Elem,bool Render3d,float Alpha=1.0f);
|
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);
|
||||||
|
|
||||||
bool Paint(CMap &Blk,CPoint &CursorPos);
|
void UpdatePos(CPoint &Pos,int Thing,int PosNo,bool Recurs=false);
|
||||||
|
|
||||||
CElemBank *ElemBank;
|
|
||||||
CList<sLayerElem> ElemList;
|
int Width,Height;
|
||||||
|
CElemBank *ThingBank;
|
||||||
|
CList<sLayerThing> ThingList;
|
||||||
|
int CurrentThing,CurrentPoint;
|
||||||
MouseMode Mode;
|
MouseMode Mode;
|
||||||
|
|
||||||
|
|
||||||
CGUIToolBar GUIToolBar;
|
CGUIToolBar GUIToolBar;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -252,7 +252,7 @@ int DrawH=ZoomH+8;
|
||||||
if (ThisElem.Tile>0)
|
if (ThisElem.Tile>0)
|
||||||
{ // Render Non Zero and Valid Tiles
|
{ // Render Non Zero and Valid Tiles
|
||||||
glColor4f(1,1,1,Alpha); // Set default Color
|
glColor4f(1,1,1,Alpha); // Set default Color
|
||||||
TileBank->RenderTile(ThisElem.Set,ThisElem.Tile,ThisElem.Flags,Render3d);
|
TileBank->RenderElem(ThisElem.Set,ThisElem.Tile,ThisElem.Flags,Render3d);
|
||||||
}
|
}
|
||||||
glTranslatef(1.0f,0,0); // Next X
|
glTranslatef(1.0f,0,0); // Next X
|
||||||
}
|
}
|
||||||
|
@ -302,14 +302,14 @@ float Y1=Rect.bottom-1;
|
||||||
void CLayerTile::GUIInit(CCore *Core)
|
void CLayerTile::GUIInit(CCore *Core)
|
||||||
{
|
{
|
||||||
TileBank->GUIInit(Core);
|
TileBank->GUIInit(Core);
|
||||||
Core->GUIAdd(GUIToolBar,IDD_LAYERTILE_TOOLBAR);
|
Core->GUIAdd(GUIToolBar,IDD_TOOLBAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::GUIKill(CCore *Core)
|
void CLayerTile::GUIKill(CCore *Core)
|
||||||
{
|
{
|
||||||
TileBank->GUIKill(Core);
|
TileBank->GUIKill(Core);
|
||||||
Core->GUIRemove(GUIToolBar,IDD_LAYERTILE_TOOLBAR);
|
Core->GUIRemove(GUIToolBar,IDD_TOOLBAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -443,6 +443,7 @@ bool Ret=false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
TRACE3("LayerTile-Unhandled Command %i (%i,%i)\n",CmdMsg,Param0,Param1);
|
TRACE3("LayerTile-Unhandled Command %i (%i,%i)\n",CmdMsg,Param0,Param1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return(Ret);
|
return(Ret);
|
||||||
}
|
}
|
||||||
|
@ -601,7 +602,7 @@ int Height=Map.GetHeight();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sExpTile OutTile;
|
sExpTile OutTile;
|
||||||
CElem &ThisTile=TileBank->GetTile(MapElem.Set,MapElem.Tile);
|
CElem &ThisTile=TileBank->GetElem(MapElem.Set,MapElem.Tile);
|
||||||
|
|
||||||
OutTile.Set=MapElem.Set;
|
OutTile.Set=MapElem.Set;
|
||||||
OutTile.Tile=MapElem.Tile;
|
OutTile.Tile=MapElem.Tile;
|
||||||
|
|
|
@ -57,7 +57,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParamBar
|
// ParamBar
|
||||||
if (!ParamBar.Create(this,IDD_PARAMBAR,(CBRS_LEFT | CBRS_SIZE_DYNAMIC),IDD_PARAMBAR))
|
if (!ParamBar.Create(this,IDD_MULTIBAR,(CBRS_LEFT | CBRS_SIZE_DYNAMIC),IDD_MULTIBAR))
|
||||||
{
|
{
|
||||||
TRACE0("Failed to create ParamBar\n");
|
TRACE0("Failed to create ParamBar\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -29,19 +29,19 @@ Class17=CMapEditDoc
|
||||||
Class18=CMapEditView
|
Class18=CMapEditView
|
||||||
|
|
||||||
ResourceCount=14
|
ResourceCount=14
|
||||||
Resource1=IDD_LAYER_TOOLBAR
|
Resource1=IDD_LAYER_SHADE
|
||||||
Resource2=IDR_MAPEDITYPE (English (U.S.))
|
Resource2=IDR_MAPEDITYPE (English (U.S.))
|
||||||
Resource3=IDD_LAYER_SHADE
|
Resource3=IDD_TILEBANK
|
||||||
Resource4=IDD_LAYER_COLLISION
|
Resource4=IDD_TOOLBAR
|
||||||
Resource5=IDR_TOOLBAR (English (U.S.))
|
Resource5=IDD_ADDLAYER
|
||||||
Resource6=IDR_MAINFRAME (English (U.S.))
|
Resource6=IDD_LAYER_COLLISION
|
||||||
Resource7=IDD_ABOUTBOX (English (U.S.))
|
Resource7=IDR_TOOLBAR (English (U.S.))
|
||||||
Resource8=IDD_MULTIBAR (English (U.S.))
|
Resource8=IDR_MAINFRAME (English (U.S.))
|
||||||
Resource9=IDD_LAYER_LIST
|
Resource9=IDD_ABOUTBOX (English (U.S.))
|
||||||
Resource10=IDD_RESIZE
|
Resource10=IDD_MULTIBAR (English (U.S.))
|
||||||
Resource11=IDD_NEWMAP
|
Resource11=IDD_LAYER_LIST
|
||||||
Resource12=IDD_ADDLAYER
|
Resource12=IDD_RESIZE
|
||||||
Resource13=IDD_TILEBANK
|
Resource13=IDD_NEWMAP
|
||||||
Resource14=IDD_ELEMLIST
|
Resource14=IDD_ELEMLIST
|
||||||
|
|
||||||
[CLS:CChildFrame]
|
[CLS:CChildFrame]
|
||||||
|
@ -222,13 +222,6 @@ Control1=IDD_TILEBANK_UPDATE,button,1342242816
|
||||||
Control2=IDD_TILEBANK_LOAD,button,1342242816
|
Control2=IDD_TILEBANK_LOAD,button,1342242816
|
||||||
Control3=IDD_TILEBANK_DELETE,button,1342242816
|
Control3=IDD_TILEBANK_DELETE,button,1342242816
|
||||||
|
|
||||||
[DLG:IDD_LAYER_TOOLBAR]
|
|
||||||
Type=1
|
|
||||||
Class=GUIToolBar
|
|
||||||
ControlCount=2
|
|
||||||
Control1=IDD_LAYERTILE_BTN_PAINT,button,1342177344
|
|
||||||
Control2=IDD_LAYERTILE_BTN_SELECT,button,1342177344
|
|
||||||
|
|
||||||
[DLG:IDD_LAYERSHADE_GUI]
|
[DLG:IDD_LAYERSHADE_GUI]
|
||||||
Type=1
|
Type=1
|
||||||
Class=CLayerShadeGUI
|
Class=CLayerShadeGUI
|
||||||
|
@ -363,3 +356,10 @@ Control14=IDC_LAYERSHADE_EDITB3,edit,1350770816
|
||||||
Control15=IDC_LAYERSHADE_COUNTEDIT,edit,1350576256
|
Control15=IDC_LAYERSHADE_COUNTEDIT,edit,1350576256
|
||||||
Control16=IDC_SPIN2,msctls_updown32,1342177302
|
Control16=IDC_SPIN2,msctls_updown32,1342177302
|
||||||
|
|
||||||
|
[DLG:IDD_TOOLBAR]
|
||||||
|
Type=1
|
||||||
|
Class=GUIToolBar
|
||||||
|
ControlCount=2
|
||||||
|
Control1=IDD_LAYERTILE_BTN_PAINT,button,1342177344
|
||||||
|
Control2=IDD_LAYERTILE_BTN_SELECT,button,1342177344
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,12 @@ BSC32=bscmake.exe
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||||
# ADD LINK32 opengl32.lib glu32.lib glib.lib ginlib.lib maths.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\libs\ginlib\debug\\" /libpath:"..\libs\glib\debug\\" /libpath:"..\libs\maths\debug\\"
|
# ADD LINK32 opengl32.lib glu32.lib glib.lib ginlib.lib maths.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\libs\ginlib\debug\\" /libpath:"..\libs\glib\debug\\" /libpath:"..\libs\maths\debug\\"
|
||||||
|
# Begin Special Build Tool
|
||||||
|
ProjDir=.
|
||||||
|
TargetDir=.\Debug
|
||||||
|
SOURCE="$(InputPath)"
|
||||||
|
PostBuild_Cmds=if not exist $(TargetDir)\collision.bmp copy $(ProjDir)\res\collision.bmp $(TargetDir)\collision.bmp if not exist $(TargetDir)\iconz.bmp copy $(ProjDir)\res\iconz.bmp $(TargetDir)\iconz.bmp
|
||||||
|
# End Special Build Tool
|
||||||
|
|
||||||
!ENDIF
|
!ENDIF
|
||||||
|
|
||||||
|
@ -115,14 +121,6 @@ SOURCE=.\LayerDef.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\LayerItem.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\LayerItem.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\LayerShade.cpp
|
SOURCE=.\LayerShade.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@ -131,6 +129,14 @@ SOURCE=.\LayerShade.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\LayerThing.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\LayerThing.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\LayerTile.cpp
|
SOURCE=.\LayerTile.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@ -176,14 +182,6 @@ SOURCE=.\Elem.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\ElemStore.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\ElemStore.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\Map.cpp
|
SOURCE=.\Map.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@ -351,9 +349,14 @@ SOURCE=.\StdAfx.h
|
||||||
# Begin Group "GUI"
|
# Begin Group "GUI"
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
# PROP Default_Filter ""
|
||||||
# Begin Group "New"
|
# Begin Source File
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
SOURCE=.\GUIAddLayer.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\GUIAddLayer.h
|
||||||
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\GUIElemList.cpp
|
SOURCE=.\GUIElemList.cpp
|
||||||
|
@ -364,76 +367,67 @@ SOURCE=.\GUIElemList.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\GUILayerCollision.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\GUILayerCollision.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\GUILayerList.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\GUILayerList.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\GUILayerShade.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\GUILayerShade.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\GUIMultibar.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\GUIMultibar.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\GUINewMap.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\GUINewMap.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\GUIResize.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\GUIResize.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\GUITileBank.cpp
|
SOURCE=.\GUITileBank.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\GUITileBank.h
|
SOURCE=.\GUITileBank.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# End Group
|
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\AddLayerDlg.cpp
|
SOURCE=.\GUIToolBar.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\AddLayerDlg.h
|
SOURCE=.\GUIToolBar.h
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\LayerCollisionGUI.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\LayerCollisionGUI.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\LayerList.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\LayerList.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\LayerShadeGUI.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\LayerShadeGUI.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\LayerTileToolbar.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\LayerTileToolbar.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\MapSizeDlg.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\MapSizeDlg.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\MultiBar.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\MultiBar.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\NewMapGUI.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\NewMapGUI.h
|
|
||||||
# End Source File
|
# End Source File
|
||||||
# End Group
|
# End Group
|
||||||
# End Target
|
# End Target
|
||||||
|
|
|
@ -520,7 +520,7 @@ BEGIN
|
||||||
PUSHBUTTON "Delete",IDD_TILEBANK_DELETE,50,5,45,15
|
PUSHBUTTON "Delete",IDD_TILEBANK_DELETE,50,5,45,15
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_LAYER_TOOLBAR DIALOG DISCARDABLE 0, 0, 156, 16
|
IDD_TOOLBAR DIALOG DISCARDABLE 0, 0, 156, 16
|
||||||
STYLE WS_CHILD
|
STYLE WS_CHILD
|
||||||
FONT 8, "MS Sans Serif"
|
FONT 8, "MS Sans Serif"
|
||||||
BEGIN
|
BEGIN
|
||||||
|
@ -632,7 +632,7 @@ BEGIN
|
||||||
BOTTOMMARGIN, 19
|
BOTTOMMARGIN, 19
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_LAYER_TOOLBAR, DIALOG
|
IDD_TOOLBAR, DIALOG
|
||||||
BEGIN
|
BEGIN
|
||||||
LEFTMARGIN, 7
|
LEFTMARGIN, 7
|
||||||
RIGHTMARGIN, 149
|
RIGHTMARGIN, 149
|
||||||
|
|
|
@ -25,7 +25,7 @@ BEGIN_MESSAGE_MAP(CMapEditDoc, CDocument)
|
||||||
ON_COMMAND(ID_ZOOM_IN, OnZoomIn)
|
ON_COMMAND(ID_ZOOM_IN, OnZoomIn)
|
||||||
ON_COMMAND(ID_ZOOM_OUT, OnZoomOut)
|
ON_COMMAND(ID_ZOOM_OUT, OnZoomOut)
|
||||||
ON_COMMAND(ID_TOGGLE_SUBVIEW, OnToggleSubView)
|
ON_COMMAND(ID_TOGGLE_SUBVIEW, OnToggleSubView)
|
||||||
ON_COMMAND(ID_TOOLBAR_GRID, OnToggleGrid)
|
ON_COMMAND(ID_TOGGLE_GRID, OnToggleGrid)
|
||||||
ON_COMMAND(ID_MIRRORX, OnMirrorx)
|
ON_COMMAND(ID_MIRRORX, OnMirrorx)
|
||||||
ON_COMMAND(ID_MIRRORY, OnMirrory)
|
ON_COMMAND(ID_MIRRORY, OnMirrory)
|
||||||
ON_COMMAND(ID_ACTIVEBRUSH_LEFT, OnActivebrushLeft)
|
ON_COMMAND(ID_ACTIVEBRUSH_LEFT, OnActivebrushLeft)
|
||||||
|
|
|
@ -15,18 +15,8 @@
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*
|
|
||||||
int CTexCache::GetTexIdx(const char *Filename,int Flags)
|
|
||||||
{
|
|
||||||
sTex Tex;
|
|
||||||
Tex.Filename=Filename;
|
|
||||||
Tex.Flags=Flags;
|
|
||||||
return(TexList.Find(Tex));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*****************************************************************************/
|
|
||||||
// Checks loaded files for dups, assumes all passed RGB is unique
|
// Checks loaded files for dups, assumes all passed RGB is unique
|
||||||
int CTexCache::ProcessTexture(const char *Filename,int Flags,sRGBData *RGBData)
|
int CTexCache::ProcessTexture(const char *Filename,sRGBData *RGBData)
|
||||||
{
|
{
|
||||||
int ListSize=TexList.size();
|
int ListSize=TexList.size();
|
||||||
sTex NewTex;
|
sTex NewTex;
|
||||||
|
@ -35,7 +25,6 @@ GFName FName=Filename;
|
||||||
|
|
||||||
NewTex.Name=FName.File();
|
NewTex.Name=FName.File();
|
||||||
NewTex.Filename=Filename;
|
NewTex.Filename=Filename;
|
||||||
NewTex.Flags=Flags;
|
|
||||||
|
|
||||||
if (!RGBData) // Need to load file
|
if (!RGBData) // Need to load file
|
||||||
{
|
{
|
||||||
|
@ -124,13 +113,13 @@ void CTexCache::LoadTex(sTex &ThisTex,sRGBData *TexData)
|
||||||
u8 *Buffer;
|
u8 *Buffer;
|
||||||
int TexWidth=TexData->Width;
|
int TexWidth=TexData->Width;
|
||||||
int TexHeight=TexData->Height;
|
int TexHeight=TexData->Height;
|
||||||
int GLWidth=AlignSize(TexWidth);
|
int AlignWidth=AlignSize(TexWidth);
|
||||||
int GLHeight=AlignSize(TexHeight);
|
int AlignHeight=AlignSize(TexHeight);
|
||||||
u8 *Src,*Dst;
|
u8 *Src,*Dst;
|
||||||
|
|
||||||
// create RGB & alpha texture & ensuse texture is correct size for GL
|
// create RGB & alpha texture & ensuse texture is correct size for GL
|
||||||
|
|
||||||
Buffer=(u8*)malloc(GLWidth*GLHeight*4);
|
Buffer=(u8*)malloc(AlignWidth*AlignHeight*4);
|
||||||
Src=TexData->RGB;
|
Src=TexData->RGB;
|
||||||
Dst=&Buffer[0];
|
Dst=&Buffer[0];
|
||||||
|
|
||||||
|
@ -153,18 +142,18 @@ u8 *Src,*Dst;
|
||||||
*Dst++=B;
|
*Dst++=B;
|
||||||
*Dst++=A;
|
*Dst++=A;
|
||||||
}
|
}
|
||||||
Dst+=(GLWidth-TexWidth)*4;
|
Dst+=(AlignWidth-TexWidth)*4;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThisTex.TexWidth=TexWidth;
|
ThisTex.TexWidth=TexWidth;
|
||||||
ThisTex.TexHeight=TexHeight;
|
ThisTex.TexHeight=TexHeight;
|
||||||
|
|
||||||
ThisTex.dW=(1.0f)/(float)(GLWidth/16.0f);
|
ThisTex.ScaleU=(float)TexWidth/(float)AlignWidth;
|
||||||
ThisTex.dH=(1.0f)/(float)(GLHeight/16.0f);
|
ThisTex.ScaleV=(float)TexHeight/(float)AlignHeight;
|
||||||
|
|
||||||
glGenTextures(1, &ThisTex.TexID);
|
glGenTextures(1, &ThisTex.TexID);
|
||||||
glBindTexture(GL_TEXTURE_2D, ThisTex.TexID);
|
glBindTexture(GL_TEXTURE_2D, ThisTex.TexID);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, 4, GLWidth, GLHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, &Buffer[0]);
|
glTexImage2D(GL_TEXTURE_2D, 0, 4, AlignWidth, AlignHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, &Buffer[0]);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
|
||||||
|
|
|
@ -25,12 +25,11 @@ struct sTex
|
||||||
GString Filename;
|
GString Filename;
|
||||||
GString Name;
|
GString Name;
|
||||||
GLuint TexID;
|
GLuint TexID;
|
||||||
int Flags;
|
|
||||||
int TexWidth,TexHeight;
|
int TexWidth,TexHeight;
|
||||||
float dW,dH;
|
float ScaleU,ScaleV; // For wrong size textures
|
||||||
bool Loaded;
|
bool Loaded;
|
||||||
|
|
||||||
bool operator==(sTex const &v1) {return (Filename==v1.Filename && Flags==v1.Flags);}
|
bool operator==(sTex const &v1) {return (Filename==v1.Filename);}
|
||||||
};
|
};
|
||||||
|
|
||||||
const RGBQUAD BlankRGB={255,0,255};
|
const RGBQUAD BlankRGB={255,0,255};
|
||||||
|
@ -44,7 +43,7 @@ public:
|
||||||
|
|
||||||
int GetTexIdx(sTex &Tex) {return(TexList.Find(Tex));}
|
int GetTexIdx(sTex &Tex) {return(TexList.Find(Tex));}
|
||||||
|
|
||||||
int ProcessTexture(const char *Name,int Flags,sRGBData *RGBData=0);
|
int ProcessTexture(const char *Name,sRGBData *RGBData=0);
|
||||||
void Purge();
|
void Purge();
|
||||||
|
|
||||||
bool LoadBMP(const char *Filename,sRGBData &RGBData);
|
bool LoadBMP(const char *Filename,sRGBData &RGBData);
|
||||||
|
|
|
@ -33,16 +33,11 @@ const float TileBrowserY0=0-TileBrowserGap/2;
|
||||||
const float TileBrowserY1=1+TileBrowserGap/2;
|
const float TileBrowserY1=1+TileBrowserGap/2;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CTileBank::CTileBank()
|
CTileBank::CTileBank() : CElemBank(16,16,true,false)
|
||||||
{
|
{
|
||||||
LoadFlag=false;
|
|
||||||
CurrentSet=0; LastSet=0;
|
|
||||||
for (int i=0; i<MaxBrush; i++) Brush[i].Delete();
|
for (int i=0; i<MaxBrush; i++) Brush[i].Delete();
|
||||||
LastCursorPos=CursorPos=-1;
|
|
||||||
ActiveBrush=0;
|
ActiveBrush=0;
|
||||||
SelStart=-1;
|
SelStart=-1;
|
||||||
SelEnd=-1;
|
|
||||||
VisibleFlag=true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -54,83 +49,28 @@ CTileBank::~CTileBank()
|
||||||
void CTileBank::Load(CFile *File,int Version)
|
void CTileBank::Load(CFile *File,int Version)
|
||||||
{
|
{
|
||||||
if (Version<FileVersion)
|
if (Version<FileVersion)
|
||||||
{
|
|
||||||
int ListSize;
|
|
||||||
GFName RootPath=File->GetFilePath();
|
|
||||||
GString FilePath;
|
|
||||||
char FixPath[1024];
|
|
||||||
|
|
||||||
FilePath=RootPath.Drive();
|
|
||||||
FilePath+=RootPath.Dir();
|
|
||||||
FilePath.Append('\\');
|
|
||||||
FilePath.Upper();
|
|
||||||
|
|
||||||
File->Read(&ListSize,sizeof(int));
|
|
||||||
File->Read(&CurrentSet,sizeof(int));
|
|
||||||
File->Read(&ActiveBrush,sizeof(int));
|
|
||||||
Brush[0].Load(File,Version);
|
|
||||||
Brush[1].Load(File,Version);
|
|
||||||
if (Version<2)
|
|
||||||
{
|
|
||||||
CurrentSet++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// New Style rel storage
|
|
||||||
for (int i=0;i<ListSize;i++)
|
|
||||||
{
|
|
||||||
char c=1;
|
|
||||||
GString FullName;
|
|
||||||
|
|
||||||
while (c)
|
|
||||||
{
|
|
||||||
File->Read(&c,1);
|
|
||||||
FullName.Append(c);
|
|
||||||
}
|
|
||||||
FullName.Upper();
|
|
||||||
GFName::makeabsolute(FilePath,FullName,FixPath);
|
|
||||||
FullName=FixPath;
|
|
||||||
_fullpath( FixPath, FullName, 1024);
|
|
||||||
for (int z=0; z<strlen(FixPath); z++)
|
|
||||||
{// Invalidate any long name short cackness
|
|
||||||
if (FixPath[z]=='~') FixPath[z]='_';
|
|
||||||
}
|
|
||||||
FullName=FixPath;
|
|
||||||
|
|
||||||
CheckFilename(FullName);
|
|
||||||
FullName.Upper();
|
|
||||||
AddSet(FullName);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
File->Read(&LayerCam,sizeof(Vector3));
|
File->Read(&LayerCam,sizeof(Vector3));
|
||||||
File->Read(&CurrentSet,sizeof(int));
|
File->Read(&CurrentSet,sizeof(int));
|
||||||
File->Read(&ActiveBrush,sizeof(int));
|
File->Read(&ActiveBrush,sizeof(int));
|
||||||
Brush[0].Load(File,Version);
|
Brush[0].Load(File,Version);
|
||||||
Brush[1].Load(File,Version);
|
Brush[1].Load(File,Version);
|
||||||
|
}
|
||||||
CElemBank::Load(File,Version);
|
else
|
||||||
|
{
|
||||||
|
File->Read(&LayerCam,sizeof(Vector3));
|
||||||
|
File->Read(&ActiveBrush,sizeof(int));
|
||||||
|
Brush[0].Load(File,Version);
|
||||||
|
Brush[1].Load(File,Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CElemBank::Load(File,Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CTileBank::Save(CFile *File)
|
void CTileBank::Save(CFile *File)
|
||||||
{
|
{
|
||||||
int ListSize=GetSetCount();
|
|
||||||
GFName RootPath=File->GetFilePath();
|
|
||||||
GString SavePath;
|
|
||||||
|
|
||||||
SavePath=RootPath.Drive();
|
|
||||||
SavePath+=RootPath.Dir();
|
|
||||||
SavePath.Append('\\');
|
|
||||||
|
|
||||||
SavePath.Upper();
|
|
||||||
|
|
||||||
File->Write(&LayerCam,sizeof(Vector3));
|
File->Write(&LayerCam,sizeof(Vector3));
|
||||||
File->Write(&CurrentSet,sizeof(int));
|
|
||||||
File->Write(&ActiveBrush,sizeof(int));
|
File->Write(&ActiveBrush,sizeof(int));
|
||||||
Brush[0].Save(File);
|
Brush[0].Save(File);
|
||||||
Brush[1].Save(File);
|
Brush[1].Save(File);
|
||||||
|
@ -138,19 +78,6 @@ GString SavePath;
|
||||||
CElemBank::Save(File);
|
CElemBank::Save(File);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CTileBank::RenderTile(int Set,int Elem,int Flags,bool Is3d)
|
|
||||||
{
|
|
||||||
if (IsValid(Set,Elem))
|
|
||||||
{
|
|
||||||
SetList[Set].RenderElem(Elem,Flags,Is3d);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetList[0].RenderInvalid();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CTileBank::DeleteCurrent()
|
void CTileBank::DeleteCurrent()
|
||||||
{
|
{
|
||||||
|
@ -171,15 +98,6 @@ int ListSize=GetSetCount();
|
||||||
if (CurrentSet) CurrentSet--;
|
if (CurrentSet) CurrentSet--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
CPoint CTileBank::GetTilePos(int ID,int Width)
|
|
||||||
{
|
|
||||||
if (ID==0)
|
|
||||||
return(CPoint(-1,-1));
|
|
||||||
else
|
|
||||||
return(IDToPoint(ID-1,Width));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CTileBank::Render(CCore *Core,Vector3 &CamPos,bool Is3d)
|
void CTileBank::Render(CCore *Core,Vector3 &CamPos,bool Is3d)
|
||||||
{
|
{
|
||||||
|
@ -200,7 +118,7 @@ float Scale=CamPos.z/(float)BrowserWidth/2.0;
|
||||||
|
|
||||||
while(TileID!=ListSize)
|
while(TileID!=ListSize)
|
||||||
{
|
{
|
||||||
CPoint Pos=GetTilePos(TileID,BrowserWidth);
|
CPoint Pos=GetElemPos(TileID,BrowserWidth);
|
||||||
float XPos=(float)Pos.x*(1+TileBrowserGap);
|
float XPos=(float)Pos.x*(1+TileBrowserGap);
|
||||||
float YPos=(float)Pos.y*(1+TileBrowserGap);
|
float YPos=(float)Pos.y*(1+TileBrowserGap);
|
||||||
|
|
||||||
|
@ -263,14 +181,14 @@ float Scale=CamPos.z/(float)BrowserWidth/2.0;
|
||||||
|
|
||||||
if (SelStart==-1)
|
if (SelStart==-1)
|
||||||
{
|
{
|
||||||
Start=GetTilePos(CursorPos,BrowserWidth);
|
Start=GetElemPos(CursorPos,BrowserWidth);
|
||||||
End=Start;
|
End=Start;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
CPoint S=IDToPoint(SelStart-1,BrowserWidth);
|
CPoint S=IDToPoint(SelStart-1,BrowserWidth);
|
||||||
CPoint E=IDToPoint(SelEnd-1,BrowserWidth);
|
CPoint E=IDToPoint(CursorPos-1,BrowserWidth);
|
||||||
|
|
||||||
Start=CPoint( min(S.x,E.x), min(S.y,E.y));
|
Start=CPoint( min(S.x,E.x), min(S.y,E.y));
|
||||||
End=CPoint( max(S.x,E.x), max(S.y,E.y));
|
End=CPoint( max(S.x,E.x), max(S.y,E.y));
|
||||||
|
@ -303,119 +221,6 @@ float Scale=CamPos.z/(float)BrowserWidth/2.0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CTileBank::RenderGrid(CCore *Core,Vector3 &CamPos,bool Active)
|
|
||||||
{
|
|
||||||
if (!GetSetCount()) return;
|
|
||||||
CElemSet &ThisSet=SetList[CurrentSet];
|
|
||||||
int ListSize=ThisSet.GetCount();
|
|
||||||
int BrowserWidth=ThisSet.GetBrowserWidth();
|
|
||||||
int TileID=1; // Dont bother with blank, its sorted
|
|
||||||
float Scale=CamPos.z/(float)BrowserWidth/2.0;
|
|
||||||
|
|
||||||
if (!ListSize) return;
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
|
|
||||||
while(TileID!=ListSize)
|
|
||||||
{
|
|
||||||
CPoint Pos=GetTilePos(TileID,BrowserWidth);
|
|
||||||
float XPos=(float)Pos.x*(1+TileBrowserGap);
|
|
||||||
float YPos=(float)Pos.y*(1+TileBrowserGap);
|
|
||||||
|
|
||||||
glLoadIdentity();
|
|
||||||
glScalef(Scale,Scale,Scale);
|
|
||||||
glTranslatef(-CamPos.x+XPos,CamPos.y-YPos,0);
|
|
||||||
|
|
||||||
glBegin(GL_LINES);
|
|
||||||
glColor3f(1,1,1);
|
|
||||||
|
|
||||||
glVertex3f( TileBrowserX0,TileBrowserY0,0);
|
|
||||||
glVertex3f( TileBrowserX1,TileBrowserY0,0);
|
|
||||||
|
|
||||||
glVertex3f( TileBrowserX0,TileBrowserY1,0);
|
|
||||||
glVertex3f( TileBrowserX1,TileBrowserY1,0);
|
|
||||||
|
|
||||||
glVertex3f( TileBrowserX0,TileBrowserY0,0);
|
|
||||||
glVertex3f( TileBrowserX0,TileBrowserY1,0);
|
|
||||||
|
|
||||||
glVertex3f( TileBrowserX1,TileBrowserY0,0);
|
|
||||||
glVertex3f( TileBrowserX1,TileBrowserY1,0);
|
|
||||||
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
TileID++;
|
|
||||||
}
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CTileBank::FindCursorPos(CCore *Core,Vector3 &CamPos,CPoint &MousePos)
|
|
||||||
{
|
|
||||||
if (!GetSetCount()) return;
|
|
||||||
CElemSet &ThisSet=SetList[CurrentSet];
|
|
||||||
int ListSize=ThisSet.GetCount();
|
|
||||||
int BrowserWidth=ThisSet.GetBrowserWidth();
|
|
||||||
GLint Viewport[4];
|
|
||||||
GLuint SelectBuffer[SELECT_BUFFER_SIZE];
|
|
||||||
int HitCount;
|
|
||||||
int TileID=0;
|
|
||||||
float Scale=CamPos.z/(float)BrowserWidth/2.0;
|
|
||||||
|
|
||||||
if (!ListSize) return;
|
|
||||||
glGetIntegerv(GL_VIEWPORT, Viewport);
|
|
||||||
glSelectBuffer (SELECT_BUFFER_SIZE, SelectBuffer );
|
|
||||||
glRenderMode (GL_SELECT);
|
|
||||||
|
|
||||||
glInitNames();
|
|
||||||
glPushName(-1);
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPushMatrix();
|
|
||||||
glLoadIdentity();
|
|
||||||
gluPickMatrix( MousePos.x ,(Viewport[3]-MousePos.y),5.0,5.0,Viewport);
|
|
||||||
Core->GetView()->SetupPersMatrix();
|
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
|
|
||||||
while(TileID!=ListSize)
|
|
||||||
{
|
|
||||||
CPoint Pos=GetTilePos(TileID,BrowserWidth);
|
|
||||||
float XPos=(float)Pos.x*(1+TileBrowserGap);
|
|
||||||
float YPos=(float)Pos.y*(1+TileBrowserGap);
|
|
||||||
|
|
||||||
glLoadIdentity();
|
|
||||||
glScalef(Scale,Scale,Scale);
|
|
||||||
glTranslatef(-CamPos.x+XPos,CamPos.y-YPos,0);
|
|
||||||
|
|
||||||
glLoadName (TileID);
|
|
||||||
glBegin (GL_QUADS);
|
|
||||||
BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0);
|
|
||||||
glEnd();
|
|
||||||
TileID++;
|
|
||||||
}
|
|
||||||
|
|
||||||
HitCount= glRenderMode (GL_RENDER);
|
|
||||||
glPopMatrix();
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
// Process hits
|
|
||||||
|
|
||||||
GLuint *HitPtr=SelectBuffer;
|
|
||||||
|
|
||||||
TileID=-2;
|
|
||||||
if (HitCount) // Just take 1st
|
|
||||||
{
|
|
||||||
TileID=HitPtr[3];
|
|
||||||
}
|
|
||||||
glMatrixMode(GL_MODELVIEW); // <-- Prevent arse GL assert
|
|
||||||
|
|
||||||
CursorPos=TileID;
|
|
||||||
SelEnd=CursorPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
bool CTileBank::LButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag)
|
bool CTileBank::LButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag)
|
||||||
{
|
{
|
||||||
|
@ -567,7 +372,7 @@ void CTileBank::SetBrush(CMap &ThisBrush)
|
||||||
{
|
{
|
||||||
int BW=SetList[CurrentSet].GetBrowserWidth();
|
int BW=SetList[CurrentSet].GetBrowserWidth();
|
||||||
CPoint S=IDToPoint(SelStart-1,BW);
|
CPoint S=IDToPoint(SelStart-1,BW);
|
||||||
CPoint E=IDToPoint(SelEnd-1,BW);
|
CPoint E=IDToPoint(CursorPos-1,BW);
|
||||||
|
|
||||||
int Width=abs(E.x-S.x)+1;
|
int Width=abs(E.x-S.x)+1;
|
||||||
int Height=abs(E.y-S.y)+1;
|
int Height=abs(E.y-S.y)+1;
|
||||||
|
|
|
@ -21,16 +21,10 @@
|
||||||
#include "GUIElemList.h"
|
#include "GUIElemList.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
enum TileSetEnum
|
|
||||||
{
|
|
||||||
DefTileBrowserWidth=8,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
class CCore;
|
class CCore;
|
||||||
|
class CTileBank : public CElemBank
|
||||||
/*****************************************************************************/
|
|
||||||
class CTileBank : public CLayer, public CElemBank
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CTileBank();
|
CTileBank();
|
||||||
|
@ -46,10 +40,10 @@ public:
|
||||||
int GetType() {return(0);}
|
int GetType() {return(0);}
|
||||||
|
|
||||||
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);
|
||||||
void RenderSelection(CCore *Core,Vector3 &ThisCam){};
|
void RenderSelection(CCore *Core,Vector3 &ThisCam){};
|
||||||
void RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d);
|
void RenderCursor(CCore *Core,Vector3 &CamPos,bool Is3d);
|
||||||
void FindCursorPos(CCore *Core,Vector3 &CamPos,CPoint &MousePos);
|
// void FindCursorPos(CCore *Core,Vector3 &CamPos,CPoint &MousePos);
|
||||||
|
|
||||||
void GUIInit(CCore *Core);
|
void GUIInit(CCore *Core);
|
||||||
void GUIKill(CCore *Core);
|
void GUIKill(CCore *Core);
|
||||||
|
@ -66,12 +60,6 @@ public:
|
||||||
bool MouseMove(CCore *Core,UINT nFlags, CPoint &CursorPos);
|
bool MouseMove(CCore *Core,UINT nFlags, CPoint &CursorPos);
|
||||||
bool Command(int CmdMsg,CCore *Core,int Param0=0,int Param1=0);
|
bool Command(int CmdMsg,CCore *Core,int Param0=0,int Param1=0);
|
||||||
|
|
||||||
// ElemSet Thruput
|
|
||||||
const char *GetSetName(int Set) {return(SetList[Set].GetName());}
|
|
||||||
const char *GetSetFilename(int Set) {return(SetList[Set].GetFilename());}
|
|
||||||
CElem &GetTile(int Set,int Tile) {return(SetList[Set].GetElem(Tile));}
|
|
||||||
void RenderTile(int Set,int Elem,int Flags,bool Is3d);
|
|
||||||
|
|
||||||
// Local
|
// Local
|
||||||
void DeleteCurrent();
|
void DeleteCurrent();
|
||||||
|
|
||||||
|
@ -81,7 +69,6 @@ const char *GetSetFilename(int Set) {return(SetList[Set].GetFilename());
|
||||||
CMap &GetActiveBrush() {return(GetBrush(ActiveBrush));}
|
CMap &GetActiveBrush() {return(GetBrush(ActiveBrush));}
|
||||||
|
|
||||||
bool CanClose() {return(SelStart==-1);}
|
bool CanClose() {return(SelStart==-1);}
|
||||||
CPoint GetTilePos(int ID,int Width);
|
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
bool SelectCancel();
|
bool SelectCancel();
|
||||||
|
@ -89,17 +76,12 @@ const char *GetSetFilename(int Set) {return(SetList[Set].GetFilename());
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool Select(int BrushID,bool DownFlag);
|
bool Select(int BrushID,bool DownFlag);
|
||||||
void SetBrush(CMap &ThisBrush);
|
void SetBrush(CMap &ThisBrush);
|
||||||
|
|
||||||
int CurrentSet,LastSet;
|
|
||||||
CMap Brush[2];
|
CMap Brush[2];
|
||||||
int ActiveBrush;
|
int ActiveBrush;
|
||||||
int SelStart,SelEnd;
|
int SelStart;
|
||||||
|
|
||||||
bool LoadFlag;
|
|
||||||
int LastCursorPos,CursorPos;
|
|
||||||
|
|
||||||
CGUIElemList GUIElemList;
|
CGUIElemList GUIElemList;
|
||||||
CGUITileBank GUITileBank;
|
CGUITileBank GUITileBank;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#define IDD_NEWMAP 169
|
#define IDD_NEWMAP 169
|
||||||
#define IDD_ADDLAYER 172
|
#define IDD_ADDLAYER 172
|
||||||
#define IDD_TILEBANK 173
|
#define IDD_TILEBANK 173
|
||||||
#define IDD_LAYER_TOOLBAR 174
|
#define IDD_TOOLBAR 174
|
||||||
#define IDD_LAYER_SHADE 175
|
#define IDD_LAYER_SHADE 175
|
||||||
#define IDD_LAYER_COLLISION 177
|
#define IDD_LAYER_COLLISION 177
|
||||||
#define IDD_ELEMLIST 178
|
#define IDD_ELEMLIST 178
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue