From: nhmall Date: Thu, 23 Jun 2022 18:01:35 +0000 (-0400) Subject: groundwork for an interface change X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=736e9f14f8bda4f6209e873f9a2339d8e87e03a6;p=nethack groundwork for an interface change Add a new window-port interface function perminvent_info * update_invent_slot(winid window, int slot, perminvent_info *); That should be nice and flexible and allow exchanges of useful information between the core and the window port. Information to be exchange can be easily modified in include/wintype.h as things evolve. Information useful to the core can be exchanged from the window-port in struct to_core. Information useful from the core to the window-port can be passed in struct from_core. I'm not going to update any docs until much later after things are fully working and settled. This also doesn't fix or have anything to do with existing TTY_PERM_INVENT issues. --- diff --git a/include/winX.h b/include/winX.h index 82efa3d42..66bb9f506 100644 --- a/include/winX.h +++ b/include/winX.h @@ -450,7 +450,6 @@ extern void X11_add_menu(winid, const glyph_info *, const ANY_P *, char, char, int, const char *, unsigned int); extern void X11_end_menu(winid, const char *); extern int X11_select_menu(winid, int, MENU_ITEM_P **); -extern void X11_update_inventory(int); extern void X11_mark_synch(void); extern void X11_wait_synch(void); #ifdef CLIPPING @@ -487,5 +486,7 @@ extern void genl_outrip(winid, int, time_t); #endif extern void X11_preference_update(const char *); +extern void X11_update_inventory(int); +extern perminvent_info *X11_update_invent_slot(winid, int, perminvent_info *); #endif /* WINX_H */ diff --git a/include/wincurs.h b/include/wincurs.h index 31b61256e..1c3b60efd 100644 --- a/include/wincurs.h +++ b/include/wincurs.h @@ -89,7 +89,6 @@ extern void curses_add_menu(winid wid, const glyph_info *, const char *str, unsigned int itemflags); extern void curses_end_menu(winid wid, const char *prompt); extern int curses_select_menu(winid wid, int how, MENU_ITEM_P **selected); -extern void curses_update_inventory(int); extern void curses_mark_synch(void); extern void curses_wait_synch(void); extern void curses_cliparound(int x, int y); @@ -113,6 +112,8 @@ extern void curses_outrip(winid wid, int how, time_t when); extern void genl_outrip(winid tmpwin, int how, time_t when); extern void curses_preference_update(const char *pref); extern void curs_reset_windows(boolean, boolean); +extern void curses_update_inventory(int); +extern perminvent_info *curses_update_invent_slot(winid, int, perminvent_info *); /* curswins.c */ diff --git a/include/winprocs.h b/include/winprocs.h index 08f9ebc72..3f6442837 100644 --- a/include/winprocs.h +++ b/include/winprocs.h @@ -37,7 +37,6 @@ struct window_procs { void (*win_end_menu)(winid, const char *); int (*win_select_menu)(winid, int, MENU_ITEM_P **); char (*win_message_menu)(char, int, const char *); - void (*win_update_inventory)(int); void (*win_mark_synch)(void); void (*win_wait_synch)(void); #ifdef CLIPPING @@ -83,6 +82,8 @@ struct window_procs { void (*win_status_update)(int, genericptr_t, int, int, int, unsigned long *); boolean (*win_can_suspend)(void); + void (*win_update_inventory)(int); + perminvent_info *(*win_update_invent_slot)(winid, int, perminvent_info *); }; extern @@ -164,6 +165,7 @@ extern */ #define status_enablefield (*windowprocs.win_status_enablefield) #define status_update (*windowprocs.win_status_update) +#define update_invent_slot (*windowprocs.win_update_invent_slot) /* * WINCAP @@ -421,7 +423,6 @@ extern void safe_add_menu(winid, const glyph_info *, const ANY_P *, extern void safe_end_menu(winid, const char *); extern int safe_select_menu(winid, int, MENU_ITEM_P **); extern char safe_message_menu(char, int, const char *); -extern void safe_update_inventory(int); extern void safe_mark_synch(void); extern void safe_wait_synch(void); #ifdef CLIPPING @@ -468,6 +469,8 @@ extern void stdio_raw_print(const char *); extern void stdio_nonl_raw_print(const char *); extern void stdio_raw_print_bold(const char *); extern void stdio_wait_synch(void); +extern void safe_update_inventory(int); +extern perminvent_info *safe_update_invent_slot(winid, int, perminvent_info *); extern int stdio_nhgetch(void); #endif /* SAFEPROCS */ #endif /* WINPROCS_H */ diff --git a/include/wintty.h b/include/wintty.h index 1c7bf527e..0baa4477f 100644 --- a/include/wintty.h +++ b/include/wintty.h @@ -242,7 +242,6 @@ E void tty_add_menu(winid, const glyph_info *, const ANY_P *, char, char, E void tty_end_menu(winid, const char *); E int tty_select_menu(winid, int, MENU_ITEM_P **); E char tty_message_menu(char, int, const char *); -E void tty_update_inventory(int); E void tty_mark_synch(void); E void tty_wait_synch(void); #ifdef CLIPPING @@ -284,6 +283,8 @@ E void genl_outrip(winid, int, time_t); E char *tty_getmsghistory(boolean); E void tty_putmsghistory(const char *, boolean); +E void tty_update_inventory(int); +E perminvent_info *tty_update_invent_slot(winid, int, perminvent_info *); #ifdef TTY_PERM_INVENT E void tty_refresh_inventory(int start, int stop, int y); diff --git a/include/wintype.h b/include/wintype.h index 9e54c21e1..e262b1aa9 100644 --- a/include/wintype.h +++ b/include/wintype.h @@ -162,6 +162,28 @@ typedef struct gi { #define MENU_BEHAVE_STANDARD 0x0000000U +struct to_core { + boolean active; + boolean use_update_inventory; /* disable the newer slot interface */ + int slotcount; + int low_slot_num, high_slot_num; + int max_slot_text; +}; + +struct from_core { + long piflags; + int slot; /* which inventory slot; 0 means info exchange only */ + int invlet; + const char *text; /* the text to display */ +}; + +struct perminvent_info_t { + struct to_core tocore; + struct from_core fromcore; +}; + +typedef struct perminvent_info_t perminvent_info; + /* clang-format on */ #endif /* WINTYPE_H */ diff --git a/src/windows.c b/src/windows.c index c0b680c37..863b368a8 100644 --- a/src/windows.c +++ b/src/windows.c @@ -536,6 +536,7 @@ static void hup_void_fdecl_int(int); static void hup_void_fdecl_winid(winid); static void hup_void_fdecl_winid_ulong(winid, unsigned long); static void hup_void_fdecl_constchar_p(const char *); +static perminvent_info *hup_update_invent_slot(winid, int, perminvent_info *); static struct window_procs hup_procs = { "hup", 0L, 0L, @@ -551,7 +552,6 @@ static struct window_procs hup_procs = { hup_curs, hup_putstr, hup_putstr, /* putmixed */ hup_display_file, hup_void_fdecl_winid_ulong, /* start_menu */ hup_add_menu, hup_end_menu, hup_select_menu, genl_message_menu, - hup_void_fdecl_int, /* update_inventory */ hup_void_ndecl, /* mark_synch */ hup_void_ndecl, /* wait_synch */ #ifdef CLIPPING @@ -584,6 +584,8 @@ static struct window_procs hup_procs = { hup_void_ndecl, /* status_finish */ genl_status_enablefield, hup_status_update, genl_can_suspend_no, + hup_void_fdecl_int, /* update_inventory */ + hup_update_invent_slot, /* update_invent_slot */ }; static void (*previnterface_exit_nhwindows)(const char *) = 0; @@ -837,6 +839,18 @@ hup_void_fdecl_constchar_p(const char *string UNUSED) return; } +/*ARGUSED*/ +perminvent_info * +hup_update_invent_slot( + winid window UNUSED, /* window to use, must be of type NHW_MENU */ + int inventory_slot UNUSED, /* slot id: 0 - info return to core */ + /* 1 - gold slot */ + /* 2 - 29 obj slots */ + perminvent_info *pi UNUSED) +{ + return (perminvent_info *) 0; +} + #endif /* HANGUPHANDLING */ diff --git a/win/Qt/qt_bind.cpp b/win/Qt/qt_bind.cpp index b5ee273cb..07229b6d3 100644 --- a/win/Qt/qt_bind.cpp +++ b/win/Qt/qt_bind.cpp @@ -490,6 +490,17 @@ void NetHackQtBind::qt_update_inventory(int arg UNUSED) */ } +perminvent_info *NetHackQtBind::qt_update_invent_slot( + winid wid UNUSED, /* window to use, must be of type NHW_MENU */ + int inventory_slot UNUSED, /* slot id: 0 - info return to core */ + /* 1 - gold slot */ + /* 2 - 29 obj slots */ + perminvent_info *pi UNUSED) +{ + NetHackQtWindow* window UNUSED =id_to_window[(int)wid]; + return (perminvent_info *) 0; +} + void NetHackQtBind::qt_mark_synch() { } @@ -1053,7 +1064,6 @@ struct window_procs Qt_procs = { nethack_qt_::NetHackQtBind::qt_end_menu, nethack_qt_::NetHackQtBind::qt_select_menu, genl_message_menu, /* no need for Qt-specific handling */ - nethack_qt_::NetHackQtBind::qt_update_inventory, nethack_qt_::NetHackQtBind::qt_mark_synch, nethack_qt_::NetHackQtBind::qt_wait_synch, #ifdef CLIPPING @@ -1100,6 +1110,8 @@ struct window_procs Qt_procs = { genl_status_update, #endif genl_can_suspend_yes, + nethack_qt_::NetHackQtBind::qt_update_inventory, + nethack_qt_::NetHackQtBind::qt_update_invent_slot, }; #ifndef WIN32 diff --git a/win/Qt/qt_bind.h b/win/Qt/qt_bind.h index f00f86440..112da9f0d 100644 --- a/win/Qt/qt_bind.h +++ b/win/Qt/qt_bind.h @@ -58,7 +58,6 @@ public: const char *str, unsigned int itemflags); static void qt_end_menu(winid wid, const char *prompt); static int qt_select_menu(winid wid, int how, MENU_ITEM_P **menu_list); - static void qt_update_inventory(int); static void qt_mark_synch(); static void qt_wait_synch(); @@ -89,6 +88,8 @@ public: static void qt_outrip(winid wid, int how, time_t when); static int qt_kbhit(); + static void qt_update_inventory(int); + static perminvent_info *qt_update_invent_slot(winid, int, perminvent_info *); static QWidget *mainWidget() { return main; } diff --git a/win/X11/winX.c b/win/X11/winX.c index 6a0a20705..12e605b2b 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -117,7 +117,7 @@ struct window_procs X11_procs = { X11_putstr, genl_putmixed, X11_display_file, X11_start_menu, X11_add_menu, X11_end_menu, X11_select_menu, genl_message_menu, /* no need for X-specific handling */ - X11_update_inventory, X11_mark_synch, X11_wait_synch, + X11_mark_synch, X11_wait_synch, #ifdef CLIPPING X11_cliparound, #endif @@ -141,6 +141,8 @@ struct window_procs X11_procs = { X11_status_init, X11_status_finish, X11_status_enablefield, X11_status_update, genl_can_suspend_no, /* XXX may not always be correct */ + X11_update_inventory, + X11_update_invent_slot, }; /* @@ -1270,6 +1272,17 @@ X11_update_inventory(int arg) return; } +perminvent_info * +X11_update_invent_slot( + winid window UNUSED, /* window to use, must be of type NHW_MENU */ + int inventory_slot UNUSED, /* slot id: 0 - info return to core */ + /* 1 - gold slot */ + /* 2 - 29 obj slots */ + perminvent_info *pi UNUSED) +{ + return (perminvent_info *) 0; +} + /* The current implementation has all of the saved lines on the screen. */ int X11_doprev_message(void) diff --git a/win/chain/wc_chainin.c b/win/chain/wc_chainin.c index 312ada5ae..e990222c9 100644 --- a/win/chain/wc_chainin.c +++ b/win/chain/wc_chainin.c @@ -29,7 +29,6 @@ void chainin_add_menu(winid, const glyph_info *, const ANY_P *, void chainin_end_menu(winid, const char *); int chainin_select_menu(winid, int, MENU_ITEM_P **); char chainin_message_menu(char, int, const char *); -void chainin_update_inventory(int); void chainin_mark_synch(void); void chainin_wait_synch(void); #ifdef CLIPPING @@ -75,6 +74,8 @@ void chainin_status_update(int, genericptr_t, int, int, int, unsigned long *); boolean chainin_can_suspend(void); +void chainin_update_inventory(int); +perminvent_info *chainin_update_invent_slot(winid, int, perminvent_info *); void *chainin_procs_chain(int cmd, int n, void *me, void *nextprocs, void *nextdata); void chainin_procs_init(int dir); @@ -576,6 +577,21 @@ chainin_can_suspend(void) return rv; } +perminvent_info * +chainin_update_invent_slot( + winid window, /* window to use, must be of type NHW_MENU */ + int inventory_slot, /* slot id: 0 - info return to core */ + /* 1 - gold slot */ + /* 2 - 29 obj slots */ + perminvent_info *pi) +{ + boolean rv; + + rv = (*cibase->nprocs->win_update_invent_slot)(cibase->ndata, window, + inventory_slot, pi); + return rv; +} + struct window_procs chainin_procs = { "-chainin", 0, /* wincap */ 0, /* wincap2 */ @@ -621,4 +637,6 @@ struct window_procs chainin_procs = { chainin_status_init, chainin_status_finish, chainin_status_enablefield, chainin_status_update, chainin_can_suspend, + chainin_update_inventory, + chainin_update_invent_slot, }; diff --git a/win/chain/wc_chainout.c b/win/chain/wc_chainout.c index 4b122ffa9..2a118608a 100644 --- a/win/chain/wc_chainout.c +++ b/win/chain/wc_chainout.c @@ -29,7 +29,6 @@ void chainout_add_menu(void *,winid, const glyph_info *, const ANY_P *, void chainout_end_menu(void *,winid, const char *); int chainout_select_menu(void *,winid, int, MENU_ITEM_P **); char chainout_message_menu(void *,char, int, const char *); -void chainout_update_inventory(void *,int); void chainout_mark_synch(void *); void chainout_wait_synch(void *); #ifdef CLIPPING @@ -75,6 +74,8 @@ void chainout_status_update(void *,int, genericptr_t, int, int, int, unsigned long *); boolean chainout_can_suspend(void *); +void chainout_update_inventory(void *, int); +perminvent_info *chainout_update_invent_slot(void *, winid, int, perminvent_info *); void chainout_procs_init(int dir); void *chainout_procs_chain(int cmd, int n, void *me, void *nextprocs, void *nextdata); @@ -698,6 +699,22 @@ chainout_can_suspend(void *vp) return rv; } +perminvent_info * +chainout_update_invent_slot( + winid window, /* window to use, must be of type NHW_MENU */ + int inventory_slot, /* slot id: 0 - info return to core */ + /* 1 - gold slot */ + /* 2 - 29 obj slots */ + perminvent_info *pi) +{ + struct chainout_data *tdp = vp; + boolean rv; + + rv = (*tdp->nprocs->win_update_invent_slot)(window, + inventory_slot, pi); + return rv; +} + struct chain_procs chainout_procs = { "-chainout", 0, /* wincap */ 0, /* wincap2 */ @@ -744,4 +761,6 @@ struct chain_procs chainout_procs = { chainout_status_init, chainout_status_finish, chainout_status_enablefield, chainout_status_update, chainout_can_suspend, + chainout_update_inventory, + chainout_update_invent_slot, }; diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index 56b7a23ae..df56cae37 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -77,7 +77,6 @@ struct window_procs curses_procs = { curses_end_menu, curses_select_menu, genl_message_menu, - curses_update_inventory, curses_mark_synch, curses_wait_synch, #ifdef CLIPPING @@ -117,6 +116,8 @@ struct window_procs curses_procs = { genl_status_enablefield, curses_status_update, genl_can_suspend_yes, + curses_update_inventory, + curses_update_invent_slot, }; /* @@ -693,6 +694,17 @@ curses_update_inventory(int arg) } } +perminvent_info * +curses_update_invent_slot( + winid window UNUSED, /* window to use, must be of type NHW_MENU */ + int inventory_slot UNUSED, /* slot id: 0 - info return to core */ + /* 1 - gold slot */ + /* 2 - 29 obj slots */ + perminvent_info *pi UNUSED) +{ + return (perminvent_info *) 0; +} + /* mark_synch() -- Don't go beyond this point in I/O on any channel until all channels are caught up to here. Can be an empty call diff --git a/win/share/safeproc.c b/win/share/safeproc.c index 28cfb37a7..5c442d277 100644 --- a/win/share/safeproc.c +++ b/win/share/safeproc.c @@ -74,7 +74,7 @@ struct window_procs safe_procs = { safe_create_nhwindow, safe_clear_nhwindow, safe_display_nhwindow, safe_destroy_nhwindow, safe_curs, safe_putstr, safe_putmixed, safe_display_file, safe_start_menu, safe_add_menu, safe_end_menu, - safe_select_menu, safe_message_menu, safe_update_inventory, + safe_select_menu, safe_message_menu, safe_mark_synch, safe_wait_synch, #ifdef CLIPPING @@ -100,6 +100,8 @@ struct window_procs safe_procs = { safe_status_finish, safe_status_enablefield, safe_status_update, safe_can_suspend, + safe_update_inventory, + safe_update_invent_slot, }; struct window_procs * @@ -270,12 +272,6 @@ safe_message_menu( return '\033'; } -void -safe_update_inventory(int arg UNUSED) -{ - return; -} - void safe_mark_synch(void) { @@ -476,6 +472,23 @@ safe_status_update( { } +void +safe_update_inventory(int arg UNUSED) +{ + return; +} + +perminvent_info * +safe_update_invent_slot( + winid window, /* window to use, must be of type NHW_MENU */ + int inventory_slot, /* slot id: 0 - info return to core */ + /* 1 - gold slot */ + /* 2 - 29 obj slots */ + perminvent_info *pi) +{ + return (perminvent_info *) 0; +} + /************************************************************** * These are some optionally selectable routines that add * some base functionality over the safe_* versions above. diff --git a/win/shim/winshim.c b/win/shim/winshim.c index 4f9fccf42..2c4454968 100644 --- a/win/shim/winshim.c +++ b/win/shim/winshim.c @@ -183,8 +183,21 @@ void shim_update_inventory(int a1 UNUSED) { display_inventory(NULL, FALSE); } } +perminvent_info * +shim_update_invent_slot( + winid window UNUSED, /* window to use, must be of type NHW_MENU */ + int inventory_slot UNUSED, /* slot id: 0 - info return to core */ + /* 1 - gold slot */ + /* 2 - 29 obj slots */ + perminvent_info *pi UNUSED) { + return (perminvent_info *) 0; +} #else /* !__EMSCRIPTEN__ */ -VDECLCB(shim_update_inventory,(int a1 UNUSED), "v") +VDECLCB(shim_update_inventory,(int a1 UNUSED) +DECLB(perminvent_info *, shim_update_invent_slot, + (winid window, int inventory_slot, perminvent_info *pi), + "viip", + A2P window UNUSED, A2P inventory_slot UNUSED, P2V pi UNUSED) #endif /* Interface definition used in windows.c */ @@ -212,7 +225,7 @@ struct window_procs shim_procs = { shim_create_nhwindow, shim_clear_nhwindow, shim_display_nhwindow, shim_destroy_nhwindow, shim_curs, shim_putstr, genl_putmixed, shim_display_file, shim_start_menu, shim_add_menu, shim_end_menu, - shim_select_menu, shim_message_menu, shim_update_inventory, shim_mark_synch, + shim_select_menu, shim_message_menu, shim_mark_synch, shim_wait_synch, #ifdef CLIPPING shim_cliparound, @@ -243,6 +256,8 @@ struct window_procs shim_procs = { genl_status_update, #endif genl_can_suspend_yes, + shim_update_inventory, + shim_update_invent_slot, }; #ifdef __EMSCRIPTEN__ diff --git a/win/tty/wintty.c b/win/tty/wintty.c index b4809569a..7a7bb1b86 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -135,7 +135,7 @@ struct window_procs tty_procs = { tty_destroy_nhwindow, tty_curs, tty_putstr, tty_putmixed, tty_display_file, tty_start_menu, tty_add_menu, tty_end_menu, - tty_select_menu, tty_message_menu, tty_update_inventory, tty_mark_synch, + tty_select_menu, tty_message_menu, tty_mark_synch, tty_wait_synch, #ifdef CLIPPING tty_cliparound, @@ -166,6 +166,8 @@ struct window_procs tty_procs = { genl_status_update, #endif genl_can_suspend_yes, + tty_update_inventory, + tty_update_invent_slot, }; winid BASE_WINDOW; @@ -3597,6 +3599,17 @@ tty_update_inventory(int arg UNUSED) return; } +perminvent_info * +tty_update_invent_slot( + winid window UNUSED, /* window to use, must be of type NHW_MENU */ + int inventory_slot UNUSED, /* slot id: 0 - info return to core */ + /* 1 - gold slot */ + /* 2 - 29 obj slots */ + perminvent_info *pi UNUSED) +{ + return (perminvent_info *) 0; +} + #ifdef TTY_PERM_INVENT /* put the formatted object description for one item into a particular row diff --git a/win/win32/mswproc.c b/win/win32/mswproc.c index eef79cd92..29507a3d2 100644 --- a/win/win32/mswproc.c +++ b/win/win32/mswproc.c @@ -100,7 +100,7 @@ struct window_procs mswin_procs = { genl_putmixed, mswin_display_file, mswin_start_menu, mswin_add_menu, mswin_end_menu, mswin_select_menu, genl_message_menu, /* no need for X-specific handling */ - mswin_update_inventory, mswin_mark_synch, mswin_wait_synch, + mswin_mark_synch, mswin_wait_synch, #ifdef CLIPPING mswin_cliparound, #endif @@ -119,6 +119,8 @@ struct window_procs mswin_procs = { mswin_status_init, mswin_status_finish, mswin_status_enablefield, mswin_status_update, genl_can_suspend_yes, + mswin_update_inventory, + mswin_update_invent_slot, }; /* @@ -1241,6 +1243,17 @@ mswin_update_inventory(int arg) display_inventory(NULL, FALSE); } +perminvent_info * +mswin_update_invent_slot( + winid window, /* window to use, must be of type NHW_MENU */ + int inventory_slot, /* slot id: 0 - info return to core */ + /* 1 - gold slot */ + /* 2 - 29 obj slots */ + perminvent_info *pi) +{ + return (perminvent_info *) 0; +} + /* mark_synch() -- Don't go beyond this point in I/O on any channel until all channels are caught up to here. Can be an empty call diff --git a/win/win32/winMS.h b/win/win32/winMS.h index 5d6b53c50..be2f6fec7 100644 --- a/win/win32/winMS.h +++ b/win/win32/winMS.h @@ -161,7 +161,6 @@ void mswin_add_menu(winid wid, const glyph_info *glyphinfo, const char *str, unsigned int itemflags); void mswin_end_menu(winid wid, const char *prompt); int mswin_select_menu(winid wid, int how, MENU_ITEM_P **selected); -void mswin_update_inventory(int); void mswin_mark_synch(void); void mswin_wait_synch(void); void mswin_cliparound(int x, int y); @@ -193,6 +192,8 @@ void mswin_status_finish(void); void mswin_status_enablefield(int fieldidx, const char *nm, const char *fmt, boolean enable); void mswin_status_update(int idx, genericptr_t ptr, int chg, int percent, int color, unsigned long *colormasks); +void mswin_update_inventory(int); +perminvent_info *mswin_update_invent_slot(winid, int, perminvent_info *); /* helper function */ HWND mswin_hwnd_from_winid(winid wid);