drawing overhaul (trunk only)

This is an overhaul to the NetHack drawing mechanism.

- eliminates the need to have separate lists in drawing.c
for the things and their associated explanations by grouping
those thing together on the same inializer in a struct.

- replaces all of these options: IBMgraphics, DECgraphics, MACgraphics,
graphics, monsters, objects, boulder, traps, effects

- drawing.c contains only the set of NetHack standard symbols for
the main game and a set of NetHack standard symbols for the
roguelevel.

- introduces a symbols file that contains named sets of
symbols that can be loaded at run time making it extensible
for situations like multinational code pages like those reported
by <Someone>, without hardcoding additional sets into the game code.

- symbols file uses names for the symbols, so offsets will not break
when new things are introduced into the game, the way the older
config file uchar load routines did.

- symbols file only contains exceptions to the standard NetHack
set, not entire sets so they are much less verbose than all of
the g_FILLER() entries that were previously in drawing.c

- 'symset' and 'roguesymset' config file options for
preselecting a symbol set from the file called 'symbols'
at startup time. The name of the symbols file is not under the
users control, only the symbol set name desired from within the
symbols file is.

- 'symset' config file option loads a desired symbol set for
everything but the rogue level.

- 'roguesymset' config file option loads a desired symbol set
for the rogue level.

- 'SYMBOLS' config file option allows the user to specify replacement
symbols on a per symbol basis. You can specify as many or as few symbols
as you wish. The symbols are identified by a name:value pair, and line
continuation is supported. Multiple symbol assignments can be made on
the same line if each name:value pair is separated by a comma.
For example:
SYMBOLS = S_bars:\xf0, S_tree: \xf1, S_room:\xfa \
	  S_fountain:\xf4 \
	  S_boulder:0

- 'symbols' file has the following structure:
start: DECgraphics
	Handling: DEC
	S_vwall: \xf8			# meta-x, vertical rule
	S_hwall: \xf1			# meta-q, horizontal rule
finish
start: IBMgraphics
	Handling: IBM
	S_vwall: \xb3			# meta-3, vertical rule
	S_hwall: \xc4			# meta-D, horizontal rule
finish

- 'symbols' file added to the source tree in the dat directory

- Port Makefiles/scripts will need to be adjusted to move them into
HACKDIR destination
This commit is contained in:
nethack.allison
2006-09-21 01:46:15 +00:00
parent 94b66d0be5
commit 253bf359af
39 changed files with 1859 additions and 1339 deletions

View File

