2000-09-22 17:11:29 +02:00
|
|
|
/***********************/
|
|
|
|
/*** Map Editor Core ***/
|
|
|
|
/***********************/
|
|
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
2000-12-04 17:47:34 +01:00
|
|
|
#include <Vector3.h>
|
2000-09-22 23:19:46 +02:00
|
|
|
#include <gl\gl.h>
|
|
|
|
#include <gl\glu.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-10-31 23:37:59 +01:00
|
|
|
#include "MainFrm.h"
|
2000-09-22 23:19:46 +02:00
|
|
|
|
2000-11-28 22:16:00 +01:00
|
|
|
#include "NewMapGUI.h"
|
2001-01-23 22:53:48 +01:00
|
|
|
#include "AddLayerDlg.h"
|
2000-11-28 22:16:00 +01:00
|
|
|
|
2000-09-22 17:11:29 +02:00
|
|
|
#include "Core.h"
|
2000-09-25 17:43:52 +02:00
|
|
|
#include "Layer.h"
|
2000-11-07 21:38:19 +01:00
|
|
|
#include "LayerTile.h"
|
2001-01-23 22:53:48 +01:00
|
|
|
#include "LayerCollision.h"
|
2001-02-09 22:17:01 +01:00
|
|
|
#include "LayerShade.h"
|
2000-11-21 22:27:55 +01:00
|
|
|
#include "utils.h"
|
|
|
|
|
2001-02-01 23:48:22 +01:00
|
|
|
#include "Export.h"
|
2001-02-09 22:17:01 +01:00
|
|
|
#include "LayerList.h"
|
|
|
|
|
2001-02-16 19:23:01 +01:00
|
|
|
const Vector3 DefaultCamPos(0.0f,0.0f,0.9f);
|
|
|
|
|
2000-09-22 17:11:29 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
CCore::CCore()
|
|
|
|
{
|
2000-11-28 22:16:00 +01:00
|
|
|
CurrentMousePos=CPoint(0,0);
|
2001-03-01 18:28:20 +01:00
|
|
|
MapCam=DefaultCamPos;
|
|
|
|
TileCam=DefaultCamPos;
|
|
|
|
SpareFlag=false;
|
|
|
|
GridFlag=true;
|
|
|
|
Is3dFlag=true;
|
2001-02-14 23:35:47 +01:00
|
|
|
CurrentView=NULL;
|
2001-03-01 18:28:20 +01:00
|
|
|
CursorPos.x=CursorPos.y=0;
|
|
|
|
|
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-11-20 21:33:42 +01:00
|
|
|
int ListSize=Layer.size();
|
2000-11-28 22:16:00 +01:00
|
|
|
for (int i=0; i<ListSize; i++) delete Layer[i];
|
2000-09-22 17:11:29 +02:00
|
|
|
}
|
|
|
|
|
2000-09-22 23:19:46 +02:00
|
|
|
/*****************************************************************************/
|
2001-03-01 18:28:20 +01:00
|
|
|
bool CCore::New()
|
2000-09-22 23:19:46 +02:00
|
|
|
{
|
2000-11-28 22:16:00 +01:00
|
|
|
CNewMapGUI Dlg;
|
|
|
|
int Width,Height;
|
2000-11-30 23:17:55 +01:00
|
|
|
Dlg.m_Width=TileLayerMinWidth;
|
|
|
|
Dlg.m_Height=TileLayerMinHeight;
|
2000-11-28 22:16:00 +01:00
|
|
|
|
2001-01-21 19:04:00 +01:00
|
|
|
#ifndef _DEBUG
|
2000-11-28 22:16:00 +01:00
|
|
|
if (Dlg.DoModal()!=IDOK) return FALSE;
|
2001-01-21 19:04:00 +01:00
|
|
|
#endif
|
2000-11-28 22:16:00 +01:00
|
|
|
Width=Dlg.m_Width;
|
|
|
|
Height=Dlg.m_Height;
|
2000-11-04 19:24:51 +01:00
|
|
|
|
2000-11-28 22:16:00 +01:00
|
|
|
// Create Tile Layers
|
2001-02-09 22:17:01 +01:00
|
|
|
AddLayer(LAYER_TYPE_TILE,LAYER_SUBTYPE_ACTION, Width, Height);
|
2001-03-01 18:28:20 +01:00
|
|
|
// AddLayer(LAYER_TYPE_TILE,LAYER_SUBTYPE_SCRATCH, Width, Height);
|
|
|
|
|
|
|
|
for (int i=0; i<Layer.size(); i++)
|
|
|
|
{
|
|
|
|
Layer[i]->InitSubView(this);
|
|
|
|
}
|
|
|
|
|
2000-11-28 22:16:00 +01:00
|
|
|
|
2001-02-14 23:35:47 +01:00
|
|
|
ActiveLayer=FindLayer(LAYER_TYPE_TILE,LAYER_SUBTYPE_ACTION);
|
2001-03-01 18:28:20 +01:00
|
|
|
CurrentLayer=Layer[ActiveLayer];
|
2000-11-28 22:16:00 +01:00
|
|
|
return(TRUE);
|
2000-11-06 21:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2000-11-20 21:33:42 +01:00
|
|
|
void CCore::Load(CFile *File)
|
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
int Version,i;
|
|
|
|
BOOL F;
|
2000-11-20 21:33:42 +01:00
|
|
|
|
2001-01-23 22:53:48 +01:00
|
|
|
File->Read(&Version,sizeof(int));
|
|
|
|
if (Version>100000) Version=1; // Check fix for changing version to int from float
|
2000-11-20 21:33:42 +01:00
|
|
|
|
2001-01-23 22:53:48 +01:00
|
|
|
if (Version<FileVersion)
|
2000-11-28 22:16:00 +01:00
|
|
|
{
|
2001-01-23 22:53:48 +01:00
|
|
|
CString mexstr;
|
|
|
|
mexstr.Format("Old File Format\n\nPlease re-save\n");
|
|
|
|
AfxMessageBox(mexstr,MB_OK | MB_ICONEXCLAMATION);
|
2000-11-20 21:33:42 +01:00
|
|
|
|
2000-11-28 22:16:00 +01:00
|
|
|
}
|
2000-11-20 21:33:42 +01:00
|
|
|
|
2001-01-23 22:53:48 +01:00
|
|
|
TRACE1("Load Version %i\n",Version);
|
|
|
|
|
|
|
|
File->Read(&MapCam,sizeof(Vector3));
|
|
|
|
File->Read(&MapCamOfs,sizeof(Vector3));
|
|
|
|
File->Read(&TileCam,sizeof(Vector3));
|
|
|
|
File->Read(&TileCamOfs,sizeof(Vector3));
|
|
|
|
|
2001-03-01 18:28:20 +01:00
|
|
|
File->Read(&F,sizeof(BOOL)); SpareFlag=F!=0;
|
|
|
|
File->Read(&F,sizeof(BOOL)); GridFlag=F!=0;
|
|
|
|
File->Read(&F,sizeof(BOOL)); Is3dFlag=F!=0;
|
2000-11-20 21:33:42 +01:00
|
|
|
|
|
|
|
// Layers
|
|
|
|
int LayerCount;
|
|
|
|
File->Read(&LayerCount,sizeof(int));
|
|
|
|
File->Read(&ActiveLayer,sizeof(int));
|
|
|
|
|
2001-03-01 18:28:20 +01:00
|
|
|
for (i=0;i<LayerCount;i++)
|
2000-11-20 21:33:42 +01:00
|
|
|
{
|
|
|
|
int Type;
|
|
|
|
|
|
|
|
File->Read(&Type,sizeof(int));
|
|
|
|
switch (Type)
|
|
|
|
{
|
|
|
|
case LAYER_TYPE_TILE:
|
2001-01-23 22:53:48 +01:00
|
|
|
AddLayer(new CLayerTile(File,Version));
|
|
|
|
break;
|
|
|
|
case LAYER_TYPE_COLLISION:
|
|
|
|
AddLayer(new CLayerCollision(File,Version));
|
2000-11-20 21:33:42 +01:00
|
|
|
break;
|
2001-02-09 22:17:01 +01:00
|
|
|
case LAYER_TYPE_SHADE:
|
|
|
|
AddLayer(new CLayerShade(File,Version));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ASSERT(!"poos");
|
2000-11-20 21:33:42 +01:00
|
|
|
}
|
|
|
|
}
|
2000-11-30 23:17:55 +01:00
|
|
|
|
2001-03-01 18:28:20 +01:00
|
|
|
for (i=0; i<Layer.size(); i++)
|
|
|
|
{
|
|
|
|
Layer[i]->InitSubView(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
GetTileBank()->Load(File,Version);
|
|
|
|
CurrentLayer=Layer[ActiveLayer];
|
2000-11-30 23:17:55 +01:00
|
|
|
|
|
|
|
// Check Layers
|
2001-02-14 23:35:47 +01:00
|
|
|
int MapWidth=ActionLayer->GetWidth();
|
|
|
|
int MapHeight=ActionLayer->GetHeight();
|
2000-11-30 23:17:55 +01:00
|
|
|
for (i=0;i<LayerCount;i++)
|
|
|
|
{
|
|
|
|
Layer[i]->CheckLayerSize(MapWidth,MapHeight);
|
|
|
|
}
|
2001-02-14 23:35:47 +01:00
|
|
|
|
2000-11-20 21:33:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::Save(CFile *File)
|
2000-11-06 21:24:11 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
BOOL F;
|
2000-11-28 22:16:00 +01:00
|
|
|
// Version 1
|
2001-01-23 22:53:48 +01:00
|
|
|
File->Write(&FileVersion,sizeof(int));
|
2000-11-20 21:33:42 +01:00
|
|
|
|
2000-12-04 17:47:34 +01:00
|
|
|
File->Write(&MapCam,sizeof(Vector3));
|
|
|
|
File->Write(&MapCamOfs,sizeof(Vector3));
|
|
|
|
File->Write(&TileCam,sizeof(Vector3));
|
|
|
|
File->Write(&TileCamOfs,sizeof(Vector3));
|
2000-11-20 21:33:42 +01:00
|
|
|
|
2001-03-01 18:28:20 +01:00
|
|
|
F=SpareFlag; File->Write(&F,sizeof(BOOL));
|
|
|
|
F=GridFlag; File->Write(&F,sizeof(BOOL));
|
|
|
|
F=Is3dFlag; File->Write(&F,sizeof(BOOL));
|
2000-11-20 21:33:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
// Layers
|
|
|
|
int LayerCount=Layer.size();
|
|
|
|
File->Write(&LayerCount,sizeof(int));
|
|
|
|
File->Write(&ActiveLayer,sizeof(int));
|
|
|
|
|
|
|
|
for (int i=0;i<LayerCount;i++)
|
|
|
|
{
|
|
|
|
int Type=Layer[i]->GetType();
|
|
|
|
File->Write(&Type,sizeof(int));
|
|
|
|
Layer[i]->Save(File);
|
|
|
|
}
|
2001-03-01 18:28:20 +01:00
|
|
|
GetTileBank()->Save(File);
|
2000-11-20 21:33:42 +01:00
|
|
|
|
2000-11-02 16:46:17 +01:00
|
|
|
}
|
2000-10-27 02:06:19 +02:00
|
|
|
|
2000-12-11 22:29:59 +01:00
|
|
|
/*****************************************************************************/
|
2001-03-01 18:28:20 +01:00
|
|
|
bool CCore::Question(char *Txt)
|
2000-12-11 22:29:59 +01:00
|
|
|
{
|
2001-02-14 23:35:47 +01:00
|
|
|
CString Str;
|
|
|
|
Str.Format(Txt);
|
|
|
|
int Ret=AfxMessageBox(Str,MB_YESNO , MB_ICONQUESTION);
|
|
|
|
|
|
|
|
if (Ret==IDYES) return(true);
|
|
|
|
return(false);
|
|
|
|
|
2000-12-11 22:29:59 +01:00
|
|
|
}
|
|
|
|
|
2000-09-22 23:19:46 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
2001-03-01 18:28:20 +01:00
|
|
|
void CCore::Render(bool ForceRender)
|
2000-09-22 23:19:46 +02:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
Vector3 &ThisCam=GetCam();
|
|
|
|
if (!CurrentView)
|
2001-02-14 23:35:47 +01:00
|
|
|
{
|
|
|
|
TRACE0("No View\n");
|
|
|
|
UpdateAll();
|
|
|
|
return;
|
|
|
|
}
|
2001-03-01 18:28:20 +01:00
|
|
|
if (GetTileBank()->NeedLoad()) GetTileBank()->LoadTileSets(this);
|
2000-11-06 21:24:11 +01:00
|
|
|
|
2000-11-14 16:03:04 +01:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen
|
2001-03-01 18:28:20 +01:00
|
|
|
|
|
|
|
if (CurrentLayer!=Layer[ActiveLayer] || CurrentLayer->IsUnique())
|
2000-11-14 16:03:04 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
CurrentLayer->Render(this,ThisCam,Is3dFlag);
|
|
|
|
CurrentLayer->RenderGrid(this,ThisCam,true);
|
|
|
|
CurrentLayer->FindCursorPos(this,GetCam(),CurrentMousePos);
|
2000-11-14 16:03:04 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-14 23:35:47 +01:00
|
|
|
RenderLayers();
|
2000-11-14 16:03:04 +01:00
|
|
|
}
|
2001-03-01 18:28:20 +01:00
|
|
|
CurrentLayer->RenderCursor(this,ThisCam,Is3dFlag);
|
|
|
|
// Get Cursor Pos
|
|
|
|
LastCursorPos=CursorPos;
|
|
|
|
CurrentLayer->FindCursorPos(this,GetCam(),CurrentMousePos);
|
2000-11-14 16:03:04 +01:00
|
|
|
|
|
|
|
}
|
2000-11-10 17:17:00 +01:00
|
|
|
|
2000-11-14 16:03:04 +01:00
|
|
|
/*****************************************************************************/
|
2001-02-14 23:35:47 +01:00
|
|
|
void CCore::RenderLayers()
|
2000-11-14 16:03:04 +01:00
|
|
|
{
|
2000-12-04 17:47:34 +01:00
|
|
|
Vector3 &ThisCam=GetCam();
|
2000-11-20 21:33:42 +01:00
|
|
|
int ListSize=Layer.size();
|
2001-02-07 22:31:31 +01:00
|
|
|
int StartLayer,EndLayer;
|
|
|
|
|
|
|
|
StartLayer=0;
|
|
|
|
EndLayer=ListSize;
|
|
|
|
|
2001-03-01 18:28:20 +01:00
|
|
|
// while (Layer[StartLayer]->IsUnique()) StartLayer++;
|
2001-02-07 22:31:31 +01:00
|
|
|
|
2001-03-01 18:28:20 +01:00
|
|
|
// if (Layer[ActiveLayer]->IsUnique())
|
|
|
|
// {
|
|
|
|
// StartLayer=ActiveLayer;
|
|
|
|
// EndLayer=StartLayer+1;
|
|
|
|
// }
|
2001-02-07 22:31:31 +01:00
|
|
|
|
|
|
|
for (int i=StartLayer; i<EndLayer; i++)
|
2000-10-31 23:37:59 +01:00
|
|
|
{
|
2000-11-28 00:14:42 +01:00
|
|
|
if (Layer[i]->IsVisible())
|
2001-02-07 22:31:31 +01:00
|
|
|
{
|
2000-11-28 00:14:42 +01:00
|
|
|
Layer[i]->Render(this,ThisCam,Is3dFlag);
|
|
|
|
if (GridFlag) Layer[i]->RenderGrid(this,ThisCam,i==ActiveLayer);
|
2001-02-07 22:31:31 +01:00
|
|
|
}
|
2000-11-02 16:46:17 +01:00
|
|
|
}
|
2001-02-07 22:31:31 +01:00
|
|
|
|
2000-09-22 23:19:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*** Control *****************************************************************/
|
2000-11-15 22:22:40 +01:00
|
|
|
/*****************************************************************************/
|
2001-03-01 18:28:20 +01:00
|
|
|
void CCore::LButtonControl(UINT nFlags, CPoint &point,bool DownFlag)
|
2000-11-15 22:22:40 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
if (CurrentLayer->IsVisible())
|
2000-11-15 22:22:40 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
CurrentLayer->LButtonControl(this,nFlags,CursorPos,DownFlag);
|
2000-11-15 22:22:40 +01:00
|
|
|
}
|
2001-03-01 18:28:20 +01:00
|
|
|
Command(CmdMsg_ActiveBrushLeft,0,0);
|
2000-11-15 22:22:40 +01:00
|
|
|
|
2001-03-01 18:28:20 +01:00
|
|
|
RedrawView();
|
2000-09-22 23:19:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-03-01 18:28:20 +01:00
|
|
|
void CCore::MButtonControl(UINT nFlags, CPoint &point,bool DownFlag)
|
2000-09-22 23:19:46 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-03-01 18:28:20 +01:00
|
|
|
void CCore::RButtonControl(UINT nFlags, CPoint &point,bool DownFlag)
|
2000-09-22 23:19:46 +02:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
if (CurrentLayer->IsVisible())
|
2000-11-15 22:22:40 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
CurrentLayer->RButtonControl(this,nFlags,CursorPos,DownFlag);
|
2000-11-15 22:22:40 +01:00
|
|
|
}
|
2001-03-01 18:28:20 +01:00
|
|
|
Command(CmdMsg_ActiveBrushRight,0,0);
|
|
|
|
RedrawView();
|
2000-09-22 23:19:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-02-09 22:17:01 +01:00
|
|
|
void CCore::Zoom(float Dst)
|
2000-09-22 23:19:46 +02:00
|
|
|
{
|
2000-12-04 17:47:34 +01:00
|
|
|
Vector3 Ofs;
|
|
|
|
Ofs.Zero();
|
2000-12-11 22:52:32 +01:00
|
|
|
Ofs.z=Dst;
|
2001-02-09 22:17:01 +01:00
|
|
|
UpdateView(&Ofs);
|
2000-09-22 23:19:46 +02:00
|
|
|
}
|
|
|
|
|
2000-12-11 22:52:32 +01:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-02-14 23:35:47 +01:00
|
|
|
void CCore::MouseWheel(UINT nFlags, short zDelta, CPoint &pt)
|
2000-12-11 22:52:32 +01:00
|
|
|
{
|
|
|
|
if (zDelta>0)
|
2001-02-09 22:17:01 +01:00
|
|
|
Zoom(-0.1f);
|
2001-01-03 23:11:13 +01:00
|
|
|
else
|
2001-02-09 22:17:01 +01:00
|
|
|
Zoom(+0.1f);
|
2000-12-11 22:52:32 +01:00
|
|
|
}
|
|
|
|
|
2000-09-22 23:19:46 +02:00
|
|
|
/*****************************************************************************/
|
2001-02-14 23:35:47 +01:00
|
|
|
void CCore::MouseMove(UINT nFlags, CPoint &point)
|
2000-09-22 23:19:46 +02:00
|
|
|
{
|
2000-12-04 17:47:34 +01:00
|
|
|
Vector3 Ofs;
|
|
|
|
Vector3 &ThisCam=GetCam();
|
2000-10-25 20:28:44 +02:00
|
|
|
// check if active doc
|
2000-12-04 17:47:34 +01:00
|
|
|
Ofs.Zero();
|
2001-02-14 23:35:47 +01:00
|
|
|
if (theApp.GetCurrent()!=CurrentView->GetDocument()) return;
|
|
|
|
GetWorkingPath();
|
2000-10-25 20:28:44 +02:00
|
|
|
CurrentMousePos=point;
|
2000-10-25 23:00:54 +02:00
|
|
|
|
|
|
|
// Handle Drag Movement
|
2000-12-11 23:42:19 +01:00
|
|
|
if (nFlags & MK_MBUTTON || nFlags & MK_SHIFT)
|
2000-09-22 23:19:46 +02:00
|
|
|
{
|
|
|
|
float XS,YS;
|
|
|
|
RECT ThisRect;
|
2001-01-17 22:52:08 +01:00
|
|
|
float MoveSpd=GetZoomW();
|
2000-09-22 23:19:46 +02:00
|
|
|
|
2001-01-17 22:52:08 +01:00
|
|
|
if (nFlags & MK_CONTROL)
|
|
|
|
{
|
|
|
|
MoveSpd*=4;
|
|
|
|
}
|
2001-02-14 23:35:47 +01:00
|
|
|
CurrentView->GetWindowRect(&ThisRect);
|
2001-01-17 22:52:08 +01:00
|
|
|
XS=ThisCam.z*MoveSpd;
|
|
|
|
YS=ThisCam.z*MoveSpd;
|
2000-10-25 23:00:54 +02:00
|
|
|
XS/=((ThisRect.right-ThisRect.left));
|
|
|
|
YS/=((ThisRect.bottom-ThisRect.top));
|
2000-09-22 23:19:46 +02:00
|
|
|
|
2000-11-02 16:46:17 +01:00
|
|
|
Ofs.x=LastMousePos.x-CurrentMousePos.x;
|
|
|
|
Ofs.y=LastMousePos.y-CurrentMousePos.y;
|
2000-09-22 23:19:46 +02:00
|
|
|
|
2000-11-02 16:46:17 +01:00
|
|
|
Ofs.x*=XS;
|
|
|
|
Ofs.y*=YS;
|
2001-02-09 22:17:01 +01:00
|
|
|
UpdateView(&Ofs);
|
2000-09-22 23:19:46 +02:00
|
|
|
}
|
2000-11-06 21:24:11 +01:00
|
|
|
else
|
2000-12-01 22:33:02 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
if (CurrentLayer->IsVisible())
|
2000-11-17 22:36:13 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
CurrentLayer->MouseMove(this,nFlags,CursorPos);
|
2000-11-17 22:36:13 +01:00
|
|
|
}
|
2001-02-14 23:35:47 +01:00
|
|
|
// Mouse still moved, so need to redraw windows, to get CursorPos
|
2001-02-09 22:17:01 +01:00
|
|
|
RedrawView();
|
2000-11-06 21:24:11 +01:00
|
|
|
}
|
2000-12-11 23:42:19 +01:00
|
|
|
LastMousePos=CurrentMousePos;
|
2000-09-22 23:19:46 +02:00
|
|
|
}
|
|
|
|
|
2000-11-15 22:22:40 +01:00
|
|
|
|
2001-03-01 18:28:20 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::Command(int CmdMsg,int Param0,int Param1)
|
|
|
|
{
|
|
|
|
bool RedrawFlag=false;
|
|
|
|
switch(CmdMsg)
|
|
|
|
{
|
|
|
|
case CmdMsg_ToggleSubView:
|
|
|
|
ToggleSubView();
|
|
|
|
break;
|
|
|
|
case CmdMsg_ToggleGrid:
|
|
|
|
ToggleGrid();
|
|
|
|
break;
|
|
|
|
case CmdMsg_Toggle2d:
|
|
|
|
Toggle2d3d();
|
|
|
|
break;
|
|
|
|
case CmdMsg_ZoomIn:
|
|
|
|
Zoom(-0.1f);
|
|
|
|
break;
|
|
|
|
case CmdMsg_ZoomOut:
|
|
|
|
Zoom(+0.1f);
|
|
|
|
break;
|
|
|
|
case CmdMsg_ResetView:
|
|
|
|
ResetView();
|
|
|
|
break;
|
|
|
|
case CmdMsg_SetLayer:
|
|
|
|
SetLayer(Param0);
|
|
|
|
break;
|
|
|
|
case CmdMsg_AddLayer:
|
|
|
|
AddLayer(Param0);
|
|
|
|
break;
|
|
|
|
case CmdMsg_DeleteLayer:
|
|
|
|
DeleteLayer(Param0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Pass remaining to Active Layer
|
|
|
|
default:
|
|
|
|
RedrawFlag=CurrentLayer->Command(CmdMsg,this,Param0,Param1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
/* if (RedrawFlag) */RedrawView();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-22 17:11:29 +02:00
|
|
|
/*****************************************************************************/
|
2000-11-02 16:46:17 +01:00
|
|
|
/*** Layers ******************************************************************/
|
2000-09-22 17:11:29 +02:00
|
|
|
/*****************************************************************************/
|
2000-11-17 00:08:54 +01:00
|
|
|
void CCore::UpdateParamBar()
|
2000-09-22 17:11:29 +02:00
|
|
|
{
|
2001-02-14 23:35:47 +01:00
|
|
|
CMainFrame *Frm=(CMainFrame*)AfxGetMainWnd();
|
2000-11-10 17:17:00 +01:00
|
|
|
CMultiBar *ParamBar=Frm->GetParamBar();
|
|
|
|
|
2001-02-09 22:17:01 +01:00
|
|
|
GUIRemoveAll();
|
|
|
|
GUIAdd(LayerList,IDD_LAYER_LIST_DIALOG);
|
2001-03-01 18:28:20 +01:00
|
|
|
CurrentLayer->GUIInit(this);
|
2001-02-09 22:17:01 +01:00
|
|
|
GUIUpdate();
|
2000-09-22 17:11:29 +02:00
|
|
|
}
|
|
|
|
|
2000-11-21 22:27:55 +01:00
|
|
|
/*****************************************************************************/
|
2001-02-09 22:17:01 +01:00
|
|
|
void CCore::UpdateLayerGUI()
|
2000-11-21 22:27:55 +01:00
|
|
|
{
|
|
|
|
int ListSize=Layer.size();
|
|
|
|
|
2001-02-09 22:17:01 +01:00
|
|
|
if (LayerList.ListBox)
|
2000-11-21 22:27:55 +01:00
|
|
|
{
|
2001-02-09 22:17:01 +01:00
|
|
|
LayerList.ListBox.ResetContent();
|
|
|
|
|
|
|
|
for (int i=0; i<ListSize; i++)
|
|
|
|
{
|
|
|
|
LayerList.ListBox.AddString(Layer[i]->GetName());
|
|
|
|
}
|
2000-11-21 22:27:55 +01:00
|
|
|
// Now sets checks (silly MSoft bug!!)
|
2001-02-09 22:17:01 +01:00
|
|
|
for (i=0; i<ListSize; i++)
|
|
|
|
{
|
|
|
|
LayerList.ListBox.SetCheck(i,Layer[i]->IsVisible());
|
|
|
|
}
|
|
|
|
LayerList.ListBox.SetCurSel(ActiveLayer);
|
2000-11-21 22:27:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-06 21:24:11 +01:00
|
|
|
/*****************************************************************************/
|
2001-02-14 23:35:47 +01:00
|
|
|
void CCore::SetLayer(int NewLayer,bool Force)
|
2000-11-06 21:24:11 +01:00
|
|
|
{
|
2001-02-14 23:35:47 +01:00
|
|
|
int LayerCount=Layer.size()-1;
|
|
|
|
int LastLayer=ActiveLayer;
|
|
|
|
|
2001-01-21 19:04:00 +01:00
|
|
|
if (NewLayer<0) NewLayer=0;
|
2001-02-09 22:17:01 +01:00
|
|
|
|
2000-12-01 22:33:02 +01:00
|
|
|
// If toggling layer, dont change the layer
|
2001-02-09 22:17:01 +01:00
|
|
|
if ((int)LayerList.ListBox.GetCheck(NewLayer)!=(int)Layer[NewLayer]->IsVisible())
|
2000-12-01 22:33:02 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
Layer[NewLayer]->SetVisible(LayerList.ListBox.GetCheck(NewLayer)!=0);
|
2001-02-09 22:17:01 +01:00
|
|
|
LayerList.ListBox.SetCurSel(ActiveLayer);
|
2000-12-01 22:33:02 +01:00
|
|
|
}
|
|
|
|
else
|
2000-11-28 00:14:42 +01:00
|
|
|
{
|
2001-01-23 22:53:48 +01:00
|
|
|
bool IsCol=Layer[NewLayer]->GetType()==LAYER_TYPE_COLLISION;
|
2001-03-01 18:28:20 +01:00
|
|
|
GetTileBank()->SetCollision(IsCol);
|
2000-11-28 00:14:42 +01:00
|
|
|
ActiveLayer=NewLayer;
|
|
|
|
}
|
2001-02-14 23:35:47 +01:00
|
|
|
|
|
|
|
if (LastLayer!=ActiveLayer || Force)
|
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
if (LastLayer<=LayerCount) CurrentLayer->GUIKill(this);
|
|
|
|
CurrentLayer=Layer[ActiveLayer];
|
|
|
|
CurrentLayer->GUIInit(this);
|
2001-02-14 23:35:47 +01:00
|
|
|
GUIUpdate();
|
|
|
|
}
|
2001-02-09 22:17:01 +01:00
|
|
|
RedrawView();
|
2000-11-06 21:24:11 +01:00
|
|
|
}
|
2000-11-28 00:07:07 +01:00
|
|
|
|
2001-01-23 22:53:48 +01:00
|
|
|
/*****************************************************************************/
|
2001-02-14 23:35:47 +01:00
|
|
|
int CCore::AddLayer(CLayer *NewLayer)
|
2001-01-23 22:53:48 +01:00
|
|
|
{
|
|
|
|
int ListSize=Layer.size();
|
|
|
|
int NewIdx=CLayer::GetLayerIdx(NewLayer->GetType(),NewLayer->GetSubType());
|
|
|
|
int Idx=ListSize;
|
|
|
|
|
|
|
|
TRACE3("Add Layer %i %i @ %i\n",NewLayer->GetType(),NewLayer->GetSubType(),NewIdx);
|
|
|
|
|
|
|
|
for (Idx=0; Idx<ListSize; Idx++)
|
|
|
|
{
|
|
|
|
int ListIdx=CLayer::GetLayerIdx(Layer[Idx]->GetType(),Layer[Idx]->GetSubType());
|
|
|
|
if (NewIdx<ListIdx) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Layer.insert(Layer.begin() + Idx,NewLayer);
|
2001-02-14 23:35:47 +01:00
|
|
|
|
2001-03-01 18:28:20 +01:00
|
|
|
if (NewLayer->GetType()==LAYER_TYPE_TILE && NewLayer->GetSubType()==LAYER_SUBTYPE_ACTION) ActionLayer=(CLayerTile*)NewLayer;
|
|
|
|
NewLayer->InitSubView(this);
|
2001-02-14 23:35:47 +01:00
|
|
|
return(Idx);
|
2001-01-23 22:53:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-02-14 23:35:47 +01:00
|
|
|
int CCore::AddLayer(int Type, int SubType, int Width, int Height)
|
2001-01-23 22:53:48 +01:00
|
|
|
{
|
2001-02-14 23:35:47 +01:00
|
|
|
int Idx;
|
2001-01-23 22:53:48 +01:00
|
|
|
switch (Type)
|
|
|
|
{
|
|
|
|
case LAYER_TYPE_TILE:
|
2001-02-14 23:35:47 +01:00
|
|
|
Idx=AddLayer(new CLayerTile(SubType, Width,Height));
|
2001-01-23 22:53:48 +01:00
|
|
|
break;
|
|
|
|
case LAYER_TYPE_COLLISION:
|
2001-02-14 23:35:47 +01:00
|
|
|
Idx=AddLayer(new CLayerCollision(SubType, Width,Height));
|
2001-01-23 22:53:48 +01:00
|
|
|
break;
|
2001-02-09 22:17:01 +01:00
|
|
|
case LAYER_TYPE_SHADE:
|
2001-02-14 23:35:47 +01:00
|
|
|
Idx=AddLayer(new CLayerShade(SubType, Width,Height));
|
2001-02-09 22:17:01 +01:00
|
|
|
break;
|
2001-01-23 22:53:48 +01:00
|
|
|
default:
|
|
|
|
ASSERT(!"AddLayer - Invalid Layer Type");
|
|
|
|
break;
|
|
|
|
}
|
2001-02-14 23:35:47 +01:00
|
|
|
return(Idx);
|
2001-01-23 22:53:48 +01:00
|
|
|
}
|
|
|
|
|
2001-01-21 19:04:00 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::AddLayer(int CurrentLayer)
|
|
|
|
{
|
2001-01-23 22:53:48 +01:00
|
|
|
std::vector<int> List;
|
|
|
|
CAddLayerDlg Dlg;
|
|
|
|
int NewLayerId=0;
|
|
|
|
int Sel;
|
|
|
|
|
|
|
|
// Build Unused List
|
|
|
|
Dlg.Sel=&Sel;
|
|
|
|
Sel=0;
|
|
|
|
for (int i=0; i<CLayer::InfoTableSize; i++)
|
|
|
|
{
|
|
|
|
if (FindLayer(CLayer::InfoTable[i].Type,CLayer::InfoTable[i].SubType)==-1)
|
|
|
|
{
|
|
|
|
List.push_back(i);
|
|
|
|
Dlg.StrList.push_back(CLayer::InfoTable[i].Name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Dlg.DoModal()!=IDOK) return;
|
|
|
|
|
|
|
|
NewLayerId=List[Sel];
|
|
|
|
|
|
|
|
TRACE2("Add Layer %i %s\n",NewLayerId,CLayer::InfoTable[NewLayerId].Name);
|
2001-01-21 19:04:00 +01:00
|
|
|
|
2001-02-14 23:35:47 +01:00
|
|
|
int Width=ActionLayer->GetWidth();
|
|
|
|
int Height=ActionLayer->GetHeight();
|
|
|
|
|
|
|
|
int Idx=AddLayer(CLayer::InfoTable[NewLayerId].Type,CLayer::InfoTable[NewLayerId].SubType,Width,Height);
|
|
|
|
if (ActiveLayer>=Idx) ActiveLayer++;
|
2001-01-21 19:04:00 +01:00
|
|
|
|
2001-02-14 23:35:47 +01:00
|
|
|
SetLayer(Idx,true);
|
2001-01-21 19:04:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::DeleteLayer(int CurrentLayer)
|
|
|
|
{
|
|
|
|
if (Layer[CurrentLayer]->CanDelete())
|
|
|
|
{
|
2001-02-09 22:17:01 +01:00
|
|
|
Layer[CurrentLayer]->GUIKill(this);
|
2001-01-21 19:04:00 +01:00
|
|
|
delete Layer[CurrentLayer];
|
|
|
|
Layer.erase(Layer.begin() + CurrentLayer);
|
2001-02-14 23:35:47 +01:00
|
|
|
SetLayer(CurrentLayer-1,true);
|
2001-01-21 19:04:00 +01:00
|
|
|
TRACE1("Deleted Layer %i\n",CurrentLayer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE1("Cant Delete Layer %i\n",CurrentLayer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-22 17:11:29 +02:00
|
|
|
/*****************************************************************************/
|
2001-03-01 18:28:20 +01:00
|
|
|
CLayer *CCore::FindSubView(int Type)
|
2000-11-15 22:22:40 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
int i,ListSize=Layer.size();
|
2000-11-15 22:22:40 +01:00
|
|
|
|
2001-03-01 18:28:20 +01:00
|
|
|
for (i=0;i<ListSize;i++)
|
2000-12-11 22:29:59 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
if (Layer[i]->GetSubViewType()==Type)
|
2000-12-11 22:29:59 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
CLayer *SV=Layer[i]->GetSubView();
|
|
|
|
if (SV) return(SV);
|
2000-12-11 22:29:59 +01:00
|
|
|
}
|
|
|
|
}
|
2001-03-01 18:28:20 +01:00
|
|
|
return(0);
|
2000-11-29 18:07:57 +01:00
|
|
|
}
|
|
|
|
|
2000-11-15 22:22:40 +01:00
|
|
|
/*****************************************************************************/
|
2001-03-01 18:28:20 +01:00
|
|
|
/*** Grid ********************************************************************/
|
2000-11-29 18:07:57 +01:00
|
|
|
/*****************************************************************************/
|
2001-03-01 18:28:20 +01:00
|
|
|
void CCore::ToggleGrid()
|
2000-11-29 18:07:57 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
GridFlag=!GridFlag;
|
|
|
|
RedrawView();
|
2000-11-29 18:07:57 +01:00
|
|
|
}
|
|
|
|
|
2001-02-20 16:57:03 +01:00
|
|
|
/*****************************************************************************/
|
2001-03-01 18:28:20 +01:00
|
|
|
/*** SubView *****************************************************************/
|
2001-01-02 15:34:02 +01:00
|
|
|
/*****************************************************************************/
|
2001-03-01 18:28:20 +01:00
|
|
|
void CCore::ToggleSubView()
|
2001-01-02 15:34:02 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
CLayer *LastLayer=CurrentLayer;
|
2001-01-02 15:34:02 +01:00
|
|
|
|
2001-03-01 18:28:20 +01:00
|
|
|
CurrentLayer=CurrentLayer->GetSubView(); // <-- Funky toggle code of what!!
|
|
|
|
if (!CurrentLayer) CurrentLayer=Layer[ActiveLayer];
|
|
|
|
if (LastLayer!=CurrentLayer)
|
|
|
|
{
|
|
|
|
LastLayer->GUIKill(this);
|
|
|
|
CurrentLayer->GUIInit(this);
|
|
|
|
GUIUpdate();
|
|
|
|
RedrawView();
|
|
|
|
}
|
2001-01-02 15:34:02 +01:00
|
|
|
}
|
|
|
|
|
2000-10-31 23:37:59 +01:00
|
|
|
/*****************************************************************************/
|
2000-11-02 16:46:17 +01:00
|
|
|
/*** Misc ********************************************************************/
|
2000-10-31 23:37:59 +01:00
|
|
|
/*****************************************************************************/
|
2000-12-04 17:47:34 +01:00
|
|
|
Vector3 &CCore::GetCam()
|
2000-10-31 23:37:59 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
// if (SubViewFlag)
|
|
|
|
// return(TileCam);
|
|
|
|
// else
|
2000-11-14 16:03:04 +01:00
|
|
|
return(MapCam);
|
2000-10-31 23:37:59 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-11-28 00:07:07 +01:00
|
|
|
/*****************************************************************************/
|
2000-12-29 23:20:38 +01:00
|
|
|
void CCore::SetScale()
|
2000-11-28 00:07:07 +01:00
|
|
|
{
|
2000-12-29 23:20:38 +01:00
|
|
|
float XS=GetZoomW();
|
|
|
|
float YS=GetZoomH();
|
|
|
|
float ZS=XS/YS;
|
2000-11-28 00:07:07 +01:00
|
|
|
|
2000-12-29 23:20:38 +01:00
|
|
|
ScaleVector.x=1.0f/XS;
|
|
|
|
ScaleVector.y=1.0f/XS;
|
2001-02-14 23:35:47 +01:00
|
|
|
ScaleVector.z=1.0f/XS;
|
2000-12-29 23:20:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
float CCore::GetZoomW()
|
|
|
|
{
|
|
|
|
Vector3 &ThisCam=GetCam();
|
|
|
|
|
2001-02-09 22:17:01 +01:00
|
|
|
return((float)SCREEN_MAP_WIDTH/ThisCam.z);
|
2000-12-29 23:20:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
float CCore::GetZoomH()
|
|
|
|
{
|
|
|
|
Vector3 &ThisCam=GetCam();
|
|
|
|
|
2001-02-09 22:17:01 +01:00
|
|
|
return((float)SCREEN_MAP_HEIGHT/ThisCam.z);
|
2000-11-28 00:07:07 +01:00
|
|
|
}
|
|
|
|
|
2001-02-16 19:23:01 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::ResetView()
|
|
|
|
{
|
|
|
|
Vector3 &ThisCam=GetCam();
|
|
|
|
|
|
|
|
ThisCam=DefaultCamPos;
|
|
|
|
UpdateView();
|
|
|
|
}
|
|
|
|
|
2000-10-31 23:37:59 +01:00
|
|
|
/*****************************************************************************/
|
2001-02-09 22:17:01 +01:00
|
|
|
/*** GUI *********************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::GUIAdd(CDialog &Dlg,int ID,bool Visible,bool Lock)
|
2000-11-02 16:46:17 +01:00
|
|
|
{
|
2001-02-14 23:35:47 +01:00
|
|
|
CMainFrame *Frm=(CMainFrame*)AfxGetMainWnd();
|
2001-02-09 22:17:01 +01:00
|
|
|
CMultiBar *ParamBar=Frm->GetParamBar();
|
2000-11-14 16:03:04 +01:00
|
|
|
|
2001-02-09 22:17:01 +01:00
|
|
|
ParamBar->Add(Dlg,ID,Visible,Lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::GUIRemove(CDialog &Dlg,int ID,bool Force)
|
|
|
|
{
|
2001-02-14 23:35:47 +01:00
|
|
|
CMainFrame *Frm=(CMainFrame*)AfxGetMainWnd();
|
2001-02-09 22:17:01 +01:00
|
|
|
CMultiBar *ParamBar=Frm->GetParamBar();
|
2000-11-14 16:03:04 +01:00
|
|
|
|
2001-02-09 22:17:01 +01:00
|
|
|
ParamBar->Remove(Dlg,Force);
|
2000-11-02 16:46:17 +01:00
|
|
|
}
|
2000-09-22 17:11:29 +02:00
|
|
|
|
2000-11-21 22:27:55 +01:00
|
|
|
/*****************************************************************************/
|
2001-02-09 22:17:01 +01:00
|
|
|
void CCore::GUIRemoveAll(bool Force)
|
2000-11-21 22:27:55 +01:00
|
|
|
{
|
2001-02-14 23:35:47 +01:00
|
|
|
CMainFrame *Frm=(CMainFrame*)AfxGetMainWnd();
|
2001-02-09 22:17:01 +01:00
|
|
|
CMultiBar *ParamBar=Frm->GetParamBar();
|
|
|
|
|
|
|
|
ParamBar->RemoveAll(Force);
|
2000-11-21 22:27:55 +01:00
|
|
|
}
|
|
|
|
|
2000-11-03 23:40:41 +01:00
|
|
|
/*****************************************************************************/
|
2001-02-09 22:17:01 +01:00
|
|
|
void CCore::GUIUpdate()
|
2000-11-03 23:40:41 +01:00
|
|
|
{
|
2001-02-14 23:35:47 +01:00
|
|
|
CMainFrame *Frm=(CMainFrame*)AfxGetMainWnd();
|
2001-02-09 22:17:01 +01:00
|
|
|
CMultiBar *ParamBar=Frm->GetParamBar();
|
|
|
|
|
|
|
|
UpdateLayerGUI();
|
2001-03-01 18:28:20 +01:00
|
|
|
CurrentLayer->GUIUpdate(this);
|
2001-02-09 22:17:01 +01:00
|
|
|
ParamBar->Update();
|
|
|
|
}
|
2000-11-20 17:21:43 +01:00
|
|
|
|
2000-12-04 17:47:34 +01:00
|
|
|
/*****************************************************************************/
|
2001-02-09 22:17:01 +01:00
|
|
|
void CCore::GUIChanged()
|
2000-12-04 17:47:34 +01:00
|
|
|
{
|
2001-03-01 18:28:20 +01:00
|
|
|
CurrentLayer->GUIChanged(this);
|
2001-02-09 22:17:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::UpdateAll()
|
|
|
|
{
|
|
|
|
UpdateParamBar();
|
2001-02-14 23:35:47 +01:00
|
|
|
RedrawView();
|
2001-02-09 22:17:01 +01:00
|
|
|
}
|
2000-12-04 17:47:34 +01:00
|
|
|
|
2001-02-09 22:17:01 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::RedrawView()
|
|
|
|
{
|
2001-02-14 23:35:47 +01:00
|
|
|
if (CurrentView) CurrentView->Invalidate();
|
2001-02-09 22:17:01 +01:00
|
|
|
}
|
2000-12-29 23:20:38 +01:00
|
|
|
|
2001-02-09 22:17:01 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::UpdateView(Vector3 *Ofs)
|
|
|
|
{
|
|
|
|
if (Ofs)
|
|
|
|
{
|
|
|
|
Vector3 &ThisCam=GetCam();
|
|
|
|
|
|
|
|
ThisCam.x+=Ofs->x;
|
|
|
|
ThisCam.y+=Ofs->y;
|
|
|
|
ThisCam.z-=Ofs->z;
|
2001-03-01 18:28:20 +01:00
|
|
|
if (ThisCam.x<0) ThisCam.x=0;
|
|
|
|
if (ThisCam.y<0) ThisCam.y=0;
|
2001-02-09 22:17:01 +01:00
|
|
|
if (ThisCam.z<0.1) ThisCam.z=0.1f;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetScale();
|
|
|
|
RedrawView();
|
2000-12-04 17:47:34 +01:00
|
|
|
}
|
2000-11-21 22:27:55 +01:00
|
|
|
|
2000-11-20 17:21:43 +01:00
|
|
|
/*****************************************************************************/
|
2001-02-09 22:17:01 +01:00
|
|
|
void CCore::SetMapSize(int Width,int Height)
|
2000-11-20 17:21:43 +01:00
|
|
|
{
|
2001-02-09 22:17:01 +01:00
|
|
|
if (Width==GetMapWidth() && Height==GetMapHeight()) return;
|
2000-11-20 17:21:43 +01:00
|
|
|
|
2000-11-20 21:33:42 +01:00
|
|
|
int ListSize=Layer.size();
|
|
|
|
|
2001-02-09 22:17:01 +01:00
|
|
|
for (int i=0; i<ListSize; i++)
|
|
|
|
{
|
|
|
|
Layer[i]->Resize(Width,Height);
|
|
|
|
}
|
2000-11-20 17:21:43 +01:00
|
|
|
|
2001-02-14 23:35:47 +01:00
|
|
|
RedrawView();
|
2000-11-22 23:08:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-02-09 22:17:01 +01:00
|
|
|
void CCore::Toggle2d3d()
|
2000-11-22 23:08:47 +01:00
|
|
|
{
|
|
|
|
Is3dFlag=!Is3dFlag;
|
2001-02-14 23:35:47 +01:00
|
|
|
RedrawView();
|
2000-11-28 00:07:07 +01:00
|
|
|
}
|
|
|
|
|
2000-11-28 22:16:00 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
int CCore::FindLayer(int Type,int SubType)
|
|
|
|
{
|
|
|
|
int ListSize=Layer.size();
|
|
|
|
|
|
|
|
for (int i=0; i<ListSize; i++)
|
|
|
|
{
|
|
|
|
if (Layer[i]->GetType()==Type)
|
|
|
|
if (SubType==-1 || Layer[i]->GetSubType()==SubType)
|
|
|
|
return(i);
|
|
|
|
}
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
2000-11-28 00:07:07 +01:00
|
|
|
/*****************************************************************************/
|
2000-11-24 23:34:20 +01:00
|
|
|
|
2000-12-04 17:47:34 +01:00
|
|
|
Vector3 CCore::OffsetCam(Vector3 &Cam,float DivVal)
|
2000-11-28 00:07:07 +01:00
|
|
|
{
|
2000-12-29 23:20:38 +01:00
|
|
|
Vector3 ThisCam=Cam;
|
2000-11-28 00:07:07 +01:00
|
|
|
|
|
|
|
ThisCam=Cam/DivVal;
|
|
|
|
ThisCam.z=Cam.z;
|
|
|
|
|
|
|
|
return(ThisCam);
|
2000-11-22 23:08:47 +01:00
|
|
|
}
|
2000-11-24 23:34:20 +01:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-02-01 23:48:22 +01:00
|
|
|
void CCore::Export(char *Filename)
|
2000-11-28 00:07:07 +01:00
|
|
|
{
|
|
|
|
|
2000-11-30 23:17:55 +01:00
|
|
|
int LayerCount=Layer.size();
|
|
|
|
char ExportName[256];
|
|
|
|
|
2001-02-01 23:48:22 +01:00
|
|
|
SetFileExt(Filename,ExportName,"MEX");
|
2000-11-30 23:17:55 +01:00
|
|
|
|
2001-02-07 22:31:31 +01:00
|
|
|
CExport Exp(ExportName);
|
2000-11-30 23:17:55 +01:00
|
|
|
|
2000-12-11 22:29:59 +01:00
|
|
|
for (int i=0;i<LayerCount;i++)
|
2000-11-30 23:17:55 +01:00
|
|
|
{
|
2001-02-07 22:31:31 +01:00
|
|
|
if (Layer[i]->CanExport())
|
|
|
|
{
|
|
|
|
Layer[i]->Export(this,Exp);
|
|
|
|
}
|
2000-11-30 23:17:55 +01:00
|
|
|
}
|
2000-12-11 22:29:59 +01:00
|
|
|
|
2000-11-30 23:17:55 +01:00
|
|
|
Exp.ExportTiles(this);
|
2001-02-06 23:25:39 +01:00
|
|
|
Exp.ExportStrList(this);
|
2000-12-01 22:08:54 +01:00
|
|
|
|
2000-12-04 17:47:34 +01:00
|
|
|
}
|
|
|
|
|