<Someone>'s gem changes.

This commit is contained in:
jwalz
2002-03-20 03:45:07 +00:00
parent 545132999d
commit 931e38a6d7
4 changed files with 965 additions and 263 deletions
+3 -4
View File
@@ -37,7 +37,7 @@ void get_colors(int handle, short *palette, int col){
if(i<16) if(i<16)
idx=vdi2dev4[i]; idx=vdi2dev4[i];
else else
idx=i; idx= i==255 ? 1 : i;
} }
vq_color(handle, i, 0, (int *)palette + idx * 3); vq_color(handle, i, 0, (int *)palette + idx * 3);
} }
@@ -49,7 +49,7 @@ void img_set_colors(int handle, short *palette, int col){
/* set color palette */ /* set color palette */
end=min(1<<col,1<<planes); end=min(1<<col,1<<planes);
for(i=0; i<end; i++){ for(i=0; i<end; i++){
switch(col){ switch(planes){ /* MAR -- war col 10.01.2001 */
case 1: case 1:
idx=i;break; idx=i;break;
case 2: case 2:
@@ -60,7 +60,7 @@ void img_set_colors(int handle, short *palette, int col){
if(i<16) if(i<16)
idx=vdi2dev4[i]; idx=vdi2dev4[i];
else else
idx=i; idx= i==255 ? 1 : i;
} }
vs_color(handle, i, (int *)palette + idx * 3); vs_color(handle, i, (int *)palette + idx * 3);
} }
@@ -239,7 +239,6 @@ int depack_img(char *name, IMG_header *pic){
/* ensure that lines aren't repeated past the end of the img */ /* ensure that lines aren't repeated past the end of the img */
if(line + scan_repeat > pic->img_h) if(line + scan_repeat > pic->img_h)
scan_repeat = pic->img_h - line; scan_repeat = pic->img_h - line;
/* copy line to image buffer */ /* copy line to image buffer */
if(scan_repeat>1){ if(scan_repeat>1){
/* calculate address of a current line in a current bitplane */ /* calculate address of a current line in a current bitplane */
+259 -15
View File
@@ -21,13 +21,28 @@ static int curr_status_line;
static char *FDECL(copy_of, (const char *)); static char *FDECL(copy_of, (const char *));
static void FDECL(bail, (const char *)); /* __attribute__((noreturn)) */ static void FDECL(bail, (const char *)); /* __attribute__((noreturn)) */
extern int mar_set_tile_mode(int);
extern void mar_set_font(int,const char*,int);
extern void mar_set_margin(int);
extern void mar_set_msg_visible(int);
extern void mar_set_status_align(int);
extern void mar_set_msg_align(int);
extern void mar_set_tilefile(char *);
extern void mar_set_tilex(int);
extern void mar_set_tiley(int);
extern short glyph2tile[MAX_GLYPH]; /* from tile.c */ extern short glyph2tile[MAX_GLYPH]; /* from tile.c */
extern void mar_display_nhwindow(winid); /* from wingem1.c */ extern void mar_display_nhwindow(winid); /* from wingem1.c */
void Gem_outrip(winid,int);
void Gem_preference_update(const char *);
/* Interface definition, for windows.c */ /* Interface definition, for windows.c */
struct window_procs Gem_procs = { struct window_procs Gem_procs = {
"Gem", "Gem",
WC_COLOR|WC_HILITE_PET|WC_INVERSE, WC_COLOR|WC_HILITE_PET|WC_ALIGN_MESSAGE|WC_ALIGN_STATUS|
WC_INVERSE|WC_SCROLL_MARGIN|
WC_FONT_MESSAGE|WC_FONT_STATUS|WC_FONT_MENU|WC_FONT_TEXT|WC_FONT_MAP|
WC_FONTSIZ_MESSAGE|WC_FONTSIZ_STATUS|WC_FONTSIZ_MENU|WC_FONTSIZ_TEXT|WC_FONTSIZ_MAP|
WC_TILE_WIDTH|WC_TILE_HEIGHT|WC_TILE_FILE|WC_VARY_MSGCOUNT|WC_ASCII_MAP,
Gem_init_nhwindows, Gem_init_nhwindows,
Gem_player_selection, Gem_player_selection,
Gem_askname, Gem_askname,
@@ -80,8 +95,8 @@ struct window_procs Gem_procs = {
/* other defs that really should go away (they're tty specific) */ /* other defs that really should go away (they're tty specific) */
Gem_start_screen, Gem_start_screen,
Gem_end_screen, Gem_end_screen,
genl_outrip, Gem_outrip,
genl_preference_update Gem_preference_update
}; };
#ifdef MAC #ifdef MAC
@@ -117,6 +132,11 @@ mar_get_msg_history()
return(iflags.msg_history); return(iflags.msg_history);
} }
int
mar_get_msg_visible()
{
return(iflags.wc_vary_msgcount);
}
/* clean up and quit */ /* clean up and quit */
static void static void
bail(mesg) bail(mesg)
@@ -128,6 +148,17 @@ const char *mesg;
/*NOTREACHED*/ /*NOTREACHED*/
} }
/*$$$*/
#define DEF_CLIPAROUND_MARGIN -1
#ifndef TILE_X
#define TILE_X 16
#endif
#define TILE_Y 16
#define TILES_PER_LINE 20
#define NHFONT_DEFAULT_SIZE 10
#define NHFONT_SIZE_MIN 3
#define NHFONT_SIZE_MAX 20
/*$$$*/
/*ARGSUSED*/ /*ARGSUSED*/
void void
Gem_init_nhwindows(argcp,argv) Gem_init_nhwindows(argcp,argv)
@@ -137,6 +168,42 @@ char** argv;
argv=argv, argcp=argcp; argv=argv, argcp=argcp;
colors_changed=TRUE; colors_changed=TRUE;
set_wc_option_mod_status(
WC_ALIGN_MESSAGE |
WC_ALIGN_STATUS |
WC_TILE_WIDTH |
WC_TILE_HEIGHT |
WC_TILE_FILE,
DISP_IN_GAME);
set_wc_option_mod_status(
WC_HILITE_PET |
WC_SCROLL_MARGIN |
WC_FONT_MESSAGE |
WC_FONT_MAP |
WC_FONT_STATUS |
WC_FONT_MENU |
WC_FONT_TEXT |
WC_FONTSIZ_MESSAGE |
WC_FONTSIZ_MAP |
WC_FONTSIZ_STATUS |
WC_FONTSIZ_MENU |
WC_FONTSIZ_TEXT |
WC_VARY_MSGCOUNT,
SET_IN_GAME
);
if( iflags.wc_align_message==0 ) iflags.wc_align_message = ALIGN_TOP;
if( iflags.wc_align_status==0 ) iflags.wc_align_status = ALIGN_BOTTOM;
if( iflags.wc_scroll_margin==0 ) iflags.wc_scroll_margin = DEF_CLIPAROUND_MARGIN;
if( iflags.wc_tile_width==0 ) iflags.wc_tile_width = TILE_X;
if( iflags.wc_tile_height==0 ) iflags.wc_tile_height = TILE_Y;
if(iflags.wc_tile_file && *iflags.wc_tile_file)
mar_set_tilefile(iflags.wc_tile_file);
if( iflags.wc_vary_msgcount==0 ) iflags.wc_vary_msgcount = 3;
mar_set_tile_mode(!iflags.wc_ascii_map); /* MAR -- 17.Mar 2002 True is tiles */
mar_set_tilex(iflags.wc_tile_width);
mar_set_tiley(iflags.wc_tile_height);
mar_set_msg_align(iflags.wc_align_message-ALIGN_BOTTOM);
mar_set_status_align(iflags.wc_align_status-ALIGN_BOTTOM);
if(mar_gem_init()==0){ if(mar_gem_init()==0){
bail((char *)0); bail((char *)0);
/*NOTREACHED*/ /*NOTREACHED*/
@@ -164,9 +231,14 @@ Gem_player_selection()
/* Should we randomly pick for the player? */ /* Should we randomly pick for the player? */
if (!flags.randomall && if (!flags.randomall &&
(flags.initrole == ROLE_NONE || flags.initrace == ROLE_NONE || (flags.initrole == ROLE_NONE || flags.initrace == ROLE_NONE ||
flags.initgend == ROLE_NONE || flags.initalign == ROLE_NONE)) { flags.initgend == ROLE_NONE || flags.initalign == ROLE_NONE)) {
pick4u = yn_function("Shall I pick a character for you? [ynq]",ynqchars,'n'); /* pick4u = yn_function("Shall I pick a character for you? [ynq]",ynqchars,'n');*/
pick4u = yn_function(
build_plselection_prompt(pbuf, QBUFSZ, flags.initrole,flags.initrace,
flags.initgend, flags.initalign)
,ynqchars,'n'
);
if(pick4u=='q'){ if(pick4u=='q'){
give_up: /* Just quit */ give_up: /* Just quit */
if (selected) free((genericptr_t) selected); if (selected) free((genericptr_t) selected);
@@ -260,7 +332,6 @@ give_up: /* Just quit */
} }
} }
} }
/* Permit the user to pick, if there is more than one */ /* Permit the user to pick, if there is more than one */
if (n > 1) { if (n > 1) {
win = create_nhwindow(NHW_MENU); win = create_nhwindow(NHW_MENU);
@@ -289,7 +360,6 @@ give_up: /* Just quit */
destroy_nhwindow(win); destroy_nhwindow(win);
if (n != 1 || selected[0].item.a_int == any.a_int) if (n != 1 || selected[0].item.a_int == any.a_int)
goto give_up; /* Selected quit */ goto give_up; /* Selected quit */
k = selected[0].item.a_int - 1; k = selected[0].item.a_int - 1;
free((genericptr_t) selected), selected = 0; free((genericptr_t) selected), selected = 0;
} }
@@ -330,7 +400,6 @@ give_up: /* Just quit */
} }
} }
} }
/* Permit the user to pick, if there is more than one */ /* Permit the user to pick, if there is more than one */
if (n > 1) { if (n > 1) {
win = create_nhwindow(NHW_MENU); win = create_nhwindow(NHW_MENU);
@@ -360,7 +429,6 @@ give_up: /* Just quit */
destroy_nhwindow(win); destroy_nhwindow(win);
if (n != 1 || selected[0].item.a_int == any.a_int) if (n != 1 || selected[0].item.a_int == any.a_int)
goto give_up; /* Selected quit */ goto give_up; /* Selected quit */
k = selected[0].item.a_int - 1; k = selected[0].item.a_int - 1;
free((genericptr_t) selected), selected = 0; free((genericptr_t) selected), selected = 0;
} }
@@ -400,7 +468,6 @@ give_up: /* Just quit */
} }
} }
} }
/* Permit the user to pick, if there is more than one */ /* Permit the user to pick, if there is more than one */
if (n > 1) { if (n > 1) {
win = create_nhwindow(NHW_MENU); win = create_nhwindow(NHW_MENU);
@@ -433,7 +500,6 @@ give_up: /* Just quit */
destroy_nhwindow(win); destroy_nhwindow(win);
if (n != 1 || selected[0].item.a_int == any.a_int) if (n != 1 || selected[0].item.a_int == any.a_int)
goto give_up; /* Selected quit */ goto give_up; /* Selected quit */
k = selected[0].item.a_int - 1; k = selected[0].item.a_int - 1;
free((genericptr_t) selected), selected = 0; free((genericptr_t) selected), selected = 0;
} }
@@ -649,6 +715,8 @@ Gem_putstr(window, attr, str)
Gem_putstr(WIN_MESSAGE,0,str); Gem_putstr(WIN_MESSAGE,0,str);
else else
mar_map_curs_weiter(); mar_map_curs_weiter();
mar_display_nhwindow(WIN_MESSAGE);
mar_display_nhwindow(WIN_STATUS);
break; break;
case NHW_MENU: case NHW_MENU:
@@ -833,7 +901,6 @@ extern int mar_set_rogue(int);
#endif #endif
extern void mar_add_pet_sign(winid,int,int); extern void mar_add_pet_sign(winid,int,int);
extern int mar_set_tile_mode(int);
void void
Gem_print_glyph(window, x, y, glyph) Gem_print_glyph(window, x, y, glyph)
@@ -851,10 +918,11 @@ Gem_print_glyph(window, x, y, glyph)
x--; /* MAR -- because x ranges from 1 to COLNO */ x--; /* MAR -- because x ranges from 1 to COLNO */
if(mar_set_tile_mode(-1)){ if(mar_set_tile_mode(-1)){
mar_print_glyph(window,x,y,glyph2tile[glyph]); mar_print_glyph(window,x,y,glyph2tile[glyph]);
if(glyph_is_pet(glyph) if(
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
&& iflags.hilite_pet iflags.hilite_pet &&
#endif #endif
glyph_is_pet(glyph)
) )
mar_add_pet_sign(window,x,y); mar_add_pet_sign(window,x,y);
}else }else
@@ -868,7 +936,7 @@ void mar_print_gl_char(window, x, y, glyph)
xchar x, y; xchar x, y;
int glyph; int glyph;
{ {
uchar ch; int ch;
int color; int color;
unsigned special; unsigned special;
@@ -978,6 +1046,182 @@ char *posbar;
{} {}
#endif #endif
/** Gem_outrip **/
void mar_set_text_to_rip(winid);
char** rip_line=0;
extern const char *killed_by_prefix[];
void
Gem_outrip(w, how)
winid w;
int how;
{
/* Code from X11 windowport */
#define STONE_LINE_LEN 15 /* # chars that fit on one line */
#define NAME_LINE 0 /* line # for player name */
#define GOLD_LINE 1 /* line # for amount of gold */
#define DEATH_LINE 2 /* line # for death description */
#define YEAR_LINE 6 /* line # for year */
char buf[BUFSZ];
char *dpx;
int line;
if (!rip_line) {
int i;
rip_line= (char **)malloc((YEAR_LINE+1)*sizeof(char *));
for (i=0; i<YEAR_LINE+1; i++) {
rip_line[i]=(char *)malloc((STONE_LINE_LEN+1)*sizeof(char));
}
}
/* Follows same algorithm as genl_outrip() */
/* Put name on stone */
Sprintf(rip_line[NAME_LINE], "%s", plname);
/* Put $ on stone */
Sprintf(rip_line[GOLD_LINE], "%ld Au",
#ifndef GOLDOBJ
u.ugold);
#else
done_money);
#endif
/* Put together death description */
switch (killer_format) {
default: impossible("bad killer format?");
case KILLED_BY_AN:
Strcpy(buf, killed_by_prefix[how]);
Strcat(buf, an(killer));
break;
case KILLED_BY:
Strcpy(buf, killed_by_prefix[how]);
Strcat(buf, killer);
break;
case NO_KILLER_PREFIX:
Strcpy(buf, killer);
break;
}
/* Put death type on stone */
for (line=DEATH_LINE, dpx = buf; line<YEAR_LINE; line++) {
register int i,i0;
char tmpchar;
if ( (i0=strlen(dpx)) > STONE_LINE_LEN) {
for(i = STONE_LINE_LEN;
((i0 > STONE_LINE_LEN) && i); i--)
if(dpx[i] == ' ') i0 = i;
if(!i) i0 = STONE_LINE_LEN;
}
tmpchar = dpx[i0];
dpx[i0] = 0;
strcpy(rip_line[line], dpx);
if (tmpchar != ' ') {
dpx[i0] = tmpchar;
dpx= &dpx[i0];
} else dpx= &dpx[i0+1];
}
/* Put year on stone */
Sprintf(rip_line[YEAR_LINE], "%4d", getyear());
mar_set_text_to_rip(w);
for(line=0;line<13;line++)
putstr(w, 0, "");
}
void
mar_get_font(type,p_fname,psize)
int type;
char **p_fname;
int *psize;
{
switch(type){
case NHW_MESSAGE:
*p_fname=iflags.wc_font_message;
*psize=iflags.wc_fontsiz_message;
break;
case NHW_MAP:
*p_fname=iflags.wc_font_map;
*psize=iflags.wc_fontsiz_map;
break;
case NHW_STATUS:
*p_fname=iflags.wc_font_status;
*psize=iflags.wc_fontsiz_status;
break;
case NHW_MENU:
*p_fname=iflags.wc_font_menu;
*psize=iflags.wc_fontsiz_menu;
break;
case NHW_TEXT:
*p_fname=iflags.wc_font_text;
*psize=iflags.wc_fontsiz_text;
break;
default:
break;
}
}
void
Gem_preference_update(pref)
const char *pref;
{
if( stricmp( pref, "font_message")==0 ||
stricmp( pref, "font_size_message")==0 ) {
if( iflags.wc_fontsiz_message<NHFONT_SIZE_MIN ||
iflags.wc_fontsiz_message>NHFONT_SIZE_MAX )
iflags.wc_fontsiz_message = NHFONT_DEFAULT_SIZE;
mar_set_font(NHW_MESSAGE,iflags.wc_font_message,iflags.wc_fontsiz_message);
return;
}
if( stricmp( pref, "font_map")==0 ||
stricmp( pref, "font_size_map")==0 ) {
if( iflags.wc_fontsiz_map<NHFONT_SIZE_MIN ||
iflags.wc_fontsiz_map>NHFONT_SIZE_MAX )
iflags.wc_fontsiz_map = NHFONT_DEFAULT_SIZE;
mar_set_font(NHW_MAP,iflags.wc_font_map,iflags.wc_fontsiz_map);
return;
}
if( stricmp( pref, "font_status")==0 ||
stricmp( pref, "font_size_status")==0 ) {
if( iflags.wc_fontsiz_status<NHFONT_SIZE_MIN ||
iflags.wc_fontsiz_status>NHFONT_SIZE_MAX )
iflags.wc_fontsiz_status = NHFONT_DEFAULT_SIZE;
mar_set_font(NHW_STATUS,iflags.wc_font_status,iflags.wc_fontsiz_status);
return;
}
if( stricmp( pref, "font_menu")==0 ||
stricmp( pref, "font_size_menu")==0 ) {
if( iflags.wc_fontsiz_menu<NHFONT_SIZE_MIN ||
iflags.wc_fontsiz_menu>NHFONT_SIZE_MAX )
iflags.wc_fontsiz_menu = NHFONT_DEFAULT_SIZE;
mar_set_font(NHW_MENU,iflags.wc_font_menu,iflags.wc_fontsiz_menu);
return;
}
if( stricmp( pref, "font_text")==0 ||
stricmp( pref, "font_size_text")==0 ) {
if( iflags.wc_fontsiz_text<NHFONT_SIZE_MIN ||
iflags.wc_fontsiz_text>NHFONT_SIZE_MAX )
iflags.wc_fontsiz_text = NHFONT_DEFAULT_SIZE;
mar_set_font(NHW_TEXT,iflags.wc_font_text,iflags.wc_fontsiz_text);
return;
}
if( stricmp( pref, "scroll_margin")==0 ) {
mar_set_margin(iflags.wc_scroll_margin);
Gem_cliparound(u.ux, u.uy);
return;
}
if( stricmp( pref, "ascii_map")==0 ) {
mar_set_tile_mode(!iflags.wc_ascii_map);
doredraw();
return;
}
if( stricmp( pref, "hilite_pet")==0 ){
/* MAR -- works without doing something here. */
return;
}
if( stricmp( pref, "align_message")==0){
mar_set_msg_align(iflags.wc_align_message-ALIGN_BOTTOM);
return;
}
if(stricmp( pref, "align_status")==0 ){
mar_set_status_align(iflags.wc_align_status-ALIGN_BOTTOM);
return;
}
if( stricmp( pref, "vary_msgcount")==0 ){
mar_set_msg_visible(iflags.wc_vary_msgcount);
return;
}
}
/* /*
* Allocate a copy of the given string. If null, return a string of * Allocate a copy of the given string. If null, return a string of
* zero length. * zero length.
+698 -244
View File
File diff suppressed because it is too large Load Diff
+5
View File
@@ -1156,6 +1156,11 @@ int color;
if (windowprocs.name != NULL && if (windowprocs.name != NULL &&
!strcmpi(windowprocs.name, "X11")) return TRUE; !strcmpi(windowprocs.name, "X11")) return TRUE;
#endif #endif
#ifdef GEM_GRAPHICS
/* XXX has_color() should be added to windowprocs */
if (windowprocs.name != NULL &&
!strcmpi(windowprocs.name, "Gem")) return TRUE;
#endif
#ifdef AMII_GRAPHICS #ifdef AMII_GRAPHICS
/* hilites[] not used */ /* hilites[] not used */
return iflags.use_color; return iflags.use_color;