Hilite Status: Improved

Allow defining multiple stops per field. Add hitpointbar.
This commit is contained in:
Pasi Kallinen
2017-09-26 10:04:25 +03:00
parent cac4344754
commit 69f7a78dba
37 changed files with 3227 additions and 1532 deletions
+70 -6
View File
@@ -2567,6 +2567,9 @@ The behavior of this option depends on the type of windowing you use.
In text windowing, text highlighting or inverse video is often used; In text windowing, text highlighting or inverse video is often used;
with tiles, generally displays a small plus-symbol beside the object with tiles, generally displays a small plus-symbol beside the object
on the top of the pile. on the top of the pile.
.lp hitpointbar
Show a hit point bar graph behind your name and title.
Only available for TTY, and only when statushilites is on.
.lp horsename .lp horsename
Name your starting horse (ex. ``horsename:Trigger''). Name your starting horse (ex. ``horsename:Trigger'').
Cannot be set with the `O' command. Cannot be set with the `O' command.
@@ -2910,7 +2913,8 @@ attack to which it is resistant (default on). Persistent.
.lp standout .lp standout
Boldface monsters and ``\fB--More--\fP'' (default off). Persistent. Boldface monsters and ``\fB--More--\fP'' (default off). Persistent.
.lp statushilites .lp statushilites
Enable coloring of status fields (default off). Controls how many turns status hilite behaviors highlight
the field. If negated or set to zero, disables status hiliting.
See ``Configuring Status Hilites'' for further information. See ``Configuring Status Hilites'' for further information.
.lp status_updates .lp status_updates
Allow updates to the status lines at the bottom of the screen (default true). Allow updates to the status lines at the bottom of the screen (default true).
@@ -3479,17 +3483,22 @@ Your copy of NetHack may have been compiled with support for ``Status Hilites''.
If so, you can customize your game display by setting thresholds to If so, you can customize your game display by setting thresholds to
change the color or appearance of fields in the status display. change the color or appearance of fields in the status display.
.pg .pg
The format for defining status colors is:
.si
.lp "OPTION=hilite_status: field-name/behavior/color&attributes"
.ei
.pg
For example, the following line in your config file will cause For example, the following line in your config file will cause
the hitpoints field to display in the color red if your hitpoints the hitpoints field to display in the color red if your hitpoints
drop to or below a threshold of 30%: drop to or below a threshold of 30%:
.si .si
.lp "OPTION=hilite_status: hitpoints/30%/red/normal" .lp "OPTION=hilite_status: hitpoints/<30%/red/normal"
.ei .ei
.pg .pg
For another example, the following line in your config file will cause For another example, the following line in your config file will cause
wisdom to be displayed red if it drops and green if it rises. wisdom to be displayed red if it drops and green if it rises.
.si .si
.lp "OPTION=hilite_status: wisdom/updown/red/green" .lp "OPTION=hilite_status: wisdom/down/red/up/green"
.ei .ei
.pg .pg
You can adjust the display of the following status fields: You can adjust the display of the following status fields:
@@ -3508,18 +3517,73 @@ experience condition
.\"TABLE_END Do not delete this line. .\"TABLE_END Do not delete this line.
.TE .TE
.lp "" .lp ""
The pseudo-field `characteristics' can be used to set all six
of Str, Dex, Con, Int, Wis, and Cha at once. `HD' is `hit dice',
an approximation of experience level displayed when polymorphed.
`experience', `time', and `score' are conditionally displayed
depending upon your other option settings.
.lp ""
Instead of a behavior, `condition' takes the following condition flags:
stone, slime, strngl, foodpois, termill, blind, deaf, stun, conf, hallu,
lev, fly, and ride. You can use `major_troubles' as an alias
for stone through termill, `minor_troubles' for blind through hallu,
`movement' for lev, fly, and ride, and `all' for every condition.
.lp ""
Allowed behaviors are "always", "up", "down", "changed", a
percentage or absolute number threshold, or a text to match against.
.si
.lp "*"
"always" will set the default attributes for that field.
.lp "*"
"up" and "down" set the field attributes for when the field
value changes upwards or downwards. This attribute times out after
statushilites turns.
.lp "*"
"changed" sets the field attribute for when the field value
changes. This attribute times out after statushilites turns.
.lp "*"
percentage sets the field attribute when the field value
matches the percentage. If the percentage is prefixed with '<'
or '>', it also matches when value is below or above the percentage.
Only valid for `power' and `hitpoints' fields.
.lp "*"
absolute value sets the attribute when the field value
matches that number. If the number is prefixed with '<'
or '>', it also matches when value is below or above.
.lp "*"
text match sets the attribute when the field value
matches the text. Text matches can only be used for `alignment',
`carrying-capacity', and `dungeon-level'.
.ei
.lp ""
Allowed colors are black, red, green, brown, blue, magenta, cyan, gray, Allowed colors are black, red, green, brown, blue, magenta, cyan, gray,
orange, lightgreen, yellow, lightblue, lightmagenta, lightcyan, and white. orange, lightgreen, yellow, lightblue, lightmagenta, lightcyan, and white.
.lp "" .lp ""
Allowed attributes are bold, inverse, normal. Allowed attributes are bold, inverse, underline, blink, dim, and normal.
Note that the platform used may interpret the attributes any way it Note that the platform used may interpret the attributes any way it
wants. wants.
.lp "" .lp ""
Behaviours can occur based on percentage thresholds, updown, or absolute values.
The in-game options menu can help you determine the correct syntax for a The in-game options menu can help you determine the correct syntax for a
config file. config file.
.lp "" .lp ""
The whole feature can be disabled by setting option statushilites off. The whole feature can be disabled by setting option
statushilites to 0.
.lp ""
Example hilites:
.sd
.si
OPTION=hilite_status: gold/up/yellow/down/brown
OPTION=hilite_status: characteristics/up/green/down/red
OPTION=hilite_status: hitpoints/100%/gray&normal
OPTION=hilite_status: hitpoints/<100%/green&normal
OPTION=hilite_status: hitpoints/<66%/yellow&normal
OPTION=hilite_status: hitpoints/<50%/orange&normal
OPTION=hilite_status: hitpoints/<33%/red&bold
OPTION=hilite_status: hitpoints/<15%/red&inverse
OPTION=hilite_status: condition/major/orange&inverse
OPTION=hilite_status: condition/lev+fly/red&inverse
.ei
.ed
.pg .pg
.hn 2 .hn 2
Modifying NetHack Symbols Modifying NetHack Symbols
+86 -6
View File
@@ -3141,6 +3141,10 @@ on the top of the pile.
Name your starting horse (ex.\ ``{\tt horsename:Trigger}''). Name your starting horse (ex.\ ``{\tt horsename:Trigger}'').
Cannot be set with the `{\tt O}' command. Cannot be set with the `{\tt O}' command.
%.lp %.lp
\item[\ib{hitpointbar}]
Show a hit point bar graph behind your name and title.
Only available for TTY, and only when statushilites is on.
%.lp
\item[\ib{ignintr}] \item[\ib{ignintr}]
Ignore interrupt signals, including breaks (default off). Persistent. Ignore interrupt signals, including breaks (default off). Persistent.
%.lp %.lp
@@ -3535,7 +3539,8 @@ attack to which it is resistant (default on). Persistent.
Boldface monsters and ``{\tt --More--}'' (default off). Persistent. Boldface monsters and ``{\tt --More--}'' (default off). Persistent.
%.lp %.lp
\item[\ib{statushilites}] \item[\ib{statushilites}]
Enable coloring of status fields (default off). Controls how many turns status hilite behaviors highlight
the field. If negated or set to zero, disables status hiliting.
See ``{\it Configuring Status Hilites\/}'' for further information. See ``{\it Configuring Status Hilites\/}'' for further information.
%.lp %.lp
\item[\ib{status\verb+_+updates}] \item[\ib{status\verb+_+updates}]
@@ -4271,18 +4276,23 @@ The pattern should be a regular expression.
Your copy of NetHack may have been compiled with support for {\it Status Hilites}. Your copy of NetHack may have been compiled with support for {\it Status Hilites}.
If so, you can customize your game display by setting thresholds to If so, you can customize your game display by setting thresholds to
change the color or appearance of fields in the status display. change the color or appearance of fields in the status display.
%.pg
The format for defining status colors is:
\begin{verbatim}
OPTION=hilite_status: field-name/behavior/color&attributes
\end{verbatim}
%.pg
For example, the following line in your config file will cause For example, the following line in your config file will cause
the hitpoints field to display in the color red if your hitpoints the hitpoints field to display in the color red if your hitpoints
drop to or below a threshold of 30%: drop to or below a threshold of 30%:
\begin{verbatim} \begin{verbatim}
OPTION=hilite_status: hitpoints/30%/red/normal OPTION=hilite_status: hitpoints/<30%/red/normal
\end{verbatim} \end{verbatim}
%.pg %.pg
For another example, the following line in your config file will cause For another example, the following line in your config file will cause
wisdom to be displayed red if it drops and green if it rises. wisdom to be displayed red if it drops and green if it rises.
\begin{verbatim} \begin{verbatim}
OPTION=hilite_status: wisdom/updown/red/green OPTION=hilite_status: wisdom/down/red/up/green
\end{verbatim} \end{verbatim}
You can adjust the display of the following status fields: You can adjust the display of the following status fields:
%.sd %.sd
@@ -4301,6 +4311,56 @@ experience & condition\\
\end{tabular} \end{tabular}
\end{center} \end{center}
%.ed %.ed
%.lp ""
The pseudo-field `characteristics' can be used to set all six
of Str, Dex, Con, Int, Wis, and Cha at once. `HD' is `hit dice',
an approximation of experience level displayed when polymorphed.
`experience', `time', and `score' are conditionally displayed
depending upon your other option settings.
%.lp ""
Instead of a behavior, `condition' takes the following condition flags:
{\it stone}, {\it slime}, {\it strngl}, {\it foodpois}, {\it termill},
{\it blind}, {\it deaf}, {\it stun}, {\it conf}, {\it hallu},
{\it lev}, {\it fly}, and {\it ride}. You can use `major\_troubles' as an alias
for stone through termill, `minor\_troubles' for blind through hallu,
`movement' for lev, fly, and ride, and `all' for every condition.
%.lp ""
Allowed behaviors are "always", "up", "down", "changed", a
percentage or absolute number threshold, or a text to match against.
\blist{}
%.lp "*"
\item{\bb{}}
"always" will set the default attributes for that field.
%.lp "*"
\item{\bb{}}
"up" and "down" set the field attributes for when the field
value changes upwards or downwards. This attribute times out after
statushilites turns.
%.lp "*"
\item{\bb{}}
"changed" sets the field attribute for when the field value
changes. This attribute times out after statushilites turns.
%.lp "*"
\item{\bb{}}
percentage sets the field attribute when the field value
matches the percentage. If the percentage is prefixed with `{\tt <}'
or `{\tt >}', it also matches when value is below or above the percentage.
Only valid for `power' and `hitpoints' fields.
%.lp "*"
\item{\bb{}}
absolute value sets the attribute when the field value
matches that number. If the number is prefixed with `{\tt <}'
or `{\tt >}', it also matches when value is below or above.
%.lp "*"
\item{\bb{}}
text match sets the attribute when the field value
matches the text. Text matches can only be used for `alignment',
`carrying-capacity', and `dungeon-level'.
%.ei
\elist
%.lp "" %.lp ""
Allowed colors are {\it black}, {\it red}, {\it green}, {\it brown}, Allowed colors are {\it black}, {\it red}, {\it green}, {\it brown},
@@ -4309,12 +4369,32 @@ Allowed colors are {\it black}, {\it red}, {\it green}, {\it brown},
{\it lightcyan}, and {\it white}. {\it lightcyan}, and {\it white}.
%.lp "" %.lp ""
Behaviours can occur based on percentage thresholds, updown, or absolute values. Allowed attributes are {\it bold}, {\it inverse}, {\it underline},
{\it blink}, {\it dim}, and {\it normal}.
Note that the platform used may interpret the attributes any way it
wants.
%.lp ""
The in-game options menu can help you determine the correct syntax for a The in-game options menu can help you determine the correct syntax for a
config file. config file.
%.lp "" %.lp ""
The whole feature can be disable by setting option {\it statushilites} off. The whole feature can be disable by setting option {\it statushilites} to 0.
%.lp ""
Example hilites:
\begin{verbatim}
OPTION=hilite_status: gold/up/yellow/down/brown
OPTION=hilite_status: characteristics/up/green/down/red
OPTION=hilite_status: hitpoints/100%/gray&normal
OPTION=hilite_status: hitpoints/<100%/green&normal
OPTION=hilite_status: hitpoints/<66%/yellow&normal
OPTION=hilite_status: hitpoints/<50%/orange&normal
OPTION=hilite_status: hitpoints/<33%/red&bold
OPTION=hilite_status: hitpoints/<15%/red&inverse
OPTION=hilite_status: condition/major/orange&inverse
OPTION=hilite_status: condition/lev+fly/red&inverse
\end{verbatim}
%.lp %.lp
%.hn 2 %.hn 2
+3
View File
@@ -450,6 +450,8 @@ if a potion on the floor survived a land mine explosion and got propelled at
adjust candelabrum's weight when candles are attached adjust candelabrum's weight when candles are attached
when lit candelabrum burned out, persistent inventory window showed that it when lit candelabrum burned out, persistent inventory window showed that it
was no longer lit but still showed phantom candles attached was no longer lit but still showed phantom candles attached
improve hilite_status, allowing multiple stops per field, and temporarily or
permanently hilited fields
Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository
@@ -671,6 +673,7 @@ new paranoid_confirm settings: wand-break to require "yes" rather than 'y'
than 'y' when hero inflicted with lycanthropy has polymorph control than 'y' when hero inflicted with lycanthropy has polymorph control
option force_invmenu to make commands asking for inventory items always option force_invmenu to make commands asking for inventory items always
use a menu instead of a text line query use a menu instead of a text line query
option hitpointbar to show a bar graph of hit points behind title field
Platform- and/or Interface-Specific New Features Platform- and/or Interface-Specific New Features
+113 -45
View File
@@ -401,7 +401,7 @@ status_enablefield(int fldindex, char fldname, char fieldfmt, boolean enable)
BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, BL_HPMAX, BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, BL_HPMAX,
BL_LEVELDESC, BL_EXP, BL_CONDITION BL_LEVELDESC, BL_EXP, BL_CONDITION
-- There are MAXBLSTATS status fields (from botl.h) -- There are MAXBLSTATS status fields (from botl.h)
status_update(int fldindex, genericptr_t ptr, int chg, int percentage) status_update(int fldindex, genericptr_t ptr, int chg, int percentage, int color, long *colormasks)
-- update the value of a status field. -- update the value of a status field.
-- the fldindex identifies which field is changing and -- the fldindex identifies which field is changing and
is an integer index value from botl.h is an integer index value from botl.h
@@ -417,58 +417,124 @@ status_update(int fldindex, genericptr_t ptr, int chg, int percentage)
-- ptr is usually a "char *", unless fldindex is BL_CONDITION. -- ptr is usually a "char *", unless fldindex is BL_CONDITION.
If fldindex is BL_CONDITION, then ptr is a long value with If fldindex is BL_CONDITION, then ptr is a long value with
any or none of the following bits set (from botl.h): any or none of the following bits set (from botl.h):
BL_MASK_BLIND 0x00000001L BL_MASK_STONE 0x00000001L
BL_MASK_CONF 0x00000002L BL_MASK_SLIME 0x00000002L
BL_MASK_FOODPOIS 0x00000004L BL_MASK_STRNGL 0x00000004L
BL_MASK_ILL 0x00000008L BL_MASK_FOODPOIS 0x00000008L
BL_MASK_HALLU 0x00000010L BL_MASK_TERMILL 0x00000010L
BL_MASK_STUNNED 0x00000020L BL_MASK_BLIND 0x00000020L
BL_MASK_SLIMED 0x00000040L BL_MASK_DEAF 0x00000040L
BL_MASK_STUN 0x00000080L
BL_MASK_CONF 0x00000100L
BL_MASK_HALLU 0x00000200L
BL_MASK_LEV 0x00000400L
BL_MASK_FLY 0x00000800L
BL_MASK_RIDE 0x00001000L
-- The value passed for BL_GOLD includes a leading -- The value passed for BL_GOLD includes a leading
symbol for GOLD "$:nnn". If the window port needs to use symbol for GOLD "$:nnn". If the window port needs to use
the textual gold amount without the leading "$:" the port the textual gold amount without the leading "$:" the port
will have to add 2 to the passed "ptr" for the BL_GOLD case. will have to add 2 to the passed "ptr" for the BL_GOLD case.
-- color is an unsigned int.
int & 0x00FF = color CLR_*
int >> 8 = attribute (if any)
This contains the color and attribute that the field should
be displayed in.
This is relevant for everything except BL_CONDITION fldindex.
If fldindex is BL_CONDITION, this parameter should be ignored,
as condition hilighting is done via the next colormasks
parameter instead.
-- colormasks - pointer to cond_hilites[] array of colormasks.
Only relevant for BL_CONDITION fldindex. The window port
should ignore this parameter for other fldindex values.
Each condition bit must only ever appear in one of the
CLR_ array members, but can appear in multiple HL_ATTCLR_
offsets (because more than one attribute can co-exist).
For the user's chosen set of BL_MASK_ condition bits,
They are stored internally in the cond_hilites[] array,
at the array offset aligned to the color those condtion
bits should display in.
For example, if the user has chosen to display strngl
and stone and termill in red and inverse,
BL_MASK_SLIME 0x00000002
BL_MASK_STRNGL 0x00000004
BL_MASK_TERMILL 0x00000010
The bitmask corresponding to those conditions is
0x00000016 (or 00010110 in binary) and the color
is at offset 1 (CLR_RED).
Here is how that is stored in the cond_hilites[] array:
+------+----------------------+--------------------+
|array | | |
|offset| macro for indexing | bitmask |
|------+----------------------+--------------------+
| 0 | CLR_BLACK | |
+------+----------------------+--------------------+
| 1 | CLR_RED | 00010110 |
+------+----------------------+--------------------+
| 2 | CLR_GREEN | |
+------+----------------------+--------------------+
| 3 | CLR_BROWN | |
+------+----------------------+--------------------+
| 4 | CLR_BLUE | |
+------+----------------------+--------------------+
| 5 | CLR_MAGENTA | |
+------+----------------------+--------------------+
| 6 | CLR_CYAN | |
+------+----------------------+--------------------+
| 7 | CLR_GRAY | |
+------+----------------------+--------------------+
| 8 | NO_COLOR | |
+------+----------------------+--------------------+
| 9 | CLR_ORANGE | |
+------+----------------------+--------------------+
| 10 | CLR_BRIGHT_GREEN | |
+------+----------------------+--------------------+
| 11 | CLR_BRIGHT_YELLOW | |
+------+----------------------+--------------------+
| 12 | CLR_BRIGHT_BLUE | |
+------+----------------------+--------------------+
| 13 | CLR_BRIGHT_MAGENTA | |
+------+----------------------+--------------------+
| 14 | CLR_BRIGHT_CYAN | |
+------+----------------------+--------------------+
| 15 | CLR_WHITE | |
+------+----------------------+--------------------+
| 16 | HL_ATTCLR_DIM | | CLR_MAX
+------+----------------------+--------------------+
| 17 | HL_ATTCLR_BLINK | |
+------+----------------------+--------------------+
| 18 | HL_ATTCLR_ULINE | |
+------+----------------------+--------------------+
| 19 | HL_ATTCLR_INVERSE | 00010110 |
+------+----------------------+--------------------+
| 20 | HL_ATTCLR_BOLD | |
+------+----------------------+--------------------+
| 21 | beyond array boundary | BL_ATTCLR_MAX
The window port can AND (&) the bits passed in the
ptr argument to status_update() with any non-zero
entries in the cond_hilites[] array to determine
the color and attributes for displaying the
condition on the screen for the user.
If the bit for a particular condition does not
appear in any of the cond_hilites[] array offsets,
that condition should be displayed in the default
color and attributes.
status_finish() -- called when it is time for the window port to tear down status_finish() -- called when it is time for the window port to tear down
the status display and free allocated memory, etc. the status display and free allocated memory, etc.
status_threshold(int fldidx, int threshholdtype, anything threshold,
int behavior, int under, int over)
-- called when a hiliting preference is added, changed, or
removed.
-- the fldindex identifies which field is having its hiliting
preference set. It is an integer index value from botl.h
-- fldindex could be any one of the following from botl.h:
BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH,
BL_ALIGN, BL_SCORE, BL_CAP, BL_GOLD, BL_ENE, BL_ENEMAX,
BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, BL_HPMAX,
BL_LEVELDESC, BL_EXP, BL_CONDITION
-- datatype is P_INT, P_UINT, P_LONG, or P_MASK.
-- threshold is an "anything" union which can contain the
datatype value.
-- behavior is used to define how threshold is used and can
be BL_TH_NONE, BL_TH_VAL_PERCENTAGE, BL_TH_VAL_ABSOLUTE,
or BL_TH_UPDOWN. BL_TH_NONE means don't do anything above
or below the threshold. BL_TH_VAL_PERCENTAGE treats the
threshold value as a precentage of the maximum possible
value. BL_TH_VAL_ABSOLUTE means that the threshold is an
actual value. BL_TH_UPDOWN means that threshold is not
used, and the two below/above hilite values indicate how
to display something going down (under) or rising (over).
-- under is the hilite attribute used if value is below the
threshold. The attribute can be BL_HILITE_NONE,
BL_HILITE_INVERSE, BL_HILITE_BOLD (-1, -2, or -3), or one
of the color indexes of CLR_BLACK, CLR_RED, CLR_GREEN,
CLR_BROWN, CLR_BLUE, CLR_MAGENTA, CLR_CYAN, CLR_GRAY,
CLR_ORANGE, CLR_BRIGHT_GREEN, CLR_YELLOW, CLR_BRIGHT_BLUE,
CLR_BRIGHT_MAGENTA, CLR_BRIGHT_CYAN, or CLR_WHITE (0 - 15).
-- over is the hilite attribute used if value is at or above
the threshold. The attribute can be BL_HILITE_NONE,
BL_HILITE_INVERSE, BL_HILITE_BOLD (-1, -2, or -3), or one
of the color indexes of CLR_BLACK, CLR_RED, CLR_GREEN,
CLR_BROWN, CLR_BLUE, CLR_MAGENTA, CLR_CYAN, CLR_GRAY,
CLR_ORANGE, CLR_BRIGHT_GREEN, CLR_YELLOW, CLR_BRIGHT_BLUE,
CLR_BRIGHT_MAGENTA, CLR_BRIGHT_CYAN, or CLR_WHITE (0 - 15).
E. Misc. Routines E. Misc. Routines
@@ -703,6 +769,7 @@ to support:
| softkeyboard | WC2_SOFTKEYBOARD | wc2_softkeyboard |boolean | | softkeyboard | WC2_SOFTKEYBOARD | wc2_softkeyboard |boolean |
| wraptext | WC2_WRAPTEXT | wc2_wraptext |boolean | | wraptext | WC2_WRAPTEXT | wc2_wraptext |boolean |
| selectsaved | WC2_SELECTSAVED | wc2_selectsaved |boolean | | selectsaved | WC2_SELECTSAVED | wc2_selectsaved |boolean |
| hitpointbar | WC2_HITPOINTBAR | wc2_hitpointbar |boolean |
+--------------------+--------------------+--------------------+--------+ +--------------------+--------------------+--------------------+--------+
align_message -- where to place message window (top, bottom, left, right) align_message -- where to place message window (top, bottom, left, right)
@@ -723,6 +790,7 @@ font_status -- port should use a font by this name for status display.
font_text -- port should use a font by this name for text windows. font_text -- port should use a font by this name for text windows.
fullscreen -- port should try to use the whole screen. fullscreen -- port should try to use the whole screen.
hilite_pet -- port should mark pets in some special way on the map. hilite_pet -- port should mark pets in some special way on the map.
hitpointbar -- port should show a graphical bar representing hit points
map_mode -- port should display the map in the manner specified. map_mode -- port should display the map in the manner specified.
player_selection player_selection
-- dialog or prompts for choosing character. -- dialog or prompts for choosing character.
+31 -38
View File
@@ -27,42 +27,18 @@ Astral Plane \GXXXXNNNN:123456 HP:1234(1234) Pw:1234(1234) AC:-127
#define MAXCO (COLNO + 40) #define MAXCO (COLNO + 40)
#endif #endif
#ifdef STATUS_VIA_WINDOWPORT enum statusfields {
#if 0 BL_CHARACTERISTICS = -2, /* alias for BL_STR..BL_CH */
/* clang-format off */ BL_FLUSH = -1, BL_TITLE = 0,
#define BL_FLUSH -1 BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, /* 1..6 */
#define BL_TITLE 0 BL_ALIGN, BL_SCORE, BL_CAP, BL_GOLD, BL_ENE, BL_ENEMAX, /* 7..12 */
#define BL_STR 1 BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, BL_HPMAX, BL_LEVELDESC, /* 13..20 */
#define BL_DX 2 BL_EXP, BL_CONDITION
#define BL_CO 3 };
#define BL_IN 4
#define BL_WI 5
#define BL_CH 6
#define BL_ALIGN 7
#define BL_SCORE 8
#define BL_CAP 9
#define BL_GOLD 10
#define BL_ENE 11
#define BL_ENEMAX 12
#define BL_XP 13
#define BL_AC 14
#define BL_HD 15
#define BL_TIME 16
#define BL_HUNGER 17
#define BL_HP 18
#define BL_HPMAX 19
#define BL_LEVELDESC 20
#define BL_EXP 21
#define BL_CONDITION 22
/* clang-format on */
#else enum relationships { LT_VALUE = -1, EQ_VALUE, GT_VALUE, TXT_VALUE };
enum statusfields { BL_FLUSH = -1, BL_TITLE = 0, BL_STR, BL_DX, BL_CO, BL_IN,
BL_WI, BL_CH, BL_ALIGN, BL_SCORE, BL_CAP, BL_GOLD, BL_ENE, BL_ENEMAX, #define MAXBLSTATS (BL_CONDITION + 1)
BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, BL_HPMAX, BL_LEVELDESC,
BL_EXP, BL_CONDITION };
#endif
#define MAXBLSTATS BL_CONDITION+1
#define BEFORE 0 #define BEFORE 0
#define NOW 1 #define NOW 1
@@ -87,7 +63,7 @@ BL_EXP, BL_CONDITION };
#define REASSESS_ONLY TRUE #define REASSESS_ONLY TRUE
#ifdef STATUS_HILITES /* #ifdef STATUS_HILITES */
/* hilite status field behavior - coloridx values */ /* hilite status field behavior - coloridx values */
#define BL_HILITE_NONE -1 /* no hilite of this field */ #define BL_HILITE_NONE -1 /* no hilite of this field */
#define BL_HILITE_INVERSE -2 /* inverse hilite */ #define BL_HILITE_INVERSE -2 /* inverse hilite */
@@ -98,9 +74,26 @@ BL_EXP, BL_CONDITION };
#define BL_TH_VAL_ABSOLUTE 101 /* threshold is particular value */ #define BL_TH_VAL_ABSOLUTE 101 /* threshold is particular value */
#define BL_TH_UPDOWN 102 /* threshold is up or down change */ #define BL_TH_UPDOWN 102 /* threshold is up or down change */
#define BL_TH_CONDITION 103 /* threshold is bitmask of conditions */ #define BL_TH_CONDITION 103 /* threshold is bitmask of conditions */
#endif #define BL_TH_TEXTMATCH 104 /* threshold text value to match against */
#define BL_TH_ALWAYS_HILITE 105 /* highlight regardless of value */
#define HL_ATTCLR_DIM CLR_MAX + 0
#define HL_ATTCLR_BLINK CLR_MAX + 1
#define HL_ATTCLR_ULINE CLR_MAX + 2
#define HL_ATTCLR_INVERSE CLR_MAX + 3
#define HL_ATTCLR_BOLD CLR_MAX + 4
#define BL_ATTCLR_MAX CLR_MAX + 5
enum hlattribs { HL_UNDEF = 0x00,
HL_NONE = 0x01,
HL_BOLD = 0x02,
HL_INVERSE = 0x04,
HL_ULINE = 0x08,
HL_BLINK = 0x10,
HL_DIM = 0x20 };
/* #endif STATUS_HILITES */
extern const char *status_fieldnames[]; /* in botl.c */ extern const char *status_fieldnames[]; /* in botl.c */
#endif
#endif /* BOTL_H */ #endif /* BOTL_H */
+1 -3
View File
@@ -498,9 +498,7 @@ typedef unsigned char uchar;
* Only available with POSIX_TYPES or GNU C */ * Only available with POSIX_TYPES or GNU C */
/* #define MSGHANDLER */ /* #define MSGHANDLER */
/* #define STATUS_VIA_WINDOWPORT */ /* re-work of the status line #define STATUS_HILITES /* support hilites of status fields */
updating process */
/* #define STATUS_HILITES */ /* support hilites of status fields */
/* #define WINCHAIN */ /* stacked window systems */ /* #define WINCHAIN */ /* stacked window systems */
-2
View File
@@ -325,9 +325,7 @@ E NEARDATA char **viz_array; /* could see/in sight row pointers */
/* Window system stuff */ /* Window system stuff */
E NEARDATA winid WIN_MESSAGE; E NEARDATA winid WIN_MESSAGE;
#ifndef STATUS_VIA_WINDOWPORT
E NEARDATA winid WIN_STATUS; E NEARDATA winid WIN_STATUS;
#endif
E NEARDATA winid WIN_MAP, WIN_INVEN; E NEARDATA winid WIN_MAP, WIN_INVEN;
/* pline (et al) for a single string argument (suppress compiler warning) */ /* pline (et al) for a single string argument (suppress compiler warning) */
+10 -11
View File
@@ -153,17 +153,17 @@ E long NDECL(botl_score);
E int FDECL(describe_level, (char *)); E int FDECL(describe_level, (char *));
E const char *FDECL(rank_of, (int, SHORT_P, BOOLEAN_P)); E const char *FDECL(rank_of, (int, SHORT_P, BOOLEAN_P));
E void NDECL(bot); E void NDECL(bot);
#ifdef STATUS_VIA_WINDOWPORT
E void FDECL(status_initialize, (BOOLEAN_P)); E void FDECL(status_initialize, (BOOLEAN_P));
E void NDECL(status_finish); E void NDECL(status_finish);
E void FDECL(status_notify_windowport, (BOOLEAN_P)); E void FDECL(status_notify_windowport, (BOOLEAN_P));
E void NDECL(status_eval_next_unhilite);
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
E boolean FDECL(set_status_hilites, (char *op, BOOLEAN_P)); E boolean FDECL(parse_status_hl1, (char *op, BOOLEAN_P));
E void FDECL(clear_status_hilites, (BOOLEAN_P)); E void NDECL(clear_status_hilites);
E char *FDECL(get_status_hilites, (char *, int)); E void NDECL(reset_status_hilites);
E int NDECL(count_status_hilites);
E boolean NDECL(status_hilite_menu); E boolean NDECL(status_hilite_menu);
#endif #endif
#endif
/* ### cmd.c ### */ /* ### cmd.c ### */
@@ -869,6 +869,7 @@ E char *FDECL(upstart, (char *));
E char *FDECL(mungspaces, (char *)); E char *FDECL(mungspaces, (char *));
E char *FDECL(trimspaces, (char *)); E char *FDECL(trimspaces, (char *));
E char *FDECL(strip_newline, (char *)); E char *FDECL(strip_newline, (char *));
E char *FDECL(stripchars, (char *, const char *, const char *));
E char *FDECL(eos, (char *)); E char *FDECL(eos, (char *));
E boolean FDECL(str_end_is, (const char *, const char *)); E boolean FDECL(str_end_is, (const char *, const char *));
E char *FDECL(strkitten, (char *, CHAR_P)); E char *FDECL(strkitten, (char *, CHAR_P));
@@ -1711,8 +1712,11 @@ E boolean FDECL(parsesymbols, (char *));
E struct symparse *FDECL(match_sym, (char *)); E struct symparse *FDECL(match_sym, (char *));
E void NDECL(set_playmode); E void NDECL(set_playmode);
E int FDECL(sym_val, (const char *)); E int FDECL(sym_val, (const char *));
E int FDECL(query_color, (const char *));
E int FDECL(query_attr, (const char *));
E const char *FDECL(clr2colorname, (int)); E const char *FDECL(clr2colorname, (int));
E int FDECL(match_str2clr, (char *)); E int FDECL(match_str2clr, (char *));
E int FDECL(match_str2attr, (const char *, BOOLEAN_P));
E boolean FDECL(add_menu_coloring, (char *)); E boolean FDECL(add_menu_coloring, (char *));
E boolean FDECL(get_menu_coloring, (char *, int *, int *)); E boolean FDECL(get_menu_coloring, (char *, int *, int *));
E void NDECL(free_menu_coloring); E void NDECL(free_menu_coloring);
@@ -2736,16 +2740,11 @@ E void FDECL(genl_putmsghistory, (const char *, BOOLEAN_P));
#ifdef HANGUPHANDLING #ifdef HANGUPHANDLING
E void NDECL(nhwindows_hangup); E void NDECL(nhwindows_hangup);
#endif #endif
#ifdef STATUS_VIA_WINDOWPORT
E void NDECL(genl_status_init); E void NDECL(genl_status_init);
E void NDECL(genl_status_finish); E void NDECL(genl_status_finish);
E void FDECL(genl_status_enablefield, E void FDECL(genl_status_enablefield,
(int, const char *, const char *, BOOLEAN_P)); (int, const char *, const char *, BOOLEAN_P));
E void FDECL(genl_status_update, (int, genericptr_t, int, int)); E void FDECL(genl_status_update, (int, genericptr_t, int, int, int, unsigned long *));
#ifdef STATUS_HILITES
E void FDECL(genl_status_threshold, (int, int, anything, int, int, int));
#endif
#endif
E void FDECL(dump_open_log, (time_t)); E void FDECL(dump_open_log, (time_t));
E void NDECL(dump_close_log); E void NDECL(dump_close_log);
+5 -1
View File
@@ -251,7 +251,10 @@ struct instance_flags {
boolean toptenwin; /* ending list in window instead of stdout */ boolean toptenwin; /* ending list in window instead of stdout */
boolean use_background_glyph; /* use background glyph when appropriate */ boolean use_background_glyph; /* use background glyph when appropriate */
boolean use_menu_color; /* use color in menus; only if wc_color */ boolean use_menu_color; /* use color in menus; only if wc_color */
boolean use_status_hilites; /* use color in status line */ #ifdef STATUS_HILITES
long hilite_delta; /* number of moves to leave a temp hilite lit */
long unhilite_deadline; /* time when oldest temp hilite should be unlit */
#endif
boolean zerocomp; /* write zero-compressed save files */ boolean zerocomp; /* write zero-compressed save files */
boolean rlecomp; /* alternative to zerocomp; run-length encoding boolean rlecomp; /* alternative to zerocomp; run-length encoding
* compression of levels when writing savefile */ * compression of levels when writing savefile */
@@ -360,6 +363,7 @@ struct instance_flags {
boolean wc2_wraptext; /* wrap text */ boolean wc2_wraptext; /* wrap text */
boolean wc2_selectsaved; /* display a menu of user's saved games */ boolean wc2_selectsaved; /* display a menu of user's saved games */
boolean wc2_darkgray; /* try to use dark-gray color for black glyphs */ boolean wc2_darkgray; /* try to use dark-gray color for black glyphs */
boolean wc2_hitpointbar; /* show graphical bar representing hit points */
boolean cmdassist; /* provide detailed assistance for some commands */ boolean cmdassist; /* provide detailed assistance for some commands */
boolean clicklook; /* allow right-clicking for look */ boolean clicklook; /* allow right-clicking for look */
boolean obsolete; /* obsolete options can point at this, it isn't used */ boolean obsolete; /* obsolete options can point at this, it isn't used */
+6 -19
View File
@@ -73,16 +73,11 @@ struct window_procs {
void FDECL((*win_preference_update), (const char *)); void FDECL((*win_preference_update), (const char *));
char *FDECL((*win_getmsghistory), (BOOLEAN_P)); char *FDECL((*win_getmsghistory), (BOOLEAN_P));
void FDECL((*win_putmsghistory), (const char *, BOOLEAN_P)); void FDECL((*win_putmsghistory), (const char *, BOOLEAN_P));
#ifdef STATUS_VIA_WINDOWPORT
void NDECL((*win_status_init)); void NDECL((*win_status_init));
void NDECL((*win_status_finish)); void NDECL((*win_status_finish));
void FDECL((*win_status_enablefield), void FDECL((*win_status_enablefield),
(int, const char *, const char *, BOOLEAN_P)); (int, const char *, const char *, BOOLEAN_P));
void FDECL((*win_status_update), (int, genericptr_t, int, int)); void FDECL((*win_status_update), (int, genericptr_t, int, int, int, unsigned long *));
#ifdef STATUS_HILITES
void FDECL((*win_status_threshold), (int, int, anything, int, int, int));
#endif
#endif
boolean NDECL((*win_can_suspend)); boolean NDECL((*win_can_suspend));
}; };
@@ -160,16 +155,11 @@ extern
#define preference_update (*windowprocs.win_preference_update) #define preference_update (*windowprocs.win_preference_update)
#define getmsghistory (*windowprocs.win_getmsghistory) #define getmsghistory (*windowprocs.win_getmsghistory)
#define putmsghistory (*windowprocs.win_putmsghistory) #define putmsghistory (*windowprocs.win_putmsghistory)
#ifdef STATUS_VIA_WINDOWPORT
/* there is a status_initialize() in botl.c, /* there is a status_initialize() in botl.c,
* which calls win_status_init() directly; same with status_finish. * which calls win_status_init() directly; same with status_finish.
*/ */
#define status_enablefield (*windowprocs.win_status_enablefield) #define status_enablefield (*windowprocs.win_status_enablefield)
#define status_update (*windowprocs.win_status_update) #define status_update (*windowprocs.win_status_update)
#ifdef STATUS_HILITES
#define status_threshold (*windowprocs.win_status_threshold)
#endif
#endif
/* /*
* WINCAP * WINCAP
@@ -221,7 +211,10 @@ extern
#define WC2_HILITE_STATUS 0x0008L /* 04 hilite fields in status */ #define WC2_HILITE_STATUS 0x0008L /* 04 hilite fields in status */
#define WC2_SELECTSAVED 0x0010L /* 05 saved game selection menu */ #define WC2_SELECTSAVED 0x0010L /* 05 saved game selection menu */
#define WC2_DARKGRAY 0x0020L /* 06 use bold black for black glyphs */ #define WC2_DARKGRAY 0x0020L /* 06 use bold black for black glyphs */
/* 26 free bits */ #define WC2_HITPOINTBAR 0x0040L /* 07 show bar representing hit points */
#define WC2_FLUSH_STATUS 0x0080L /* 08 call status_update(BL_FLUSH)
after updating status window fields */
/* 24 free bits */
#define ALIGN_LEFT 1 #define ALIGN_LEFT 1
#define ALIGN_RIGHT 2 #define ALIGN_RIGHT 2
@@ -362,17 +355,11 @@ struct chain_procs {
void FDECL((*win_preference_update), (CARGS, const char *)); void FDECL((*win_preference_update), (CARGS, const char *));
char *FDECL((*win_getmsghistory), (CARGS, BOOLEAN_P)); char *FDECL((*win_getmsghistory), (CARGS, BOOLEAN_P));
void FDECL((*win_putmsghistory), (CARGS, const char *, BOOLEAN_P)); void FDECL((*win_putmsghistory), (CARGS, const char *, BOOLEAN_P));
#ifdef STATUS_VIA_WINDOWPORT
void FDECL((*win_status_init), (CARGS)); void FDECL((*win_status_init), (CARGS));
void FDECL((*win_status_finish), (CARGS)); void FDECL((*win_status_finish), (CARGS));
void FDECL((*win_status_enablefield), void FDECL((*win_status_enablefield),
(CARGS, int, const char *, const char *, BOOLEAN_P)); (CARGS, int, const char *, const char *, BOOLEAN_P));
void FDECL((*win_status_update), (CARGS, int, genericptr_t, int, int)); void FDECL((*win_status_update), (CARGS, int, genericptr_t, int, int, int, unsigned long));
#ifdef STATUS_HILITES
void FDECL((*win_status_threshold),
(CARGS, int, int, anything, int, int, int));
#endif
#endif
boolean FDECL((*win_can_suspend), (CARGS)); boolean FDECL((*win_can_suspend), (CARGS));
}; };
#endif /* WINCHAIN */ #endif /* WINCHAIN */
+1 -6
View File
@@ -215,13 +215,8 @@ E short FDECL(set_tty_font_name, (winid, char *));
#endif #endif
E char *NDECL(tty_get_color_string); E char *NDECL(tty_get_color_string);
#endif #endif
#ifdef STATUS_VIA_WINDOWPORT
E void NDECL(tty_status_init); E void NDECL(tty_status_init);
E void FDECL(tty_status_update, (int, genericptr_t, int, int)); E void FDECL(tty_status_update, (int, genericptr_t, int, int, int, unsigned long *));
#ifdef STATUS_HILITES
E void FDECL(tty_status_threshold, (int, int, anything, int, int, int));
#endif
#endif
/* other defs that really should go away (they're tty specific) */ /* other defs that really should go away (they're tty specific) */
E void NDECL(tty_start_screen); E void NDECL(tty_start_screen);
+7 -9
View File
@@ -59,15 +59,12 @@ boolean resuming;
context.rndencode = rnd(9000); context.rndencode = rnd(9000);
set_wear((struct obj *) 0); /* for side-effects of starting gear */ set_wear((struct obj *) 0); /* for side-effects of starting gear */
(void) pickup(1); /* autopickup at initial location */ (void) pickup(1); /* autopickup at initial location */
} else { /* restore old game */ }
#ifndef WIN32 context.botlx = TRUE; /* for STATUS_HILITES */
update_inventory(); /* for perm_invent */ update_inventory(); /* for perm_invent */
#endif if (resuming) { /* restoring old game */
read_engr_at(u.ux, u.uy); /* subset of pickup() */ read_engr_at(u.ux, u.uy); /* subset of pickup() */
} }
#ifdef WIN32
update_inventory(); /* for perm_invent */
#endif
(void) encumber_msg(); /* in case they auto-picked up something */ (void) encumber_msg(); /* in case they auto-picked up something */
if (defer_see_monsters) { if (defer_see_monsters) {
@@ -317,6 +314,7 @@ boolean resuming;
/* once-per-hero-took-time things go here */ /* once-per-hero-took-time things go here */
/******************************************/ /******************************************/
status_eval_next_unhilite();
if (context.bypasses) if (context.bypasses)
clear_bypasses(); clear_bypasses();
if ((u.uhave.amulet || Clairvoyant) && !In_endgame(&u.uz) if ((u.uhave.amulet || Clairvoyant) && !In_endgame(&u.uz)
@@ -529,7 +527,7 @@ void
display_gamewindows() display_gamewindows()
{ {
WIN_MESSAGE = create_nhwindow(NHW_MESSAGE); WIN_MESSAGE = create_nhwindow(NHW_MESSAGE);
#ifdef STATUS_VIA_WINDOWPORT #ifdef STATUS_HILITES
status_initialize(0); status_initialize(0);
#else #else
WIN_STATUS = create_nhwindow(NHW_STATUS); WIN_STATUS = create_nhwindow(NHW_STATUS);
@@ -553,7 +551,7 @@ display_gamewindows()
* The mac port is not DEPENDENT on the order of these * The mac port is not DEPENDENT on the order of these
* displays, but it looks a lot better this way... * displays, but it looks a lot better this way...
*/ */
#ifndef STATUS_VIA_WINDOWPORT #ifndef STATUS_HILITES
display_nhwindow(WIN_STATUS, FALSE); display_nhwindow(WIN_STATUS, FALSE);
#endif #endif
display_nhwindow(WIN_MESSAGE, FALSE); display_nhwindow(WIN_MESSAGE, FALSE);
+2355 -752
View File
File diff suppressed because it is too large Load Diff
-2
View File
@@ -264,9 +264,7 @@ NEARDATA char **viz_array = 0; /* used in cansee() and couldsee() macros */
/* Global windowing data, defined here for multi-window-system support */ /* Global windowing data, defined here for multi-window-system support */
NEARDATA winid WIN_MESSAGE = WIN_ERR; NEARDATA winid WIN_MESSAGE = WIN_ERR;
#ifndef STATUS_VIA_WINDOWPORT
NEARDATA winid WIN_STATUS = WIN_ERR; NEARDATA winid WIN_STATUS = WIN_ERR;
#endif
NEARDATA winid WIN_MAP = WIN_ERR, WIN_INVEN = WIN_ERR; NEARDATA winid WIN_MAP = WIN_ERR, WIN_INVEN = WIN_ERR;
char toplines[TBUFSZ]; char toplines[TBUFSZ];
/* Windowing stuff that's really tty oriented, but present for all ports */ /* Windowing stuff that's really tty oriented, but present for all ports */
+1 -1
View File
@@ -1277,7 +1277,7 @@ int how;
destroy_nhwindow(WIN_INVEN), WIN_INVEN = WIN_ERR; destroy_nhwindow(WIN_INVEN), WIN_INVEN = WIN_ERR;
display_nhwindow(WIN_MESSAGE, TRUE); display_nhwindow(WIN_MESSAGE, TRUE);
destroy_nhwindow(WIN_MAP), WIN_MAP = WIN_ERR; destroy_nhwindow(WIN_MAP), WIN_MAP = WIN_ERR;
#ifndef STATUS_VIA_WINDOWPORT #ifndef STATUS_HILITES
destroy_nhwindow(WIN_STATUS), WIN_STATUS = WIN_ERR; destroy_nhwindow(WIN_STATUS), WIN_STATUS = WIN_ERR;
#endif #endif
destroy_nhwindow(WIN_MESSAGE), WIN_MESSAGE = WIN_ERR; destroy_nhwindow(WIN_MESSAGE), WIN_MESSAGE = WIN_ERR;
+5
View File
@@ -2540,6 +2540,11 @@ char *origbuf;
} else if (match_varname(buf, "MENUCOLOR", 9)) { } else if (match_varname(buf, "MENUCOLOR", 9)) {
if (!add_menu_coloring(bufp)) if (!add_menu_coloring(bufp))
retval = FALSE; retval = FALSE;
} else if (match_varname(buf, "HILITE_STATUS", 6)) {
#ifdef STATUS_HILITES
if (!parse_status_hl1(bufp, TRUE))
retval = FALSE;
#endif
} else if (match_varname(buf, "WARNINGS", 5)) { } else if (match_varname(buf, "WARNINGS", 5)) {
(void) get_uchars(bufp, translate, FALSE, WARNCOUNT, (void) get_uchars(bufp, translate, FALSE, WARNCOUNT,
"WARNINGS"); "WARNINGS");
+26
View File
@@ -20,6 +20,7 @@
char * mungspaces (char *) char * mungspaces (char *)
char * trimspaces (char *) char * trimspaces (char *)
char * strip_newline (char *) char * strip_newline (char *)
char * stripchars (char *, const char *, const char *)
char * eos (char *) char * eos (char *)
boolean str_end_is (const char *, const char *) boolean str_end_is (const char *, const char *)
char * strkitten (char *,char) char * strkitten (char *,char)
@@ -433,6 +434,31 @@ char c;
return ccc; return ccc;
} }
/* strip all the chars in stuff_to_strip from orig */
/* caller is responsible for ensuring that bp is a
valid pointer to a BUFSZ buffer */
char *
stripchars(bp, stuff_to_strip, orig)
char *bp;
const char *stuff_to_strip, *orig;
{
int i = 0;
char *s = bp;
if (s) {
while (s && *orig && i < (BUFSZ - 1)) {
if (!index(stuff_to_strip, *orig)) {
*s++ = *orig;
i++;
}
orig++;
}
*s = '\0';
} else
impossible("no output buf in stripchars");
return bp;
}
/* substitute a word or phrase in a string (in place) */ /* substitute a word or phrase in a string (in place) */
/* caller is responsible for ensuring that bp points to big enough buffer */ /* caller is responsible for ensuring that bp points to big enough buffer */
char * char *
+67 -40
View File
@@ -131,6 +131,9 @@ static struct Bool_Opt {
{ "help", &flags.help, TRUE, SET_IN_GAME }, { "help", &flags.help, TRUE, SET_IN_GAME },
{ "hilite_pet", &iflags.wc_hilite_pet, FALSE, SET_IN_GAME }, /*WC*/ { "hilite_pet", &iflags.wc_hilite_pet, FALSE, SET_IN_GAME }, /*WC*/
{ "hilite_pile", &iflags.hilite_pile, FALSE, SET_IN_GAME }, { "hilite_pile", &iflags.hilite_pile, FALSE, SET_IN_GAME },
#ifdef STATUS_HILITES
{ "hitpointbar", &iflags.wc2_hitpointbar, FALSE, SET_IN_GAME }, /*WC2*/
#endif
#ifndef MAC #ifndef MAC
{ "ignintr", &flags.ignintr, FALSE, SET_IN_GAME }, { "ignintr", &flags.ignintr, FALSE, SET_IN_GAME },
#else #else
@@ -205,11 +208,6 @@ static struct Bool_Opt {
{ "sparkle", &flags.sparkle, TRUE, SET_IN_GAME }, { "sparkle", &flags.sparkle, TRUE, SET_IN_GAME },
{ "splash_screen", &iflags.wc_splash_screen, TRUE, DISP_IN_GAME }, /*WC*/ { "splash_screen", &iflags.wc_splash_screen, TRUE, DISP_IN_GAME }, /*WC*/
{ "standout", &flags.standout, FALSE, SET_IN_GAME }, { "standout", &flags.standout, FALSE, SET_IN_GAME },
#if defined(STATUS_VIA_WINDOWPORT) && defined(STATUS_HILITES)
{ "statushilites", &iflags.use_status_hilites, TRUE, SET_IN_GAME },
#else
{ "statushilites", &iflags.use_status_hilites, FALSE, DISP_IN_GAME },
#endif
{ "status_updates", &iflags.status_updates, TRUE, DISP_IN_GAME }, { "status_updates", &iflags.status_updates, TRUE, DISP_IN_GAME },
{ "tiled_map", &iflags.wc_tiled_map, PREFER_TILED, DISP_IN_GAME }, /*WC*/ { "tiled_map", &iflags.wc_tiled_map, PREFER_TILED, DISP_IN_GAME }, /*WC*/
{ "time", &flags.time, FALSE, SET_IN_GAME }, { "time", &flags.time, FALSE, SET_IN_GAME },
@@ -375,6 +373,13 @@ static struct Comp_Opt {
SET_IN_GAME }, SET_IN_GAME },
#ifdef MSDOS #ifdef MSDOS
{ "soundcard", "type of sound card to use", 20, SET_IN_FILE }, { "soundcard", "type of sound card to use", 20, SET_IN_FILE },
#endif
#ifdef STATUS_HILITES
{ "statushilites",
"0=no status highlighting, N=show highlights for N turns",
20, SET_IN_GAME },
#else
{ "statushilites", "highlight control", 20, SET_IN_FILE },
#endif #endif
{ "symset", "load a set of display symbols from the symbols file", 70, { "symset", "load a set of display symbols from the symbols file", 70,
SET_IN_GAME }, SET_IN_GAME },
@@ -516,10 +521,7 @@ STATIC_DCL int FDECL(feature_alert_opts, (char *, const char *));
STATIC_DCL boolean FDECL(duplicate_opt_detection, (const char *, int)); STATIC_DCL boolean FDECL(duplicate_opt_detection, (const char *, int));
STATIC_DCL void FDECL(complain_about_duplicate, (const char *, int)); STATIC_DCL void FDECL(complain_about_duplicate, (const char *, int));
STATIC_DCL int FDECL(match_str2attr, (const char *));
STATIC_DCL const char *FDECL(attr2attrname, (int)); STATIC_DCL const char *FDECL(attr2attrname, (int));
STATIC_DCL int NDECL(query_color);
STATIC_DCL int FDECL(query_attr, (const char *));
STATIC_DCL const char * FDECL(msgtype2name, (int)); STATIC_DCL const char * FDECL(msgtype2name, (int));
STATIC_DCL int NDECL(query_msgtype); STATIC_DCL int NDECL(query_msgtype);
STATIC_DCL boolean FDECL(msgtype_add, (int, char *)); STATIC_DCL boolean FDECL(msgtype_add, (int, char *));
@@ -1279,9 +1281,9 @@ static const struct {
{ "light magenta", CLR_BRIGHT_MAGENTA }, { "light magenta", CLR_BRIGHT_MAGENTA },
{ "light cyan", CLR_BRIGHT_CYAN }, { "light cyan", CLR_BRIGHT_CYAN },
{ "white", CLR_WHITE }, { "white", CLR_WHITE },
{ "no color", NO_COLOR },
{ NULL, CLR_BLACK }, /* everything after this is an alias */ { NULL, CLR_BLACK }, /* everything after this is an alias */
{ "transparent", NO_COLOR }, { "transparent", NO_COLOR },
{ "nocolor", NO_COLOR },
{ "purple", CLR_MAGENTA }, { "purple", CLR_MAGENTA },
{ "light purple", CLR_BRIGHT_MAGENTA }, { "light purple", CLR_BRIGHT_MAGENTA },
{ "bright purple", CLR_BRIGHT_MAGENTA }, { "bright purple", CLR_BRIGHT_MAGENTA },
@@ -1302,7 +1304,10 @@ static const struct {
{ "dim", ATR_DIM }, { "dim", ATR_DIM },
{ "underline", ATR_ULINE }, { "underline", ATR_ULINE },
{ "blink", ATR_BLINK }, { "blink", ATR_BLINK },
{ "inverse", ATR_INVERSE } { "inverse", ATR_INVERSE },
{ NULL, ATR_NONE }, /* everything after this is an alias */
{ "normal", ATR_NONE },
{ "uline", ATR_ULINE }
}; };
const char * const char *
@@ -1321,7 +1326,7 @@ int
match_str2clr(str) match_str2clr(str)
char *str; char *str;
{ {
int i, c = NO_COLOR; int i, c = CLR_MAX;
/* allow "lightblue", "light blue", and "light-blue" to match "light blue" /* allow "lightblue", "light blue", and "light-blue" to match "light blue"
(also junk like "_l i-gh_t---b l u e" but we won't worry about that); (also junk like "_l i-gh_t---b l u e" but we won't worry about that);
@@ -1353,9 +1358,10 @@ int attr;
return (char *) 0; return (char *) 0;
} }
STATIC_OVL int int
match_str2attr(str) match_str2attr(str, complain)
const char *str; const char *str;
boolean complain;
{ {
int i, a = -1; int i, a = -1;
@@ -1366,14 +1372,15 @@ const char *str;
break; break;
} }
if (a == -1) if (a == -1 && complain)
config_error_add("Unknown text attribute '%s'", str); config_error_add("Unknown text attribute '%s'", str);
return a; return a;
} }
STATIC_OVL int int
query_color() query_color(prompt)
const char *prompt;
{ {
winid tmpwin; winid tmpwin;
anything any; anything any;
@@ -1390,7 +1397,7 @@ query_color()
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, colornames[i].name, add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, colornames[i].name,
MENU_UNSELECTED); MENU_UNSELECTED);
} }
end_menu(tmpwin, "Pick a color"); end_menu(tmpwin, (prompt && *prompt) ? prompt : "Pick a color");
pick_cnt = select_menu(tmpwin, PICK_ONE, &picks); pick_cnt = select_menu(tmpwin, PICK_ONE, &picks);
destroy_nhwindow(tmpwin); destroy_nhwindow(tmpwin);
if (pick_cnt > 0) { if (pick_cnt > 0) {
@@ -1401,7 +1408,7 @@ query_color()
return -1; return -1;
} }
STATIC_OVL int int
query_attr(prompt) query_attr(prompt)
const char *prompt; const char *prompt;
{ {
@@ -1420,7 +1427,7 @@ const char *prompt;
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, attrnames[i].attr, add_menu(tmpwin, NO_GLYPH, &any, 0, 0, attrnames[i].attr,
attrnames[i].name, MENU_UNSELECTED); attrnames[i].name, MENU_UNSELECTED);
} }
end_menu(tmpwin, prompt ? prompt : "Pick an attribute"); end_menu(tmpwin, (prompt && *prompt) ? prompt : "Pick an attribute");
pick_cnt = select_menu(tmpwin, PICK_ONE, &picks); pick_cnt = select_menu(tmpwin, PICK_ONE, &picks);
destroy_nhwindow(tmpwin); destroy_nhwindow(tmpwin);
if (pick_cnt > 0) { if (pick_cnt > 0) {
@@ -1706,7 +1713,7 @@ char *tmpstr;
if (amp) { if (amp) {
tmps = amp + 1; /* advance past '&' */ tmps = amp + 1; /* advance past '&' */
a = match_str2attr(tmps); a = match_str2attr(tmps, TRUE);
if (a == -1) if (a == -1)
return FALSE; return FALSE;
} }
@@ -3427,7 +3434,7 @@ boolean tinitial, tfrom_file;
} else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) { } else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
return FALSE; return FALSE;
} }
tmpattr = match_str2attr(opts); tmpattr = match_str2attr(opts, TRUE);
if (tmpattr == -1) if (tmpattr == -1)
return FALSE; return FALSE;
else else
@@ -3458,23 +3465,39 @@ boolean tinitial, tfrom_file;
return retval; return retval;
} }
} }
#if defined(STATUS_VIA_WINDOWPORT) && defined(STATUS_HILITES) #ifdef STATUS_HILITES
/* hilite fields in status prompt */ /* hilite fields in status prompt */
if (match_optname(opts, "hilite_status", 13, TRUE)) { if (match_optname(opts, "hilite_status", 13, TRUE)) {
if (duplicate) if (duplicate)
complain_about_duplicate(opts, 1); complain_about_duplicate(opts, 1);
op = string_for_opt(opts, TRUE); op = string_for_opt(opts, TRUE);
if (op && negated) { if (op && negated) {
clear_status_hilites(tfrom_file); clear_status_hilites();
return retval; return retval;
} else if (!op) { } else if (!op) {
config_error_add("Value is mandatory for hilite_status"); config_error_add("Value is mandatory for hilite_status");
return FALSE; return FALSE;
} }
if (!set_status_hilites(op, tfrom_file)) /* TODO: error msg? */ if (!parse_status_hl1(op, tfrom_file))
return FALSE; return FALSE;
return retval; return retval;
} }
/* control over whether highlights should be displayed, and for how long */
fullname = "statushilites";
if (match_optname(opts, fullname, 9, TRUE)) {
if (negated) {
iflags.hilite_delta = 0L;
} else {
op = string_for_opt(opts, TRUE);
iflags.hilite_delta = (!op || !*op) ? 3L : atol(op);
if (iflags.hilite_delta < 0L)
iflags.hilite_delta = 1L;
}
if (!tfrom_file)
reset_status_hilites();
return retval;
}
#endif #endif
#if defined(BACKWARD_COMPAT) #if defined(BACKWARD_COMPAT)
@@ -3624,7 +3647,7 @@ boolean tinitial, tfrom_file;
|| boolopt[i].addr == &flags.showscore || boolopt[i].addr == &flags.showscore
#endif #endif
|| boolopt[i].addr == &flags.showexp) { || boolopt[i].addr == &flags.showexp) {
#ifdef STATUS_VIA_WINDOWPORT #ifdef STATUS_HILITES
status_initialize(REASSESS_ONLY); status_initialize(REASSESS_ONLY);
#endif #endif
context.botl = TRUE; context.botl = TRUE;
@@ -3650,6 +3673,9 @@ boolean tinitial, tfrom_file;
|| boolopt[i].addr == &iflags.hilite_pile || boolopt[i].addr == &iflags.hilite_pile
|| boolopt[i].addr == &iflags.hilite_pet) { || boolopt[i].addr == &iflags.hilite_pet) {
need_redraw = TRUE; need_redraw = TRUE;
} else if ((boolopt[i].addr) == &iflags.wc2_hitpointbar) {
status_initialize(REASSESS_ONLY);
need_redraw = TRUE;
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
} else if (boolopt[i].addr == &iflags.use_color) { } else if (boolopt[i].addr == &iflags.use_color) {
need_redraw = TRUE; need_redraw = TRUE;
@@ -3954,10 +3980,8 @@ static struct other_opts {
{ "autopickup exceptions", SET_IN_GAME, OPT_OTHER_APEXC }, { "autopickup exceptions", SET_IN_GAME, OPT_OTHER_APEXC },
{ "menucolors", SET_IN_GAME, OPT_OTHER_MENUCOLOR }, { "menucolors", SET_IN_GAME, OPT_OTHER_MENUCOLOR },
{ "message types", SET_IN_GAME, OPT_OTHER_MSGTYPE }, { "message types", SET_IN_GAME, OPT_OTHER_MSGTYPE },
#ifdef STATUS_VIA_WINDOWPORT
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
{ "status_hilites", SET_IN_GAME, OPT_OTHER_STATHILITE }, { "status hilite rules", SET_IN_GAME, OPT_OTHER_STATHILITE },
#endif
#endif #endif
{ (char *) 0, 0, (enum opt_other_enums) 0 }, { (char *) 0, 0, (enum opt_other_enums) 0 },
}; };
@@ -4092,13 +4116,9 @@ doset() /* changing options via menu by Per Liboriussen */
NULL, count_menucolors()); NULL, count_menucolors());
opts_add_others(tmpwin, "message types", OPT_OTHER_MSGTYPE, opts_add_others(tmpwin, "message types", OPT_OTHER_MSGTYPE,
NULL, msgtype_count()); NULL, msgtype_count());
#ifdef STATUS_VIA_WINDOWPORT
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
get_status_hilites(buf2, 60); opts_add_others(tmpwin, "status hilite rules", OPT_OTHER_STATHILITE,
if (!*buf2) NULL, count_status_hilites());
Sprintf(buf2, "%s", "(none)");
opts_add_others(tmpwin, "status_hilites", OPT_OTHER_STATHILITE, buf2, 0);
#endif
#endif #endif
#ifdef PREFIXES_IN_USE #ifdef PREFIXES_IN_USE
any = zeroany; any = zeroany;
@@ -4123,16 +4143,14 @@ doset() /* changing options via menu by Per Liboriussen */
if (opt_indx == OPT_OTHER_APEXC) { if (opt_indx == OPT_OTHER_APEXC) {
(void) special_handling("autopickup_exception", setinitial, (void) special_handling("autopickup_exception", setinitial,
fromfile); fromfile);
#ifdef STATUS_VIA_WINDOWPORT
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
} else if (opt_indx == OPT_OTHER_STATHILITE) { } else if (opt_indx == OPT_OTHER_STATHILITE) {
if (!status_hilite_menu()) { if (!status_hilite_menu()) {
pline("Bad status hilite(s) specified."); pline("Bad status hilite(s) specified.");
} else { } else {
if (wc2_supported("status_hilites")) if (wc2_supported("hilite_status"))
preference_update("status_hilites"); preference_update("hilite_status");
} }
#endif
#endif #endif
} else if (opt_indx == OPT_OTHER_MENUCOLOR) { } else if (opt_indx == OPT_OTHER_MENUCOLOR) {
(void) special_handling("menucolors", setinitial, (void) special_handling("menucolors", setinitial,
@@ -4728,7 +4746,7 @@ boolean setinitial, setfromfile;
return TRUE; return TRUE;
if (*mcbuf if (*mcbuf
&& test_regex_pattern(mcbuf, (const char *)0) && test_regex_pattern(mcbuf, (const char *)0)
&& (mcclr = query_color()) != -1 && (mcclr = query_color((char *) 0)) != -1
&& (mcattr = query_attr((char *) 0)) != -1 && (mcattr = query_attr((char *) 0)) != -1
&& !add_menu_coloring_parsed(mcbuf, mcclr, mcattr)) { && !add_menu_coloring_parsed(mcbuf, mcclr, mcattr)) {
pline("Error adding the menu color."); pline("Error adding the menu color.");
@@ -5305,6 +5323,14 @@ char *buf;
#ifdef MSDOS #ifdef MSDOS
} else if (!strcmp(optname, "soundcard")) { } else if (!strcmp(optname, "soundcard")) {
Sprintf(buf, "%s", to_be_done); Sprintf(buf, "%s", to_be_done);
#endif
#ifdef STATUS_HILITES
} else if (!strcmp("statushilites", optname)) {
if (!iflags.hilite_delta)
Strcpy(buf, "0 (off: don't highlight status fields)");
else
Sprintf(buf, "%ld (on: highlight status for %ld turns)",
iflags.hilite_delta, iflags.hilite_delta);
#endif #endif
} else if (!strcmp(optname, "suppress_alert")) { } else if (!strcmp(optname, "suppress_alert")) {
if (flags.suppress_alert == 0L) if (flags.suppress_alert == 0L)
@@ -6010,7 +6036,8 @@ struct wc_Opt wc2_options[] = { { "fullscreen", WC2_FULLSCREEN },
{ "softkeyboard", WC2_SOFTKEYBOARD }, { "softkeyboard", WC2_SOFTKEYBOARD },
{ "wraptext", WC2_WRAPTEXT }, { "wraptext", WC2_WRAPTEXT },
{ "use_darkgray", WC2_DARKGRAY }, { "use_darkgray", WC2_DARKGRAY },
#ifdef STATUS_VIA_WINDOWPORT #ifdef STATUS_HILITES
{ "hitpointbar", WC2_HITPOINTBAR },
{ "hilite_status", WC2_HILITE_STATUS }, { "hilite_status", WC2_HILITE_STATUS },
#endif #endif
{ (char *) 0, 0L } }; { (char *) 0, 0L } };
+3 -1
View File
@@ -107,9 +107,11 @@ set_uasmon()
youmonst.movement = new_speed * youmonst.movement / old_speed; youmonst.movement = new_speed * youmonst.movement / old_speed;
} }
#ifdef STATUS_VIA_WINDOWPORT #ifdef STATUS_HILITES
status_initialize(REASSESS_ONLY); status_initialize(REASSESS_ONLY);
#endif #endif
polysense();
} }
/* Levitation overrides Flying; set or clear BFlying|I_SPECIAL */ /* Levitation overrides Flying; set or clear BFlying|I_SPECIAL */
+1 -1
View File
@@ -1410,7 +1410,7 @@ freedynamicdata()
/* free_pickinv_cache(); -- now done from really_done()... */ /* free_pickinv_cache(); -- now done from really_done()... */
free_symsets(); free_symsets();
#endif /* FREE_ALL_MEMORY */ #endif /* FREE_ALL_MEMORY */
#ifdef STATUS_VIA_WINDOWPORT #ifdef STATUS_HILITES
status_finish(); status_finish();
#endif #endif
#ifdef DUMPLOG #ifdef DUMPLOG
+16 -29
View File
@@ -474,9 +474,7 @@ static short FDECL(hup_set_font_name, (winid, char *));
#endif #endif
static char *NDECL(hup_get_color_string); static char *NDECL(hup_get_color_string);
#endif /* CHANGE_COLOR */ #endif /* CHANGE_COLOR */
#ifdef STATUS_VIA_WINDOWPORT static void FDECL(hup_status_update, (int, genericptr_t, int, int, int, unsigned long *));
static void FDECL(hup_status_update, (int, genericptr_t, int, int));
#endif
static int NDECL(hup_int_ndecl); static int NDECL(hup_int_ndecl);
static void NDECL(hup_void_ndecl); static void NDECL(hup_void_ndecl);
@@ -526,14 +524,9 @@ static struct window_procs hup_procs = {
hup_void_ndecl, /* end_screen */ hup_void_ndecl, /* end_screen */
hup_outrip, genl_preference_update, genl_getmsghistory, hup_outrip, genl_preference_update, genl_getmsghistory,
genl_putmsghistory, genl_putmsghistory,
#ifdef STATUS_VIA_WINDOWPORT
hup_void_ndecl, /* status_init */ hup_void_ndecl, /* status_init */
hup_void_ndecl, /* status_finish */ hup_void_ndecl, /* status_finish */
genl_status_enablefield, hup_status_update, genl_status_enablefield, hup_status_update,
#ifdef STATUS_HILITES
genl_status_threshold,
#endif
#endif /* STATUS_VIA_WINDOWPORT */
genl_can_suspend_no, genl_can_suspend_no,
}; };
@@ -762,17 +755,17 @@ hup_get_color_string(VOID_ARGS)
} }
#endif /* CHANGE_COLOR */ #endif /* CHANGE_COLOR */
#ifdef STATUS_VIA_WINDOWPORT
/*ARGSUSED*/ /*ARGSUSED*/
static void static void
hup_status_update(idx, ptr, chg, percent) hup_status_update(idx, ptr, chg, pc, color, colormasks)
int idx UNUSED; int idx UNUSED;
genericptr_t ptr UNUSED; genericptr_t ptr UNUSED;
int chg UNUSED, percent UNUSED; int chg UNUSED, pc UNUSED, color UNUSED;
unsigned long *colormasks UNUSED;
{ {
return; return;
} }
#endif /* STATUS_VIA_WINDOWPORT */
/* /*
* Non-specific stubs. * Non-specific stubs.
@@ -816,7 +809,6 @@ const char *string UNUSED;
#endif /* HANGUPHANDLING */ #endif /* HANGUPHANDLING */
#ifdef STATUS_VIA_WINDOWPORT
/****************************************************************************/ /****************************************************************************/
/* genl backward compat stuff */ /* genl backward compat stuff */
@@ -871,10 +863,11 @@ boolean enable;
/* call once for each field, then call with BL_FLUSH to output the result */ /* call once for each field, then call with BL_FLUSH to output the result */
void void
genl_status_update(idx, ptr, chg, percent) genl_status_update(idx, ptr, chg, percent, color, colormasks)
int idx; int idx;
genericptr_t ptr; genericptr_t ptr;
int chg UNUSED, percent UNUSED; int chg UNUSED, percent UNUSED, color UNUSED;
unsigned long *colormasks UNUSED;
{ {
char newbot1[MAXCO], newbot2[MAXCO]; char newbot1[MAXCO], newbot2[MAXCO];
long cond, *condptr = (long *) ptr; long cond, *condptr = (long *) ptr;
@@ -912,12 +905,17 @@ int chg UNUSED, percent UNUSED;
BL_LEVELDESC, BL_GOLD, BL_XP, BL_EXP, BL_HD, BL_TIME, BL_FLUSH }, BL_LEVELDESC, BL_GOLD, BL_XP, BL_EXP, BL_HD, BL_TIME, BL_FLUSH },
}; };
/* in case interface is using genl_status_update() but has not
specified WC2_FLUSH_STATUS (status_update() for field values
is buffered so final BL_FLUSH is needed to produce output) */
windowprocs.wincap2 |= WC2_FLUSH_STATUS;
if (idx != BL_FLUSH) { if (idx != BL_FLUSH) {
if (!status_activefields[idx]) if (!status_activefields[idx])
return; return;
switch (idx) { switch (idx) {
case BL_CONDITION: case BL_CONDITION:
cond = *condptr; cond = condptr ? *condptr : 0L;
nb = status_vals[idx]; nb = status_vals[idx];
*nb = '\0'; *nb = '\0';
if (cond & BL_MASK_STONE) if (cond & BL_MASK_STONE)
@@ -949,7 +947,8 @@ int chg UNUSED, percent UNUSED;
break; break;
default: default:
Sprintf(status_vals[idx], Sprintf(status_vals[idx],
status_fieldfmt[idx] ? status_fieldfmt[idx] : "%s", text); status_fieldfmt[idx] ? status_fieldfmt[idx] : "%s",
text ? text : "");
break; break;
} }
return; /* processed one field other than BL_FLUSH */ return; /* processed one field other than BL_FLUSH */
@@ -1035,18 +1034,6 @@ int chg UNUSED, percent UNUSED;
putmixed(WIN_STATUS, 0, newbot2); /* putmixed() due to GOLD glyph */ putmixed(WIN_STATUS, 0, newbot2); /* putmixed() due to GOLD glyph */
} }
#ifdef STATUS_HILITES
void
genl_status_threshold(fldidx, thresholdtype, threshold, behavior, under, over)
int fldidx UNUSED, thresholdtype UNUSED;
anything threshold UNUSED;
int behavior UNUSED, under UNUSED, over UNUSED;
{
return;
}
#endif /* STATUS_HILITES */
#endif /* STATUS_VIA_WINDOWPORT */
STATIC_VAR struct window_procs dumplog_windowprocs_backup; STATIC_VAR struct window_procs dumplog_windowprocs_backup;
STATIC_VAR FILE *dumplog_file; STATIC_VAR FILE *dumplog_file;
-10
View File
@@ -51,13 +51,8 @@ struct window_procs amii_procs = {
/* other defs that really should go away (they're tty specific) */ /* other defs that really should go away (they're tty specific) */
amii_delay_output, amii_delay_output, amii_outrip, genl_preference_update, amii_delay_output, amii_delay_output, amii_outrip, genl_preference_update,
genl_getmsghistory, genl_putmsghistory, genl_getmsghistory, genl_putmsghistory,
#ifdef STATUS_VIA_WINDOWPORT
genl_status_init, genl_status_finish, genl_status_enablefield, genl_status_init, genl_status_finish, genl_status_enablefield,
genl_status_update, genl_status_update,
#ifdef STATUS_HILITES
genl_status_threshold,
#endif
#endif
genl_can_suspend_yes, genl_can_suspend_yes,
}; };
@@ -88,13 +83,8 @@ struct window_procs amiv_procs = {
/* other defs that really should go away (they're tty specific) */ /* other defs that really should go away (they're tty specific) */
amii_delay_output, amii_delay_output, amii_outrip, genl_preference_update, amii_delay_output, amii_delay_output, amii_outrip, genl_preference_update,
genl_getmsghistory, genl_putmsghistory, genl_getmsghistory, genl_putmsghistory,
#ifdef STATUS_VIA_WINDOWPORT
genl_status_init, genl_status_finish, genl_status_enablefield, genl_status_init, genl_status_finish, genl_status_enablefield,
genl_status_update, genl_status_update,
#ifdef STATUS_HILITES
genl_status_threshold,
#endif
#endif
genl_can_suspend_yes, genl_can_suspend_yes,
}; };
-5
View File
@@ -73,13 +73,8 @@ struct window_procs mswin_procs = {
/* other defs that really should go away (they're tty specific) */ /* other defs that really should go away (they're tty specific) */
mswin_start_screen, mswin_end_screen, mswin_outrip, mswin_start_screen, mswin_end_screen, mswin_outrip,
mswin_preference_update, genl_getmsghistory, genl_putmsghistory, mswin_preference_update, genl_getmsghistory, genl_putmsghistory,
#ifdef STATUS_VIA_WINDOWPORT
genl_status_init, genl_status_finish, genl_status_enablefield, genl_status_init, genl_status_finish, genl_status_enablefield,
genl_status_update, genl_status_update,
#ifdef STATUS_HILITES
genl_status_threshold,
#endif
#endif
genl_can_suspend_no, genl_can_suspend_no,
}; };
+15 -5
View File
@@ -42,9 +42,7 @@ void FDECL(cmov, (int, int));
void FDECL(nocmov, (int, int)); void FDECL(nocmov, (int, int));
int FDECL(process_keystroke, int FDECL(process_keystroke,
(INPUT_RECORD *, boolean *, BOOLEAN_P numberpad, int portdebug)); (INPUT_RECORD *, boolean *, BOOLEAN_P numberpad, int portdebug));
#ifdef TEXTCOLOR
static void NDECL(init_ttycolor); static void NDECL(init_ttycolor);
#endif
static void NDECL(really_move_cursor); static void NDECL(really_move_cursor);
/* Win32 Console handles for input and output */ /* Win32 Console handles for input and output */
@@ -111,8 +109,10 @@ static DWORD ccount, acount;
#ifndef CLR_MAX #ifndef CLR_MAX
#define CLR_MAX 16 #define CLR_MAX 16
#endif #endif
int ttycolors[CLR_MAX]; int ttycolors[CLR_MAX];
int ttycolors_inv[CLR_MAX]; int ttycolors_inv[CLR_MAX];
#define MAX_OVERRIDES 256 #define MAX_OVERRIDES 256
unsigned char key_overrides[MAX_OVERRIDES]; unsigned char key_overrides[MAX_OVERRIDES];
static char nullstr[] = ""; static char nullstr[] = "";
@@ -158,7 +158,7 @@ gettty()
init_ttycolor(); init_ttycolor();
#else #else
for (k = 0; k < CLR_MAX; ++k) for (k = 0; k < CLR_MAX; ++k)
ttycolors[k] = 7; ttycolors[k] = NO_COLOR;
#endif #endif
} }
@@ -692,6 +692,7 @@ tty_delay_output()
static void static void
init_ttycolor() init_ttycolor()
{ {
#ifdef TEXTCOLOR
ttycolors[CLR_BLACK] = FOREGROUND_INTENSITY; /* fix by Quietust */ ttycolors[CLR_BLACK] = FOREGROUND_INTENSITY; /* fix by Quietust */
ttycolors[CLR_RED] = FOREGROUND_RED; ttycolors[CLR_RED] = FOREGROUND_RED;
ttycolors[CLR_GREEN] = FOREGROUND_GREEN; ttycolors[CLR_GREEN] = FOREGROUND_GREEN;
@@ -728,6 +729,15 @@ init_ttycolor()
ttycolors_inv[CLR_BRIGHT_CYAN] = BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY; ttycolors_inv[CLR_BRIGHT_CYAN] = BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY;
ttycolors_inv[CLR_WHITE] = BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED ttycolors_inv[CLR_WHITE] = BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED
| BACKGROUND_INTENSITY; | BACKGROUND_INTENSITY;
#else
int k;
ttycolors[0] = FOREGROUND_INTENSITY;
ttycolors_inv[0] = BACKGROUND_INTENSITY;
for (k = 1; k < SIZE(ttycolors); ++k) {
ttycolors[k] = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED;
ttycolors_inv[k] = BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED;
}
#endif
init_ttycolor_completed = TRUE; init_ttycolor_completed = TRUE;
} }
#endif /* TEXTCOLOR */ #endif /* TEXTCOLOR */
@@ -739,7 +749,7 @@ has_color(int color)
if ((color >= 0) && (color < CLR_MAX)) if ((color >= 0) && (color < CLR_MAX))
return 1; return 1;
#else #else
if ((color == CLR_BLACK) || (color == CLR_WHITE)) if ((color == CLR_BLACK) || (color == CLR_WHITE) || (color == NO_COLOR))
return 1; return 1;
#endif #endif
else else
@@ -794,7 +804,7 @@ term_start_color(int color)
console.current_nhcolor = color; console.current_nhcolor = color;
} else } else
#endif #endif
console.current_nhcolor = color; console.current_nhcolor = NO_COLOR;
} }
void void
+4 -7
View File
@@ -1501,14 +1501,11 @@ static const char *build_opts[] = {
#ifdef SHELL #ifdef SHELL
"shell command", "shell command",
#endif #endif
#ifdef STATUS_VIA_WINDOWPORT
# ifdef STATUS_HILITES
"status via windowport with highlighting",
# else
"status via windowport without highlighting",
# endif
#else
"traditional status display", "traditional status display",
#ifdef STATUS_HILITES
"status via windowport with highlighting",
#else
"status via windowport without highlighting",
#endif #endif
#ifdef SUSPEND #ifdef SUSPEND
"suspend command", "suspend command",
+1 -5
View File
@@ -5286,15 +5286,11 @@ struct window_procs Qt_procs = {
genl_preference_update, genl_preference_update,
genl_getmsghistory, genl_getmsghistory,
genl_putmsghistory, genl_putmsghistory,
#ifdef STATUS_VIA_WINDOWPORT
genl_status_init, genl_status_init,
genl_status_finish, genl_status_finish,
genl_status_enablefield, genl_status_enablefield,
genl_status_update, genl_status_update,
# ifdef STATUS_HILITES genl_can_suspend_yes,
genl_status_threshold,
# endif
#endif
}; };
extern "C" void play_usersound(const char* filename, int volume) extern "C" void play_usersound(const char* filename, int volume)
-5
View File
@@ -125,13 +125,8 @@ struct window_procs X11_procs = {
genl_outrip, genl_outrip,
#endif #endif
X11_preference_update, genl_getmsghistory, genl_putmsghistory, X11_preference_update, genl_getmsghistory, genl_putmsghistory,
#ifdef STATUS_VIA_WINDOWPORT
genl_status_init, genl_status_finish, genl_status_enablefield, genl_status_init, genl_status_finish, genl_status_enablefield,
genl_status_update, genl_status_update,
#ifdef STATUS_HILITES
genl_status_threshold,
#endif
#endif
genl_can_suspend_no, /* XXX may not always be correct */ genl_can_suspend_no, /* XXX may not always be correct */
}; };
+4 -24
View File
@@ -462,7 +462,6 @@ boolean is_restoring;
(*cibase->nprocs->win_putmsghistory)(cibase->ndata, msg, is_restoring); (*cibase->nprocs->win_putmsghistory)(cibase->ndata, msg, is_restoring);
} }
#ifdef STATUS_VIA_WINDOWPORT
void void
chainin_status_init() chainin_status_init()
{ {
@@ -487,29 +486,15 @@ boolean enable;
} }
void void
chainin_status_update(idx, ptr, chg, percent) chainin_status_update(idx, ptr, chg, percent, color, colormasks)
int idx, chg, percent; int idx, chg, percent, color;
genericptr_t ptr; genericptr_t ptr;
unsigned long *colormasks;
{ {
(*cibase->nprocs->win_status_update)(cibase->ndata, idx, ptr, chg, (*cibase->nprocs->win_status_update)(cibase->ndata, idx, ptr, chg,
percent); percent, color, colormasks);
} }
#ifdef STATUS_HILITES
void
chainin_status_threshold(fldidx, thresholdtype, threshold, behavior, under,
over)
int fldidx, thresholdtype;
int behavior, under, over;
anything threshold;
{
(*cibase->nprocs->win_status_threshold)(cibase->ndata, fldidx,
thresholdtype, threshold,
behavior, under, over);
}
#endif
#endif
boolean boolean
chainin_can_suspend() chainin_can_suspend()
{ {
@@ -561,12 +546,7 @@ struct window_procs chainin_procs = {
chainin_outrip, chainin_preference_update, chainin_getmsghistory, chainin_outrip, chainin_preference_update, chainin_getmsghistory,
chainin_putmsghistory, chainin_putmsghistory,
#ifdef STATUS_VIA_WINDOWPORT
chainin_status_init, chainin_status_finish, chainin_status_enablefield, chainin_status_init, chainin_status_finish, chainin_status_enablefield,
chainin_status_update, chainin_status_update,
#ifdef STATUS_HILITES
chainin_status_threshold,
#endif
#endif
chainin_can_suspend, chainin_can_suspend,
}; };
+3 -25
View File
@@ -586,7 +586,6 @@ boolean is_restoring;
(*tdp->nprocs->win_putmsghistory)(msg, is_restoring); (*tdp->nprocs->win_putmsghistory)(msg, is_restoring);
} }
#ifdef STATUS_VIA_WINDOWPORT
void void
chainout_status_init(vp) chainout_status_init(vp)
void *vp; void *vp;
@@ -619,33 +618,17 @@ boolean enable;
} }
void void
chainout_status_update(vp, idx, ptr, chg, percent) chainout_status_update(vp, idx, ptr, chg, percent, color, colormasks)
void *vp; void *vp;
int idx, chg, percent; int idx, chg, percent;
genericptr_t ptr; genericptr_t ptr;
unsigned long *colormasks;
{ {
struct chainout_data *tdp = vp; struct chainout_data *tdp = vp;
(*tdp->nprocs->win_status_update)(idx, ptr, chg, percent); (*tdp->nprocs->win_status_update)(idx, ptr, chg, percent, color, colormasks);
} }
#ifdef STATUS_HILITES
void
chainout_status_threshold(vp, fldidx, thresholdtype, threshold, behavior,
under, over)
void *vp;
int fldidx, thresholdtype;
int behavior, under, over;
anything threshold;
{
struct chainout_data *tdp = vp;
(*tdp->nprocs->win_status_threshold)(fldidx, thresholdtype, threshold,
behavior, under, over);
}
#endif
#endif
boolean boolean
chainout_can_suspend(vp) chainout_can_suspend(vp)
void *vp; void *vp;
@@ -700,12 +683,7 @@ struct chain_procs chainout_procs = {
chainout_outrip, chainout_preference_update, chainout_getmsghistory, chainout_outrip, chainout_preference_update, chainout_getmsghistory,
chainout_putmsghistory, chainout_putmsghistory,
#ifdef STATUS_VIA_WINDOWPORT
chainout_status_init, chainout_status_finish, chainout_status_enablefield, chainout_status_init, chainout_status_finish, chainout_status_enablefield,
chainout_status_update, chainout_status_update,
#ifdef STATUS_HILITES
chainout_status_threshold,
#endif
#endif
chainout_can_suspend, chainout_can_suspend,
}; };
+3 -31
View File
@@ -1027,7 +1027,6 @@ boolean is_restoring;
POST; POST;
} }
#ifdef STATUS_VIA_WINDOWPORT
void void
trace_status_init(vp) trace_status_init(vp)
void *vp; void *vp;
@@ -1084,10 +1083,11 @@ boolean enable;
} }
void void
trace_status_update(vp, idx, ptr, chg, percent) trace_status_update(vp, idx, ptr, chg, color, colormasks)
void *vp; void *vp;
int idx, chg, percent; int idx, chg, percent;
genericptr_t ptr; genericptr_t ptr;
unsigned long *colormasks;
{ {
struct trace_data *tdp = vp; struct trace_data *tdp = vp;
@@ -1095,33 +1095,10 @@ genericptr_t ptr;
ptr, chg, percent); ptr, chg, percent);
PRE; PRE;
(*tdp->nprocs->win_status_update)(tdp->ndata, idx, ptr, chg, percent); (*tdp->nprocs->win_status_update)(tdp->ndata, idx, ptr, chg, color colormasks);
POST; POST;
} }
#ifdef STATUS_HILITES
void
trace_status_threshold(vp, fldidx, thresholdtype, threshold, behavior, under,
over)
void *vp;
int fldidx, thresholdtype;
int behavior, under, over;
anything threshold;
{
struct trace_data *tdp = vp;
/* XXX how do we print an anything? We don't. */
fprintf(wc_tracelogf, "%sstatus_threshold(%d, %d, -, %d, %d, %d)\n",
INDENT, fldidx, thresholdtype, behavior, under, over);
PRE;
(*tdp->nprocs->win_status_threshold)(tdp->ndata, fldidx, thresholdtype,
threshold, behavior, under, over);
POST;
}
#endif
#endif
boolean boolean
trace_can_suspend(vp) trace_can_suspend(vp)
void *vp; void *vp;
@@ -1179,12 +1156,7 @@ struct chain_procs trace_procs = {
trace_outrip, trace_preference_update, trace_getmsghistory, trace_outrip, trace_preference_update, trace_getmsghistory,
trace_putmsghistory, trace_putmsghistory,
#ifdef STATUS_VIA_WINDOWPORT
trace_status_init, trace_status_finish, trace_status_enablefield, trace_status_init, trace_status_finish, trace_status_enablefield,
trace_status_update, trace_status_update,
#ifdef STATUS_HILITES
trace_status_threshold,
#endif
#endif
trace_can_suspend, trace_can_suspend,
}; };
-5
View File
@@ -70,13 +70,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_end_screen, Gem_outrip, Gem_preference_update, Gem_start_screen, Gem_end_screen, Gem_outrip, Gem_preference_update,
genl_getmsghistory, genl_putmsghistory genl_getmsghistory, genl_putmsghistory
#ifdef STATUS_VIA_WINDOWPORT
genl_status_init, genl_status_init,
genl_status_finish, genl_status_enablefield, genl_status_update, genl_status_finish, genl_status_enablefield, genl_status_update,
#ifdef STATUS_HILITES
genl_status_threshold,
#endif
#endif
genl_can_suspend_no, genl_can_suspend_no,
}; };
-5
View File
@@ -48,13 +48,8 @@ struct window_procs Gnome_procs = {
/* other defs that really should go away (they're tty specific) */ /* other defs that really should go away (they're tty specific) */
gnome_start_screen, gnome_end_screen, gnome_outrip, gnome_start_screen, gnome_end_screen, gnome_outrip,
genl_preference_update, genl_getmsghistory, genl_putmsghistory, genl_preference_update, genl_getmsghistory, genl_putmsghistory,
#ifdef STATUS_VIA_WINDOWPORT
genl_status_init, genl_status_finish, genl_status_enablefield, genl_status_init, genl_status_finish, genl_status_enablefield,
genl_status_update, genl_status_update,
#ifdef STATUS_HILITES
genl_status_threshold,
#endif
#endif
genl_can_suspend_yes, genl_can_suspend_yes,
}; };
+296 -264
View File
@@ -62,6 +62,9 @@ struct window_procs tty_procs = {
WC_COLOR | WC_HILITE_PET | WC_INVERSE | WC_EIGHT_BIT_IN, WC_COLOR | WC_HILITE_PET | WC_INVERSE | WC_EIGHT_BIT_IN,
#if defined(SELECTSAVED) #if defined(SELECTSAVED)
WC2_SELECTSAVED | WC2_SELECTSAVED |
#endif
#if defined(STATUS_HILITES)
WC2_HITPOINTBAR | WC2_FLUSH_STATUS |
#endif #endif
WC2_DARKGRAY, WC2_DARKGRAY,
tty_init_nhwindows, tty_player_selection, tty_askname, tty_get_nh_event, tty_init_nhwindows, tty_player_selection, tty_askname, tty_get_nh_event,
@@ -96,13 +99,12 @@ struct window_procs tty_procs = {
genl_preference_update, genl_preference_update,
#endif #endif
tty_getmsghistory, tty_putmsghistory, tty_getmsghistory, tty_putmsghistory,
#ifdef STATUS_VIA_WINDOWPORT
tty_status_init, tty_status_init,
genl_status_finish, genl_status_enablefield, genl_status_finish, genl_status_enablefield,
tty_status_update,
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
tty_status_threshold, tty_status_update,
#endif #else
genl_status_update,
#endif #endif
genl_can_suspend_yes, genl_can_suspend_yes,
}; };
@@ -1293,9 +1295,7 @@ const char *str;
} }
} }
WIN_MAP = WIN_MESSAGE = WIN_INVEN = WIN_ERR; /* these are all gone now */ WIN_MAP = WIN_MESSAGE = WIN_INVEN = WIN_ERR; /* these are all gone now */
#ifndef STATUS_VIA_WINDOWPORT
WIN_STATUS = WIN_ERR; WIN_STATUS = WIN_ERR;
#endif
#ifdef FREE_ALL_MEMORY #ifdef FREE_ALL_MEMORY
if (BASE_WINDOW != WIN_ERR && wins[BASE_WINDOW]) { if (BASE_WINDOW != WIN_ERR && wins[BASE_WINDOW]) {
free_window_info(wins[BASE_WINDOW], TRUE); free_window_info(wins[BASE_WINDOW], TRUE);
@@ -2527,7 +2527,16 @@ const char *str;
} }
break; break;
} }
#ifdef STATUS_HILITES
/* Don't optimize the putsym away, in case it happens
to be the same character but different color/attr.
We don't optimize on iflags.use_status_hilites either,
in case old chars were written with highlighting and
that option has just now been toggled off. [We could
do better by tracking color/attr more closely.] */
#else
if (*ob != *nb) if (*ob != *nb)
#endif
tty_putsym(WIN_STATUS, i, cw->cury, *nb); tty_putsym(WIN_STATUS, i, cw->cury, *nb);
if (*ob) if (*ob)
ob++; ob++;
@@ -2535,13 +2544,9 @@ const char *str;
(void) strncpy(&cw->data[cw->cury][j], str, cw->cols - j - 1); (void) strncpy(&cw->data[cw->cury][j], str, cw->cols - j - 1);
cw->data[cw->cury][cw->cols - 1] = '\0'; /* null terminate */ cw->data[cw->cury][cw->cols - 1] = '\0'; /* null terminate */
#ifdef STATUS_VIA_WINDOWPORT #ifndef STATUS_HILITES
if (!iflags.use_status_hilites) { cw->cury = (cw->cury + 1) % 2;
#endif cw->curx = 0;
cw->cury = (cw->cury + 1) % 2;
cw->curx = 0;
#ifdef STATUS_VIA_WINDOWPORT
}
#endif #endif
break; break;
case NHW_MAP: case NHW_MAP:
@@ -3402,40 +3407,26 @@ char *posbar;
} }
#endif #endif
#ifdef STATUS_VIA_WINDOWPORT
/* /*
* The following data structures come from the genl_ routines in * The following data structures come from the genl_ routines in
* src/windows.c and as such are considered to be on the window-port * src/windows.c and as such are considered to be on the window-port
* "side" of things, rather than the NetHack-core "side" of things. * "side" of things, rather than the NetHack-core "side" of things.
*/ */
extern const char *status_fieldnm[MAXBLSTATS];
extern const char *status_fieldfmt[MAXBLSTATS]; extern const char *status_fieldfmt[MAXBLSTATS];
extern char *status_vals[MAXBLSTATS]; extern char *status_vals[MAXBLSTATS];
extern boolean status_activefields[MAXBLSTATS]; extern boolean status_activefields[MAXBLSTATS];
extern winid WIN_STATUS; extern winid WIN_STATUS;
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
typedef struct hilite_data_struct { static long tty_condition_bits;
int thresholdtype;
anything threshold;
int behavior;
int under;
int over;
} hilite_data_t;
static hilite_data_t tty_status_hilites[MAXBLSTATS];
static int tty_status_colors[MAXBLSTATS]; static int tty_status_colors[MAXBLSTATS];
int hpbar_percent, hpbar_color;
#endif /* STATUS_HILITES */
struct color_option { static int FDECL(condcolor, (long, unsigned long *));
int color; static int FDECL(condattr, (long, unsigned long *));
int attr_bits;
};
static void FDECL(start_color_option, (struct color_option));
static void FDECL(end_color_option, (struct color_option));
static void FDECL(apply_color_option, (struct color_option, const char *));
static void FDECL(add_colored_text, (const char *, char *));
#endif
void void
tty_status_init() tty_status_init()
@@ -3445,15 +3436,11 @@ tty_status_init()
/* let genl_status_init do most of the initialization */ /* let genl_status_init do most of the initialization */
genl_status_init(); genl_status_init();
for (i = 0; i < MAXBLSTATS; ++i) {
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
for (i = 0; i < MAXBLSTATS; ++i) {
tty_status_colors[i] = NO_COLOR; /* no color */ tty_status_colors[i] = NO_COLOR; /* no color */
tty_status_hilites[i].thresholdtype = 0;
tty_status_hilites[i].behavior = BL_TH_NONE;
tty_status_hilites[i].under = BL_HILITE_NONE;
tty_status_hilites[i].over = BL_HILITE_NONE;
#endif /* STATUS_HILITES */
} }
#endif /* STATUS_HILITES */
} }
/* /*
@@ -3490,22 +3477,102 @@ tty_status_init()
* symbol for GOLD "\GXXXXNNNN:nnn". If the window port needs to use * symbol for GOLD "\GXXXXNNNN:nnn". If the window port needs to use
* the textual gold amount without the leading "$:" the port will * the textual gold amount without the leading "$:" the port will
* have to skip past ':' in the passed "ptr" for the BL_GOLD case. * have to skip past ':' in the passed "ptr" for the BL_GOLD case.
* -- color is an unsigned int.
* color_index = color & 0x00FF; CLR_* value
* attribute = color & 0xFF00 >> 8; BL_* values
* This holds the color and attribute that the field should
* be displayed in.
* This is relevant for everything except BL_CONDITION fldindex.
* If fldindex is BL_CONDITION, this parameter should be ignored,
* as condition hilighting is done via the next colormasks
* parameter instead.
*
* -- colormasks - pointer to cond_hilites[] array of colormasks.
* Only relevant for BL_CONDITION fldindex. The window port
* should ignore this parameter for other fldindex values.
* Each condition bit must only ever appear in one of the
* CLR_ array members, but can appear in multiple HL_ATTCLR_
* offsets (because more than one attribute can co-exist).
* See doc/window.doc for more details.
*/ */
/* new approach through status_update() only */
#define Begin_Attr(m) \
if (m) { \
if ((m) & HL_BOLD) \
term_start_attr(ATR_BOLD); \
if ((m) & HL_INVERSE) \
term_start_attr(ATR_INVERSE); \
if ((m) & HL_ULINE) \
term_start_attr(ATR_ULINE); \
if ((m) & HL_BLINK) \
term_start_attr(ATR_BLINK); \
if ((m) & HL_DIM) \
term_start_attr(ATR_DIM); \
}
#define End_Attr(m) \
if (m) { \
if ((m) & HL_DIM) \
term_end_attr(ATR_DIM); \
if ((m) & HL_BLINK) \
term_end_attr(ATR_BLINK); \
if ((m) & HL_ULINE) \
term_end_attr(ATR_ULINE); \
if ((m) & HL_INVERSE) \
term_end_attr(ATR_INVERSE); \
if ((m) & HL_BOLD) \
term_end_attr(ATR_BOLD); \
}
#ifdef STATUS_HILITES
#ifdef TEXTCOLOR
#define MaybeDisplayCond(bm,txt) \
if (tty_condition_bits & (bm)) { \
putstr(WIN_STATUS, 0, " "); \
if (iflags.hilite_delta) { \
attrmask = condattr(bm, colormasks); \
Begin_Attr(attrmask); \
if ((coloridx = condcolor(bm, colormasks)) != NO_COLOR) \
term_start_color(coloridx); \
} \
putstr(WIN_STATUS, 0, txt); \
if (iflags.hilite_delta) { \
if (coloridx != NO_COLOR) \
term_end_color(); \
End_Attr(attrmask); \
} \
}
#else
#define MaybeDisplayCond(bm,txt) \
if (tty_condition_bits & (bm)) { \
putstr(WIN_STATUS, 0, " "); \
if (iflags.hilite_delta) { \
attrmask = condattr(bm, colormasks); \
Begin_Attr(attrmask); \
} \
putstr(WIN_STATUS, 0, txt); \
if (iflags.hilite_delta) { \
End_Attr(attrmask); \
} \
}
#endif
void void
tty_status_update(fldidx, ptr, chg, percent) tty_status_update(fldidx, ptr, chg, percent, color, colormasks)
int fldidx, chg, percent; int fldidx, chg UNUSED, percent UNUSED, color;
genericptr_t ptr; genericptr_t ptr;
unsigned long *colormasks;
{ {
long cond, *condptr = (long *) ptr; long *condptr = (long *) ptr;
register int i; int i, attrmask = 0;
#ifdef TEXTCOLOR
int coloridx = NO_COLOR;
#endif
char *text = (char *) ptr; char *text = (char *) ptr;
/* Mapping BL attributes to tty attributes static boolean oncearound = FALSE; /* prevent premature partial status display */
* BL_HILITE_NONE -1 + 3 = 2 (statusattr[2])
* BL_HILITE_INVERSE -2 + 3 = 1 (statusattr[1])
* BL_HILITE_BOLD -3 + 3 = 0 (statusattr[0])
*/
long value = -1L;
static boolean beenhere = FALSE;
enum statusfields fieldorder[2][15] = { enum statusfields fieldorder[2][15] = {
{ BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, BL_ALIGN, { BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, BL_ALIGN,
BL_SCORE, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_SCORE, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH,
@@ -3514,175 +3581,118 @@ genericptr_t ptr;
BL_AC, BL_XP, BL_EXP, BL_HD, BL_TIME, BL_HUNGER, BL_AC, BL_XP, BL_EXP, BL_HD, BL_TIME, BL_HUNGER,
BL_CAP, BL_CONDITION, BL_FLUSH } BL_CAP, BL_CONDITION, BL_FLUSH }
}; };
#ifdef STATUS_HILITES
static int statusattr[] = { ATR_BOLD, ATR_INVERSE, ATR_NONE };
int attridx = 0; int attridx = 0;
#else
nhUse(chg);
nhUse(percent);
#endif
if (fldidx != BL_FLUSH) { if (fldidx != BL_FLUSH) {
if (!status_activefields[fldidx]) if (!status_activefields[fldidx])
return; return;
switch (fldidx) { switch (fldidx) {
case BL_CONDITION: case BL_CONDITION:
cond = *condptr; tty_condition_bits = *condptr;
*status_vals[fldidx] = '\0'; oncearound = TRUE;
if (cond & BL_MASK_STONE)
Strcat(status_vals[fldidx], " Stone");
if (cond & BL_MASK_SLIME)
Strcat(status_vals[fldidx], " Slime");
if (cond & BL_MASK_STRNGL)
Strcat(status_vals[fldidx], " Strngl");
if (cond & BL_MASK_FOODPOIS)
Strcat(status_vals[fldidx], " FoodPois");
if (cond & BL_MASK_TERMILL)
Strcat(status_vals[fldidx], " TermIll");
if (cond & BL_MASK_BLIND)
Strcat(status_vals[fldidx], " Blind");
if (cond & BL_MASK_DEAF)
Strcat(status_vals[fldidx], " Deaf");
if (cond & BL_MASK_STUN)
Strcat(status_vals[fldidx], " Stun");
if (cond & BL_MASK_CONF)
Strcat(status_vals[fldidx], " Conf");
if (cond & BL_MASK_HALLU)
Strcat(status_vals[fldidx], " Hallu");
if (cond & BL_MASK_LEV)
Strcat(status_vals[fldidx], " Lev");
if (cond & BL_MASK_FLY)
Strcat(status_vals[fldidx], " Fly");
if (cond & BL_MASK_RIDE)
Strcat(status_vals[fldidx], " Ride");
value = cond;
break; break;
default: default:
value = atol(text);
Sprintf(status_vals[fldidx], Sprintf(status_vals[fldidx],
(fldidx == BL_TITLE && iflags.wc2_hitpointbar) ? "%-30s" :
status_fieldfmt[fldidx] ? status_fieldfmt[fldidx] : "%s", status_fieldfmt[fldidx] ? status_fieldfmt[fldidx] : "%s",
text); text);
break; #ifdef TEXTCOLOR
} tty_status_colors[fldidx] = color;
#else
#ifdef STATUS_HILITES
switch (tty_status_hilites[fldidx].behavior) {
case BL_TH_NONE:
tty_status_colors[fldidx] = NO_COLOR; tty_status_colors[fldidx] = NO_COLOR;
break; #endif
case BL_TH_UPDOWN: if (iflags.wc2_hitpointbar && fldidx == BL_HP) {
if (chg > 0) hpbar_percent = percent;
tty_status_colors[fldidx] = tty_status_hilites[fldidx].over; #ifdef TEXTCOLOR
else if (chg < 0) hpbar_color = color;
tty_status_colors[fldidx] = tty_status_hilites[fldidx].under; #else
else hpbar_color = NO_COLOR;
tty_status_colors[fldidx] = NO_COLOR; #endif
break;
case BL_TH_VAL_PERCENTAGE: {
int pct_th = 0;
if (tty_status_hilites[fldidx].thresholdtype != ANY_INT) {
impossible(
"tty_status_update: unsupported percentage threshold type %d",
tty_status_hilites[fldidx].thresholdtype);
} else {
pct_th = tty_status_hilites[fldidx].threshold.a_int;
tty_status_colors[fldidx] = (percent >= pct_th)
? tty_status_hilites[fldidx].over
: tty_status_hilites[fldidx].under;
} }
break; break;
} }
case BL_TH_VAL_ABSOLUTE: {
int c = NO_COLOR;
int o = tty_status_hilites[fldidx].over;
int u = tty_status_hilites[fldidx].under;
anything *t = &tty_status_hilites[fldidx].threshold;
switch (tty_status_hilites[fldidx].thresholdtype) {
case ANY_LONG:
c = (value >= t->a_long) ? o : u;
break;
case ANY_INT:
c = (value >= t->a_int) ? o : u;
break;
case ANY_UINT:
c = ((unsigned long) value >= t->a_uint) ? o : u;
break;
case ANY_ULONG:
c = ((unsigned long) value >= t->a_ulong) ? o : u;
break;
case ANY_MASK32:
c = (value & t->a_ulong) ? o : u;
break;
default:
impossible(
"tty_status_update: unsupported absolute threshold type %d\n",
tty_status_hilites[fldidx].thresholdtype);
break;
}
tty_status_colors[fldidx] = c;
break;
} /* case */
} /* switch */
#endif /* STATUS_HILITES */
} }
/* For now, this version copied from the genl_ version currently if (!oncearound) return;
* updates everything on the display, everytime
*/
if (!beenhere || !iflags.use_status_hilites) {
char newbot1[MAXCO], newbot2[MAXCO];
newbot1[0] = '\0';
for (i = 0; fieldorder[0][i] >= 0; ++i) {
int idx1 = fieldorder[0][i];
if (status_activefields[idx1])
Strcat(newbot1, status_vals[idx1]);
}
newbot2[0] = '\0';
for (i = 0; fieldorder[1][i] >= 0; ++i) {
int idx2 = fieldorder[1][i];
if (status_activefields[idx2])
Strcat(newbot2, status_vals[idx2]);
}
curs(WIN_STATUS, 1, 0);
putstr(WIN_STATUS, 0, newbot1);
curs(WIN_STATUS, 1, 1);
putmixed(WIN_STATUS, 0, newbot2); /* putmixed() due to GOLD glyph */
beenhere = TRUE;
return;
}
curs(WIN_STATUS, 1, 0); curs(WIN_STATUS, 1, 0);
for (i = 0; fieldorder[0][i] != BL_FLUSH; ++i) { for (i = 0; fieldorder[0][i] != BL_FLUSH; ++i) {
int fldidx1 = fieldorder[0][i]; int fldidx1 = fieldorder[0][i];
if (status_activefields[fldidx1]) { if (status_activefields[fldidx1]) {
#ifdef STATUS_HILITES if (fldidx1 != BL_TITLE || !iflags.wc2_hitpointbar) {
if (tty_status_colors[fldidx1] < 0
&& tty_status_colors[fldidx1] >= -3) {
/* attribute, not a color */
attridx = tty_status_colors[fldidx1] + 3;
term_start_attr(statusattr[attridx]);
putstr(WIN_STATUS, 0, status_vals[fldidx1]);
term_end_attr(statusattr[attridx]);
} else
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
if (tty_status_colors[fldidx1] != CLR_MAX) { coloridx = tty_status_colors[fldidx1] & 0x00FF;
if (tty_status_colors[fldidx1] != NO_COLOR)
term_start_color(tty_status_colors[fldidx1]);
putstr(WIN_STATUS, 0, status_vals[fldidx1]);
if (tty_status_colors[fldidx1] != NO_COLOR)
term_end_color();
} else
#endif #endif
#endif /* STATUS_HILITES */ attridx = (tty_status_colors[fldidx1] & 0xFF00) >> 8;
putstr(WIN_STATUS, 0, status_vals[fldidx1]); text = status_vals[fldidx1];
if (iflags.hilite_delta) {
if (*text == ' ') {
putstr(WIN_STATUS, 0, " ");
text++;
}
/* multiple attributes can be in effect concurrently */
Begin_Attr(attridx);
#ifdef TEXTCOLOR
if (coloridx != NO_COLOR && coloridx != CLR_MAX)
term_start_color(coloridx);
#endif
}
putstr(WIN_STATUS, 0, text);
if (iflags.hilite_delta) {
#ifdef TEXTCOLOR
if (coloridx != NO_COLOR)
term_end_color();
#endif
End_Attr(attridx);
}
} else {
/* hitpointbar using hp percent calculation */
int bar_pos, bar_len;
char *bar2 = (char *)0;
char bar[MAXCO], savedch;
boolean twoparts = FALSE;
text = status_vals[fldidx1];
bar_len = strlen(text);
if (bar_len < MAXCO-1) {
Strcpy(bar, text);
bar_pos = (bar_len * hpbar_percent) / 100;
if (bar_pos < 1 && hpbar_percent > 0)
bar_pos = 1;
if (bar_pos >= bar_len && hpbar_percent < 100)
bar_pos = bar_len - 1;
if (bar_pos > 0 && bar_pos < bar_len) {
twoparts = TRUE;
bar2 = &bar[bar_pos];
savedch = *bar2;
*bar2 = '\0';
}
}
if (iflags.hilite_delta && iflags.wc2_hitpointbar) {
putstr(WIN_STATUS, 0, "[");
#ifdef TEXTCOLOR
coloridx = hpbar_color & 0x00FF;
/* attridx = (hpbar_color & 0xFF00) >> 8; */
if (coloridx != NO_COLOR)
term_start_color(coloridx);
#endif
term_start_attr(ATR_INVERSE);
putstr(WIN_STATUS, 0, bar);
term_end_attr(ATR_INVERSE);
#ifdef TEXTCOLOR
if (coloridx != NO_COLOR)
term_end_color();
#endif
if (twoparts) {
*bar2 = savedch;
putstr(WIN_STATUS, 0, bar2);
}
putstr(WIN_STATUS, 0, "]");
} else
putstr(WIN_STATUS, 0, text);
}
} }
} }
curs(WIN_STATUS, 1, 1); curs(WIN_STATUS, 1, 1);
@@ -3690,93 +3700,115 @@ genericptr_t ptr;
int fldidx2 = fieldorder[1][i]; int fldidx2 = fieldorder[1][i];
if (status_activefields[fldidx2]) { if (status_activefields[fldidx2]) {
#ifdef STATUS_HILITES if (fldidx2 != BL_CONDITION) {
if (tty_status_colors[fldidx2] < 0
&& tty_status_colors[fldidx2] >= -3) {
/* attribute, not a color */
attridx = tty_status_colors[fldidx2] + 3;
term_start_attr(statusattr[attridx]);
putstr(WIN_STATUS, 0, status_vals[fldidx2]);
term_end_attr(statusattr[attridx]);
} else
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
if (tty_status_colors[fldidx2] != CLR_MAX) { coloridx = tty_status_colors[fldidx2] & 0x00FF;
if (tty_status_colors[fldidx2] != NO_COLOR) #endif
term_start_color(tty_status_colors[fldidx2]); attridx = (tty_status_colors[fldidx2] & 0xFF00) >> 8;
text = status_vals[fldidx2];
if (iflags.hilite_delta) {
if (*text == ' ') {
putstr(WIN_STATUS, 0, " ");
text++;
}
/* multiple attributes can be in effect concurrently */
Begin_Attr(attridx);
#ifdef TEXTCOLOR
if (coloridx != NO_COLOR && coloridx != CLR_MAX)
term_start_color(coloridx);
#endif
}
if (fldidx2 == BL_GOLD) { if (fldidx2 == BL_GOLD) {
/* putmixed() due to GOLD glyph */ /* putmixed() due to GOLD glyph */
putmixed(WIN_STATUS, 0, status_vals[fldidx2]); putmixed(WIN_STATUS, 0, text);
} else { } else {
putstr(WIN_STATUS, 0, status_vals[fldidx2]); putstr(WIN_STATUS, 0, text);
} }
if (tty_status_colors[fldidx2] != NO_COLOR)
term_end_color(); if (iflags.hilite_delta) {
} else #ifdef TEXTCOLOR
if (coloridx != NO_COLOR)
term_end_color();
#endif #endif
#endif /* STATUS_HILITES */ End_Attr(attridx);
putstr(WIN_STATUS, 0, status_vals[fldidx2]); }
} else {
MaybeDisplayCond(BL_MASK_STONE, "Stone");
MaybeDisplayCond(BL_MASK_SLIME, "Slime");
MaybeDisplayCond(BL_MASK_STRNGL, "Strngl");
MaybeDisplayCond(BL_MASK_FOODPOIS, "FoodPois");
MaybeDisplayCond(BL_MASK_TERMILL, "TermIll");
MaybeDisplayCond(BL_MASK_BLIND, "Blind");
MaybeDisplayCond(BL_MASK_DEAF, "Deaf");
MaybeDisplayCond(BL_MASK_STUN, "Stun");
MaybeDisplayCond(BL_MASK_CONF, "Conf");
MaybeDisplayCond(BL_MASK_HALLU, "Hallu");
MaybeDisplayCond(BL_MASK_LEV, "Lev");
MaybeDisplayCond(BL_MASK_FLY, "Fly");
MaybeDisplayCond(BL_MASK_RIDE, "Ride");
}
} }
} }
return; return;
} }
#ifdef STATUS_HILITES #ifdef TEXTCOLOR
/* /*
* status_threshold(int fldidx, int threshholdtype, anything threshold, * Return what color this condition should
* int behavior, int under, int over) * be displayed in based on user settings.
*
* -- called when a hiliting preference is added, changed, or
* removed.
* -- the fldindex identifies which field is having its hiliting
* preference set. It is an integer index value from botl.h
* -- fldindex could be any one of the following from botl.h:
* BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH,
* BL_ALIGN, BL_SCORE, BL_CAP, BL_GOLD, BL_ENE, BL_ENEMAX,
* BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, BL_HPMAX,
* BL_LEVELDESC, BL_EXP, BL_CONDITION
* -- datatype is P_INT, P_UINT, P_LONG, or P_MASK.
* -- threshold is an "anything" union which can contain the
* datatype value.
* -- behavior is used to define how threshold is used and can
* be BL_TH_NONE, BL_TH_VAL_PERCENTAGE, BL_TH_VAL_ABSOLUTE,
* or BL_TH_UPDOWN. BL_TH_NONE means don't do anything above
* or below the threshold. BL_TH_VAL_PERCENTAGE treats the
* threshold value as a precentage of the maximum possible
* value. BL_TH_VAL_ABSOLUTE means that the threshold is an
* actual value. BL_TH_UPDOWN means that threshold is not
* used, and the two below/above hilite values indicate how
* to display something going down (under) or rising (over).
* -- under is the hilite attribute used if value is below the
* threshold. The attribute can be BL_HILITE_NONE,
* BL_HILITE_INVERSE, BL_HILITE_BOLD (-1, -2, or -3), or one
* of the color indexes of CLR_BLACK, CLR_RED, CLR_GREEN,
* CLR_BROWN, CLR_BLUE, CLR_MAGENTA, CLR_CYAN, CLR_GRAY,
* CLR_ORANGE, CLR_BRIGHT_GREEN, CLR_YELLOW, CLR_BRIGHT_BLUE,
* CLR_BRIGHT_MAGENTA, CLR_BRIGHT_CYAN, or CLR_WHITE (0 - 15).
* -- over is the hilite attribute used if value is at or above
* the threshold. The attribute can be BL_HILITE_NONE,
* BL_HILITE_INVERSE, BL_HILITE_BOLD (-1, -2, or -3), or one
* of the color indexes of CLR_BLACK, CLR_RED, CLR_GREEN,
* CLR_BROWN, CLR_BLUE, CLR_MAGENTA, CLR_CYAN, CLR_GRAY,
* CLR_ORANGE, CLR_BRIGHT_GREEN, CLR_YELLOW, CLR_BRIGHT_BLUE,
* CLR_BRIGHT_MAGENTA, CLR_BRIGHT_CYAN, or CLR_WHITE (0 - 15).
*/ */
void int condcolor(bm, bmarray)
tty_status_threshold(fldidx, thresholdtype, threshold, behavior, under, over) long bm;
int fldidx, thresholdtype; unsigned long *bmarray;
int behavior, under, over;
anything threshold;
{ {
tty_status_hilites[fldidx].thresholdtype = thresholdtype; #ifdef STATUS_HILITES
tty_status_hilites[fldidx].threshold = threshold; int i;
tty_status_hilites[fldidx].behavior = behavior;
tty_status_hilites[fldidx].under = under;
tty_status_hilites[fldidx].over = over;
return;
}
if (bm && bmarray)
for (i = 0; i < CLR_MAX; ++i) {
if (bmarray[i] && (bm & bmarray[i]))
return i;
}
#endif
return NO_COLOR;
}
#endif /* TEXTCOLOR */
int condattr(bm, bmarray)
long bm;
unsigned long *bmarray;
{
int attr = 0;
int i;
if (bm && bmarray) {
for (i = HL_ATTCLR_DIM; i < BL_ATTCLR_MAX; ++i) {
if (bmarray[i] && (bm & bmarray[i])) {
switch(i) {
case HL_ATTCLR_DIM:
attr |= HL_DIM;
break;
case HL_ATTCLR_BLINK:
attr |= HL_BLINK;
break;
case HL_ATTCLR_ULINE:
attr |= HL_ULINE;
break;
case HL_ATTCLR_INVERSE:
attr |= HL_INVERSE;
break;
case HL_ATTCLR_BOLD:
attr |= HL_BOLD;
break;
}
}
}
}
return attr;
}
#endif /* STATUS_HILITES */ #endif /* STATUS_HILITES */
#endif /*STATUS_VIA_WINDOWPORT*/
#endif /* TTY_GRAPHICS */ #endif /* TTY_GRAPHICS */
+1
View File
@@ -72,6 +72,7 @@ typedef struct mswin_nhmsg_update_status {
int n_fields; int n_fields;
const char **vals; const char **vals;
boolean *activefields; boolean *activefields;
int *percents;
int *colors; int *colors;
} MSNHMsgUpdateStatus, *PMSNHMsgUpdateStatus; } MSNHMsgUpdateStatus, *PMSNHMsgUpdateStatus;
+76 -35
View File
@@ -18,10 +18,10 @@ typedef struct mswin_nethack_status_window {
int n_fields; int n_fields;
const char **vals; const char **vals;
boolean *activefields; boolean *activefields;
int *percents;
int *colors; int *colors;
} NHStatusWindow, *PNHStatusWindow; } NHStatusWindow, *PNHStatusWindow;
#ifdef STATUS_VIA_WINDOWPORT
static int fieldorder1[] = { BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, static int fieldorder1[] = { BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN,
BL_WI, BL_CH, BL_ALIGN, BL_SCORE, -1 }; BL_WI, BL_CH, BL_ALIGN, BL_SCORE, -1 };
static int fieldorder2[] = { BL_LEVELDESC, BL_GOLD, BL_HP, BL_HPMAX, static int fieldorder2[] = { BL_LEVELDESC, BL_GOLD, BL_HP, BL_HPMAX,
@@ -29,7 +29,6 @@ static int fieldorder2[] = { BL_LEVELDESC, BL_GOLD, BL_HP, BL_HPMAX,
BL_EXP, BL_HD, BL_TIME, BL_HUNGER, BL_EXP, BL_HD, BL_TIME, BL_HUNGER,
BL_CAP, BL_CONDITION, -1 }; BL_CAP, BL_CONDITION, -1 };
static int *fieldorders[] = { fieldorder1, fieldorder2, NULL }; static int *fieldorders[] = { fieldorder1, fieldorder2, NULL };
#endif /* STATUS_VIA_WINDOWPORT */
static TCHAR szStatusWindowClass[] = TEXT("MSNHStatusWndClass"); static TCHAR szStatusWindowClass[] = TEXT("MSNHStatusWndClass");
LRESULT CALLBACK StatusWndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK StatusWndProc(HWND, UINT, WPARAM, LPARAM);
@@ -133,9 +132,10 @@ StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case MSNH_MSG_GETTEXT: { case MSNH_MSG_GETTEXT: {
PMSNHMsgGetText msg_data = (PMSNHMsgGetText) lParam; PMSNHMsgGetText msg_data = (PMSNHMsgGetText) lParam;
#ifdef STATUS_VIA_WINDOWPORT #ifdef STATUS_HILITES
int **fop; int **fop;
int *f; int *f;
msg_data->buffer[0] = '\0'; msg_data->buffer[0] = '\0';
if (data->n_fields > 0) { if (data->n_fields > 0) {
for (fop = fieldorders; *fop; fop++) { for (fop = fieldorders; *fop; fop++) {
@@ -143,20 +143,20 @@ StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (data->activefields[*f]) if (data->activefields[*f])
strncat(msg_data->buffer, data->vals[*f], strncat(msg_data->buffer, data->vals[*f],
msg_data->max_size msg_data->max_size
- strlen(msg_data->buffer)); - strlen(msg_data->buffer));
} }
strncat(msg_data->buffer, "\r\n", strncat(msg_data->buffer, "\r\n",
msg_data->max_size - strlen(msg_data->buffer)); msg_data->max_size - strlen(msg_data->buffer));
} }
} }
#else /* STATUS_VIA_WINDOWPORT */ #else
strncpy(msg_data->buffer, data->window_text[0], strncpy(msg_data->buffer, data->window_text[0],
msg_data->max_size); msg_data->max_size);
strncat(msg_data->buffer, "\r\n", strncat(msg_data->buffer, "\r\n",
msg_data->max_size - strlen(msg_data->buffer)); msg_data->max_size - strlen(msg_data->buffer));
strncat(msg_data->buffer, data->window_text[1], strncat(msg_data->buffer, data->window_text[1],
msg_data->max_size - strlen(msg_data->buffer)); msg_data->max_size - strlen(msg_data->buffer));
#endif /* STATUS_VIA_WINDOWPORT */ #endif
} break; } break;
case MSNH_MSG_UPDATE_STATUS: { case MSNH_MSG_UPDATE_STATUS: {
@@ -164,6 +164,7 @@ StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
data->n_fields = msg_data->n_fields; data->n_fields = msg_data->n_fields;
data->vals = msg_data->vals; data->vals = msg_data->vals;
data->activefields = msg_data->activefields; data->activefields = msg_data->activefields;
data->percents = msg_data->percents;
data->colors = msg_data->colors; data->colors = msg_data->colors;
InvalidateRect(hWnd, NULL, TRUE); InvalidateRect(hWnd, NULL, TRUE);
} break; } break;
@@ -206,10 +207,12 @@ StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return 0; return 0;
} }
#ifdef STATUS_VIA_WINDOWPORT #ifdef STATUS_HILITES
static LRESULT static LRESULT
onWMPaint(HWND hWnd, WPARAM wParam, LPARAM lParam) onWMPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
{ {
int hpbar_percent = 100;
int hpbar_color = NO_COLOR;
int *f; int *f;
int **fop; int **fop;
SIZE sz; SIZE sz;
@@ -238,45 +241,83 @@ onWMPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
: (COLORREF) GetSysColor(DEFAULT_COLOR_FG_STATUS); : (COLORREF) GetSysColor(DEFAULT_COLOR_FG_STATUS);
OldFg = SetTextColor(hdc, Fg); OldFg = SetTextColor(hdc, Fg);
if (iflags.wc2_hitpointbar && BL_HP < data->n_fields
&& data->activefields[BL_HP]) {
hpbar_percent = data->percents[BL_HP];
hpbar_color = data->colors[BL_HP] & 0x00ff;
}
for (fop = fieldorders; *fop; fop++) { for (fop = fieldorders; *fop; fop++) {
LONG left = rt.left; LONG left = rt.left;
LONG cy = 0; LONG cy = 0;
int vlen; int vlen;
for (f = *fop; *f != -1; f++) { for (f = *fop; *f != -1; f++) {
int clr, atr;
int fntatr = ATR_NONE;
HGDIOBJ fnt;
COLORREF nFg, nBg;
if (((*f) >= data->n_fields) || (!data->activefields[*f])) if (((*f) >= data->n_fields) || (!data->activefields[*f]))
continue; continue;
clr = data->colors[*f] & 0x00ff;
atr = (data->colors[*f] & 0xff00) >> 8;
vlen = strlen(data->vals[*f]); vlen = strlen(data->vals[*f]);
NH_A2W(data->vals[*f], wbuf, SIZE(wbuf)); NH_A2W(data->vals[*f], wbuf, SIZE(wbuf));
if (!iflags.use_status_hilites) { if (atr & HL_BOLD)
SelectObject(hdc, normalFont); fntatr = ATR_BOLD;
SetBkColor(hdc, Bg); else if (atr & HL_INVERSE)
SetTextColor(hdc, Fg); fntatr = ATR_INVERSE;
} else if (data->colors[*f] == CLR_MAX else if (atr & HL_ULINE)
|| data->colors[*f] == BL_HILITE_NONE) { fntatr = ATR_ULINE;
SelectObject(hdc, normalFont); else if (atr & HL_BLINK)
SetBkColor(hdc, Bg); fntatr = ATR_BLINK;
SetTextColor(hdc, Fg); else if (atr & HL_DIM)
} else if (data->colors[*f] > 0) { fntatr = ATR_DIM;
SelectObject(hdc, normalFont); fnt = mswin_get_font(NHW_STATUS, fntatr, hdc, FALSE);
SetBkColor(hdc, Bg); nFg = (clr >= 0 && clr < CLR_MAX) ? nhcolor_to_RGB(clr) : Fg;
SetTextColor(hdc, nhcolor_to_RGB(data->colors[*f])); nBg = Bg;
} else if (data->colors[*f] == BL_HILITE_INVERSE) {
SelectObject(hdc, normalFont);
SetBkColor(hdc, Fg);
SetTextColor(hdc, Bg);
} else if (data->colors[*f] == BL_HILITE_BOLD) {
SelectObject(hdc, boldFont);
SetBkColor(hdc, Bg);
SetTextColor(hdc, Fg);
} else {
SelectObject(hdc, normalFont);
SetBkColor(hdc, Bg);
SetTextColor(hdc, Fg);
}
GetTextExtentPoint32(hdc, wbuf, vlen, &sz); GetTextExtentPoint32(hdc, wbuf, vlen, &sz);
DrawText(hdc, wbuf, vlen, &rt, DT_LEFT); if (*f == BL_TITLE && iflags.wc2_hitpointbar) {
HBRUSH back_brush = CreateSolidBrush(nhcolor_to_RGB(hpbar_color));
RECT barrect;
/* first draw title normally */
SelectObject(hdc, fnt);
SetBkMode(hdc, OPAQUE);
SetBkColor(hdc, Bg);
SetTextColor(hdc, nhcolor_to_RGB(hpbar_color));
DrawText(hdc, wbuf, vlen, &rt, DT_LEFT);
/* calc bar length */
barrect.left = rt.left;
barrect.top = rt.top;
barrect.bottom = sz.cy;
if (hpbar_percent > 0)
barrect.right = (int)((hpbar_percent * sz.cx) / 100);
else
barrect.right = sz.cx;
/* then draw hpbar on top of title */
FillRect(hdc, &barrect, back_brush);
SetBkMode(hdc, TRANSPARENT);
SetTextColor(hdc, nBg);
DrawText(hdc, wbuf, vlen, &barrect, DT_LEFT);
DeleteObject(back_brush);
} else {
if (atr & HL_INVERSE) {
COLORREF tmp = nFg;
nFg = nBg;
nBg = tmp;
}
SelectObject(hdc, fnt);
SetBkMode(hdc, OPAQUE);
SetBkColor(hdc, nBg);
SetTextColor(hdc, nFg);
DrawText(hdc, wbuf, vlen, &rt, DT_LEFT);
}
rt.left += sz.cx; rt.left += sz.cx;
cy = max(cy, sz.cy); cy = max(cy, sz.cy);
@@ -336,7 +377,7 @@ onWMPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
return 0; return 0;
} }
#endif /*STATUS_VIA_WINDOWPORT*/ #endif /* !STATUS_HILITES */
void void
mswin_status_window_size(HWND hWnd, LPSIZE sz) mswin_status_window_size(HWND hWnd, LPSIZE sz)
+16 -126
View File
@@ -85,6 +85,9 @@ struct window_procs mswin_procs = {
| WC_FONTSIZ_TEXT | WC_TILE_WIDTH | WC_TILE_HEIGHT | WC_TILE_FILE | WC_FONTSIZ_TEXT | WC_TILE_WIDTH | WC_TILE_HEIGHT | WC_TILE_FILE
| WC_VARY_MSGCOUNT | WC_WINDOWCOLORS | WC_PLAYER_SELECTION | WC_VARY_MSGCOUNT | WC_WINDOWCOLORS | WC_PLAYER_SELECTION
| WC_SPLASH_SCREEN | WC_POPUP_DIALOG | WC_MOUSE_SUPPORT, | WC_SPLASH_SCREEN | WC_POPUP_DIALOG | WC_MOUSE_SUPPORT,
#ifdef STATUS_HILITES
WC2_HITPOINTBAR | WC2_FLUSH_STATUS |
#endif
0L, mswin_init_nhwindows, mswin_player_selection, mswin_askname, 0L, mswin_init_nhwindows, mswin_player_selection, mswin_askname,
mswin_get_nh_event, mswin_exit_nhwindows, mswin_suspend_nhwindows, mswin_get_nh_event, mswin_exit_nhwindows, mswin_suspend_nhwindows,
mswin_resume_nhwindows, mswin_create_nhwindow, mswin_clear_nhwindow, mswin_resume_nhwindows, mswin_create_nhwindow, mswin_clear_nhwindow,
@@ -108,13 +111,8 @@ struct window_procs mswin_procs = {
/* other defs that really should go away (they're tty specific) */ /* other defs that really should go away (they're tty specific) */
mswin_start_screen, mswin_end_screen, mswin_outrip, mswin_start_screen, mswin_end_screen, mswin_outrip,
mswin_preference_update, mswin_getmsghistory, mswin_putmsghistory, mswin_preference_update, mswin_getmsghistory, mswin_putmsghistory,
#ifdef STATUS_VIA_WINDOWPORT
mswin_status_init, mswin_status_finish, mswin_status_enablefield, mswin_status_init, mswin_status_finish, mswin_status_enablefield,
mswin_status_update, mswin_status_update,
#ifdef STATUS_HILITES
mswin_status_threshold,
#endif
#endif
genl_can_suspend_yes, genl_can_suspend_yes,
}; };
@@ -2713,18 +2711,18 @@ NHMessageBox(HWND hWnd, LPCTSTR text, UINT type)
return MessageBox(hWnd, text, title, type); return MessageBox(hWnd, text, title, type);
} }
#ifdef STATUS_VIA_WINDOWPORT
static const char *_status_fieldnm[MAXBLSTATS]; static const char *_status_fieldnm[MAXBLSTATS];
static const char *_status_fieldfmt[MAXBLSTATS]; static const char *_status_fieldfmt[MAXBLSTATS];
static char *_status_vals[MAXBLSTATS]; static char *_status_vals[MAXBLSTATS];
static int _status_colors[MAXBLSTATS]; static int _status_colors[MAXBLSTATS];
static int _status_percents[MAXBLSTATS];
static boolean _status_activefields[MAXBLSTATS]; static boolean _status_activefields[MAXBLSTATS];
extern winid WIN_STATUS; extern winid WIN_STATUS;
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
typedef struct hilite_data_struct { typedef struct hilite_data_struct {
int thresholdtype; int thresholdtype;
anything threshold; anything value;
int behavior; int behavior;
int under; int under;
int over; int over;
@@ -2747,6 +2745,7 @@ mswin_status_init(void)
_status_activefields[i] = FALSE; _status_activefields[i] = FALSE;
_status_fieldfmt[i] = (const char *) 0; _status_fieldfmt[i] = (const char *) 0;
_status_colors[i] = CLR_MAX; /* no color */ _status_colors[i] = CLR_MAX; /* no color */
_status_percents[i] = 0;
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
_status_hilites[i].thresholdtype = 0; _status_hilites[i].thresholdtype = 0;
_status_hilites[i].behavior = BL_TH_NONE; _status_hilites[i].behavior = BL_TH_NONE;
@@ -2804,64 +2803,9 @@ mswin_status_enablefield(int fieldidx, const char *nm, const char *fmt,
_status_activefields[fieldidx] = enable; _status_activefields[fieldidx] = enable;
} }
#ifdef STATUS_HILITES
/*
status_threshold(int fldidx, int threshholdtype, anything threshold,
int behavior, int under, int over)
-- called when a hiliting preference is added, changed, or
removed.
-- the fldindex identifies which field is having its hiliting
preference set. It is an integer index value from botl.h
-- fldindex could be any one of the following from botl.h:
BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH,
BL_ALIGN, BL_SCORE, BL_CAP, BL_GOLD, BL_ENE, BL_ENEMAX,
BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, BL_HPMAX,
BL_LEVELDESC, BL_EXP, BL_CONDITION
-- datatype is P_INT, P_UINT, P_LONG, or P_MASK.
-- threshold is an "anything" union which can contain the
datatype value.
-- behavior is used to define how threshold is used and can
be BL_TH_NONE, BL_TH_VAL_PERCENTAGE, BL_TH_VAL_ABSOLUTE,
or BL_TH_UPDOWN. BL_TH_NONE means don't do anything above
or below the threshold. BL_TH_VAL_PERCENTAGE treats the
threshold value as a precentage of the maximum possible
value. BL_TH_VAL_ABSOLUTE means that the threshold is an
actual value. BL_TH_UPDOWN means that threshold is not
used, and the two below/above hilite values indicate how
to display something going down (under) or rising (over).
-- under is the hilite attribute used if value is below the
threshold. The attribute can be BL_HILITE_NONE,
BL_HILITE_INVERSE, BL_HILITE_BOLD (-1, -2, or -3), or one
of the color indexes of CLR_BLACK, CLR_RED, CLR_GREEN,
CLR_BROWN, CLR_BLUE, CLR_MAGENTA, CLR_CYAN, CLR_GRAY,
CLR_ORANGE, CLR_BRIGHT_GREEN, CLR_YELLOW, CLR_BRIGHT_BLUE,
CLR_BRIGHT_MAGENTA, CLR_BRIGHT_CYAN, or CLR_WHITE (0 - 15).
-- over is the hilite attribute used if value is at or above
the threshold. The attribute can be BL_HILITE_NONE,
BL_HILITE_INVERSE, BL_HILITE_BOLD (-1, -2, or -3), or one
of the color indexes of CLR_BLACK, CLR_RED, CLR_GREEN,
CLR_BROWN, CLR_BLUE, CLR_MAGENTA, CLR_CYAN, CLR_GRAY,
CLR_ORANGE, CLR_BRIGHT_GREEN, CLR_YELLOW, CLR_BRIGHT_BLUE,
CLR_BRIGHT_MAGENTA, CLR_BRIGHT_CYAN, or CLR_WHITE (0 - 15).
*/
void
mswin_status_threshold(int fldidx, int thresholdtype, anything threshold,
int behavior, int under, int over)
{
logDebug("mswin_status_threshold(%d, %d, %d, %d, %d)\n", fldidx,
thresholdtype, behavior, under, over);
assert(fldidx >= 0 && fldidx < MAXBLSTATS);
_status_hilites[fldidx].thresholdtype = thresholdtype;
_status_hilites[fldidx].threshold = threshold;
_status_hilites[fldidx].behavior = behavior;
_status_hilites[fldidx].under = under;
_status_hilites[fldidx].over = over;
}
#endif /* STATUS_HILITES */
/* /*
status_update(int fldindex, genericptr_t ptr, int chg, int percentage) status_update(int fldindex, genericptr_t ptr, int chg, int percent, int color, unsigned long *colormasks)
-- update the value of a status field. -- update the value of a status field.
-- the fldindex identifies which field is changing and -- the fldindex identifies which field is changing and
is an integer index value from botl.h is an integer index value from botl.h
@@ -2894,9 +2838,13 @@ status_update(int fldindex, genericptr_t ptr, int chg, int percentage)
symbol for GOLD "\GXXXXNNNN:nnn". If window port needs symbol for GOLD "\GXXXXNNNN:nnn". If window port needs
textual gold amount without the leading "$:" the port will textual gold amount without the leading "$:" the port will
have to skip past ':' in passed "ptr" for the BL_GOLD case. have to skip past ':' in passed "ptr" for the BL_GOLD case.
-- color is the color that the NetHack core is telling you to
use to display the text.
-- colormasks is a pointer to a set of CLR_MAX unsigned longs
telling you which fields should be displayed in each color.
*/ */
void void
mswin_status_update(int idx, genericptr_t ptr, int chg, int percent) mswin_status_update(int idx, genericptr_t ptr, int chg, int percent, int color, unsigned long *colormasks)
{ {
long cond, *condptr = (long *) ptr; long cond, *condptr = (long *) ptr;
char *text = (char *) ptr; char *text = (char *) ptr;
@@ -2905,11 +2853,12 @@ mswin_status_update(int idx, genericptr_t ptr, int chg, int percent)
unsigned ospecial; unsigned ospecial;
long value = -1; long value = -1;
logDebug("mswin_status_update(%d, %p, %d, %d)\n", idx, ptr, chg, percent); logDebug("mswin_status_update(%d, %p, %d, %d, %x, %p)\n", idx, ptr, chg, percent, color, colormasks);
if (idx != BL_FLUSH) { if (idx != BL_FLUSH) {
if (!_status_activefields[idx]) if (!_status_activefields[idx])
return; return;
_status_percents[idx] = percent;
switch (idx) { switch (idx) {
case BL_CONDITION: { case BL_CONDITION: {
cond = *condptr; cond = *condptr;
@@ -2971,75 +2920,16 @@ mswin_status_update(int idx, genericptr_t ptr, int chg, int percent)
} }
} }
#ifdef STATUS_HILITES _status_colors[idx] = color;
switch (_status_hilites[idx].behavior) {
case BL_TH_NONE: {
_status_colors[idx] = CLR_MAX;
} break;
case BL_TH_UPDOWN: {
if (chg > 0)
_status_colors[idx] = _status_hilites[idx].over;
else if (chg < 0)
_status_colors[idx] = _status_hilites[idx].under;
else
_status_colors[idx] = CLR_MAX;
} break;
case BL_TH_VAL_PERCENTAGE: {
int pct_th = 0;
if (_status_hilites[idx].thresholdtype != ANY_INT) {
impossible("mswin_status_update: unsupported percentage "
"threshold type %d",
_status_hilites[idx].thresholdtype);
break;
}
pct_th = _status_hilites[idx].threshold.a_int;
_status_colors[idx] = (percent >= pct_th)
? _status_hilites[idx].over
: _status_hilites[idx].under;
} break;
case BL_TH_VAL_ABSOLUTE: {
int c = CLR_MAX;
int o = _status_hilites[idx].over;
int u = _status_hilites[idx].under;
anything *t = &_status_hilites[idx].threshold;
switch (_status_hilites[idx].thresholdtype) {
case ANY_LONG:
c = (value >= t->a_long) ? o : u;
break;
case ANY_INT:
c = (value >= t->a_int) ? o : u;
break;
case ANY_UINT:
c = ((unsigned long) value >= t->a_uint) ? o : u;
break;
case ANY_ULONG:
c = ((unsigned long) value >= t->a_ulong) ? o : u;
break;
case ANY_MASK32:
c = (value & t->a_ulong) ? o : u;
break;
default:
impossible("mswin_status_update: unsupported absolute threshold "
"type %d\n",
_status_hilites[idx].thresholdtype);
break;
}
_status_colors[idx] = c;
} break;
}
#endif /* STATUS_HILITES */
/* send command to status window */ /* send command to status window */
ZeroMemory(&update_cmd_data, sizeof(update_cmd_data)); ZeroMemory(&update_cmd_data, sizeof(update_cmd_data));
update_cmd_data.n_fields = MAXBLSTATS; update_cmd_data.n_fields = MAXBLSTATS;
update_cmd_data.vals = _status_vals; update_cmd_data.vals = _status_vals;
update_cmd_data.activefields = _status_activefields; update_cmd_data.activefields = _status_activefields;
update_cmd_data.percents = _status_percents;
update_cmd_data.colors = _status_colors; update_cmd_data.colors = _status_colors;
SendMessage(mswin_hwnd_from_winid(WIN_STATUS), WM_MSNH_COMMAND, SendMessage(mswin_hwnd_from_winid(WIN_STATUS), WM_MSNH_COMMAND,
(WPARAM) MSNH_MSG_UPDATE_STATUS, (LPARAM) &update_cmd_data); (WPARAM) MSNH_MSG_UPDATE_STATUS, (LPARAM) &update_cmd_data);
} }
#endif /*STATUS_VIA_WINDOWPORT*/
+1 -8
View File
@@ -182,18 +182,11 @@ void mswin_preference_update(const char *pref);
char *mswin_getmsghistory(BOOLEAN_P init); char *mswin_getmsghistory(BOOLEAN_P init);
void mswin_putmsghistory(const char *msg, BOOLEAN_P); void mswin_putmsghistory(const char *msg, BOOLEAN_P);
#ifdef STATUS_VIA_WINDOWPORT
void mswin_status_init(void); void mswin_status_init(void);
void mswin_status_finish(void); void mswin_status_finish(void);
void mswin_status_enablefield(int fieldidx, const char *nm, const char *fmt, void mswin_status_enablefield(int fieldidx, const char *nm, const char *fmt,
boolean enable); boolean enable);
void mswin_status_update(int idx, genericptr_t ptr, int chg, int percent); void mswin_status_update(int idx, genericptr_t ptr, int chg, int percent, int color, unsigned long *colormasks);
#ifdef STATUS_HILITES
void mswin_status_threshold(int fldidx, int thresholdtype, anything threshold,
int behavior, int under, int over);
#endif /* STATUS_HILITES */
#endif /*STATUS_VIA_WINDOWPORT*/
/* helper function */ /* helper function */
HWND mswin_hwnd_from_winid(winid wid); HWND mswin_hwnd_from_winid(winid wid);