📄 me_dx.h
字号:
/************************************************************************************************
* *
* Map Editor *
* Edition : DX1.0 *
* Main header. *
* main.h *
* Author : CCH & LightWing *
* Red Ants . SoftWorld . BeiJing *
* (C)1998 5-6 *
* *
************************************************************************************************/
#define NAME "MapEditor_DX"
#define TITLE "Map Editor DX1.0"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <stdlib.h>
#include <stdarg.h>
#include "C:\DX5SDK\SDK\INC\ddraw.h"
#include "C:\DX5SDK\SDK\INC\dinput.h"
#include "resource.h"
#include "ddutil.h"
// #include "sMap.h"
#define DINPUT_BUFFERSIZE 16
// Name of our bitmap resource.
static char szBitmap[] = "ME_DX";
#define TIMER_ID 1
#define TIMER_RATE 100
#define MERGEWORD(hi,lo) ( ( DWORD ) ( (hi) << 16 ) | (lo) )
// Properties of map element.
// format of data in ppt file
typedef struct S_MAP_ELEMENT_ATTR
{
DWORD Index; // 图元索引号.
BYTE Height; // 地形高度.
BYTE Reserved[3];
DWORD hotx; // 中心点.
DWORD hoty; //
// Properties of map, include:
// 地图属性,包括:
// 1.> structure | land | water | stone ?
// 2.> animate of terrain on | off?
// 3.> allow step ?
// ...
DWORD Cap; // 地图属性.
void * pData; // 在图块文件的数据索引地址
} SME;
// header of ppt file
typedef struct SPPTFileHeader
{
DWORD iBlockSum;
} SPPTHeader;
//
// file.elm
//lstrcpy
typedef struct SElementFile
{
struct sHead
{
int Width; // width of the block by pixel
int Height; // height of the block by pixel
}head;
BYTE *pBitData; // pointer to the data.
} SMEData;
typedef struct
{
int g_x; // Virtual x-coordinate.
int g_y; // Virtual y-coordinate.
int rx; // Map position coordinate.
int ry; //
int g_xCross; // Cursor's width.
int g_yCross; //
int g_xHot; // Cursor's hot spot.
int g_yHot; //
} SMouse;
typedef struct
{
int index;
int height;
int hotx;
int hoty;
RECT *pdata;
} sTME;
typedef struct sMEE
{
int l;
int x;
int y;
sTME mec;
} sMEE;
typedef struct MAPFILE
{
BYTE flags[4]; // It's me!
int baseterrain; // the base tarrain of the map.
DWORD headsize; // size of the file header.
DWORD width; // the width of the map.
DWORD height;
DWORD levels;
int szbkpic; // background picture.
int direct; // the direct of the picture move to.
int weather; // the weather of the compaine
BYTE reserved[92];
} MapHeader;
//
// This class for realize the edit opration.
//
class sEditor
{
public:
sTME * lpMap; // pointer to the map array.
sTME * sERL[5]; //
sTME * lpME;
BOOL bSaved; // File is saved ?
int layer; // current layer.
int ME_Changed; // How many map element was changed?
int ChangeStep; // How many changed steps happened?
int mapWidth; // map width.
int mapHeight; // map height.
int baseterrain; // base terrain
int levels; // the map levels.
int szbkpic; // backgroud picture index(if exist).
int direct; // picture move direction(if back move).
int scrX; // screen start position at array's x
int scrY; // screen start position at array's y
int curX; // current x;
int curY; // current y;
char mapfile[16]; // the filename would be saved.
private:
sMEE * LastChange; // The Last change makes the change.
sMEE * ClipChange; // You can through it copy/cut/paste.
public:
sEditor(); // Ha ha, you need me?!...
~sEditor(); // Will you back? mmm, I'll have a rest.
void NewMap(); // New is better than old.You are wise.
void LoadMap(); // Cann't you forget your old sweet heart? That's good.
void SaveMap(); // What's you know is old.Update it.
void Help(); // Ha,ha,you don't know!!! Press F1, ha ha!
void Quit(); // I'm tired, bye.
void Copy(); // Double it.
void Paste(); // Ha ha, I'm clone...
void Delete(); // Kill bugs.
void Cut(); // You ought not to be at here.
void Select(); // Hi, you. Go out.
void UnChange( void ); // No, no no ...I'm not means that.
void ButtonYes(); // Yeah? What do you want me do?
void ButtonNo(); // Sorry, I cann't do this.
void ButtonCancel(); // Back, back, go back...
void SelectME(int id1, int id2, int id3); // Please let me be...
void ChangeMap(int x,int y, sTME * me); // Are you make wrong?
void CreateMap();
};
static LPDIRECTDRAW lpDD; // DirectDraw object
static LPDIRECTDRAWSURFACE lpDDSPrimary; // DirectDraw primary surface
static LPDIRECTDRAWSURFACE lpDDSBack; // DirectDraw back surface
static LPDIRECTDRAWSURFACE lpDDSOne; // Offscreen surface 1
static LPDIRECTDRAWSURFACE lpDDSTwo; // Offscreen surface 2
static LPDIRECTDRAWPALETTE lpDDPal; // DirectDraw palette
// State about some object.
static BOOL bActive; // is application active?
static BOOL bGrid; // Grid On/Off.
static void * CurWnd; // Current active window.
static void * PreWnd; // Storage main window handle.
static char codebuf[128]; // Used to message.
static BOOL IsInRect(RECT * rc, long x, long y);
static int sRetMessage( void );
static void UpdateFrame();
static BOOL InitSurfaces( void );
static void finiObjects(void);
static void UpdateCursorPosition(int dx, int dy);
static void displayCursor(long cx, long cy);
extern void display(char * code,RECT * rc);
extern void displayME(int cc,int cp);
static SMouse md = // mouse data;
{400, 300, 0, 0, 32, 32, 0, 0};
static RECT sRcb[24] =
{// left top right bottom
{14, 3, 44, 32 }, // Button Group 1.
{45, 3, 75, 32 }, // Total: 6
{76, 3, 106, 32 },
{107, 3, 137, 32 },
{138, 3, 168, 32 },
{169, 3, 199, 32 },
{219, 3, 249, 32 }, // Button Group 2.
{250, 3, 280, 32 }, // Total: 6
{281, 3, 311, 32 },
{312, 3, 342, 32 },
{343, 3, 373, 32 },
{374, 3, 403, 32 },
{426, 3, 456, 32 }, // Button Group 3.
{457, 3, 487, 32 }, // Total: 5
{488, 3, 518, 32 },
{519, 3, 549, 32 },
{550, 3, 580, 32 },
{589, 210, 603, 221 }, // Button Yes/No/Cancel
{589, 222, 603, 234 },
{589, 235, 603, 246 },
};
static RECT sRcw[5] = // display region.
{// left top right bottom
{8, 43, 585, 588 }, // Edit Region.
{596, 10, 792, 206 }, // Small map.
{596, 253, 782, 529 }, // Select region.
{615, 559, 783, 587 }, // prompt region 2.
{608, 213, 793, 245 }, // prompt region 1.
};
static RECT sRcm[8] = // button back,cursor & other.
{// left top right bottom
{0, 634, 509, 663 }, // Buton back.
{734, 602, 763, 617 }, // up back.
{734, 618, 763, 633 }, // down back.
{512, 602, 573, 649 }, // test element 1.
{576, 602, 639, 633 }, // Cursor enabled.
{576, 635, 639, 666 }, // Cursor disabled.
{639, 600, 702, 679 }, // test element 2.
{655, 51, 726, 181 }, // test element 3.
};
enum { Earth = 0, Structure, Tree, River, Object, Army };
static char *sButtonPrompt[20] =
{
"选择地面 F ","选择建筑 S ","选择树木 T ",
"选择河流 R ","选择物品 E ","选择部队 A ",
"复制 Ctrl+C ","粘贴 Ctrl+V ","删除 Ctrl+D ",
"剪贴 Ctrl+X ","选择 Ctrl+A ","取消 Ctrl+Z ",
"新建 F2 ","打开 F3 ","存盘 F4 ",
"退出 Esc ","帮助 F1 ",
"确定 ","否 ","取消 ",
};
// array of the map. we suggested it as 100*100 in this demo.
// in fact it decided by the user, so we defined a pointer.
// this is the true we used.
extern int ButtonPressed; // the button current pressed.
extern int PreButton; // the oprate button before system button.
extern int CurClass; // Current selected element class.
extern int CurPage; // Current selected element page.
extern sTME *sER;
extern sTME sERL1[100][100];
extern sTME sERL2[100][100];
// Current selected map element.
extern sTME CurME;
// Map Elements, we suggested that it has 72 in 6 class.
// Of cause not only so much.
extern sTME me[6][12];
extern BOOL dispME;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -