NHDT->ANH, nethack->anethack, nhdat->anhdat
[aNetHack.git] / win / win32 / winMS.h
blob2091a67f28db72fb10ba526c96facc5c8277ff00
1 /* aNetHack 0.0.1 winMS.h $ANH-Date: 1434804346 2015/06/20 12:45:46 $ $ANH-Branch: win32-x64-working $:$ANH-Revision: 1.41 $ */
2 /* Copyright (C) 2001 by Alex Kompel */
3 /* aNetHack may be freely redistributed. See license for details. */
5 #ifndef WINMS_H
6 #define WINMS_H
8 #ifdef _MSC_VER
9 #if _MSC_VER >= 1400
10 /* Visual C 8 warning elimination */
11 #ifndef _CRT_SECURE_NO_DEPRECATE
12 #define _CRT_SECURE_NO_DEPRECATE
13 #endif
14 #ifndef _SCL_SECURE_NO_DEPRECATE
15 #define _SCL_SECURE_NO_DEPRECATE
16 #endif
17 #ifndef _CRT_NONSTDC_NO_DEPRECATE
18 #define _CRT_NONSTDC_NO_DEPRECATE
19 #endif
20 #endif
21 #endif
23 #define WIN32_LEAN_AND_MEAN
24 #include <windows.h>
25 #include <commctrl.h>
26 #include <tchar.h>
27 #include "hack.h"
28 #include "color.h"
30 /* Create an array to keep track of the various windows */
32 #ifndef MAXWINDOWS
33 #define MAXWINDOWS 15
34 #endif
36 #define NHW_RIP 32
37 #define NHW_INVEN 33
39 #ifndef TILE_X
40 #define TILE_X 16
41 #endif
42 #define TILE_Y 16
44 #define TILES_PER_LINE 40
46 /* tile background color */
47 #define TILE_BK_COLOR RGB(71, 108, 108)
49 /* minimum/maximum font size (in points - 1/72 inch) */
50 #define NHFONT_DEFAULT_SIZE 9
51 #define NHFONT_SIZE_MIN 3
52 #define NHFONT_SIZE_MAX 20
54 #define MAX_LOADSTRING 100
55 #define USE_PILEMARK
57 typedef struct mswin_nhwindow_data {
58 HWND win;
59 int type;
60 int dead;
61 } MSNHWinData, *PMSNHWinData;
63 typedef BOOL(WINAPI *LPTRANSPARENTBLT)(HDC, int, int, int, int, HDC, int, int,
64 int, int, UINT);
66 typedef struct mswin_nhwindow_app {
67 HINSTANCE hApp;
68 HWND hMainWnd;
69 HACCEL hAccelTable;
70 HWND hPopupWnd; /* current popup window */
72 MSNHWinData windowlist[MAXWINDOWS];
74 HBITMAP bmpTiles;
75 HBITMAP bmpPetMark;
76 #ifdef USE_PILEMARK
77 HBITMAP bmpPileMark;
78 #endif
79 HBITMAP bmpMapTiles; /* custom tiles bitmap */
80 HBITMAP bmpRip;
81 HBITMAP bmpSplash;
82 int mapTile_X; /* tile width */
83 int mapTile_Y; /* tile height */
84 int mapTilesPerLine; /* number of tile per row in the bitmap */
86 boolean bNoHScroll; /* disable cliparound for horizontal grid (map) */
87 boolean bNoVScroll; /* disable cliparound for vertical grid (map) */
89 int mapDisplayModeSave; /* saved map display mode */
91 char *saved_text;
93 DWORD saveRegistrySettings; /* Flag if we should save this time */
94 DWORD
95 regaNetHackMode; /* aNetHack mode means no Windows keys in some places
98 COLORREF regMapColors[CLR_MAX];
100 LONG regMainMinX;
101 LONG regMainMinY;
102 LONG regMainMaxX;
103 LONG regMainMaxY;
104 LONG regMainLeft;
105 LONG regMainTop;
106 LONG regMainBottom;
107 LONG regMainRight;
108 DWORD regMainShowState;
110 BOOL bAutoLayout;
111 RECT rtMapWindow;
112 RECT rtMsgWindow;
113 RECT rtStatusWindow;
114 RECT rtMenuWindow;
115 RECT rtTextWindow;
116 RECT rtInvenWindow;
117 BOOL bWindowsLocked; /* TRUE if windows are "locked" - no captions */
119 BOOL bNoSounds; /* disable sounds */
121 LPTRANSPARENTBLT lpfnTransparentBlt; /* transparent blt function */
122 } NHWinApp, *PNHWinApp;
124 #define E extern
126 E PNHWinApp GetNHApp(void);
127 E struct window_procs mswin_procs;
129 #undef E
131 /* Some prototypes */
132 void mswin_init_nhwindows(int *argc, char **argv);
133 void mswin_player_selection(void);
134 void mswin_askname(void);
135 void mswin_get_nh_event(void);
136 void mswin_exit_nhwindows(const char *);
137 void mswin_suspend_nhwindows(const char *);
138 void mswin_resume_nhwindows(void);
139 winid mswin_create_nhwindow(int type);
140 void mswin_clear_nhwindow(winid wid);
141 void mswin_display_nhwindow(winid wid, BOOLEAN_P block);
142 void mswin_destroy_nhwindow(winid wid);
143 void mswin_curs(winid wid, int x, int y);
144 void mswin_putstr(winid wid, int attr, const char *text);
145 void mswin_putstr_ex(winid wid, int attr, const char *text, int);
146 void mswin_display_file(const char *filename, BOOLEAN_P must_exist);
147 void mswin_start_menu(winid wid);
148 void mswin_add_menu(winid wid, int glyph, const ANY_P *identifier,
149 CHAR_P accelerator, CHAR_P group_accel, int attr,
150 const char *str, BOOLEAN_P presel);
151 void mswin_end_menu(winid wid, const char *prompt);
152 int mswin_select_menu(winid wid, int how, MENU_ITEM_P **selected);
153 void mswin_update_inventory(void);
154 void mswin_mark_synch(void);
155 void mswin_wait_synch(void);
156 void mswin_cliparound(int x, int y);
157 void mswin_print_glyph(winid wid, XCHAR_P x, XCHAR_P y, int glyph, int bkglyph);
158 void mswin_raw_print(const char *str);
159 void mswin_raw_print_bold(const char *str);
160 int mswin_nhgetch(void);
161 int mswin_nh_poskey(int *x, int *y, int *mod);
162 void mswin_nhbell(void);
163 int mswin_doprev_message(void);
164 char mswin_yn_function(const char *question, const char *choices, CHAR_P def);
165 void mswin_getlin(const char *question, char *input);
166 int mswin_get_ext_cmd(void);
167 void mswin_number_pad(int state);
168 void mswin_delay_output(void);
169 void mswin_change_color(void);
170 char *mswin_get_color_string(void);
171 void mswin_start_screen(void);
172 void mswin_end_screen(void);
173 void mswin_outrip(winid wid, int how, time_t when);
174 void mswin_preference_update(const char *pref);
175 char *mswin_getmsghistory(BOOLEAN_P init);
176 void mswin_putmsghistory(const char *msg, BOOLEAN_P);
178 #ifdef STATUS_VIA_WINDOWPORT
179 void mswin_status_init(void);
180 void mswin_status_finish(void);
181 void mswin_status_enablefield(int fieldidx, const char *nm, const char *fmt,
182 boolean enable);
183 void mswin_status_update(int idx, genericptr_t ptr, int chg, int percent);
185 #ifdef STATUS_HILITES
186 void mswin_status_threshold(int fldidx, int thresholdtype, anything threshold,
187 int behavior, int under, int over);
188 #endif /* STATUS_HILITES */
189 #endif /*STATUS_VIA_WINDOWPORT*/
191 /* helper function */
192 HWND mswin_hwnd_from_winid(winid wid);
193 winid mswin_winid_from_type(int type);
194 winid mswin_winid_from_handle(HWND hWnd);
195 void mswin_window_mark_dead(winid wid);
196 void bail(const char *mesg);
198 void mswin_popup_display(HWND popup, int *done_indicator);
199 void mswin_popup_destroy(HWND popup);
201 void mswin_read_reg(void);
202 void mswin_destroy_reg(void);
203 void mswin_write_reg(void);
205 void mswin_get_window_placement(int type, LPRECT rt);
206 void mswin_update_window_placement(int type, LPRECT rt);
207 void mswin_apply_window_style(HWND hwnd);
209 int NHMessageBox(HWND hWnd, LPCTSTR text, UINT type);
211 extern HBRUSH menu_bg_brush;
212 extern HBRUSH menu_fg_brush;
213 extern HBRUSH text_bg_brush;
214 extern HBRUSH text_fg_brush;
215 extern HBRUSH status_bg_brush;
216 extern HBRUSH status_fg_brush;
217 extern HBRUSH message_bg_brush;
218 extern HBRUSH message_fg_brush;
220 extern COLORREF menu_bg_color;
221 extern COLORREF menu_fg_color;
222 extern COLORREF text_bg_color;
223 extern COLORREF text_fg_color;
224 extern COLORREF status_bg_color;
225 extern COLORREF status_fg_color;
226 extern COLORREF message_bg_color;
227 extern COLORREF message_fg_color;
229 #define SYSCLR_TO_BRUSH(x) ((HBRUSH)((x) + 1))
231 /* unicode stuff */
232 #define NH_CODEPAGE (SYMHANDLING(H_IBM) ? GetOEMCP() : GetACP())
233 #ifdef _UNICODE
234 #define NH_W2A(w, a, cb) \
235 (WideCharToMultiByte(NH_CODEPAGE, 0, (w), -1, (a), (cb), NULL, NULL), (a))
237 #define NH_A2W(a, w, cb) \
238 (MultiByteToWideChar(NH_CODEPAGE, 0, (a), -1, (w), (cb)), (w))
239 #else
240 #define NH_W2A(w, a, cb) (strncpy((a), (w), (cb)))
242 #define NH_A2W(a, w, cb) (strncpy((w), (a), (cb)))
243 #endif
245 /* map mode macros */
246 #define IS_MAP_FIT_TO_SCREEN(mode) \
247 ((mode) == MAP_MODE_ASCII_FIT_TO_SCREEN \
248 || (mode) == MAP_MODE_TILES_FIT_TO_SCREEN)
250 #define IS_MAP_ASCII(mode) \
251 ((mode) != MAP_MODE_TILES && (mode) != MAP_MODE_TILES_FIT_TO_SCREEN)
253 #endif /* WINMS_H */