/*: @author coelocanth @plugindesc Replaces save game titles with chapter / map names @help The default RPGMaker save files have a title that is the same as the name of the game. While this may be classic PS1 memory card nostalgia, You may prefer to have titles that show the player where the save file is in the game. This plugin makes the save file title a combination of chapter number, chapter title, and/or map name. Setup: To use chapters, you will need to reserve one of your game variables to be the chapter number. This is configured in the plugin parameters, and You will change the variable as needed using standard event commands. To use chapter titles, configure the chapter names in the plugin parameters. The first entry is for chapter 0, since variables are set to 0 at the start of a new game. To use map names, give each of your maps a display name in the editor. Any elements of the save title can be disabled in the plugin parameters if You do not want them. @param chapters @text Chapters @param includeChapterNumber @parent chapters @text Include Chapter Number @desc Whether the chapter number should be included in save titles @type boolean @default true @param includeChapterName @parent chapters @text Include Chapter Name @desc Whether the chapter number should be included in save titles @type boolean @default true @param chapterPrefix @parent chapters @text Chapter Prefix @type text @default Ch. @param chapterVariable @parent chapters @text Chapter Variable @desc Variable which contains the chapter number to use in save titles @type variable @default 0 @param chapterInfix @parent chapters @text Chapter Infix @desc Separator between the chapter number and chapter title @type text @default - @param chapterTitles @parent chapters @type text[] @default ["Prologue"] @text Chapter Titles @desc Title for each chapter, indexed by chapter number. The first entry is for value 0. @param chapterSuffix @parent chapters @text Chapter Suffix @desc Separator between chapter title and map name. @default - @param map @text Map @param includeMap @parent map @text Include Map Name @desc Whether the map name should be included in save titles @type boolean @default true @param advanced @text Advanced @param formatString @parent advanced @text Format String @desc Following sequences are special: '%c' = chapter, '%t' = chapter title, '%m' = map name */ (function () { var _params = PluginManager.parameters('cc_savefile_titles'); var _includeChapterNumber = Boolean(_params["includeChapterNumber"] == 'true'); var _includeChapterName = Boolean(_params["includeChapterName"] == 'true'); var _textChapterPrefix = _params['chapterPrefix']; var _textChapterInfix = _params['chapterInfix']; var _textChapterSuffix = _params['chapterSuffix']; var _chapterVariable = parseInt(_params['chapterVariable']); var _chapterTitles = JSON.parse(_params['chapterTitles']); var _includeMap = Boolean(_params["includeMap"] == 'true'); var _formatString = _params['formatString']; var _DataManager_makeSavefileInfo = DataManager.makeSavefileInfo; DataManager.makeSavefileInfo = function() { info = _DataManager_makeSavefileInfo.call(this); // be careful with saves, fall back to original title on error try { var title = this.makeSavefileTitle(); info.title = title; } catch(e) { console.error(e.stack); } return info; } DataManager.makeSavefileTitle = function() { if(_formatString) { var chapter = $gameVariables.value(_chapterVariable) || 0; var title = _chapterTitles[chapter] || ""; var map = $gameMap.displayName(); return _formatString.replace('%c', chapter) .replace('%t', title).replace('%m', map); } var title_parts = []; if(_chapterVariable) { var chapter = $gameVariables.value(_chapterVariable); if(_includeChapterNumber) { if(_textChapterPrefix) { title_parts.push(_textChapterPrefix); } title_parts.push(chapter); } if(_includeChapterName && _chapterTitles[chapter] !== undefined) { if(title_parts.length && _textChapterInfix) { title_parts.push(_textChapterInfix); } title_parts.push(_chapterTitles[chapter]); } } if(_includeMap) { if(title_parts.length) { title_parts.push(_textChapterSuffix); } title_parts.push($gameMap.displayName()); } return title_parts.join(" "); } }());