move some parts of TTY_PERM_INVENT into core

This starts the tty perm_invent just in time later in the
startup rather than initializing it with the other
game windows.

This also splits the duties:

The core will inquire from the window port about how many
inventory slots it can fill.

The core will handle figuring out the inventory text and
inventory letters, and will do the traversing of internal
data structures like obj chains, and passing customization
options on to the window port.

The window port will look after placing each inventory slot's
text at an appropriate location on the screen.

This, in theory, makes the core-portion available for
window ports other than tty to use, though none currently do.
The decision of what goes in an inventory slot is all left up
to the core with the update_invent_slot interface.

Documentation updates will come later, not at this time.
This commit is contained in:
nhmall
2022-06-24 15:01:38 -04:00
parent 90e7fdaa4b
commit 18b28084f8
9 changed files with 422 additions and 109 deletions

View File

@@ -972,9 +972,9 @@ struct instance_globals {
persistent one doesn't get shrunk during filtering for item selection
then regrown to full inventory, possibly being resized in the process */
winid cached_pickinv_win;
#ifdef TTY_PERM_INVENT
winid tty_invent_win;
#endif
winid perm_invent_win;
int core_invent_state;
/* query objlist callback: return TRUE if obj type matches "this_type" */
int this_type;
const char *this_title; /* title for inventory list of specific type */

View File

@@ -1174,6 +1174,7 @@ extern long count_contents(struct obj *, boolean, boolean, boolean, boolean);
extern void carry_obj_effects(struct obj *);
extern const char *currency(long);
extern void silly_thing(const char *, struct obj *);
extern void core_update_invent_slot(void);
/* ### ioctl.c ### */

View File

@@ -11,6 +11,7 @@
#define WINDOW_STRUCTS
#ifdef TTY_PERM_INVENT
enum { tty_pi_minrow = 28, tty_pi_mincol = 79 };
/* for static init of zerottycell, put pointer first */
union ttycellcontent {
@@ -123,11 +124,7 @@ struct tty_status_fields {
#ifdef NHW_BASE
#undef NHW_BASE
#endif
#define NHW_BASE (NHW_TEXT + 1)
#ifdef TTY_PERM_INVENT
#define NHW_TTYINVENT (NHW_BASE + 1)
#endif
#define NHW_BASE (NHW_LAST_TYPE + 1)
extern struct window_procs tty_procs;

View File

@@ -111,6 +111,8 @@ typedef struct gi {
#define NHW_MAP 3
#define NHW_MENU 4
#define NHW_TEXT 5
#define NHW_PERMINVENT 6
#define NHW_LAST_TYPE NHW_PERMINVENT
/* attribute types for putstr; the same as the ANSI value, for convenience */
#define ATR_NONE 0
@@ -162,19 +164,37 @@ typedef struct gi {
#define MENU_BEHAVE_STANDARD 0x0000000U
/* inventory modes */
enum inv_modes { InvNormal = 0, InvShowGold = 1, InvSparse = 2, InvInUse = 4 };
enum to_core_flags {
active = 0x001,
prohibited = 0x002,
no_init_done = 0x004
};
enum from_core_requests {
request_settings = 1,
update_slot = 2,
render = 3
};
struct to_core {
long tocore_flags;
boolean active;
boolean use_update_inventory; /* disable the newer slot interface */
int slotcount;
int low_slot_num, high_slot_num;
int max_slot_text;
int maxslot;
int needrows, needcols;
int haverows, havecols;
};
struct from_core {
long piflags;
int slot; /* which inventory slot; 0 means info exchange only */
enum from_core_requests core_request;
enum inv_modes invmode;
boolean force_redraw;
int slot; /* which inventory slot; 0 indicates request */
int invlet;
const char *text; /* the text to display */
char text[BUFSZ];
};
struct perminvent_info_t {
@@ -184,6 +204,8 @@ struct perminvent_info_t {
typedef struct perminvent_info_t perminvent_info;
#define CORE_INVENT
/* clang-format on */
#endif /* WINTYPE_H */