Changeset - r23256:260d782e8b26
[Not reviewed]
master
0 2 0
Niels Martin Hansen - 6 years ago 2019-02-01 19:17:28
nielsm@indvikleren.dk
Add: Warn before overwriting an existing save file
2 files changed with 24 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/fios_gui.cpp
Show inline comments
 
@@ -278,12 +278,24 @@ private:
 
	Scrollbar *vscroll;
 

	
 
	StringFilter string_filter; ///< Filter for available games.
 
	QueryString filter_editbox; ///< Filter editbox;
 
	SmallVector<bool, 32> fios_items_shown; ///< Map of the filtered out fios items
 

	
 
	static void SaveGameConfirmationCallback(Window *w, bool confirmed)
 
	{
 
		/* File name has already been written to _file_to_saveload */
 
		if (confirmed) _switch_mode = SM_SAVE_GAME;
 
	}
 

	
 
	static void SaveHeightmapConfirmationCallback(Window *w, bool confirmed)
 
	{
 
		/* File name has already been written to _file_to_saveload */
 
		if (confirmed) _switch_mode = SM_SAVE_HEIGHTMAP;
 
	}
 

	
 
public:
 

	
 
	/** Generate a default save filename. */
 
	void GenerateFileName()
 
	{
 
		GenerateDefaultSaveName(this->filename_editbox.text.buf, &this->filename_editbox.text.buf[this->filename_editbox.text.max_bytes - 1]);
 
@@ -728,17 +740,25 @@ public:
 
				this->InvalidateData(SLIWD_RESCAN_FILES);
 
				/* Reset file name to current date on successful delete */
 
				if (this->abstract_filetype == FT_SAVEGAME) GenerateFileName();
 
			}
 
		} else if (this->IsWidgetLowered(WID_SL_SAVE_GAME)) { // Save button clicked
 
			if (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO) {
 
				_switch_mode = SM_SAVE_GAME;
 
				FiosMakeSavegameName(_file_to_saveload.name, this->filename_editbox.text.buf, lastof(_file_to_saveload.name));
 
				if (FioCheckFileExists(_file_to_saveload.name, Subdirectory::SAVE_DIR)) {
 
					ShowQuery(STR_SAVELOAD_OVERWRITE_TITLE, STR_SAVELOAD_OVERWRITE_WARNING, this, SaveLoadWindow::SaveGameConfirmationCallback);
 
				} else {
 
					_switch_mode = SM_SAVE_GAME;
 
				}
 
			} else {
 
				_switch_mode = SM_SAVE_HEIGHTMAP;
 
				FiosMakeHeightmapName(_file_to_saveload.name, this->filename_editbox.text.buf, lastof(_file_to_saveload.name));
 
				if (FioCheckFileExists(_file_to_saveload.name, Subdirectory::SAVE_DIR)) {
 
					ShowQuery(STR_SAVELOAD_OVERWRITE_TITLE, STR_SAVELOAD_OVERWRITE_WARNING, this, SaveLoadWindow::SaveHeightmapConfirmationCallback);
 
				} else {
 
					_switch_mode = SM_SAVE_HEIGHTMAP;
 
				}
 
			}
 

	
 
			/* In the editor set up the vehicle engines correctly (date might have changed) */
 
			if (_game_mode == GM_EDITOR) StartupEngines();
 
		}
 
	}
src/lang/english.txt
Show inline comments
 
@@ -2776,12 +2776,14 @@ STR_SAVELOAD_LOAD_TOOLTIP               
 
STR_SAVELOAD_LOAD_HEIGHTMAP_TOOLTIP                             :{BLACK}Load the selected heightmap
 
STR_SAVELOAD_DETAIL_CAPTION                                     :{BLACK}Game Details
 
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_FILTER_TITLE                                       :{BLACK}Filter string:
 
STR_SAVELOAD_OVERWRITE_TITLE                                    :{WHITE}Overwrite File
 
STR_SAVELOAD_OVERWRITE_WARNING                                  :{YELLOW}Are you sure you want to overwrite the existing file?
 

	
 
STR_SAVELOAD_OSKTITLE                                           :{BLACK}Enter a name for the savegame
 

	
 
# World generation
 
STR_MAPGEN_WORLD_GENERATION_CAPTION                             :{WHITE}World Generation
 
STR_MAPGEN_MAPSIZE                                              :{BLACK}Map size:
0 comments (0 inline, 0 general)