SBSPSS/Utils/MapEdit/Core.cpp

173 lines
4.7 KiB
C++
Raw Normal View History

2000-09-22 17:11:29 +02:00
/***********************/
/*** Map Editor Core ***/
/***********************/
#include "stdafx.h"
2000-09-22 23:19:46 +02:00
#include "gl3d.h"
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glut.h>
#include "GLEnabledView.h"
2000-10-25 20:28:44 +02:00
#include "MapEdit.h"
2000-09-22 23:19:46 +02:00
#include "MapEditDoc.h"
#include "MapEditView.h"
2000-09-22 17:11:29 +02:00
#include "Core.h"
2000-09-25 17:43:52 +02:00
#include "Layer.h"
2000-10-25 20:28:44 +02:00
#include "LayerBack.h"
#include "LayerMid.h"
#include "LayerAction.h"
#include "LayerFore.h"
2000-09-22 17:11:29 +02:00
2000-09-22 23:19:46 +02:00
2000-09-22 17:11:29 +02:00
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
CCore::CCore()
{
2000-09-25 17:43:52 +02:00
MouseMode=MOUSE_MODE_NONE;
2000-10-25 20:28:44 +02:00
Layers[LAYER_TYPE_BACK]= new CLayerBack;
Layers[LAYER_TYPE_MID]= new CLayerMid;
Layers[LAYER_TYPE_ACTION]= new CLayerAction;
Layers[LAYER_TYPE_FORE]= new CLayerFore;
2000-09-22 17:11:29 +02:00
}
2000-09-25 17:43:52 +02:00
2000-09-22 17:11:29 +02:00
/*****************************************************************************/
CCore::~CCore()
{
2000-10-25 20:28:44 +02:00
for (int i=0; i<LAYER_TYPE_MAX; i++) delete Layers[i];
2000-09-22 17:11:29 +02:00
}
2000-09-22 23:19:46 +02:00
/*****************************************************************************/
void CCore::Init(CMapEditView *Wnd)
{
ParentWindow=Wnd;
2000-10-25 20:28:44 +02:00
ActiveLayer=0;
MapPos.x=MapPos.y=MapPos.z=0;
2000-09-22 23:19:46 +02:00
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CCore::Render()
{
2000-10-25 20:28:44 +02:00
for (int i=0;i<LAYER_TYPE_MAX;i++)
{
Layers[i]->Render(MapPos);
}
2000-09-22 23:19:46 +02:00
}
/*****************************************************************************/
void CCore::UpdateView(float XOfs,float YOfs,float ZOfs)
{
2000-10-25 20:28:44 +02:00
MapPos=MapPos+Vec(XOfs,YOfs,ZOfs);
if (MapPos.z>-1) MapPos.z=-1;
2000-09-22 23:19:46 +02:00
2000-10-25 20:28:44 +02:00
ParentWindow->Invalidate();
2000-09-22 23:19:46 +02:00
}
/*****************************************************************************/
/*** Control *****************************************************************/
/*****************************************************************************/
void CCore::LButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
{
2000-10-25 20:28:44 +02:00
// if (!(nFlags & (MK_MBUTTON | MK_RBUTTON))) Layers[ActiveLayer].MouseMsg(nFlags,point);
2000-09-22 23:19:46 +02:00
}
/*****************************************************************************/
void CCore::MButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
{
2000-10-25 20:28:44 +02:00
// if (!(nFlags & (MK_LBUTTON | MK_RBUTTON))) Layers[ActiveLayer].MouseMsg(nFlags,point);
2000-09-22 23:19:46 +02:00
}
/*****************************************************************************/
void CCore::RButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
{
2000-10-25 20:28:44 +02:00
// if (!(nFlags & (MK_LBUTTON | MK_MBUTTON))) Layers[ActiveLayer].MouseMsg(nFlags,point);
2000-09-22 23:19:46 +02:00
}
/*****************************************************************************/
void CCore::MouseWheel(UINT nFlags, short zDelta, CPoint &pt)
{
2000-10-25 20:28:44 +02:00
if (zDelta>0)
UpdateView(0,0,1.0f);
else
UpdateView(0,0,-1.0f);
2000-09-22 23:19:46 +02:00
}
/*****************************************************************************/
2000-10-25 20:28:44 +02:00
void CCore::MouseMove(UINT nFlags, CPoint &point)
2000-09-22 23:19:46 +02:00
{
float XOfs=0;
float YOfs=0;
2000-10-25 20:28:44 +02:00
// check if active doc
if (theApp.GetCurrent()!=ParentWindow->GetDocument()) return;
2000-09-22 23:19:46 +02:00
2000-10-25 20:28:44 +02:00
// Layers[ActiveLayer].MouseMsg(nFlags,point);
/*
// Handle Movement
CurrentMousePos=point;
2000-09-22 23:19:46 +02:00
{
float XS,YS;
RECT ThisRect;
ParentWindow->GetWindowRect(&ThisRect);
2000-10-25 20:28:44 +02:00
XS=MapPos.z/((ThisRect.right-ThisRect.left));
YS=MapPos.z/((ThisRect.bottom-ThisRect.top));
2000-09-22 23:19:46 +02:00
XOfs=LastMousePos.x-CurrentMousePos.x;
YOfs=LastMousePos.y-CurrentMousePos.y;
2000-09-25 17:43:52 +02:00
LastMousePos=CurrentMousePos;
2000-09-22 23:19:46 +02:00
XOfs*=XS;
YOfs*=YS;
2000-10-25 20:28:44 +02:00
// TRACE2("Move %i %i,",ThisRect.left,ThisRect.top);
// TRACE2("Move %i %i \n",ThisRect.right,ThisRect.bottom);
2000-09-22 23:19:46 +02:00
}
UpdateView(-XOfs,-YOfs,0);
2000-09-25 17:43:52 +02:00
// if (nFlags & MK_LBUTTON) LButtonControl(nFlags,point,TRUE);
// if (nFlags & MK_RBUTTON) RButtonControl(nFlags,point,TRUE);
2000-09-22 23:19:46 +02:00
2000-10-25 20:28:44 +02:00
TRACE2("Move %i %i \n",point.x,point.y);
*/
MapPos.x+=0.01f;
UpdateView(0.01f,0,0);
//Render();
2000-09-22 23:19:46 +02:00
}
2000-09-22 17:11:29 +02:00
/*****************************************************************************/
/*** Layer Code **************************************************************/
/*****************************************************************************/
void CCore::LayerSetActive(int i)
{
}
/*****************************************************************************/
int CCore::LayerGetActive()
{
return(ActiveLayer);
}
/*****************************************************************************/
2000-10-25 20:28:44 +02:00
CLayer *CCore::LayerGet(int i)
2000-09-22 17:11:29 +02:00
{
return(Layers[i]);
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/