Newer
Older
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Uint8 type; //事件类型
SDL_ActiveEvent active; //窗口焦点、输入焦点及鼠标焦点的失去和得到事件
SDL_KeyboardEvent key; //键盘事件,键盘按下和释放
SDL_MouseMotionEvent motion; //鼠标移动事件
SDL_MouseButtonEvent button; //鼠标按键事件
SDL_QuitEvent quit; //退出事件
SDL_SysWMEvent syswm; //平台相关的系统事件
}SDL_Event;*/
//typedef enum
//{
//SDL_NOEVENT = 0, /* 未使用 */
//SDL_ACTIVEEVENT, /* 应用程序失去焦点或得到焦点*/
//SDL_KEYDOWN, /* 按下某键 */
//SDL_KEYUP, /* 松开某键 */
//SDL_MOUSEMOTION, /* 鼠标移动 */
//SDL_MOUSEBUTTONDOWN, /* 鼠标键按下 */
//SDL_MOUSEBUTTONUP, /* 鼠标键松开 */
//SDL_QUIT, /*离开 */
//SDL_SYSWMEVENT, /* 系统事件 */
//SDL_EVENT_RESERVEDA, /* 保留 */
//SDL_EVENT_RESERVEDB, /* 保留 */
//SDL_VIDEORESIZE, /* 用户改变视频模式 */
//SDL_VIDEOEXPOSE, /* 屏幕重画 */
//SDL_EVENT_RESERVED2, /* 保留*/
//SDL_EVENT_RESERVED3, /* 保留 */
//SDL_EVENT_RESERVED4, /* 保留 */
//SDL_EVENT_RESERVED5, /* 保留 */
//SDL_EVENT_RESERVED6, /* 保留*/
//SDL_EVENT_RESERVED7, /* 保留 */
//SDL_USEREVENT = 24, /* 用户自定义事件 */
//SDL_NUMEVENTS = 32
//}SDL_EventType;
//typedef struct SDL_MouseButtonEvent
//{
// Uint8 type; /* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
// Uint8 which; /* The mouse device index */
// Uint8 button; /* 鼠标按键,左、右、中三个键*/
// Uint8 state; /* SDL_PRESSED按下 or SDL_RELEASED松开 */
// Uint16 x, y; /* 鼠标按下时的坐标 */
//}SDL_MouseButtonEvent;
//typedef struct SDL_MouseMotionEvent
//{
// Uint8 type; /* SDL_MOUSEMOTION */
// Uint8 which; /* The mouse device index */
// Uint8 state; /* 鼠标状态 */
// Uint16 x, y; /* 鼠标当前坐标 */
// Sint16 xrel; /* 鼠标在x方向的位移 */
// Sint16 yrel; /* 鼠标在y方向的位移*/
//} SDL_MouseMotionEvent;
typedef enum {LEFT,RIGHT}BUTTONPOS; //枚举按钮在精灵图中的编号
typedef enum {un,deux,OTHER}BUTTONFLAG; //枚举按钮
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef FONT_H
#define FONT_H
typedef int BOOL;
#define TRUE 1
#define FALSE 0
//表面声明
extern SDL_Surface *gpBackground; //背景表面
extern SDL_Surface *gpScreen; //显示表面
extern SDL_Surface *gpMessage[1]; //文字表面
//事件声明
extern SDL_Event myEvent;
// 字体声明
extern TTF_Font *font;
extern const SDL_Color RGB_Black;
extern const SDL_Color RGB_Red;
extern const SDL_Color RGB_Green;
extern const SDL_Color RGB_Blue;
extern const SDL_Color RGB_Cyan;
extern const SDL_Color RGB_Magenta;
extern const SDL_Color RGB_Yellow;
extern const SDL_Color RGB_White;
extern const SDL_Color RGB_Gray;
extern const SDL_Color RGB_Grey;
extern const SDL_Color RGB_Maroon ;
extern const SDL_Color RGB_Darkgreen;
extern const SDL_Color RGB_Navy;
extern const SDL_Color RGB_Teal;
extern const SDL_Color RGB_Purple;
extern const SDL_Color RGB_Olive;
extern const SDL_Color RGB_Noname;
int isOnButton(int aX,int aY, int aIndex);
void changeButton(BUTTONPOS aPos,int aNo,SDL_Rect *aDst);
BOOL init(char* aCaption,char * aIcon);
SDL_Surface *loadImage( char * filename );
void applySurface( int x, int y, SDL_Surface* source, SDL_Surface* destination );
void cleanup();
char *localeToUTF8(char *src);
wchar_t* cstringToUnicode(char * aSrc);
void handle_input(char *str, SDL_Surface *text);
void show_centered(SDL_Surface *text);
#endif