Two things: 1. This patch causes the window placement of the main window to be written to the registry, and to be restored upon the next start of the program. I had to move the creation of the main window to init_nhwindows, as the registry is not read until then. 2. Implement support for wc_popup_dialog (or rather, support for not having popup windows.) It asks getlin questions and get_ext_cmd on the message window, much like the TTY port does it. The get_ext_cmd procedure is almost but not quite the same as the one for TTY, and I think it is better: It autocompletes the extended command you type, but if you keep on typing it doesn't add those letters after the completed command, but just keeps track of how many (correct) characters you typed. If you type a different character than the autocompleted command has, it shows you what you typed again. If you press backspace, it deletes the characters you typed, and if autocompletion is no longer possible, it removes the autocompleted part. The effect of this is that you can type as many letters as you want when typing an extended command, as long as it is enough to identify one command; and you only have to delete the characters you actually typed if you made a mistake. I think autocompletion is a lot less obtrusive this way. Some notes about the patch: - Both mswin_getlin and mswin_get_ext_cmd now have two versions, with and without a popup. - yn_question was changed so that it displays a caret, which is a lot nicer IMHO. - I had to implement a new NetHack Windows Message parameter, "MSNH_MSG_CARET", to make it possible to show and hide the caret in the message window. Normally the caret is created and destroyed by the window that owns it, but in NetHack the input focus is always on the main window, while the caret is in the message window, which happens to be the only one that knows how large the caret should be. - mswin_putstr_ex's last parameter changed from boolean to int; the semantics are enhanced so that a negative last parameter means "delete that many characters from the input line". The string to be deleted is passed in as well, although it is currently not used. - A rather large chunk of code finds out where the last string that was displayed on the message window ended. This is necessary to place the caret at the right spot. The caret is always positioned there, even if it is hidden or non-existing. - mswin_get_nh_event was changed to actually process and empty the message queue, and called from mswin_putstr_ex to make sure the message window is updated before the next step is done. Without this, the caret is positioned before the last message is painted, which makes its x-position after the last character of the previous line.
63 lines
1.4 KiB
C
63 lines
1.4 KiB
C
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
|
/* NetHack may be freely redistributed. See license for details. */
|
|
|
|
#ifndef MHNethackMessages_H
|
|
#define MHNethackMessages_H
|
|
|
|
/* nethack messages */
|
|
#define WM_MSNH_COMMAND (WM_APP+1)
|
|
|
|
#define MSNH_MSG_ADDWND 100
|
|
#define MSNH_MSG_PUTSTR 101
|
|
#define MSNH_MSG_PRINT_GLYPH 102
|
|
#define MSNH_MSG_CLEAR_WINDOW 103
|
|
#define MSNH_MSG_CLIPAROUND 104
|
|
#define MSNH_MSG_STARTMENU 105
|
|
#define MSNH_MSG_ADDMENU 106
|
|
#define MSNH_MSG_CURSOR 107
|
|
#define MSNH_MSG_ENDMENU 108
|
|
#define MSNH_MSG_DIED 109
|
|
#define MSNH_MSG_CARET 110
|
|
|
|
typedef struct mswin_nhmsg_add_wnd {
|
|
winid wid;
|
|
} MSNHMsgAddWnd, *PMSNHMsgAddWnd;
|
|
|
|
typedef struct mswin_nhmsg_putstr {
|
|
int attr;
|
|
const char* text;
|
|
boolean append;
|
|
} MSNHMsgPutstr, *PMSNHMsgPutstr;
|
|
|
|
typedef struct mswin_nhmsg_print_glyph {
|
|
XCHAR_P x;
|
|
XCHAR_P y;
|
|
int glyph;
|
|
} MSNHMsgPrintGlyph, *PMSNHMsgPrintGlyph;
|
|
|
|
typedef struct mswin_nhmsg_cliparound {
|
|
int x;
|
|
int y;
|
|
} MSNHMsgClipAround, *PMSNHMsgClipAround;
|
|
|
|
typedef struct mswin_nhmsg_add_menu {
|
|
int glyph;
|
|
const ANY_P* identifier;
|
|
CHAR_P accelerator;
|
|
CHAR_P group_accel;
|
|
int attr;
|
|
const char * str;
|
|
BOOLEAN_P presel;
|
|
} MSNHMsgAddMenu, *PMSNHMsgAddMenu;
|
|
|
|
typedef struct mswin_nhmsg_cursor {
|
|
int x;
|
|
int y;
|
|
} MSNHMsgCursor, *PMSNHMsgCursor;
|
|
|
|
typedef struct mswin_nhmsg_end_menu {
|
|
const char* text;
|
|
} MSNHMsgEndMenu, *PMSNHMsgEndMenu;
|
|
|
|
#endif
|