X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ffiles.c;h=c0f256c73c27016f42c2af688f47f97cc0769111;hp=97934c17f5dc1d13397c4aab2257310a3993f06a;hb=8d71e6fb8309bd90ce5f2900d84c686b17950492;hpb=e73cc9fa0feac62a97f7bb0bf0346cdf2134c249 diff --git a/src/files.c b/src/files.c index 97934c17..c0f256c7 100644 --- a/src/files.c +++ b/src/files.c @@ -1786,10 +1786,41 @@ static void setFileInfoToDefaults(struct LevelFileInfo *level_file_info) level_file_info->filename = NULL; } +int getMappedElement_SB(int, boolean); + static void ActivateLevelTemplate() { int x, y; + if (check_special_flags("load_xsb_to_ces")) + { + /* fill smaller playfields with padding "beyond border wall" elements */ + if (level.fieldx < level_template.fieldx || + level.fieldy < level_template.fieldy) + { + short field[level.fieldx][level.fieldy]; + int new_fieldx = MAX(level.fieldx, level_template.fieldx); + int new_fieldy = MAX(level.fieldy, level_template.fieldy); + int pos_fieldx = (new_fieldx - level.fieldx) / 2; + int pos_fieldy = (new_fieldy - level.fieldy) / 2; + + /* copy old playfield (which is smaller than the visible area) */ + for (y = 0; y < level.fieldy; y++) for (x = 0; x < level.fieldx; x++) + field[x][y] = level.field[x][y]; + + /* fill new, larger playfield with "beyond border wall" elements */ + for (y = 0; y < new_fieldy; y++) for (x = 0; x < new_fieldx; x++) + level.field[x][y] = getMappedElement_SB('_', TRUE); + + /* copy the old playfield to the middle of the new playfield */ + for (y = 0; y < level.fieldy; y++) for (x = 0; x < level.fieldx; x++) + level.field[pos_fieldx + x][pos_fieldy + y] = field[x][y]; + + level.fieldx = new_fieldx; + level.fieldy = new_fieldy; + } + } + /* Currently there is no special action needed to activate the template data, because 'element_info' property settings overwrite the original level data, while all other variables do not change. */ @@ -5756,32 +5787,6 @@ static void LoadLevelFromFileInfo_SB(struct LevelInfo *level, { /* special global settings can now be set in level template */ - /* fill smaller playfields with padding "beyond border wall" elements */ - if (level->fieldx < SCR_FIELDX || - level->fieldy < SCR_FIELDY) - { - short field[level->fieldx][level->fieldy]; - int new_fieldx = MAX(level->fieldx, SCR_FIELDX); - int new_fieldy = MAX(level->fieldy, SCR_FIELDY); - int pos_fieldx = (new_fieldx - level->fieldx) / 2; - int pos_fieldy = (new_fieldy - level->fieldy) / 2; - - /* copy old playfield (which is smaller than the visible area) */ - for (y = 0; y < level->fieldy; y++) for (x = 0; x < level->fieldx; x++) - field[x][y] = level->field[x][y]; - - /* fill new, larger playfield with "beyond border wall" elements */ - for (y = 0; y < new_fieldy; y++) for (x = 0; x < new_fieldx; x++) - level->field[x][y] = getMappedElement_SB('_', load_xsb_to_ces); - - /* copy the old playfield to the middle of the new playfield */ - for (y = 0; y < level->fieldy; y++) for (x = 0; x < level->fieldx; x++) - level->field[pos_fieldx + x][pos_fieldy + y] = field[x][y]; - - level->fieldx = new_fieldx; - level->fieldy = new_fieldy; - } - level->use_custom_template = TRUE; } } @@ -8050,6 +8055,32 @@ void SaveScore(int nr) #define NUM_INTERNAL_SETUP_TOKENS 17 +/* debug setup */ +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_0 0 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_1 1 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_2 2 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_3 3 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_4 4 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_5 5 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_6 6 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_7 7 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_8 8 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_9 9 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_0 10 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_1 11 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_2 12 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_3 13 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_4 14 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_5 15 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_6 16 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_7 17 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_8 18 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_9 19 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_USE_MOD_KEY 20 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_GAME_ONLY 21 + +#define NUM_DEBUG_SETUP_TOKENS 22 + /* options setup */ #define SETUP_TOKEN_OPTIONS_VERBOSE 0 @@ -8063,6 +8094,7 @@ static struct SetupShortcutInfo ssi; static struct SetupInputInfo sii; static struct SetupSystemInfo syi; static struct SetupInternalInfo sxi; +static struct SetupDebugInfo sdi; static struct OptionInfo soi; static struct TokenInfo global_setup_tokens[] = @@ -8225,6 +8257,32 @@ static struct TokenInfo internal_setup_tokens[] = { TYPE_INTEGER,&sxi.default_window_height, "default_window_height" }, }; +static struct TokenInfo debug_setup_tokens[] = +{ + { TYPE_INTEGER, &sdi.frame_delay[0], "debug.frame_delay_0" }, + { TYPE_INTEGER, &sdi.frame_delay[1], "debug.frame_delay_1" }, + { TYPE_INTEGER, &sdi.frame_delay[2], "debug.frame_delay_2" }, + { TYPE_INTEGER, &sdi.frame_delay[3], "debug.frame_delay_3" }, + { TYPE_INTEGER, &sdi.frame_delay[4], "debug.frame_delay_4" }, + { TYPE_INTEGER, &sdi.frame_delay[5], "debug.frame_delay_5" }, + { TYPE_INTEGER, &sdi.frame_delay[6], "debug.frame_delay_6" }, + { TYPE_INTEGER, &sdi.frame_delay[7], "debug.frame_delay_7" }, + { TYPE_INTEGER, &sdi.frame_delay[8], "debug.frame_delay_8" }, + { TYPE_INTEGER, &sdi.frame_delay[9], "debug.frame_delay_9" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[0], "debug.key.frame_delay_0" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[1], "debug.key.frame_delay_1" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[2], "debug.key.frame_delay_2" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[3], "debug.key.frame_delay_3" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[4], "debug.key.frame_delay_4" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[5], "debug.key.frame_delay_5" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[6], "debug.key.frame_delay_6" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[7], "debug.key.frame_delay_7" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[8], "debug.key.frame_delay_8" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[9], "debug.key.frame_delay_9" }, + { TYPE_BOOLEAN, &sdi.frame_delay_use_mod_key,"debug.frame_delay.use_mod_key"}, + { TYPE_BOOLEAN, &sdi.frame_delay_game_only, "debug.frame_delay.game_only" }, +}; + static struct TokenInfo options_setup_tokens[] = { { TYPE_BOOLEAN, &soi.verbose, "options.verbose" }, @@ -8389,6 +8447,31 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->internal.default_window_width = WIN_XSIZE_DEFAULT; si->internal.default_window_height = WIN_YSIZE_DEFAULT; + si->debug.frame_delay[0] = DEFAULT_FRAME_DELAY_0; + si->debug.frame_delay[1] = DEFAULT_FRAME_DELAY_1; + si->debug.frame_delay[2] = DEFAULT_FRAME_DELAY_2; + si->debug.frame_delay[3] = DEFAULT_FRAME_DELAY_3; + si->debug.frame_delay[4] = DEFAULT_FRAME_DELAY_4; + si->debug.frame_delay[5] = DEFAULT_FRAME_DELAY_5; + si->debug.frame_delay[6] = DEFAULT_FRAME_DELAY_6; + si->debug.frame_delay[7] = DEFAULT_FRAME_DELAY_7; + si->debug.frame_delay[8] = DEFAULT_FRAME_DELAY_8; + si->debug.frame_delay[9] = DEFAULT_FRAME_DELAY_9; + + si->debug.frame_delay_key[0] = DEFAULT_KEY_FRAME_DELAY_0; + si->debug.frame_delay_key[1] = DEFAULT_KEY_FRAME_DELAY_1; + si->debug.frame_delay_key[2] = DEFAULT_KEY_FRAME_DELAY_2; + si->debug.frame_delay_key[3] = DEFAULT_KEY_FRAME_DELAY_3; + si->debug.frame_delay_key[4] = DEFAULT_KEY_FRAME_DELAY_4; + si->debug.frame_delay_key[5] = DEFAULT_KEY_FRAME_DELAY_5; + si->debug.frame_delay_key[6] = DEFAULT_KEY_FRAME_DELAY_6; + si->debug.frame_delay_key[7] = DEFAULT_KEY_FRAME_DELAY_7; + si->debug.frame_delay_key[8] = DEFAULT_KEY_FRAME_DELAY_8; + si->debug.frame_delay_key[9] = DEFAULT_KEY_FRAME_DELAY_9; + + si->debug.frame_delay_use_mod_key = DEFAULT_FRAME_DELAY_USE_MOD_KEY; + si->debug.frame_delay_game_only = DEFAULT_FRAME_DELAY_GAME_ONLY; + si->options.verbose = FALSE; #if defined(PLATFORM_ANDROID) @@ -8477,6 +8560,13 @@ static void decodeSetupFileHash(SetupFileHash *setup_file_hash) getHashEntry(setup_file_hash, internal_setup_tokens[i].text)); setup.internal = sxi; + /* debug setup */ + sdi = setup.debug; + for (i = 0; i < NUM_DEBUG_SETUP_TOKENS; i++) + setSetupInfo(debug_setup_tokens, i, + getHashEntry(setup_file_hash, debug_setup_tokens[i].text)); + setup.debug = sdi; + /* options setup */ soi = setup.options; for (i = 0; i < NUM_OPTIONS_SETUP_TOKENS; i++) @@ -8643,6 +8733,12 @@ void SaveSetup() /* internal setup */ /* (internal setup values not saved to user setup file) */ + /* debug setup */ + sdi = setup.debug; + fprintf(file, "\n"); + for (i = 0; i < NUM_DEBUG_SETUP_TOKENS; i++) + fprintf(file, "%s\n", getSetupLine(debug_setup_tokens, "", i)); + /* options setup */ soi = setup.options; fprintf(file, "\n"); @@ -8875,12 +8971,48 @@ static void InitMenuDesignSettings_SpecialPostProcessing() /* set default position for snapshot buttons to stop/pause/play buttons */ for (i = 0; game_buttons_xy[i].dst != NULL; i++) - { 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; +} + +static void InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics() +{ + static struct + { + struct XYTileSize *dst, *src; + int graphic; + } + editor_buttons_xy[] = + { { - (*game_buttons_xy[i].dst).x = (*game_buttons_xy[i].src).x; - (*game_buttons_xy[i].dst).y = (*game_buttons_xy[i].src).y; + &editor.button.element_left, &editor.palette.element_left, + IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT + }, + { + &editor.button.element_middle, &editor.palette.element_middle, + IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE + }, + { + &editor.button.element_right, &editor.palette.element_right, + IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT + }, + + { NULL, NULL } + }; + int i; + + /* set default position for element buttons to element graphics */ + for (i = 0; editor_buttons_xy[i].dst != NULL; i++) + { + if ((*editor_buttons_xy[i].dst).x == -1 && + (*editor_buttons_xy[i].dst).y == -1) + { + struct GraphicInfo *gd = &graphic_info[editor_buttons_xy[i].graphic]; + + gd->width = gd->height = editor_buttons_xy[i].src->tile_size; + + *editor_buttons_xy[i].dst = *editor_buttons_xy[i].src; } } } @@ -9268,6 +9400,11 @@ void LoadMenuDesignSettings() InitMenuDesignSettings_SpecialPostProcessing(); } +void LoadMenuDesignSettings_AfterGraphics() +{ + InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics(); +} + void LoadUserDefinedEditorElementList(int **elements, int *num_elements) { char *filename = getEditorSetupFilename(); @@ -9905,15 +10042,15 @@ void ConvertLevels() convert_level_nr = convert_leveldir->first_level; - printf_line("=", 79); - printf("Converting levels\n"); - printf_line("-", 79); - printf("Level series identifier: '%s'\n", convert_leveldir->identifier); - printf("Level series name: '%s'\n", convert_leveldir->name); - printf("Level series author: '%s'\n", convert_leveldir->author); - printf("Number of levels: %d\n", convert_leveldir->levels); - printf_line("=", 79); - printf("\n"); + PrintLine("=", 79); + Print("Converting levels\n"); + PrintLine("-", 79); + Print("Level series identifier: '%s'\n", convert_leveldir->identifier); + Print("Level series name: '%s'\n", convert_leveldir->name); + Print("Level series author: '%s'\n", convert_leveldir->author); + Print("Number of levels: %d\n", convert_leveldir->levels); + PrintLine("=", 79); + Print("\n"); for (i = 0; i < MAX_NUM_CONVERT_LEVELS; i++) levels_failed[i] = FALSE; @@ -9925,16 +10062,16 @@ void ConvertLevels() level_nr = convert_level_nr++; - printf("Level %03d: ", level_nr); + Print("Level %03d: ", level_nr); LoadLevel(level_nr); if (level.no_valid_file) { - printf("(no level)\n"); + Print("(no level)\n"); continue; } - printf("converting level ... "); + Print("converting level ... "); level_filename = getDefaultLevelFilename(level_nr); new_level = !fileExists(level_filename); @@ -9945,28 +10082,28 @@ void ConvertLevels() num_levels_converted++; - printf("converted.\n"); + Print("converted.\n"); } else { if (level_nr >= 0 && level_nr < MAX_NUM_CONVERT_LEVELS) levels_failed[level_nr] = TRUE; - printf("NOT CONVERTED -- LEVEL ALREADY EXISTS.\n"); + Print("NOT CONVERTED -- LEVEL ALREADY EXISTS.\n"); } num_levels_handled++; } - printf("\n"); - printf_line("=", 79); - printf("Number of levels handled: %d\n", num_levels_handled); - printf("Number of levels converted: %d (%d%%)\n", num_levels_converted, + Print("\n"); + PrintLine("=", 79); + Print("Number of levels handled: %d\n", num_levels_handled); + Print("Number of levels converted: %d (%d%%)\n", num_levels_converted, (num_levels_handled ? num_levels_converted * 100 / num_levels_handled : 0)); - printf_line("-", 79); - printf("Summary (for automatic parsing by scripts):\n"); - printf("LEVELDIR '%s', CONVERTED %d/%d (%d%%)", + PrintLine("-", 79); + Print("Summary (for automatic parsing by scripts):\n"); + Print("LEVELDIR '%s', CONVERTED %d/%d (%d%%)", convert_leveldir->identifier, num_levels_converted, num_levels_handled, (num_levels_handled ? @@ -9974,14 +10111,14 @@ void ConvertLevels() if (num_levels_handled != num_levels_converted) { - printf(", FAILED:"); + Print(", FAILED:"); for (i = 0; i < MAX_NUM_CONVERT_LEVELS; i++) if (levels_failed[i]) - printf(" %03d", i); + Print(" %03d", i); } - printf("\n"); - printf_line("=", 79); + Print("\n"); + PrintLine("=", 79); CloseAllAndExit(0); }