(svn r4018) -Backport from trunk (4001:4002):

Add length parameter to FiosMakeSavegameName() and use this function for creating the full path instead of home-brewn snprintf.
	Use the title of a savegame in the saveload dialog-editbox. This gets rid of the '.sav' appended to each game as well as properly showing UTF-8 saves when this is implemented. Also don't change the text if the save has failed.
This commit is contained in:
celestar
2006-03-22 11:26:08 +00:00
parent f4d5c1b01b
commit 85141929a8
5 changed files with 18 additions and 17 deletions

View File

@@ -1325,7 +1325,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
DeleteWindow(w);
} else {
// SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox
ttd_strlcpy(WP(w, querystr_d).text.buf, file->name, WP(w, querystr_d).text.maxlength);
ttd_strlcpy(WP(w, querystr_d).text.buf, file->title, WP(w, querystr_d).text.maxlength);
UpdateTextBufferSize(&WP(w, querystr_d).text);
InvalidateWidget(w, 10);
}
@@ -1359,16 +1359,17 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
if (HASBIT(w->click_state, 11)) { /* Delete button clicked */
if (!FiosDelete(WP(w,querystr_d).text.buf)) {
ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0);
} else {
BuildFileList();
/* Reset file name to current date on successfull delete */
if (_saveload_mode == SLD_SAVE_GAME) GenerateFileName();
}
UpdateTextBufferSize(&WP(w, querystr_d).text);
SetWindowDirty(w);
BuildFileList();
if (_saveload_mode == SLD_SAVE_GAME) {
GenerateFileName(); /* Reset file name to current date */
UpdateTextBufferSize(&WP(w, querystr_d).text);
}
} else if (HASBIT(w->click_state, 12)) { /* Save button clicked */
_switch_mode = SM_SAVE;
FiosMakeSavegameName(_file_to_saveload.name, WP(w,querystr_d).text.buf);
FiosMakeSavegameName(_file_to_saveload.name, WP(w,querystr_d).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();