SBSPSS/Utils/MapEdit/Core.cpp

248 lines
5.9 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"
#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-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-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-09-22 23:19:46 +02:00
/*****************************************************************************/
void CCore::Init(CMapEditView *Wnd)
{
ParentWindow=Wnd;
2000-09-25 17:43:52 +02:00
// ParentWindow->SetCapture();
// ParentWindow->SetCapture();
2000-09-22 23:19:46 +02:00
// TestLayer.Init();
// UpdateView();
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CCore::Render()
{
2000-09-25 17:43:52 +02:00
TRACE0("HERE");
Layers[ActiveLayer].Render();
2000-09-22 23:19:46 +02:00
// if (RenderMode & RENDER_MODE_GFX) TestLayer.Render();
// if (RenderMode & RENDER_MODE_POS) TestLayer.UpdateCursor(this);
// RenderMode=0;
}
/*****************************************************************************/
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;
// ParentWindow->Redraw();
}
/*****************************************************************************/
/*** Control *****************************************************************/
2000-09-25 17:43:52 +02:00
/*****************************************************************************/
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
}
}
2000-09-22 23:19:46 +02:00
/*****************************************************************************/
void CCore::LButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
{
// TestLayer.LButtonControl(nFlags,point,DownFlag);
2000-09-25 17:43:52 +02:00
SetMouseMode(MOUSE_MODE_NONE,MOUSE_MODE_LMB);
TRACE0("LMB\n");
2000-09-22 23:19:46 +02:00
}
/*****************************************************************************/
void CCore::MButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
{
2000-09-25 17:43:52 +02:00
if (DownFlag)
SetMouseMode(MOUSE_MODE_NONE,MOUSE_MODE_MMB);
else
SetMouseMode(MOUSE_MODE_MMB,MOUSE_MODE_NONE);
TRACE0("MMB\n");
/*
2000-09-22 23:19:46 +02:00
if (DownFlag)
{
LastMousePos=point;
ParentWindow->SetCapture();
}
else
{
ReleaseCapture();
}
2000-09-25 17:43:52 +02:00
*/
2000-09-22 23:19:46 +02:00
}
/*****************************************************************************/
void CCore::RButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
{
// TestLayer.RButtonControl(nFlags,point,DownFlag);
2000-09-25 17:43:52 +02:00
SetMouseMode(MOUSE_MODE_NONE,MOUSE_MODE_RMB);
TRACE0("RMB\n");
2000-09-22 23:19:46 +02:00
}
/*****************************************************************************/
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);
}
}
/*****************************************************************************/
2000-09-25 17:43:52 +02:00
void CCore::MouseMove(UINT nFlags, CPoint &point,BOOL CaptureFlag)
2000-09-22 23:19:46 +02:00
{
float XOfs=0;
float YOfs=0;
2000-09-25 17:43:52 +02:00
CurrentMousePos=point;
2000-09-22 23:19:46 +02:00
if (CaptureFlag)
{
float XS,YS;
RECT ThisRect;
ParentWindow->GetWindowRect(&ThisRect);
XS=ViewPos.z/((ThisRect.right-ThisRect.left));
YS=ViewPos.z/((ThisRect.bottom-ThisRect.top));
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;
}
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-09-25 17:43:52 +02:00
TRACE3("Move %i %i %i \n",point.x,point.y,CaptureFlag);
2000-09-22 23:19:46 +02:00
}
2000-09-22 17:11:29 +02:00
/*****************************************************************************/
/*** Layer Code **************************************************************/
/*****************************************************************************/
void CCore::LayerAdd(char *Name)
{
2000-09-25 17:43:52 +02:00
CLayer NewLayer;
2000-09-22 17:11:29 +02:00
if (!Name)
{
char DynName[32];
sprintf(DynName,"Layer%2d",Layers.size()+1);
Name=DynName;
}
2000-09-25 17:43:52 +02:00
NewLayer.SetName(Name);
// strcpy(NewLayer.Name,Name);
2000-09-22 17:11:29 +02:00
TRACE1("New Layer [%s]\n",Name);
Layers.push_back(NewLayer);
}
/*****************************************************************************/
void CCore::LayerSetActive(int i)
{
}
/*****************************************************************************/
int CCore::LayerGetActive()
{
return(ActiveLayer);
}
/*****************************************************************************/
int CCore::LayerGetCount()
{
return(Layers.size());
}
/*****************************************************************************/
2000-09-25 17:43:52 +02:00
CLayer &CCore::LayerGet(int i)
2000-09-22 17:11:29 +02:00
{
return(Layers[i]);
}
/*****************************************************************************/
void CCore::LayerDelete(int Layer)
{
Layers.erase(Layers.begin() + Layer);
TRACE0("Delete Layer\n");
}
/*****************************************************************************/
void CCore::LayerMoveUp(int Layer)
{
2000-09-25 17:43:52 +02:00
CLayer Tmp;
2000-09-22 17:11:29 +02:00
Tmp=Layers[Layer];
Layers[Layer]=Layers[Layer-1];
Layers[Layer-1]=Tmp;
TRACE0("Layer Up \n");
}
/*****************************************************************************/
void CCore::LayerMoveDown(int Layer)
{
2000-09-25 17:43:52 +02:00
CLayer Tmp;
2000-09-22 17:11:29 +02:00
Tmp=Layers[Layer];
Layers[Layer]=Layers[Layer+1];
Layers[Layer+1]=Tmp;
TRACE0("Layer Down\n");
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/