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 <gl\glut.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)
|
|
|
|
ON_WM_SETFOCUS()
|
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-09-22 17:11:29 +02:00
|
|
|
//}}AFX_MSG_MAP
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CMapEditView construction/destruction
|
|
|
|
|
|
|
|
CMapEditView::CMapEditView()
|
|
|
|
{
|
2000-09-25 17:43:52 +02:00
|
|
|
CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
|
|
|
|
LayerBar=Frm->GetLayerBar();
|
|
|
|
|
2000-09-22 17:11:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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-09-22 23:19:46 +02:00
|
|
|
c=THOUSANDS; // ask for 65355 colors...
|
|
|
|
z=NORMAL; // ...16 bit Z-buffer...
|
|
|
|
dbuf=TRUE; // ...double-buffering
|
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-09-22 23:19:46 +02:00
|
|
|
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
|
|
|
|
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
|
|
|
|
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
|
|
|
|
glClearDepth(1.0f); // Depth Buffer Setup
|
|
|
|
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
|
|
|
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
|
|
|
|
glEnable(GL_LIGHT0); // Quick And Dirty Lighting (Assumes Light0 Is SetUp)
|
|
|
|
glEnable(GL_LIGHTING); // Enable Lighting
|
|
|
|
glEnable(GL_COLOR_MATERIAL); // Enable Material Coloring
|
|
|
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
|
|
|
|
|
2000-09-25 17:43:52 +02:00
|
|
|
Core.Init(this);
|
2000-09-22 23:19:46 +02:00
|
|
|
|
2000-09-22 17:11:29 +02:00
|
|
|
}
|
|
|
|
|
2000-09-22 23:19:46 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
void CMapEditView::OnDrawGL()
|
2000-09-22 17:11:29 +02:00
|
|
|
{
|
2000-09-25 17:43:52 +02:00
|
|
|
Core.Render();
|
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
|
|
|
|
|
|
|
|
void CMapEditView::OnSetFocus(CWnd* pOldWnd)
|
|
|
|
{
|
|
|
|
CMapEditDoc *CurDoc=GetDocument();
|
2000-09-22 18:56:20 +02:00
|
|
|
CGLEnabledView::OnSetFocus(pOldWnd);
|
2000-09-22 17:11:29 +02:00
|
|
|
theApp.SetCurrent(CurDoc);
|
2000-09-25 17:43:52 +02:00
|
|
|
UpdateAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
|
|
|
/*********************************************************************************/
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditView::UpdateAll()
|
|
|
|
{
|
|
|
|
UpdateLayerBar();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-22 23:19:46 +02:00
|
|
|
/*********************************************************************************/
|
2000-09-25 17:43:52 +02:00
|
|
|
void CMapEditView::UpdateLayerBar()
|
|
|
|
{
|
|
|
|
CListBox *Dlg=(CListBox *)LayerBar->GetDlgItem(IDC_LAYERBAR_LIST);
|
|
|
|
int CurSel=Dlg->GetCurSel();
|
|
|
|
|
|
|
|
Dlg->ResetContent();
|
|
|
|
|
2000-10-25 20:28:44 +02:00
|
|
|
for (int i=0;i<LAYER_TYPE_MAX;i++)
|
2000-09-25 17:43:52 +02:00
|
|
|
{
|
2000-10-25 20:28:44 +02:00
|
|
|
CLayer *ThisLayer=Core.LayerGet(i);
|
|
|
|
Dlg->AddString(ThisLayer->GetName());
|
2000-09-25 17:43:52 +02:00
|
|
|
}
|
|
|
|
Dlg->SetCurSel(CurSel);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-22 23:19:46 +02:00
|
|
|
/*********************************************************************************/
|
2000-09-25 17:43:52 +02:00
|
|
|
int CMapEditView::GetLayerCurSel()
|
|
|
|
{
|
|
|
|
CListBox *Dlg=(CListBox *)LayerBar->GetDlgItem(IDC_LAYERBAR_LIST);
|
|
|
|
return(Dlg->GetCurSel());
|
2000-09-22 23:19:46 +02:00
|
|
|
|
2000-09-25 17:43:52 +02:00
|
|
|
}
|
2000-09-22 23:19:46 +02:00
|
|
|
|
|
|
|
/*********************************************************************************/
|
2000-09-25 17:43:52 +02:00
|
|
|
int CMapEditView::GetLayerCount()
|
|
|
|
{
|
|
|
|
CListBox *Dlg=(CListBox *)LayerBar->GetDlgItem(IDC_LAYERBAR_LIST);
|
|
|
|
return(Dlg->GetCount());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
|
|
|
/*********************************************************************************/
|
|
|
|
/*********************************************************************************/
|
|
|
|
void CMapEditView::OnLButtonDown(UINT nFlags, CPoint point) {Core.LButtonControl(nFlags,point,TRUE);}
|
|
|
|
void CMapEditView::OnLButtonUp(UINT nFlags, CPoint point) {Core.LButtonControl(nFlags,point,FALSE);}
|
|
|
|
void CMapEditView::OnMButtonDown(UINT nFlags, CPoint point) {Core.MButtonControl(nFlags,point,TRUE);}
|
|
|
|
void CMapEditView::OnMButtonUp(UINT nFlags, CPoint point) {Core.MButtonControl(nFlags,point,FALSE);}
|
|
|
|
BOOL CMapEditView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) {Core.MouseWheel(nFlags,zDelta,pt) ;return(0);}
|
|
|
|
void CMapEditView::OnRButtonDown(UINT nFlags, CPoint point) {Core.RButtonControl(nFlags,point,TRUE);}
|
|
|
|
void CMapEditView::OnRButtonUp(UINT nFlags, CPoint point) {Core.RButtonControl(nFlags,point,FALSE);}
|
2000-10-25 20:28:44 +02:00
|
|
|
void CMapEditView::OnMouseMove(UINT nFlags, CPoint point) {Core.MouseMove(nFlags, point);}
|
2000-09-25 17:43:52 +02:00
|
|
|
|
|
|
|
|