1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-11-14 06:59:42 +01:00

Add error messages for failed writes to disk of settings

Changing settings would most of the time attempt to save unlock.vvv and
now also settings.vvv, but there would be no feedback whether the files
have been saved successfully or not. Now, if saving fails when changing
settings in the menu, a warning message will be shown. The setting will
still be applied of course, but the user will be informed it couldn't
be saved. This message can be silenced until the game is restarted,
because I can imagine this could get very annoying when someone already
knows their settings aren't writeable.

Also, some options didn't even save settings in the first place. These
are turning off invincibility, and by coincidence precisely all the
options in the advanced options menu. I made sure these options now do
so.
This commit is contained in:
Dav999-v 2020-11-22 03:10:26 +01:00 committed by Ethan Lee
parent d910c5118d
commit 444074a931
4 changed files with 76 additions and 33 deletions

View file

@ -210,6 +210,8 @@ void Game::init(void)
playcustomlevel=0; playcustomlevel=0;
createmenu(Menu::mainmenu); createmenu(Menu::mainmenu);
silence_settings_error = false;
deathcounts = 0; deathcounts = 0;
gameoverdelay = 0; gameoverdelay = 0;
frames = 0; frames = 0;
@ -4734,7 +4736,7 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, ScreenSettings* s
} }
} }
void Game::savestats(const bool stats_only /*= true*/) bool Game::savestats(const bool stats_only /*= true*/)
{ {
tinyxml2::XMLDocument doc; tinyxml2::XMLDocument doc;
bool already_exists = FILESYSTEM_loadTiXml2Document("saves/unlock.vvv", doc); bool already_exists = FILESYSTEM_loadTiXml2Document("saves/unlock.vvv", doc);
@ -4810,11 +4812,23 @@ void Game::savestats(const bool stats_only /*= true*/)
serializesettings(dataNode); serializesettings(dataNode);
FILESYSTEM_saveTiXml2Document("saves/unlock.vvv", doc); bool success = FILESYSTEM_saveTiXml2Document("saves/unlock.vvv", doc);
if (!stats_only) if (!stats_only)
{ {
savesettings(); success = success && savesettings();
}
return success;
}
void Game::savestats_menu()
{
// Call Game::savestats(), but upon failure, go to the save error screen
if (!savestats() && !silence_settings_error)
{
createmenu(Menu::errorsavingsettings);
map.nexttowercolour();
} }
} }
@ -4973,7 +4987,7 @@ void Game::loadsettings(ScreenSettings* screen_settings)
deserializesettings(dataNode, screen_settings); deserializesettings(dataNode, screen_settings);
} }
void Game::savesettings() bool Game::savesettings()
{ {
tinyxml2::XMLDocument doc; tinyxml2::XMLDocument doc;
bool already_exists = FILESYSTEM_loadTiXml2Document("saves/settings.vvv", doc); bool already_exists = FILESYSTEM_loadTiXml2Document("saves/settings.vvv", doc);
@ -4992,7 +5006,7 @@ void Game::savesettings()
serializesettings(dataNode); serializesettings(dataNode);
FILESYSTEM_saveTiXml2Document("saves/settings.vvv", doc); return FILESYSTEM_saveTiXml2Document("saves/settings.vvv", doc);
} }
void Game::customstart() void Game::customstart()
@ -6822,6 +6836,11 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
option("return to play menu"); option("return to play menu");
menuyoff = 70; menuyoff = 70;
break; break;
case Menu::errorsavingsettings:
option("ok");
option("silence");
menuyoff = 10;
break;
} }
// Automatically center the menu. We must check the width of the menu with the initial horizontal spacing. // Automatically center the menu. We must check the width of the menu with the initial horizontal spacing.

View file

@ -32,6 +32,7 @@ namespace Menu
quickloadlevel, quickloadlevel,
youwannaquit, youwannaquit,
errornostart, errornostart,
errorsavingsettings,
graphicoptions, graphicoptions,
ed_settings, ed_settings,
ed_desc, ed_desc,
@ -132,7 +133,8 @@ public:
void loadstats(ScreenSettings* screen_settings); void loadstats(ScreenSettings* screen_settings);
void savestats(const bool stats_only = false); bool savestats(const bool stats_only = false);
void savestats_menu();
void deletestats(); void deletestats();
@ -142,7 +144,7 @@ public:
void loadsettings(ScreenSettings* screen_settings); void loadsettings(ScreenSettings* screen_settings);
void savesettings(); bool savesettings();
void deletesettings(); void deletesettings();
@ -260,6 +262,8 @@ public:
int creditposx, creditposy, creditposdelay; int creditposx, creditposy, creditposdelay;
int oldcreditposx; int oldcreditposx;
bool silence_settings_error;
//Sine Wave Ninja Minigame //Sine Wave Ninja Minigame
bool swnmode; bool swnmode;

