Index: src/fios_gui.cpp =================================================================== --- src/fios_gui.cpp (revision 22854) +++ src/fios_gui.cpp (working copy) @@ -239,6 +239,21 @@ QSortT(_fios_items.Get(sort_start), s_amount, CompareFiosItems); } +/** + * Handle the user's confirmation/cancellation of overwriting a saved file. + * @param w unused + * @param confirmed whether the user confirms the overwrite or not + */ +static void AskFileSaveOverwriteCallback(Window *w, bool confirmed) +{ + if (confirmed) { + _switch_mode = _saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO ? SM_SAVE_GAME : SM_SAVE_HEIGHTMAP; + + /* In the editor set up the vehicle engines correctly (date might have changed) */ + if (_game_mode == GM_EDITOR) StartupEngines(); + } +} + struct SaveLoadWindow : public QueryStringBaseWindow { private: FiosItem o_dir; @@ -655,15 +670,17 @@ UpdateTextBufferSize(&this->text); } else if (this->IsWidgetLowered(SLWW_SAVE_GAME)) { // Save button clicked if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { - _switch_mode = SM_SAVE_GAME; FiosMakeSavegameName(_file_to_saveload.name, this->text.buf, sizeof(_file_to_saveload.name)); } else { - _switch_mode = SM_SAVE_HEIGHTMAP; FiosMakeHeightmapName(_file_to_saveload.name, this->text.buf, sizeof(_file_to_saveload.name)); } - /* In the editor set up the vehicle engines correctly (date might have changed) */ - if (_game_mode == GM_EDITOR) StartupEngines(); + if (FioCheckFileExists(_file_to_saveload.name, NO_DIRECTORY)) { + SetDParamStr(0, this->text.buf); + ShowQuery(this->GetWidget(SLWW_WINDOWTITLE)->widget_data, STR_SAVELOAD_OVERWRITE_CONFIRM_MESSAGE, this, AskFileSaveOverwriteCallback); + } else { + AskFileSaveOverwriteCallback(this, true); + } } } Index: src/lang/english.txt =================================================================== --- src/lang/english.txt (revision 22854) +++ src/lang/english.txt (working copy) @@ -2303,6 +2303,7 @@ STR_SAVELOAD_DETAIL_NOT_AVAILABLE :{BLACK}No information available STR_SAVELOAD_DETAIL_COMPANY_INDEX :{SILVER}{COMMA}: {WHITE}{STRING1} STR_SAVELOAD_DETAIL_GRFSTATUS :{SILVER}NewGRF: {WHITE}{STRING} +STR_SAVELOAD_OVERWRITE_CONFIRM_MESSAGE :{YELLOW}Are you sure you want to overwrite "{RAW_STRING}"? STR_SAVELOAD_OSKTITLE :{BLACK}Enter a name for the savegame