From: Holger Schemel Date: Mon, 30 Mar 2015 13:08:16 +0000 (+0200) Subject: added setting engine snapshot mode to setup screen and file X-Git-Tag: 4.0.0.0-rc1~221 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=9fa601d400aa71f38fcdc19eaf107f42e0d2a2a3;p=rocksndiamonds.git added setting engine snapshot mode to setup screen and file --- diff --git a/src/files.c b/src/files.c index e17322d6..4dab8195 100644 --- a/src/files.c +++ b/src/files.c @@ -7892,41 +7892,42 @@ void SaveScore(int nr) #define SETUP_TOKEN_TOONS 5 #define SETUP_TOKEN_SCROLL_DELAY 6 #define SETUP_TOKEN_SCROLL_DELAY_VALUE 7 -#define SETUP_TOKEN_SOFT_SCROLLING 8 -#define SETUP_TOKEN_FADE_SCREENS 9 -#define SETUP_TOKEN_AUTORECORD 10 -#define SETUP_TOKEN_SHOW_TITLESCREEN 11 -#define SETUP_TOKEN_QUICK_DOORS 12 -#define SETUP_TOKEN_TEAM_MODE 13 -#define SETUP_TOKEN_HANDICAP 14 -#define SETUP_TOKEN_SKIP_LEVELS 15 -#define SETUP_TOKEN_TIME_LIMIT 16 -#define SETUP_TOKEN_FULLSCREEN 17 -#define SETUP_TOKEN_FULLSCREEN_MODE 18 -#define SETUP_TOKEN_WINDOW_SCALING_PERCENT 19 -#define SETUP_TOKEN_WINDOW_SCALING_QUALITY 20 -#define SETUP_TOKEN_ASK_ON_ESCAPE 21 -#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR 22 -#define SETUP_TOKEN_QUICK_SWITCH 23 -#define SETUP_TOKEN_INPUT_ON_FOCUS 24 -#define SETUP_TOKEN_PREFER_AGA_GRAPHICS 25 -#define SETUP_TOKEN_GAME_FRAME_DELAY 26 -#define SETUP_TOKEN_SP_SHOW_BORDER_ELEMENTS 27 -#define SETUP_TOKEN_SMALL_GAME_GRAPHICS 28 -#define SETUP_TOKEN_GRAPHICS_SET 29 -#define SETUP_TOKEN_SOUNDS_SET 30 -#define SETUP_TOKEN_MUSIC_SET 31 -#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 32 -#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 33 -#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 34 -#define SETUP_TOKEN_VOLUME_SIMPLE 35 -#define SETUP_TOKEN_VOLUME_LOOPS 36 -#define SETUP_TOKEN_VOLUME_MUSIC 37 -#define SETUP_TOKEN_TOUCH_CONTROL_TYPE 38 -#define SETUP_TOKEN_TOUCH_MOVE_DISTANCE 39 -#define SETUP_TOKEN_TOUCH_DROP_DISTANCE 40 - -#define NUM_GLOBAL_SETUP_TOKENS 41 +#define SETUP_TOKEN_ENGINE_SNAPSHOT_MODE 8 +#define SETUP_TOKEN_SOFT_SCROLLING 9 +#define SETUP_TOKEN_FADE_SCREENS 10 +#define SETUP_TOKEN_AUTORECORD 11 +#define SETUP_TOKEN_SHOW_TITLESCREEN 12 +#define SETUP_TOKEN_QUICK_DOORS 13 +#define SETUP_TOKEN_TEAM_MODE 14 +#define SETUP_TOKEN_HANDICAP 15 +#define SETUP_TOKEN_SKIP_LEVELS 16 +#define SETUP_TOKEN_TIME_LIMIT 17 +#define SETUP_TOKEN_FULLSCREEN 18 +#define SETUP_TOKEN_FULLSCREEN_MODE 19 +#define SETUP_TOKEN_WINDOW_SCALING_PERCENT 20 +#define SETUP_TOKEN_WINDOW_SCALING_QUALITY 21 +#define SETUP_TOKEN_ASK_ON_ESCAPE 22 +#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR 23 +#define SETUP_TOKEN_QUICK_SWITCH 24 +#define SETUP_TOKEN_INPUT_ON_FOCUS 25 +#define SETUP_TOKEN_PREFER_AGA_GRAPHICS 26 +#define SETUP_TOKEN_GAME_FRAME_DELAY 27 +#define SETUP_TOKEN_SP_SHOW_BORDER_ELEMENTS 28 +#define SETUP_TOKEN_SMALL_GAME_GRAPHICS 29 +#define SETUP_TOKEN_GRAPHICS_SET 30 +#define SETUP_TOKEN_SOUNDS_SET 31 +#define SETUP_TOKEN_MUSIC_SET 32 +#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 33 +#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 34 +#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 35 +#define SETUP_TOKEN_VOLUME_SIMPLE 36 +#define SETUP_TOKEN_VOLUME_LOOPS 37 +#define SETUP_TOKEN_VOLUME_MUSIC 38 +#define SETUP_TOKEN_TOUCH_CONTROL_TYPE 39 +#define SETUP_TOKEN_TOUCH_MOVE_DISTANCE 40 +#define SETUP_TOKEN_TOUCH_DROP_DISTANCE 41 + +#define NUM_GLOBAL_SETUP_TOKENS 42 /* editor setup */ #define SETUP_TOKEN_EDITOR_EL_BOULDERDASH 0 @@ -8044,6 +8045,7 @@ static struct TokenInfo global_setup_tokens[] = { TYPE_SWITCH, &si.toons, "toons" }, { TYPE_SWITCH, &si.scroll_delay, "scroll_delay" }, { TYPE_INTEGER,&si.scroll_delay_value, "scroll_delay_value" }, + { TYPE_STRING, &si.engine_snapshot_mode, "engine_snapshot_mode" }, { TYPE_SWITCH, &si.soft_scrolling, "soft_scrolling" }, { TYPE_SWITCH, &si.fade_screens, "fade_screens" }, { TYPE_SWITCH, &si.autorecord, "automatic_tape_recording"}, @@ -8204,6 +8206,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->toons = TRUE; si->scroll_delay = TRUE; si->scroll_delay_value = STD_SCROLL_DELAY; + si->engine_snapshot_mode = getStringCopy(STR_SNAPSHOT_MODE_DEFAULT); si->soft_scrolling = TRUE; si->fade_screens = TRUE; si->autorecord = TRUE; diff --git a/src/game.c b/src/game.c index eeb12767..82931d3f 100644 --- a/src/game.c +++ b/src/game.c @@ -3039,7 +3039,11 @@ static void InitGameEngine() for (i = 0; i < MAX_PLAYERS; i++) game.snapshot.last_action[i] = 0; game.snapshot.changed_action = FALSE; - game.snapshot.mode = SNAPSHOT_MODE_MOVE; + game.snapshot.mode = + (strEqual(setup.engine_snapshot_mode, STR_SNAPSHOT_MODE_EVERY_STEP) ? + SNAPSHOT_MODE_EVERY_STEP : + strEqual(setup.engine_snapshot_mode, STR_SNAPSHOT_MODE_EVERY_MOVE) ? + SNAPSHOT_MODE_EVERY_MOVE : SNAPSHOT_MODE_OFF); FreeEngineSnapshotList(); } @@ -14752,13 +14756,13 @@ boolean SaveEngineSnapshotToList() { boolean save_snapshot = (FrameCounter == 0 || - (game.snapshot.mode == SNAPSHOT_MODE_STEP) || - (game.snapshot.mode == SNAPSHOT_MODE_MOVE && + (game.snapshot.mode == SNAPSHOT_MODE_EVERY_STEP) || + (game.snapshot.mode == SNAPSHOT_MODE_EVERY_MOVE && game.snapshot.changed_action)); game.snapshot.changed_action = FALSE; - if (!save_snapshot) + if (game.snapshot.mode == SNAPSHOT_MODE_OFF || !save_snapshot) return FALSE; ListNode *buffers = SaveEngineSnapshotBuffers(); @@ -14802,12 +14806,17 @@ void LoadEngineSnapshot_Redo(int steps) LoadEngineSnapshotValues(); } -boolean CheckEngineSnapshot() +boolean CheckEngineSnapshotSingle() { return (strEqual(snapshot_level_identifier, leveldir_current->identifier) && snapshot_level_nr == level_nr); } +boolean CheckEngineSnapshotList() +{ + return CheckSnapshotList(); +} + /* ---------- new game button stuff ---------------------------------------- */ @@ -15019,7 +15028,7 @@ void GameUndoRedoExt() void GameUndo(int steps) { - if (!CheckEngineSnapshot()) + if (!CheckEngineSnapshotList()) return; LoadEngineSnapshot_Undo(steps); @@ -15029,7 +15038,7 @@ void GameUndo(int steps) void GameRedo(int steps) { - if (!CheckEngineSnapshot()) + if (!CheckEngineSnapshotList()) return; LoadEngineSnapshot_Redo(steps); diff --git a/src/game.h b/src/game.h index ae0a1cc1..e334dcc6 100644 --- a/src/game.h +++ b/src/game.h @@ -15,21 +15,28 @@ /* (not included here due to collisions with Emerald Mine engine definitions) */ /* #include "main.h" */ -#define MAX_INVENTORY_SIZE 1000 +#define MAX_INVENTORY_SIZE 1000 -#define STD_NUM_KEYS 4 -#define MAX_NUM_KEYS 8 +#define STD_NUM_KEYS 4 +#define MAX_NUM_KEYS 8 -#define NUM_BELTS 4 -#define NUM_BELT_PARTS 3 +#define NUM_BELTS 4 +#define NUM_BELT_PARTS 3 -#define NUM_PANEL_INVENTORY 8 -#define NUM_PANEL_GRAPHICS 8 -#define NUM_PANEL_ELEMENTS 8 -#define NUM_PANEL_CE_SCORE 8 +#define NUM_PANEL_INVENTORY 8 +#define NUM_PANEL_GRAPHICS 8 +#define NUM_PANEL_ELEMENTS 8 +#define NUM_PANEL_CE_SCORE 8 -#define SNAPSHOT_MODE_STEP 0 -#define SNAPSHOT_MODE_MOVE 1 +#define STR_SNAPSHOT_MODE_OFF "off" +#define STR_SNAPSHOT_MODE_EVERY_STEP "every_step" +#define STR_SNAPSHOT_MODE_EVERY_MOVE "every_move" +#define STR_SNAPSHOT_MODE_DEFAULT STR_SNAPSHOT_MODE_EVERY_MOVE + +#define SNAPSHOT_MODE_OFF 0 +#define SNAPSHOT_MODE_EVERY_STEP 1 +#define SNAPSHOT_MODE_EVERY_MOVE 2 +#define SNAPSHOT_MODE_DEFAULT SNAPSHOT_MODE_EVERY_MOVE struct GamePanelInfo @@ -369,7 +376,7 @@ void FreeEngineSnapshotList(); void LoadEngineSnapshotSingle(); void SaveEngineSnapshotSingle(); boolean SaveEngineSnapshotToList(); -boolean CheckEngineSnapshot(); +boolean CheckEngineSnapshotSingle(); void CreateGameButtons(); void FreeGameButtons(); diff --git a/src/libgame/snapshot.c b/src/libgame/snapshot.c index e05a998c..43a42c34 100644 --- a/src/libgame/snapshot.c +++ b/src/libgame/snapshot.c @@ -86,7 +86,7 @@ void FreeSnapshotBuffers(ListNode *snapshot_buffers) } // ----------------------------------------------------------------------------- -// functions for handling one of several snapshots +// functions for handling single shapshot or list of snapshots // ----------------------------------------------------------------------------- static void FreeSnapshot(void *snapshot_buffers_ptr) @@ -167,7 +167,7 @@ boolean LoadSnapshotSingle() boolean LoadSnapshotFromList_Older(int steps) { - if (snapshot_current->next) + if (snapshot_current && snapshot_current->next) { while (snapshot_current->next && steps--) snapshot_current = snapshot_current->next; @@ -186,7 +186,7 @@ boolean LoadSnapshotFromList_Older(int steps) boolean LoadSnapshotFromList_Newer(int steps) { - if (snapshot_current->prev) + if (snapshot_current && snapshot_current->prev) { while (snapshot_current->prev && steps--) snapshot_current = snapshot_current->prev; @@ -202,3 +202,8 @@ boolean LoadSnapshotFromList_Newer(int steps) return FALSE; } + +boolean CheckSnapshotList() +{ + return (snapshot_list ? TRUE : FALSE); +} diff --git a/src/libgame/snapshot.h b/src/libgame/snapshot.h index 40b85938..ef114dd4 100644 --- a/src/libgame/snapshot.h +++ b/src/libgame/snapshot.h @@ -36,6 +36,7 @@ void SaveSnapshotToList(); boolean LoadSnapshotSingle(); boolean LoadSnapshotFromList_Older(); boolean LoadSnapshotFromList_Newer(); +boolean CheckSnapshotList(); void FreeSnapshotSingle(); void FreeSnapshotList(); diff --git a/src/libgame/system.h b/src/libgame/system.h index 617fc573..eff54525 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -948,6 +948,7 @@ struct SetupInfo boolean toons; boolean scroll_delay; boolean scroll_delay_value; + char *engine_snapshot_mode; boolean soft_scrolling; boolean fade_screens; boolean autorecord; diff --git a/src/screens.c b/src/screens.c index ccf4e8f4..6757061e 100644 --- a/src/screens.c +++ b/src/screens.c @@ -60,20 +60,21 @@ /* sub-screens on the setup screen (specific) */ #define SETUP_MODE_CHOOSE_GAME_SPEED 16 #define SETUP_MODE_CHOOSE_SCROLL_DELAY 17 -#define SETUP_MODE_CHOOSE_SCREEN_MODE 18 -#define SETUP_MODE_CHOOSE_WINDOW_SIZE 19 -#define SETUP_MODE_CHOOSE_SCALING_TYPE 20 -#define SETUP_MODE_CHOOSE_GRAPHICS 21 -#define SETUP_MODE_CHOOSE_SOUNDS 22 -#define SETUP_MODE_CHOOSE_MUSIC 23 -#define SETUP_MODE_CHOOSE_VOLUME_SIMPLE 24 -#define SETUP_MODE_CHOOSE_VOLUME_LOOPS 25 -#define SETUP_MODE_CHOOSE_VOLUME_MUSIC 26 -#define SETUP_MODE_CHOOSE_TOUCH_CONTROL 27 -#define SETUP_MODE_CHOOSE_MOVE_DISTANCE 28 -#define SETUP_MODE_CHOOSE_DROP_DISTANCE 29 - -#define MAX_SETUP_MODES 30 +#define SETUP_MODE_CHOOSE_SNAPSHOT_MODE 18 +#define SETUP_MODE_CHOOSE_SCREEN_MODE 19 +#define SETUP_MODE_CHOOSE_WINDOW_SIZE 20 +#define SETUP_MODE_CHOOSE_SCALING_TYPE 21 +#define SETUP_MODE_CHOOSE_GRAPHICS 22 +#define SETUP_MODE_CHOOSE_SOUNDS 23 +#define SETUP_MODE_CHOOSE_MUSIC 24 +#define SETUP_MODE_CHOOSE_VOLUME_SIMPLE 25 +#define SETUP_MODE_CHOOSE_VOLUME_LOOPS 26 +#define SETUP_MODE_CHOOSE_VOLUME_MUSIC 27 +#define SETUP_MODE_CHOOSE_TOUCH_CONTROL 28 +#define SETUP_MODE_CHOOSE_MOVE_DISTANCE 29 +#define SETUP_MODE_CHOOSE_DROP_DISTANCE 30 + +#define MAX_SETUP_MODES 31 /* for input setup functions */ #define SETUPINPUT_SCREEN_POS_START 0 @@ -201,6 +202,9 @@ static TreeInfo *scaling_type_current = NULL; static TreeInfo *scroll_delays = NULL; static TreeInfo *scroll_delay_current = NULL; +static TreeInfo *snapshot_modes = NULL; +static TreeInfo *snapshot_mode_current = NULL; + static TreeInfo *game_speeds = NULL; static TreeInfo *game_speed_current = NULL; @@ -310,6 +314,19 @@ static struct { -1, NULL }, }; +static struct +{ + char *value; + char *text; +} snapshot_modes_list[] = +{ + { STR_SNAPSHOT_MODE_OFF, "Off" }, + { STR_SNAPSHOT_MODE_EVERY_STEP, "Every Step" }, + { STR_SNAPSHOT_MODE_EVERY_MOVE, "Every Move" }, + + { NULL, NULL }, +}; + static struct { int value; @@ -3504,7 +3521,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, else if (game_status == GAME_MODE_SETUP) { if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED || - setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY) + setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY || + setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE) execSetupGame(); else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE || setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE || @@ -3596,7 +3614,6 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, ti->cl_first, ti); } - return; } @@ -3702,7 +3719,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, if (game_status == GAME_MODE_SETUP) { if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED || - setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY) + setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY || + setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE) execSetupGame(); else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE || setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE || @@ -3965,6 +3983,7 @@ static char *screen_mode_text; static char *window_size_text; static char *scaling_type_text; static char *scroll_delay_text; +static char *snapshot_mode_text; static char *game_speed_text; static char *graphics_set_name; static char *sounds_set_name; @@ -4083,10 +4102,61 @@ static void execSetupGame_setScrollDelays() scroll_delay_text = scroll_delay_current->name; } +static void execSetupGame_setSnapshotModes() +{ + if (snapshot_modes == NULL) + { + int i; + + for (i = 0; snapshot_modes_list[i].value != NULL; i++) + { + TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED); + char identifier[32], name[32]; + char *value = snapshot_modes_list[i].value; + char *text = snapshot_modes_list[i].text; + + ti->node_top = &snapshot_modes; + ti->sort_priority = i; + + sprintf(identifier, "%s", value); + sprintf(name, "%s", text); + + setString(&ti->identifier, identifier); + setString(&ti->name, name); + setString(&ti->name_sorting, name); + setString(&ti->infotext, "Snapshot Mode"); + + pushTreeInfo(&snapshot_modes, ti); + } + + /* sort snapshot mode values to start with lowest snapshot mode value */ + sortTreeInfo(&snapshot_modes); + + /* set current snapshot mode value to configured snapshot mode value */ + snapshot_mode_current = + getTreeInfoFromIdentifier(snapshot_modes, setup.engine_snapshot_mode); + + /* if that fails, set current snapshot mode to reliable default value */ + if (snapshot_mode_current == NULL) + snapshot_mode_current = + getTreeInfoFromIdentifier(snapshot_modes, STR_SNAPSHOT_MODE_DEFAULT); + + /* if that also fails, set current snapshot mode to first available value */ + if (snapshot_mode_current == NULL) + snapshot_mode_current = snapshot_modes; + } + + setup.engine_snapshot_mode = snapshot_mode_current->identifier; + + /* needed for displaying snapshot mode text instead of identifier */ + snapshot_mode_text = snapshot_mode_current->name; +} + static void execSetupGame() { execSetupGame_setGameSpeeds(); execSetupGame_setScrollDelays(); + execSetupGame_setSnapshotModes(); setup_mode = SETUP_MODE_GAME; @@ -4107,6 +4177,13 @@ static void execSetupChooseScrollDelay() DrawSetupScreen(); } +static void execSetupChooseSnapshotMode() +{ + setup_mode = SETUP_MODE_CHOOSE_SNAPSHOT_MODE; + + DrawSetupScreen(); +} + static void execSetupEditor() { setup_mode = SETUP_MODE_EDITOR; @@ -4920,6 +4997,8 @@ static struct TokenInfo setup_info_game[] = { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" }, { TYPE_STRING, &scroll_delay_text, "" }, #endif + { TYPE_ENTER_LIST, execSetupChooseSnapshotMode,"Game Engine Snapshot Mode:" }, + { TYPE_STRING, &snapshot_mode_text, "" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, @@ -6435,6 +6514,8 @@ void DrawSetupScreen() DrawChooseTree(&game_speed_current); else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY) DrawChooseTree(&scroll_delay_current); + else if (setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE) + DrawChooseTree(&snapshot_mode_current); else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE) DrawChooseTree(&screen_mode_current); else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE) @@ -6486,6 +6567,8 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) HandleChooseTree(mx, my, dx, dy, button, &game_speed_current); else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY) HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current); + else if (setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE) + HandleChooseTree(mx, my, dx, dy, button, &snapshot_mode_current); else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE) HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current); else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE) diff --git a/src/tape.c b/src/tape.c index ded004fc..896a8721 100644 --- a/src/tape.c +++ b/src/tape.c @@ -739,15 +739,18 @@ void TapeTogglePause(boolean toggle_manual) TapeAppendRecording(); - if (!CheckEngineSnapshot()) + if (!CheckEngineSnapshotSingle()) SaveEngineSnapshotSingle(); } } - if (tape.pausing) - MapUndoRedoButtons(); - else if (!tape.single_step) - MapStopPlayButtons(); + if (CheckEngineSnapshotList()) + { + if (tape.pausing) + MapUndoRedoButtons(); + else if (!tape.single_step) + MapStopPlayButtons(); + } } void TapeStartPlaying() @@ -1032,7 +1035,7 @@ void TapeQuickLoad() if (game_status != GAME_MODE_PLAYING && game_status != GAME_MODE_MAIN) return; - if (CheckEngineSnapshot()) + if (CheckEngineSnapshotSingle()) { TapeStartGamePlaying();