View file

@ -385,16 +385,17 @@ void menuactionpress()
case 0: case 0:
music.playef(11); music.playef(11);
graphics.screenbuffer->toggleFullScreen(); graphics.screenbuffer->toggleFullScreen();
game.savestats();
// Recreate menu to update "resize to nearest" // Recreate menu to update "resize to nearest"
game.createmenu(game.currentmenuname, true); game.createmenu(game.currentmenuname, true);
game.currentmenuoption = 0; game.currentmenuoption = 0;
game.savestats_menu();
break; break;
case 1: case 1:
music.playef(11); music.playef(11);
graphics.screenbuffer->toggleStretchMode(); graphics.screenbuffer->toggleStretchMode();
game.savestats(); game.savestats_menu();
break; break;
case 2: case 2:
// resize to nearest multiple // resize to nearest multiple
@ -402,7 +403,7 @@ void menuactionpress()
{ {
music.playef(11); music.playef(11);
graphics.screenbuffer->ResizeToNearestMultiple(); graphics.screenbuffer->ResizeToNearestMultiple();
game.savestats(); game.savestats_menu();
} }
else else
{ {
@ -412,19 +413,19 @@ void menuactionpress()
case 3: case 3:
music.playef(11); music.playef(11);
graphics.screenbuffer->toggleLinearFilter(); graphics.screenbuffer->toggleLinearFilter();
game.savestats(); game.savestats_menu();
break; break;
case 4: case 4:
//change smoothing //change smoothing
music.playef(11); music.playef(11);
graphics.screenbuffer->badSignalEffect= !graphics.screenbuffer->badSignalEffect; graphics.screenbuffer->badSignalEffect= !graphics.screenbuffer->badSignalEffect;
game.savestats(); game.savestats_menu();
break; break;
case 5: case 5:
//toggle 30+ fps //toggle 30+ fps
music.playef(11); music.playef(11);
game.over30mode = !game.over30mode; game.over30mode = !game.over30mode;
game.savestats(); game.savestats_menu();
break; break;
case 6: case 6:
//toggle vsync //toggle vsync
@ -432,7 +433,7 @@ void menuactionpress()
#ifndef __HAIKU__ // FIXME: Remove after SDL VSync bug is fixed! -flibit #ifndef __HAIKU__ // FIXME: Remove after SDL VSync bug is fixed! -flibit
graphics.screenbuffer->vsync = !graphics.screenbuffer->vsync; graphics.screenbuffer->vsync = !graphics.screenbuffer->vsync;
graphics.screenbuffer->resetRendererWorkaround(); graphics.screenbuffer->resetRendererWorkaround();
game.savestats(); game.savestats_menu();
#endif #endif
break; break;
default: default:
@ -476,10 +477,10 @@ void menuactionpress()
break; break;
default: default:
map.invincibility = !map.invincibility; map.invincibility = !map.invincibility;
game.savestats();
music.playef(11); music.playef(11);
game.returnmenu(); game.returnmenu();
map.nexttowercolour(); map.nexttowercolour();
game.savestats_menu();
break; break;
} }
break; break;
@ -489,35 +490,35 @@ void menuactionpress()
case 0: case 0:
//back //back
game.slowdown = 30; game.slowdown = 30;
game.savestats();
music.playef(11); music.playef(11);
game.returnmenu(); game.returnmenu();
game.currentmenuoption = 4; game.currentmenuoption = 4;
map.nexttowercolour(); map.nexttowercolour();
game.savestats_menu();
break; break;
case 1: case 1:
game.slowdown = 24; game.slowdown = 24;
game.savestats();
music.playef(11); music.playef(11);
game.returnmenu(); game.returnmenu();
game.currentmenuoption = 4; game.currentmenuoption = 4;
map.nexttowercolour(); map.nexttowercolour();
game.savestats_menu();
break; break;
case 2: case 2:
game.slowdown = 18; game.slowdown = 18;
game.savestats();
music.playef(11); music.playef(11);
game.returnmenu(); game.returnmenu();
game.currentmenuoption = 4; game.currentmenuoption = 4;
map.nexttowercolour(); map.nexttowercolour();
game.savestats_menu();
break; break;
case 3: case 3:
game.slowdown = 12; game.slowdown = 12;
game.savestats();
music.playef(11); music.playef(11);
game.returnmenu(); game.returnmenu();
game.currentmenuoption = 4; game.currentmenuoption = 4;
map.nexttowercolour(); map.nexttowercolour();
game.savestats_menu();
break; break;
} }
break; break;
@ -535,26 +536,31 @@ void menuactionpress()
SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_ENABLE);
graphics.showmousecursor = true; graphics.showmousecursor = true;
} }
game.savestats_menu();
break; break;
case 1: case 1:
// toggle unfocus pause // toggle unfocus pause
game.disablepause = !game.disablepause; game.disablepause = !game.disablepause;
game.savestats_menu();
music.playef(11); music.playef(11);
break; break;
case 2: case 2:
// toggle fake load screen // toggle fake load screen
game.skipfakeload = !game.skipfakeload; game.skipfakeload = !game.skipfakeload;
game.savestats_menu();
music.playef(11); music.playef(11);
break; break;
case 3: case 3:
// toggle translucent roomname BG // toggle translucent roomname BG
graphics.translucentroomname = !graphics.translucentroomname; graphics.translucentroomname = !graphics.translucentroomname;
game.savestats_menu();
music.playef(11); music.playef(11);
break; break;
case 4: case 4:
// Glitchrunner mode // Glitchrunner mode
music.playef(11); music.playef(11);
game.glitchrunnermode = !game.glitchrunnermode; game.glitchrunnermode = !game.glitchrunnermode;
game.savestats_menu();
break; break;
case 5: case 5:
//back //back
@ -570,7 +576,7 @@ void menuactionpress()
case 0: case 0:
//disable animated backgrounds //disable animated backgrounds
game.colourblindmode = !game.colourblindmode; game.colourblindmode = !game.colourblindmode;
game.savestats(); game.savestats_menu();
graphics.towerbg.tdrawback = true; graphics.towerbg.tdrawback = true;
graphics.titlebg.tdrawback = true; graphics.titlebg.tdrawback = true;
music.playef(11); music.playef(11);
@ -578,7 +584,7 @@ void menuactionpress()
case 1: case 1:
//disable screeneffects //disable screeneffects
game.noflashingmode = !game.noflashingmode; game.noflashingmode = !game.noflashingmode;
game.savestats(); game.savestats_menu();
if (!game.noflashingmode) if (!game.noflashingmode)
{ {
music.playef(18); music.playef(18);
@ -591,7 +597,7 @@ void menuactionpress()
case 2: case 2:
//disable text outline //disable text outline
graphics.notextoutline = !graphics.notextoutline; graphics.notextoutline = !graphics.notextoutline;
game.savestats(); game.savestats_menu();
music.playef(11); music.playef(11);
break; break;
case 3: case 3:
@ -606,6 +612,7 @@ void menuactionpress()
else else
{ {
map.invincibility = !map.invincibility; map.invincibility = !map.invincibility;
game.savestats_menu();
} }
music.playef(11); music.playef(11);
} }
@ -775,49 +782,49 @@ void menuactionpress()
game.unlock[9] = true; game.unlock[9] = true;
game.unlocknotify[9] = true; game.unlocknotify[9] = true;
music.playef(11); music.playef(11);
game.savestats();
game.createmenu(Menu::unlockmenutrials, true); game.createmenu(Menu::unlockmenutrials, true);
game.currentmenuoption = 0; game.currentmenuoption = 0;
game.savestats_menu();
break; break;
case 1: //unlock 2 case 1: //unlock 2
game.unlock[10] = true; game.unlock[10] = true;
game.unlocknotify[10] = true; game.unlocknotify[10] = true;
music.playef(11); music.playef(11);
game.savestats();
game.createmenu(Menu::unlockmenutrials, true); game.createmenu(Menu::unlockmenutrials, true);
game.currentmenuoption = 1; game.currentmenuoption = 1;
game.savestats_menu();
break; break;
case 2: //unlock 3 case 2: //unlock 3
game.unlock[11] = true; game.unlock[11] = true;
game.unlocknotify[11] = true; game.unlocknotify[11] = true;
music.playef(11); music.playef(11);
game.savestats();
game.createmenu(Menu::unlockmenutrials, true); game.createmenu(Menu::unlockmenutrials, true);
game.currentmenuoption = 2; game.currentmenuoption = 2;
game.savestats_menu();
break; break;
case 3: //unlock 4 case 3: //unlock 4
game.unlock[12] = true; game.unlock[12] = true;
game.unlocknotify[12] = true; game.unlocknotify[12] = true;
music.playef(11); music.playef(11);
game.savestats();
game.createmenu(Menu::unlockmenutrials, true); game.createmenu(Menu::unlockmenutrials, true);
game.currentmenuoption = 3; game.currentmenuoption = 3;
game.savestats_menu();
break; break;
case 4: //unlock 5 case 4: //unlock 5
game.unlock[13] = true; game.unlock[13] = true;
game.unlocknotify[13] = true; game.unlocknotify[13] = true;
music.playef(11); music.playef(11);
game.savestats();
game.createmenu(Menu::unlockmenutrials, true); game.createmenu(Menu::unlockmenutrials, true);
game.currentmenuoption = 4; game.currentmenuoption = 4;
game.savestats_menu();
break; break;
case 5: //unlock 6 case 5: //unlock 6
game.unlock[14] = true; game.unlock[14] = true;
game.unlocknotify[14] = true; game.unlocknotify[14] = true;
music.playef(11); music.playef(11);
game.savestats();
game.createmenu(Menu::unlockmenutrials, true); game.createmenu(Menu::unlockmenutrials, true);
game.currentmenuoption = 5; game.currentmenuoption = 5;
game.savestats_menu();
break; break;
case 6: //back case 6: //back
//back //back
@ -843,44 +850,44 @@ void menuactionpress()
game.unlocknotify[16] = true; game.unlocknotify[16] = true;
game.unlock[6] = true; game.unlock[6] = true;
game.unlock[7] = true; game.unlock[7] = true;
game.savestats();
game.createmenu(Menu::unlockmenu, true); game.createmenu(Menu::unlockmenu, true);
game.currentmenuoption = 1; game.currentmenuoption = 1;
game.savestats_menu();
break; break;
case 2: case 2:
//unlock no death mode //unlock no death mode
music.playef(11); music.playef(11);
game.unlock[17] = true; game.unlock[17] = true;
game.unlocknotify[17] = true; game.unlocknotify[17] = true;
game.savestats();
game.createmenu(Menu::unlockmenu, true); game.createmenu(Menu::unlockmenu, true);
game.currentmenuoption = 2; game.currentmenuoption = 2;
game.savestats_menu();
break; break;
case 3: case 3:
//unlock flip mode //unlock flip mode
music.playef(11); music.playef(11);
game.unlock[18] = true; game.unlock[18] = true;
game.unlocknotify[18] = true; game.unlocknotify[18] = true;
game.savestats();
game.createmenu(Menu::unlockmenu, true); game.createmenu(Menu::unlockmenu, true);
game.currentmenuoption = 3; game.currentmenuoption = 3;
game.savestats_menu();
break; break;
case 4: case 4:
//unlock jukebox //unlock jukebox
music.playef(11); music.playef(11);
game.stat_trinkets = 20; game.stat_trinkets = 20;
game.savestats();
game.createmenu(Menu::unlockmenu, true); game.createmenu(Menu::unlockmenu, true);
game.currentmenuoption = 4; game.currentmenuoption = 4;
game.savestats_menu();
break; break;
case 5: case 5:
//unlock secret lab //unlock secret lab
music.playef(11); music.playef(11);
game.unlock[8] = true; game.unlock[8] = true;
game.unlocknotify[8] = true; game.unlocknotify[8] = true;
game.savestats();
game.createmenu(Menu::unlockmenu, true); game.createmenu(Menu::unlockmenu, true);
game.currentmenuoption = 5; game.currentmenuoption = 5;
game.savestats_menu();
break; break;
default: default:
//back //back
@ -1244,6 +1251,7 @@ void menuactionpress()
{ {
key.sensitivity = 0; key.sensitivity = 0;
} }
game.savestats_menu();
break; break;
case 5: case 5:
@ -1585,6 +1593,15 @@ void menuactionpress()
game.returnmenu(); game.returnmenu();
map.nexttowercolour(); map.nexttowercolour();
break; break;
case Menu::errorsavingsettings:
if (game.currentmenuoption == 1)
{
game.silence_settings_error = true;
}
music.playef(11);
game.returnmenu();
map.nexttowercolour();
break;
default: default:
break; break;
} }

View file

@ -1157,6 +1157,9 @@ void menurender()
} }
break; break;
} }
case Menu::errorsavingsettings:
graphics.Print( -1, 95, "ERROR: Could not save settings file!", tr, tg, tb, true);
break;
default: default:
break; break;
} }