From: nethack.allison Date: Mon, 4 Feb 2002 12:50:46 +0000 (+0000) Subject: wincap field updates X-Git-Tag: MOVE2GIT~3268 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd44ec4f65b9ae3e8d42080f59fda6a71864d340;p=nethack wincap field updates As Warwick suggested, instead of having fixed tile sizes as options, allow specification of the size explicitly. Also, at Yitzhak's suggestion, provide a hook for overriding the port's tile file name. That name, and the contents of the file it points to, will be window-port specific of course. --- diff --git a/doc/window.doc b/doc/window.doc index 7fedb4035..989732f8c 100644 --- a/doc/window.doc +++ b/doc/window.doc @@ -440,9 +440,9 @@ to support: | preload_tiles | WC_PRELOAD_TILES | wc_preload_tiles |boolean | | scroll_margin | WC_SCROLL_MARGIN | wc_scroll_margin |int | | tiled_map | WC_TILED_MAP | wc_tiled_map |boolean | - | tiles_16x16 | WC_TILES_16x16 | wc_tiles_16x16 |boolean | - | tiles_32x32 | WC_TILES_32x32 | wc_tiles_32x32 |boolean | - | tiles_8x16 | WC_TILES_8x16 | wc_tiles_8x16 |boolean | + | tile_width | WC_TILE_WIDTH | wc_tile_width |int | + | tile_height | WC_TILE_HEIGHT | wc_tile_height |int | + | tile_file | WC_TILE_FILE | wc_tile_file |char * | | use_inverse | WC_INVERSE | wc_inverse |boolean | | vary_msgcount | WC_VARY_MSGCOUNT | wc_vary_msgcount |int | +-------------------+--------------------+-------------------+--------+ @@ -471,9 +471,12 @@ preload_tiles -- port should preload tiles into memory. scroll_margin -- port should scroll the display when the hero or cursor is this number of cells away from the edge of the window. tiled_map -- port should display a tiled map if it can. -tiles_16x16 -- port should display 16x16 tiles if it can. -tiles_32x32 -- port should display 32x32 tiles if it can. -tiles_8x16 -- port should display 8x16 tiles if it can. +tile_width -- port should display tiles with this width or round to closest + if it can. +tile_height -- port should display tiles with this height or round to closest + if it can. +tile_file -- open this alterntive tile file. The file name is likely to be + window-port or platform specific. use_inverse -- port should display inverse when NetHack asks for it. vary_msgcount -- port should display this number of messages at a time in the message window. diff --git a/include/flag.h b/include/flag.h index 526932d5a..c50c3cdd9 100644 --- a/include/flag.h +++ b/include/flag.h @@ -209,16 +209,16 @@ struct instance_flags { /* * Window capability support. */ - boolean wc_color; /* use color graphics */ - boolean wc_hilite_pet; /* hilight pets */ - boolean wc_ascii_map; /* show map using traditional ascii */ - boolean wc_tiled_map; /* show map using tiles */ - boolean wc_preload_tiles; /* preload tiles into memory */ - boolean wc_tiles_8x16; /* use 8x16 tiles */ - boolean wc_tiles_16x16; /* use 16x16 tiles */ - boolean wc_tiles_32x32; /* use 32x32 tiles */ + boolean wc_color; /* use color graphics */ + boolean wc_hilite_pet; /* hilight pets */ + boolean wc_ascii_map; /* show map using traditional ascii */ + boolean wc_tiled_map; /* show map using tiles */ + boolean wc_preload_tiles; /* preload tiles into memory */ + int wc_tile_width; /* tile width */ + int wc_tile_height; /* tile height */ + char *wc_tile_file; /* name of tile file;overrides default */ boolean wc_inverse; /* use inverse video for some things */ - int wc_align_status; /* status win at top|bot|right|left */ + int wc_align_status; /* status win at top|bot|right|left */ int wc_align_message; /* message win at top|bot|right|left */ int wc_vary_msgcount; /* show more old messages at a time */ char *wc_font_map; /* points to font name for the map win */ diff --git a/include/winprocs.h b/include/winprocs.h index c26f68a15..d3dccae59 100644 --- a/include/winprocs.h +++ b/include/winprocs.h @@ -139,9 +139,9 @@ extern NEARDATA struct window_procs windowprocs; #define WC_ASCII_MAP 0x04L /* 03 supports an ascii map */ #define WC_TILED_MAP 0x08L /* 04 supports a tiled map */ #define WC_PRELOAD_TILES 0x10L /* 05 supports pre-loading tiles */ -#define WC_TILES_8x16 0x20L /* 06 supports 8x16 tiles */ -#define WC_TILES_16x16 0x40L /* 07 supports 16x16 tiles */ -#define WC_TILES_32x32 0x80L /* 08 supports 32x32 tiles */ +#define WC_TILE_WIDTH 0x20L /* 06 prefer this width of tile */ +#define WC_TILE_HEIGHT 0x40L /* 07 prefer this height of tile */ +#define WC_TILE_FILE 0x80L /* 08 alternative tile file name */ #define WC_INVERSE 0x100L /* 09 Port supports inverse video */ #define WC_ALIGN_MESSAGE 0x200L /* 10 supports message alignmt top|b|l|r */ #define WC_ALIGN_STATUS 0x400L /* 11 supports status alignmt top|b|l|r */ @@ -168,6 +168,7 @@ extern NEARDATA struct window_procs windowprocs; #define ALIGN_TOP 3 #define ALIGN_BOTTOM 4 +/* map_mode settings - deprecated */ #define MAP_MODE_TILES 0 #define MAP_MODE_ASCII4x6 1 #define MAP_MODE_ASCII6x8 2 diff --git a/src/options.c b/src/options.c index 078fff6d6..d5817f473 100644 --- a/src/options.c +++ b/src/options.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)options.c 3.3 2002/02/02 */ +/* SCCS Id: @(#)options.c 3.3 2002/02/04 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -171,9 +171,6 @@ static struct Bool_Opt {"standout", &flags.standout, FALSE, SET_IN_GAME}, {"time", &flags.time, FALSE, SET_IN_GAME}, {"tiled_map", &iflags.wc_tiled_map, FALSE, DISP_IN_GAME}, /*WC*/ - {"tiles_8x16", &iflags.wc_tiles_8x16, FALSE, DISP_IN_GAME}, /*WC*/ - {"tiles_16x16", &iflags.wc_tiles_16x16, FALSE, DISP_IN_GAME}, /*WC*/ - {"tiles_32x32", &iflags.wc_tiles_32x32, FALSE, DISP_IN_GAME}, /*WC*/ #ifdef TIMED_DELAY {"timed_delay", &flags.nap, TRUE, SET_IN_GAME}, #else @@ -289,6 +286,9 @@ static struct Comp_Opt #endif { "suppress_alert", "suppress alerts about version-specific features", 8, SET_IN_GAME }, + { "tile_width", "width of tiles", 20, DISP_IN_GAME}, /*WC*/ + { "tile_height", "height of tiles", 20, DISP_IN_GAME}, /*WC*/ + { "tile_file", "name of tile file", 70, DISP_IN_GAME}, /*WC*/ { "traps", "the symbols to use in drawing traps", MAXTCHARS+1, SET_IN_FILE }, #ifdef MAC @@ -1879,6 +1879,36 @@ goodfruit: } else if (negated) bad_negation(fullname, TRUE); return; } + /* WINCAP + * tile_width:nn */ + fullname = "tile_width"; + if (match_optname(opts, fullname, sizeof("tile_width")-1, TRUE)) { + op = string_for_env_opt(fullname, opts, negated); + if ((negated && !op) || (!negated && op)) { + iflags.wc_tile_width = negated ? 0 : atoi(op); + } else if (negated) bad_negation(fullname, TRUE); + return; + } + /* WINCAP + * tile_file:name */ + fullname = "tile_file"; + if (match_optname(opts, fullname, sizeof("tile_file")-1, TRUE)) { + if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { + if (iflags.wc_tile_file) free(iflags.wc_tile_file); + iflags.wc_tile_file = (char *)alloc(strlen(op) + 1); + Strcpy(iflags.wc_tile_file, op); + } + } + /* WINCAP + * tile_height:nn */ + fullname = "tile_height"; + if (match_optname(opts, fullname, sizeof("tile_height")-1, TRUE)) { + op = string_for_env_opt(fullname, opts, negated); + if ((negated && !op) || (!negated && op)) { + iflags.wc_tile_height = negated ? 0 : atoi(op); + } else if (negated) bad_negation(fullname, TRUE); + return; + } /* WINCAP * vary_msgcount:nn */ fullname = "vary_msgcount"; @@ -2627,7 +2657,14 @@ char *buf; FEATURE_NOTICE_VER_MAJ, FEATURE_NOTICE_VER_MIN, FEATURE_NOTICE_VER_PATCH); - } else if (!strcmp(optname, "traps")) + } + else if (!strcmp(optname, "tile_file")) + Sprintf(buf, "%s", iflags.wc_tile_file ? iflags.wc_tile_file : none); + else if (!strcmp(optname, "tile_height")) + Sprintf(buf, "%d", iflags.wc_tile_width); + else if (!strcmp(optname, "tile_width")) + Sprintf(buf, "%d", iflags.wc_tile_width); + else if (!strcmp(optname, "traps")) Sprintf(buf, "%s", to_be_done); else if (!strcmp(optname, "vary_msgcount")) Sprintf(buf, "%d", iflags.wc_vary_msgcount); @@ -2979,9 +3016,9 @@ struct wc_Opt wc_options[] = { {"popup_dialog", WC_POPUP_DIALOG}, {"preload_tiles", WC_PRELOAD_TILES}, {"tiled_map", WC_TILED_MAP}, - {"tiles_16x16", WC_TILES_16x16}, - {"tiles_32x32", WC_TILES_32x32}, - {"tiles_8x16", WC_TILES_8x16}, + {"tile_file", WC_TILE_FILE}, + {"tile_width", WC_TILE_WIDTH}, + {"tile_height", WC_TILE_HEIGHT}, {"use_inverse", WC_INVERSE}, {"align_message", WC_ALIGN_MESSAGE}, {"align_status", WC_ALIGN_STATUS}, @@ -3037,6 +3074,7 @@ int wtype; char *fontname; { char **fn = (char **)0; + if (!fontname) return; switch(wtype) { case NHW_MAP: fn = &iflags.wc_font_map; @@ -3053,6 +3091,8 @@ char *fontname; case NHW_STATUS: fn = &iflags.wc_font_status; break; + default: + return; } if (fn) { if (*fn) free(*fn); diff --git a/src/save.c b/src/save.c index a2bd8de28..2162f0948 100644 --- a/src/save.c +++ b/src/save.c @@ -992,11 +992,12 @@ freedynamicdata() free_dungeons(); /* some pointers in iflags */ - if (iflags.wc_font_map) free(iflags.wc_font_map); - if (iflags.wc_font_message) free(iflags.wc_font_message); - if (iflags.wc_font_text) free(iflags.wc_font_text); - if (iflags.wc_font_menu) free(iflags.wc_font_menu); - if (iflags.wc_font_status) free(iflags.wc_font_status); + if (iflags.wc_font_map) free(iflags.wc_font_map); + if (iflags.wc_font_message) free(iflags.wc_font_message); + if (iflags.wc_font_text) free(iflags.wc_font_text); + if (iflags.wc_font_menu) free(iflags.wc_font_menu); + if (iflags.wc_font_status) free(iflags.wc_font_status); + if (iflags.wc_tile_file) free(iflags.wc_tile_file); #endif /* FREE_ALL_MEMORY */ return;