SBSPSS/Utils/MapEdit/MapEditView.cpp

175 lines
5.8 KiB
C++
Raw Normal View History

2000-09-22 17:11:29 +02:00
// MapEditView.cpp : implementation of the CMapEditView class
//
2000-09-22 18:56:20 +02:00
#include "stdafx.h"
#include <gl\gl.h>
#include <gl\glu.h>
#include "GLEnabledView.h"
#include "MapEdit.h"
#include "MapEditDoc.h"
#include "MapEditView.h"
2000-09-25 17:43:52 +02:00
#include "MainFrm.h"
2000-09-22 17:11:29 +02:00
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMapEditView
2000-09-22 18:56:20 +02:00
IMPLEMENT_DYNCREATE(CMapEditView, CGLEnabledView)
2000-09-22 17:11:29 +02:00
2000-09-22 18:56:20 +02:00
BEGIN_MESSAGE_MAP(CMapEditView, CGLEnabledView)
2000-09-22 17:11:29 +02:00
//{{AFX_MSG_MAP(CMapEditView)
2000-09-22 23:19:46 +02:00
ON_WM_LBUTTONUP()
ON_WM_LBUTTONDOWN()
ON_WM_MBUTTONDOWN()
ON_WM_MBUTTONUP()
ON_WM_MOUSEWHEEL()
ON_WM_RBUTTONDOWN()
ON_WM_RBUTTONUP()
2000-09-25 17:43:52 +02:00
ON_WM_MOUSEMOVE()
2000-11-17 00:08:54 +01:00
ON_COMMAND(ID_TOGGLE_TILEVIEW, OnToggleTileview)
ON_COMMAND(ID_TOOLBAR_GRID, OnToggleGrid)
ON_COMMAND(ID_MIRRORX, OnMirrorx)
ON_COMMAND(ID_MIRRORY, OnMirrory)
2000-11-17 22:36:13 +01:00
ON_COMMAND(ID_ACTIVEBRUSH_LEFT, OnActivebrushLeft)
ON_COMMAND(ID_ACTIVEBRUSH_RIGHT, OnActivebrushRight)
2000-11-22 23:08:47 +01:00
ON_COMMAND(ID_MAP_SETSIZE, OnMapSetSize)
2000-12-11 22:52:32 +01:00
ON_COMMAND(ID_2D_3D_TOGGLE, On2d3dToggle)
2001-01-02 15:34:02 +01:00
ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
2001-02-09 22:17:01 +01:00
ON_COMMAND(ID_TOOLBAR_TILEPALETTE, OnToggleTileview)
ON_COMMAND(ID_TOGGLE_GRID, OnToggleGrid)
2000-09-22 17:11:29 +02:00
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMapEditView construction/destruction
CMapEditView::CMapEditView()
{
}
CMapEditView::~CMapEditView()
{
}
/////////////////////////////////////////////////////////////////////////////
2000-09-22 23:19:46 +02:00
void CMapEditView::VideoMode(ColorsNumber & c, ZAccuracy & z, BOOL & dbuf)
2000-09-22 17:11:29 +02:00
{
2000-12-29 23:20:38 +01:00
c=MILLIONS;
z=NORMAL;
dbuf=TRUE;
2000-09-22 17:11:29 +02:00
}
2000-09-22 23:19:46 +02:00
/////////////////////////////////////////////////////////////////////////////
void CMapEditView::OnCreateGL()
2000-09-22 17:11:29 +02:00
{
2000-11-17 22:36:13 +01:00
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Background Color
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
2000-11-28 00:07:07 +01:00
glEnable(GL_BLEND); // Enable Alpha Channel
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Alpha Blend Style
2000-09-22 17:11:29 +02:00
}
2000-11-03 23:40:41 +01:00
2000-10-30 22:16:48 +01:00
/////////////////////////////////////////////////////////////////////////////
2000-11-06 21:24:11 +01:00
2000-09-22 23:19:46 +02:00
void CMapEditView::OnDrawGL()
2000-09-22 17:11:29 +02:00
{
2000-11-06 21:24:11 +01:00
GetDocument()->Render(this);
2000-09-22 17:11:29 +02:00
}
2000-11-03 23:40:41 +01:00
/////////////////////////////////////////////////////////////////////////////
void CMapEditView::OnSizeGL(int cx, int cy)
{
2000-12-29 23:20:38 +01:00
// cy=cx/1.5f;
2000-11-03 23:40:41 +01:00
glViewport(0,0,cx,cy);
2000-11-28 00:07:07 +01:00
2000-11-03 23:40:41 +01:00
// update the camera
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
SetupPersMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
2000-11-06 21:24:11 +01:00
GetDocument()->UpdateView(this);
2000-11-03 23:40:41 +01:00
}
/////////////////////////////////////////////////////////////////////////////
2000-11-06 21:24:11 +01:00
void CMapEditView::SetupPersMatrix()
2000-11-03 23:40:41 +01:00
{
2000-11-28 00:07:07 +01:00
gluPerspective(40.0,m_dAspectRatio,0.1f, 100.0f);
2000-12-29 23:20:38 +01:00
glTranslatef(0.0f,0.0f,-1.f);
2000-11-03 23:40:41 +01:00
}
2000-11-06 21:24:11 +01:00
2000-09-22 17:11:29 +02:00
/////////////////////////////////////////////////////////////////////////////
// CMapEditView diagnostics
#ifdef _DEBUG
void CMapEditView::AssertValid() const
{
2000-09-22 18:56:20 +02:00
CGLEnabledView::AssertValid();
2000-09-22 17:11:29 +02:00
}
void CMapEditView::Dump(CDumpContext& dc) const
{
2000-09-22 18:56:20 +02:00
CGLEnabledView::Dump(dc);
2000-09-22 17:11:29 +02:00
}
CMapEditDoc* CMapEditView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMapEditDoc)));
return (CMapEditDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMapEditView message handlers
2000-09-25 17:43:52 +02:00
/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
2000-11-06 21:24:11 +01:00
void CMapEditView::OnLButtonDown(UINT nFlags, CPoint point) {GetDocument()->LButtonControl(this,nFlags,point,TRUE);}
void CMapEditView::OnLButtonUp(UINT nFlags, CPoint point) {GetDocument()->LButtonControl(this,nFlags,point,FALSE);}
void CMapEditView::OnMButtonDown(UINT nFlags, CPoint point) {GetDocument()->MButtonControl(this,nFlags,point,TRUE);}
void CMapEditView::OnMButtonUp(UINT nFlags, CPoint point) {GetDocument()->MButtonControl(this,nFlags,point,FALSE);}
BOOL CMapEditView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) {GetDocument()->MouseWheel(this,nFlags,zDelta,pt) ;return(0);}
void CMapEditView::OnRButtonDown(UINT nFlags, CPoint point) {GetDocument()->RButtonControl(this,nFlags,point,TRUE);}
void CMapEditView::OnRButtonUp(UINT nFlags, CPoint point) {GetDocument()->RButtonControl(this,nFlags,point,FALSE);}
void CMapEditView::OnMouseMove(UINT nFlags, CPoint point) {GetDocument()->MouseMove(this,nFlags, point);}
2000-11-17 00:08:54 +01:00
void CMapEditView::OnToggleTileview() {GetDocument()->ToggleTileView(this);}
void CMapEditView::OnToggleGrid() {GetDocument()->ToggleGrid(this);}
2000-11-20 17:21:43 +01:00
void CMapEditView::OnMirrorx() {GetDocument()->MirrorX(this);}
void CMapEditView::OnMirrory() {GetDocument()->MirrorY(this);}
2001-01-02 15:34:02 +01:00
void CMapEditView::OnEditCopy() {GetDocument()->CopySelection(this);}
void CMapEditView::OnEditPaste() {GetDocument()->PasteSelection(this);}
2000-11-20 17:21:43 +01:00
void CMapEditView::OnActivebrushLeft() {GetDocument()->ActiveBrushLeft(this);}
void CMapEditView::OnActivebrushRight() {GetDocument()->ActiveBrushRight(this);}
2000-11-17 22:36:13 +01:00
2000-11-20 17:21:43 +01:00
void CMapEditView::OnMapSetSize() {GetDocument()->MapSetSize(this);}
2000-11-22 23:08:47 +01:00
void CMapEditView::On2d3dToggle() {GetDocument()->Toggle2d3d(this);}
2001-02-09 22:17:01 +01:00
void CMapEditView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
CGLEnabledView::OnActivateView(bActivate, pActivateView, pDeactiveView);
if (bActivate)
{
CMapEditDoc *CurDoc=GetDocument();
theApp.SetCurrent(CurDoc);
2001-02-10 21:21:20 +01:00
CurDoc->SetView(this);
2001-02-09 22:17:01 +01:00
CurDoc->UpdateAll(this);
}
}