@@ -231,9 +231,9 @@ E NEARDATA struct spell spl_book[]; /* sized in decl.c */
E const int zapcolors[];
#endif
E const char def_oc_syms[MAXOCLASSES]; /* default class symbols */
E const struct class_sym def_oc_syms[MAXOCLASSES]; /* default class symbols */
E uchar oc_syms[MAXOCLASSES]; /* current class symbols */
E const char def_monsyms[MAXMCLASSES]; /* default class symbols */
E const struct class_sym def_monsyms[MAXMCLASSES]; /* default class symbols */
E uchar monsyms[MAXMCLASSES]; /* current class symbols */
#include "obj.h"
@@ -269,6 +269,8 @@ E NEARDATA struct mvitals {
uchar mvflags;
} mvitals[NUMMONS];
E struct symparse loadsyms[];
E NEARDATA struct c_color_names {
const char *const c_black, *const c_amber, *const c_golden,
*const c_light_blue,*const c_red, *const c_green,
@@ -347,7 +349,7 @@ E struct tc_gbl_data { /* also declared in tcap.h */
#endif
/* xxxexplain[] is in drawing.c */
E const char * const monexplain[], invisexplain[], * const objexplain[], * const oclass_names[];
E const char * const monexplain[], invisexplain[], * const oclass_names[];
/* Some systems want to use full pathnames for some subsets of file names,
* rather than assuming that they're all in the current directory. This

View File

@@ -491,10 +491,18 @@ E boolean FDECL(hurtle_step, (genericptr_t, int, int));
E int FDECL(def_char_to_objclass, (CHAR_P));
E int FDECL(def_char_to_monclass, (CHAR_P));
#if !defined(MAKEDEFS_C) && !defined(LEV_LEX_C)
E void FDECL(assign_graphics, (uchar *,int,int,int));
E void FDECL(switch_graphics, (int));
#ifdef REINCARNATION
E void FDECL(assign_rogue_graphics, (BOOLEAN_P));
E void NDECL(init_r_symbols);
#endif
E void NDECL(init_symbols);
E void NDECL(init_disp_symbols);
E void NDECL(init_l_symbols);
#ifdef ASCIIGRAPH
E void FDECL(update_l_symset, (struct symparse *,int));
E void FDECL(update_r_symset, (struct symparse *,int));
E void FDECL(switch_graphics, (int));
#endif
#ifdef BARGETHROUGH
E boolean FDECL(cursed_object_at, (int, int));
@@ -710,6 +718,10 @@ E void FDECL(check_recordfile, (const char *));
#if defined(WIZARD)
E void NDECL(read_wizkit);
#endif
#ifdef ASCIIGRAPH
E int FDECL(read_sym_file, (BOOLEAN_P));
E int FDECL(parse_sym_line, (char *,BOOLEAN_P));
#endif
E void FDECL(paniclog, (const char *, const char *));
E int FDECL(validate_prefix_locations, (char *));
E char** NDECL(get_saved_games);
@@ -1524,6 +1536,12 @@ E void FDECL(set_option_mod_status, (const char *,int));
E int FDECL(add_autopickup_exception, (const char *));
E void NDECL(free_autopickup_exceptions);
#endif /* AUTOPICKUP_EXCEPTIONS */
#ifdef ASCIIGRAPH
E int FDECL(load_symset, (const char *,BOOLEAN_P));
E void FDECL(parsesymbols, (char *));
E struct symparse *FDECL(match_sym, (char *));
E int FDECL(sym_val, (char *));
#endif
/* ### pager.c ### */

View File

@@ -181,9 +181,15 @@ struct instance_flags {
boolean zerocomp; /* write zero-compressed save files */
boolean rlecomp; /* run-length comp of levels when writing savefile */
uchar num_pad_mode;
boolean DECgraphics; /* use DEC VT-xxx extended character set */
boolean echo; /* 1 to echo characters */
#if 0
boolean DECgraphics; /* use DEC VT-xxx extended character set */
boolean IBMgraphics; /* use IBM extended character set */
#ifdef MAC_GRAPHICS_ENV
boolean MACgraphics; /* use Macintosh extended character set, as
as defined in the special font HackFont */
#endif
#endif
uchar bouldersym; /* symbol for boulder display */
#ifdef TTY_GRAPHICS
char prevmsg_window; /* type of old message window to use */

View File

@@ -26,7 +26,7 @@
#define LICENSE "license" /* file with license information */
#define OPTIONFILE "opthelp" /* file explaining runtime options */
#define OPTIONS_USED "options" /* compile-time options, for #version */
#define SYMBOLS "symbols" /* replacement symbol sets */
#define LEV_EXT ".lev" /* extension for special level files */

View File

@@ -109,6 +109,12 @@ struct objclass {
unsigned short oc_nutrition; /* food value */
};
struct class_sym {
char sym;
char *name;
char *explain;
};
struct objdescr {
const char *oc_name; /* actual name */
const char *oc_descr; /* description when name unknown */
@@ -149,7 +155,7 @@ extern NEARDATA struct objdescr obj_descr[];
#define MON_EXPLODE (MAXOCLASSES+2) /* Exploding monster (e.g. gas spore) */
#if 0 /* moved to decl.h so that makedefs.c won't see them */
extern const char def_oc_syms[MAXOCLASSES]; /* default class symbols */
extern const struct class_sym def_oc_syms[MAXOCLASSES]; /* default class symbols */
extern uchar oc_syms[MAXOCLASSES]; /* current class symbols */
#endif

View File

@@ -223,17 +223,49 @@ struct symdef {
#endif
};
struct symparse {
unsigned range;
#define SYM_CONTROL 1 /* start/finish markers */
#define SYM_PCHAR 2 /* index into showsyms */
#define SYM_MON 3 /* index into monsyms */
#define SYM_OC 4 /* index into oc_syms */
#define SYM_OBJ 5 /* index into objects */
int idx;
const char *name;
};
/* general linked list of text pointers */
struct textlist {
char *text; /* the text */
int idx; /* an index value */
struct textlist *next; /* next in list */
};
#ifdef REINCARNATION
#define ROGUEHANDLING(H) ((Is_rogue_level(&u.uz) && roguehandling && \
!strcmpi(roguehandling,H)))
#define SYMHANDLING(H) (ROGUEHANDLING(H) || \
(!Is_rogue_level(&u.uz) && symhandling && \
!strcmpi(symhandling,H)))
#else
#define SYMHANDLING(H) (symhandling && !strcmpi(symhandling,H))
#endif
extern const struct symdef defsyms[MAXPCHARS]; /* defaults */
extern uchar showsyms[MAXPCHARS];
extern const struct symdef def_warnsyms[WARNCOUNT];
extern char *symset, *symhandling; /* from drawing.c */
extern char *roguesymset, *roguehandling; /* from drawing.c */
/*
* Graphics sets for display symbols
*/
#define ASCII_GRAPHICS 0 /* regular characters: '-', '+', &c */
#define DEFAULT_GRAPHICS 0 /* regular characters: '-', '+', &c */
#if 0
#define IBM_GRAPHICS 1 /* PC graphic characters */
#define DEC_GRAPHICS 2 /* VT100 line drawing characters */
#define MAC_GRAPHICS 3 /* Macintosh drawing characters */
#endif
/*
* The 5 possible states of doors