This commit is contained in:
parent
17b863e4be
commit
9be320207d
12 changed files with 308 additions and 202 deletions
|
@ -30,37 +30,25 @@ BOOL Test3dFlag=TRUE;
|
|||
/*****************************************************************************/
|
||||
CCore::CCore()
|
||||
{
|
||||
/*
|
||||
Layers[LAYER_TYPE_BACK]= new CLayerBack(this);
|
||||
Layers[LAYER_TYPE_MID]= new CLayerMid(this);
|
||||
Layers[LAYER_TYPE_ACTION]= new CLayerAction(this);
|
||||
Layers[LAYER_TYPE_FORE]= new CLayerFore(this);
|
||||
|
||||
TileViewFlag=0;
|
||||
LayerViewFlag=1;
|
||||
*/
|
||||
for (int i=0; i<LAYER_TYPE_MAX; i++) Layers[i]=0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
CCore::~CCore()
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<LAYER_TYPE_MAX; i++) delete Layers[i];
|
||||
for (int i=0; i<LAYER_TYPE_MAX; i++) if (Layers[i]) delete Layers[i];
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::Init(CMapEditView *Wnd)
|
||||
void CCore::NewMap()
|
||||
{
|
||||
ParentWindow=Wnd;
|
||||
|
||||
RenderFlag=TRUE;
|
||||
UpdateView();
|
||||
|
||||
// To be loaded/created
|
||||
Layers[LAYER_TYPE_BACK]= new CLayerBack(this);
|
||||
Layers[LAYER_TYPE_MID]= new CLayerMid(this);
|
||||
Layers[LAYER_TYPE_ACTION]= new CLayerAction(this);
|
||||
Layers[LAYER_TYPE_FORE]= new CLayerFore(this);
|
||||
Layers[LAYER_TYPE_BACK]= new CLayerBack();
|
||||
Layers[LAYER_TYPE_MID]= new CLayerMid();
|
||||
Layers[LAYER_TYPE_ACTION]= new CLayerAction();
|
||||
Layers[LAYER_TYPE_FORE]= new CLayerFore();
|
||||
|
||||
TileViewFlag=0;
|
||||
LayerViewFlag=1;
|
||||
|
@ -68,20 +56,27 @@ void CCore::Init(CMapEditView *Wnd)
|
|||
ActiveLayer=LAYER_TYPE_ACTION;
|
||||
MapCam=Vec(0,0,0);
|
||||
TileCam=Vec(0,0,0);
|
||||
TileSet.push_back(CTileSet("c:/temp/3/test.gin",this));
|
||||
TileBank.AddTileSet("c:/temp/3/test.gin");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::OpenMap()
|
||||
{
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
void CCore::Render()
|
||||
void CCore::Render(CMapEditView *View)
|
||||
{
|
||||
Vec &ThisCam=GetCam();
|
||||
|
||||
if (TileBank.NeedLoad()) TileBank.LoadTileSets(this);
|
||||
|
||||
if (RenderFlag)
|
||||
{
|
||||
RenderFlag=FALSE;
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen
|
||||
if (GetTileView())
|
||||
{
|
||||
|
||||
|
@ -90,52 +85,51 @@ Vec &ThisCam=GetCam();
|
|||
{
|
||||
for (int i=0;i<LAYER_TYPE_MAX;i++)
|
||||
{
|
||||
Layers[i]->Render(ThisCam,Test3dFlag);
|
||||
Layers[i]->Render(this,ThisCam,Test3dFlag);
|
||||
}
|
||||
}
|
||||
Layers[ActiveLayer]->RenderGrid(ThisCam);
|
||||
Layers[ActiveLayer]->RenderGrid(this,ThisCam);
|
||||
}
|
||||
// Calc CursorPos
|
||||
Layers[ActiveLayer]->FindCursorPos(ThisCam,CurrentMousePos);
|
||||
Layers[ActiveLayer]->FindCursorPos(this,View,ThisCam,CurrentMousePos);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Control *****************************************************************/
|
||||
/*****************************************************************************/
|
||||
void CCore::LButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
|
||||
void CCore::LButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag)
|
||||
{
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::MButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
|
||||
void CCore::MButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag)
|
||||
{
|
||||
LastMousePos=point;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::RButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
|
||||
void CCore::RButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag)
|
||||
{
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::MouseWheel(UINT nFlags, short zDelta, CPoint &pt)
|
||||
void CCore::MouseWheel(CMapEditView *View,UINT nFlags, short zDelta, CPoint &pt)
|
||||
{
|
||||
if (zDelta>0)
|
||||
UpdateView(Vec(0,0,1.0f));
|
||||
UpdateView(View,Vec(0,0,1.0f));
|
||||
else
|
||||
UpdateView(Vec(0,0,-1.0f));
|
||||
UpdateView(View,Vec(0,0,-1.0f));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::MouseMove(UINT nFlags, CPoint &point)
|
||||
void CCore::MouseMove(CMapEditView *View,UINT nFlags, CPoint &point)
|
||||
{
|
||||
Vec Ofs(0,0,0);
|
||||
|
||||
Vec &ThisCam=GetCam();
|
||||
// check if active doc
|
||||
if (theApp.GetCurrent()!=ParentWindow->GetDocument()) return;
|
||||
if (theApp.GetCurrent()!=View->GetDocument()) return;
|
||||
|
||||
CurrentMousePos=point;
|
||||
|
||||
|
@ -145,7 +139,7 @@ Vec &ThisCam=GetCam();
|
|||
float XS,YS;
|
||||
RECT ThisRect;
|
||||
|
||||
ParentWindow->GetWindowRect(&ThisRect);
|
||||
View->GetWindowRect(&ThisRect);
|
||||
XS=ThisCam.z*4;//*Layers[ActiveLayer]->GetLayerZPos();
|
||||
YS=ThisCam.z*4;//*Layers[ActiveLayer]->GetLayerZPos();
|
||||
XS/=((ThisRect.right-ThisRect.left));
|
||||
|
@ -158,17 +152,19 @@ Vec &ThisCam=GetCam();
|
|||
Ofs.x*=XS;
|
||||
Ofs.y*=YS;
|
||||
|
||||
UpdateView(Ofs);
|
||||
UpdateView(View,Ofs);
|
||||
}
|
||||
else
|
||||
{ // Mouse still moved, so need to redraw windows, to get CursorPos (And pos render)
|
||||
View->Invalidate();
|
||||
}
|
||||
// Mouse has moved, so need to redraw windows, to get CursorPos (And pos render)
|
||||
ParentWindow->Invalidate();
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Layers ******************************************************************/
|
||||
/*****************************************************************************/
|
||||
void CCore::UpdateLayerBar(BOOL ViewFlag)
|
||||
void CCore::UpdateLayerBar(CMapEditView *View,BOOL ViewFlag)
|
||||
{
|
||||
CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
|
||||
CToolBar *ToolBar=Frm->GetToolBar();
|
||||
|
@ -192,31 +188,39 @@ CListBox *Dlg=(CListBox *)LayerBar->GetDlgItem(IDC_LAYERBAR_LIST);
|
|||
Frm->ShowControlBar(LayerBar, LayerViewFlag, FALSE);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::ToggleLayerView(CMapEditView *View)
|
||||
{
|
||||
UpdateLayerBar(View,!LayerViewFlag);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::SetActiveLayer(int i)
|
||||
{
|
||||
UpdateLayerBar(LayerViewFlag);
|
||||
UpdateLayerBar(NULL,LayerViewFlag);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** TileBank ****************************************************************/
|
||||
/*****************************************************************************/
|
||||
void CCore::UpdateTileView(BOOL ViewFlag)
|
||||
/*****************************************************************************/
|
||||
void CCore::UpdateTileView(CMapEditView *View,BOOL ViewFlag)
|
||||
{
|
||||
CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
|
||||
CToolBar *ToolBar=Frm->GetToolBar();
|
||||
|
||||
TileViewFlag=ViewFlag;
|
||||
ToolBar->GetToolBarCtrl().PressButton(ID_TOOLBAR_TILEPALETTE,TileViewFlag);
|
||||
UpdateView();
|
||||
UpdateView(View);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
GLint CCore::GetTile(int Bank,int TileNo)
|
||||
void CCore::ToggleTileView(CMapEditView *View)
|
||||
{
|
||||
return(TileSet[Bank].GetTile(TileNo));
|
||||
UpdateTileView(View,!TileViewFlag);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Misc ********************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -230,28 +234,21 @@ Vec &CCore::GetCam()
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::UpdateAll()
|
||||
void CCore::UpdateAll(CMapEditView *View)
|
||||
{
|
||||
UpdateView();
|
||||
UpdateLayerBar(LayerViewFlag);
|
||||
UpdateTileView(TileViewFlag);
|
||||
UpdateView(View);
|
||||
UpdateLayerBar(View,LayerViewFlag);
|
||||
UpdateTileView(View,TileViewFlag);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::Redraw(BOOL f)
|
||||
{
|
||||
RenderFlag=f;
|
||||
if (RenderFlag)
|
||||
ParentWindow->Invalidate();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::UpdateView(Vec Ofs)
|
||||
void CCore::UpdateView(CMapEditView *View,Vec Ofs)
|
||||
{
|
||||
Vec &ThisCam=GetCam();
|
||||
|
||||
Ofs.y=-Ofs.y;
|
||||
ThisCam+=Ofs;
|
||||
if (ThisCam.z>-1) ThisCam.z=-1;
|
||||
Redraw();
|
||||
RenderFlag=TRUE;
|
||||
View->Invalidate();
|
||||
}
|
||||
|
|
|
@ -23,27 +23,29 @@ public:
|
|||
CCore();
|
||||
~CCore();
|
||||
|
||||
void Init(CMapEditView *Wnd);
|
||||
void Render();
|
||||
void Init();
|
||||
void NewMap();
|
||||
void OpenMap();
|
||||
void Render(CMapEditView *View);
|
||||
|
||||
// Control
|
||||
void LButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag);
|
||||
void MButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag);
|
||||
void RButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag);
|
||||
void MouseWheel(UINT nFlags, short zDelta, CPoint &pt);
|
||||
void MouseMove(UINT nFlags, CPoint &point);
|
||||
void LButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
|
||||
void MButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
|
||||
void RButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
|
||||
void MouseWheel(CMapEditView *View,UINT nFlags, short zDelta, CPoint &pt);
|
||||
void MouseMove(CMapEditView *View,UINT nFlags, CPoint &point);
|
||||
|
||||
// TileBank
|
||||
void UpdateTileView(BOOL ViewFlag);
|
||||
void UpdateTileView(CMapEditView *View,BOOL ViewFlag);
|
||||
void ToggleTileView(CMapEditView *View);
|
||||
BOOL GetTileView() {return(TileViewFlag);}
|
||||
void ToggleTileView() {UpdateTileView(!TileViewFlag);}
|
||||
|
||||
GLint GetTile(int Bank,int TileNo);
|
||||
CTile GetTile(int Bank,int TileNo) {return(TileBank.GetTile(Bank,TileNo));}
|
||||
|
||||
// Layers
|
||||
void UpdateLayerBar(BOOL ViewFlag);
|
||||
void UpdateLayerBar(CMapEditView *View,BOOL ViewFlag);
|
||||
void ToggleLayerView(CMapEditView *View);
|
||||
BOOL GetLayerViewFlag() {return(LayerViewFlag);}
|
||||
void ToggleLayerView() {UpdateLayerBar(!LayerViewFlag);}
|
||||
|
||||
void SetActiveLayer(int Layer);
|
||||
int GetActiveLayer() {return(ActiveLayer);}
|
||||
|
@ -53,17 +55,13 @@ public:
|
|||
CTexCache &GetTexCache() {return(TexCache);}
|
||||
|
||||
// Misc
|
||||
void UpdateAll();
|
||||
void UpdateView(Vec Ofs=Vec(0,0,0));
|
||||
void UpdateAll(CMapEditView *View);
|
||||
void UpdateView(CMapEditView *View,Vec Ofs=Vec(0,0,0));
|
||||
|
||||
Vec &GetCam();
|
||||
void SetCursorPos(CPoint &Pos) {CursorPos=Pos;}
|
||||
CPoint &GetCursorPos() {return(CursorPos);}
|
||||
CMapEditView *GetParentWindow() {return(ParentWindow);}
|
||||
void Redraw(BOOL f=TRUE);
|
||||
|
||||
private:
|
||||
CMapEditView *ParentWindow;
|
||||
CPoint CurrentMousePos,LastMousePos;
|
||||
CPoint CursorPos,LastCursorPos;
|
||||
Vec MapCam,TileCam;
|
||||
|
@ -71,14 +69,14 @@ private:
|
|||
CLayer *Layers[LAYER_TYPE_MAX];
|
||||
int ActiveLayer;
|
||||
|
||||
std::vector<CTileSet> TileSet;
|
||||
// std::vector<CTileSet> TileSet;
|
||||
CTileBank TileBank;
|
||||
CTexCache TexCache;
|
||||
|
||||
BOOL RenderFlag;
|
||||
BOOL TileViewFlag;
|
||||
BOOL LayerViewFlag;
|
||||
|
||||
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
CLayer::CLayer(CCore *_Core)
|
||||
CLayer::CLayer()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -31,23 +31,13 @@ CLayer::~CLayer()
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayer::InitLayer(CCore *_Core)
|
||||
void CLayer::Render(CCore *Core,Vec &MapPos,BOOL Is3d)
|
||||
{
|
||||
int Width=Map.GetWidth();
|
||||
int Height=Map.GetHeight();
|
||||
|
||||
Core=_Core;
|
||||
TRACE3("%i x %i = %i\t",Width,Height,Width*Height);
|
||||
Render2d(Core,MapPos);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayer::Render(Vec &MapPos,BOOL Is3d)
|
||||
{
|
||||
Render2d(MapPos);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayer::Render2d(Vec &MapPos)
|
||||
void CLayer::Render2d(CCore *Core,Vec &MapPos)
|
||||
{
|
||||
float XYDiv=GetLayerZPosDiv();
|
||||
return;
|
||||
|
@ -69,13 +59,14 @@ int Height=Map.GetHeight();
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayer::Render3d(Vec &MapPos)
|
||||
void CLayer::Render3d(CCore *Core,Vec &MapPos)
|
||||
{
|
||||
float XYDiv=GetLayerZPosDiv();
|
||||
int MapW=Map.GetWidth();
|
||||
int MapH=Map.GetHeight();
|
||||
float StartX=MapPos.x/XYDiv;
|
||||
float StartY=MapPos.y/XYDiv;
|
||||
CTexCache &TexCache=Core->GetTexCache();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
|
@ -83,18 +74,19 @@ float StartY=MapPos.y/XYDiv;
|
|||
{
|
||||
for (int XLoop=0; XLoop<MapW; XLoop++)
|
||||
{
|
||||
sMapElem &ThisTile=Map.GetTile(XLoop,YLoop);
|
||||
sMapElem &ThisElem=Map.GetTile(XLoop,YLoop);
|
||||
CTile &ThisTile=Core->GetTile(ThisElem.Bank,ThisElem.Tile);
|
||||
|
||||
glLoadIdentity(); // Slow way, but good to go for the mo
|
||||
glTranslatef(StartX+XLoop,StartY-YLoop,MapPos.z);
|
||||
glCallList(Core->GetTile(ThisTile.Bank,ThisTile.Tile));
|
||||
ThisTile.Render();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayer::RenderGrid(Vec &MapPos)
|
||||
void CLayer::RenderGrid(CCore *Core,Vec &MapPos)
|
||||
{
|
||||
float XYDiv=GetLayerZPosDiv();
|
||||
int MapW=Map.GetWidth();
|
||||
|
@ -129,7 +121,7 @@ float OverVal=0.5;
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayer::FindCursorPos(Vec &MapPos,CPoint &MousePos)
|
||||
void CLayer::FindCursorPos(CCore *Core,CMapEditView *View,Vec &MapPos,CPoint &MousePos)
|
||||
{
|
||||
GLint Viewport[4];
|
||||
GLuint SelectBuffer[SELECT_BUFFER_SIZE];
|
||||
|
@ -154,7 +146,7 @@ float StartY=MapPos.y/XYDiv;
|
|||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
gluPickMatrix( MousePos.x ,(Viewport[3]-MousePos.y),5.0,5.0,Viewport);
|
||||
Core->GetParentWindow()->SetupPersMatrix();
|
||||
View->SetupPersMatrix();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
|
|
@ -30,31 +30,27 @@ enum LAYER_TYPE
|
|||
/*****************************************************************************/
|
||||
class CCore;
|
||||
class CMap;
|
||||
class CMapEditView;
|
||||
class CLayer
|
||||
{
|
||||
public:
|
||||
CLayer(){ASSERT(1);}
|
||||
CLayer(CCore *_Core);
|
||||
CLayer();
|
||||
~CLayer();
|
||||
|
||||
void InitLayer(CCore *_Core);
|
||||
|
||||
// Virtual
|
||||
virtual void Init()=0;
|
||||
virtual char *GetName()=0;
|
||||
virtual void Render(Vec &MapPos,BOOL Is3d);
|
||||
virtual void Render2d(Vec &MapPos);
|
||||
virtual void Render3d(Vec &MapPos);
|
||||
virtual void RenderGrid(Vec &MapPos);
|
||||
virtual void Render(CCore *Core,Vec &MapPos,BOOL Is3d);
|
||||
virtual void Render2d(CCore *Core,Vec &MapPos);
|
||||
virtual void Render3d(CCore *Core,Vec &MapPos);
|
||||
virtual void RenderGrid(CCore *Core,Vec &MapPos);
|
||||
|
||||
virtual float GetLayerZPosDiv()=0;
|
||||
virtual BOOL CanRender3d()=0;
|
||||
|
||||
virtual void FindCursorPos(Vec &MapPos,CPoint &MousePos);
|
||||
virtual void FindCursorPos(CCore *Core,CMapEditView *View,Vec &MapPos,CPoint &MousePos);
|
||||
|
||||
protected:
|
||||
|
||||
CCore *Core;
|
||||
CMap Map;
|
||||
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[General Info]
|
||||
Version=1
|
||||
LastClass=CMapEditDoc
|
||||
LastClass=CMapEditView
|
||||
LastTemplate=CFrameWnd
|
||||
NewFileInclude1=#include "stdafx.h"
|
||||
NewFileInclude2=#include "mapedit.h"
|
||||
|
@ -84,7 +84,7 @@ Type=0
|
|||
BaseClass=CGLEnabledView
|
||||
HeaderFile=MapEditView.h
|
||||
ImplementationFile=MapEditView.cpp
|
||||
LastObject=CMapEditView
|
||||
LastObject=ID_TOOLBAR_LAYERBAR
|
||||
Filter=C
|
||||
VirtualFilter=VWC
|
||||
|
||||
|
|
|
@ -95,8 +95,8 @@ BOOL CMapEditApp::InitInstance()
|
|||
// Parse command line for standard shell commands, DDE, file open
|
||||
CCommandLineInfo cmdInfo;
|
||||
ParseCommandLine(cmdInfo);
|
||||
// Prevent creating new doc on startup (should still open cmd line file tho
|
||||
if (cmdInfo.m_nShellCommand==CCommandLineInfo::FileNew) cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing;
|
||||
// Prevent creating new doc on startup (should still open cmd line file tho)
|
||||
// if (cmdInfo.m_nShellCommand==CCommandLineInfo::FileNew) cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing;
|
||||
|
||||
// Dispatch commands specified on the command line
|
||||
if (!ProcessShellCommand(cmdInfo)) return FALSE;
|
||||
|
|
|
@ -19,6 +19,7 @@ IMPLEMENT_DYNCREATE(CMapEditDoc, CDocument)
|
|||
|
||||
BEGIN_MESSAGE_MAP(CMapEditDoc, CDocument)
|
||||
//{{AFX_MSG_MAP(CMapEditDoc)
|
||||
ON_UPDATE_COMMAND_UI(ID_INDICATOR_CURSORXY, OnStatusCursorXY)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
@ -35,12 +36,9 @@ CMapEditDoc::~CMapEditDoc()
|
|||
|
||||
BOOL CMapEditDoc::OnNewDocument()
|
||||
{
|
||||
if (!CDocument::OnNewDocument())
|
||||
return FALSE;
|
||||
if (!CDocument::OnNewDocument()) return FALSE;
|
||||
TRACE0("New Doc\n");
|
||||
|
||||
// TODO: add reinitialization code here
|
||||
// (SDI documents will reuse this document)
|
||||
Core.NewMap();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -52,20 +50,18 @@ BOOL CMapEditDoc::OnOpenDocument(LPCTSTR lpszPathName)
|
|||
|
||||
TRACE1("Load Doc %s\n",lpszPathName);
|
||||
|
||||
// TODO: Add your specialized creation code here
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMapEditDoc serialization
|
||||
|
||||
void CMapEditDoc::Serialize(CArchive& ar)
|
||||
{
|
||||
if (ar.IsStoring())
|
||||
{
|
||||
// TODO: add storing code here
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -87,3 +83,83 @@ void CMapEditDoc::Dump(CDumpContext& dc) const
|
|||
CDocument::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/*********************************************************************************/
|
||||
/*********************************************************************************/
|
||||
/*********************************************************************************/
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::UpdateView(CMapEditView *View)
|
||||
{
|
||||
Core.UpdateView(View);
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::Render(CMapEditView *View)
|
||||
{
|
||||
Core.Render(View);
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::UpdateAll(CMapEditView *View)
|
||||
{
|
||||
Core.UpdateAll(View);
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::OnStatusCursorXY(CCmdUI *pCmdUI)
|
||||
{
|
||||
|
||||
CPoint &XY=Core.GetCursorPos();
|
||||
CString XYStr;
|
||||
pCmdUI->Enable();
|
||||
if (XY.x!=-1 && XY.y!=-1)
|
||||
XYStr.Format( "%d\t%d", XY.x,XY.y);
|
||||
pCmdUI->SetText(XYStr);
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
/*********************************************************************************/
|
||||
/*** Windows Message Handlers ****************************************************/
|
||||
/*********************************************************************************/
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::LButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag)
|
||||
{
|
||||
Core.LButtonControl(View,nFlags,point,DownFlag);
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::MButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag)
|
||||
{
|
||||
Core.MButtonControl(View,nFlags,point,DownFlag);
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::RButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag)
|
||||
{
|
||||
Core.RButtonControl(View,nFlags,point,DownFlag);
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::MouseWheel(CMapEditView *View,UINT nFlags, short zDelta, CPoint &point)
|
||||
{
|
||||
Core.MouseWheel(View,nFlags,zDelta,point);
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::MouseMove(CMapEditView *View,UINT nFlags, CPoint &point)
|
||||
{
|
||||
Core.MouseMove(View,nFlags,point);
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::ToggleLayerView(CMapEditView *View)
|
||||
{
|
||||
Core.ToggleLayerView(View);
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::ToggleTileView(CMapEditView *View)
|
||||
{
|
||||
Core.ToggleTileView(View);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,19 @@ protected: // create from serialization only
|
|||
|
||||
// Attributes
|
||||
public:
|
||||
// void SetupPersMatrix(float _m_dAspectRatio);
|
||||
void UpdateView(CMapEditView *View);
|
||||
void Render(CMapEditView *View);
|
||||
void UpdateAll(CMapEditView *View);
|
||||
|
||||
// Windows Messages Thru Point
|
||||
void LButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
|
||||
void MButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
|
||||
void RButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
|
||||
void MouseWheel(CMapEditView *View,UINT nFlags, short zDelta, CPoint &pt);
|
||||
void MouseMove(CMapEditView *View,UINT nFlags, CPoint &point);
|
||||
void ToggleLayerView(CMapEditView *View);
|
||||
void ToggleTileView(CMapEditView *View);
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
@ -28,8 +41,8 @@ public:
|
|||
//{{AFX_VIRTUAL(CMapEditDoc)
|
||||
public:
|
||||
virtual BOOL OnNewDocument();
|
||||
virtual void Serialize(CArchive& ar);
|
||||
virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
|
||||
virtual void Serialize(CArchive& ar);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
|
@ -41,11 +54,11 @@ public:
|
|||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
CCore Core;
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CMapEditDoc)
|
||||
afx_msg void OnStatusCursorXY(CCmdUI *pCmdUI);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ BEGIN_MESSAGE_MAP(CMapEditView, CGLEnabledView)
|
|||
ON_WM_MOUSEMOVE()
|
||||
ON_COMMAND(ID_TOOLBAR_LAYERBAR, OnToolbarLayerbar)
|
||||
ON_COMMAND(ID_TOOLBAR_TILEPALETTE, OnToolbarTilepalette)
|
||||
ON_UPDATE_COMMAND_UI(ID_INDICATOR_CURSORXY, OnStatusCursorXY)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
@ -46,9 +45,6 @@ END_MESSAGE_MAP()
|
|||
|
||||
CMapEditView::CMapEditView()
|
||||
{
|
||||
//CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
|
||||
//CDialogBar *LayerBar=Frm->GetLayerBar();
|
||||
|
||||
}
|
||||
|
||||
CMapEditView::~CMapEditView()
|
||||
|
@ -76,16 +72,14 @@ void CMapEditView::OnCreateGL()
|
|||
glEnable(GL_LIGHTING); // Enable Lighting
|
||||
glEnable(GL_COLOR_MATERIAL); // Enable Material Coloring
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
|
||||
|
||||
Core.Init(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CMapEditView::OnDrawGL()
|
||||
{
|
||||
Core.Render();
|
||||
GetDocument()->Render(this);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -99,7 +93,7 @@ void CMapEditView::OnSizeGL(int cx, int cy)
|
|||
SetupPersMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
Core.Redraw();
|
||||
GetDocument()->UpdateView(this);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -107,9 +101,9 @@ void CMapEditView::SetupPersMatrix()
|
|||
{
|
||||
gluPerspective(40.0,m_dAspectRatio,0.1f, 100.0f);
|
||||
glTranslatef(0.0f,0.0f,-4.f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMapEditView diagnostics
|
||||
|
||||
|
@ -139,41 +133,19 @@ void CMapEditView::OnSetFocus(CWnd* pOldWnd)
|
|||
CMapEditDoc *CurDoc=GetDocument();
|
||||
CGLEnabledView::OnSetFocus(pOldWnd);
|
||||
theApp.SetCurrent(CurDoc);
|
||||
UpdateAll();
|
||||
CurDoc->UpdateAll(this);
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
/*********************************************************************************/
|
||||
/*********************************************************************************/
|
||||
void CMapEditView::UpdateAll()
|
||||
{
|
||||
Core.UpdateAll();
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
void CMapEditView::OnStatusCursorXY(CCmdUI *pCmdUI)
|
||||
{
|
||||
CPoint &XY=Core.GetCursorPos();
|
||||
CString XYStr;
|
||||
pCmdUI->Enable();
|
||||
if (XY.x!=-1 && XY.y!=-1)
|
||||
XYStr.Format( "%d\t%d", XY.x,XY.y);
|
||||
pCmdUI->SetText(XYStr);
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
/*********************************************************************************/
|
||||
/*********************************************************************************/
|
||||
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);}
|
||||
void CMapEditView::OnMouseMove(UINT nFlags, CPoint point) {Core.MouseMove(nFlags, point);}
|
||||
|
||||
void CMapEditView::OnToolbarLayerbar() {Core.ToggleLayerView();}
|
||||
void CMapEditView::OnToolbarTilepalette() {Core.ToggleTileView();}
|
||||
|
||||
|
||||
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);}
|
||||
void CMapEditView::OnToolbarLayerbar() {GetDocument()->ToggleLayerView(this);}
|
||||
void CMapEditView::OnToolbarTilepalette() {GetDocument()->ToggleTileView(this);}
|
||||
|
|
|
@ -39,11 +39,9 @@ public:
|
|||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
void UpdateAll();
|
||||
|
||||
protected:
|
||||
void VideoMode(ColorsNumber &c,ZAccuracy &z,BOOL &dbuf);
|
||||
CCore Core;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
|
@ -59,7 +57,6 @@ protected:
|
|||
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
||||
afx_msg void OnToolbarLayerbar();
|
||||
afx_msg void OnToolbarTilepalette();
|
||||
afx_msg void OnStatusCursorXY(CCmdUI *pCmdUI);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <gl\glut.h>
|
||||
#include <Vector>
|
||||
|
||||
#include "Core.h"
|
||||
#include "TileSet.h"
|
||||
#include "GinTex.h"
|
||||
#include "utils.h"
|
||||
|
@ -16,19 +17,63 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*** TileBank ****************************************************************/
|
||||
/*****************************************************************************/
|
||||
CTileSet::CTileSet(char *_Filename,CCore *Core)
|
||||
/*****************************************************************************/
|
||||
CTileBank::CTileBank()
|
||||
{
|
||||
LoadFlag=FALSE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
CTileBank::~CTileBank()
|
||||
{
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CTileBank::AddTileSet(char *Filename)
|
||||
{
|
||||
TileSet.push_back(CTileSet(Filename));
|
||||
LoadFlag=TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CTileBank::LoadTileSets(CCore *Core)
|
||||
{
|
||||
int ListSize=TileSet.size();
|
||||
|
||||
for (int i=0;i<ListSize;i++)
|
||||
{
|
||||
CTileSet &ThisSet=TileSet[i];
|
||||
|
||||
if (!ThisSet.IsLoaded()) ThisSet.Load(Core);
|
||||
}
|
||||
LoadFlag=FALSE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
CTile &CTileBank::GetTile(int Bank,int Tile)
|
||||
{
|
||||
return(TileSet[Bank].GetTile(Tile));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*** TileSet *****************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
CTileSet::CTileSet(char *_Filename)
|
||||
{
|
||||
char Drive[_MAX_DRIVE];
|
||||
char Dir[_MAX_DIR];
|
||||
char Fname[_MAX_FNAME];
|
||||
char Ext[_MAX_EXT];
|
||||
|
||||
sprintf(FullName,"%s",_Filename);
|
||||
_splitpath(_Filename,Drive,Dir,Fname,Ext);
|
||||
sprintf(Path,"%s%s",Drive,Dir);
|
||||
sprintf(Filename,"%s%s",Fname,Ext);
|
||||
|
||||
Load(Core,_Filename);
|
||||
Loaded=FALSE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -41,11 +86,11 @@ CTileSet::~CTileSet()
|
|||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
int CTileSet::Load(CCore *Core,char *_Filename)
|
||||
void CTileSet::Load(CCore *Core)
|
||||
{
|
||||
CScene Scene;
|
||||
|
||||
Scene.Load(_Filename);
|
||||
Scene.Load(FullName);
|
||||
|
||||
CNode &ThisNode=Scene.GetSceneNode(0);
|
||||
int ChildCount=ThisNode.GetPruneChildCount();
|
||||
|
@ -57,7 +102,7 @@ int ChildCount=ThisNode.GetPruneChildCount();
|
|||
Tile.push_back(NewTile);
|
||||
}
|
||||
|
||||
|
||||
return(1);
|
||||
Loaded=TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -14,28 +14,48 @@
|
|||
|
||||
#include "TexCache.h"
|
||||
#include "Tile.h"
|
||||
//#include "GinTex.h"
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
class CCore;
|
||||
class CTile;
|
||||
|
||||
/*****************************************************************************/
|
||||
class CTileBank
|
||||
{
|
||||
public:
|
||||
CTileBank();
|
||||
~CTileBank();
|
||||
|
||||
void AddTileSet(char *Filename);
|
||||
int NeedLoad() {return(LoadFlag);}
|
||||
void LoadTileSets(CCore *Core);
|
||||
CTile &GetTile(int Bank,int Tile);
|
||||
|
||||
private:
|
||||
std::vector<CTileSet> TileSet;
|
||||
BOOL LoadFlag;
|
||||
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
class CTileSet
|
||||
{
|
||||
public:
|
||||
CTileSet(char *_Filename,CCore *Core);
|
||||
CTileSet(char *_Filename);
|
||||
~CTileSet();
|
||||
|
||||
int Load(CCore *Core,char *_Filename);
|
||||
int IsLoaded() {return(Loaded);}
|
||||
void Load(CCore *Core);
|
||||
char *GetPath() {return(Path);}
|
||||
char *GetFilename() {return(Filename);}
|
||||
GLint GetTile(int No) {return(Tile[No].GetTile());}
|
||||
CTile &GetTile(int No) {return(Tile[No]);}
|
||||
|
||||
|
||||
private:
|
||||
char Path[256];
|
||||
char Filename[256];
|
||||
char FullName[256],Path[256],Filename[256];
|
||||
std::vector<CTile> Tile;
|
||||
BOOL Loaded;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue