This commit is contained in:
parent
b35617dd9a
commit
c634faf7b8
18 changed files with 698 additions and 236 deletions
|
@ -69,9 +69,6 @@ void CCore::NewMap()
|
||||||
ActiveLayer=LAYER_TYPE_ACTION;
|
ActiveLayer=LAYER_TYPE_ACTION;
|
||||||
MapCam=Vec(0,0,0);
|
MapCam=Vec(0,0,0);
|
||||||
TileCam=Vec(0,0,0);
|
TileCam=Vec(0,0,0);
|
||||||
// TileBank.AddTileSet("c:/temp/3/test.gin");
|
|
||||||
// TileBank.AddTileSet("c:/temp/4/4.gin");
|
|
||||||
// TileBank.AddTileSet("c:/temp/slope/slope.gin");
|
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +106,7 @@ Vec &ThisCam=GetCam();
|
||||||
Layers[i]->Render(this,ThisCam,Is3dFlag);
|
Layers[i]->Render(this,ThisCam,Is3dFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Layers[ActiveLayer]->RenderCursor(this,ThisCam,Is3dFlag);
|
||||||
if (GridFlag) Layers[ActiveLayer]->RenderGrid(this,ThisCam);
|
if (GridFlag) Layers[ActiveLayer]->RenderGrid(this,ThisCam);
|
||||||
|
|
||||||
// Get Cursor Pos
|
// Get Cursor Pos
|
||||||
|
@ -122,6 +120,7 @@ void CCore::RenderTileView(CMapEditView *View)
|
||||||
Vec &ThisCam=GetCam();
|
Vec &ThisCam=GetCam();
|
||||||
|
|
||||||
TileBank.RenderSet(this,ThisCam,Is3dFlag);
|
TileBank.RenderSet(this,ThisCam,Is3dFlag);
|
||||||
|
// TileBank.RenderCursor(this,ThisCam,Is3dFlag);
|
||||||
|
|
||||||
// Get Cursor Pos
|
// Get Cursor Pos
|
||||||
TileBank.FindCursorPos(this,View,GetCam(),CurrentMousePos);
|
TileBank.FindCursorPos(this,View,GetCam(),CurrentMousePos);
|
||||||
|
@ -145,12 +144,16 @@ BOOL RedrawFlag=FALSE;
|
||||||
|
|
||||||
if (TileViewFlag)
|
if (TileViewFlag)
|
||||||
{
|
{
|
||||||
RedrawFlag=TileBank.TileSelectL();
|
if (nFlags & MK_RBUTTON)
|
||||||
|
RedrawFlag=TileBank.SelectCancel();
|
||||||
|
else
|
||||||
|
RedrawFlag=TileBank.SelectL(DownFlag);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RedrawFlag=Layers[ActiveLayer]->LButtonControl(this,View,nFlags,CursorPos,DownFlag);
|
RedrawFlag=Layers[ActiveLayer]->LButtonControl(this,View,nFlags,CursorPos,DownFlag);
|
||||||
}
|
}
|
||||||
|
TileBank.SetActiveBrushL();
|
||||||
|
|
||||||
if (RedrawFlag) View->Invalidate();
|
if (RedrawFlag) View->Invalidate();
|
||||||
}
|
}
|
||||||
|
@ -168,12 +171,16 @@ BOOL RedrawFlag=FALSE;
|
||||||
|
|
||||||
if (TileViewFlag)
|
if (TileViewFlag)
|
||||||
{
|
{
|
||||||
RedrawFlag=TileBank.TileSelectR();
|
if (nFlags & MK_LBUTTON)
|
||||||
|
RedrawFlag=TileBank.SelectCancel();
|
||||||
|
else
|
||||||
|
RedrawFlag=TileBank.SelectR(DownFlag);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RedrawFlag=Layers[ActiveLayer]->RButtonControl(this,View,nFlags,CursorPos,DownFlag);
|
RedrawFlag=Layers[ActiveLayer]->RButtonControl(this,View,nFlags,CursorPos,DownFlag);
|
||||||
}
|
}
|
||||||
|
TileBank.SetActiveBrushR();
|
||||||
|
|
||||||
if (RedrawFlag) View->Invalidate();
|
if (RedrawFlag) View->Invalidate();
|
||||||
}
|
}
|
||||||
|
@ -222,8 +229,14 @@ Vec &ThisCam=GetCam();
|
||||||
else
|
else
|
||||||
{ // Mouse still moved, so need to redraw windows, to get CursorPos (And pos render)
|
{ // Mouse still moved, so need to redraw windows, to get CursorPos (And pos render)
|
||||||
View->Invalidate();
|
View->Invalidate();
|
||||||
|
if (TileViewFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Layers[ActiveLayer]->MouseMove(this,View,nFlags,CursorPos);
|
Layers[ActiveLayer]->MouseMove(this,View,nFlags,CursorPos);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,13 +329,13 @@ CTileSetDlg *TileSetDlg=(CTileSetDlg*)Frm->GetDialog(IDD_TILESET_DIALOG);
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CCore::MirrorX()
|
void CCore::MirrorX()
|
||||||
{
|
{
|
||||||
if (!TileViewFlag) Layers[ActiveLayer]->MirrorX();
|
if (!TileViewFlag) Layers[ActiveLayer]->MirrorX(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CCore::MirrorY()
|
void CCore::MirrorY()
|
||||||
{
|
{
|
||||||
if (!TileViewFlag) Layers[ActiveLayer]->MirrorY();
|
if (!TileViewFlag) Layers[ActiveLayer]->MirrorY(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -47,7 +47,8 @@ public:
|
||||||
void TileBankSet();
|
void TileBankSet();
|
||||||
void MirrorX();
|
void MirrorX();
|
||||||
void MirrorY();
|
void MirrorY();
|
||||||
|
void ActiveBrushLeft() {TileBank.SetActiveBrushL();}
|
||||||
|
void ActiveBrushRight() {TileBank.SetActiveBrushR();}
|
||||||
// Param Bar
|
// Param Bar
|
||||||
void UpdateParamBar();
|
void UpdateParamBar();
|
||||||
|
|
||||||
|
|
|
@ -45,10 +45,12 @@ virtual void Render(CCore *Core,Vec &CamPos,BOOL Is3d)=0;
|
||||||
virtual void RenderGrid(CCore *Core,Vec &CamPos)=0;
|
virtual void RenderGrid(CCore *Core,Vec &CamPos)=0;
|
||||||
|
|
||||||
virtual void FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos)=0;
|
virtual void FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos)=0;
|
||||||
|
virtual void RenderCursor(CCore *Core,Vec &CamPos,BOOL Is3d)=0;
|
||||||
|
|
||||||
virtual void InitGUI(CCore *Core)=0;
|
virtual void InitGUI(CCore *Core)=0;
|
||||||
virtual void UpdateGUI(CCore *Core)=0;
|
virtual void UpdateGUI(CCore *Core)=0;
|
||||||
|
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
virtual BOOL SetMode(int NewMode)=0;
|
virtual BOOL SetMode(int NewMode)=0;
|
||||||
virtual BOOL InitMode()=0;
|
virtual BOOL InitMode()=0;
|
||||||
|
@ -57,8 +59,8 @@ virtual BOOL LButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint
|
||||||
virtual BOOL RButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos,BOOL DownFlag)=0;
|
virtual BOOL RButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos,BOOL DownFlag)=0;
|
||||||
virtual BOOL MouseMove(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos)=0;
|
virtual BOOL MouseMove(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos)=0;
|
||||||
|
|
||||||
virtual BOOL MirrorX(){return(FALSE);};
|
virtual BOOL MirrorX(CCore *Core){return(FALSE);};
|
||||||
virtual BOOL MirrorY(){return(FALSE);};
|
virtual BOOL MirrorY(CCore *Core){return(FALSE);};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ CLayerTile::CLayerTile(char *_Name,int Width,int Height,float ZDiv,BOOL Is3d)
|
||||||
ZPosDiv=ZDiv;
|
ZPosDiv=ZDiv;
|
||||||
Render3dFlag=Is3d;
|
Render3dFlag=Is3d;
|
||||||
Mode=MouseModePaint;
|
Mode=MouseModePaint;
|
||||||
Flag=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -52,41 +51,75 @@ CLayerTile::~CLayerTile()
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::Render(CCore *Core,Vec &CamPos,BOOL Is3d)
|
void CLayerTile::Render(CCore *Core,Vec &CamPos,BOOL Is3d)
|
||||||
{
|
{
|
||||||
|
float XYDiv=GetLayerZPosDiv();
|
||||||
|
Vec ThisCam=CamPos/XYDiv;
|
||||||
|
|
||||||
if (Is3d && Render3dFlag)
|
if (Is3d && Render3dFlag)
|
||||||
{
|
{
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
Render3d(Core,CamPos);
|
Render3d(Core,ThisCam,Map);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Render2d(Core,CamPos);
|
Render2d(Core,ThisCam,Map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::Render2d(CCore *Core,Vec &CamPos)
|
void CLayerTile::RenderCursorPaint(CCore *Core,Vec &CamPos,BOOL Is3d)
|
||||||
|
{
|
||||||
|
CTileBank &TileBank=Core->GetTileBank();
|
||||||
|
Vec ThisCam=CamPos;
|
||||||
|
CPoint &CursPos=Core->GetCursorPos();
|
||||||
|
CMap &Brush=TileBank.GetActiveBrush();
|
||||||
|
|
||||||
|
if (!Brush.IsValid()) return;
|
||||||
|
|
||||||
|
if (CursPos.x==-1 || CursPos.y==-1) return;
|
||||||
|
ThisCam.x+=CursPos.x;
|
||||||
|
ThisCam.y-=CursPos.y;
|
||||||
|
|
||||||
|
if (Is3d && Render3dFlag)
|
||||||
|
{
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
Render3d(Core,ThisCam,Brush,0.5);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Render2d(Core,ThisCam,Brush,0.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CLayerTile::Render2d(CCore *Core,Vec &CamPos,CMap &ThisMap,float Alpha)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
float XYDiv=GetLayerZPosDiv();
|
int Width=ThisMap.GetWidth();
|
||||||
int MapW=Map.GetWidth();
|
int Height=ThisMap.GetHeight();
|
||||||
int MapH=Map.GetHeight();
|
|
||||||
float StartX=CamPos.x/XYDiv;
|
|
||||||
float StartY=CamPos.y/XYDiv;
|
|
||||||
CTexCache &TexCache=Core->GetTexCache();
|
|
||||||
|
|
||||||
|
if (Alpha<1)
|
||||||
|
{
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Alpha Blend Style
|
||||||
|
glColor4f(0.5,0.5,0.5,Alpha);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
glColor3f(0.5,0.5,0.5);
|
glColor3f(0.5,0.5,0.5);
|
||||||
|
}
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
for (int YLoop=0; YLoop<MapH; YLoop++)
|
for (int YLoop=0; YLoop<Height; YLoop++)
|
||||||
{
|
{
|
||||||
for (int XLoop=0; XLoop<MapW; XLoop++)
|
for (int XLoop=0; XLoop<Width; XLoop++)
|
||||||
{
|
{
|
||||||
sMapElem &ThisElem=Map.GetTile(XLoop,YLoop);
|
sMapElem &ThisElem=ThisMap.Get(XLoop,YLoop);
|
||||||
CTile &ThisTile=Core->GetTile(ThisElem.Set,ThisElem.Tile);
|
CTile &ThisTile=Core->GetTile(ThisElem.Set,ThisElem.Tile);
|
||||||
|
|
||||||
glLoadIdentity(); // Slow way, but good to go for the mo
|
glLoadIdentity(); // Slow way, but good to go for the mo
|
||||||
glTranslatef(StartX+XLoop,StartY-YLoop,CamPos.z);
|
glTranslatef(CamPos.x+XLoop,CamPos.y-YLoop,CamPos.z);
|
||||||
// ThisTile.Render();
|
// ThisTile.Render();
|
||||||
int c=(XLoop+YLoop)&1;
|
int c=(XLoop+YLoop)&1;
|
||||||
glColor3f(c,1,1);
|
glColor3f(c,1,1);
|
||||||
|
@ -96,36 +129,44 @@ int c=(XLoop+YLoop)&1;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::Render3d(CCore *Core,Vec &CamPos)
|
void CLayerTile::Render3d(CCore *Core,Vec &CamPos,CMap &ThisMap,float Alpha)
|
||||||
{
|
{
|
||||||
float XYDiv=GetLayerZPosDiv();
|
int Width=ThisMap.GetWidth();
|
||||||
int MapW=Map.GetWidth();
|
int Height=ThisMap.GetHeight();
|
||||||
int MapH=Map.GetHeight();
|
|
||||||
float StartX=CamPos.x/XYDiv;
|
|
||||||
float StartY=CamPos.y/XYDiv;
|
|
||||||
CTexCache &TexCache=Core->GetTexCache();
|
|
||||||
|
|
||||||
|
if (Alpha<1)
|
||||||
|
{
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Alpha Blend Style
|
||||||
|
glColor4f(0.5,0.5,0.5,Alpha);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
glColor3f(0.5,0.5,0.5);
|
glColor3f(0.5,0.5,0.5);
|
||||||
|
}
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
for (int YLoop=0; YLoop<MapH; YLoop++)
|
for (int YLoop=0; YLoop<Height; YLoop++)
|
||||||
{
|
{
|
||||||
for (int XLoop=0; XLoop<MapW; XLoop++)
|
for (int XLoop=0; XLoop<Width; XLoop++)
|
||||||
{
|
{
|
||||||
sMapElem &ThisElem=Map.GetTile(XLoop,YLoop);
|
sMapElem &ThisElem=ThisMap.Get(XLoop,YLoop);
|
||||||
if (ThisElem.Tile)
|
if (ThisElem.Tile)
|
||||||
{ // Render Non Zero Tiles
|
{ // Render Non Zero Tiles
|
||||||
CTile &ThisTile=Core->GetTile(ThisElem.Set,ThisElem.Tile);
|
CTile &ThisTile=Core->GetTile(ThisElem.Set,ThisElem.Tile);
|
||||||
|
|
||||||
glLoadIdentity(); // Slow way, but good to go for the mo
|
glLoadIdentity(); // Slow way, but good to go for the mo
|
||||||
glTranslatef(StartX+XLoop,StartY-YLoop,CamPos.z);
|
glTranslatef(CamPos.x+XLoop,CamPos.y-YLoop,CamPos.z);
|
||||||
ThisTile.Render(ThisElem.Flags);
|
ThisTile.Render(ThisElem.Flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,8 +174,8 @@ CTexCache &TexCache=Core->GetTexCache();
|
||||||
void CLayerTile::RenderGrid(CCore *Core,Vec &CamPos)
|
void CLayerTile::RenderGrid(CCore *Core,Vec &CamPos)
|
||||||
{
|
{
|
||||||
float XYDiv=GetLayerZPosDiv();
|
float XYDiv=GetLayerZPosDiv();
|
||||||
int MapW=Map.GetWidth();
|
int Width=Map.GetWidth();
|
||||||
int MapH=Map.GetHeight();
|
int Height=Map.GetHeight();
|
||||||
float StartX=CamPos.x/XYDiv;
|
float StartX=CamPos.x/XYDiv;
|
||||||
float StartY=CamPos.y/XYDiv;
|
float StartY=CamPos.y/XYDiv;
|
||||||
float OverVal=0.5;
|
float OverVal=0.5;
|
||||||
|
@ -148,16 +189,16 @@ float OverVal=0.5;
|
||||||
glNormal3f( 1,1,1);
|
glNormal3f( 1,1,1);
|
||||||
glColor3ub(255,255,255);
|
glColor3ub(255,255,255);
|
||||||
|
|
||||||
for (int YLoop=0; YLoop<MapH+1; YLoop++)
|
for (int YLoop=0; YLoop<Height+1; YLoop++)
|
||||||
{
|
{
|
||||||
glVertex3f( 0-OverVal, -YLoop+1, 0);
|
glVertex3f( 0-OverVal, -YLoop+1, 0);
|
||||||
glVertex3f( MapW+OverVal, -YLoop+1, 0);
|
glVertex3f( Width+OverVal, -YLoop+1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int XLoop=0; XLoop<MapW+1; XLoop++)
|
for (int XLoop=0; XLoop<Width+1; XLoop++)
|
||||||
{
|
{
|
||||||
glVertex3f( XLoop, 0+1+OverVal, 0);
|
glVertex3f( XLoop, 0+1+OverVal, 0);
|
||||||
glVertex3f( XLoop, -MapH+1-OverVal, 0);
|
glVertex3f( XLoop, -Height+1-OverVal, 0);
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
@ -174,8 +215,8 @@ int TileID=0;
|
||||||
CPoint &CursorPos=Core->GetCursorPos();
|
CPoint &CursorPos=Core->GetCursorPos();
|
||||||
|
|
||||||
float XYDiv=GetLayerZPosDiv();
|
float XYDiv=GetLayerZPosDiv();
|
||||||
int MapW=Map.GetWidth();
|
int Width=Map.GetWidth();
|
||||||
int MapH=Map.GetHeight();
|
int Height=Map.GetHeight();
|
||||||
float StartX=CamPos.x/XYDiv;
|
float StartX=CamPos.x/XYDiv;
|
||||||
float StartY=CamPos.y/XYDiv;
|
float StartY=CamPos.y/XYDiv;
|
||||||
|
|
||||||
|
@ -197,9 +238,9 @@ float StartY=CamPos.y/XYDiv;
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(StartX,StartY,CamPos.z);
|
glTranslatef(StartX,StartY,CamPos.z);
|
||||||
|
|
||||||
for (int YLoop=0; YLoop<MapH; YLoop++)
|
for (int YLoop=0; YLoop<Height; YLoop++)
|
||||||
{
|
{
|
||||||
for (int XLoop=0; XLoop<MapW; XLoop++)
|
for (int XLoop=0; XLoop<Width; XLoop++)
|
||||||
{
|
{
|
||||||
glLoadName (TileID);
|
glLoadName (TileID);
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
|
@ -222,8 +263,7 @@ GLuint *HitPtr=SelectBuffer;
|
||||||
|
|
||||||
{
|
{
|
||||||
int HitID=HitPtr[3];
|
int HitID=HitPtr[3];
|
||||||
CursorPos.x=HitID%MapW;
|
CursorPos=IDToPoint(HitID,Width);
|
||||||
CursorPos.y=HitID/MapW;
|
|
||||||
}
|
}
|
||||||
glMatrixMode(GL_MODELVIEW); // <-- Prevent arse GL assert
|
glMatrixMode(GL_MODELVIEW); // <-- Prevent arse GL assert
|
||||||
|
|
||||||
|
@ -251,8 +291,6 @@ CGfxToolBar *GfxDlg=(CGfxToolBar *)Frm->GetDialog(IDD_GFXTOOLBAR);
|
||||||
GfxDlg->ResetButtons();
|
GfxDlg->ResetButtons();
|
||||||
switch(Mode)
|
switch(Mode)
|
||||||
{
|
{
|
||||||
case MouseModeNone:
|
|
||||||
break;
|
|
||||||
case MouseModePaint:
|
case MouseModePaint:
|
||||||
GfxDlg->SetButtonState(CGfxToolBar::PAINT,TRUE);
|
GfxDlg->SetButtonState(CGfxToolBar::PAINT,TRUE);
|
||||||
break;
|
break;
|
||||||
|
@ -265,8 +303,6 @@ CGfxToolBar *GfxDlg=(CGfxToolBar *)Frm->GetDialog(IDD_GFXTOOLBAR);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GfxDlg->SetButtonState(CGfxToolBar::MIRRORX,Flag & MouseFlagMirrorX);
|
|
||||||
GfxDlg->SetButtonState(CGfxToolBar::MIRRORY,Flag & MouseFlagMirrorY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -290,8 +326,6 @@ BOOL CLayerTile::InitMode()
|
||||||
{
|
{
|
||||||
switch(Mode)
|
switch(Mode)
|
||||||
{
|
{
|
||||||
case MouseModeNone:
|
|
||||||
break;
|
|
||||||
case MouseModePaint:
|
case MouseModePaint:
|
||||||
break;
|
break;
|
||||||
case MouseModeSelect:
|
case MouseModeSelect:
|
||||||
|
@ -309,8 +343,6 @@ BOOL CLayerTile::ExitMode()
|
||||||
{
|
{
|
||||||
switch(Mode)
|
switch(Mode)
|
||||||
{
|
{
|
||||||
case MouseModeNone:
|
|
||||||
break;
|
|
||||||
case MouseModePaint:
|
case MouseModePaint:
|
||||||
break;
|
break;
|
||||||
case MouseModeSelect:
|
case MouseModeSelect:
|
||||||
|
@ -323,13 +355,6 @@ BOOL CLayerTile::ExitMode()
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
BOOL CLayerTile::SetFlag(int NewFlag)
|
|
||||||
{
|
|
||||||
Flag^=NewFlag;
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
BOOL CLayerTile::LButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos,BOOL DownFlag)
|
BOOL CLayerTile::LButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos,BOOL DownFlag)
|
||||||
{
|
{
|
||||||
|
@ -338,11 +363,9 @@ CTileBank &TileBank=Core->GetTileBank();
|
||||||
|
|
||||||
switch(Mode)
|
switch(Mode)
|
||||||
{
|
{
|
||||||
case MouseModeNone:
|
|
||||||
break;
|
|
||||||
case MouseModePaint:
|
case MouseModePaint:
|
||||||
if (DownFlag)
|
if (DownFlag)
|
||||||
Ret=Paint(TileBank.GetLTile(),CursorPos);
|
Ret=Paint(TileBank.GetLBrush(),CursorPos);
|
||||||
break;
|
break;
|
||||||
case MouseModeSelect:
|
case MouseModeSelect:
|
||||||
break;
|
break;
|
||||||
|
@ -362,11 +385,9 @@ CTileBank &TileBank=Core->GetTileBank();
|
||||||
|
|
||||||
switch(Mode)
|
switch(Mode)
|
||||||
{
|
{
|
||||||
case MouseModeNone:
|
|
||||||
break;
|
|
||||||
case MouseModePaint:
|
case MouseModePaint:
|
||||||
if (DownFlag)
|
if (DownFlag)
|
||||||
Ret=Paint(TileBank.GetRTile(),CursorPos);
|
Ret=Paint(TileBank.GetRBrush(),CursorPos);
|
||||||
break;
|
break;
|
||||||
case MouseModeSelect:
|
case MouseModeSelect:
|
||||||
break;
|
break;
|
||||||
|
@ -386,14 +407,12 @@ CTileBank &TileBank=Core->GetTileBank();
|
||||||
|
|
||||||
switch(Mode)
|
switch(Mode)
|
||||||
{
|
{
|
||||||
case MouseModeNone:
|
|
||||||
break;
|
|
||||||
case MouseModePaint:
|
case MouseModePaint:
|
||||||
if (nFlags & MK_LBUTTON)
|
if (nFlags & MK_LBUTTON)
|
||||||
Ret=Paint(TileBank.GetLTile(),CursorPos);
|
Ret=Paint(TileBank.GetLBrush(),CursorPos);
|
||||||
else
|
else
|
||||||
if (nFlags & MK_RBUTTON)
|
if (nFlags & MK_RBUTTON)
|
||||||
Ret=Paint(TileBank.GetRTile(),CursorPos);
|
Ret=Paint(TileBank.GetRBrush(),CursorPos);
|
||||||
break;
|
break;
|
||||||
case MouseModeSelect:
|
case MouseModeSelect:
|
||||||
break;
|
break;
|
||||||
|
@ -406,16 +425,45 @@ CTileBank &TileBank=Core->GetTileBank();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
BOOL CLayerTile::MirrorX()
|
void CLayerTile::RenderCursor(CCore *Core,Vec &CamPos,BOOL Is3d)
|
||||||
{
|
{
|
||||||
SetFlag(MouseFlagMirrorX);
|
switch(Mode)
|
||||||
|
{
|
||||||
|
case MouseModePaint:
|
||||||
|
RenderCursorPaint(Core,CamPos,Is3d);
|
||||||
|
break;
|
||||||
|
case MouseModeSelect:
|
||||||
|
break;
|
||||||
|
case MouseModePicker:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
BOOL CLayerTile::MirrorX(CCore *Core)
|
||||||
|
{
|
||||||
|
CTileBank &TileBank=Core->GetTileBank();
|
||||||
|
CMap &LBrush=TileBank.GetLBrush();
|
||||||
|
CMap &RBrush=TileBank.GetRBrush();
|
||||||
|
|
||||||
|
LBrush.MirrorX(MouseFlagMirrorX);
|
||||||
|
RBrush.MirrorX(MouseFlagMirrorX);
|
||||||
|
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
BOOL CLayerTile::MirrorY()
|
BOOL CLayerTile::MirrorY(CCore *Core)
|
||||||
{
|
{
|
||||||
SetFlag(MouseFlagMirrorY);
|
CTileBank &TileBank=Core->GetTileBank();
|
||||||
|
CMap &LBrush=TileBank.GetLBrush();
|
||||||
|
CMap &RBrush=TileBank.GetRBrush();
|
||||||
|
|
||||||
|
LBrush.MirrorY(MouseFlagMirrorY);
|
||||||
|
RBrush.MirrorY(MouseFlagMirrorY);
|
||||||
|
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,13 +471,14 @@ BOOL CLayerTile::MirrorY()
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
BOOL CLayerTile::Paint(sMapElem &Tile,CPoint &CursorPos)
|
BOOL CLayerTile::Paint(CMap &Blk,CPoint &CursorPos)
|
||||||
{
|
{
|
||||||
if (CursorPos.y==-1 || CursorPos.y==-1) return(FALSE); // Off Map?
|
if (CursorPos.y==-1 || CursorPos.y==-1) return(FALSE); // Off Map?
|
||||||
if (Tile.Set==-1 || Tile.Tile==-1) return(FALSE); // Invalid tile?
|
if (!Blk.IsValid()) return(FALSE); // Invalid tile?
|
||||||
|
|
||||||
Tile.Flags=Flag;
|
// Tile.Flags=Flag;
|
||||||
Map.SetTile(CursorPos.x,CursorPos.y,Tile);
|
|
||||||
|
Map.Set(CursorPos.x,CursorPos.y,Blk);
|
||||||
|
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,9 @@ class CLayerTile : public CLayer
|
||||||
public:
|
public:
|
||||||
enum MouseMode
|
enum MouseMode
|
||||||
{
|
{
|
||||||
MouseModeNone=0,
|
MouseModePaint=0,
|
||||||
MouseModePaint,
|
|
||||||
MouseModeSelect,
|
MouseModeSelect,
|
||||||
MouseModePicker,
|
MouseModePicker,
|
||||||
// MouseModeMirrorX,
|
|
||||||
// MouseModeMirrorY,
|
|
||||||
};
|
};
|
||||||
enum MouseFlag
|
enum MouseFlag
|
||||||
{
|
{
|
||||||
|
@ -44,35 +41,36 @@ public:
|
||||||
|
|
||||||
void Render(CCore *Core,Vec &CamPos,BOOL Is3d);
|
void Render(CCore *Core,Vec &CamPos,BOOL Is3d);
|
||||||
void RenderGrid(CCore *Core,Vec &CamPos);
|
void RenderGrid(CCore *Core,Vec &CamPos);
|
||||||
|
|
||||||
void FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos);
|
void FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos);
|
||||||
|
void RenderCursor(CCore *Core,Vec &CamPos,BOOL Is3d);
|
||||||
|
|
||||||
void InitGUI(CCore *Core);
|
void InitGUI(CCore *Core);
|
||||||
void UpdateGUI(CCore *Core);
|
void UpdateGUI(CCore *Core);
|
||||||
|
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
BOOL SetMode(int NewMode);
|
BOOL SetMode(int NewMode);
|
||||||
BOOL InitMode();
|
BOOL InitMode();
|
||||||
BOOL ExitMode();
|
BOOL ExitMode();
|
||||||
|
|
||||||
BOOL SetFlag(int Flag);
|
|
||||||
|
|
||||||
BOOL LButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
|
BOOL LButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
|
||||||
BOOL RButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
|
BOOL RButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
|
||||||
BOOL MouseMove(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &point);
|
BOOL MouseMove(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &point);
|
||||||
|
|
||||||
BOOL MirrorX();
|
BOOL MirrorX(CCore *Core);
|
||||||
BOOL MirrorY();
|
BOOL MirrorY(CCore *Core);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Render2d(CCore *Core,Vec &CamPos);
|
void Render2d(CCore *Core,Vec &CamPos,CMap &ThisMap,float Alpha=1.0f);
|
||||||
void Render3d(CCore *Core,Vec &CamPos);
|
void Render3d(CCore *Core,Vec &CamPos,CMap &ThisMap,float Alpha=1.0f);
|
||||||
BOOL Paint(sMapElem &Blk,CPoint &CursorPos);
|
void RenderCursorPaint(CCore *Core,Vec &CamPos,BOOL Is3d);
|
||||||
|
|
||||||
|
BOOL Paint(CMap &Blk,CPoint &CursorPos);
|
||||||
|
|
||||||
CMap Map;
|
CMap Map;
|
||||||
|
|
||||||
MouseMode Mode;
|
MouseMode Mode;
|
||||||
BOOL Flag;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/******************/
|
/*****************/
|
||||||
/*** Map Stuph ***/
|
/*** Map Stuph ***/
|
||||||
/*****************/
|
/*****************/
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CMap::SetSize(int Width,int Height,BOOL Clear)
|
void CMap::SetSize(int Width,int Height,BOOL ClearFlag)
|
||||||
{
|
{
|
||||||
Map.resize(Width);
|
Map.resize(Width);
|
||||||
for (int i=0;i<Width;i++)
|
for (int i=0;i<Width;i++)
|
||||||
|
@ -21,8 +21,15 @@ void CMap::SetSize(int Width,int Height,BOOL Clear)
|
||||||
Map[i].resize(Height);
|
Map[i].resize(Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Clear)
|
if (ClearFlag) Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CMap::Clear()
|
||||||
{
|
{
|
||||||
|
int Width=GetWidth();
|
||||||
|
int Height=GetHeight();
|
||||||
|
|
||||||
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++)
|
||||||
|
@ -34,8 +41,6 @@ void CMap::SetSize(int Width,int Height,BOOL Clear)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CMap::SetWidth(int Width)
|
void CMap::SetWidth(int Width)
|
||||||
{
|
{
|
||||||
|
@ -45,9 +50,24 @@ void CMap::SetWidth(int Width)
|
||||||
void CMap::SetHeight(int Height)
|
void CMap::SetHeight(int Height)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
/*****************************************************************************/
|
||||||
|
int CMap::GetWidth()
|
||||||
|
{
|
||||||
|
return(Map.size());
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CMap::Clear()
|
int CMap::GetHeight()
|
||||||
|
{
|
||||||
|
if (GetWidth())
|
||||||
|
{
|
||||||
|
return(Map[0].size());
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CMap::Delete()
|
||||||
{
|
{
|
||||||
int Width=GetWidth();
|
int Width=GetWidth();
|
||||||
|
|
||||||
|
@ -56,18 +76,114 @@ int Width=GetWidth();
|
||||||
Map[i].clear();
|
Map[i].clear();
|
||||||
}
|
}
|
||||||
Map.clear();
|
Map.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
sMapElem &CMap::GetTile(int X,int Y)
|
sMapElem &CMap::Get(int X,int Y)
|
||||||
{
|
{
|
||||||
return(Map[X][Y]);
|
return(Map[X][Y]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CMap::SetTile(int X,int Y,sMapElem &New)
|
void CMap::Set(int X,int Y,sMapElem &Blk)
|
||||||
{
|
{
|
||||||
Map[X][Y]=New;
|
int Width=GetWidth();
|
||||||
|
int Height=GetHeight();
|
||||||
|
|
||||||
|
// Make sure within map
|
||||||
|
if ((X>=0 && X<Width) && (Y>=0 && Y<Height))
|
||||||
|
{
|
||||||
|
Map[X][Y]=Blk;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CMap::Set(int StartX,int StartY,CMap &Blk)
|
||||||
|
{
|
||||||
|
int Width=Blk.GetWidth();
|
||||||
|
int Height=Blk.GetHeight();
|
||||||
|
|
||||||
|
for (int Y=0; Y<Height; Y++)
|
||||||
|
{
|
||||||
|
for (int X=0; X<Width; X++)
|
||||||
|
{
|
||||||
|
Set(StartX+X,StartY+Y,Blk.Get(X,Y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CMap::Set(CMap &Src,int StartX,int StartY,int Width,int Height)
|
||||||
|
{
|
||||||
|
Delete();
|
||||||
|
SetSize(Width,Height);
|
||||||
|
|
||||||
|
for (int Y=0; Y<Height; Y++)
|
||||||
|
{
|
||||||
|
for (int X=0; X<Width; X++)
|
||||||
|
{
|
||||||
|
Set(X,Y,Src.Get(StartX+X,StartY+Y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CMap::MirrorX(int Flag)
|
||||||
|
{
|
||||||
|
CMap Old=*this;
|
||||||
|
|
||||||
|
int Width=GetWidth();
|
||||||
|
int Height=GetHeight();
|
||||||
|
|
||||||
|
for (int Y=0; Y<Height; Y++)
|
||||||
|
{
|
||||||
|
for (int X=0; X<Width; X++)
|
||||||
|
{
|
||||||
|
sMapElem &ThisElem=Old.Get(X,Y);
|
||||||
|
ThisElem.Flags^=Flag;
|
||||||
|
Set((Width-1)-X,Y,ThisElem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CMap::MirrorY(int Flag)
|
||||||
|
{
|
||||||
|
CMap Old=*this;
|
||||||
|
|
||||||
|
int Width=GetWidth();
|
||||||
|
int Height=GetHeight();
|
||||||
|
|
||||||
|
for (int Y=0; Y<Height; Y++)
|
||||||
|
{
|
||||||
|
for (int X=0; X<Width; X++)
|
||||||
|
{
|
||||||
|
sMapElem &ThisElem=Old.Get(X,Y);
|
||||||
|
ThisElem.Flags^=Flag;
|
||||||
|
Set(X,(Height-1)-Y,ThisElem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
BOOL CMap::DoesContainTile(sMapElem &Tile)
|
||||||
|
{
|
||||||
|
int Width=GetWidth();
|
||||||
|
int Height=GetHeight();
|
||||||
|
|
||||||
|
for (int Y=0; Y<Height; Y++)
|
||||||
|
{
|
||||||
|
for (int X=0; X<Width; X++)
|
||||||
|
{
|
||||||
|
sMapElem &ThisElem=Get(X,Y);
|
||||||
|
if (ThisElem.Set==Tile.Set && ThisElem.Tile==Tile.Tile) return(TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -27,16 +27,33 @@ public:
|
||||||
CMap(){};
|
CMap(){};
|
||||||
~CMap(){};
|
~CMap(){};
|
||||||
|
|
||||||
int GetWidth() {return(Map.size());}
|
int GetWidth();
|
||||||
int GetHeight() {return(Map[0].size());}
|
int GetHeight();
|
||||||
|
BOOL IsValid() {return(GetHeight());}
|
||||||
|
|
||||||
void SetSize(int Width,int Height,BOOL Clear=FALSE);
|
void SetSize(int Width,int Height,BOOL Clear=FALSE);
|
||||||
void SetWidth(int Width);
|
void SetWidth(int Width);
|
||||||
void SetHeight(int Height);
|
void SetHeight(int Height);
|
||||||
void Clear();
|
void Clear();
|
||||||
|
void Delete();
|
||||||
|
void MirrorX(int Flag);
|
||||||
|
void MirrorY(int Flag);
|
||||||
|
|
||||||
sMapElem &GetTile(int X,int Y);
|
sMapElem &Get(int X,int Y);
|
||||||
void SetTile(int X,int Y,sMapElem &New);
|
void Set(int X,int Y,sMapElem &Blk);
|
||||||
|
void Set(int X,int Y,CMap &Blk);
|
||||||
|
void Set(CMap &Src,int StartX,int StartY,int Width,int Height);
|
||||||
|
|
||||||
|
BOOL DoesContainTile(sMapElem &Tile);
|
||||||
|
|
||||||
|
inline void operator=(CMap &Src)
|
||||||
|
{
|
||||||
|
int Width=Src.GetWidth();
|
||||||
|
int Height=Src.GetHeight();
|
||||||
|
Delete();
|
||||||
|
SetSize(Width,Height);
|
||||||
|
Set(Src,0,0,Width,Height);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector< std::vector<sMapElem> > Map;
|
std::vector< std::vector<sMapElem> > Map;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[General Info]
|
[General Info]
|
||||||
Version=1
|
Version=1
|
||||||
LastClass=CMapEditView
|
LastClass=CMapEditDoc
|
||||||
LastTemplate=CDialog
|
LastTemplate=CDialog
|
||||||
NewFileInclude1=#include "stdafx.h"
|
NewFileInclude1=#include "stdafx.h"
|
||||||
NewFileInclude2=#include "mapedit.h"
|
NewFileInclude2=#include "mapedit.h"
|
||||||
|
@ -18,17 +18,17 @@ Class6=CMapEditDoc
|
||||||
Class7=CMapEditView
|
Class7=CMapEditView
|
||||||
|
|
||||||
ResourceCount=9
|
ResourceCount=9
|
||||||
Resource1=IDD_TILESET_DIALOG
|
Resource1=IDD_ABOUTBOX (English (U.S.))
|
||||||
Resource2=IDD_LAYER_LIST_DIALOG
|
Resource2=IDR_TOOLBAR (English (U.S.))
|
||||||
Resource3=IDD_MULTIBAR (English (U.S.))
|
Resource3=IDD_TILESET_DIALOG
|
||||||
Resource4=IDD_DIALOGBAR (English (U.S.))
|
Resource4=IDD_DIALOGBAR (English (U.S.))
|
||||||
Resource5=IDR_TOOLBAR (English (U.S.))
|
Resource5=IDR_MAPEDITYPE (English (U.S.))
|
||||||
Class8=CMultiBar
|
Class8=CMultiBar
|
||||||
Resource6=IDD_ABOUTBOX (English (U.S.))
|
Resource6=IDD_LAYER_LIST_DIALOG
|
||||||
Resource7=IDR_MAPEDITYPE (English (U.S.))
|
Resource7=IDR_MAINFRAME (English (U.S.))
|
||||||
Class9=CLayerList
|
Class9=CLayerList
|
||||||
Class10=CTileSetDlg
|
Class10=CTileSetDlg
|
||||||
Resource8=IDR_MAINFRAME (English (U.S.))
|
Resource8=IDD_MULTIBAR (English (U.S.))
|
||||||
Class11=CGfxToolBar
|
Class11=CGfxToolBar
|
||||||
Resource9=IDD_GFXTOOLBAR
|
Resource9=IDD_GFXTOOLBAR
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ Type=0
|
||||||
BaseClass=CGLEnabledView
|
BaseClass=CGLEnabledView
|
||||||
HeaderFile=MapEditView.h
|
HeaderFile=MapEditView.h
|
||||||
ImplementationFile=MapEditView.cpp
|
ImplementationFile=MapEditView.cpp
|
||||||
LastObject=ID_MIRRORY
|
LastObject=ID_ACTIVEBRUSH_RIGHT
|
||||||
Filter=C
|
Filter=C
|
||||||
VirtualFilter=VWC
|
VirtualFilter=VWC
|
||||||
|
|
||||||
|
@ -130,34 +130,38 @@ Command14=ID_TOGGLE_GRID
|
||||||
Command15=ID_TOGGLE_TILEVIEW
|
Command15=ID_TOGGLE_TILEVIEW
|
||||||
Command16=ID_MIRRORX
|
Command16=ID_MIRRORX
|
||||||
Command17=ID_MIRRORY
|
Command17=ID_MIRRORY
|
||||||
Command18=ID_WINDOW_NEW
|
Command18=ID_ACTIVEBRUSH_LEFT
|
||||||
Command19=ID_WINDOW_CASCADE
|
Command19=ID_ACTIVEBRUSH_RIGHT
|
||||||
Command20=ID_WINDOW_TILE_HORZ
|
Command20=ID_WINDOW_NEW
|
||||||
Command21=ID_WINDOW_ARRANGE
|
Command21=ID_WINDOW_CASCADE
|
||||||
Command22=ID_APP_ABOUT
|
Command22=ID_WINDOW_TILE_HORZ
|
||||||
CommandCount=22
|
Command23=ID_WINDOW_ARRANGE
|
||||||
|
Command24=ID_APP_ABOUT
|
||||||
|
CommandCount=24
|
||||||
|
|
||||||
[ACL:IDR_MAINFRAME (English (U.S.))]
|
[ACL:IDR_MAINFRAME (English (U.S.))]
|
||||||
Type=1
|
Type=1
|
||||||
Class=?
|
Class=?
|
||||||
Command1=ID_EDIT_COPY
|
Command1=ID_ACTIVEBRUSH_LEFT
|
||||||
Command2=ID_TOGGLE_GRID
|
Command2=ID_ACTIVEBRUSH_RIGHT
|
||||||
Command3=ID_FILE_NEW
|
Command3=ID_EDIT_COPY
|
||||||
Command4=ID_FILE_OPEN
|
Command4=ID_TOGGLE_GRID
|
||||||
Command5=ID_FILE_SAVE
|
Command5=ID_FILE_NEW
|
||||||
Command6=ID_EDIT_PASTE
|
Command6=ID_FILE_OPEN
|
||||||
Command7=ID_EDIT_UNDO
|
Command7=ID_FILE_SAVE
|
||||||
Command8=ID_EDIT_CUT
|
Command8=ID_EDIT_PASTE
|
||||||
Command9=ID_EDIT_COPY
|
Command9=ID_EDIT_UNDO
|
||||||
Command10=ID_EDIT_PASTE
|
Command10=ID_EDIT_CUT
|
||||||
Command11=ID_TOGGLE_TILEVIEW
|
Command11=ID_EDIT_COPY
|
||||||
Command12=ID_NEXT_PANE
|
Command12=ID_EDIT_PASTE
|
||||||
Command13=ID_PREV_PANE
|
Command13=ID_TOGGLE_TILEVIEW
|
||||||
Command14=ID_MIRRORX
|
Command14=ID_NEXT_PANE
|
||||||
Command15=ID_EDIT_CUT
|
Command15=ID_PREV_PANE
|
||||||
Command16=ID_MIRRORY
|
Command16=ID_MIRRORX
|
||||||
Command17=ID_EDIT_UNDO
|
Command17=ID_EDIT_CUT
|
||||||
CommandCount=17
|
Command18=ID_MIRRORY
|
||||||
|
Command19=ID_EDIT_UNDO
|
||||||
|
CommandCount=19
|
||||||
|
|
||||||
[DLG:IDD_ABOUTBOX (English (U.S.))]
|
[DLG:IDD_ABOUTBOX (English (U.S.))]
|
||||||
Type=1
|
Type=1
|
||||||
|
@ -233,10 +237,8 @@ VirtualFilter=dWC
|
||||||
[DLG:IDD_GFXTOOLBAR]
|
[DLG:IDD_GFXTOOLBAR]
|
||||||
Type=1
|
Type=1
|
||||||
Class=CGfxToolBar
|
Class=CGfxToolBar
|
||||||
ControlCount=5
|
ControlCount=3
|
||||||
Control1=IDD_GFXTOOLBAR_PAINT,button,1342177344
|
Control1=IDD_GFXTOOLBAR_PAINT,button,1342177344
|
||||||
Control2=IDD_GFXTOOLBAR_SELECT,button,1342177344
|
Control2=IDD_GFXTOOLBAR_SELECT,button,1476395072
|
||||||
Control3=IDD_GFXTOOLBAR_PICKER,button,1342177344
|
Control3=IDD_GFXTOOLBAR_PICKER,button,1476395072
|
||||||
Control4=IDD_GFXTOOLBAR_MIRRORX,button,1342177344
|
|
||||||
Control5=IDD_GFXTOOLBAR_MIRRORY,button,1342177344
|
|
||||||
|
|
||||||
|
|
|
@ -119,8 +119,12 @@ BEGIN
|
||||||
POPUP "&TileBank"
|
POPUP "&TileBank"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "&Toggle TileView", ID_TOGGLE_TILEVIEW
|
MENUITEM "&Toggle TileView", ID_TOGGLE_TILEVIEW
|
||||||
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "Mirror &X", ID_MIRRORX
|
MENUITEM "Mirror &X", ID_MIRRORX
|
||||||
MENUITEM "Mirror &Y", ID_MIRRORY
|
MENUITEM "Mirror &Y", ID_MIRRORY
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "View Left Brush", ID_ACTIVEBRUSH_LEFT
|
||||||
|
MENUITEM "View Right Brush", ID_ACTIVEBRUSH_RIGHT
|
||||||
END
|
END
|
||||||
POPUP "&Window"
|
POPUP "&Window"
|
||||||
BEGIN
|
BEGIN
|
||||||
|
@ -143,6 +147,8 @@ END
|
||||||
|
|
||||||
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
|
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
|
||||||
BEGIN
|
BEGIN
|
||||||
|
219, ID_ACTIVEBRUSH_LEFT, VIRTKEY, NOINVERT
|
||||||
|
221, ID_ACTIVEBRUSH_RIGHT, VIRTKEY, NOINVERT
|
||||||
"C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
|
"C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
|
||||||
"G", ID_TOGGLE_GRID, VIRTKEY, NOINVERT
|
"G", ID_TOGGLE_GRID, VIRTKEY, NOINVERT
|
||||||
"N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT
|
"N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT
|
||||||
|
@ -461,14 +467,10 @@ FONT 8, "MS Sans Serif"
|
||||||
BEGIN
|
BEGIN
|
||||||
PUSHBUTTON "P",IDD_GFXTOOLBAR_PAINT,5,5,15,15,BS_ICON | NOT
|
PUSHBUTTON "P",IDD_GFXTOOLBAR_PAINT,5,5,15,15,BS_ICON | NOT
|
||||||
WS_TABSTOP
|
WS_TABSTOP
|
||||||
PUSHBUTTON "S",IDD_GFXTOOLBAR_SELECT,20,5,15,15,BS_ICON | NOT
|
PUSHBUTTON "S",IDD_GFXTOOLBAR_SELECT,20,5,15,15,BS_ICON |
|
||||||
WS_TABSTOP
|
WS_DISABLED | NOT WS_TABSTOP
|
||||||
PUSHBUTTON "Pk",IDD_GFXTOOLBAR_PICKER,35,5,15,15,BS_ICON | NOT
|
PUSHBUTTON "Pk",IDD_GFXTOOLBAR_PICKER,35,5,15,15,BS_ICON |
|
||||||
WS_TABSTOP
|
WS_DISABLED | NOT WS_TABSTOP
|
||||||
PUSHBUTTON "X",IDD_GFXTOOLBAR_MIRRORX,50,5,15,15,BS_ICON | NOT
|
|
||||||
WS_TABSTOP
|
|
||||||
PUSHBUTTON "Y",IDD_GFXTOOLBAR_MIRRORY,65,5,15,15,BS_ICON | NOT
|
|
||||||
WS_TABSTOP
|
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -220,3 +220,17 @@ void CMapEditDoc::TileBankSet()
|
||||||
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
|
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*********************************************************************************/
|
||||||
|
void CMapEditDoc::ActiveBrushLeft()
|
||||||
|
{
|
||||||
|
Core.ActiveBrushLeft();
|
||||||
|
UpdateAllViews(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************************************************************/
|
||||||
|
void CMapEditDoc::ActiveBrushRight()
|
||||||
|
{
|
||||||
|
Core.ActiveBrushRight();
|
||||||
|
UpdateAllViews(NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@ public:
|
||||||
void ToggleGrid(CMapEditView *View);
|
void ToggleGrid(CMapEditView *View);
|
||||||
void MirrorX();
|
void MirrorX();
|
||||||
void MirrorY();
|
void MirrorY();
|
||||||
|
void ActiveBrushLeft();
|
||||||
|
void ActiveBrushRight();
|
||||||
|
|
||||||
void TileBankLoad();
|
void TileBankLoad();
|
||||||
void TileBankReload();
|
void TileBankReload();
|
||||||
|
|
|
@ -37,10 +37,12 @@ BEGIN_MESSAGE_MAP(CMapEditView, CGLEnabledView)
|
||||||
ON_WM_MOUSEMOVE()
|
ON_WM_MOUSEMOVE()
|
||||||
ON_COMMAND(ID_TOGGLE_TILEVIEW, OnToggleTileview)
|
ON_COMMAND(ID_TOGGLE_TILEVIEW, OnToggleTileview)
|
||||||
ON_COMMAND(ID_TOOLBAR_GRID, OnToggleGrid)
|
ON_COMMAND(ID_TOOLBAR_GRID, OnToggleGrid)
|
||||||
ON_COMMAND(ID_TOOLBAR_TILEPALETTE, OnToggleTileview)
|
|
||||||
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_TOOLBAR_TILEPALETTE, OnToggleTileview)
|
||||||
|
ON_COMMAND(ID_TOGGLE_GRID, OnToggleGrid)
|
||||||
|
ON_COMMAND(ID_ACTIVEBRUSH_LEFT, OnActivebrushLeft)
|
||||||
|
ON_COMMAND(ID_ACTIVEBRUSH_RIGHT, OnActivebrushRight)
|
||||||
//}}AFX_MSG_MAP
|
//}}AFX_MSG_MAP
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
@ -68,7 +70,7 @@ void CMapEditView::OnCreateGL()
|
||||||
{
|
{
|
||||||
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
|
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
|
||||||
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
|
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
|
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Background Color
|
||||||
glClearDepth(1.0f); // Depth Buffer Setup
|
glClearDepth(1.0f); // Depth Buffer Setup
|
||||||
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
||||||
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
|
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
|
||||||
|
@ -76,6 +78,9 @@ void CMapEditView::OnCreateGL()
|
||||||
glEnable(GL_LIGHTING); // Enable Lighting
|
glEnable(GL_LIGHTING); // Enable Lighting
|
||||||
glEnable(GL_COLOR_MATERIAL); // Enable Material Coloring
|
glEnable(GL_COLOR_MATERIAL); // Enable Material Coloring
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
|
||||||
|
// glDisable(GL_BLEND); // Enable Alpha Channel
|
||||||
|
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Alpha Blend Style
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,3 +160,6 @@ void CMapEditView::OnToggleTileview() {GetDocument()->ToggleTileView(thi
|
||||||
void CMapEditView::OnToggleGrid() {GetDocument()->ToggleGrid(this);}
|
void CMapEditView::OnToggleGrid() {GetDocument()->ToggleGrid(this);}
|
||||||
void CMapEditView::OnMirrorx() {GetDocument()->MirrorX();}
|
void CMapEditView::OnMirrorx() {GetDocument()->MirrorX();}
|
||||||
void CMapEditView::OnMirrory() {GetDocument()->MirrorY();}
|
void CMapEditView::OnMirrory() {GetDocument()->MirrorY();}
|
||||||
|
|
||||||
|
void CMapEditView::OnActivebrushLeft() {GetDocument()->ActiveBrushLeft();}
|
||||||
|
void CMapEditView::OnActivebrushRight() {GetDocument()->ActiveBrushRight();}
|
||||||
|
|
|
@ -59,6 +59,8 @@ protected:
|
||||||
afx_msg void OnToggleGrid();
|
afx_msg void OnToggleGrid();
|
||||||
afx_msg void OnMirrorx();
|
afx_msg void OnMirrorx();
|
||||||
afx_msg void OnMirrory();
|
afx_msg void OnMirrory();
|
||||||
|
afx_msg void OnActivebrushLeft();
|
||||||
|
afx_msg void OnActivebrushRight();
|
||||||
//}}AFX_MSG
|
//}}AFX_MSG
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,14 +38,32 @@ CTileBank::CTileBank()
|
||||||
{
|
{
|
||||||
LoadFlag=FALSE;
|
LoadFlag=FALSE;
|
||||||
CurrentSet=0;
|
CurrentSet=0;
|
||||||
LTile.Set=-1;
|
for (int i=0; i<MaxBrush; i++) Brush[i].Delete();
|
||||||
RTile.Set=-1;
|
LastCursorPos=CursorPos=-1;
|
||||||
|
ActiveBrush=0;
|
||||||
|
SelStart=-1;
|
||||||
|
SelEnd=1;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
AddTileSet("c:/temp/rockp/rockp.gin");
|
AddTileSet("c:/temp/rockp/rockp.gin");
|
||||||
LTile.Set=0;
|
|
||||||
LTile.Tile=1;
|
int W=3;
|
||||||
RTile.Set=0;
|
int H=3;
|
||||||
RTile.Tile=2;
|
CMap &Brush=GetLBrush();
|
||||||
|
|
||||||
|
Brush.SetSize(W,H);
|
||||||
|
sMapElem Blk;
|
||||||
|
Blk.Set=0;
|
||||||
|
Blk.Tile=1;
|
||||||
|
Blk.Flags=0;
|
||||||
|
for (int Y=0; Y<H; Y++)
|
||||||
|
{
|
||||||
|
for (int X=0; X<W; X++)
|
||||||
|
{
|
||||||
|
Brush.Set(X,Y,Blk);
|
||||||
|
Blk.Tile++;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +75,8 @@ CTileBank::~CTileBank()
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CTileBank::AddTileSet(char *Filename)
|
void CTileBank::AddTileSet(char *Filename)
|
||||||
{
|
{
|
||||||
TileSet.push_back(CTileSet(Filename));
|
int ListSize=TileSet.size();
|
||||||
|
TileSet.push_back(CTileSet(Filename,ListSize));
|
||||||
LoadFlag=TRUE;
|
LoadFlag=TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,24 +116,21 @@ CTile &CTileBank::GetTile(int Bank,int Tile)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CTileBank::RenderSet(CCore *Core,Vec &CamPos,BOOL Is3d)
|
void CTileBank::RenderSet(CCore *Core,Vec &CamPos,BOOL Is3d)
|
||||||
{
|
{
|
||||||
int LT=LTile.Tile;
|
|
||||||
int RT=RTile.Tile;
|
|
||||||
|
|
||||||
if (LTile.Set!=CurrentSet) LT=-1;
|
|
||||||
if (RTile.Set!=CurrentSet) RT=-1;
|
|
||||||
|
|
||||||
if (!TileSet.size()) return; // No tiles, return
|
if (!TileSet.size()) return; // No tiles, return
|
||||||
|
|
||||||
if (Is3d)
|
if (Is3d)
|
||||||
{
|
{
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
TileSet[CurrentSet].Render3d(CamPos,LT,RT,CursorPos,Core->IsGridOn());
|
TileSet[CurrentSet].Render3d(CamPos,GetLBrush(),GetRBrush());
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TileSet[CurrentSet].Render2d(CamPos,LT,RT,CursorPos,Core->IsGridOn());
|
TileSet[CurrentSet].Render2d(CamPos,GetLBrush(),GetRBrush());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TileSet[CurrentSet].RenderCursor(CamPos,CursorPos,SelStart,SelEnd);
|
||||||
|
if (Core->IsGridOn()) TileSet[CurrentSet].RenderGrid(CamPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -123,6 +139,7 @@ void CTileBank::FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint
|
||||||
if (!TileSet.size()) return; // No tiles, return
|
if (!TileSet.size()) return; // No tiles, return
|
||||||
|
|
||||||
CursorPos=TileSet[CurrentSet].FindCursorPos(Core,View,CamPos,MousePos);
|
CursorPos=TileSet[CurrentSet].FindCursorPos(Core,View,CamPos,MousePos);
|
||||||
|
SelEnd=CursorPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -155,17 +172,66 @@ int ListSize=TileSet.size();
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*** Functions ***************************************************************/
|
/*** Functions ***************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
BOOL CTileBank::TileSelect(sMapElem &ThisTile,sMapElem &OtherTile)
|
BOOL CTileBank::Select(int BrushID,BOOL DownFlag)
|
||||||
|
{
|
||||||
|
if (DownFlag && SelStart==-1)
|
||||||
{
|
{
|
||||||
if (CursorPos==-1) return(FALSE);
|
if (CursorPos==-1) return(FALSE);
|
||||||
if (CurrentSet==OtherTile.Set && OtherTile.Tile==CursorPos)
|
SelStart=CursorPos;
|
||||||
{ // Dont assign if same as other Tile
|
TRACE3("Start %i=%i,%i\n",SelStart,SelStart%TileBrowserWidth,SelStart/TileBrowserWidth);
|
||||||
return(FALSE);
|
}
|
||||||
|
else
|
||||||
|
if (!DownFlag && SelStart!=-1)
|
||||||
|
{
|
||||||
|
if (CursorPos==-1) return(SelectCancel());
|
||||||
|
|
||||||
|
SetBrush(GetBrush(BrushID));
|
||||||
|
|
||||||
|
SelStart=-1;
|
||||||
|
TRACE0("END SEL\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ThisTile.Set=CurrentSet;
|
return(TRUE);
|
||||||
ThisTile.Tile=CursorPos;
|
}
|
||||||
if (ThisTile.Tile==0) ThisTile.Set=0; // Always make zero tile, bank 0 (dunno why, just seems handy)
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CTileBank::SetBrush(CMap &ThisBrush)
|
||||||
|
{
|
||||||
|
|
||||||
|
CPoint S=IDToPoint(SelStart,TileBrowserWidth);
|
||||||
|
CPoint E=IDToPoint(SelEnd,TileBrowserWidth);
|
||||||
|
|
||||||
|
CPoint Start=CPoint(min(S.x,E.x), min(S.y,E.y));
|
||||||
|
CPoint End=CPoint( max(S.x,E.x), max(S.y,E.y));
|
||||||
|
int Width=(End.x-Start.x)+1;
|
||||||
|
int Height=(End.y-Start.y)+1;
|
||||||
|
sMapElem ThisElem;
|
||||||
|
int MaxTile=TileSet[CurrentSet].GetTileCount();
|
||||||
|
|
||||||
|
if (PointToID(End,TileBrowserWidth)>=MaxTile) SelectCancel(); // Invalid selection
|
||||||
|
|
||||||
|
ThisElem.Set=CurrentSet;
|
||||||
|
ThisElem.Flags=0;
|
||||||
|
|
||||||
|
ThisBrush.Delete();
|
||||||
|
ThisBrush.SetSize(Width,Height);
|
||||||
|
|
||||||
|
for (int Y=0; Y<Height; Y++)
|
||||||
|
{
|
||||||
|
for (int X=0; X<Width; X++)
|
||||||
|
{
|
||||||
|
ThisElem.Tile=PointToID(CPoint(Start.x+X,Start.y+Y),TileBrowserWidth);
|
||||||
|
ThisBrush.Set(X,Y,ThisElem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
BOOL CTileBank::SelectCancel()
|
||||||
|
{
|
||||||
|
SelStart=-1;
|
||||||
|
TRACE0("Select Cancelled\n");
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +240,7 @@ BOOL CTileBank::TileSelect(sMapElem &ThisTile,sMapElem &OtherTile)
|
||||||
/*** TileSet *****************************************************************/
|
/*** TileSet *****************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CTileSet::CTileSet(char *_Filename)
|
CTileSet::CTileSet(char *_Filename,int Idx)
|
||||||
{
|
{
|
||||||
char Drive[_MAX_DRIVE];
|
char Drive[_MAX_DRIVE];
|
||||||
char Dir[_MAX_DIR];
|
char Dir[_MAX_DIR];
|
||||||
|
@ -185,6 +251,7 @@ char Ext[_MAX_EXT];
|
||||||
sprintf(Path,"%s%s",Drive,Dir);
|
sprintf(Path,"%s%s",Drive,Dir);
|
||||||
sprintf(Name,"%s",Fname);
|
sprintf(Name,"%s",Fname);
|
||||||
Loaded=FALSE;
|
Loaded=FALSE;
|
||||||
|
SetNumber=Idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -232,30 +299,66 @@ int ListSize=Tile.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CTileSet::Render2d(Vec &CamPos,int LTile,int RTile,int CursorPos,BOOL GridFlag)
|
void CTileSet::Render2d(Vec &CamPos,CMap &LBrush,CMap &RBrush)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CTileSet::Render3d(Vec &CamPos,int LTile,int RTile,int CursorPos,BOOL GridFlag)
|
void CTileSet::Render3d(Vec &CamPos,CMap &LBrush,CMap &RBrush)
|
||||||
{
|
{
|
||||||
int ListSize=Tile.size();
|
int ListSize=Tile.size();
|
||||||
int TileID=0;
|
int TileID=0;
|
||||||
|
sMapElem ThisElem;
|
||||||
|
int SelFlag;
|
||||||
|
|
||||||
|
ThisElem.Flags=0;
|
||||||
|
ThisElem.Set=SetNumber;
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
while(TileID!=ListSize)
|
while(TileID!=ListSize)
|
||||||
{
|
{
|
||||||
int XPos=TileID%TileBrowserWidth;
|
CPoint Pos=IDToPoint(TileID,TileBrowserWidth);
|
||||||
int YPos=TileID/TileBrowserWidth;
|
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(CamPos.x+XPos*(1+TileBrowserGap),CamPos.y-YPos*(1+TileBrowserGap),CamPos.z);
|
glTranslatef(CamPos.x+Pos.x*(1+TileBrowserGap),CamPos.y-Pos.y*(1+TileBrowserGap),CamPos.z);
|
||||||
|
|
||||||
RenderMisc(TileID==LTile,TileID==RTile,TileID==CursorPos,GridFlag);
|
|
||||||
|
|
||||||
glColor3f(0.5,0.5,0.5);
|
glColor3f(0.5,0.5,0.5);
|
||||||
if (TileID) Tile[TileID].Render(0);
|
if (TileID) Tile[TileID].Render(0);
|
||||||
|
ThisElem.Tile=TileID;
|
||||||
|
SelFlag=0;
|
||||||
|
|
||||||
|
if (LBrush.DoesContainTile(ThisElem)) SelFlag|=1;
|
||||||
|
if (RBrush.DoesContainTile(ThisElem)) SelFlag|=2;
|
||||||
|
|
||||||
|
if (SelFlag)
|
||||||
|
{
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glNormal3f( 1,1,1);
|
||||||
|
switch(SelFlag)
|
||||||
|
{
|
||||||
|
case 1: // L
|
||||||
|
glColor4f(1,0,0,0.5);
|
||||||
|
BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0);
|
||||||
|
break;
|
||||||
|
case 2: // R
|
||||||
|
glColor4f(0,0,1,0.5);
|
||||||
|
BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0);
|
||||||
|
break;
|
||||||
|
case 3: // LR
|
||||||
|
glColor4f(1,0,0,0.5);
|
||||||
|
BuildGLQuad(TileBrowserX0,0.5,TileBrowserY0,TileBrowserY1,0);
|
||||||
|
glColor4f(0,0,1,0.5);
|
||||||
|
BuildGLQuad(0.5,TileBrowserX1,TileBrowserY0,TileBrowserY1,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
glEnd();
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
TileID++;
|
TileID++;
|
||||||
}
|
}
|
||||||
|
@ -263,6 +366,97 @@ int TileID=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
void CTileSet::RenderCursor(Vec &CamPos,int CursorPos,int SelStart,int SelEnd)
|
||||||
|
{
|
||||||
|
int ListSize=Tile.size();
|
||||||
|
CPoint Start,End;
|
||||||
|
int MaxTile=Tile.size();
|
||||||
|
if (CursorPos<0 || CursorPos>ListSize) return;
|
||||||
|
|
||||||
|
if (SelStart==-1)
|
||||||
|
{
|
||||||
|
Start=IDToPoint(CursorPos,TileBrowserWidth);
|
||||||
|
End=Start;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CPoint S=IDToPoint(SelStart,TileBrowserWidth);
|
||||||
|
CPoint E=IDToPoint(SelEnd,TileBrowserWidth);
|
||||||
|
|
||||||
|
Start=CPoint( min(S.x,E.x), min(S.y,E.y));
|
||||||
|
End=CPoint( max(S.x,E.x), max(S.y,E.y));
|
||||||
|
if (PointToID(End,TileBrowserWidth)>=MaxTile) return; // Invalid selection
|
||||||
|
}
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
|
||||||
|
for (int Y=Start.y; Y<=End.y; Y++)
|
||||||
|
{
|
||||||
|
for (int X=Start.x; X<=End.x; X++)
|
||||||
|
{
|
||||||
|
// RenderCursorBlock(CamPos,X,Y);
|
||||||
|
glLoadIdentity();
|
||||||
|
glTranslatef(CamPos.x+X*(1+TileBrowserGap),CamPos.y-Y*(1+TileBrowserGap),CamPos.z);
|
||||||
|
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glNormal3f( 1,1,1);
|
||||||
|
|
||||||
|
glColor4f(1,1,0,0.5);
|
||||||
|
BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CTileSet::RenderGrid(Vec &CamPos)
|
||||||
|
{
|
||||||
|
int ListSize=Tile.size();
|
||||||
|
int TileID=0;
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
while(TileID!=ListSize)
|
||||||
|
{
|
||||||
|
CPoint Pos=IDToPoint(TileID,TileBrowserWidth);
|
||||||
|
|
||||||
|
glLoadIdentity();
|
||||||
|
glTranslatef(CamPos.x+Pos.x*(1+TileBrowserGap),CamPos.y-Pos.y*(1+TileBrowserGap),CamPos.z);
|
||||||
|
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glNormal3f( 1,1,1);
|
||||||
|
glColor3ub(255,255,255);
|
||||||
|
|
||||||
|
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++;
|
||||||
|
}
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void CTileSet::RenderMisc(BOOL LTileFlag,BOOL RTileFlag,BOOL CursorFlag,BOOL GridFlag)
|
void CTileSet::RenderMisc(BOOL LTileFlag,BOOL RTileFlag,BOOL CursorFlag,BOOL GridFlag)
|
||||||
{
|
{
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
@ -309,7 +503,7 @@ void CTileSet::RenderMisc(BOOL LTileFlag,BOOL RTileFlag,BOOL CursorFlag,BOOL Gri
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int CTileSet::FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos)
|
int CTileSet::FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos)
|
||||||
{
|
{
|
||||||
|
@ -336,11 +530,10 @@ int TileID=0;
|
||||||
|
|
||||||
while(TileID!=ListSize)
|
while(TileID!=ListSize)
|
||||||
{
|
{
|
||||||
int XPos=TileID%TileBrowserWidth;
|
CPoint Pos=IDToPoint(TileID,TileBrowserWidth);
|
||||||
int YPos=TileID/TileBrowserWidth;
|
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(CamPos.x+XPos*(1+TileBrowserGap),CamPos.y-YPos*(1+TileBrowserGap),CamPos.z);
|
glTranslatef(CamPos.x+Pos.x*(1+TileBrowserGap),CamPos.y-Pos.y*(1+TileBrowserGap),CamPos.z);
|
||||||
|
|
||||||
glLoadName (TileID);
|
glLoadName (TileID);
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
|
@ -363,6 +556,7 @@ GLuint *HitPtr=SelectBuffer;
|
||||||
TileID=HitPtr[3];
|
TileID=HitPtr[3];
|
||||||
}
|
}
|
||||||
glMatrixMode(GL_MODELVIEW); // <-- Prevent arse GL assert
|
glMatrixMode(GL_MODELVIEW); // <-- Prevent arse GL assert
|
||||||
|
|
||||||
return(TileID);
|
return(TileID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,13 @@ public:
|
||||||
CTileBank();
|
CTileBank();
|
||||||
~CTileBank();
|
~CTileBank();
|
||||||
|
|
||||||
|
enum BrushEnum
|
||||||
|
{
|
||||||
|
LBrush=0,
|
||||||
|
RBrush,
|
||||||
|
MaxBrush
|
||||||
|
};
|
||||||
|
|
||||||
void AddTileSet(char *Filename);
|
void AddTileSet(char *Filename);
|
||||||
int NeedLoad() {return(LoadFlag);}
|
int NeedLoad() {return(LoadFlag);}
|
||||||
void Reload();
|
void Reload();
|
||||||
|
@ -40,53 +47,66 @@ public:
|
||||||
|
|
||||||
void SetCurrent(int Set) {CurrentSet=Set;}
|
void SetCurrent(int Set) {CurrentSet=Set;}
|
||||||
|
|
||||||
sMapElem &GetLTile() {return(LTile);}
|
CMap &GetLBrush() {return(Brush[LBrush]);}
|
||||||
sMapElem &GetRTile() {return(RTile);}
|
CMap &GetRBrush() {return(Brush[RBrush]);}
|
||||||
|
CMap &GetBrush(int i) {return(Brush[i]);}
|
||||||
|
CMap &GetActiveBrush() {return(GetBrush(ActiveBrush));}
|
||||||
|
|
||||||
void RenderSet(CCore *Core,Vec &CamPos,BOOL Is3d);
|
void RenderSet(CCore *Core,Vec &CamPos,BOOL Is3d);
|
||||||
void FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos);
|
void FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos);
|
||||||
|
void RenderCursor(CCore *Core,Vec &CamPos,BOOL Is3d);
|
||||||
|
|
||||||
void UpdateGUI(CCore *Core,BOOL IsTileView);
|
void UpdateGUI(CCore *Core,BOOL IsTileView);
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
BOOL TileSelectL() {return(TileSelect(LTile,RTile));}
|
BOOL SelectL(BOOL DownFlag) {return(Select(LBrush,DownFlag));}
|
||||||
BOOL TileSelectR() {return(TileSelect(RTile,LTile));}
|
BOOL SelectR(BOOL DownFlag) {return(Select(RBrush,DownFlag));}
|
||||||
|
BOOL SelectCancel();
|
||||||
|
|
||||||
|
void SetActiveBrushL() {ActiveBrush=LBrush;}
|
||||||
|
void SetActiveBrushR() {ActiveBrush=RBrush;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOOL TileSelect(sMapElem &ThisTile,sMapElem &OtherTile);
|
BOOL Select(int BrushID,BOOL DownFlag);
|
||||||
|
void SetBrush(CMap &ThisBrush);
|
||||||
|
|
||||||
std::vector<CTileSet> TileSet;
|
std::vector<CTileSet> TileSet;
|
||||||
int CurrentSet;
|
int CurrentSet;
|
||||||
sMapElem LTile,RTile;
|
CMap Brush[2];
|
||||||
|
int ActiveBrush;
|
||||||
|
int SelStart,SelEnd;
|
||||||
|
|
||||||
BOOL LoadFlag;
|
BOOL LoadFlag;
|
||||||
int CursorPos;
|
int LastCursorPos,CursorPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
class CTileSet
|
class CTileSet
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CTileSet(char *_Filename);
|
CTileSet(char *_Filename,int Idx);
|
||||||
~CTileSet();
|
~CTileSet();
|
||||||
|
|
||||||
int IsLoaded() {return(Loaded);}
|
int IsLoaded() {return(Loaded);}
|
||||||
|
int GetTileCount() {return(Tile.size());}
|
||||||
void Load(CCore *Core);
|
void Load(CCore *Core);
|
||||||
char *GetPath() {return(Path);}
|
char *GetPath() {return(Path);}
|
||||||
char *GetName() {return(Name);}
|
char *GetName() {return(Name);}
|
||||||
CTile &GetTile(int No) {return(Tile[No]);}
|
CTile &GetTile(int No) {return(Tile[No]);}
|
||||||
void Purge();
|
void Purge();
|
||||||
int FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos);
|
int FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos);
|
||||||
void Render2d(Vec &CamPos,int LTile,int RTile,int CursorPos,BOOL GridFlag);
|
void Render2d(Vec &CamPos,CMap &LBrush,CMap &RBrush);
|
||||||
void Render3d(Vec &CamPos,int LTile,int RTile,int CursorPos,BOOL GridFlag);
|
void Render3d(Vec &CamPos,CMap &LBrush,CMap &RBrush);
|
||||||
|
void RenderCursor(Vec &CamPos,int Pos,int Width, int Height);
|
||||||
|
void RenderBrush(Vec &CamPos,CMap &LBrush,CMap &RBrush);
|
||||||
|
void RenderGrid(Vec &CamPos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RenderMisc(BOOL LTileFlag,BOOL RTileFlag,BOOL CursorFlag,BOOL GridFlag);
|
|
||||||
|
|
||||||
char Path[256],Name[256];
|
char Path[256],Name[256];
|
||||||
|
int SetNumber;
|
||||||
std::vector<CTile> Tile;
|
std::vector<CTile> Tile;
|
||||||
BOOL Loaded;
|
BOOL Loaded;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -24,8 +24,6 @@
|
||||||
#define IDC_TILESETDLG_BTN_LOAD 1031
|
#define IDC_TILESETDLG_BTN_LOAD 1031
|
||||||
#define IDD_GFXTOOLBAR_SELECT 1032
|
#define IDD_GFXTOOLBAR_SELECT 1032
|
||||||
#define IDD_GFXTOOLBAR_PICKER 1033
|
#define IDD_GFXTOOLBAR_PICKER 1033
|
||||||
#define IDD_GFXTOOLBAR_MIRRORX 1034
|
|
||||||
#define IDD_GFXTOOLBAR_MIRRORY 1035
|
|
||||||
#define ID_TOOLBAR_LAYERBAR 32773
|
#define ID_TOOLBAR_LAYERBAR 32773
|
||||||
#define ID_TOOLBAR_TILEPALETTE 32774
|
#define ID_TOOLBAR_TILEPALETTE 32774
|
||||||
#define ID_TOOLBAR_COMBO 32777
|
#define ID_TOOLBAR_COMBO 32777
|
||||||
|
@ -36,6 +34,8 @@
|
||||||
#define ID_TOGGLE_GRID 32787
|
#define ID_TOGGLE_GRID 32787
|
||||||
#define ID_MIRRORX 32788
|
#define ID_MIRRORX 32788
|
||||||
#define ID_MIRRORY 32789
|
#define ID_MIRRORY 32789
|
||||||
|
#define ID_ACTIVEBRUSH_LEFT 32790
|
||||||
|
#define ID_ACTIVEBRUSH_RIGHT 32791
|
||||||
#define ID_INDICATOR_CURSORXY 59142
|
#define ID_INDICATOR_CURSORXY 59142
|
||||||
|
|
||||||
// Next default values for new objects
|
// Next default values for new objects
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_3D_CONTROLS 1
|
#define _APS_3D_CONTROLS 1
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 167
|
#define _APS_NEXT_RESOURCE_VALUE 167
|
||||||
#define _APS_NEXT_COMMAND_VALUE 32790
|
#define _APS_NEXT_COMMAND_VALUE 32792
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1037
|
#define _APS_NEXT_CONTROL_VALUE 1037
|
||||||
#define _APS_NEXT_SYMED_VALUE 101
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -155,6 +155,25 @@ TVECTOR Out;
|
||||||
return Out;
|
return Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************/
|
||||||
|
CPoint IDToPoint(int ID,int Width)
|
||||||
|
{
|
||||||
|
CPoint XY;
|
||||||
|
|
||||||
|
XY.x=ID%Width;
|
||||||
|
XY.y=ID/Width;
|
||||||
|
return(XY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************/
|
||||||
|
int PointToID(CPoint &Pnt,int Width)
|
||||||
|
{
|
||||||
|
int ID;
|
||||||
|
ID=(Pnt.y*Width)+Pnt.x;
|
||||||
|
|
||||||
|
return(ID);
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
|
@ -19,6 +19,9 @@ int LoadGLTexture(char *FileName, GLuint &Text);
|
||||||
void TNormalise(TVECTOR &V);
|
void TNormalise(TVECTOR &V);
|
||||||
TVECTOR TCrossProduct(TVECTOR const &V0,TVECTOR const &V1,const TVECTOR &V2 );
|
TVECTOR TCrossProduct(TVECTOR const &V0,TVECTOR const &V1,const TVECTOR &V2 );
|
||||||
|
|
||||||
|
CPoint IDToPoint(int ID,int Width);
|
||||||
|
int PointToID(CPoint &Pnt,int Width);
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Add table
Reference in a new issue