⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmapeditor.h

📁 一个利用MAP的类,可以方便地使用多维数组.
💻 H
字号:
/*

CMapEditor v. 1.0

Copyright (C) 2003 Eugenio Panero.
All Rights Reserved.

www.eugigames.tk
info@eugigames.tk

*/

#include <vector>
using namespace std;

typedef struct _MAPINFO
{	//Map information structure

	int iWidth;		//Map width
	int iHeight;	//Map height
	int nLevels;	//Number of levels
}MAPINFO;

typedef struct _SPOINT
{	//Point structure
	unsigned short int x;	//x coordinate
	unsigned short int y;	//y coordinate
	unsigned short int z;	//z coordinate (unimplemented)
	unsigned short int l;	//level
}SPOINT;

typedef struct _SUNDO
{	//Undo structure for CMapEditor
	vector<SPOINT>	vPoints;
	vector<int>		vpiUndo;
	vector<int>		vpiRedo;
}SUNDO;

class CMapEditor
{	//CMapEditor provides a simple interface to handle multi-level matrixes of values
public:
	CMapEditor(int iWidth,int iHeight,int nLevels);							//Standard constructor
	~CMapEditor(void);														//Standard destructor
	bool	EndDrag(int ptX, int ptY, int iValue);							//Ends the drag operation and sets map values
	bool	Fill(int ptX, int ptY, int iLevel, int iReplace, int iValue);	//Fills a region of adjacent iReplace cells with iValue
	MAPINFO	GetMapInfo(void);												//Returns map information
	int		GetMapValue(int ptX, int ptY, int iLevel);						//Retrieves the value of a map cell
	bool	IsValidCoord(int ptX, int ptY, int iLevel);						//Checks if these values are a valid coordinate
	void	NextUndo(void);													//Defines an undo set of operations
	int		Redo(void);														//Redo action
	bool	SetMapValue(int ptX, int ptY, int iLevel, int iValue);			//Sets a map cell's value
	bool	StartDrag(int ptX, int ptY, int iLevel);						//Starts the drag operation. Call EndDrag() next
	int		Undo(void);														//Undo action

protected:
	int m_iDragLevel;			//The map level involved in the drag operation
	int	m_iHeight;				//Map height
	int	m_iWidth;				//Map width
	int m_iUndoPos;				//Current undo position
	int	***m_prgMap;			//The map
	int	m_nLevels;				//Number of levels
	int m_ptDragX;				//X coordinate of the drag operation start point
	int m_ptDragY;				//Y coordinate of the drag operation start point
	vector<SUNDO> m_vUndos;		//Undo vector
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -