This commit is contained in:
parent
86e55aae82
commit
803f94e415
24 changed files with 492 additions and 254 deletions
|
@ -4,11 +4,9 @@
|
|||
|
||||
|
||||
#include "stdafx.h"
|
||||
//#include "gl3d.h"
|
||||
#include <Vector3.h>
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include "GLEnabledView.h"
|
||||
|
||||
#include "MapEdit.h"
|
||||
|
@ -78,16 +76,9 @@ int Width,Height;
|
|||
Layer.push_back(new CLayerTile( LAYERTILE_ACTION, Width, Height, 1.0f, TRUE, TRUE));
|
||||
if (Dlg.m_Fore) Layer.push_back(new CLayerTile( LAYERTILE_FORE, Width, Height, 0.5f, FALSE, TRUE));
|
||||
|
||||
Vector3 CamOfs;
|
||||
CamOfs.Zero();
|
||||
CamOfs.x=-15;
|
||||
CamOfs.y=+10;
|
||||
|
||||
ActiveLayer=FindActionLayer();
|
||||
MapCam.Zero();
|
||||
MapCamOfs=CamOfs;
|
||||
TileCam.Zero();
|
||||
TileCamOfs=CamOfs;
|
||||
TileViewFlag=FALSE;
|
||||
GridFlag=TRUE;
|
||||
Is3dFlag=TRUE;
|
||||
|
@ -151,6 +142,7 @@ int MapHeight=Layer[FindActionLayer()]->GetHeight();
|
|||
}
|
||||
|
||||
Init();
|
||||
// MapCam.Zero();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -185,7 +177,7 @@ int LayerCount=Layer.size();
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
bool CCore::Question(char *Txt)
|
||||
BOOL CCore::Question(char *Txt)
|
||||
{
|
||||
return(theApp.GetCurrent()->Question(Txt));
|
||||
}
|
||||
|
@ -321,9 +313,9 @@ Vector3 Ofs;
|
|||
void CCore::MouseWheel(CMapEditView *View,UINT nFlags, short zDelta, CPoint &pt)
|
||||
{
|
||||
if (zDelta>0)
|
||||
Zoom(View,+1.0f);
|
||||
Zoom(View,+0.1f);
|
||||
else
|
||||
Zoom(View,-1.0f);
|
||||
Zoom(View,-0.1f);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -345,8 +337,8 @@ Vector3 &ThisCam=GetCam();
|
|||
RECT ThisRect;
|
||||
|
||||
View->GetWindowRect(&ThisRect);
|
||||
XS=ThisCam.z*4;
|
||||
YS=ThisCam.z*4;
|
||||
XS=ThisCam.z*16;
|
||||
YS=ThisCam.z*16;
|
||||
XS/=((ThisRect.right-ThisRect.left));
|
||||
YS/=((ThisRect.bottom-ThisRect.top));
|
||||
|
||||
|
@ -355,18 +347,8 @@ Vector3 &ThisCam=GetCam();
|
|||
|
||||
Ofs.x*=XS;
|
||||
Ofs.y*=YS;
|
||||
if (nFlags & MK_CONTROL)
|
||||
{ // Move Ofs
|
||||
Vector3 &CamOfs=GetCamOfs();
|
||||
Ofs.y=-Ofs.y;
|
||||
CamOfs+=Ofs;
|
||||
UpdateView(View);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateView(View,Ofs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TileViewFlag)
|
||||
|
@ -432,7 +414,7 @@ CMultiBar *ParamBar=Frm->GetParamBar();
|
|||
CLayerList *List=(CLayerList*)Frm->GetDialog(IDD_LAYER_LIST_DIALOG);
|
||||
|
||||
// If toggling layer, dont change the layer
|
||||
if (List->ListBox.GetCheck(NewLayer)!=Layer[NewLayer]->IsVisible())
|
||||
if ((int)List->ListBox.GetCheck(NewLayer)!=(int)Layer[NewLayer]->IsVisible())
|
||||
{
|
||||
Layer[NewLayer]->SetVisible(List->ListBox.GetCheck(NewLayer));
|
||||
List->ListBox.SetCurSel(ActiveLayer);
|
||||
|
@ -579,13 +561,31 @@ Vector3 &CCore::GetCam()
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
Vector3 &CCore::GetCamOfs()
|
||||
void CCore::SetScale()
|
||||
{
|
||||
if (TileViewFlag)
|
||||
return(TileCamOfs);
|
||||
else
|
||||
return(MapCamOfs);
|
||||
float XS=GetZoomW();
|
||||
float YS=GetZoomH();
|
||||
float ZS=XS/YS;
|
||||
|
||||
ScaleVector.x=1.0f/XS;
|
||||
ScaleVector.y=1.0f/XS;
|
||||
ScaleVector.z=1.0f/XS;//4.0f;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
float CCore::GetZoomW()
|
||||
{
|
||||
Vector3 &ThisCam=GetCam();
|
||||
|
||||
return((float)SCREEN_MAP_WIDTH/ThisCam.z);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
float CCore::GetZoomH()
|
||||
{
|
||||
Vector3 &ThisCam=GetCam();
|
||||
|
||||
return((float)SCREEN_MAP_HEIGHT/ThisCam.z);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -608,6 +608,7 @@ void CCore::UpdateAll(CMapEditView *View)
|
|||
/*****************************************************************************/
|
||||
void CCore::UpdateView(CMapEditView *View)
|
||||
{
|
||||
SetScale();
|
||||
if (View) View->Invalidate();
|
||||
}
|
||||
|
||||
|
@ -617,9 +618,13 @@ void CCore::UpdateView(CMapEditView *View,Vector3 &Ofs)
|
|||
Vector3 &ThisCam=GetCam();
|
||||
|
||||
ThisCam.x+=Ofs.x;
|
||||
ThisCam.y-=Ofs.y;
|
||||
ThisCam.z+=Ofs.z;
|
||||
if (ThisCam.z>-1) ThisCam.z=-1;
|
||||
ThisCam.y+=Ofs.y;
|
||||
ThisCam.z-=Ofs.z;
|
||||
if (ThisCam.x<0) ThisCam.x=0;
|
||||
if (ThisCam.y<0) ThisCam.y=0;
|
||||
if (ThisCam.z<0.1) ThisCam.z=0.1f;
|
||||
TRACE1("ZoomVal %f\n",ThisCam.z);
|
||||
|
||||
UpdateView(View);
|
||||
}
|
||||
|
||||
|
@ -643,7 +648,6 @@ void CCore::Toggle2d3d(CMapEditView *View)
|
|||
{
|
||||
Is3dFlag=!Is3dFlag;
|
||||
UpdateView(View);
|
||||
// ExportPSX("c:/temp/test.pme");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -672,11 +676,10 @@ int Idx=FindLayer(LAYER_TYPE_TILE,LAYERTILE_ACTION);
|
|||
|
||||
Vector3 CCore::OffsetCam(Vector3 &Cam,float DivVal)
|
||||
{
|
||||
Vector3 ThisCam;
|
||||
Vector3 ThisCam=Cam;
|
||||
|
||||
ThisCam=Cam/DivVal;
|
||||
ThisCam.z=Cam.z;
|
||||
ThisCam+=GetCamOfs();
|
||||
|
||||
return(ThisCam);
|
||||
}
|
||||
|
@ -715,8 +718,6 @@ CExportPSX Exp(ExportName,LayerCount);
|
|||
Layer[i]->Export(this,Exp);
|
||||
}
|
||||
|
||||
// Layer[FindActionLayer()]->Export(this,Exp);
|
||||
|
||||
Exp.ExportTiles(this);
|
||||
Exp.ExportTexList(this);
|
||||
|
||||
|
@ -734,3 +735,13 @@ GString Path=FullPath.Dir();
|
|||
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::CopySelection()
|
||||
{
|
||||
Layer[ActiveLayer]->CopySelection(this);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::PasteSelection()
|
||||
{
|
||||
Layer[ActiveLayer]->PasteSelection(this);
|
||||
}
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
#define __CORE_HEADER__
|
||||
|
||||
#include <Vector>
|
||||
//#include "gl3d.h"
|
||||
#include <Vector3.h>
|
||||
#include "Layer.h"
|
||||
//#include "LayerTile.h"
|
||||
|
||||
#include "TexCache.h"
|
||||
#include "TileSet.h"
|
||||
|
||||
const float FileVersion=1.01f;
|
||||
|
||||
#define SCREEN_MAP_WIDTH 30
|
||||
#define SCREEN_MAP_HEIGHT 20
|
||||
|
||||
/*****************************************************************************/
|
||||
class CMapEditView;
|
||||
|
@ -29,7 +29,7 @@ public:
|
|||
BOOL New();
|
||||
void Load(CFile *File);
|
||||
void Save(CFile *File);
|
||||
bool Question(char *Txt);
|
||||
BOOL Question(char *Txt);
|
||||
void Render(CMapEditView *View,BOOL ForceRender=FALSE);
|
||||
void RenderLayers(CMapEditView *View);
|
||||
void RenderTileView(CMapEditView *View);
|
||||
|
@ -85,7 +85,6 @@ public:
|
|||
void UpdateView(CMapEditView *View,Vector3 &Ofs);
|
||||
|
||||
Vector3 &GetCam();
|
||||
Vector3 &GetCamOfs();
|
||||
Vector3 OffsetCam(Vector3 &Cam,float DivVal);
|
||||
void SetCursorPos(CPoint &Pos) {CursorPos=Pos;}
|
||||
CPoint &GetCursorPos() {return(CursorPos);}
|
||||
|
@ -98,12 +97,21 @@ public:
|
|||
int FindLayer(int Type,int SubType=-1);
|
||||
int FindActionLayer();
|
||||
|
||||
void SetScale();
|
||||
Vector3 &GetScaleVector() {return(ScaleVector);}
|
||||
float GetZoomW();
|
||||
float GetZoomH();
|
||||
|
||||
void CopySelection();
|
||||
void PasteSelection();
|
||||
|
||||
GString GetCurrentPath();
|
||||
private:
|
||||
CPoint CurrentMousePos,LastMousePos;
|
||||
CPoint CursorPos,LastCursorPos;
|
||||
Vector3 MapCam,TileCam;
|
||||
Vector3 MapCamOfs,TileCamOfs;
|
||||
Vector3 ScaleVector;
|
||||
|
||||
std::vector<CLayer*> Layer;
|
||||
int ActiveLayer;
|
||||
|
|
|
@ -65,7 +65,7 @@ v 1.4: introduced GL/GLU error checking in OnDraw message handler after scene dr
|
|||
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
//#include <gl\glut.h>
|
||||
#include "GLEnabledView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
|
|
@ -4,15 +4,10 @@
|
|||
|
||||
|
||||
#include "stdafx.h"
|
||||
//#include "gl3d.h"
|
||||
#include <Vector3.h>
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
//#include "GLEnabledView.h"
|
||||
|
||||
//#include "MapEditDoc.h"
|
||||
//#include "MapEditView.h"
|
||||
|
||||
#include "Core.h"
|
||||
#include "Layer.h"
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#define __LAYER_HEADER__
|
||||
|
||||
#include <Vector>
|
||||
//#include "gl3d.h"
|
||||
#include <Vector3.h>
|
||||
#include "Map.h"
|
||||
#include "Select.h"
|
||||
#include "LayerDef.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -43,6 +43,8 @@ virtual float GetScaleFactor() {return(ScaleFactor);}
|
|||
|
||||
virtual void Render(CCore *Core,Vector3 &CamPos,BOOL Is3d)=0;
|
||||
virtual void RenderGrid(CCore *Core,Vector3 &CamPos,BOOL Active)=0;
|
||||
virtual void RenderSelection(CCore *Core,Vector3 &ThisCam)=0;
|
||||
|
||||
|
||||
virtual void FindCursorPos(CCore *Core,CMapEditView *View,Vector3 &CamPos,CPoint &MousePos)=0;
|
||||
virtual void RenderCursor(CCore *Core,Vector3 &CamPos,BOOL Is3d)=0;
|
||||
|
@ -68,8 +70,11 @@ 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 MouseMove(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos)=0;
|
||||
|
||||
virtual BOOL MirrorX(CCore *Core){return(FALSE);};
|
||||
virtual BOOL MirrorY(CCore *Core){return(FALSE);};
|
||||
virtual BOOL MirrorX(CCore *Core){return(false);};
|
||||
virtual BOOL MirrorY(CCore *Core){return(false);};
|
||||
|
||||
virtual BOOL CopySelection(CCore *Core) {return(false);}
|
||||
virtual BOOL PasteSelection(CCore *Core) {return(false);}
|
||||
|
||||
|
||||
virtual void DeleteSet(int Set){};
|
||||
|
@ -80,7 +85,7 @@ protected:
|
|||
float ScaleFactor;
|
||||
BOOL ResizeFlag;
|
||||
BOOL VisibleFlag;
|
||||
|
||||
CSelect Selection;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -4,11 +4,9 @@
|
|||
|
||||
|
||||
#include "stdafx.h"
|
||||
//#include "gl3d.h"
|
||||
#include <Vector3.h>
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include "GLEnabledView.h"
|
||||
|
||||
#include "MapEdit.h"
|
||||
|
@ -20,6 +18,7 @@
|
|||
#include "Layer.h"
|
||||
#include "LayerTile.h"
|
||||
#include "Utils.h"
|
||||
#include "Select.h"
|
||||
#include "Export.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -37,7 +36,6 @@ char *CLayerTile::LayerName[]=
|
|||
// New Layer
|
||||
CLayerTile::CLayerTile(int _SubType,int Width,int Height,float Scale,BOOL Is3d,BOOL Resizable)
|
||||
{
|
||||
// SetName(_Name);
|
||||
SubType=_SubType;
|
||||
ScaleFactor=Scale;
|
||||
ResizeFlag=Resizable;
|
||||
|
@ -87,8 +85,6 @@ void CLayerTile::Load(CFile *File,float Version)
|
|||
TRACE1("%s\t",GetName());
|
||||
TRACE1("Scl:%g\t",ScaleFactor);
|
||||
TRACE1("%i\n",VisibleFlag);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -164,8 +160,8 @@ CMap &Brush=TileBank.GetActiveBrush();
|
|||
|
||||
if (!Brush.IsValid()) return;
|
||||
|
||||
if (CursPos.x==-1 || CursPos.y==-1) return;
|
||||
ThisCam.x+=CursPos.x;
|
||||
if (CursPos.x<0 || CursPos.y<0) return;
|
||||
ThisCam.x-=CursPos.x;
|
||||
ThisCam.y-=CursPos.y;
|
||||
|
||||
if (Is3d && Render3dFlag)
|
||||
|
@ -181,86 +177,136 @@ CMap &Brush=TileBank.GetActiveBrush();
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerTile::Render(CCore *Core,Vector3 &CamPos,CMap &ThisMap,BOOL Render3d,float Alpha)
|
||||
void CLayerTile::Render(CCore *Core,Vector3 &ThisCam,CMap &ThisMap,BOOL Render3d,float Alpha)
|
||||
{
|
||||
int Width=ThisMap.GetWidth();
|
||||
int Height=ThisMap.GetHeight();
|
||||
|
||||
if (Alpha<1)
|
||||
{
|
||||
glColor4f(1,1,1,Alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
glColor3f(1,1,1);
|
||||
}
|
||||
int MapWidth=ThisMap.GetWidth();
|
||||
int MapHeight=ThisMap.GetHeight();
|
||||
float ZoomW=Core->GetZoomW();
|
||||
float ZoomH=Core->GetZoomH();
|
||||
float ScrOfsX=(ZoomW/2);
|
||||
float ScrOfsY=(ZoomH/2);
|
||||
Vector3 &Scale=Core->GetScaleVector();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glScalef(Scale.x,Scale.y,Scale.z);
|
||||
glTranslatef(-ThisCam.x,ThisCam.y,0);
|
||||
glTranslatef(-ScrOfsX,ScrOfsY,0); // Bring to top left corner
|
||||
|
||||
for (int YLoop=0; YLoop<Height; YLoop++)
|
||||
glColor4f(1,1,1,Alpha);
|
||||
for (int YLoop=0; YLoop<MapHeight; YLoop++)
|
||||
{
|
||||
for (int XLoop=0; XLoop<Width; XLoop++)
|
||||
for (int XLoop=0; XLoop<MapWidth; XLoop++)
|
||||
{
|
||||
sMapElem &ThisElem=ThisMap.Get(XLoop,YLoop);
|
||||
if (ThisElem.Tile && Core->IsTileValid(ThisElem.Set,ThisElem.Tile))
|
||||
{ // Render Non Zero Tiles
|
||||
CTile &ThisTile=Core->GetTile(ThisElem.Set,ThisElem.Tile);
|
||||
|
||||
glLoadIdentity(); // Slow way, but good to go for the mo
|
||||
glTranslatef(CamPos.x+XLoop,CamPos.y-YLoop,CamPos.z);
|
||||
ThisTile.Render(ThisElem.Flags,Render3d);
|
||||
}
|
||||
glTranslatef(1.0f,0,0); // Next X
|
||||
}
|
||||
glTranslatef(-MapWidth,-1,0); // Next y, rewind to start X
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerTile::RenderSelection(CCore *Core,Vector3 &CamPos)
|
||||
{
|
||||
CRect Rect=Selection.GetRect();
|
||||
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
||||
float ZoomW=Core->GetZoomW();
|
||||
float ZoomH=Core->GetZoomH();
|
||||
float ScrOfsX=(ZoomW/2);
|
||||
float ScrOfsY=(ZoomH/2);
|
||||
Vector3 &Scale=Core->GetScaleVector();
|
||||
|
||||
if (!Selection.IsValid()) return;
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glScalef(Scale.x,Scale.y,Scale.z);
|
||||
glTranslatef(-ThisCam.x,ThisCam.y,0);
|
||||
glTranslatef(-ScrOfsX,ScrOfsY,0); // Bring to top left corner
|
||||
|
||||
glColor4f(1,0,1,0.5f);
|
||||
glBegin (GL_QUADS);
|
||||
float X0=Rect.left;
|
||||
float X1=Rect.right;
|
||||
float Y0=Rect.top-1;
|
||||
float Y1=Rect.bottom-1;
|
||||
glVertex3f( X0, -Y0, 0);
|
||||
glVertex3f( X1, -Y0, 0);
|
||||
glVertex3f( X1, -Y1, 0);
|
||||
glVertex3f( X0, -Y1, 0);
|
||||
glEnd();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerTile::RenderGrid(CCore *Core,Vector3 &CamPos,BOOL Active)
|
||||
{
|
||||
int Width=Map.GetWidth();
|
||||
int Height=Map.GetHeight();
|
||||
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
||||
float OverVal=0.5;
|
||||
int MapWidth=Map.GetWidth();
|
||||
int MapHeight=Map.GetHeight();
|
||||
float ZoomW=Core->GetZoomW();
|
||||
float ZoomH=Core->GetZoomH();
|
||||
float ScrOfsX=(ZoomW/2);
|
||||
float ScrOfsY=(ZoomH/2);
|
||||
Vector3 &Scale=Core->GetScaleVector();
|
||||
float Col;
|
||||
const float OverVal=0.1f;
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glTranslatef(ThisCam.x,ThisCam.y,ThisCam.z);
|
||||
glScalef(Scale.x,Scale.y,Scale.z);
|
||||
glTranslatef(-ThisCam.x,ThisCam.y,0);
|
||||
glTranslatef(-ScrOfsX,ScrOfsY,0); // Bring to top left corner
|
||||
|
||||
if (Active) Col=1; else Col=0.5f;
|
||||
|
||||
glBegin(GL_LINES);
|
||||
if (Active)
|
||||
glColor3f(1,1,1);
|
||||
else
|
||||
glColor3f(0.5,0.5,0.5);
|
||||
|
||||
for (int YLoop=0; YLoop<Height+1; YLoop++)
|
||||
glColor3f(Col,Col,Col);
|
||||
|
||||
for (int YLoop=0; YLoop<MapHeight+1; YLoop++)
|
||||
{
|
||||
glVertex3f( 0-OverVal, -YLoop+1, 0);
|
||||
glVertex3f( Width+OverVal, -YLoop+1, 0);
|
||||
glVertex3f( MapWidth+OverVal, -YLoop+1, 0);
|
||||
}
|
||||
|
||||
for (int XLoop=0; XLoop<Width+1; XLoop++)
|
||||
for (int XLoop=0; XLoop<MapWidth+1; XLoop++)
|
||||
{
|
||||
glVertex3f( XLoop, 0+1+OverVal, 0);
|
||||
glVertex3f( XLoop, -Height+1-OverVal, 0);
|
||||
glVertex3f( XLoop, -MapHeight+1-OverVal, 0);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerTile::FindCursorPos(CCore *Core,CMapEditView *View,Vector3 &CamPos,CPoint &MousePos)
|
||||
{
|
||||
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
||||
int MapWidth=Map.GetWidth();
|
||||
int MapHeight=Map.GetHeight();
|
||||
float ZoomW=Core->GetZoomW();
|
||||
float ZoomH=Core->GetZoomH();
|
||||
float ScrOfsX=(ZoomW/2);
|
||||
float ScrOfsY=(ZoomH/2);
|
||||
Vector3 &Scale=Core->GetScaleVector();
|
||||
|
||||
GLint Viewport[4];
|
||||
GLuint SelectBuffer[SELECT_BUFFER_SIZE];
|
||||
int HitCount;
|
||||
int TileID=0;
|
||||
CPoint &CursorPos=Core->GetCursorPos();
|
||||
|
||||
int Width=Map.GetWidth();
|
||||
int Height=Map.GetHeight();
|
||||
Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
||||
|
||||
glGetIntegerv(GL_VIEWPORT, Viewport);
|
||||
glSelectBuffer (SELECT_BUFFER_SIZE, SelectBuffer );
|
||||
glRenderMode (GL_SELECT);
|
||||
|
@ -275,12 +321,15 @@ Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
|||
View->SetupPersMatrix();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glTranslatef(ThisCam.x,ThisCam.y,ThisCam.z);
|
||||
glScalef(Scale.x,Scale.y,Scale.z);
|
||||
glTranslatef(-ThisCam.x,ThisCam.y,0);
|
||||
glTranslatef(-ScrOfsX,ScrOfsY,0); // Bring to top left corner
|
||||
|
||||
for (int YLoop=0; YLoop<Height; YLoop++)
|
||||
for (int YLoop=0; YLoop<MapHeight; YLoop++)
|
||||
{
|
||||
for (int XLoop=0; XLoop<Width; XLoop++)
|
||||
for (int XLoop=0; XLoop<MapWidth; XLoop++)
|
||||
{
|
||||
glLoadName (TileID);
|
||||
glBegin (GL_QUADS);
|
||||
|
@ -290,7 +339,8 @@ Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
|||
}
|
||||
}
|
||||
|
||||
HitCount= glRenderMode (GL_RENDER);
|
||||
TileID= glRenderMode (GL_RENDER);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
CursorPos.x=CursorPos.y=-1;
|
||||
|
@ -299,14 +349,12 @@ Vector3 ThisCam=Core->OffsetCam(CamPos,GetScaleFactor());
|
|||
|
||||
GLuint *HitPtr=SelectBuffer;
|
||||
|
||||
if (HitCount) // Just take 1st
|
||||
|
||||
if (TileID) // Just take 1st
|
||||
{
|
||||
int HitID=HitPtr[3];
|
||||
CursorPos=IDToPoint(HitID,Width);
|
||||
CursorPos=IDToPoint(HitID,MapWidth);
|
||||
}
|
||||
glMatrixMode(GL_MODELVIEW); // <-- Prevent arse GL assert
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -401,6 +449,11 @@ CTileBank &TileBank=Core->GetTileBank();
|
|||
Ret=Paint(TileBank.GetLBrush(),CursorPos);
|
||||
break;
|
||||
case MouseModeSelect:
|
||||
Ret=Selection.Handle(CursorPos,nFlags);
|
||||
if (Selection.HasSelection())
|
||||
{
|
||||
TRACE0("LMB Selection\n");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -421,6 +474,11 @@ CTileBank &TileBank=Core->GetTileBank();
|
|||
Ret=Paint(TileBank.GetRBrush(),CursorPos);
|
||||
break;
|
||||
case MouseModeSelect:
|
||||
Ret=Selection.Handle(CursorPos,nFlags);
|
||||
if (Selection.HasSelection())
|
||||
{
|
||||
TRACE0("RMB Selection\n");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -444,6 +502,7 @@ CTileBank &TileBank=Core->GetTileBank();
|
|||
Ret=Paint(TileBank.GetRBrush(),CursorPos);
|
||||
break;
|
||||
case MouseModeSelect:
|
||||
Ret=Selection.Handle(CursorPos,nFlags);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -460,6 +519,7 @@ void CLayerTile::RenderCursor(CCore *Core,Vector3 &CamPos,BOOL Is3d)
|
|||
RenderCursorPaint(Core,CamPos,Is3d);
|
||||
break;
|
||||
case MouseModeSelect:
|
||||
RenderSelection(Core,CamPos);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -469,12 +529,26 @@ void CLayerTile::RenderCursor(CCore *Core,Vector3 &CamPos,BOOL Is3d)
|
|||
/*****************************************************************************/
|
||||
BOOL CLayerTile::MirrorX(CCore *Core)
|
||||
{
|
||||
CTileBank &TileBank=Core->GetTileBank();
|
||||
CMap &LBrush=TileBank.GetLBrush();
|
||||
CMap &RBrush=TileBank.GetRBrush();
|
||||
switch(Mode)
|
||||
{
|
||||
case MouseModePaint:
|
||||
{
|
||||
CTileBank &TileBank=Core->GetTileBank();
|
||||
|
||||
LBrush.MirrorX(TILE_FLAG_MIRROR_X);
|
||||
RBrush.MirrorX(TILE_FLAG_MIRROR_X);
|
||||
TileBank.GetLBrush().MirrorX(TILE_FLAG_MIRROR_X);
|
||||
TileBank.GetRBrush().MirrorX(TILE_FLAG_MIRROR_X);
|
||||
}
|
||||
break;
|
||||
case MouseModeSelect:
|
||||
{
|
||||
if (!Selection.IsValid()) return(false); // No Selection
|
||||
CRect R=Selection.GetRect();
|
||||
Map.MirrorX(TILE_FLAG_MIRROR_X,&R);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
@ -482,16 +556,56 @@ CMap &RBrush=TileBank.GetRBrush();
|
|||
/*****************************************************************************/
|
||||
BOOL CLayerTile::MirrorY(CCore *Core)
|
||||
{
|
||||
CTileBank &TileBank=Core->GetTileBank();
|
||||
CMap &LBrush=TileBank.GetLBrush();
|
||||
CMap &RBrush=TileBank.GetRBrush();
|
||||
switch(Mode)
|
||||
{
|
||||
case MouseModePaint:
|
||||
{
|
||||
CTileBank &TileBank=Core->GetTileBank();
|
||||
|
||||
TileBank.GetLBrush().MirrorY(TILE_FLAG_MIRROR_Y);
|
||||
TileBank.GetRBrush().MirrorY(TILE_FLAG_MIRROR_Y);
|
||||
}
|
||||
break;
|
||||
case MouseModeSelect:
|
||||
{
|
||||
if (!Selection.IsValid()) return(false); // No Selection
|
||||
CRect R=Selection.GetRect();
|
||||
Map.MirrorY(TILE_FLAG_MIRROR_Y,&R);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
LBrush.MirrorY(TILE_FLAG_MIRROR_Y);
|
||||
RBrush.MirrorY(TILE_FLAG_MIRROR_Y);
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
BOOL CLayerTile::CopySelection(CCore *Core)
|
||||
{
|
||||
if (Mode!=MouseModeSelect) return(false); // Not in select mode
|
||||
if (!Selection.IsValid()) return(false); // No Selection
|
||||
|
||||
CTileBank &TileBank=Core->GetTileBank();
|
||||
CRect Rect=Selection.GetRect();
|
||||
|
||||
TileBank.GetLBrush().Set(Map,Rect.left,Rect.top,Rect.Width(),Rect.Height());
|
||||
|
||||
return(true);
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
BOOL CLayerTile::PasteSelection(CCore *Core)
|
||||
{
|
||||
if (Mode!=MouseModeSelect) return(false); // Not in select mode
|
||||
if (!Selection.IsValid()) return(false); // No Selection
|
||||
|
||||
TRACE0("Paste\n");
|
||||
return(true);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
|
||||
void Render(CCore *Core,Vector3 &CamPos,BOOL Is3d);
|
||||
void RenderGrid(CCore *Core,Vector3 &CamPos,BOOL Active);
|
||||
void RenderSelection(CCore *Core,Vector3 &ThisCam);
|
||||
|
||||
void FindCursorPos(CCore *Core,CMapEditView *View,Vector3 &CamPos,CPoint &MousePos);
|
||||
void RenderCursor(CCore *Core,Vector3 &CamPos,BOOL Is3d);
|
||||
|
@ -66,6 +67,9 @@ public:
|
|||
BOOL MirrorX(CCore *Core);
|
||||
BOOL MirrorY(CCore *Core);
|
||||
|
||||
BOOL CopySelection(CCore *Core);
|
||||
BOOL PasteSelection(CCore *Core);
|
||||
|
||||
void DeleteSet(int Set);
|
||||
void RemapSet(int OrigSet,int NewSet);
|
||||
|
||||
|
|
|
@ -4,11 +4,9 @@
|
|||
|
||||
|
||||
#include "stdafx.h"
|
||||
//#include "gl3d.h"
|
||||
#include <Vector3.h>
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
|
||||
#include "Map.h"
|
||||
|
||||
|
@ -180,43 +178,53 @@ void CMap::Set(CMap &Src,int StartX,int StartY,int Width,int Height,BOOL Force)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CMap::MirrorX(int Flag)
|
||||
void CMap::Set(CMap &Src,CRect &Rect,BOOL Force)
|
||||
{
|
||||
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,true);
|
||||
}
|
||||
}
|
||||
|
||||
Set(Src,Rect.left,Rect.top,Rect.Width(),Rect.Height(),Force);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CMap::MirrorY(int Flag)
|
||||
void CMap::MirrorX(int Flag,CRect *R)
|
||||
{
|
||||
CMap Old=*this;
|
||||
|
||||
int Width=GetWidth();
|
||||
int Height=GetHeight();
|
||||
if (!R)
|
||||
{ // No rect, use full
|
||||
R=new CRect(0,0,GetWidth(),GetHeight());
|
||||
}
|
||||
|
||||
for (int Y=0; Y<Height; Y++)
|
||||
int Ofs=(R->right+R->left)-1;
|
||||
for (int Y=R->top; Y<R->bottom; Y++)
|
||||
{
|
||||
for (int X=0; X<Width; X++)
|
||||
for (int X=R->left; X<R->right; X++)
|
||||
{
|
||||
sMapElem &ThisElem=Old.Get(X,Y);
|
||||
ThisElem.Flags^=Flag;
|
||||
Set(X,(Height-1)-Y,ThisElem,true);
|
||||
Set(Ofs-X,Y,ThisElem,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CMap::MirrorY(int Flag,CRect *R)
|
||||
{
|
||||
CMap Old=*this;
|
||||
|
||||
if (!R)
|
||||
{ // No rect, use full
|
||||
R=new CRect(0,0,GetWidth(),GetHeight());
|
||||
}
|
||||
|
||||
int Ofs=(R->bottom+R->top)-1;
|
||||
for (int Y=R->top; Y<R->bottom; Y++)
|
||||
{
|
||||
for (int X=R->left; X<R->right; X++)
|
||||
{
|
||||
sMapElem &ThisElem=Old.Get(X,Y);
|
||||
ThisElem.Flags^=Flag;
|
||||
Set(X,Ofs-Y,ThisElem,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -36,20 +36,21 @@ public:
|
|||
|
||||
int GetWidth();
|
||||
int GetHeight();
|
||||
BOOL IsValid() {return(GetHeight());}
|
||||
BOOL IsValid() {return(GetHeight()!=0);}
|
||||
|
||||
void SetSize(int Width,int Height,BOOL Clear=FALSE);
|
||||
void SetWidth(int Width);
|
||||
void SetHeight(int Height);
|
||||
void Clear();
|
||||
void Delete();
|
||||
void MirrorX(int Flag);
|
||||
void MirrorY(int Flag);
|
||||
void MirrorX(int Flag,CRect *R=NULL);
|
||||
void MirrorY(int Flag,CRect *R=NULL);
|
||||
|
||||
sMapElem &Get(int X,int Y);
|
||||
void Set(int X,int Y,sMapElem &Blk,BOOL Force=FALSE);
|
||||
void Set(int X,int Y,CMap &Blk,BOOL Force=FALSE);
|
||||
void Set(CMap &Src,int StartX,int StartY,int Width,int Height,BOOL Force=FALSE);
|
||||
void Set(CMap &Src,CRect &Rect,BOOL Force=FALSE);
|
||||
|
||||
void Resize(int Width,int Height);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[General Info]
|
||||
Version=1
|
||||
LastClass=CMapEditView
|
||||
LastClass=CMapEditDoc
|
||||
LastTemplate=CDialog
|
||||
NewFileInclude1=#include "stdafx.h"
|
||||
NewFileInclude2=#include "mapedit.h"
|
||||
|
@ -18,21 +18,21 @@ Class6=CMapEditDoc
|
|||
Class7=CMapEditView
|
||||
|
||||
ResourceCount=11
|
||||
Resource1=IDD_ABOUTBOX (English (U.S.))
|
||||
Resource1=IDD_MULTIBAR (English (U.S.))
|
||||
Resource2=IDR_MAPEDITYPE (English (U.S.))
|
||||
Resource3=IDR_MAINFRAME (English (U.S.))
|
||||
Resource3=IDD_LAYERTILE_GUI
|
||||
Resource4=IDD_DIALOGBAR (English (U.S.))
|
||||
Resource5=IDD_LAYER_LIST_DIALOG
|
||||
Resource5=IDR_TOOLBAR (English (U.S.))
|
||||
Class8=CMultiBar
|
||||
Resource6=IDD_NEW_LAYER
|
||||
Resource7=IDD_MULTIBAR (English (U.S.))
|
||||
Resource6=IDD_MAPSIZE
|
||||
Resource7=IDD_NEW_LAYER
|
||||
Class9=CLayerList
|
||||
Class10=CMapSizeDlg
|
||||
Resource8=IDD_LAYERTILE_GUI
|
||||
Resource8=IDR_MAINFRAME (English (U.S.))
|
||||
Class11=CGfxToolBar
|
||||
Class12=CLayerTileGUI
|
||||
Resource9=IDR_TOOLBAR (English (U.S.))
|
||||
Resource10=IDD_MAPSIZE
|
||||
Resource9=IDD_LAYER_LIST_DIALOG
|
||||
Resource10=IDD_ABOUTBOX (English (U.S.))
|
||||
Class13=CNewMapGUI
|
||||
Class14=CProgressDlg
|
||||
Resource11=IDD_NEWMAP
|
||||
|
@ -77,7 +77,7 @@ Type=0
|
|||
BaseClass=CDocument
|
||||
HeaderFile=MapEditDoc.h
|
||||
ImplementationFile=MapEditDoc.cpp
|
||||
LastObject=CMapEditDoc
|
||||
LastObject=ID_EDIT_COPY
|
||||
Filter=N
|
||||
VirtualFilter=DC
|
||||
|
||||
|
@ -86,7 +86,7 @@ Type=0
|
|||
BaseClass=CGLEnabledView
|
||||
HeaderFile=MapEditView.h
|
||||
ImplementationFile=MapEditView.cpp
|
||||
LastObject=CMapEditView
|
||||
LastObject=ID_ZOOM_IN
|
||||
Filter=C
|
||||
VirtualFilter=VWC
|
||||
|
||||
|
@ -265,7 +265,7 @@ Control1=IDD_LAYERTILE_LIST,combobox,1342242819
|
|||
Control2=IDD_LAYERTILE_BTN_UPDATE,button,1342242816
|
||||
Control3=IDD_LAYERTILE_BTN_LOAD,button,1342242816
|
||||
Control4=IDD_LAYERTILE_BTN_PAINT,button,1342177344
|
||||
Control5=IDD_LAYERTILE_BTN_SELECT,button,1476395072
|
||||
Control5=IDD_LAYERTILE_BTN_SELECT,button,1342177344
|
||||
Control6=IDD_LAYERTILE_BTN_DELETE,button,1342242816
|
||||
|
||||
[CLS:CLayerTileGUI]
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "stdafx.h"
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include "GLEnabledView.h"
|
||||
|
||||
#include "MapEdit.h"
|
||||
|
|
|
@ -23,8 +23,8 @@ CFG=MapEdit - Win32 Debug
|
|||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
# PROP Scc_ProjName ""$/Utils/MapEdit", IKCAAAAA"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
@ -239,6 +239,10 @@ SOURCE=.\MapEditView.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Select.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc"stdafx.h"
|
||||
# End Source File
|
||||
|
@ -252,18 +256,10 @@ SOURCE=.\ChildFrm.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gl3d.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GLEnabledView.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\List.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MainFrm.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -284,6 +280,10 @@ SOURCE=.\Resource.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Select.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# End Group
|
||||
|
|
|
@ -477,8 +477,8 @@ BEGIN
|
|||
PUSHBUTTON "Load",IDD_LAYERTILE_BTN_LOAD,5,25,45,15
|
||||
PUSHBUTTON "P",IDD_LAYERTILE_BTN_PAINT,5,45,15,15,BS_ICON | NOT
|
||||
WS_TABSTOP
|
||||
PUSHBUTTON "S",IDD_LAYERTILE_BTN_SELECT,20,45,15,15,BS_ICON |
|
||||
WS_DISABLED | NOT WS_TABSTOP
|
||||
PUSHBUTTON "S",IDD_LAYERTILE_BTN_SELECT,20,45,15,15,BS_ICON | NOT
|
||||
WS_TABSTOP
|
||||
PUSHBUTTON "Delete",IDD_LAYERTILE_BTN_DELETE,50,25,45,15
|
||||
END
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ BEGIN_MESSAGE_MAP(CMapEditDoc, CDocument)
|
|||
ON_COMMAND(ID_EXPORT_PSX, OnExportPsx)
|
||||
ON_COMMAND(ID_ZOOM_IN, OnZoomIn)
|
||||
ON_COMMAND(ID_ZOOM_OUT, OnZoomOut)
|
||||
ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
|
||||
ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
@ -326,6 +328,17 @@ void CMapEditDoc::Toggle2d3d(CMapEditView *View)
|
|||
void CMapEditDoc::FocusView()
|
||||
{
|
||||
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::OnEditCopy()
|
||||
{
|
||||
Core.CopySelection();
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::OnEditPaste()
|
||||
{
|
||||
Core.PasteSelection();
|
||||
}
|
||||
|
|
|
@ -79,6 +79,8 @@ protected:
|
|||
afx_msg void OnExportPsx();
|
||||
afx_msg void OnZoomIn();
|
||||
afx_msg void OnZoomOut();
|
||||
afx_msg void OnEditCopy();
|
||||
afx_msg void OnEditPaste();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "stdafx.h"
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include "GLEnabledView.h"
|
||||
#include "MapEdit.h"
|
||||
|
||||
|
@ -62,9 +61,9 @@ CMapEditView::~CMapEditView()
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CMapEditView::VideoMode(ColorsNumber & c, ZAccuracy & z, BOOL & dbuf)
|
||||
{
|
||||
c=MILLIONS; // ask for 65355 colors...
|
||||
z=NORMAL; // ...16 bit Z-buffer...
|
||||
dbuf=TRUE; // ...double-buffering
|
||||
c=MILLIONS;
|
||||
z=NORMAL;
|
||||
dbuf=TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -91,6 +90,7 @@ void CMapEditView::OnDrawGL()
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CMapEditView::OnSizeGL(int cx, int cy)
|
||||
{
|
||||
// cy=cx/1.5f;
|
||||
glViewport(0,0,cx,cy);
|
||||
|
||||
// update the camera
|
||||
|
@ -107,21 +107,7 @@ void CMapEditView::OnSizeGL(int cx, int cy)
|
|||
void CMapEditView::SetupPersMatrix()
|
||||
{
|
||||
gluPerspective(40.0,m_dAspectRatio,0.1f, 100.0f);
|
||||
glTranslatef(0.0f,0.0f,-4.f);
|
||||
|
||||
// GLint viewport[4];
|
||||
|
||||
// glGetIntegerv( GL_VIEWPORT, viewport );
|
||||
// glMatrixMode( GL_PROJECTION );
|
||||
// glLoadIdentity();
|
||||
// glOrtho( 0.0f, viewport[2]-viewport[0],viewport[3]-viewport[1], 0.0f, 0.1f, 100.0f);
|
||||
// glOrtho( 0.0f, +30,+20, 0, 0.1f, 100.0f);
|
||||
// glTranslatef(0.0f,0.0f,-0.f);
|
||||
|
||||
// glMatrixMode( GL_MODELVIEW );
|
||||
// glLoadIdentity();
|
||||
// glTranslatef( 0.375, 0.375, 0.0 );
|
||||
|
||||
glTranslatef(0.0f,0.0f,-1.f);
|
||||
}
|
||||
|
||||
|
||||
|
@ -155,7 +141,6 @@ CMapEditDoc *CurDoc=GetDocument();
|
|||
CGLEnabledView::OnSetFocus(pOldWnd);
|
||||
theApp.SetCurrent(CurDoc);
|
||||
CurDoc->UpdateAll(this);
|
||||
// CurDoc->UpdateAllViews(this);
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
|
|
68
Utils/MapEdit/Select.cpp
Normal file
68
Utils/MapEdit/Select.cpp
Normal file
|
@ -0,0 +1,68 @@
|
|||
/***********************/
|
||||
/*** Selection Class ***/
|
||||
/***********************/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Select.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
CSelect::CSelect()
|
||||
{
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CSelect::Invalidate()
|
||||
{
|
||||
Sel.SetRectEmpty();
|
||||
Mode=0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
bool CSelect::Handle(CPoint &Pnt,UINT Flags)
|
||||
{
|
||||
Flags&=(MK_LBUTTON | MK_RBUTTON);
|
||||
if (!Mode && !Flags) return(false);
|
||||
if (!Mode && Flags)
|
||||
{ // Start new Selection
|
||||
Start(Pnt,Flags);
|
||||
}
|
||||
// Order the points
|
||||
Sel.SetRect(Pos0,Pnt);
|
||||
Sel.NormalizeRect();
|
||||
Sel.InflateRect(0,0,1,1); // extend to make valid sel (right and bottom are +1)
|
||||
|
||||
if (Mode && !Flags)
|
||||
{
|
||||
End(Pnt,Flags);
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CSelect::Start(CPoint &Pnt,UINT Flags)
|
||||
{
|
||||
Invalidate();
|
||||
Mode=Flags;
|
||||
Pos0=Pnt;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CSelect::End(CPoint &Pnt,UINT Flags)
|
||||
{
|
||||
Mode=0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
bool CSelect::IsValid()
|
||||
{
|
||||
if (Sel.left==-1 || Sel.top==-1) return(false); // Invalid coords
|
||||
return(!Sel.IsRectEmpty());
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
bool CSelect::HasSelection()
|
||||
{
|
||||
if (Mode) return(false); // Still Selecting?
|
||||
return(IsValid());
|
||||
}
|
34
Utils/MapEdit/Select.h
Normal file
34
Utils/MapEdit/Select.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/***********************/
|
||||
/*** Selection Class ***/
|
||||
/***********************/
|
||||
|
||||
#ifndef __SELECTION_CLASS_HEADER__
|
||||
#define __SELECTION_CLASS_HEADER__
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
class CSelect
|
||||
{
|
||||
public:
|
||||
CSelect();
|
||||
virtual ~CSelect(){};
|
||||
|
||||
void Invalidate();
|
||||
bool Handle(CPoint &Pnt,UINT Flags);
|
||||
bool IsValid();
|
||||
bool HasSelection();
|
||||
|
||||
CRect &GetRect() {return(Sel);}
|
||||
|
||||
private:
|
||||
void Start(CPoint &Pnt, UINT Flags);
|
||||
void End(CPoint &Pnt, UINT Flags);
|
||||
|
||||
CPoint Pos,Pos0;
|
||||
CRect Sel;
|
||||
UINT Mode;
|
||||
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
#endif
|
|
@ -5,7 +5,6 @@
|
|||
#include "stdafx.h"
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include <frame.hpp>
|
||||
#include <Vector>
|
||||
|
||||
|
@ -147,6 +146,8 @@ u8 *Src,*Dst;
|
|||
glTexImage2D(GL_TEXTURE_2D, 0, 4, GLWidth, GLHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, &Buffer[0]);
|
||||
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_WRAP_S,GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
free(Buffer);
|
||||
}
|
||||
|
|
|
@ -6,11 +6,8 @@
|
|||
#define __TEXCACHE_HEADER__
|
||||
|
||||
#include "stdafx.h"
|
||||
//#include "gl3d.h"
|
||||
//#include <Vector3.h>
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include <Vector>
|
||||
#include "Utils.h"
|
||||
#include "List.h"
|
||||
|
@ -29,9 +26,9 @@ struct sTex
|
|||
int Flags;
|
||||
int TexWidth,TexHeight;
|
||||
float dW,dH;
|
||||
BOOL Loaded;
|
||||
bool Loaded;
|
||||
|
||||
BOOL operator==(sTex const &v1) {return (!strcmp(Filename,v1.Filename) && Flags==v1.Flags);}
|
||||
bool operator==(sTex const &v1) {return (!strcmp(Filename,v1.Filename) && Flags==v1.Flags);}
|
||||
};
|
||||
|
||||
const RGBQUAD BlankRGB={255,0,255};
|
||||
|
@ -52,7 +49,7 @@ public:
|
|||
void LoadBMP(char *Filename,sRGBData &RGBData);
|
||||
void FreeBMP(sRGBData &RGBData);
|
||||
void FixBMP(sRGBData &RGBData);
|
||||
BOOL IsSizeOk(int Size);
|
||||
bool IsSizeOk(int Size);
|
||||
int AlignSize(int Size);
|
||||
|
||||
void LoadTex(sTex &ThisTex,sRGBData *TexData);
|
||||
|
|
|
@ -3,11 +3,9 @@
|
|||
/*********************/
|
||||
|
||||
#include "stdafx.h"
|
||||
//#include "gl3d.h"
|
||||
#include <Vector3.h>
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include "GLEnabledView.h"
|
||||
#include <Vector>
|
||||
#include <GFName.hpp>
|
||||
|
@ -216,15 +214,16 @@ void CTileBank::RenderSet(CCore *Core,Vector3 &CamPos,BOOL Is3d)
|
|||
{
|
||||
if (!TileSet.size()) return; // No tiles, return
|
||||
|
||||
|
||||
if (Is3d)
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
TileSet[CurrentSet].Render(CamPos,GetLBrush(),GetRBrush(),TRUE);
|
||||
TileSet[CurrentSet].Render(Core,CamPos,GetLBrush(),GetRBrush(),TRUE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
}
|
||||
else
|
||||
{
|
||||
TileSet[CurrentSet].Render(CamPos,GetLBrush(),GetRBrush(),FALSE);
|
||||
TileSet[CurrentSet].Render(Core,CamPos,GetLBrush(),GetRBrush(),FALSE);
|
||||
}
|
||||
|
||||
TileSet[CurrentSet].RenderCursor(CamPos,CursorPos,SelStart,SelEnd);
|
||||
|
@ -426,31 +425,6 @@ int Height=ThisTex.TexHeight/16;
|
|||
TileBrowserWidth=Width;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
BOOL CTileSet::Create16x16Tile(sRGBData &Src,u8 *Dst,int XOfs,int YOfs)
|
||||
{
|
||||
BOOL Data=FALSE;
|
||||
|
||||
for (int Y=0; Y<16; Y++)
|
||||
{
|
||||
for (int X=0; X<16; X++)
|
||||
{
|
||||
u8 *SrcPtr=(u8*)&Src.RGB[((((YOfs*16)+Y)*Src.Width)+(X+(XOfs*16)))*3];
|
||||
u8 R=SrcPtr[0];
|
||||
u8 G=SrcPtr[1];
|
||||
u8 B=SrcPtr[2];
|
||||
|
||||
if (R!=BlankRGB.rgbRed || G!=BlankRGB.rgbGreen || B!=BlankRGB.rgbBlue) Data=TRUE;
|
||||
|
||||
*Dst++=R;
|
||||
*Dst++=G;
|
||||
*Dst++=B;
|
||||
}
|
||||
}
|
||||
return(Data);
|
||||
}
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
void CTileSet::Load3d(CCore *Core)
|
||||
{
|
||||
|
@ -498,7 +472,7 @@ CPoint CTileSet::GetTilePos(int ID)
|
|||
BOOL CTileSet::IsTileValid(int No)
|
||||
{
|
||||
ASSERT(No<Tile.size());
|
||||
return(Tile[No].IsValid());
|
||||
{return(Tile[No].IsValid());}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -509,26 +483,30 @@ BOOL CTileSet::IsTileValidGB(int No)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CTileSet::Render(Vector3 &CamPos,CMap &LBrush,CMap &RBrush,BOOL Render3d)
|
||||
void CTileSet::Render(CCore *Core,Vector3 &CamPos,CMap &LBrush,CMap &RBrush,BOOL Render3d)
|
||||
{
|
||||
int ListSize=Tile.size();
|
||||
int TileID=0;
|
||||
sMapElem ThisElem;
|
||||
int SelFlag;
|
||||
BOOL ValidTile=TRUE;
|
||||
float Scale=1.0f/(float)TileBrowserWidth/CamPos.z;
|
||||
|
||||
ThisElem.Flags=0;
|
||||
ThisElem.Set=SetNumber;
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
||||
while(TileID!=ListSize)
|
||||
{
|
||||
CPoint Pos=GetTilePos(TileID);
|
||||
|
||||
float XPos=(float)Pos.x*(1+TileBrowserGap);
|
||||
float YPos=(float)Pos.y*(1+TileBrowserGap);
|
||||
|
||||
glLoadIdentity();
|
||||
glTranslatef(CamPos.x+Pos.x*(1+TileBrowserGap),CamPos.y-Pos.y*(1+TileBrowserGap),CamPos.z);
|
||||
glScalef(Scale,Scale,Scale);
|
||||
glTranslatef(-CamPos.x+XPos,CamPos.y-YPos,0);
|
||||
|
||||
ValidTile=IsTileValid(TileID);
|
||||
if (TileID && ValidTile)
|
||||
|
@ -551,17 +529,17 @@ BOOL ValidTile=TRUE;
|
|||
{
|
||||
case 1: // L
|
||||
glColor4f(1,0,0,0.5);
|
||||
BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0.01);
|
||||
BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0.01f);
|
||||
break;
|
||||
case 2: // R
|
||||
glColor4f(0,0,1,0.5);
|
||||
BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0.01);
|
||||
BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0.01f);
|
||||
break;
|
||||
case 3: // LR
|
||||
glColor4f(1,0,0,0.5);
|
||||
BuildGLQuad(TileBrowserX0,0.5,TileBrowserY0,TileBrowserY1,0.01);
|
||||
BuildGLQuad(TileBrowserX0,0.5,TileBrowserY0,TileBrowserY1,0.01f);
|
||||
glColor4f(0,0,1,0.5);
|
||||
BuildGLQuad(0.5,TileBrowserX1,TileBrowserY0,TileBrowserY1,0.01);
|
||||
BuildGLQuad(0.5,TileBrowserX1,TileBrowserY0,TileBrowserY1,0.01f);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -606,6 +584,7 @@ BOOL ValidTile=TRUE;
|
|||
|
||||
TileID++;
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
|
@ -615,6 +594,7 @@ void CTileSet::RenderCursor(Vector3 &CamPos,int CursorPos,int SelStart,int SelEn
|
|||
int ListSize=Tile.size();
|
||||
CPoint Start,End;
|
||||
int MaxTile=Tile.size();
|
||||
float Scale=1.0f/(float)TileBrowserWidth/CamPos.z;
|
||||
|
||||
if (CursorPos<-1 || CursorPos>ListSize) return;
|
||||
|
||||
|
@ -635,13 +615,19 @@ int MaxTile=Tile.size();
|
|||
}
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
||||
for (int Y=Start.y; Y<=End.y; Y++)
|
||||
{
|
||||
for (int X=Start.x; X<=End.x; X++)
|
||||
{
|
||||
float XPos=(float)X*(1+TileBrowserGap);
|
||||
float YPos=(float)Y*(1+TileBrowserGap);
|
||||
|
||||
glLoadIdentity();
|
||||
glTranslatef(CamPos.x+X*(1+TileBrowserGap),CamPos.y-Y*(1+TileBrowserGap),CamPos.z);
|
||||
glScalef(Scale,Scale,Scale);
|
||||
glTranslatef(-CamPos.x+XPos,CamPos.y-YPos,0);
|
||||
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glColor4f(1,1,0,0.5);
|
||||
|
@ -650,6 +636,7 @@ int MaxTile=Tile.size();
|
|||
|
||||
}
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -657,15 +644,20 @@ void CTileSet::RenderGrid(Vector3 &CamPos)
|
|||
{
|
||||
int ListSize=Tile.size();
|
||||
int TileID=1; // Dont bother with blank, its sorted
|
||||
float Scale=1.0f/(float)TileBrowserWidth/CamPos.z;
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
||||
while(TileID!=ListSize)
|
||||
{
|
||||
CPoint Pos=GetTilePos(TileID);
|
||||
float XPos=(float)Pos.x*(1+TileBrowserGap);
|
||||
float YPos=(float)Pos.y*(1+TileBrowserGap);
|
||||
|
||||
glLoadIdentity();
|
||||
glTranslatef(CamPos.x+Pos.x*(1+TileBrowserGap),CamPos.y-Pos.y*(1+TileBrowserGap),CamPos.z);
|
||||
glScalef(Scale,Scale,Scale);
|
||||
glTranslatef(-CamPos.x+XPos,CamPos.y-YPos,0);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1,1,1);
|
||||
|
@ -686,6 +678,8 @@ int TileID=1; // Dont bother with blank, its sorted
|
|||
|
||||
TileID++;
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -696,6 +690,7 @@ GLint Viewport[4];
|
|||
GLuint SelectBuffer[SELECT_BUFFER_SIZE];
|
||||
int HitCount;
|
||||
int TileID=0;
|
||||
float Scale=1.0f/(float)TileBrowserWidth/CamPos.z;
|
||||
|
||||
glGetIntegerv(GL_VIEWPORT, Viewport);
|
||||
glSelectBuffer (SELECT_BUFFER_SIZE, SelectBuffer );
|
||||
|
@ -711,13 +706,17 @@ int TileID=0;
|
|||
View->SetupPersMatrix();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
||||
while(TileID!=ListSize)
|
||||
{
|
||||
CPoint Pos=GetTilePos(TileID);
|
||||
float XPos=(float)Pos.x*(1+TileBrowserGap);
|
||||
float YPos=(float)Pos.y*(1+TileBrowserGap);
|
||||
|
||||
glLoadIdentity();
|
||||
glTranslatef(CamPos.x+Pos.x*(1+TileBrowserGap),CamPos.y-Pos.y*(1+TileBrowserGap),CamPos.z);
|
||||
glScalef(Scale,Scale,Scale);
|
||||
glTranslatef(-CamPos.x+XPos,CamPos.y-YPos,0);
|
||||
|
||||
glLoadName (TileID);
|
||||
glBegin (GL_QUADS);
|
||||
|
@ -727,6 +726,7 @@ int TileID=0;
|
|||
}
|
||||
|
||||
HitCount= glRenderMode (GL_RENDER);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
|
||||
|
|
|
@ -6,11 +6,9 @@
|
|||
#define __TILESET_HEADER__
|
||||
|
||||
#include "stdafx.h"
|
||||
//#include "gl3d.h"
|
||||
#include <Vector3.h>
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include <Vector>
|
||||
#include <gfname.hpp>
|
||||
|
||||
|
@ -117,7 +115,7 @@ public:
|
|||
CTile &GetTile(int No) {return(Tile[No]);}
|
||||
void Purge();
|
||||
int FindCursorPos(CCore *Core,CMapEditView *View,Vector3 &CamPos,CPoint &MousePos);
|
||||
void Render(Vector3 &CamPos,CMap &LBrush,CMap &RBrush,BOOL Render3d);
|
||||
void Render(CCore *Core,Vector3 &CamPos,CMap &LBrush,CMap &RBrush,BOOL Render3d);
|
||||
void RenderCursor(Vector3 &CamPos,int Pos,int Width, int Height);
|
||||
void RenderBrush(Vector3 &CamPos,CMap &LBrush,CMap &RBrush);
|
||||
void RenderGrid(Vector3 &CamPos);
|
||||
|
|
|
@ -4,12 +4,9 @@
|
|||
|
||||
#include "stdafx.h"
|
||||
|
||||
//#include "gl3d.h"
|
||||
#include <Vector3.h>
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include <gl\glaux.h> // Header File For The Glaux Library
|
||||
#include "GLEnabledView.h"
|
||||
|
||||
#include "Utils.H"
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#include <vector3.h>
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include <gl\glaux.h> // Header File For The Glaux Library
|
||||
|
||||
/**************************************************************************************/
|
||||
typedef signed char s8;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue