From e5b29af394c3fd0bb350f254259fa38ff9d71be1 Mon Sep 17 00:00:00 2001 From: NyakoFox Date: Wed, 5 Jun 2024 09:17:04 -0300 Subject: [PATCH 1/4] Checkpoint autosaving --- desktop_version/src/Entity.cpp | 7 +++++++ desktop_version/src/Game.cpp | 12 ++++++++++++ desktop_version/src/Game.h | 1 + desktop_version/src/Script.cpp | 7 +++++++ 4 files changed, 27 insertions(+) diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index 210145a814..3a372db893 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -2732,6 +2732,13 @@ bool entityclass::updateentities( int i ) game.savedir = entities[player].dir; } entities[i].state = 0; + + if (game.checkpoint_saving) + { + bool success = game.savequick(); + game.gamesaved = success; + game.gamesavefailed = !success; + } } break; case 9: //Gravity Lines diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 1d7bad140c..b7deec5192 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -376,6 +376,12 @@ void Game::init(void) screenshot_border_timer = 0; screenshot_saved_success = false; +#ifdef __ANDROID__ + checkpoint_saving = true; +#else + checkpoint_saving = false; +#endif + setdefaultcontrollerbuttons(); } @@ -4936,6 +4942,10 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, struct ScreenSett roomname_translator::set_enabled(help.Int(pText)); } + if (SDL_strcmp(pKey, "checkpoint_saving") == 0) + { + checkpoint_saving = help.Int(pText); + } } setdefaultcontrollerbuttons(); @@ -5194,6 +5204,8 @@ void Game::serializesettings(tinyxml2::XMLElement* dataNode, const struct Screen xml::update_tag(dataNode, "english_sprites", (int) loc::english_sprites); xml::update_tag(dataNode, "new_level_font", loc::new_level_font.c_str()); xml::update_tag(dataNode, "roomname_translator", (int) roomname_translator::enabled); + + xml::update_tag(dataNode, "checkpoint_saving", (int) checkpoint_saving); } static bool settings_loaded = false; diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 362a956ced..f4bc4e172b 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -363,6 +363,7 @@ class Game int savetrinkets; bool startscript; std::string newscript; + bool checkpoint_saving; bool menustart; diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index a58b1735a1..4b7bd83ece 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -1206,6 +1206,13 @@ void scriptclass::run(void) { game.savedir = obj.entities[i].dir; } + + if (game.checkpoint_saving) + { + bool success = game.savequick(); + game.gamesaved = success; + game.gamesavefailed = !success; + } } else if (words[0] == "gamestate") { From 8802d2754d1a446235517e07cb6b1b0e9f7ed75d Mon Sep 17 00:00:00 2001 From: NyakoFox Date: Thu, 26 Sep 2024 13:20:18 -0300 Subject: [PATCH 2/4] add menu option for checkpoint saving --- desktop_version/lang/ar/strings.xml | 5 +++++ desktop_version/lang/ca/strings.xml | 5 +++++ desktop_version/lang/cy/strings.xml | 5 +++++ desktop_version/lang/de/strings.xml | 5 +++++ desktop_version/lang/en/strings.xml | 5 +++++ desktop_version/lang/eo/strings.xml | 5 +++++ desktop_version/lang/es/strings.xml | 5 +++++ desktop_version/lang/es_419/strings.xml | 5 +++++ desktop_version/lang/es_AR/strings.xml | 5 +++++ desktop_version/lang/fr/strings.xml | 5 +++++ desktop_version/lang/ga/strings.xml | 5 +++++ desktop_version/lang/it/strings.xml | 5 +++++ desktop_version/lang/ja/strings.xml | 5 +++++ desktop_version/lang/ko/strings.xml | 5 +++++ desktop_version/lang/nl/strings.xml | 5 +++++ desktop_version/lang/pl/strings.xml | 5 +++++ desktop_version/lang/pt_BR/strings.xml | 5 +++++ desktop_version/lang/pt_PT/strings.xml | 5 +++++ desktop_version/lang/ru/strings.xml | 5 +++++ desktop_version/lang/szl/strings.xml | 5 +++++ desktop_version/lang/tr/strings.xml | 5 +++++ desktop_version/lang/uk/strings.xml | 5 +++++ desktop_version/lang/zh/strings.xml | 5 +++++ desktop_version/lang/zh_TW/strings.xml | 5 +++++ desktop_version/src/Game.cpp | 1 + desktop_version/src/Input.cpp | 6 ++++++ desktop_version/src/Render.cpp | 16 ++++++++++++++++ 27 files changed, 143 insertions(+) diff --git a/desktop_version/lang/ar/strings.xml b/desktop_version/lang/ar/strings.xml index dc4ab172a4..fa676260ae 100644 --- a/desktop_version/lang/ar/strings.xml +++ b/desktop_version/lang/ar/strings.xml @@ -236,6 +236,11 @@ + + + + + + + + + + diff --git a/desktop_version/lang/cy/strings.xml b/desktop_version/lang/cy/strings.xml index 75233e0a01..e4a69d5efd 100644 --- a/desktop_version/lang/cy/strings.xml +++ b/desktop_version/lang/cy/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/de/strings.xml b/desktop_version/lang/de/strings.xml index 8bc440f81a..922ef2b08a 100644 --- a/desktop_version/lang/de/strings.xml +++ b/desktop_version/lang/de/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/en/strings.xml b/desktop_version/lang/en/strings.xml index 86a4217f37..2f5fe398cc 100644 --- a/desktop_version/lang/en/strings.xml +++ b/desktop_version/lang/en/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/eo/strings.xml b/desktop_version/lang/eo/strings.xml index 6c08504366..d40600510c 100644 --- a/desktop_version/lang/eo/strings.xml +++ b/desktop_version/lang/eo/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/es/strings.xml b/desktop_version/lang/es/strings.xml index 68c8a2468d..95af51fcc1 100644 --- a/desktop_version/lang/es/strings.xml +++ b/desktop_version/lang/es/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/es_419/strings.xml b/desktop_version/lang/es_419/strings.xml index 827a3b97f9..dcde51ebbe 100644 --- a/desktop_version/lang/es_419/strings.xml +++ b/desktop_version/lang/es_419/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/es_AR/strings.xml b/desktop_version/lang/es_AR/strings.xml index e2cdc45706..4669bd0295 100644 --- a/desktop_version/lang/es_AR/strings.xml +++ b/desktop_version/lang/es_AR/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/fr/strings.xml b/desktop_version/lang/fr/strings.xml index 411cc564be..021c29e456 100644 --- a/desktop_version/lang/fr/strings.xml +++ b/desktop_version/lang/fr/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/ga/strings.xml b/desktop_version/lang/ga/strings.xml index cbdf99877c..38115d4b13 100644 --- a/desktop_version/lang/ga/strings.xml +++ b/desktop_version/lang/ga/strings.xml @@ -233,6 +233,11 @@ Déan cóip chúltaca, ar eagla na heagla." explanation="translation maintenance + + + + + diff --git a/desktop_version/lang/it/strings.xml b/desktop_version/lang/it/strings.xml index f4798b2b6a..b2aea43242 100644 --- a/desktop_version/lang/it/strings.xml +++ b/desktop_version/lang/it/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/ja/strings.xml b/desktop_version/lang/ja/strings.xml index f7fe0042f1..3a2c5ba7fc 100644 --- a/desktop_version/lang/ja/strings.xml +++ b/desktop_version/lang/ja/strings.xml @@ -246,6 +246,11 @@ Escキーを押すと表示を終了する。" explanation="" max="38*6" max_loc + + + + + diff --git a/desktop_version/lang/ko/strings.xml b/desktop_version/lang/ko/strings.xml index e7b69f1f94..131453f3a3 100755 --- a/desktop_version/lang/ko/strings.xml +++ b/desktop_version/lang/ko/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/nl/strings.xml b/desktop_version/lang/nl/strings.xml index 6d1aeebc24..12b3de8582 100644 --- a/desktop_version/lang/nl/strings.xml +++ b/desktop_version/lang/nl/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/pl/strings.xml b/desktop_version/lang/pl/strings.xml index 059bd1edd8..3dfe2cae22 100644 --- a/desktop_version/lang/pl/strings.xml +++ b/desktop_version/lang/pl/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/pt_BR/strings.xml b/desktop_version/lang/pt_BR/strings.xml index 0d084ab8a1..db151e1f5f 100644 --- a/desktop_version/lang/pt_BR/strings.xml +++ b/desktop_version/lang/pt_BR/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/pt_PT/strings.xml b/desktop_version/lang/pt_PT/strings.xml index 3d24a84f57..b3d1a9c744 100644 --- a/desktop_version/lang/pt_PT/strings.xml +++ b/desktop_version/lang/pt_PT/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/ru/strings.xml b/desktop_version/lang/ru/strings.xml index 04c6476b5e..2c1cf436cc 100644 --- a/desktop_version/lang/ru/strings.xml +++ b/desktop_version/lang/ru/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/szl/strings.xml b/desktop_version/lang/szl/strings.xml index 3eadda2581..6aefae606d 100644 --- a/desktop_version/lang/szl/strings.xml +++ b/desktop_version/lang/szl/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/tr/strings.xml b/desktop_version/lang/tr/strings.xml index c7cfdf82b7..b80a41fd61 100644 --- a/desktop_version/lang/tr/strings.xml +++ b/desktop_version/lang/tr/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/uk/strings.xml b/desktop_version/lang/uk/strings.xml index dbfc81a9c6..047e4ab518 100644 --- a/desktop_version/lang/uk/strings.xml +++ b/desktop_version/lang/uk/strings.xml @@ -232,6 +232,11 @@ + + + + + diff --git a/desktop_version/lang/zh/strings.xml b/desktop_version/lang/zh/strings.xml index d437c5ba4c..40d263801f 100644 --- a/desktop_version/lang/zh/strings.xml +++ b/desktop_version/lang/zh/strings.xml @@ -238,6 +238,11 @@ + + + + + diff --git a/desktop_version/lang/zh_TW/strings.xml b/desktop_version/lang/zh_TW/strings.xml index 157c0cbaaf..62cf319700 100644 --- a/desktop_version/lang/zh_TW/strings.xml +++ b/desktop_version/lang/zh_TW/strings.xml @@ -238,6 +238,11 @@ + + + + + diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index b7deec5192..5af8aeff29 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -6864,6 +6864,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) option(loc::gettext("unfocus pause")); option(loc::gettext("unfocus audio pause")); option(loc::gettext("room name background")); + option(loc::gettext("checkpoint saving")); option(loc::gettext("return")); menuyoff = 0; maxspacing = 15; diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 468c265aac..c00f736206 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -862,6 +862,12 @@ static void menuactionpress(void) game.savestatsandsettings_menu(); music.playef(Sound_VIRIDIAN); break; + case 3: + // toggle checkpoint saving + game.checkpoint_saving = !game.checkpoint_saving; + game.savestatsandsettings_menu(); + music.playef(Sound_VIRIDIAN); + break; default: //back music.playef(Sound_VIRIDIAN); diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 20efc8ffd0..9b22bd89cb 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1139,6 +1139,7 @@ static void menurender(void) break; } case 2: + { font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("Room Name BG"), tr, tg, tb); int next_y = font::print_wrap(PR_CEN, -1, 65, loc::gettext("Lets you see through what is behind the name at the bottom of the screen."), tr, tg, tb); if (graphics.translucentroomname) @@ -1147,6 +1148,21 @@ static void menurender(void) font::print_wrap(PR_CEN, -1, next_y, loc::gettext("Room name background is OPAQUE"), tr, tg, tb); break; } + case 3: + { + font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("Checkpoint Saving"), tr, tg, tb); + int next_y = font::print_wrap(PR_CEN, -1, 65, loc::gettext("Toggle if checkpoints should save the game."), tr, tg, tb); + if (game.checkpoint_saving) + { + font::print_wrap(PR_CEN, -1, next_y, loc::gettext("Checkpoint saving is OFF"), tr / 2, tg / 2, tb / 2); + } + else + { + font::print_wrap(PR_CEN, -1, next_y, loc::gettext("Checkpoint saving is ON"), tr, tg, tb); + } + break; + } + } break; case Menu::accessibility: { From 4837c85164f4072bafca305e5fe169819899beba Mon Sep 17 00:00:00 2001 From: NyakoFox Date: Thu, 26 Sep 2024 13:32:46 -0300 Subject: [PATCH 3/4] Fix menu option, show textbox when save failed In my last commit, I accidentally inverted whether the description says ON or OFF. --- desktop_version/src/Entity.cpp | 5 +++++ desktop_version/src/Game.cpp | 17 +++++++++++------ desktop_version/src/Game.h | 1 + desktop_version/src/Render.cpp | 2 +- desktop_version/src/Script.cpp | 5 +++++ 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index 3a372db893..bb5ffe4083 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -2738,6 +2738,11 @@ bool entityclass::updateentities( int i ) bool success = game.savequick(); game.gamesaved = success; game.gamesavefailed = !success; + + if (game.gamesavefailed) { + game.show_save_fail(); + graphics.textboxapplyposition(); + } } } break; diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 5af8aeff29..da4d246dd2 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -827,7 +827,7 @@ static void savetele_textbox_success(textboxclass* THIS) THIS->pad(3, 3); } -static void savetele_textbox_fail(textboxclass* THIS) +static void save_textbox_fail(textboxclass* THIS) { THIS->lines.clear(); THIS->lines.push_back(loc::gettext("ERROR: Could not save game!")); @@ -835,6 +835,15 @@ static void savetele_textbox_fail(textboxclass* THIS) THIS->pad(1, 1); } +void Game::show_save_fail(void) +{ + graphics.createtextboxflipme("", -1, 12, TEXT_COLOUR("red")); + graphics.textboxprintflags(PR_FONT_INTERFACE); + graphics.textboxcenterx(); + graphics.textboxtimer(50); + graphics.textboxtranslate(TEXTTRANSLATE_FUNCTION, save_textbox_fail); +} + void Game::savetele_textbox(void) { if (inspecial() || map.custommode) @@ -852,11 +861,7 @@ void Game::savetele_textbox(void) } else { - graphics.createtextboxflipme("", -1, 12, TEXT_COLOUR("red")); - graphics.textboxprintflags(PR_FONT_INTERFACE); - graphics.textboxcenterx(); - graphics.textboxtimer(50); - graphics.textboxtranslate(TEXTTRANSLATE_FUNCTION, savetele_textbox_fail); + show_save_fail(); } graphics.textboxapplyposition(); } diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index f4bc4e172b..b81f15db42 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -225,6 +225,7 @@ class Game void crewmate_textbox(const int color); void remaining_textbox(void); void actionprompt_textbox(void); + void show_save_fail(void); void savetele_textbox(void); void setstate(int gamestate); diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 9b22bd89cb..252dc53dc3 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1152,7 +1152,7 @@ static void menurender(void) { font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("Checkpoint Saving"), tr, tg, tb); int next_y = font::print_wrap(PR_CEN, -1, 65, loc::gettext("Toggle if checkpoints should save the game."), tr, tg, tb); - if (game.checkpoint_saving) + if (!game.checkpoint_saving) { font::print_wrap(PR_CEN, -1, next_y, loc::gettext("Checkpoint saving is OFF"), tr / 2, tg / 2, tb / 2); } diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 4b7bd83ece..34f7087829 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -1212,6 +1212,11 @@ void scriptclass::run(void) bool success = game.savequick(); game.gamesaved = success; game.gamesavefailed = !success; + + if (game.gamesavefailed) { + game.show_save_fail(); + graphics.textboxapplyposition(); + } } } else if (words[0] == "gamestate") From 170d4bbffc911471eccea439942bc098cbd3a21c Mon Sep 17 00:00:00 2001 From: NyakoFox Date: Thu, 26 Sep 2024 15:25:13 -0300 Subject: [PATCH 4/4] Abstract checkpoint saving to its own function This also makes the save failed textbox not appear in special modes, and allows custom levels to quicksave from checkpoints as well. --- desktop_version/src/Entity.cpp | 12 +----------- desktop_version/src/Game.cpp | 16 ++++++++++++++++ desktop_version/src/Game.h | 1 + desktop_version/src/Script.cpp | 12 +----------- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index bb5ffe4083..52a1e82812 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -2733,17 +2733,7 @@ bool entityclass::updateentities( int i ) } entities[i].state = 0; - if (game.checkpoint_saving) - { - bool success = game.savequick(); - game.gamesaved = success; - game.gamesavefailed = !success; - - if (game.gamesavefailed) { - game.show_save_fail(); - graphics.textboxapplyposition(); - } - } + game.checkpoint_save(); } break; case 9: //Gravity Lines diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index da4d246dd2..25131e1a0b 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -844,6 +844,22 @@ void Game::show_save_fail(void) graphics.textboxtranslate(TEXTTRANSLATE_FUNCTION, save_textbox_fail); } +void Game::checkpoint_save(void) +{ + if (checkpoint_saving && !inspecial()) + { + bool success = map.custommode ? customsavequick(cl.ListOfMetaData[playcustomlevel].filename) : savequick(); + gamesaved = success; + gamesavefailed = !success; + + if (gamesavefailed) + { + show_save_fail(); + graphics.textboxapplyposition(); + } + } +} + void Game::savetele_textbox(void) { if (inspecial() || map.custommode) diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index b81f15db42..21faf747a8 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -226,6 +226,7 @@ class Game void remaining_textbox(void); void actionprompt_textbox(void); void show_save_fail(void); + void checkpoint_save(void); void savetele_textbox(void); void setstate(int gamestate); diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 34f7087829..53d4737c9c 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -1207,17 +1207,7 @@ void scriptclass::run(void) game.savedir = obj.entities[i].dir; } - if (game.checkpoint_saving) - { - bool success = game.savequick(); - game.gamesaved = success; - game.gamesavefailed = !success; - - if (game.gamesavefailed) { - game.show_save_fail(); - graphics.textboxapplyposition(); - } - } + game.checkpoint_save(); } else if (words[0] == "gamestate") {