- Implement proper up/down paging in showlfstats()

- getspellschoolknown() returning unpredictable results
- in Skill screen, show abbreviations on each line for ease of reading.
This commit is contained in:
Rob Pearce 2016-06-02 11:24:32 +10:00
parent 997d5f88a8
commit 321a5ae00c
5 changed files with 367 additions and 203 deletions

540
io.c
View File

@ -5840,6 +5840,14 @@ void dolook(cell_t *where, int onpurpose) {
} }
} }
void lfstatheading(char *headstr, int offset) {
char buf[BUFLEN];
snprintf(buf, BUFLEN, "%s%s", headstr, offset ? " (continued)" : "");
wattron(mainwin, A_UNDERLINE);
centre(mainwin, C_WHITE, 0, "SKILLS");
wattroff(mainwin, A_UNDERLINE);
}
char *makedesc_god(lifeform_t *god, char *retbuf) { char *makedesc_god(lifeform_t *god, char *retbuf) {
char thisline[BUFLEN]; char thisline[BUFLEN];
char godname[BUFLEN]; char godname[BUFLEN];
@ -6109,12 +6117,13 @@ char *makedesc_job(job_t *j, char *retbuf) {
strcpy(thisline, ""); strcpy(thisline, "");
for (sk = firstskill ; sk ; sk = sk->next) { for (sk = firstskill ; sk ; sk = sk->next) {
char lev[BUFLEN]; char *lev = NULL;
enum SKILLLEVEL slev = PR_INEPT; enum SKILLLEVEL slev = PR_INEPT;
strcpy(lev, "");
f = hasflagval(j->flags, F_STARTSKILL, sk->id, NA, NA, NULL); f = hasflagval(j->flags, F_STARTSKILL, sk->id, NA, NA, NULL);
if (f) { if (f) {
slev = f->val[1]; slev = f->val[1];
lev = getskilllevelabbr(slev);
/*
switch (slev) { switch (slev) {
case PR_INEPT: strcpy(lev, "---"); break; case PR_INEPT: strcpy(lev, "---"); break;
case PR_NOVICE: strcpy(lev, "Nov"); break; case PR_NOVICE: strcpy(lev, "Nov"); break;
@ -6124,8 +6133,9 @@ char *makedesc_job(job_t *j, char *retbuf) {
case PR_EXPERT: strcpy(lev, "Exp"); break; case PR_EXPERT: strcpy(lev, "Exp"); break;
case PR_MASTER: strcpy(lev, "Mst"); break; case PR_MASTER: strcpy(lev, "Mst"); break;
} }
*/
} }
if (strlen(lev)) { if (lev) {
char *p; char *p;
char buf[BUFLEN]; char buf[BUFLEN];
//char bufpad[BUFLEN]; //char bufpad[BUFLEN];
@ -8785,6 +8795,7 @@ void dooptions(void) {
char part1[BUFLEN]; char part1[BUFLEN];
char promptstr[BUFLEN],cmdchars[BUFLENSMALL]; char promptstr[BUFLEN],cmdchars[BUFLENSMALL];
char ch; char ch;
int headinglines = 2;
int y,h,done = B_FALSE; int y,h,done = B_FALSE;
option_t *opt; option_t *opt;
@ -8804,7 +8815,7 @@ void dooptions(void) {
while (!done) { while (!done) {
cls(); cls();
centre(mainwin,C_WHITE, 0, "OPTIONS"); centre(mainwin,C_WHITE, 0, "OPTIONS");
y = 2; y = headinglines;
ch = '\0'; ch = '\0';
for (opt = firstoption ; opt ; opt = opt->next) { for (opt = firstoption ; opt ; opt = opt->next) {
sprintf(part1, "%c - %s", opt->letter, opt->text); sprintf(part1, "%c - %s", opt->letter, opt->text);
@ -8812,9 +8823,10 @@ void dooptions(void) {
if (opt->enabled == opt->def) strcat(buf, " (default)"); if (opt->enabled == opt->def) strcat(buf, " (default)");
wmove(mainwin, y, 0); wmove(mainwin, y, 0);
textwithcol(mainwin, buf); textwithcol(mainwin, buf);
if (opt->next && downline(&y, h, "INVENTORY", NULL, promptstr, cmdchars, &ch)) { if (opt->next && downline(&y, h, headinglines, NULL)) {
//finished = B_TRUE;
break; break;
} }
} }
if (!ch) { if (!ch) {
centre(mainwin, C_WHITE, h-1, promptstr); centre(mainwin, C_WHITE, h-1, promptstr);
@ -9578,18 +9590,21 @@ int dothrow(obpile_t *op, object_t *o) {
return B_TRUE; return B_TRUE;
} }
// returns TRUE if escape pressed // returns TRUE if we hit the bottom of the screen.
int downline(int *y, int h, char *heading, char *subheading, char *bottomstring, char *cmdchars, char *retchar) { int downline(int *y, int h, int headinglines, int *nextoffset) {
char headbuf[BUFLEN];
int ch;
int w; int w;
w = getmaxx(mainwin); w = getmaxx(mainwin);
/*
// this is the heading we'll print after going past the 'MORE' strong
snprintf(headbuf, w-1, "%s (continued)", heading); snprintf(headbuf, w-1, "%s (continued)", heading);
(*y)++; (*y)++;
// are we aff the bottom of the screen?
if (*y >= (h-3)) { if (*y >= (h-3)) {
// prompt to press a key
centre(mainwin,C_WHITE, h-2, MORESTRING); centre(mainwin,C_WHITE, h-2, MORESTRING);
if (bottomstring) { if (bottomstring) { // show extra prompt if required.
centre(mainwin, C_WHITE, h-1, bottomstring); centre(mainwin, C_WHITE, h-1, bottomstring);
} }
ch = getch(); ch = getch();
@ -9601,6 +9616,7 @@ int downline(int *y, int h, char *heading, char *subheading, char *bottomstring,
return B_TRUE; return B_TRUE;
} }
// clear screen and print the heading
cls(); *y = 0; cls(); *y = 0;
centre(mainwin, C_WHITE, *y, headbuf); centre(mainwin, C_WHITE, *y, headbuf);
@ -9611,6 +9627,17 @@ int downline(int *y, int h, char *heading, char *subheading, char *bottomstring,
} }
} }
return B_FALSE; return B_FALSE;
*/
(*y)++;
// are we aff the bottom of the screen?
if (*y >= (h-3)) {
if (nextoffset) *nextoffset = *y - headinglines - 2;
return B_TRUE;
} else {
if (nextoffset) *nextoffset = 0;
}
return B_FALSE;
} }
@ -12269,6 +12296,7 @@ void showlfarmour(lifeform_t *lf) {
void showlfstats(lifeform_t *lf, int showall) { void showlfstats(lifeform_t *lf, int showall) {
int y = 0, y2 = 0, x2 = 40; int y = 0, y2 = 0, x2 = 40;
int startx,starty; int startx,starty;
int headinglines = 2;
int x; int x;
int arating, evasion; int arating, evasion;
int acc; int acc;
@ -12295,14 +12323,14 @@ void showlfstats(lifeform_t *lf, int showall) {
obpile_t *op = NULL; obpile_t *op = NULL;
char ch; char ch;
char mode = '@'; char mode = '@';
char promptstr[BUFLEN]; char promptstr[BUFLEN],navstr[BUFLEN];
char cmdchars[BUFLEN]; char cmdchars[BUFLEN];
int done = B_FALSE; int done = B_FALSE;
enum SKILLLEVEL lorelev; enum SKILLLEVEL lorelev;
enum COLOUR lorecol; enum COLOUR lorecol;
int min,max; int min,max;
flag_t *retflag[MAXCANDIDATES]; flag_t *retflag[MAXCANDIDATES];
int nretflags; int nretflags,offset = 0, nextoffset = 0;
h = getmaxy(mainwin); h = getmaxy(mainwin);
@ -12325,29 +12353,6 @@ void showlfstats(lifeform_t *lf, int showall) {
showall = B_TRUE; showall = B_TRUE;
} }
if (isplayer(lf) || showall) {
snprintf(promptstr, BUFLEN, "^h[^W@^n=stats ^WS^nkills ^WA^nbils ^WM^nagic ^WE^nffects %s%s^W?^n=describe ^WESC^n=quit^h]",
isplayer(lf) ? "^WG^nods " : "",
isplayer(lf) ? "" : "^WI^ntems " );
snprintf(cmdchars, BUFLEN, "@asme%s%s",isplayer(lf) ? "g" : "", isplayer(lf) ? "" : "i");
} else {
snprintf(cmdchars, BUFLEN, "@e?");
// can always see stats & effects
snprintf(promptstr, BUFLEN, "^h[^W@^n=stats ^WE^nffects ");
if (!isplayer(lf)) {
snprintf(buf, BUFLEN, "^WI^ntems ");
strcat(promptstr, buf);
strcat(cmdchars, "i");
}
if ((lorelev >= PR_ADEPT) || (getskill(player, SK_LORE_ARCANA) >= PR_ADEPT)) {
snprintf(buf, BUFLEN, "^WM^nagic ");
strcat(promptstr, buf);
strcat(cmdchars, "m");
}
snprintf(buf, BUFLEN, "^W?^n=describe ^WESC^n=quit]");
strcat(promptstr, buf);
}
while (!done) { while (!done) {
cls(); cls();
y = 0; y = 0;
@ -12366,10 +12371,10 @@ void showlfstats(lifeform_t *lf, int showall) {
} }
wattroff(mainwin, A_UNDERLINE); wattroff(mainwin, A_UNDERLINE);
x = 0; x = 0;
centre(mainwin, C_MAGENTA, 1, "[Press ? for a full description]");
y = 2; //centre(mainwin, C_MAGENTA, 1, "[Press ? for a full description]");
y2 = 2; y = headinglines;
y2 = headinglines;
dammod = getstrdammod(lf); dammod = getstrdammod(lf);
//accmod = getstatmod(lf, A_AGI); //accmod = getstatmod(lf, A_AGI);
@ -13295,58 +13300,63 @@ void showlfstats(lifeform_t *lf, int showall) {
wrapprint(mainwin, &y, &x, 0, "Nothing obvious."); wrapprint(mainwin, &y, &x, 0, "Nothing obvious.");
} }
} else if (mode == 'a') { } else if (mode == 'a') {
int count = 0;
wattron(mainwin, A_UNDERLINE); wattron(mainwin, A_UNDERLINE);
centre(mainwin, C_WHITE, 0, "ABILITIES"); centre(mainwin, C_WHITE, 0, "ABILITIES");
wattroff(mainwin, A_UNDERLINE); wattroff(mainwin, A_UNDERLINE);
y = 2; y = headinglines;
for (ot = objecttype ; ot ; ot = ot->next) { for (ot = objecttype ; ot ; ot = ot->next) {
f = lfhasknownflagval(lf, F_CANWILL, ot->id, NA, NA, NULL); f = lfhasknownflagval(lf, F_CANWILL, ot->id, NA, NA, NULL);
if (f && (f->known)) { if (f && (f->known)) {
char expirebuf[BUFLEN]; if (count >= offset) {
char eb2[BUFLEN],racestr[BUFLEN]; char expirebuf[BUFLEN];
int needgrab = B_FALSE; char eb2[BUFLEN],racestr[BUFLEN];
int range; int needgrab = B_FALSE;
int range;
if (f->val[2] == NA) {
snprintf(expirebuf, BUFLEN, "at will"); if (f->val[2] == NA) {
} else { snprintf(expirebuf, BUFLEN, "at will");
snprintf(expirebuf, BUFLEN, "every %d turn%s",f->val[2], } else {
(f->val[2] == 1) ? "" : "s"); snprintf(expirebuf, BUFLEN, "every %d turn%s",f->val[2],
} (f->val[2] == 1) ? "" : "s");
}
// extra options? // extra options?
texttospellopts(f->text, "needgrab:", &needgrab, "range:", &range, "race:", racestr, NULL); texttospellopts(f->text, "needgrab:", &needgrab, "range:", &range, "race:", racestr, NULL);
if (needgrab) { if (needgrab) {
strcat(expirebuf, ",after grab"); strcat(expirebuf, ",after grab");
} }
if (range) { if (range) {
char rbuf[BUFLEN]; char rbuf[BUFLEN];
snprintf(rbuf, BUFLEN, ",range:%d",range); snprintf(rbuf, BUFLEN, ",range:%d",range);
strcat(expirebuf, rbuf); strcat(expirebuf, rbuf);
} }
if (strlen(racestr)) { if (strlen(racestr)) {
char rbuf[BUFLEN]; char rbuf[BUFLEN];
snprintf(rbuf, BUFLEN, ",race:%s",racestr); snprintf(rbuf, BUFLEN, ",race:%s",racestr);
strcat(expirebuf, rbuf); strcat(expirebuf, rbuf);
} }
if (strlen(expirebuf)) { if (strlen(expirebuf)) {
snprintf(eb2, BUFLEN,"(%s)",expirebuf); snprintf(eb2, BUFLEN,"(%s)",expirebuf);
} else { } else {
strcpy(eb2, ""); strcpy(eb2, "");
} }
setcol(mainwin, C_GREEN); setcol(mainwin, C_GREEN);
snprintf(buf, BUFLEN, "%-12s", ot->name); snprintf(buf, BUFLEN, "%-12s", ot->name);
mvwprintw(mainwin, y, 0, buf); mvwprintw(mainwin, y, 0, buf);
unsetcol(mainwin, C_GREEN); unsetcol(mainwin, C_GREEN);
snprintf(buf, BUFLEN, "%s%s", ot->desc, eb2); snprintf(buf, BUFLEN, "%s%s", ot->desc, eb2);
wprintw(mainwin, buf); wprintw(mainwin, buf);
if (downline(&y, h, "ABILITIES", NULL, promptstr, cmdchars, &ch)) { if (downline(&y, h, headinglines, &nextoffset)) {
break; nextoffset += offset;
break;
}
} }
count++;
} }
} }
y++; y++;
@ -13356,13 +13366,13 @@ void showlfstats(lifeform_t *lf, int showall) {
enum SKILLLEVEL slev; enum SKILLLEVEL slev;
skill_t *sk; skill_t *sk;
int finished = B_FALSE,dounknown; int finished = B_FALSE,dounknown;
int count = 0;
wattron(mainwin, A_UNDERLINE); lfstatheading("SKILLS", offset);
centre(mainwin, C_WHITE, 0, "SKILLS"); //ooooooo start of skills
wattroff(mainwin, A_UNDERLINE); y = headinglines;
y = 2;
// construct headings
snprintf(skilltitle, BUFLEN, "%-21s"," "); snprintf(skilltitle, BUFLEN, "%-21s"," ");
for (i = PR_NOVICE; i <= PR_MASTER; i++) { for (i = PR_NOVICE; i <= PR_MASTER; i++) {
char toadd[BUFLEN], *sn; char toadd[BUFLEN], *sn;
@ -13383,7 +13393,8 @@ void showlfstats(lifeform_t *lf, int showall) {
} }
doheading(mainwin, &y, 0, skilltitle); doheading(mainwin, &y, 0, skilltitle);
// for each skill... // go through and list each skill, known ones first.
count = 0;
for (dounknown = 0; dounknown <= 1; dounknown++) { for (dounknown = 0; dounknown <= 1; dounknown++) {
for (sk = firstskill ; sk ; sk = sk->next) { for (sk = firstskill ; sk ; sk = sk->next) {
char thisline[BUFLEN]; char thisline[BUFLEN];
@ -13391,76 +13402,109 @@ void showlfstats(lifeform_t *lf, int showall) {
slev = getskill(lf, sk->id); slev = getskill(lf, sk->id);
if (!dounknown && (slev != PR_INEPT)) { if (!dounknown && (slev != PR_INEPT)) {
char endbit[BUFLEN]; if (count >= offset) {
char basecolour = 'n'; char endbit[BUFLEN];
int max; char basecolour = 'n';
if (ismaxedskill(lf, sk->id)) { int max;
basecolour = 'h'; if (ismaxedskill(lf, sk->id)) {
} basecolour = 'h';
// known skill }
sprintf(thisline, "^%c%-21s^%c[^%d", basecolour, sk->name, basecolour, // known skill
getskilllevelcolour(slev)); sprintf(thisline, "^%c%-21s^%c[^%d", basecolour, sk->name, basecolour,
max = getmaxskilllevel(player, sk->id); getskilllevelcolour(slev));
for (i = PR_NOVICE; i <= PR_MASTER; i++) { max = getmaxskilllevel(player, sk->id);
char toadd[BUFLEN]; for (i = PR_NOVICE; i <= PR_MASTER; i++) {
char toadd[BUFLEN];
/*if (i == (max+1)) {
sprintf(toadd, "^n]########"); /*if (i == (max+1)) {
} else if (i > max) { sprintf(toadd, "^n]########");
sprintf(toadd, "^n#########"); } else if (i > max) {
} else*/ sprintf(toadd, "^n#########");
if (i <= max) { } else*/
if (i == slev) { if (i <= max) {
if (ismaxedskill(lf, sk->id)) { if (i == slev) {
sprintf(toadd, "*********"); char blank[2],endchar[2];
int n,blanklen;
char *sn;
sn = getskilllevelabbr(slev);
if (ismaxedskill(lf, sk->id)) {
strcpy(blank, "*");
strcpy(endchar, "*");
blanklen = 7 - strlen(sn);
} else {
strcpy(blank, "=");
strcpy(endchar, "|");
blanklen = 7 - strlen(sn);
}
strcpy(toadd,"");
for (n = 0; n < blanklen; n++) {
strncat(toadd, blank, BUFLEN);
}
strncat(toadd, sn, BUFLEN);
strncat(toadd, blank, BUFLEN);
strncat(toadd, endchar, BUFLEN);
/*
if (ismaxedskill(lf, sk->id)) {
sprintf(toadd, "*********");
} else {
sprintf(toadd, "========|");
}
*/
} else if (i < slev) {
if (ismaxedskill(lf, sk->id)) {
sprintf(toadd, "*********");
} else {
sprintf(toadd, "=========");
}
} else { } else {
sprintf(toadd, "========|"); sprintf(toadd, "^n.........");
} }
} else if (i < slev) { strcat(thisline, toadd);
if (ismaxedskill(lf, sk->id)) {
sprintf(toadd, "*********");
} else {
sprintf(toadd, "=========");
}
} else {
sprintf(toadd, "^n.........");
} }
strcat(thisline, toadd);
} }
sprintf(endbit, "^%c]^n",basecolour);
strcat(thisline, endbit);
wmove(mainwin, y, 0);
textwithcol(mainwin, thisline);
printed = B_TRUE;
} }
sprintf(endbit, "^%c]^n",basecolour);
strcat(thisline, endbit); count++;
wmove(mainwin, y, 0);
textwithcol(mainwin, thisline);
printed = B_TRUE;
} else if (dounknown && !slev && lfhasflagval(lf, F_CANLEARN, sk->id, NA, NA, NULL)) { } else if (dounknown && !slev && lfhasflagval(lf, F_CANLEARN, sk->id, NA, NA, NULL)) {
char toadd[BUFLEN]; if (count >= offset) {
int max; char toadd[BUFLEN];
// learnable skill int max;
sprintf(toadd, "^B%-21s[", sk->name ); // learnable skill
wmove(mainwin, y, 0); sprintf(toadd, "^B%-21s[", sk->name );
textwithcol(mainwin, toadd); wmove(mainwin, y, 0);
max = getmaxskilllevel(player, sk->id); textwithcol(mainwin, toadd);
for (i = PR_NOVICE; i <= PR_MASTER; i++) { max = getmaxskilllevel(player, sk->id);
/* for (i = PR_NOVICE; i <= PR_MASTER; i++) {
if (i == max+1) { /*
textwithcol(mainwin, "^B]########"); if (i == max+1) {
} else if (i > max) { textwithcol(mainwin, "^B]########");
textwithcol(mainwin, "^B#########"); } else if (i > max) {
} else { textwithcol(mainwin, "^B#########");
wprintw(mainwin, " "); } else {
} wprintw(mainwin, " ");
*/ }
if (i <= max) { */
textwithcol(mainwin, "^B........."); if (i <= max) {
textwithcol(mainwin, "^B.........");
}
} }
textwithcol(mainwin, "^B]^n");
printed = B_TRUE;
} }
textwithcol(mainwin, "^B]^n");
printed = B_TRUE; count++;
} }
if (printed) { if (printed) {
if (downline(&y, h, "SKILLS", skilltitle, promptstr, cmdchars, &ch)) { if (downline(&y, h, headinglines, &nextoffset)) {
nextoffset += offset;
finished = B_TRUE; finished = B_TRUE;
break; break;
} }
@ -13468,11 +13512,13 @@ void showlfstats(lifeform_t *lf, int showall) {
} }
if (finished) break; if (finished) break;
} }
//oooooooooooo end of skills oooooooooo
} else if (mode == 'm') { } else if (mode == 'm') {
char subheading[BUFLEN]; char subheading[BUFLEN];
int lev; int lev;
int anyfound; int anyfound;
int exitnow = B_FALSE; int exitnow = B_FALSE;
int count = 0;
snprintf(subheading, BUFLEN, " %-4s%-26s%-15s%-13s%s","Lv","Spell", "School", "Power", "Cost"); snprintf(subheading, BUFLEN, " %-4s%-26s%-15s%-13s%s","Lv","Spell", "School", "Power", "Cost");
@ -13489,68 +13535,72 @@ void showlfstats(lifeform_t *lf, int showall) {
if (thislev == lev) { if (thislev == lev) {
f = lfhasknownflagval(lf, F_CANCAST, ot->id, NA, NA, NULL); f = lfhasknownflagval(lf, F_CANCAST, ot->id, NA, NA, NULL);
if (f && (f->known)) { if (f && (f->known)) {
char spellname[BUFLEN]; if (count >= offset) {
char mpbuf[BUFLEN]; char spellname[BUFLEN];
char powerbuf[BUFLEN]; char mpbuf[BUFLEN];
int power; char powerbuf[BUFLEN];
int mpcost; int power;
int castable = B_TRUE; int mpcost;
int atwill = B_FALSE; int castable = B_TRUE;
int atwill = B_FALSE;
// power // power
power = getspellpower(lf, ot->id); power = getspellpower(lf, ot->id);
snprintf(powerbuf, BUFLEN, "["); snprintf(powerbuf, BUFLEN, "[");
for (i = 0; i < power; i++) { for (i = 0; i < power; i++) {
strcat(powerbuf, "#"); strcat(powerbuf, "#");
} }
for (i = 0; i < (getspellmaxpower(ot->id) - power); i++) { for (i = 0; i < (getspellmaxpower(ot->id) - power); i++) {
strcat(powerbuf, "-"); strcat(powerbuf, "-");
} }
strcat(powerbuf, "]"); strcat(powerbuf, "]");
// mp cost // mp cost
if (f->id == F_CANWILL) { if (f->id == F_CANWILL) {
mpcost = 0; mpcost = 0;
if (f->val[2] == NA) { if (f->val[2] == NA) {
snprintf(mpbuf, BUFLEN, "At will"); snprintf(mpbuf, BUFLEN, "At will");
} else {
snprintf(mpbuf, BUFLEN, "At will, every %d turn%s",f->val[2],
(f->val[2] == 1) ? "" : "s");
}
atwill = B_TRUE;
} else { } else {
snprintf(mpbuf, BUFLEN, "At will, every %d turn%s",f->val[2], mpcost = getmpcost(lf, ot->id);
(f->val[2] == 1) ? "" : "s"); if (mpcost) {
getspellcosttext(lf, ot->id, power, mpbuf);
} else {
snprintf(mpbuf, BUFLEN, "At will");
}
} }
atwill = B_TRUE;
} else {
mpcost = getmpcost(lf, ot->id);
if (mpcost) {
getspellcosttext(lf, ot->id, power, mpbuf);
} else {
snprintf(mpbuf, BUFLEN, "At will");
}
}
if (!atwill) { if (!atwill) {
if ((mpcost > getmaxmp(lf)) || (power <= 0)) { if ((mpcost > getmaxmp(lf)) || (power <= 0)) {
castable = B_FALSE; castable = B_FALSE;
}
} }
}
getspellname(ot->id, lf, spellname, B_FALSE);
getspellname(ot->id, lf, spellname, B_FALSE); if (castable || !isplayer(lf)) setcol(mainwin, C_GREEN);
if (castable || !isplayer(lf)) setcol(mainwin, C_GREEN); else setcol(mainwin, C_RED);
else setcol(mainwin, C_RED); snprintf(buf, BUFLEN, " %-4d%-26s%-15s%-13s%s",thislev, spellname, getschoolnameshort(getspellschoolknown(lf, ot->id)), powerbuf, mpbuf);
snprintf(buf, BUFLEN, " %-4d%-26s%-15s%-13s%s",thislev, spellname, getschoolnameshort(getspellschoolknown(lf, ot->id)), powerbuf, mpbuf); mvwprintw(mainwin, y, 0, "%s\n", buf);
mvwprintw(mainwin, y, 0, "%s\n", buf); if (castable || !isplayer(lf)) unsetcol(mainwin, C_GREEN);
if (castable || !isplayer(lf)) unsetcol(mainwin, C_GREEN); else unsetcol(mainwin, C_RED);
else unsetcol(mainwin, C_RED); anyfound = B_TRUE;
anyfound = B_TRUE; if (downline(&y, h, headinglines, &nextoffset)) {
if (downline(&y, h, "MAGIC", subheading, promptstr, cmdchars, &ch)) { nextoffset += offset;
exitnow = B_TRUE; exitnow = B_TRUE;
break; break;
} }
} // end if count >= offset
count++;
} }
} }
} }
} } // end foreach obtype
} }
if (!anyfound) { if (!anyfound) {
mvwprintw(mainwin, y, 0, "%s cannot cast any spells.", you(lf)); mvwprintw(mainwin, y, 0, "%s cannot cast any spells.", you(lf));
@ -13643,7 +13693,6 @@ void showlfstats(lifeform_t *lf, int showall) {
} }
} }
// spells // spells
nfound = 0; nfound = 0;
for (f = lf->flags->first ; f ; f = f->next) { for (f = lf->flags->first ; f ; f = f->next) {
@ -14766,7 +14815,7 @@ void showlfstats(lifeform_t *lf, int showall) {
} }
wattroff(mainwin, A_UNDERLINE); wattroff(mainwin, A_UNDERLINE);
y = 2; y = headinglines;
if ((lf == player) && lfhasflag(lf, F_NOPACK)) { if ((lf == player) && lfhasflag(lf, F_NOPACK)) {
mvwprintw(mainwin, y, 0, "It cannot carry anything."); mvwprintw(mainwin, y, 0, "It cannot carry anything.");
} else if (countobs(lf->pack, B_FALSE)) { } else if (countobs(lf->pack, B_FALSE)) {
@ -14790,7 +14839,8 @@ void showlfstats(lifeform_t *lf, int showall) {
mvwprintw(mainwin, y, 0, "%s", buf); mvwprintw(mainwin, y, 0, "%s", buf);
if (o->next && downline(&y, h, "INVENTORY", NULL, promptstr, cmdchars, &ch)) { if (o->next && downline(&y, h, headinglines, &nextoffset)) {
nextoffset += offset;
break; break;
} }
} }
@ -14805,7 +14855,7 @@ void showlfstats(lifeform_t *lf, int showall) {
wattron(mainwin, A_UNDERLINE); wattron(mainwin, A_UNDERLINE);
centre(mainwin, C_WHITE, 0, "GODS"); centre(mainwin, C_WHITE, 0, "GODS");
wattroff(mainwin, A_UNDERLINE); wattroff(mainwin, A_UNDERLINE);
y = 2; y = headinglines;
snprintf(line, BUFLEN, "%-29s Worship? %-22s %s","God","Piety", "Happiness"); snprintf(line, BUFLEN, "%-29s Worship? %-22s %s","God","Piety", "Happiness");
@ -14896,8 +14946,70 @@ void showlfstats(lifeform_t *lf, int showall) {
} }
} }
// wait for key // display the prompt
if (isplayer(lf) || showall) {
snprintf(promptstr, BUFLEN, "^h[^W@^n=stats ^WS^nkills ^WA^nbils ^WM^nagic ^WE^nffects %s%s ^WESC^n=quit^h]",
isplayer(lf) ? "^WG^nods " : "",
isplayer(lf) ? "" : "^WI^ntems "
);
snprintf(cmdchars, BUFLEN, "@asme%s%s",isplayer(lf) ? "g" : "", isplayer(lf) ? "" : "i");
} else {
snprintf(cmdchars, BUFLEN, "@e");
// can always see stats & effects
snprintf(promptstr, BUFLEN, "^h[^W@^n=stats ^WE^nffects ");
if (!isplayer(lf)) {
snprintf(buf, BUFLEN, "^WI^ntems ");
strcat(promptstr, buf);
strcat(cmdchars, "i");
}
if ((lorelev >= PR_ADEPT) || (getskill(player, SK_LORE_ARCANA) >= PR_ADEPT)) {
snprintf(buf, BUFLEN, "^WM^nagic ");
strcat(promptstr, buf);
strcat(cmdchars, "m");
}
snprintf(buf, BUFLEN, "^WESC^n=quit]");
strcat(promptstr, buf);
}
switch (mode) {
case 'g': // help on gods
case 's': // help on skills
case '@': // help on current race
strcat(cmdchars, "?");
default:
break;
}
// are there other pages to go to (or go back to)?
strcpy(navstr, "");
if (nextoffset) {
strcat(cmdchars, "']}");
if (offset) {
strcat(cmdchars, "[{");
}
snprintf(buf, BUFLEN, "^W'^n=next page %s^W]^n=forward %s^W}^n=pgdn",
(offset) ? "^W[^n=back " : "",
(offset) ? "^W{^n=pgup " : "");
strncat(navstr, buf, BUFLEN);
} else if (offset) {
strcat(cmdchars, "'[{");
snprintf(buf, BUFLEN, "^W'^n=back to start ^W[^n=back ^W{^n=pgup");
strncat(navstr, buf, BUFLEN);
}
if (strlen(navstr)) {
centre(mainwin, C_GREY, h-3, "(%s)", navstr);
}
if (strchr(cmdchars, '?')) {
centre(mainwin, C_MAGENTA, 1, "[Press ? for a full description]");
}
centre(mainwin, C_WHITE, h-1, promptstr); centre(mainwin, C_WHITE, h-1, promptstr);
// wait for key
if (ch == '\0') { if (ch == '\0') {
ch = getch(); ch = getch();
} }
@ -14918,6 +15030,34 @@ void showlfstats(lifeform_t *lf, int showall) {
case 's': case 's':
case 'i': case 'i':
mode = ch; mode = ch;
offset = 0;
nextoffset = 0;
break;
case '\'':
// go to next page, or back to start
if (nextoffset) {
offset = nextoffset;
} else {
offset = 0;
}
break;
case ']':
// go forward one line
offset++;
break;
case '[':
// go back one line
offset--;
break;
case '}':
// go forward one page
offset += 18;
limit (&offset, NA, nextoffset);
break;
case '{':
// go back one page
offset -= 18;
limit (&offset, 0, NA);
break; break;
case '?': case '?':
if (mode == 'g') { // help on gods if (mode == 'g') { // help on gods

4
io.h
View File

@ -87,7 +87,8 @@ int dotakeoff(obpile_t *op);
int dothrow(obpile_t *op, object_t *o); int dothrow(obpile_t *op, object_t *o);
int dowear(obpile_t *op); int dowear(obpile_t *op);
int doweild(obpile_t *op); int doweild(obpile_t *op);
int downline(int *y, int h, char *heading, char *subheading, char *bottomstring, char *cmdchars, char *retchar); //int downline(int *y, int h, char *heading, char *subheading, char *bottomstring, char *cmdchars, char *retchar);
int downline(int *y, int h, int headinglines, int *nextoffset);
void drawbar(WINDOW *win, char *title, int cur, int max, int realmax, int lossamt, enum COLOUR textcol, enum COLOUR textcolwithbg, int barbg, int lossbg); void drawbar(WINDOW *win, char *title, int cur, int max, int realmax, int lossamt, enum COLOUR textcol, enum COLOUR textcolwithbg, int barbg, int lossbg);
void drawglyph(glyph_t *g, int x, int y); void drawglyph(glyph_t *g, int x, int y);
//void drawunviscell(cell_t *cell, int x, int y); //void drawunviscell(cell_t *cell, int x, int y);
@ -123,6 +124,7 @@ void initgfx(void);
void initprompt(prompt_t *p, char *q1); void initprompt(prompt_t *p, char *q1);
int keycodetokey(int keycode, int escseqok); int keycodetokey(int keycode, int escseqok);
void listobs(WINDOW *win, object_t **mylist, int *sellist, int *selcount, int firstob, int *counter, int lastline, int *y, char *myletters, int forpickup, int showpoints, object_t *sellshop, enum SHOPACTION sellaction); void listobs(WINDOW *win, object_t **mylist, int *sellist, int *selcount, int firstob, int *counter, int lastline, int *y, char *myletters, int forpickup, int showpoints, object_t *sellshop, enum SHOPACTION sellaction);
void lfstatheading(char *headstr, int offset);
char *makedesc_god(lifeform_t *god, char *retbuf); char *makedesc_god(lifeform_t *god, char *retbuf);
char *makedesc_job(job_t *j, char *retbuf); char *makedesc_job(job_t *j, char *retbuf);
char *makedesc_ob(object_t *o, char *retbuf); char *makedesc_ob(object_t *o, char *retbuf);

20
lf.c
View File

@ -11496,6 +11496,26 @@ char *getskillname(enum SKILL id) {
return "?unknownskill?"; return "?unknownskill?";
} }
char *getskilllevelabbr(enum SKILLLEVEL sl) {
switch (sl) {
case PR_INEPT:
return "---";
case PR_NOVICE:
return "Nov";
case PR_BEGINNER:
return "Beg";
case PR_ADEPT:
return "Adp";
case PR_SKILLED:
return "Skl";
case PR_EXPERT:
return "Exp";
case PR_MASTER:
return "Mst";
}
return "???";
}
char *getskilllevelname(enum SKILLLEVEL sl) { char *getskilllevelname(enum SKILLLEVEL sl) {
switch (sl) { switch (sl) {
case PR_INEPT: case PR_INEPT:

1
lf.h
View File

@ -306,6 +306,7 @@ long getspforpoint(lifeform_t *lf);
float getstatmod(lifeform_t *lf, enum ATTRIB att); float getstatmod(lifeform_t *lf, enum ATTRIB att);
char *getskilldesc(enum SKILL id ); char *getskilldesc(enum SKILL id );
char *getskillname(enum SKILL id ); char *getskillname(enum SKILL id );
char *getskilllevelabbr(enum SKILLLEVEL sl);
char *getskilllevelname(enum SKILLLEVEL sl); char *getskilllevelname(enum SKILLLEVEL sl);
int getteachableskills(lifeform_t *teacher, lifeform_t *student, int *info, enum TRADEINFOTYPE *tradetype, int *ninfo ); int getteachableskills(lifeform_t *teacher, lifeform_t *student, int *info, enum TRADEINFOTYPE *tradetype, int *ninfo );
int gettr(lifeform_t *lf); int gettr(lifeform_t *lf);

View File

@ -15084,8 +15084,9 @@ enum SPELLSCHOOL getspellschoolknown(lifeform_t *lf, enum OBTYPE spellid) {
} }
} }
// pick one randomly // pick the first one.
thisschool = poss2[rnd(0,nposs2-1)]; //thisschool = poss2[rnd(0,nposs2-1)];
thisschool = poss2[0];
} else { } else {
// if we don't know any of the schools... // if we don't know any of the schools...
// just pick the first one. // just pick the first one.