CHANGE_COLOR palette option adjustments

It was too early to call the windowport change_color() routine
while processing the config file. The windowport was not yet
fully operational.

Now the palette option processing will just place the rgb
value into the appropriate ga.altpalette[CLR_MAX] entry.

init_sound_disp_gamewindows(void) [allmain.c] calls
change_palette() [coloratt.c] and it will call the windowport
change_color() function for each ga.altpalette[] entry that
has been set.

Notes:
The rgb values stored in ga.altpalette[] have the NH_ALTPALETTE bit set
so that the rgb value of 0 can be stored and be distinguishable from
a "not set" entry.

The NH_ALTPALETTE bit is cleared from the rgb value in change_palette()
prior to calling the windowport change_color() function.

The syntax for palette is colorname/r-g-b.
For example: palette:black/12-12-12

colorname must be one of the NH_BASIC_COLOR names or a suitable
alias for one of those 16 entries.

Some of the windowport CHANGE_COLOR functions had the wrong parameters,
perhaps due to bitrot. Those have been corrected to match the prototype.
This commit is contained in:
nhmall
2024-04-12 21:57:27 -04:00
parent 749f2ffb0e
commit 15db874f71
13 changed files with 239 additions and 62 deletions

View File

@@ -55,6 +55,7 @@
#define HI_ZAP CLR_BRIGHT_BLUE
#define NH_BASIC_COLOR 0x1000000
#define NH_ALTPALETTE 0x2000000
#define COLORVAL(x) ((x) & 0xFFFFFF)
enum nhcolortype { no_color, nh_color, rgb_color };

View File

@@ -157,6 +157,11 @@ struct instance_globals_a {
short *animal_list; /* list of PM values for animal monsters */
int animal_list_count;
#ifdef CHANGE_COLOR
/* options.c */
uint32 altpalette[CLR_MAX];
#endif
/* pickup.c */
int A_first_hint; /* menustyle:Full plus 'A' response + !paranoid:A */
int A_second_hint; /* menustyle:Full plus 'A' response + paranoid:A */
@@ -759,6 +764,7 @@ struct instance_globals_o {
boolean opt_need_promptstyle;
boolean opt_reset_customcolors;
boolean opt_reset_customsymbols;
boolean opt_update_basic_palette;
/* pickup.c */
int oldcap; /* last encumbrance */

View File

@@ -325,6 +325,10 @@ extern boolean closest_color(uint32_t lcolor, uint32_t *closecolor, uint16 *clri
extern int color_distance(uint32_t, uint32_t);
extern boolean onlyhexdigits(const char *buf);
extern uint32 get_nhcolor_from_256_index(int idx);
#ifdef CHANGE_COLOR
extern int count_alt_palette(void);
extern void change_palette(void);
#endif
/* ### cmd.c ### */

View File

@@ -534,14 +534,14 @@ static int optfn_##a(int, int, boolean, char *, char *);
No, Yes, No, No, NoAlias,
"the inventory order of the items in your pack")
#ifdef CHANGE_COLOR
#ifndef WIN32
#ifndef MAC /* not old Mac OS9 */
NHOPTC(palette, Advanced, 15, opt_in, set_gameview,
No, Yes, No, No, "hicolor",
"palette (adjust an RGB color in palette (color/R-G-B)")
#else
NHOPTC(palette, Advanced, 15, opt_in, set_in_game,
No, Yes, No, No, "hicolor",
"palette (00c/880/-fff is blue/yellow/reverse white)")
#else
NHOPTC(palette, Advanced, 15, opt_in, set_in_config,
No, Yes, No, No, "hicolor",
"palette (adjust an RGB color in palette (color-R-G-B)")
#endif
#endif
/* prior to paranoid_confirmation, 'prayconfirm' was a distinct option */