1 /* SCCS Id: @(#)nhwin32.h 3.2 95/09/06 */ 2 /* Copyright (c) NetHack MS Windows Porting Team 1995 */ 3 /* NetHack may be freely redistributed. See license for details. */ 4 5 #ifndef WIN32_H 6 #define WIN32_H 7 8 struct win32_WinDesc { 9 int type; /* type of window */ 10 boolean active; /* true if window is active */ 11 boolean wasup; /* true if menu/text window was already open */ 12 short rowcount; /* Rows displayed in window */ 13 int widest; /* largest string in window */ 14 /* Win32 stuff */ 15 HWND hWnd; /* win32 window handle */ 16 HWND hDlg; /* dialog box hande (for menus mostly) */ 17 HFONT hFnt; /* handle of current font */ 18 HFONT hOldFnt; /* handle of old font */ 19 DWORD dwCharX; /* average width of characters */ 20 DWORD dwCharY; /* height of characters */ 21 #if 0 22 DWORD dwClientX; /* width of client area */ 23 DWORD dwClientY; /* height of client area */ 24 #endif 25 DWORD dwLineLen; /* line length */ 26 DWORD dwLines; /* text lines in client area */ 27 int nWindowX; /* horizontal position of window */ 28 int nWindowY; /* vertical position of window */ 29 int WindowWidth; /* width of window */ 30 int WindowHeight; /* height of window */ 31 int nCaretPosX; /* horizontal position of the carat */ 32 int nCaretPosY; /* vertical position of the carat */ 33 int nCharWidth; /* width of a character */ 34 int nCurChar; /* current character */ 35 int BackGroundColor; /* background color */ 36 int NormalTextColor; /* default text color */ 37 int maxrows, maxcols; /* the maximum size used */ 38 /* maxcols is also used by WIN_MESSAGE for */ 39 /* tracking the ^P command */ 40 /* NetHack data */ 41 int *glyph; /* the glyph values for a tiled map window */ 42 uchar *data; /* the character value if not tiled */ 43 int *color; /* the text color for the data in the window */ 44 char *resp; /* valid menu responses (for NHW_INVEN) */ 45 char *canresp; /* cancel responses; 1st is the return value */ 46 char *morestr; /* string to display instead of default */ 47 long wflags; 48 short cursx, cursy; /* Where the cursor is displayed at */ 49 short curs_apen, /* Color cursor is displayed in */ 50 curs_bpen; 51 short extra; /* temporary values between window calls */ 52 }; 53 54 struct win32_DisplayDesc { 55 /* we need this for Screen size (which will vary with display mode) */ 56 uchar rows, cols; /* width & height of display in text units */ 57 short xpix, ypix; /* width and height of display in pixels */ 58 int toplin; /* flag for topl stuff */ 59 int rawprint; /* number of raw_printed lines since synch */ 60 winid lastwin; /* last window used for I/O */ 61 }; 62 63 struct win32_menuitem { 64 int glyph; 65 anything identifier; 66 char ch; 67 int attr; 68 char *str; 69 }; 70 71 #ifdef TEXTCOLOR 72 #define zap_color(n) color = iflags.use_color ? zapcolors[n] : NO_COLOR 73 #define cmap_color(n) color = iflags.use_color ? defsyms[n].color : NO_COLOR 74 #define obj_color(n) color = iflags.use_color ? objects[n].oc_color : NO_COLOR 75 #define mon_color(n) color = iflags.use_color ? mons[n].mcolor : NO_COLOR 76 #define pet_color(n) color = iflags.use_color ? mons[n].mcolor : \ 77 /* If no color, try to hilite pets; black */ \ 78 /* should be HI */ \ 79 ((iflags.hilite_pet && has_color(CLR_BLACK)) ? \ 80 CLR_BLACK : NO_COLOR) 81 # else /* no text color */ 82 #define zap_color(n) 83 #define cmap_color(n) 84 #define obj_color(n) 85 #define mon_color(n) 86 #define pet_color(c) 87 #endif 88 89 #define WINMODE_TTY 0 90 #define WINMODE_WIN32 1 91 #define MAXWIN 20 /* maximum number of windows, cop-out */ 92 #define NHIcon 500 93 #define MAX_KEYS 100 94 #define BUFSIZE 65535 95 #define SHIFTED 0x8000 96 #define RINGBUFSIZE 132 97 #define MAX_MESSAGE_COUNT 5 98 #define MAX_INVENTORY 52 /* maximum items allowed in inventory */ 99 #define MAX_MENU_WINDOWS MAXWIN /* max inventory windows on the go */ 100 101 #define WFLAGS_TILED 0x0001L 102 103 #define TYPE_INVALID -1 104 #define TYPE_UNDETERMINED -2 105 106 #define IDM_SAVE 100 107 #define IDM_QUIT 101 108 #define IDM_EXIT 102 109 #define IDM_GAMEOPT 300 110 #define IDM_ENVOPT 301 111 #define IDM_DISPOPT 302 112 #define IDM_HELPCONTENTS 400 113 #define IDM_HELPSEARCH 401 114 #define IDM_HELPHELP 402 115 #define IDM_ABOUT 403 116 117 #define IDD_INPUTTEXT 501 118 #define IDD_QUESTION 502 119 #define IDD_NAME 503 120 #define IDD_ARCH 601 121 #define IDD_BARB 602 122 #define IDD_CAVEMAN 603 123 #define IDD_ELF 604 124 #define IDD_HEAL 605 125 #define IDD_KNIGHT 606 126 #define IDD_PRIEST 607 127 #define IDD_ROGUE 608 128 #define IDD_SAM 609 129 #define IDD_TOUR 610 130 #define IDD_VAL 611 131 #define IDD_WIZ 612 132 #define IDD_RAND 613 133 #define IDD_ABOUT1 616 134 #define IDD_ABOUT2 617 135 #define IDD_ABOUT3 618 136 #define IDD_ABOUT4 619 137 #define IDD_ABOUT5 620 138 #define IDD_ABOUT6 621 139 #define IDD_ABOUT7 622 140 #define IDD_ABOUT8 623 141 #define IDD_ABOUT9 624 142 143 #define IDD_LB1 700 144 145 146 #define DEBUG_MSG(str) \ 147 if (strlen(str) != 0) \ 148 MessageBox(BasehWnd,str,"Debug",MB_SYSTEMMODAL|MB_ICONHAND); 149 150 #define POP_MESSAGE(str) \ 151 if (strlen(str) != 0) \ 152 MessageBox(BasehWnd,str,"NetHackMenu",MB_SYSTEMMODAL); 153 154 #define NHW_BASE 0 155 156 /* 157 * The following global variables are defined in nhprocs.c 158 */ 159 extern struct win32_WinDesc *wins[MAXWIN]; 160 extern struct win32_DisplayDesc *win32Display; 161 extern char morc; /* last character typed to xwaitforspace */ 162 extern char defmorestr[]; /* default --more-- prompt */ 163 extern winid WIN_BASE; 164 165 /* 166 * The following global variables are defined in winmain.c 167 */ 168 169 extern WNDCLASS wcNetHack; 170 extern WNDCLASS wcNHText; 171 extern WNDCLASS wcNHPopup; 172 extern WNDCLASS wcNHListbox; 173 extern char GameName[]; 174 extern char NHTextClassName[]; 175 extern char NHPopupClassName[]; 176 extern char NHListboxClassName[]; 177 extern HANDLE hGlobInstance; 178 extern HWND BasehWnd; 179 180 extern unsigned char *pchBuf; /* input "ring" buffer */ 181 extern unsigned char *pchGet; /* "Get" chars from here */ 182 extern unsigned char *pchPut; /* "Put" chars here */ 183 extern int pchCount; /* characters in ring buffer */ 184 extern int BaseUnits; 185 extern int BaseHeight; 186 extern int BaseWidth; 187 extern int MessageHeight; 188 extern int MessageWidth; 189 extern int MessageX; 190 extern int MessageY; 191 extern int MessageCount; 192 extern char *MessagePtr[MAX_MESSAGE_COUNT]; 193 extern int MapHeight; 194 extern int MapWidth; 195 extern int MapX; 196 extern int MapY; 197 extern int StatusHeight; 198 extern int StatusWidth; 199 extern int StatusX; 200 extern int StatusY; 201 extern int tiles_on; /* tiles enabled */ 202 extern int DefCharWidth; 203 extern int DefCharHeight; 204 extern int DefBackGroundColor; 205 extern int DefNormalTextColor; 206 extern struct win32_menuitem *MenuPtr[MAX_MENU_WINDOWS][MAX_INVENTORY]; 207 extern int MenuCount[MAX_MENU_WINDOWS]; 208 extern int MenuWindowCount; 209 extern COLORREF colormap[]; 210 extern HFONT hDefFnt; 211 extern TEXTMETRIC tm; 212 extern RECT rcClient; 213 extern int inputstatus; 214 215 extern char input_text[BUFSZ]; 216 extern int input_text_size; 217 # define WAITING_FOR_KEY 1 218 # define WAITING_FOR_MOUSE 2 219 # define WAITING_FOR_KEY_OR_MOUSE (WAITING_FOR_KEY | WAITING_FOR_MOUSE) 220 221 222 /* JUNK TO GO */ 223 /* extern winid WIN_VIEW; */ 224 /* extern winid WIN_VIEWBOX; */ 225 /* #define NHW_VIEW 7 */ 226 /* #define NHW_VIEWBOX 8 */ 227 228 /* extern struct win32_WinDesc *win32_wins[MAXWIN + 6]; */ 229 230 231 232 /*############################################################ 233 * External function prototypes 234 *############################################################ 235 */ 236 #define E extern 237 238 239 /* #### nhproc.c #### */ 240 241 E void NDECL(win32_init_nhwindows); 242 E void NDECL(win32_player_selection); 243 E void NDECL(win32_askname); 244 E void NDECL(win32_get_nh_event) ; 245 E void FDECL(win32_exit_nhwindows, (const char *)); 246 E void FDECL(win32_suspend_nhwindows, (const char *)); 247 E void NDECL(win32_resume_nhwindows); 248 E winid FDECL(win32_create_nhwindow, (int)); 249 E void FDECL(win32_clear_nhwindow, (winid)); 250 E void FDECL(win32_display_nhwindow, (winid, BOOLEAN_P)); 251 E void FDECL(win32_dismiss_nhwindow, (winid)); 252 E void FDECL(win32_destroy_nhwindow, (winid)); 253 E void FDECL(win32_curs, (winid,int,int)); 254 E void FDECL(win32_putstr, (winid, int, const char *)); 255 #ifdef FILE_AREAS 256 E void FDECL(win32_display_file, (const char *, const char *, BOOLEAN_P)); 257 #else 258 E void FDECL(win32_display_file, (const char *, BOOLEAN_P)); 259 #endif 260 E void FDECL(win32_start_menu, (winid)); 261 E void FDECL(win32_add_menu, (winid,int,const ANY_P, 262 CHAR_P,int,const char *, BOOLEAN_P)); 263 E void FDECL(win32_end_menu, (winid, const char *)); 264 E int FDECL(win32_select_menu, (winid, int, MENU_ITEM_P **)); 265 E void NDECL(win32_update_inventory); 266 E void NDECL(win32_mark_synch); 267 E void NDECL(win32_wait_synch); 268 #ifdef CLIPPING 269 E void FDECL(win32_cliparound, (int, int)); 270 #endif 271 E void FDECL(win32_print_glyph, (winid,XCHAR_P,XCHAR_P,int)); 272 E void FDECL(win32_raw_print, (const char *)); 273 E void FDECL(win32_raw_print_bold, (const char *)); 274 E int NDECL(win32_nhgetch); 275 E int FDECL(win32_nh_poskey, (int *, int *, int *)); 276 E void NDECL(win32_nhbell); 277 E int NDECL(win32_doprev_message); 278 E char FDECL(win32_yn_function, (const char *, const char *, CHAR_P)); 279 E void FDECL(win32_getlin, (const char *,char *)); 280 E int NDECL(win32_get_ext_cmd); 281 E void FDECL(win32_number_pad, (int)); 282 E void NDECL(win32_delay_output); 283 284 /* other defs that really should go away (they're win32 specific) */ 285 E void NDECL(win32_start_screen); 286 E void NDECL(win32_end_screen); 287 E void FDECL(genl_outrip, (winid,int)); 288 289 /* #### win32msg.c #### */ 290 291 E LONG WINAPI BaseWndProc(HWND,UINT,UINT,LONG); 292 E LONG WINAPI TextWndProc(HWND,UINT,UINT,LONG); 293 E LONG WINAPI PopupWndProc(HWND,UINT,UINT,LONG); 294 E LONG WINAPI ListboxWndProc(HWND,UINT,UINT,LONG); 295 E BOOL WINAPI PlayerSelectProc(HWND,UINT,UINT,LONG); 296 E BOOL WINAPI CopyrightProc(HWND,UINT,UINT,LONG); 297 E BOOL WINAPI AskNameProc(HWND,UINT,UINT,LONG); 298 E LRESULT CALLBACK MenuDialogProc(HWND,UINT,UINT,LONG); 299 E int win32_kbhit(void); 300 301 /* #### winmain.c #### */ 302 303 E void NDECL(win_win32_init); 304 E BOOL InitBaseWindow(void); 305 E BOOL InitTextWindow(void); 306 E BOOL InitPopupWindow(void); 307 E BOOL InitListboxWindow(void); 308 E BOOL CALLBACK EnumChildProc(HWND,LPARAM); 309 #if 0 310 E void WinClear(HWND); 311 E int WinGetChar(HWND); 312 E int WinPutChar(HWND,int,int,int); 313 E void WinMinSize(HWND,int,int); 314 E void WinHackGetText(const char *,char *); 315 #endif 316 #undef E 317 318 #endif /* WIN32_H */ 319