X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ffiles.c;h=eb33f7dc73c8775d99a9496703815bfcac7450fe;hp=f2ff5d21d3b651f05f2f664699ce2e959dc4bd9f;hb=89401883eeb279c7101b1c635477a9bccc123d21;hpb=7ec31aa5be2feaf42ce3deef16e421af32ab48db diff --git a/src/files.c b/src/files.c index f2ff5d21..eb33f7dc 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; } } @@ -7862,6 +7867,7 @@ void LoadScore(int nr) void SaveScore(int nr) { int i; + int permissions = (program.global_scores ? PERMS_PUBLIC : PERMS_PRIVATE); char *filename = getScoreFilename(nr); FILE *file; @@ -7880,7 +7886,7 @@ void SaveScore(int nr) fclose(file); - SetFilePermissions(filename, PERMS_PUBLIC); + SetFilePermissions(filename, permissions); } @@ -7938,25 +7944,14 @@ void SaveScore(int nr) #define NUM_GLOBAL_SETUP_TOKENS 43 /* editor setup */ -#define SETUP_TOKEN_EDITOR_EL_BOULDERDASH 0 -#define SETUP_TOKEN_EDITOR_EL_EMERALD_MINE 1 -#define SETUP_TOKEN_EDITOR_EL_EMERALD_MINE_CLUB 2 -#define SETUP_TOKEN_EDITOR_EL_MORE 3 -#define SETUP_TOKEN_EDITOR_EL_SOKOBAN 4 -#define SETUP_TOKEN_EDITOR_EL_SUPAPLEX 5 -#define SETUP_TOKEN_EDITOR_EL_DIAMOND_CAVES 6 -#define SETUP_TOKEN_EDITOR_EL_DX_BOULDERDASH 7 -#define SETUP_TOKEN_EDITOR_EL_CHARS 8 -#define SETUP_TOKEN_EDITOR_EL_STEEL_CHARS 9 -#define SETUP_TOKEN_EDITOR_EL_CUSTOM 10 -#define SETUP_TOKEN_EDITOR_EL_HEADLINES 11 -#define SETUP_TOKEN_EDITOR_EL_USER_DEFINED 12 -#define SETUP_TOKEN_EDITOR_EL_DYNAMIC 13 -#define SETUP_TOKEN_EDITOR_EL_BY_GAME 14 -#define SETUP_TOKEN_EDITOR_EL_BY_TYPE 15 -#define SETUP_TOKEN_EDITOR_SHOW_ELEMENT_TOKEN 16 - -#define NUM_EDITOR_SETUP_TOKENS 17 +#define SETUP_TOKEN_EDITOR_EL_CHARS 0 +#define SETUP_TOKEN_EDITOR_EL_STEEL_CHARS 1 +#define SETUP_TOKEN_EDITOR_EL_CUSTOM 2 +#define SETUP_TOKEN_EDITOR_EL_USER_DEFINED 3 +#define SETUP_TOKEN_EDITOR_EL_DYNAMIC 4 +#define SETUP_TOKEN_EDITOR_SHOW_ELEMENT_TOKEN 5 + +#define NUM_EDITOR_SETUP_TOKENS 6 /* editor cascade setup */ #define SETUP_TOKEN_EDITOR_CASCADE_BD 0 @@ -8141,22 +8136,11 @@ static struct TokenInfo global_setup_tokens[] = static struct TokenInfo editor_setup_tokens[] = { - { TYPE_SWITCH, &sei.el_boulderdash, "editor.el_boulderdash" }, - { TYPE_SWITCH, &sei.el_emerald_mine, "editor.el_emerald_mine" }, - { TYPE_SWITCH, &sei.el_emerald_mine_club,"editor.el_emerald_mine_club"}, - { TYPE_SWITCH, &sei.el_more, "editor.el_more" }, - { TYPE_SWITCH, &sei.el_sokoban, "editor.el_sokoban" }, - { TYPE_SWITCH, &sei.el_supaplex, "editor.el_supaplex" }, - { TYPE_SWITCH, &sei.el_diamond_caves, "editor.el_diamond_caves" }, - { TYPE_SWITCH, &sei.el_dx_boulderdash,"editor.el_dx_boulderdash" }, { TYPE_SWITCH, &sei.el_chars, "editor.el_chars" }, { TYPE_SWITCH, &sei.el_steel_chars, "editor.el_steel_chars" }, { TYPE_SWITCH, &sei.el_custom, "editor.el_custom" }, - { TYPE_SWITCH, &sei.el_headlines, "editor.el_headlines" }, { TYPE_SWITCH, &sei.el_user_defined, "editor.el_user_defined" }, { TYPE_SWITCH, &sei.el_dynamic, "editor.el_dynamic" }, - { TYPE_SWITCH, &sei.el_by_game, "editor.el_by_game" }, - { TYPE_SWITCH, &sei.el_by_type, "editor.el_by_type" }, { TYPE_SWITCH, &sei.show_element_token,"editor.show_element_token" }, }; @@ -8966,12 +8950,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[] = + { + { + &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 + }, { - (*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_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; } } } @@ -9359,6 +9379,11 @@ void LoadMenuDesignSettings() InitMenuDesignSettings_SpecialPostProcessing(); } +void LoadMenuDesignSettings_AfterGraphics() +{ + InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics(); +} + void LoadUserDefinedEditorElementList(int **elements, int *num_elements) { char *filename = getEditorSetupFilename(); @@ -10163,6 +10188,8 @@ void CreateCustomElementImages(char *directory) SDLInitVideoDisplay(); + ReCreateBitmap(&backbuffer, video.width, video.height); + src_bitmap = LoadImage(src_filename); bitmap = CreateBitmap(TILEX * 16 * 2,