X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ffiles.c;h=e9b56ea9b55f19e091c8ee091888ceaa65baa910;hp=b5c92b98f5033e4b3fce32cc156f645d6b6bdf2a;hb=c0441f4c88acd9bd63f3b30bc4ce22d61ebee10a;hpb=ffd8016e47406b66dbbb8d78eb85129ead34f0a7 diff --git a/src/files.c b/src/files.c index b5c92b98..e9b56ea9 100644 --- a/src/files.c +++ b/src/files.c @@ -9842,7 +9842,7 @@ static void InitMenuDesignSettings_SpecialPostProcessing(void) { NULL, NULL } }; - int i; + int i, j; // special case: initialize later added SETUP list size from LEVELS value if (menu.list_size[GAME_MODE_SETUP] == -1) @@ -9853,6 +9853,237 @@ static void InitMenuDesignSettings_SpecialPostProcessing(void) if ((*game_buttons_xy[i].dst).x == -1 && (*game_buttons_xy[i].dst).y == -1) *game_buttons_xy[i].dst = *game_buttons_xy[i].src; + + // -------------------------------------------------------------------------- + // dynamic viewports (including playfield margins, borders and alignments) + // -------------------------------------------------------------------------- + + // dynamic viewports currently only supported for landscape mode + int display_width = MAX(video.display_width, video.display_height); + int display_height = MIN(video.display_width, video.display_height); + + for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++) + { + struct RectWithBorder *vp_window = &viewport.window[i]; + struct RectWithBorder *vp_playfield = &viewport.playfield[i]; + struct RectWithBorder *vp_door_1 = &viewport.door_1[i]; + struct RectWithBorder *vp_door_2 = &viewport.door_2[i]; + boolean dynamic_window_width = (vp_window->min_width != -1); + boolean dynamic_window_height = (vp_window->min_height != -1); + boolean dynamic_playfield_width = (vp_playfield->min_width != -1); + boolean dynamic_playfield_height = (vp_playfield->min_height != -1); + + // adjust window size if min/max width/height is specified + + if (vp_window->min_width != -1) + { + int window_width = display_width; + + // when using static window height, use aspect ratio of display + if (vp_window->min_height == -1) + window_width = vp_window->height * display_width / display_height; + + vp_window->width = MAX(vp_window->min_width, window_width); + } + + if (vp_window->min_height != -1) + { + int window_height = display_height; + + // when using static window width, use aspect ratio of display + if (vp_window->min_width == -1) + window_height = vp_window->width * display_height / display_width; + + vp_window->height = MAX(vp_window->min_height, window_height); + } + + if (vp_window->max_width != -1) + vp_window->width = MIN(vp_window->width, vp_window->max_width); + + if (vp_window->max_height != -1) + vp_window->height = MIN(vp_window->height, vp_window->max_height); + + int playfield_width = vp_window->width; + int playfield_height = vp_window->height; + + // adjust playfield size and position according to specified margins + + playfield_width -= vp_playfield->margin_left; + playfield_width -= vp_playfield->margin_right; + + playfield_height -= vp_playfield->margin_top; + playfield_height -= vp_playfield->margin_bottom; + + // adjust playfield size if min/max width/height is specified + + if (vp_playfield->min_width != -1) + vp_playfield->width = MAX(vp_playfield->min_width, playfield_width); + + if (vp_playfield->min_height != -1) + vp_playfield->height = MAX(vp_playfield->min_height, playfield_height); + + if (vp_playfield->max_width != -1) + vp_playfield->width = MIN(vp_playfield->width, vp_playfield->max_width); + + if (vp_playfield->max_height != -1) + vp_playfield->height = MIN(vp_playfield->height,vp_playfield->max_height); + + // adjust playfield position according to specified alignment + + if (vp_playfield->align == ALIGN_LEFT || vp_playfield->x > 0) + vp_playfield->x = ALIGNED_VP_XPOS(vp_playfield); + else if (vp_playfield->align == ALIGN_CENTER) + vp_playfield->x = playfield_width / 2 - vp_playfield->width / 2; + else if (vp_playfield->align == ALIGN_RIGHT) + vp_playfield->x += playfield_width - vp_playfield->width; + + if (vp_playfield->valign == VALIGN_TOP || vp_playfield->y > 0) + vp_playfield->y = ALIGNED_VP_YPOS(vp_playfield); + else if (vp_playfield->valign == VALIGN_MIDDLE) + vp_playfield->y = playfield_height / 2 - vp_playfield->height / 2; + else if (vp_playfield->valign == VALIGN_BOTTOM) + vp_playfield->y += playfield_height - vp_playfield->height; + + vp_playfield->x += vp_playfield->margin_left; + vp_playfield->y += vp_playfield->margin_top; + + // adjust individual playfield borders if only default border is specified + + if (vp_playfield->border_left == -1) + vp_playfield->border_left = vp_playfield->border_size; + if (vp_playfield->border_right == -1) + vp_playfield->border_right = vp_playfield->border_size; + if (vp_playfield->border_top == -1) + vp_playfield->border_top = vp_playfield->border_size; + if (vp_playfield->border_bottom == -1) + vp_playfield->border_bottom = vp_playfield->border_size; + + // set dynamic playfield borders if borders are specified as undefined + // (but only if window size was dynamic and playfield size was static) + + if (dynamic_window_width && !dynamic_playfield_width) + { + if (vp_playfield->border_left == -1) + { + vp_playfield->border_left = (vp_playfield->x - + vp_playfield->margin_left); + vp_playfield->x -= vp_playfield->border_left; + vp_playfield->width += vp_playfield->border_left; + } + + if (vp_playfield->border_right == -1) + { + vp_playfield->border_right = (vp_window->width - + vp_playfield->x - + vp_playfield->width - + vp_playfield->margin_right); + vp_playfield->width += vp_playfield->border_right; + } + } + + if (dynamic_window_height && !dynamic_playfield_height) + { + if (vp_playfield->border_top == -1) + { + vp_playfield->border_top = (vp_playfield->y - + vp_playfield->margin_top); + vp_playfield->y -= vp_playfield->border_top; + vp_playfield->height += vp_playfield->border_top; + } + + if (vp_playfield->border_bottom == -1) + { + vp_playfield->border_bottom = (vp_window->height - + vp_playfield->y - + vp_playfield->height - + vp_playfield->margin_bottom); + vp_playfield->height += vp_playfield->border_bottom; + } + } + + // adjust playfield size to be a multiple of a defined alignment tile size + + int align_size = vp_playfield->align_size; + int playfield_xtiles = vp_playfield->width / align_size; + int playfield_ytiles = vp_playfield->height / align_size; + int playfield_width_corrected = playfield_xtiles * align_size; + int playfield_height_corrected = playfield_ytiles * align_size; + boolean is_playfield_mode = (i == GFX_SPECIAL_ARG_PLAYING || + i == GFX_SPECIAL_ARG_EDITOR); + + if (is_playfield_mode && + dynamic_playfield_width && + vp_playfield->width != playfield_width_corrected) + { + int playfield_xdiff = vp_playfield->width - playfield_width_corrected; + + vp_playfield->width = playfield_width_corrected; + + if (vp_playfield->align == ALIGN_LEFT) + { + vp_playfield->border_left += playfield_xdiff; + } + else if (vp_playfield->align == ALIGN_RIGHT) + { + vp_playfield->border_right += playfield_xdiff; + } + else if (vp_playfield->align == ALIGN_CENTER) + { + int border_left_diff = playfield_xdiff / 2; + int border_right_diff = playfield_xdiff - border_left_diff; + + vp_playfield->border_left += border_left_diff; + vp_playfield->border_right += border_right_diff; + } + } + + if (is_playfield_mode && + dynamic_playfield_height && + vp_playfield->height != playfield_height_corrected) + { + int playfield_ydiff = vp_playfield->height - playfield_height_corrected; + + vp_playfield->height = playfield_height_corrected; + + if (vp_playfield->valign == VALIGN_TOP) + { + vp_playfield->border_top += playfield_ydiff; + } + else if (vp_playfield->align == VALIGN_BOTTOM) + { + vp_playfield->border_right += playfield_ydiff; + } + else if (vp_playfield->align == VALIGN_MIDDLE) + { + int border_top_diff = playfield_ydiff / 2; + int border_bottom_diff = playfield_ydiff - border_top_diff; + + vp_playfield->border_top += border_top_diff; + vp_playfield->border_bottom += border_bottom_diff; + } + } + + // adjust door positions according to specified alignment + + for (j = 0; j < 2; j++) + { + struct RectWithBorder *vp_door = (j == 0 ? vp_door_1 : vp_door_2); + + if (vp_door->align == ALIGN_LEFT || vp_door->x > 0) + vp_door->x = ALIGNED_VP_XPOS(vp_door); + else if (vp_door->align == ALIGN_CENTER) + vp_door->x = vp_window->width / 2 - vp_door->width / 2; + else if (vp_door->align == ALIGN_RIGHT) + vp_door->x += vp_window->width - vp_door->width; + + if (vp_door->valign == VALIGN_TOP || vp_door->y > 0) + vp_door->y = ALIGNED_VP_YPOS(vp_door); + else if (vp_door->valign == VALIGN_MIDDLE) + vp_door->y = vp_window->height / 2 - vp_door->height / 2; + else if (vp_door->valign == VALIGN_BOTTOM) + vp_door->y += vp_window->height - vp_door->height; + } + } } static void InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics(void) @@ -9894,6 +10125,40 @@ static void InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics(void) *editor_buttons_xy[i].dst = *editor_buttons_xy[i].src; } } + + // adjust editor palette rows and columns if specified to be dynamic + + if (editor.palette.cols == -1) + { + int vp_width = viewport.playfield[GFX_SPECIAL_ARG_EDITOR].width; + int bt_width = graphic_info[IMG_EDITOR_PALETTE_BUTTON].width; + int sc_width = graphic_info[IMG_EDITOR_PALETTE_SCROLLBAR].width; + + editor.palette.cols = (vp_width - sc_width) / bt_width; + + if (editor.palette.x == -1) + { + int palette_width = editor.palette.cols * bt_width + sc_width; + + editor.palette.x = (vp_width - palette_width) / 2; + } + } + + if (editor.palette.rows == -1) + { + int vp_height = viewport.playfield[GFX_SPECIAL_ARG_EDITOR].height; + int bt_height = graphic_info[IMG_EDITOR_PALETTE_BUTTON].height; + int tx_height = getFontHeight(FONT_TEXT_2); + + editor.palette.rows = (vp_height - tx_height) / bt_height; + + if (editor.palette.y == -1) + { + int palette_height = editor.palette.rows * bt_height + tx_height; + + editor.palette.y = (vp_height - palette_height) / 2; + } + } } static void LoadMenuDesignSettingsFromFilename(char *filename) @@ -10003,36 +10268,41 @@ static void LoadMenuDesignSettingsFromFilename(char *filename) // (e.g., init "menu.draw_xoffset.INFO" from "menu.draw_xoffset") for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++) { - char *value_1 = getHashEntry(setup_file_hash, "menu.draw_xoffset"); - char *value_2 = getHashEntry(setup_file_hash, "menu.draw_yoffset"); - char *value_3 = getHashEntry(setup_file_hash, "menu.list_size"); + struct TokenIntPtrInfo menu_config[] = + { + { "menu.draw_xoffset", &menu.draw_xoffset[i] }, + { "menu.draw_yoffset", &menu.draw_yoffset[i] }, + { "menu.list_size", &menu.list_size[i] } + }; + + for (j = 0; j < ARRAY_SIZE(menu_config); j++) + { + char *token = menu_config[j].token; + char *value = getHashEntry(setup_file_hash, token); - if (value_1 != NULL) - menu.draw_xoffset[i] = get_integer_from_string(value_1); - if (value_2 != NULL) - menu.draw_yoffset[i] = get_integer_from_string(value_2); - if (value_3 != NULL) - menu.list_size[i] = get_integer_from_string(value_3); + if (value != NULL) + *menu_config[j].value = get_integer_from_string(value); + } } // special case: initialize with default values that may be overwritten // (eg, init "menu.draw_xoffset.INFO[XXX]" from "menu.draw_xoffset.INFO") for (i = 0; i < NUM_SPECIAL_GFX_INFO_ARGS; i++) { - char *value_1 = getHashEntry(setup_file_hash, "menu.draw_xoffset.INFO"); - char *value_2 = getHashEntry(setup_file_hash, "menu.draw_yoffset.INFO"); - - if (value_1 != NULL) - menu.draw_xoffset_info[i] = get_integer_from_string(value_1); - if (value_2 != NULL) - menu.draw_yoffset_info[i] = get_integer_from_string(value_2); + struct TokenIntPtrInfo menu_config[] = + { + { "menu.draw_xoffset.INFO", &menu.draw_xoffset_info[i] }, + { "menu.draw_yoffset.INFO", &menu.draw_yoffset_info[i] }, + { "menu.list_size.INFO", &menu.list_size_info[i] } + }; - if (i == GFX_SPECIAL_ARG_INFO_ELEMENTS) + for (j = 0; j < ARRAY_SIZE(menu_config); j++) { - char *value_1 = getHashEntry(setup_file_hash, "menu.list_size.INFO"); + char *token = menu_config[j].token; + char *value = getHashEntry(setup_file_hash, token); - if (value_1 != NULL) - menu.list_size_info[i] = get_integer_from_string(value_1); + if (value != NULL) + *menu_config[j].value = get_integer_from_string(value); } } @@ -10040,179 +10310,131 @@ static void LoadMenuDesignSettingsFromFilename(char *filename) // (eg, init "menu.draw_xoffset.SETUP[XXX]" from "menu.draw_xoffset.SETUP") for (i = 0; i < NUM_SPECIAL_GFX_SETUP_ARGS; i++) { - char *value_1 = getHashEntry(setup_file_hash, "menu.draw_xoffset.SETUP"); - char *value_2 = getHashEntry(setup_file_hash, "menu.draw_yoffset.SETUP"); + struct TokenIntPtrInfo menu_config[] = + { + { "menu.draw_xoffset.SETUP", &menu.draw_xoffset_setup[i] }, + { "menu.draw_yoffset.SETUP", &menu.draw_yoffset_setup[i] } + }; + + for (j = 0; j < ARRAY_SIZE(menu_config); j++) + { + char *token = menu_config[j].token; + char *value = getHashEntry(setup_file_hash, token); - if (value_1 != NULL) - menu.draw_xoffset_setup[i] = get_integer_from_string(value_1); - if (value_2 != NULL) - menu.draw_yoffset_setup[i] = get_integer_from_string(value_2); + if (value != NULL) + *menu_config[j].value = get_integer_from_string(value); + } } // special case: initialize with default values that may be overwritten // (eg, init "menu.line_spacing.INFO[XXX]" from "menu.line_spacing.INFO") for (i = 0; i < NUM_SPECIAL_GFX_INFO_ARGS; i++) { - char *value_1 = getHashEntry(setup_file_hash,"menu.left_spacing.INFO"); - char *value_2 = getHashEntry(setup_file_hash,"menu.right_spacing.INFO"); - char *value_3 = getHashEntry(setup_file_hash,"menu.top_spacing.INFO"); - char *value_4 = getHashEntry(setup_file_hash,"menu.bottom_spacing.INFO"); - char *value_5 = getHashEntry(setup_file_hash,"menu.paragraph_spacing.INFO"); - char *value_6 = getHashEntry(setup_file_hash,"menu.headline1_spacing.INFO"); - char *value_7 = getHashEntry(setup_file_hash,"menu.headline2_spacing.INFO"); - char *value_8 = getHashEntry(setup_file_hash,"menu.line_spacing.INFO"); - char *value_9 = getHashEntry(setup_file_hash,"menu.extra_spacing.INFO"); - - if (value_1 != NULL) - menu.left_spacing_info[i] = get_integer_from_string(value_1); - if (value_2 != NULL) - menu.right_spacing_info[i] = get_integer_from_string(value_2); - if (value_3 != NULL) - menu.top_spacing_info[i] = get_integer_from_string(value_3); - if (value_4 != NULL) - menu.bottom_spacing_info[i] = get_integer_from_string(value_4); - if (value_5 != NULL) - menu.paragraph_spacing_info[i] = get_integer_from_string(value_5); - if (value_6 != NULL) - menu.headline1_spacing_info[i] = get_integer_from_string(value_6); - if (value_7 != NULL) - menu.headline2_spacing_info[i] = get_integer_from_string(value_7); - if (value_8 != NULL) - menu.line_spacing_info[i] = get_integer_from_string(value_8); - if (value_9 != NULL) - menu.extra_spacing_info[i] = get_integer_from_string(value_9); + struct TokenIntPtrInfo menu_config[] = + { + { "menu.left_spacing.INFO", &menu.left_spacing_info[i] }, + { "menu.right_spacing.INFO", &menu.right_spacing_info[i] }, + { "menu.top_spacing.INFO", &menu.top_spacing_info[i] }, + { "menu.bottom_spacing.INFO", &menu.bottom_spacing_info[i] }, + { "menu.paragraph_spacing.INFO", &menu.paragraph_spacing_info[i] }, + { "menu.headline1_spacing.INFO", &menu.headline1_spacing_info[i] }, + { "menu.headline2_spacing.INFO", &menu.headline2_spacing_info[i] }, + { "menu.line_spacing.INFO", &menu.line_spacing_info[i] }, + { "menu.extra_spacing.INFO", &menu.extra_spacing_info[i] }, + }; + + for (j = 0; j < ARRAY_SIZE(menu_config); j++) + { + char *token = menu_config[j].token; + char *value = getHashEntry(setup_file_hash, token); + + if (value != NULL) + *menu_config[j].value = get_integer_from_string(value); + } } // special case: initialize with default values that may be overwritten // (eg, init "menu.enter_screen.SCORES.xyz" from "menu.enter_screen.xyz") for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++) { - char *token_1 = "menu.enter_screen.fade_mode"; - char *token_2 = "menu.enter_screen.fade_delay"; - char *token_3 = "menu.enter_screen.post_delay"; - char *token_4 = "menu.leave_screen.fade_mode"; - char *token_5 = "menu.leave_screen.fade_delay"; - char *token_6 = "menu.leave_screen.post_delay"; - char *token_7 = "menu.next_screen.fade_mode"; - char *token_8 = "menu.next_screen.fade_delay"; - char *token_9 = "menu.next_screen.post_delay"; - char *value_1 = getHashEntry(setup_file_hash, token_1); - char *value_2 = getHashEntry(setup_file_hash, token_2); - char *value_3 = getHashEntry(setup_file_hash, token_3); - char *value_4 = getHashEntry(setup_file_hash, token_4); - char *value_5 = getHashEntry(setup_file_hash, token_5); - char *value_6 = getHashEntry(setup_file_hash, token_6); - char *value_7 = getHashEntry(setup_file_hash, token_7); - char *value_8 = getHashEntry(setup_file_hash, token_8); - char *value_9 = getHashEntry(setup_file_hash, token_9); - - if (value_1 != NULL) - menu.enter_screen[i].fade_mode = get_token_parameter_value(token_1, - value_1); - if (value_2 != NULL) - menu.enter_screen[i].fade_delay = get_token_parameter_value(token_2, - value_2); - if (value_3 != NULL) - menu.enter_screen[i].post_delay = get_token_parameter_value(token_3, - value_3); - if (value_4 != NULL) - menu.leave_screen[i].fade_mode = get_token_parameter_value(token_4, - value_4); - if (value_5 != NULL) - menu.leave_screen[i].fade_delay = get_token_parameter_value(token_5, - value_5); - if (value_6 != NULL) - menu.leave_screen[i].post_delay = get_token_parameter_value(token_6, - value_6); - if (value_7 != NULL) - menu.next_screen[i].fade_mode = get_token_parameter_value(token_7, - value_7); - if (value_8 != NULL) - menu.next_screen[i].fade_delay = get_token_parameter_value(token_8, - value_8); - if (value_9 != NULL) - menu.next_screen[i].post_delay = get_token_parameter_value(token_9, - value_9); + struct TokenIntPtrInfo menu_config[] = + { + { "menu.enter_screen.fade_mode", &menu.enter_screen[i].fade_mode }, + { "menu.enter_screen.fade_delay", &menu.enter_screen[i].fade_delay }, + { "menu.enter_screen.post_delay", &menu.enter_screen[i].post_delay }, + { "menu.leave_screen.fade_mode", &menu.leave_screen[i].fade_mode }, + { "menu.leave_screen.fade_delay", &menu.leave_screen[i].fade_delay }, + { "menu.leave_screen.post_delay", &menu.leave_screen[i].post_delay }, + { "menu.next_screen.fade_mode", &menu.next_screen[i].fade_mode }, + { "menu.next_screen.fade_delay", &menu.next_screen[i].fade_delay }, + { "menu.next_screen.post_delay", &menu.next_screen[i].post_delay } + }; + + for (j = 0; j < ARRAY_SIZE(menu_config); j++) + { + char *token = menu_config[j].token; + char *value = getHashEntry(setup_file_hash, token); + + if (value != NULL) + *menu_config[j].value = get_token_parameter_value(token, value); + } } // special case: initialize with default values that may be overwritten // (eg, init "viewport.door_1.MAIN.xyz" from "viewport.door_1.xyz") for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++) { - char *token_w1 = "viewport.window.width"; - char *token_w2 = "viewport.window.height"; - char *token_01 = "viewport.playfield.x"; - char *token_02 = "viewport.playfield.y"; - char *token_03 = "viewport.playfield.width"; - char *token_04 = "viewport.playfield.height"; - char *token_05 = "viewport.playfield.border_size"; - char *token_06 = "viewport.door_1.x"; - char *token_07 = "viewport.door_1.y"; - char *token_08 = "viewport.door_1.width"; - char *token_09 = "viewport.door_1.height"; - char *token_10 = "viewport.door_1.border_size"; - char *token_11 = "viewport.door_2.x"; - char *token_12 = "viewport.door_2.y"; - char *token_13 = "viewport.door_2.width"; - char *token_14 = "viewport.door_2.height"; - char *token_15 = "viewport.door_2.border_size"; - char *value_w1 = getHashEntry(setup_file_hash, token_w1); - char *value_w2 = getHashEntry(setup_file_hash, token_w2); - char *value_01 = getHashEntry(setup_file_hash, token_01); - char *value_02 = getHashEntry(setup_file_hash, token_02); - char *value_03 = getHashEntry(setup_file_hash, token_03); - char *value_04 = getHashEntry(setup_file_hash, token_04); - char *value_05 = getHashEntry(setup_file_hash, token_05); - char *value_06 = getHashEntry(setup_file_hash, token_06); - char *value_07 = getHashEntry(setup_file_hash, token_07); - char *value_08 = getHashEntry(setup_file_hash, token_08); - char *value_09 = getHashEntry(setup_file_hash, token_09); - char *value_10 = getHashEntry(setup_file_hash, token_10); - char *value_11 = getHashEntry(setup_file_hash, token_11); - char *value_12 = getHashEntry(setup_file_hash, token_12); - char *value_13 = getHashEntry(setup_file_hash, token_13); - char *value_14 = getHashEntry(setup_file_hash, token_14); - char *value_15 = getHashEntry(setup_file_hash, token_15); - - if (value_w1 != NULL) - viewport.window[i].width = get_token_parameter_value(token_w1, value_w1); - if (value_w2 != NULL) - viewport.window[i].height = get_token_parameter_value(token_w2, value_w2); - if (value_01 != NULL) - viewport.playfield[i].x = get_token_parameter_value(token_01, value_01); - if (value_02 != NULL) - viewport.playfield[i].y = get_token_parameter_value(token_02, value_02); - if (value_03 != NULL) - viewport.playfield[i].width = get_token_parameter_value(token_03, - value_03); - if (value_04 != NULL) - viewport.playfield[i].height = get_token_parameter_value(token_04, - value_04); - if (value_05 != NULL) - viewport.playfield[i].border_size = get_token_parameter_value(token_05, - value_05); - if (value_06 != NULL) - viewport.door_1[i].x = get_token_parameter_value(token_06, value_06); - if (value_07 != NULL) - viewport.door_1[i].y = get_token_parameter_value(token_07, value_07); - if (value_08 != NULL) - viewport.door_1[i].width = get_token_parameter_value(token_08, value_08); - if (value_09 != NULL) - viewport.door_1[i].height = get_token_parameter_value(token_09, value_09); - if (value_10 != NULL) - viewport.door_1[i].border_size = get_token_parameter_value(token_10, - value_10); - if (value_11 != NULL) - viewport.door_2[i].x = get_token_parameter_value(token_11, value_11); - if (value_12 != NULL) - viewport.door_2[i].y = get_token_parameter_value(token_12, value_12); - if (value_13 != NULL) - viewport.door_2[i].width = get_token_parameter_value(token_13, value_13); - if (value_14 != NULL) - viewport.door_2[i].height = get_token_parameter_value(token_14, value_14); - if (value_15 != NULL) - viewport.door_1[i].border_size = get_token_parameter_value(token_15, - value_15); + struct + { + char *token_prefix; + struct RectWithBorder *struct_ptr; + } + vp_struct[] = + { + { "viewport.window", &viewport.window[i] }, + { "viewport.playfield", &viewport.playfield[i] }, + { "viewport.door_1", &viewport.door_1[i] }, + { "viewport.door_2", &viewport.door_2[i] } + }; + + for (j = 0; j < ARRAY_SIZE(vp_struct); j++) + { + struct TokenIntPtrInfo vp_config[] = + { + { ".x", &vp_struct[j].struct_ptr->x }, + { ".y", &vp_struct[j].struct_ptr->y }, + { ".width", &vp_struct[j].struct_ptr->width }, + { ".height", &vp_struct[j].struct_ptr->height }, + { ".min_width", &vp_struct[j].struct_ptr->min_width }, + { ".min_height", &vp_struct[j].struct_ptr->min_height }, + { ".max_width", &vp_struct[j].struct_ptr->max_width }, + { ".max_height", &vp_struct[j].struct_ptr->max_height }, + { ".margin_left", &vp_struct[j].struct_ptr->margin_left }, + { ".margin_right", &vp_struct[j].struct_ptr->margin_right }, + { ".margin_top", &vp_struct[j].struct_ptr->margin_top }, + { ".margin_bottom", &vp_struct[j].struct_ptr->margin_bottom }, + { ".border_left", &vp_struct[j].struct_ptr->border_left }, + { ".border_right", &vp_struct[j].struct_ptr->border_right }, + { ".border_top", &vp_struct[j].struct_ptr->border_top }, + { ".border_bottom", &vp_struct[j].struct_ptr->border_bottom }, + { ".border_size", &vp_struct[j].struct_ptr->border_size }, + { ".align_size", &vp_struct[j].struct_ptr->align_size }, + { ".align", &vp_struct[j].struct_ptr->align }, + { ".valign", &vp_struct[j].struct_ptr->valign } + }; + + for (k = 0; k < ARRAY_SIZE(vp_config); k++) + { + char *token = getStringCat2(vp_struct[j].token_prefix, + vp_config[k].token); + char *value = getHashEntry(setup_file_hash, token); + + if (value != NULL) + *vp_config[k].value = get_token_parameter_value(token, value); + + free(token); + } + } } // special case: initialize with default values that may be overwritten @@ -11043,7 +11265,6 @@ void ConvertLevels(void) void CreateLevelSketchImages(void) { -#if defined(TARGET_SDL) Bitmap *bitmap1; Bitmap *bitmap2; int i; @@ -11099,7 +11320,6 @@ void CreateLevelSketchImages(void) Error(ERR_INFO, "%d normal and small images created", NUM_FILE_ELEMENTS); CloseAllAndExit(0); -#endif } @@ -11109,7 +11329,6 @@ void CreateLevelSketchImages(void) void CreateCustomElementImages(char *directory) { -#if defined(TARGET_SDL) char *src_basename = "RocksCE-template.ilbm"; char *dst_basename = "RocksCE.bmp"; char *src_filename = getPath2(directory, src_basename); @@ -11201,5 +11420,4 @@ void CreateCustomElementImages(char *directory) FreeBitmap(bitmap); CloseAllAndExit(0); -#endif }