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.
This commit is contained in:
nhmall
2022-06-23 14:01:35 -04:00
parent da3c5dfe87
commit 736e9f14f8
17 changed files with 196 additions and 24 deletions

View File

@@ -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

View File

@@ -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; }

View File

@@ -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)

View File

@@ -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,
};

View File

@@ -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,
};

View File

@@ -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

View File

@@ -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.

View File

@@ -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__

View File

@@ -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

View File

@@ -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

View File

@@ -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);