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. */
10 /* Visual C 8 warning elimination */
11 #ifndef _CRT_SECURE_NO_DEPRECATE
12 #define _CRT_SECURE_NO_DEPRECATE
14 #ifndef _SCL_SECURE_NO_DEPRECATE
15 #define _SCL_SECURE_NO_DEPRECATE
17 #ifndef _CRT_NONSTDC_NO_DEPRECATE
18 #define _CRT_NONSTDC_NO_DEPRECATE
23 #define WIN32_LEAN_AND_MEAN
30 /* Create an array to keep track of the various windows */
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
57 typedef struct mswin_nhwindow_data
{
61 } MSNHWinData
, *PMSNHWinData
;
63 typedef BOOL(WINAPI
*LPTRANSPARENTBLT
)(HDC
, int, int, int, int, HDC
, int, int,
66 typedef struct mswin_nhwindow_app
{
70 HWND hPopupWnd
; /* current popup window */
72 MSNHWinData windowlist
[MAXWINDOWS
];
79 HBITMAP bmpMapTiles
; /* custom tiles bitmap */
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 */
93 DWORD saveRegistrySettings
; /* Flag if we should save this time */
95 regaNetHackMode
; /* aNetHack mode means no Windows keys in some places
98 COLORREF regMapColors
[CLR_MAX
];
108 DWORD regMainShowState
;
117 BOOL bWindowsLocked
; /* TRUE if windows are "locked" - no captions */
119 BOOL bNoSounds
; /* disable sounds */
121 LPTRANSPARENTBLT lpfnTransparentBlt
; /* transparent blt function */
122 } NHWinApp
, *PNHWinApp
;
126 E PNHWinApp
GetNHApp(void);
127 E
struct window_procs mswin_procs
;
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
,
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))
232 #define NH_CODEPAGE (SYMHANDLING(H_IBM) ? GetOEMCP() : GetACP())
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))
240 #define NH_W2A(w, a, cb) (strncpy((a), (w), (cb)))
242 #define NH_A2W(a, w, cb) (strncpy((w), (a), (cb)))
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)