some tty per field rendering and optimization

This commit is contained in:
nhmall
2018-05-14 21:13:37 -04:00
parent fba7c06fd6
commit 2e8b69d5ff
2 changed files with 45 additions and 33 deletions

View File

@@ -17,6 +17,7 @@ Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository
Platform- and/or Interface-Specific Fixes Platform- and/or Interface-Specific Fixes
----------------------------------------- -----------------------------------------
windows-tty: Specify both width and height when creating font for width testing windows-tty: Specify both width and height when creating font for width testing
tty: some optimizations for performance and per field rendering
Code Cleanup and Reorganization Code Cleanup and Reorganization

View File

@@ -3650,6 +3650,8 @@ unsigned long *colormasks;
int i; int i;
long *condptr = (long *) ptr; long *condptr = (long *) ptr;
char *text = (char *) ptr; char *text = (char *) ptr;
char *lastchar = (char *) 0;
char *fval = (char *) 0;
boolean do_color = FALSE; boolean do_color = FALSE;
boolean force_update = FALSE; boolean force_update = FALSE;
@@ -3672,15 +3674,6 @@ unsigned long *colormasks;
tty_status[NOW][fldidx].dirty = TRUE; tty_status[NOW][fldidx].dirty = TRUE;
truncation_expected = FALSE; truncation_expected = FALSE;
break; break;
case BL_CAP:
for (i = 0; i < SIZE(encvals); ++i) {
if (!strcmp(encvals[enc_shrinklvl][i],
status_vals[BL_CAP])) {
enclev = i;
break;
}
}
/*FALLTHRU*/
default: default:
tty_status[NOW][fldidx].idx = fldidx; tty_status[NOW][fldidx].idx = fldidx;
Sprintf(status_vals[fldidx], Sprintf(status_vals[fldidx],
@@ -3692,16 +3685,9 @@ unsigned long *colormasks;
tty_status[NOW][fldidx].lth = strlen(status_vals[fldidx]); tty_status[NOW][fldidx].lth = strlen(status_vals[fldidx]);
tty_status[NOW][fldidx].valid = TRUE; tty_status[NOW][fldidx].valid = TRUE;
tty_status[NOW][fldidx].dirty = TRUE; tty_status[NOW][fldidx].dirty = TRUE;
break; break;
} }
/* Special additional processing for hitpointbar */
if (iflags.wc2_hitpointbar && fldidx == BL_HP) {
hpbar_percent = percent;
hpbar_color = do_color ? (color & 0x00FF) : NO_COLOR;
}
/* The core botl engine sends a single blank to the window port /* The core botl engine sends a single blank to the window port
for carrying-capacity when its unused. Let's suppress that */ for carrying-capacity when its unused. Let's suppress that */
if (tty_status[NOW][fldidx].lth == 1 if (tty_status[NOW][fldidx].lth == 1
@@ -3710,24 +3696,49 @@ unsigned long *colormasks;
tty_status[NOW][fldidx].lth = 0; tty_status[NOW][fldidx].lth = 0;
} }
/* The core botl engine sends trailing blanks for some fields /* default processing above was required before these */
Let's suppress the trailing blanks */ switch (fldidx) {
if (fldidx == BL_LEVELDESC || fldidx == BL_HUNGER) { case BL_HP:
char *lastchar = eos(status_vals[fldidx]); if (iflags.wc2_hitpointbar) {
lastchar--; /* Special additional processing for hitpointbar */
while (lastchar && *lastchar == ' ' hpbar_percent = percent;
&& lastchar >= status_vals[fldidx]) { hpbar_color = do_color ? (color & 0x00FF) : NO_COLOR;
*lastchar-- = '\0'; }
tty_status[NOW][fldidx].lth--; break;
} case BL_LEVELDESC:
case BL_HUNGER:
/* The core sends trailing blanks for some fields
Let's suppress the trailing blanks */
char *lastchar = eos(status_vals[fldidx]);
lastchar = eos(status_vals[fldidx]);
lastchar--;
while (lastchar && *lastchar == ' '
&& lastchar >= status_vals[fldidx]) {
*lastchar-- = '\0';
tty_status[NOW][fldidx].lth--;
}
break;
case BL_TITLE:
if (iflags.wc2_hitpointbar)
tty_status[NOW][fldidx].lth += 2; /* '[' and ']' */
break;
case BL_GOLD:
tty_status[NOW][fldidx].lth -= 9; /* \GXXXXNNNN counts as 1 */
break;
case BL_CAP:
fval = status_vals[fldidx];
if (fval) {
if (*fval == ' ')
fval++;
for (i = 0; i < SIZE(encvals); ++i) {
if (!strcmp(encvals[enc_shrinklvl][i], fval)) {
enclev = i;
break; /* for */
}
}
}
break;
} }
/* Some other special case fixups */
if (iflags.wc2_hitpointbar && fldidx == BL_TITLE)
tty_status[NOW][fldidx].lth += 2; /* [ and ] */
if (fldidx == BL_GOLD)
tty_status[NOW][fldidx].lth -= 9; /* \GXXXXNNNN counts as 1 */
if (make_things_fit(force_update) || truncation_expected) if (make_things_fit(force_update) || truncation_expected)
render_status(); render_status();
return; return;