From: Holger Schemel Date: Fri, 13 Dec 2024 19:26:31 +0000 (+0100) Subject: added support for two extra colors for color templates X-Git-Tag: 4.4.0.0-test-6~9 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=19bbdaf80814cafa46aef9672b2edd34fdecad96;p=rocksndiamonds.git added support for two extra colors for color templates --- diff --git a/src/editor.c b/src/editor.c index 6cbe01d3..b97de907 100644 --- a/src/editor.c +++ b/src/editor.c @@ -702,6 +702,8 @@ enum GADGET_ID_BD_COLOR_TEXT_3, GADGET_ID_BD_COLOR_TEXT_4, GADGET_ID_BD_COLOR_TEXT_5, + GADGET_ID_BD_COLOR_TEXT_6, + GADGET_ID_BD_COLOR_TEXT_7, GADGET_ID_ELEMENT_NAME, // text area identifiers @@ -723,6 +725,8 @@ enum GADGET_ID_BD_COLOR_C64_3, GADGET_ID_BD_COLOR_C64_4, GADGET_ID_BD_COLOR_C64_5, + GADGET_ID_BD_COLOR_C64_6, + GADGET_ID_BD_COLOR_C64_7, GADGET_ID_WIND_DIRECTION, GADGET_ID_PLAYER_SPEED, GADGET_ID_BD_GRAVITY_DIRECTION, @@ -786,6 +790,8 @@ enum GADGET_ID_BD_COLOR_PICK_3, GADGET_ID_BD_COLOR_PICK_4, GADGET_ID_BD_COLOR_PICK_5, + GADGET_ID_BD_COLOR_PICK_6, + GADGET_ID_BD_COLOR_PICK_7, // gadgets for scrolling of drawing area @@ -1047,6 +1053,8 @@ enum ED_TEXTINPUT_ID_BD_COLOR_TEXT_3, ED_TEXTINPUT_ID_BD_COLOR_TEXT_4, ED_TEXTINPUT_ID_BD_COLOR_TEXT_5, + ED_TEXTINPUT_ID_BD_COLOR_TEXT_6, + ED_TEXTINPUT_ID_BD_COLOR_TEXT_7, ED_TEXTINPUT_ID_ELEMENT_NAME, ED_NUM_TEXTINPUT @@ -1059,7 +1067,7 @@ enum #define ED_TEXTINPUT_ID_LEVELSET_LAST ED_TEXTINPUT_ID_LEVELSET_AUTHOR #define ED_TEXTINPUT_ID_COLORS_FIRST ED_TEXTINPUT_ID_BD_COLOR_TEXT_B -#define ED_TEXTINPUT_ID_COLORS_LAST ED_TEXTINPUT_ID_BD_COLOR_TEXT_5 +#define ED_TEXTINPUT_ID_COLORS_LAST ED_TEXTINPUT_ID_BD_COLOR_TEXT_7 // values for text area gadgets enum @@ -1088,6 +1096,8 @@ enum ED_SELECTBOX_ID_BD_COLOR_C64_3, ED_SELECTBOX_ID_BD_COLOR_C64_4, ED_SELECTBOX_ID_BD_COLOR_C64_5, + ED_SELECTBOX_ID_BD_COLOR_C64_6, + ED_SELECTBOX_ID_BD_COLOR_C64_7, ED_SELECTBOX_ID_WIND_DIRECTION, ED_SELECTBOX_ID_PLAYER_SPEED, ED_SELECTBOX_ID_BD_GRAVITY_DIRECTION, @@ -1131,7 +1141,7 @@ enum #define ED_SELECTBOX_ID_ENGINE_LAST ED_SELECTBOX_ID_BD_SCHEDULING_TYPE #define ED_SELECTBOX_ID_COLORS_FIRST ED_SELECTBOX_ID_BD_COLOR_C64_B -#define ED_SELECTBOX_ID_COLORS_LAST ED_SELECTBOX_ID_BD_COLOR_C64_5 +#define ED_SELECTBOX_ID_COLORS_LAST ED_SELECTBOX_ID_BD_COLOR_C64_7 #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION @@ -1193,6 +1203,8 @@ enum ED_GRAPHICBUTTON_ID_BD_COLOR_PICK_3, ED_GRAPHICBUTTON_ID_BD_COLOR_PICK_4, ED_GRAPHICBUTTON_ID_BD_COLOR_PICK_5, + ED_GRAPHICBUTTON_ID_BD_COLOR_PICK_6, + ED_GRAPHICBUTTON_ID_BD_COLOR_PICK_7, ED_NUM_GRAPHICBUTTONS }; @@ -1201,7 +1213,7 @@ enum #define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE #define ED_GRAPHICBUTTON_ID_PICK_FIRST ED_GRAPHICBUTTON_ID_BD_COLOR_PICK_B -#define ED_GRAPHICBUTTON_ID_PICK_LAST ED_GRAPHICBUTTON_ID_BD_COLOR_PICK_5 +#define ED_GRAPHICBUTTON_ID_PICK_LAST ED_GRAPHICBUTTON_ID_BD_COLOR_PICK_7 // values for checkbutton gadgets enum @@ -1720,7 +1732,7 @@ static boolean levelset_use_levelset_artwork = FALSE; static boolean levelset_copy_level_template = FALSE; static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE; -#define MAX_BD_COLORS 7 +#define MAX_BD_COLORS 9 #define MAX_BD_COLOR_TEXT_LEN 12 static int bd_color_type_default = GD_COLOR_TYPE_RGB; @@ -1737,6 +1749,8 @@ static int *bd_color[MAX_BD_COLORS] = &level.bd_color_3, &level.bd_color_4, &level.bd_color_5, + &level.bd_color_6, + &level.bd_color_7, }; static struct @@ -2272,6 +2286,22 @@ static struct bd_color_text[6], NULL, "Slime color: ", NULL, "Enter slime color (C64 graphics)" }, + { + ED_TEXTINPUT_ID_BD_COLOR_TEXT_6, + ED_ENGINE_SETTINGS_XPOS(0), ED_ENGINE_SETTINGS_YPOS(8), + GADGET_ID_BD_COLOR_TEXT_6, + MAX_BD_COLOR_TEXT_LEN, + bd_color_text[7], + NULL, "Extra color 1: ", NULL, "Enter extra color 1 (C64 graphics)" + }, + { + ED_TEXTINPUT_ID_BD_COLOR_TEXT_7, + ED_ENGINE_SETTINGS_XPOS(0), ED_ENGINE_SETTINGS_YPOS(9), + GADGET_ID_BD_COLOR_TEXT_7, + MAX_BD_COLOR_TEXT_LEN, + bd_color_text[8], + NULL, "Extra color 2: ", NULL, "Enter extra color 2 (C64 graphics)" + }, // ---------- element settings: configure (several elements) ---------------- @@ -3236,6 +3266,24 @@ static struct &bd_color_c64[6], NULL, "Slime color: ", NULL, "Select slime color (C64 graphics)" }, + { + ED_SELECTBOX_ID_BD_COLOR_C64_6, + ED_ENGINE_SETTINGS_XPOS(0), ED_ENGINE_SETTINGS_YPOS(8), + GADGET_ID_BD_COLOR_C64_6, GADGET_ID_NONE, + -1, + options_bd_color_c64_name, + &bd_color_c64[7], + NULL, "Extra color 1: ", NULL, "Select extra color 1 (C64 graphics)" + }, + { + ED_SELECTBOX_ID_BD_COLOR_C64_7, + ED_ENGINE_SETTINGS_XPOS(0), ED_ENGINE_SETTINGS_YPOS(9), + GADGET_ID_BD_COLOR_C64_7, GADGET_ID_NONE, + -1, + options_bd_color_c64_name, + &bd_color_c64[8], + NULL, "Extra color 2: ", NULL, "Select extra color 2 (C64 graphics)" + }, // ---------- element settings: configure (several elements) ---------------- @@ -3661,7 +3709,7 @@ static struct { ED_TEXTBUTTON_ID_BD_SET_RANDOM_COLORS, - ED_ENGINE_SETTINGS_XPOS(0), ED_ENGINE_SETTINGS_YPOS(8), + ED_ENGINE_SETTINGS_XPOS(0), ED_ENGINE_SETTINGS_YPOS(10), GADGET_ID_BD_SET_RANDOM_COLORS, GADGET_ID_NONE, -1, "Set random colors", NULL, NULL, NULL, "Create and set random level colors" @@ -3755,6 +3803,20 @@ static struct GADGET_ID_BD_COLOR_PICK_5, GADGET_ID_BD_COLOR_TEXT_5, NULL, NULL, "Pick slime color (C64 graphics)" }, + { + ED_GRAPHICBUTTON_ID_BD_COLOR_PICK_6, + IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, + -1, ED_ENGINE_SETTINGS_YPOS(8), + GADGET_ID_BD_COLOR_PICK_6, GADGET_ID_BD_COLOR_TEXT_6, + NULL, NULL, "Pick extra color 1 (C64 graphics)" + }, + { + ED_GRAPHICBUTTON_ID_BD_COLOR_PICK_7, + IMG_GFX_EDITOR_BUTTON_PICK_ELEMENT, + -1, ED_ENGINE_SETTINGS_YPOS(9), + GADGET_ID_BD_COLOR_PICK_7, GADGET_ID_BD_COLOR_TEXT_7, + NULL, NULL, "Pick extra color 2 (C64 graphics)" + }, }; static struct @@ -11873,6 +11935,8 @@ void SetCurrentLevelColors_BD(void) cave->color3 = level.bd_color_3; cave->color4 = level.bd_color_4; cave->color5 = level.bd_color_5; + cave->color6 = level.bd_color_6; + cave->color7 = level.bd_color_7; } void SetRandomLevelColors_BD(int bd_color_type) @@ -11891,6 +11955,8 @@ void SetRandomLevelColors_BD(int bd_color_type) level.bd_color_3 = cave->color3; level.bd_color_4 = cave->color4; level.bd_color_5 = cave->color5; + level.bd_color_6 = cave->color6; + level.bd_color_7 = cave->color7; } static void DrawColorBox_BD(int nr) diff --git a/src/files.c b/src/files.c index f922d6e5..82fd7c74 100644 --- a/src/files.c +++ b/src/files.c @@ -352,6 +352,16 @@ static struct LevelFileConfigInfo chunk_config_INFO[] = TYPE_INTEGER, CONF_VALUE_32_BIT(9), &li.bd_color_5, GD_C64_COLOR(6) }, + { + -1, -1, + TYPE_INTEGER, CONF_VALUE_32_BIT(10), + &li.bd_color_6, GD_C64_COLOR(12) + }, + { + -1, -1, + TYPE_INTEGER, CONF_VALUE_32_BIT(11), + &li.bd_color_7, GD_C64_COLOR(1) + }, { -1, -1, @@ -4492,6 +4502,8 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level) cave->color3 = level->bd_color_3; cave->color4 = level->bd_color_4; cave->color5 = level->bd_color_5; + cave->color6 = level->bd_color_6; + cave->color7 = level->bd_color_7; // level name strncpy(cave->name, level->name, sizeof(GdString)); @@ -4680,6 +4692,8 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level) level->bd_color_3 = cave->color3; level->bd_color_4 = cave->color4; level->bd_color_5 = cave->color5; + level->bd_color_6 = cave->color6; + level->bd_color_7 = cave->color7; // set default color type and colors for BD style level colors SetDefaultLevelColorType_BD(); diff --git a/src/game_bd/bd_bdcff.c b/src/game_bd/bd_bdcff.c index e170cdce..09b14f26 100644 --- a/src/game_bd/bd_bdcff.c +++ b/src/game_bd/bd_bdcff.c @@ -483,6 +483,8 @@ static boolean cave_process_tags_func(const char *attrib, const char *param, GdC cave->color3 = gd_color_get_from_string(params[2]); cave->color4 = cave->color3; // amoeba cave->color5 = cave->color1; // slime + cave->color6 = gd_c64_color(12); // extra color 1 - gray + cave->color7 = gd_c64_color(1); // extra color 2 - white } else if (paramcount == 5) { @@ -494,6 +496,8 @@ static boolean cave_process_tags_func(const char *attrib, const char *param, GdC cave->color3 = gd_color_get_from_string(params[4]); cave->color4 = cave->color3; // amoeba cave->color5 = cave->color1; // slime + cave->color6 = gd_c64_color(12); // extra color 1 - gray + cave->color7 = gd_c64_color(1); // extra color 2 - white } else if (paramcount == 7) { @@ -505,6 +509,8 @@ static boolean cave_process_tags_func(const char *attrib, const char *param, GdC cave->color3 = gd_color_get_from_string(params[4]); cave->color4 = gd_color_get_from_string(params[5]); // amoeba cave->color5 = gd_color_get_from_string(params[6]); // slime + cave->color6 = gd_c64_color(12); // extra color 1 - gray + cave->color7 = gd_c64_color(1); // extra color 2 - white } else { @@ -521,7 +527,9 @@ static boolean cave_process_tags_func(const char *attrib, const char *param, GdC gd_color_is_unknown(cave->color2) || gd_color_is_unknown(cave->color3) || gd_color_is_unknown(cave->color4) || - gd_color_is_unknown(cave->color5)) + gd_color_is_unknown(cave->color5) || + gd_color_is_unknown(cave->color6) || + gd_color_is_unknown(cave->color7)) { Warn("created a new C64 color scheme."); diff --git a/src/game_bd/bd_c64import.c b/src/game_bd/bd_c64import.c index 7940be74..988f3108 100644 --- a/src/game_bd/bd_c64import.c +++ b/src/game_bd/bd_c64import.c @@ -830,6 +830,8 @@ static int cave_copy_from_bd1(GdCave *cave, const byte *data, int remaining_byte cave->color5 = gd_atari_color(data[0x16]); // in atari, slime was green cave->colorb = gd_atari_color(data[0x17]); // border = background cave->color0 = gd_atari_color(data[0x17]); // background + cave->color6 = gd_atari_color(8); // extra color 1 - gray + cave->color7 = gd_atari_color(15); // extra color 2 - white } else { @@ -841,6 +843,8 @@ static int cave_copy_from_bd1(GdCave *cave, const byte *data, int remaining_byte cave->color3 = gd_c64_color(data[0x15] & 0x7); // lower 3 bits only (vic-ii worked this way) cave->color4 = cave->color3; // in bd1, amoeba was color3 cave->color5 = cave->color3; // no slime, but let it be color 3 + cave->color6 = gd_c64_color(12); // extra color 1 - gray + cave->color7 = gd_c64_color(1); // extra color 2 - white } // random fill @@ -1377,6 +1381,8 @@ static int cave_copy_from_bd2(GdCave *cave, const byte *data, int remaining_byte cave->color3 = gd_c64_color(data[index + 2] & 0x7); // lower 3 bits only! cave->color4 = cave->color1; // in bd2, amoeba was color1 cave->color5 = cave->color1; // slime too + cave->color6 = gd_c64_color(12); // extra color 1 - gray + cave->color7 = gd_c64_color(1); // extra color 2 - white index += 3; } else @@ -1389,6 +1395,8 @@ static int cave_copy_from_bd2(GdCave *cave, const byte *data, int remaining_byte cave->color5 = gd_atari_color(data[index + 3]); cave->colorb = gd_atari_color(data[index + 4]); // background and border cave->color0 = gd_atari_color(data[index + 4]); + cave->color6 = gd_atari_color(8); // extra color 1 - gray + cave->color7 = gd_atari_color(15); // extra color 2 - white index += 5; } @@ -1533,6 +1541,10 @@ static int cave_copy_from_plck(GdCave *cave, const byte *data, // (maybe they could have been changed in a hex editor) cave->color4 = gd_atari_color(data[0x1e1]); cave->color5 = gd_atari_color(data[0x1e1]); + + // extra colors + cave->color6 = gd_atari_color(8); // extra color 1 - gray + cave->color7 = gd_atari_color(15); // extra color 2 - white } else { @@ -1544,6 +1556,8 @@ static int cave_copy_from_plck(GdCave *cave, const byte *data, cave->color3 = gd_c64_color(data[0x1e3] & 0x7); // lower 3 bits only! cave->color4 = cave->color3; // in plck, amoeba was color3 cave->color5 = cave->color3; // same for slime + cave->color6 = gd_c64_color(12); // extra color 1 - gray + cave->color7 = gd_c64_color(1); // extra color 2 - white } // ... the cave is stored like a map. @@ -1654,6 +1668,8 @@ static int cave_copy_from_dlb(GdCave *cave, const byte *data, int remaining_byte cave->color3 = gd_c64_color(data[12] & 0x7); // lower 3 bits only! cave->color4 = cave->color3; // in plck, amoeba was color3 cave->color5 = cave->color3; // same for slime + cave->color6 = gd_c64_color(12); // extra color 1 - gray + cave->color7 = gd_c64_color(1); // extra color 2 - white // cave map is compressed. // employ a state machine to decompress data. @@ -1910,6 +1926,8 @@ static int cave_copy_from_1stb(GdCave *cave, const byte *data, int remaining_byt cave->color3 = gd_c64_color(data[0x388] & 0x7); // lower 3 bits only! cave->color4 = cave->color1; cave->color5 = cave->color1; + cave->color6 = gd_c64_color(12); // extra color 1 - gray + cave->color7 = gd_c64_color(1); // extra color 2 - white cave->amoeba_growth_prob = amoeba_probability(data[0x382]); cave->amoeba_fast_growth_prob = amoeba_probability(data[0x383]); @@ -2029,6 +2047,8 @@ static int cave_copy_from_crdr_7(GdCave *cave, const byte *data, int remaining_b cave->color3 = gd_c64_color(data[0x18] & 0x7); // lower 3 bits only! cave->color4 = cave->color3; cave->color5 = cave->color1; + cave->color6 = gd_c64_color(12); // extra color 1 - gray + cave->color7 = gd_c64_color(1); // extra color 2 - white cave->intermission = (data[0x19] != 0); @@ -2500,6 +2520,8 @@ static int cave_copy_from_crli(GdCave *cave, const byte *data, int remaining_byt cave->color3 = gd_c64_color(uncompressed[0x388] & 0x7); // lower 3 bits only! cave->color4 = cave->color3; cave->color5 = cave->color1; + cave->color6 = gd_c64_color(12); // extra color 1 - gray + cave->color7 = gd_c64_color(1); // extra color 2 - white cave->intermission = (uncompressed[0x389] != 0); diff --git a/src/game_bd/bd_cave.c b/src/game_bd/bd_cave.c index 83351c0e..d23dbeca 100644 --- a/src/game_bd/bd_cave.c +++ b/src/game_bd/bd_cave.c @@ -791,6 +791,7 @@ void gd_cave_set_random_c64_colors(GdCave *cave) { const int bright_colors[] = { 1, 3, 7 }; const int dark_colors[] = { 2, 6, 8, 9, 11 }; + const int gray_colors[] = { 11, 12, 15 }; // always black cave->colorb = gd_c64_color(0); @@ -817,6 +818,10 @@ void gd_cave_set_random_c64_colors(GdCave *cave) // copy amoeba and slime color cave->color4 = cave->color3; cave->color5 = cave->color1; + + // extra colors + cave->color6 = gd_c64_color(gray_colors[gd_random_int_range(0, ARRAY_SIZE(gray_colors))]); + cave->color7 = gd_c64_color(1); } static void cave_set_random_indexed_colors(GdCave *cave, GdColor (*color_indexer_func) (int, int)) @@ -855,6 +860,10 @@ static void cave_set_random_indexed_colors(GdCave *cave, GdColor (*color_indexer cave->color4 = color_indexer_func(gd_random_int_range(11, 13), gd_random_int_range(6, 12)); // some blueish thing cave->color5 = color_indexer_func(gd_random_int_range(7, 10), gd_random_int_range(0, 6)); + + // extra colors + cave->color6 = color_indexer_func(0, bri1); + cave->color7 = color_indexer_func(0, 15); } static void gd_cave_set_random_atari_colors(GdCave *cave) @@ -937,6 +946,10 @@ static void gd_cave_set_random_rgb_colors(GdCave *cave) cave->color4 = gd_color_get_from_hsv(gd_random_int_range(100, 140), s2, v2); // blue(240+-20) with saturation and brightness of dirt cave->color5 = gd_color_get_from_hsv(gd_random_int_range(220, 260), s1, v1); + + // extra colors + cave->color6 = gd_color_get_from_hsv(0, 0, v1); // gray with brightness of dirt + cave->color7 = gd_color_get_from_hsv(0, 0, 1); // white } void gd_cave_set_random_colors(GdCave *cave, GdColorType type) diff --git a/src/game_bd/bd_cave.h b/src/game_bd/bd_cave.h index a1de3792..f76c215b 100644 --- a/src/game_bd/bd_cave.h +++ b/src/game_bd/bd_cave.h @@ -403,7 +403,7 @@ typedef struct _gd_cave GdColor colorb; // border color GdColor color0, color1, color2, color3, color4, color5; // c64-style colors; // color 4 and 5 are amoeba and slime. - + GdColor color6, color7; // extra colors int diamond_value; // Score for a diamond. int extra_diamond_value; // Score for a diamond, when gate is open. diff --git a/src/game_bd/bd_cavedb.c b/src/game_bd/bd_cavedb.c index df768a50..559a49dd 100644 --- a/src/game_bd/bd_cavedb.c +++ b/src/game_bd/bd_cavedb.c @@ -2246,6 +2246,16 @@ const GdStructDescriptor gd_cave_properties[] = N_("Slime color"), STRUCT_OFFSET(GdCave, color5), 1, N_("Slime color for C64 graphics") }, + { + "Colors", GD_TYPE_COLOR, GD_ALWAYS_SAVE, + N_("Extra color 1"), STRUCT_OFFSET(GdCave, color6), 1, + N_("Extra color 1 for C64 graphics") + }, + { + "Colors", GD_TYPE_COLOR, GD_ALWAYS_SAVE, + N_("Extra color 2"), STRUCT_OFFSET(GdCave, color7), 1, + N_("Extra color 2 for C64 graphics") + }, // difficulty { diff --git a/src/game_bd/bd_caveset.c b/src/game_bd/bd_caveset.c index 59a46627..33d2515c 100644 --- a/src/game_bd/bd_caveset.c +++ b/src/game_bd/bd_caveset.c @@ -509,6 +509,8 @@ static void brc_import(byte *data) cave->color3 = 0xffffff; // white for brick cave->color4 = 0xe5ad23; // fixed for amoeba cave->color5 = 0x8af713; // fixed for slime + cave->color6 = 0x888888; // extra color 1 - gray + cave->color7 = 0xffffff; // extra color 2 - white if (import_effect) { diff --git a/src/game_bd/bd_graphics.c b/src/game_bd/bd_graphics.c index 6aaa0ada..ceaa12df 100644 --- a/src/game_bd/bd_graphics.c +++ b/src/game_bd/bd_graphics.c @@ -348,8 +348,8 @@ static SDL_Surface *get_colored_surface_from_template(GdCave *cave, SDL_Surface color[3] = get_template_color(cave->color3); // replace yellow color[4] = get_template_color(cave->color5); // replace blue color[5] = get_template_color(cave->color2); // replace purple - color[6] = get_template_color(GD_GDASH_GRAY2); // replace cyan - color[7] = get_template_color(GD_GDASH_WHITE); // replace white + color[6] = get_template_color(cave->color6); // replace cyan + color[7] = get_template_color(cave->color7); // replace white for (y = 0; y < height; y++) { diff --git a/src/main.h b/src/main.h index 678e1930..d0a9d92d 100644 --- a/src/main.h +++ b/src/main.h @@ -3953,6 +3953,8 @@ struct LevelInfo int bd_color_3; // BD engine C64-style cave color (wall) int bd_color_4; // BD engine C64-style cave color (amoeba) int bd_color_5; // BD engine C64-style cave color (slime) + int bd_color_6; // BD engine C64-style cave color (extra color 1) + int bd_color_7; // BD engine C64-style cave color (extra color 2) boolean em_slippery_gems; // EM style "gems slip from wall" behaviour boolean em_explodes_by_fire; // EM style chain explosion behaviour