This commit is contained in:
Daveo 2000-10-25 18:28:44 +00:00
parent 0e6c23803d
commit a1e872c005
9 changed files with 144 additions and 264 deletions

View file

@ -10,11 +10,16 @@
#include <gl\glut.h>
#include "GLEnabledView.h"
#include "MapEdit.h"
#include "MapEditDoc.h"
#include "MapEditView.h"
#include "Core.h"
#include "Layer.h"
#include "LayerBack.h"
#include "LayerMid.h"
#include "LayerAction.h"
#include "LayerFore.h"
/*****************************************************************************/
@ -23,23 +28,26 @@
CCore::CCore()
{
MouseMode=MOUSE_MODE_NONE;
Layers[LAYER_TYPE_BACK]= new CLayerBack;
Layers[LAYER_TYPE_MID]= new CLayerMid;
Layers[LAYER_TYPE_ACTION]= new CLayerAction;
Layers[LAYER_TYPE_FORE]= new CLayerFore;
}
/*****************************************************************************/
CCore::~CCore()
{
for (int i=0; i<LAYER_TYPE_MAX; i++) delete Layers[i];
}
/*****************************************************************************/
void CCore::Init(CMapEditView *Wnd)
{
ParentWindow=Wnd;
// ParentWindow->SetCapture();
// ParentWindow->SetCapture();
// TestLayer.Init();
// UpdateView();
ActiveLayer=0;
MapPos.x=MapPos.y=MapPos.z=0;
}
@ -48,106 +56,73 @@ void CCore::Init(CMapEditView *Wnd)
/*****************************************************************************/
void CCore::Render()
{
TRACE0("HERE");
Layers[ActiveLayer].Render();
// if (RenderMode & RENDER_MODE_GFX) TestLayer.Render();
// if (RenderMode & RENDER_MODE_POS) TestLayer.UpdateCursor(this);
// RenderMode=0;
for (int i=0;i<LAYER_TYPE_MAX;i++)
{
Layers[i]->Render(MapPos);
}
}
/*****************************************************************************/
void CCore::UpdateView(float XOfs,float YOfs,float ZOfs)
{
// RenderMode|= RENDER_MODE_POS;
// RenderMode|= RENDER_MODE_GFX;
// ViewPos=ViewPos+Vec(XOfs,YOfs,ZOfs);
// if (ViewPos.z>-1) ViewPos.z=-1;
MapPos=MapPos+Vec(XOfs,YOfs,ZOfs);
if (MapPos.z>-1) MapPos.z=-1;
// ParentWindow->Redraw();
ParentWindow->Invalidate();
}
/*****************************************************************************/
/*** Control *****************************************************************/
/*****************************************************************************/
void CCore::SetMouseMode(MOUSE_MODE CurrentMode,MOUSE_MODE NewMode)
{
if (MouseMode==CurrentMode)
{
// ReleaseCapture();
MouseMode=NewMode;
// if (MouseMode!=MOUSE_MODE_NONE) ParentWindow->SetCapture(); // Set new capture
}
}
/*****************************************************************************/
void CCore::LButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
{
// TestLayer.LButtonControl(nFlags,point,DownFlag);
SetMouseMode(MOUSE_MODE_NONE,MOUSE_MODE_LMB);
TRACE0("LMB\n");
// if (!(nFlags & (MK_MBUTTON | MK_RBUTTON))) Layers[ActiveLayer].MouseMsg(nFlags,point);
}
/*****************************************************************************/
void CCore::MButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
{
if (DownFlag)
SetMouseMode(MOUSE_MODE_NONE,MOUSE_MODE_MMB);
else
SetMouseMode(MOUSE_MODE_MMB,MOUSE_MODE_NONE);
TRACE0("MMB\n");
/*
if (DownFlag)
{
LastMousePos=point;
ParentWindow->SetCapture();
}
else
{
ReleaseCapture();
}
*/
// if (!(nFlags & (MK_LBUTTON | MK_RBUTTON))) Layers[ActiveLayer].MouseMsg(nFlags,point);
}
/*****************************************************************************/
void CCore::RButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
{
// TestLayer.RButtonControl(nFlags,point,DownFlag);
SetMouseMode(MOUSE_MODE_NONE,MOUSE_MODE_RMB);
TRACE0("RMB\n");
// if (!(nFlags & (MK_LBUTTON | MK_MBUTTON))) Layers[ActiveLayer].MouseMsg(nFlags,point);
}
/*****************************************************************************/
void CCore::MouseWheel(UINT nFlags, short zDelta, CPoint &pt)
{
if (zDelta<0)
{
UpdateView(0,0,+1.0f);
}
if (zDelta>0)
{
UpdateView(0,0,-1.0f);
}
if (zDelta>0)
UpdateView(0,0,1.0f);
else
UpdateView(0,0,-1.0f);
}
/*****************************************************************************/
void CCore::MouseMove(UINT nFlags, CPoint &point,BOOL CaptureFlag)
void CCore::MouseMove(UINT nFlags, CPoint &point)
{
float XOfs=0;
float YOfs=0;
CurrentMousePos=point;
// check if active doc
if (theApp.GetCurrent()!=ParentWindow->GetDocument()) return;
if (CaptureFlag)
// Layers[ActiveLayer].MouseMsg(nFlags,point);
/*
// Handle Movement
CurrentMousePos=point;
{
float XS,YS;
RECT ThisRect;
ParentWindow->GetWindowRect(&ThisRect);
XS=ViewPos.z/((ThisRect.right-ThisRect.left));
YS=ViewPos.z/((ThisRect.bottom-ThisRect.top));
XS=MapPos.z/((ThisRect.right-ThisRect.left));
YS=MapPos.z/((ThisRect.bottom-ThisRect.top));
XOfs=LastMousePos.x-CurrentMousePos.x;
YOfs=LastMousePos.y-CurrentMousePos.y;
@ -155,35 +130,24 @@ float YOfs=0;
XOfs*=XS;
YOfs*=YS;
// TRACE2("Move %i %i,",ThisRect.left,ThisRect.top);
// TRACE2("Move %i %i \n",ThisRect.right,ThisRect.bottom);
}
UpdateView(-XOfs,-YOfs,0);
// if (nFlags & MK_LBUTTON) LButtonControl(nFlags,point,TRUE);
// if (nFlags & MK_RBUTTON) RButtonControl(nFlags,point,TRUE);
TRACE3("Move %i %i %i \n",point.x,point.y,CaptureFlag);
TRACE2("Move %i %i \n",point.x,point.y);
*/
MapPos.x+=0.01f;
UpdateView(0.01f,0,0);
//Render();
}
/*****************************************************************************/
/*** Layer Code **************************************************************/
/*****************************************************************************/
void CCore::LayerAdd(char *Name)
{
CLayer NewLayer;
if (!Name)
{
char DynName[32];
sprintf(DynName,"Layer%2d",Layers.size()+1);
Name=DynName;
}
NewLayer.SetName(Name);
// strcpy(NewLayer.Name,Name);
TRACE1("New Layer [%s]\n",Name);
Layers.push_back(NewLayer);
}
/*****************************************************************************/
void CCore::LayerSetActive(int i)
{
@ -196,50 +160,11 @@ int CCore::LayerGetActive()
}
/*****************************************************************************/
int CCore::LayerGetCount()
{
return(Layers.size());
}
/*****************************************************************************/
CLayer &CCore::LayerGet(int i)
CLayer *CCore::LayerGet(int i)
{
return(Layers[i]);
}
/*****************************************************************************/
void CCore::LayerDelete(int Layer)
{
Layers.erase(Layers.begin() + Layer);
TRACE0("Delete Layer\n");
}
/*****************************************************************************/
void CCore::LayerMoveUp(int Layer)
{
CLayer Tmp;
Tmp=Layers[Layer];
Layers[Layer]=Layers[Layer-1];
Layers[Layer-1]=Tmp;
TRACE0("Layer Up \n");
}
/*****************************************************************************/
void CCore::LayerMoveDown(int Layer)
{
CLayer Tmp;
Tmp=Layers[Layer];
Layers[Layer]=Layers[Layer+1];
Layers[Layer+1]=Tmp;
TRACE0("Layer Down\n");
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/