2000-11-07 22:15:35 +01:00
|
|
|
/******************/
|
|
|
|
/*** Layer Tile ***/
|
|
|
|
/******************/
|
|
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "gl3d.h"
|
|
|
|
#include <gl\gl.h>
|
|
|
|
#include <gl\glu.h>
|
|
|
|
#include <gl\glut.h>
|
|
|
|
#include "GLEnabledView.h"
|
|
|
|
|
2000-11-14 16:03:04 +01:00
|
|
|
#include "MapEdit.h"
|
2000-11-07 22:15:35 +01:00
|
|
|
#include "MapEditDoc.h"
|
|
|
|
#include "MapEditView.h"
|
2000-11-14 16:03:04 +01:00
|
|
|
#include "MainFrm.h"
|
2000-11-07 22:15:35 +01:00
|
|
|
|
|
|
|
#include "Core.h"
|
|
|
|
#include "Layer.h"
|
|
|
|
#include "LayerTile.h"
|
|
|
|
#include "Utils.h"
|
2000-11-24 23:34:20 +01:00
|
|
|
#include "Export.h"
|
2000-11-07 22:15:35 +01:00
|
|
|
|
2000-11-28 22:16:00 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
char *CLayerTile::LayerName[]=
|
|
|
|
{
|
|
|
|
"Back",
|
|
|
|
"Mid",
|
|
|
|
"Action",
|
|
|
|
"Fore",
|
|
|
|
};
|
2000-11-07 22:15:35 +01:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
// New Layer
|
2000-11-28 22:16:00 +01:00
|
|
|
CLayerTile::CLayerTile(int _SubType,int Width,int Height,float Scale,BOOL Is3d,BOOL Resizable)
|
2000-11-07 22:15:35 +01:00
|
|
|
{
|
2000-11-28 22:16:00 +01:00
|
|
|
// SetName(_Name);
|
|
|
|
SubType=_SubType;
|
|
|
|
ScaleFactor=Scale;
|
2000-11-20 17:21:43 +01:00
|
|
|
ResizeFlag=Resizable;
|
2000-11-07 22:15:35 +01:00
|
|
|
Render3dFlag=Is3d;
|
2000-11-21 22:27:55 +01:00
|
|
|
VisibleFlag=TRUE;
|
2000-11-15 22:22:40 +01:00
|
|
|
Mode=MouseModePaint;
|
2000-11-20 17:21:43 +01:00
|
|
|
|
2000-11-28 15:34:42 +01:00
|
|
|
if (ResizeFlag)
|
|
|
|
{
|
2000-11-28 22:16:00 +01:00
|
|
|
Map.SetSize(Width/ScaleFactor,Height/ScaleFactor,TRUE);
|
2000-11-28 15:34:42 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Map.SetSize(Width,Height,TRUE);
|
|
|
|
}
|
2000-11-07 22:15:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
// Load Layer
|
2000-11-20 21:33:42 +01:00
|
|
|
CLayerTile::CLayerTile(CFile *File,int Version)
|
2000-11-07 22:15:35 +01:00
|
|
|
{
|
2000-11-20 21:33:42 +01:00
|
|
|
Load(File,Version);
|
2000-11-07 22:15:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
CLayerTile::~CLayerTile()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-11-20 21:33:42 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
void CLayerTile::Load(CFile *File,float Version)
|
|
|
|
{
|
|
|
|
// Version 1
|
2000-11-28 22:16:00 +01:00
|
|
|
if (Version>=1.0)
|
|
|
|
{
|
|
|
|
File->Read(&Render3dFlag,sizeof(BOOL));
|
|
|
|
File->Read(&ScaleFactor,sizeof(float));
|
|
|
|
File->Read(&ResizeFlag,sizeof(BOOL));
|
|
|
|
File->Read(&VisibleFlag,sizeof(BOOL));
|
|
|
|
File->Read(&Mode,sizeof(MouseMode));
|
|
|
|
File->Read(&SubType,sizeof(int));
|
|
|
|
Map.Load(File,Version);
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE1("%s\t",GetName());
|
|
|
|
TRACE1("Scl:%g\t",ScaleFactor);
|
2000-11-28 00:07:07 +01:00
|
|
|
TRACE1("%i\n",VisibleFlag);
|
|
|
|
|
|
|
|
|
2000-11-20 21:33:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CLayerTile::Save(CFile *File)
|
|
|
|
{
|
|
|
|
// Always Save current version
|
|
|
|
|
|
|
|
File->Write(&Render3dFlag,sizeof(BOOL));
|
2000-11-28 22:16:00 +01:00
|
|
|
File->Write(&ScaleFactor,sizeof(float));
|
2000-11-20 21:33:42 +01:00
|
|
|
File->Write(&ResizeFlag,sizeof(BOOL));
|
2000-11-21 22:27:55 +01:00
|
|
|
File->Write(&VisibleFlag,sizeof(BOOL));
|
2000-11-20 21:33:42 +01:00
|
|
|
File->Write(&Mode,sizeof(MouseMode));
|
2000-11-28 22:16:00 +01:00
|
|
|
File->Write(&SubType,sizeof(SubType));
|
2000-11-20 21:33:42 +01:00
|
|
|
Map.Save(File);
|
|
|
|
}
|
|
|
|
|
2000-11-20 17:21:43 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
void CLayerTile::Resize(int Width,int Height)
|
|
|
|
{
|
|
|
|
if (!ResizeFlag) return; // Its a fixed size, so DONT DO IT!
|
|
|
|
|
2000-11-28 22:16:00 +01:00
|
|
|
Map.Resize(Width/ScaleFactor,Height/ScaleFactor);
|
2000-11-20 17:21:43 +01:00
|
|
|
}
|
|
|
|
|
2000-11-07 22:15:35 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
2000-11-14 16:03:04 +01:00
|
|
|
void CLayerTile::Render(CCore *Core,Vec &CamPos,BOOL Is3d)
|
2000-11-07 22:15:35 +01:00
|
|
|
{
|
2000-11-28 22:16:00 +01:00
|
|
|
Vec ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
2000-11-17 22:36:13 +01:00
|
|
|
|
|
|
|
if (Is3d && Render3dFlag)
|
|
|
|
{
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
2000-11-22 23:08:47 +01:00
|
|
|
Render(Core,ThisCam,Map,TRUE);
|
2000-11-17 22:36:13 +01:00
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-11-22 23:08:47 +01:00
|
|
|
Render(Core,ThisCam,Map,FALSE);
|
2000-11-17 22:36:13 +01:00
|
|
|
}
|
2000-11-07 22:15:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2000-11-17 22:36:13 +01:00
|
|
|
void CLayerTile::RenderCursorPaint(CCore *Core,Vec &CamPos,BOOL Is3d)
|
|
|
|
{
|
|
|
|
CTileBank &TileBank=Core->GetTileBank();
|
2000-11-28 00:07:07 +01:00
|
|
|
//Vec ThisCam=CamPos;
|
2000-11-28 22:16:00 +01:00
|
|
|
Vec ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
2000-11-17 22:36:13 +01:00
|
|
|
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);
|
2000-11-22 23:08:47 +01:00
|
|
|
Render(Core,ThisCam,Brush,TRUE,0.5);
|
2000-11-17 22:36:13 +01:00
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-11-22 23:08:47 +01:00
|
|
|
Render(Core,ThisCam,Brush,FALSE,0.5);
|
2000-11-17 22:36:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2000-11-22 23:08:47 +01:00
|
|
|
void CLayerTile::Render(CCore *Core,Vec &CamPos,CMap &ThisMap,BOOL Render3d,float Alpha)
|
2000-11-07 22:15:35 +01:00
|
|
|
{
|
2000-11-17 22:36:13 +01:00
|
|
|
int Width=ThisMap.GetWidth();
|
|
|
|
int Height=ThisMap.GetHeight();
|
|
|
|
|
|
|
|
if (Alpha<1)
|
|
|
|
{
|
|
|
|
glColor4f(0.5,0.5,0.5,Alpha);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
glColor3f(0.5,0.5,0.5);
|
|
|
|
}
|
|
|
|
|
2000-11-07 22:15:35 +01:00
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
2000-11-17 22:36:13 +01:00
|
|
|
for (int YLoop=0; YLoop<Height; YLoop++)
|
2000-11-07 22:15:35 +01:00
|
|
|
{
|
2000-11-17 22:36:13 +01:00
|
|
|
for (int XLoop=0; XLoop<Width; XLoop++)
|
2000-11-07 22:15:35 +01:00
|
|
|
{
|
2000-11-17 22:36:13 +01:00
|
|
|
sMapElem &ThisElem=ThisMap.Get(XLoop,YLoop);
|
2000-11-29 18:07:57 +01:00
|
|
|
if (ThisElem.Tile && Core->IsTileValid(ThisElem.Set,ThisElem.Tile))
|
2000-11-15 22:22:40 +01:00
|
|
|
{ // Render Non Zero Tiles
|
|
|
|
CTile &ThisTile=Core->GetTile(ThisElem.Set,ThisElem.Tile);
|
|
|
|
|
|
|
|
glLoadIdentity(); // Slow way, but good to go for the mo
|
2000-11-17 22:36:13 +01:00
|
|
|
glTranslatef(CamPos.x+XLoop,CamPos.y-YLoop,CamPos.z);
|
2000-11-22 23:08:47 +01:00
|
|
|
ThisTile.Render(ThisElem.Flags,Render3d);
|
2000-11-15 22:22:40 +01:00
|
|
|
}
|
2000-11-07 22:15:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2000-11-28 00:07:07 +01:00
|
|
|
void CLayerTile::RenderGrid(CCore *Core,Vec &CamPos,BOOL Active)
|
2000-11-07 22:15:35 +01:00
|
|
|
{
|
2000-11-17 22:36:13 +01:00
|
|
|
int Width=Map.GetWidth();
|
|
|
|
int Height=Map.GetHeight();
|
2000-11-28 22:16:00 +01:00
|
|
|
Vec ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
2000-11-07 22:15:35 +01:00
|
|
|
float OverVal=0.5;
|
|
|
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity();
|
2000-11-28 00:07:07 +01:00
|
|
|
glTranslatef(ThisCam.x,ThisCam.y,ThisCam.z);
|
2000-11-07 22:15:35 +01:00
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
2000-11-24 23:34:20 +01:00
|
|
|
#ifdef UseLighting
|
2000-11-07 22:15:35 +01:00
|
|
|
glNormal3f( 1,1,1);
|
2000-11-24 23:34:20 +01:00
|
|
|
#endif
|
2000-11-28 00:07:07 +01:00
|
|
|
if (Active)
|
|
|
|
glColor3ub(255,255,255);
|
|
|
|
else
|
|
|
|
glColor3ub(127,127,127);
|
2000-11-07 22:15:35 +01:00
|
|
|
|
2000-11-17 22:36:13 +01:00
|
|
|
for (int YLoop=0; YLoop<Height+1; YLoop++)
|
2000-11-07 22:15:35 +01:00
|
|
|
{
|
|
|
|
glVertex3f( 0-OverVal, -YLoop+1, 0);
|
2000-11-17 22:36:13 +01:00
|
|
|
glVertex3f( Width+OverVal, -YLoop+1, 0);
|
2000-11-07 22:15:35 +01:00
|
|
|
}
|
|
|
|
|
2000-11-17 22:36:13 +01:00
|
|
|
for (int XLoop=0; XLoop<Width+1; XLoop++)
|
2000-11-07 22:15:35 +01:00
|
|
|
{
|
|
|
|
glVertex3f( XLoop, 0+1+OverVal, 0);
|
2000-11-17 22:36:13 +01:00
|
|
|
glVertex3f( XLoop, -Height+1-OverVal, 0);
|
2000-11-07 22:15:35 +01:00
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2000-11-14 16:03:04 +01:00
|
|
|
void CLayerTile::FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos)
|
2000-11-07 22:15:35 +01:00
|
|
|
{
|
|
|
|
GLint Viewport[4];
|
|
|
|
GLuint SelectBuffer[SELECT_BUFFER_SIZE];
|
|
|
|
int HitCount;
|
|
|
|
int TileID=0;
|
|
|
|
CPoint &CursorPos=Core->GetCursorPos();
|
|
|
|
|
2000-11-17 22:36:13 +01:00
|
|
|
int Width=Map.GetWidth();
|
|
|
|
int Height=Map.GetHeight();
|
2000-11-28 22:16:00 +01:00
|
|
|
Vec ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
2000-11-08 20:53:57 +01:00
|
|
|
|
2000-11-07 22:15:35 +01:00
|
|
|
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);
|
|
|
|
View->SetupPersMatrix();
|
|
|
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity();
|
2000-11-28 00:07:07 +01:00
|
|
|
glTranslatef(ThisCam.x,ThisCam.y,ThisCam.z);
|
2000-11-07 22:15:35 +01:00
|
|
|
|
2000-11-17 22:36:13 +01:00
|
|
|
for (int YLoop=0; YLoop<Height; YLoop++)
|
2000-11-07 22:15:35 +01:00
|
|
|
{
|
2000-11-17 22:36:13 +01:00
|
|
|
for (int XLoop=0; XLoop<Width; XLoop++)
|
2000-11-07 22:15:35 +01:00
|
|
|
{
|
|
|
|
glLoadName (TileID);
|
|
|
|
glBegin (GL_QUADS);
|
|
|
|
BuildGLQuad(XLoop,XLoop+1,-YLoop,-YLoop+1,0);
|
|
|
|
glEnd();
|
|
|
|
TileID++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HitCount= glRenderMode (GL_RENDER);
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glPopMatrix();
|
|
|
|
CursorPos.x=CursorPos.y=-1;
|
|
|
|
|
|
|
|
// Process hits
|
|
|
|
|
|
|
|
GLuint *HitPtr=SelectBuffer;
|
|
|
|
|
|
|
|
if (HitCount) // Just take 1st
|
|
|
|
|
|
|
|
{
|
|
|
|
int HitID=HitPtr[3];
|
2000-11-17 22:36:13 +01:00
|
|
|
CursorPos=IDToPoint(HitID,Width);
|
2000-11-07 22:15:35 +01:00
|
|
|
}
|
|
|
|
glMatrixMode(GL_MODELVIEW); // <-- Prevent arse GL assert
|
|
|
|
|
|
|
|
}
|
2000-11-14 16:03:04 +01:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*** Gui *********************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CLayerTile::InitGUI(CCore *Core)
|
|
|
|
{
|
|
|
|
CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
|
|
|
|
CMultiBar *ParamBar=Frm->GetParamBar();
|
|
|
|
|
2000-11-28 15:34:42 +01:00
|
|
|
ParamBar->Add(Frm->GetLayerTileGUI(),IDD_LAYERTILE_GUI,TRUE);
|
2000-11-14 16:03:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CLayerTile::UpdateGUI(CCore *Core)
|
|
|
|
{
|
2000-11-28 15:34:42 +01:00
|
|
|
CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
|
|
|
|
CLayerTileGUI *Dlg=(CLayerTileGUI *)Frm->GetDialog(IDD_LAYERTILE_GUI);
|
2000-11-17 00:08:54 +01:00
|
|
|
|
2000-11-28 15:34:42 +01:00
|
|
|
if (Dlg)
|
2000-11-17 00:08:54 +01:00
|
|
|
{
|
2000-11-28 15:34:42 +01:00
|
|
|
Dlg->ResetButtons();
|
2000-11-17 00:08:54 +01:00
|
|
|
switch(Mode)
|
|
|
|
{
|
|
|
|
case MouseModePaint:
|
2000-11-28 15:34:42 +01:00
|
|
|
Dlg->SetButtonState(CLayerTileGUI::PAINT,TRUE);
|
2000-11-17 00:08:54 +01:00
|
|
|
break;
|
|
|
|
case MouseModeSelect:
|
2000-11-28 15:34:42 +01:00
|
|
|
Dlg->SetButtonState(CLayerTileGUI::SELECT,TRUE);
|
2000-11-17 00:08:54 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-11-28 15:34:42 +01:00
|
|
|
Core->UpdateTileViewGUI();
|
2000-11-15 22:22:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*** Functions ***************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
BOOL CLayerTile::SetMode(int NewMode)
|
|
|
|
{
|
|
|
|
BOOL Ret=FALSE;
|
2000-11-17 00:08:54 +01:00
|
|
|
|
2000-11-15 22:22:40 +01:00
|
|
|
// Clean up last mode
|
2000-11-17 00:08:54 +01:00
|
|
|
Ret|=ExitMode();
|
|
|
|
Mode=(MouseMode)NewMode;
|
|
|
|
Ret|=InitMode();
|
|
|
|
return(Ret);
|
2000-11-15 22:22:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
BOOL CLayerTile::InitMode()
|
|
|
|
{
|
2000-11-17 00:08:54 +01:00
|
|
|
switch(Mode)
|
|
|
|
{
|
|
|
|
case MouseModePaint:
|
|
|
|
break;
|
|
|
|
case MouseModeSelect:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return(FALSE);
|
2000-11-15 22:22:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
BOOL CLayerTile::ExitMode()
|
|
|
|
{
|
2000-11-17 00:08:54 +01:00
|
|
|
switch(Mode)
|
|
|
|
{
|
|
|
|
case MouseModePaint:
|
|
|
|
break;
|
|
|
|
case MouseModeSelect:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
2000-11-15 22:22:40 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
BOOL CLayerTile::LButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos,BOOL DownFlag)
|
|
|
|
{
|
|
|
|
BOOL Ret=FALSE;
|
|
|
|
CTileBank &TileBank=Core->GetTileBank();
|
|
|
|
|
2000-11-17 00:08:54 +01:00
|
|
|
switch(Mode)
|
|
|
|
{
|
|
|
|
case MouseModePaint:
|
|
|
|
if (DownFlag)
|
2000-11-17 22:36:13 +01:00
|
|
|
Ret=Paint(TileBank.GetLBrush(),CursorPos);
|
2000-11-17 00:08:54 +01:00
|
|
|
break;
|
|
|
|
case MouseModeSelect:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return(Ret);
|
2000-11-15 22:22:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
BOOL CLayerTile::RButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos,BOOL DownFlag)
|
|
|
|
{
|
|
|
|
BOOL Ret=FALSE;
|
|
|
|
CTileBank &TileBank=Core->GetTileBank();
|
|
|
|
|
2000-11-17 00:08:54 +01:00
|
|
|
switch(Mode)
|
|
|
|
{
|
|
|
|
case MouseModePaint:
|
|
|
|
if (DownFlag)
|
2000-11-17 22:36:13 +01:00
|
|
|
Ret=Paint(TileBank.GetRBrush(),CursorPos);
|
2000-11-17 00:08:54 +01:00
|
|
|
break;
|
|
|
|
case MouseModeSelect:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return(Ret);
|
2000-11-15 22:22:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
BOOL CLayerTile::MouseMove(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos)
|
|
|
|
{
|
|
|
|
BOOL Ret=FALSE;
|
|
|
|
CTileBank &TileBank=Core->GetTileBank();
|
|
|
|
|
2000-11-17 00:08:54 +01:00
|
|
|
switch(Mode)
|
|
|
|
{
|
|
|
|
case MouseModePaint:
|
|
|
|
if (nFlags & MK_LBUTTON)
|
2000-11-17 22:36:13 +01:00
|
|
|
Ret=Paint(TileBank.GetLBrush(),CursorPos);
|
2000-11-17 00:08:54 +01:00
|
|
|
else
|
|
|
|
if (nFlags & MK_RBUTTON)
|
2000-11-17 22:36:13 +01:00
|
|
|
Ret=Paint(TileBank.GetRBrush(),CursorPos);
|
2000-11-17 00:08:54 +01:00
|
|
|
break;
|
|
|
|
case MouseModeSelect:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return(Ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2000-11-17 22:36:13 +01:00
|
|
|
void CLayerTile::RenderCursor(CCore *Core,Vec &CamPos,BOOL Is3d)
|
2000-11-17 00:08:54 +01:00
|
|
|
{
|
2000-11-17 22:36:13 +01:00
|
|
|
switch(Mode)
|
|
|
|
{
|
|
|
|
case MouseModePaint:
|
|
|
|
RenderCursorPaint(Core,CamPos,Is3d);
|
|
|
|
break;
|
|
|
|
case MouseModeSelect:
|
|
|
|
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);
|
|
|
|
|
2000-11-17 00:08:54 +01:00
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2000-11-17 22:36:13 +01:00
|
|
|
BOOL CLayerTile::MirrorY(CCore *Core)
|
2000-11-17 00:08:54 +01:00
|
|
|
{
|
2000-11-17 22:36:13 +01:00
|
|
|
CTileBank &TileBank=Core->GetTileBank();
|
|
|
|
CMap &LBrush=TileBank.GetLBrush();
|
|
|
|
CMap &RBrush=TileBank.GetRBrush();
|
|
|
|
|
|
|
|
LBrush.MirrorY(MouseFlagMirrorY);
|
|
|
|
RBrush.MirrorY(MouseFlagMirrorY);
|
|
|
|
|
2000-11-17 00:08:54 +01:00
|
|
|
return(TRUE);
|
2000-11-15 22:22:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2000-11-17 00:08:54 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
2000-11-17 22:36:13 +01:00
|
|
|
BOOL CLayerTile::Paint(CMap &Blk,CPoint &CursorPos)
|
2000-11-15 22:22:40 +01:00
|
|
|
{
|
|
|
|
if (CursorPos.y==-1 || CursorPos.y==-1) return(FALSE); // Off Map?
|
2000-11-17 22:36:13 +01:00
|
|
|
if (!Blk.IsValid()) return(FALSE); // Invalid tile?
|
|
|
|
|
|
|
|
Map.Set(CursorPos.x,CursorPos.y,Blk);
|
2000-11-15 22:22:40 +01:00
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
2000-11-24 23:34:20 +01:00
|
|
|
/*****************************************************************************/
|
2000-11-29 18:07:57 +01:00
|
|
|
void CLayerTile::Export(CCore *Core,CExport &Exp)
|
2000-11-24 23:34:20 +01:00
|
|
|
{
|
2000-11-29 18:07:57 +01:00
|
|
|
Exp.ExportLayerTile(Core,GetName(),Map);
|
2000-11-24 23:34:20 +01:00
|
|
|
}
|