OSDN Git Service

Initial Import
[nethackexpress/trunk.git] / win / win32 / winMS.h
1 /* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
2 /* NetHack may be freely redistributed.  See license for details. */
3
4 #ifndef WINMS_H
5 #define WINMS_H
6
7 #define WIN32_LEAN_AND_MEAN
8 #include <windows.h>
9 #include <commctrl.h>
10 #include <tchar.h>
11 #include "hack.h"
12
13 /* Create an array to keep track of the various windows */
14
15 #ifndef MAXWINDOWS
16 #define MAXWINDOWS 15
17 #endif
18
19 #define NHW_RIP  32
20
21 #ifndef TILE_X
22 #define TILE_X 16
23 #endif
24 #define TILE_Y 16
25
26 #define TILES_PER_LINE  40
27
28 /* tile background color */
29 #define TILE_BK_COLOR RGB(71, 108, 108)
30
31 /* minimum/maximum font size (in points - 1/72 inch) */
32 #define NHFONT_DEFAULT_SIZE 9
33 #define NHFONT_SIZE_MIN 3
34 #define NHFONT_SIZE_MAX 20
35
36 #define MAX_LOADSTRING 100
37
38 typedef struct mswin_nhwindow_data {
39   HWND        win;
40   int             type;
41   int             dead;
42 } MSNHWinData, *PMSNHWinData;
43
44 typedef struct mswin_nhwindow_app {
45         HINSTANCE   hApp;
46         HWND            hMainWnd;
47         HACCEL          hAccelTable;
48         HWND            hPopupWnd;      /* current popup window  */
49
50         MSNHWinData windowlist[MAXWINDOWS];
51
52         HBITMAP         bmpTiles;
53         HBITMAP         bmpPetMark;
54         HBITMAP         bmpMapTiles; /* custom tiles bitmap */
55         HBITMAP         bmpRip;
56         HBITMAP         bmpSplash;
57         int                     mapTile_X;      /* tile width */
58         int                     mapTile_Y;      /* tile height */
59         int                     mapTilesPerLine;        /* number of tile per row in the bitmap */
60
61         boolean         bNoHScroll;     /* disable cliparound for horizontal grid (map) */
62         boolean         bNoVScroll; /* disable cliparound for vertical grid (map) */
63
64         int                     mapDisplayModeSave;     /* saved map display mode */
65
66         char*           saved_text;
67
68     DWORD       saveRegistrySettings; /* Flag if we should save this time */
69     DWORD       regNetHackMode;   /* NetHack mode means no Windows keys in some places */
70
71         LONG    regMainMinX;
72         LONG    regMainMinY;
73         LONG    regMainMaxX;
74         LONG    regMainMaxY;
75         LONG    regMainLeft;
76         LONG    regMainTop;
77         LONG    regMainBottom;
78         LONG    regMainRight;
79         DWORD   regMainShowState;
80 } NHWinApp, *PNHWinApp;
81
82 #define E extern
83
84 E PNHWinApp GetNHApp(void);
85 E struct window_procs mswin_procs;
86
87 #undef E
88
89 /* Some prototypes */
90 void mswin_init_nhwindows(int* argc, char** argv);
91 void mswin_player_selection(void);
92 void mswin_askname(void);
93 void mswin_get_nh_event(void);
94 void mswin_exit_nhwindows(const char *);
95 void mswin_suspend_nhwindows(const char *);
96 void mswin_resume_nhwindows(void);
97 winid mswin_create_nhwindow(int type);
98 void mswin_clear_nhwindow(winid wid);
99 void mswin_display_nhwindow(winid wid, BOOLEAN_P block);
100 void mswin_destroy_nhwindow(winid wid);
101 void mswin_curs(winid wid, int x, int y);
102 void mswin_putstr(winid wid, int attr, const char *text);
103 void mswin_putstr_ex(winid wid, int attr, const char *text, int);
104 void mswin_display_file(const char *filename,BOOLEAN_P must_exist);
105 void mswin_start_menu(winid wid);
106 void mswin_add_menu(winid wid, int glyph, const ANY_P * identifier,
107                 CHAR_P accelerator, CHAR_P group_accel, int attr, 
108                 const char *str, BOOLEAN_P presel);
109 void mswin_end_menu(winid wid, const char *prompt);
110 int  mswin_select_menu(winid wid, int how, MENU_ITEM_P **selected);
111 void mswin_update_inventory(void);
112 void mswin_mark_synch(void);
113 void mswin_wait_synch(void);
114 void mswin_cliparound(int x, int y);
115 void mswin_print_glyph(winid wid,XCHAR_P x,XCHAR_P y,int glyph);
116 void mswin_raw_print(const char *str);
117 void mswin_raw_print_bold(const char *str);
118 int  mswin_nhgetch(void);
119 int  mswin_nh_poskey(int *x, int *y, int *mod);
120 void mswin_nhbell(void);
121 int  mswin_doprev_message(void);
122 char mswin_yn_function(const char *question, const char *choices,
123                 CHAR_P def);
124 void mswin_getlin(const char *question, char *input);
125 int  mswin_get_ext_cmd(void);
126 void mswin_number_pad(int state);
127 void mswin_delay_output(void);
128 void mswin_change_color(void);
129 char *mswin_get_color_string(void);
130 void mswin_start_screen(void);
131 void mswin_end_screen(void);
132 void mswin_outrip(winid wid, int how);
133 void mswin_preference_update(const char *pref);
134
135 /* helper function */
136 HWND mswin_hwnd_from_winid(winid wid);
137 winid mswin_winid_from_type(int type);
138 winid mswin_winid_from_handle(HWND hWnd);
139 void mswin_window_mark_dead(winid wid);
140 void bail(const char *mesg);
141 void nhapply_image_transparent( 
142         HDC hDC, int x, int y, int width, int height,
143         HDC sourceDC, int s_x, int s_y, int s_width, int s_height,
144         COLORREF cTransparent
145 );
146
147 void mswin_popup_display(HWND popup, int* done_indicator);
148 void mswin_popup_destroy(HWND popup);
149
150 void mswin_read_reg(void);
151 void mswin_destroy_reg(void);
152 void mswin_write_reg(void);
153
154 int NHMessageBox(HWND hWnd, LPCTSTR text, UINT type);
155
156 extern HBRUSH menu_bg_brush;
157 extern HBRUSH menu_fg_brush;
158 extern HBRUSH text_bg_brush;
159 extern HBRUSH text_fg_brush;
160 extern HBRUSH status_bg_brush;
161 extern HBRUSH status_fg_brush;
162 extern HBRUSH message_bg_brush;
163 extern HBRUSH message_fg_brush;
164
165 extern COLORREF menu_bg_color;
166 extern COLORREF menu_fg_color;
167 extern COLORREF text_bg_color;
168 extern COLORREF text_fg_color;
169 extern COLORREF status_bg_color;
170 extern COLORREF status_fg_color;
171 extern COLORREF message_bg_color;
172 extern COLORREF message_fg_color;
173
174
175 #define SYSCLR_TO_BRUSH(x) ((HBRUSH)((x) + 1))
176
177 /* unicode stuff */
178 #ifdef UNICODE
179         #define NH_W2A(w, a, cb)     ( WideCharToMultiByte(                              \
180                                                                                                    CP_ACP,                      \
181                                                                                                    0,                           \
182                                                                                                    (w),                           \
183                                                                                                    -1,                          \
184                                                                                                    (a),                           \
185                                                                                                    (cb),                          \
186                                                                                                    NULL,                        \
187                                                                                                    NULL), (a) )
188
189         #define NH_A2W(a, w, cb)     ( MultiByteToWideChar(                              \
190                                                                                                    CP_ACP,                      \
191                                                                                                    0,                           \
192                                                                                                    (a),                           \
193                                                                                                    -1,                          \
194                                                                                                    (w),                           \
195                                                                                                    (cb)), (w) )
196 #else
197         #define NH_W2A(w, a, cb)     (strncpy((a), (w), (cb)))
198
199         #define NH_A2W(a, w, cb)     (strncpy((w), (a), (cb)))
200 #endif
201
202 #endif /* WINmswin_H */