Project1

标题: KMS存读档优化与删除存档冲突 [打印本页]

作者: 梦路    时间: 2024-9-8 12:56
标题: KMS存读档优化与删除存档冲突
本帖最后由 梦路 于 2024-9-8 12:56 编辑

游戏做大以后存读档特别卡,于是用了KMS的高速存读档插件
存档和读档特别丝滑,但是与YEP_SaveCore的删存档功能有冲突,删除存档会报错:uncaught SyntaxError:unexpected token o in JSON at position 1
求大佬看看能不能优化一下删存档功能

范例工程:https://pan.baidu.com/s/1KhYl4F6b2ttCaOUIdZxA-A
提取码:en39




JAVASCRIPT 代码复制下载
  1. //=============================================================================
  2. // KMS_AccelerateFileScene.js
  3. //   Last update: 2015/12/05
  4. //=============================================================================
  5.  
  6. /*:
  7.  * @plugindesc
  8.  * [v0.1.0] Accelerate drawing save/load scene.
  9.  *
  10.  * @author TOMY (Kamesoft)
  11.  *
  12.  * @help This plugin does not provide plugin commands.
  13.  */
  14.  
  15. /*:ja
  16.  * @plugindesc
  17.  * [v0.1.0] セーブ/ロード画面の描画を高速化します。
  18.  *
  19.  * @author TOMY (Kamesoft)
  20.  *
  21.  * @help このプラグインには、プラグインコマンドはありません。
  22.  */
  23.  
  24. var KMS = KMS || {};
  25.  
  26. (function() {
  27.  
  28. KMS.imported = KMS.imported || {};
  29. KMS.imported['AccelerateFileScene'] = true;
  30.  
  31. //var pluginParams = PluginManager.parameters('KMS_AccelerateFileScene');
  32. //var Params = {};
  33.  
  34. //-----------------------------------------------------------------------------
  35. // DataManager
  36.  
  37. var _KMS_AccelerateFileScene_DataManager_loadGlobalInfo = DataManager.loadGlobalInfo;
  38. DataManager.loadGlobalInfo = function()
  39. {
  40.     if (!this._globalInfoCache)
  41.     {
  42.         this._globalInfoCache = _KMS_AccelerateFileScene_DataManager_loadGlobalInfo.call(this);
  43.     }
  44.  
  45.     return this._globalInfoCache;
  46. };
  47.  
  48. var _KMS_AccelerateFileScene_DataManager_saveGlobalInfo = DataManager.saveGlobalInfo;
  49. DataManager.saveGlobalInfo = function(info)
  50. {
  51.     this._globalInfoCache = null;
  52.     _KMS_AccelerateFileScene_DataManager_saveGlobalInfo.call(this, info);
  53. };
  54.  
  55. })();

插件.rar

11.63 KB, 下载次数: 7


作者: alexncf125    时间: 2024-9-8 12:56
本帖最后由 alexncf125 于 2024-9-8 18:25 编辑

以下这三段插入到YEP_SaveCore.js的底部去

JAVASCRIPT 代码复制
  1. Window_SaveInfo.prototype.isJson = function (content) {
  2.   try {
  3.     if (typeof JSON.parse(content) === "object") {
  4.       return true;
  5.     }
  6.   } catch (e) {
  7.     return false;
  8.   }
  9. };
  10.  
  11. Window_SaveInfo.prototype.drawContents = function (dy) {
  12.   if (!this._saveContents) {
  13.     return setTimeout(this.drawContents.bind(this, dy), 50);
  14.   }
  15.   if (this.isJson(this._saveContents)) {
  16.     this._saveContents = JsonEx.parse(this._saveContents);
  17.   }
  18.   dy = this.drawPartyGraphics(dy);
  19.   dy = this.drawPartyNames(dy);
  20.   dy = this.drawPartyLevels(dy);
  21.   this.drawColumnData(dy);
  22. };
  23.  
  24. Yanfly.Save.Scene_File_performActionDelete = Scene_File.prototype.performActionDelete;
  25. Scene_File.prototype.performActionDelete = function () {
  26.   Yanfly.Save.Scene_File_performActionDelete.call(this);
  27.   var globalInfo = DataManager.loadGlobalInfo();
  28.   delete globalInfo[this.savefileId()];
  29.   DataManager.saveGlobalInfo(globalInfo);
  30.   this._listWindow.refresh();
  31. };

作者: 青衣blackcloth    时间: 2024-9-8 13:12

有个傻瓜办法,就是注释掉删除,这样就不报错了

如图,没有删除了

作者: 梦路    时间: 2024-9-8 13:15
青衣blackcloth 发表于 2024-9-8 13:12
有个傻瓜办法,就是注释掉删除,这样就不报错了

如图,没有删除了

就是想保留删除存档功能




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1