设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 101|回复: 4
打印 上一主题 下一主题

[有事请教] KMS存读档优化与删除存档冲突

[复制链接]

Lv4.逐梦者

梦石
4
星屑
1079
在线时间
254 小时
注册时间
2016-2-16
帖子
24
跳转到指定楼层
1
发表于 2024-9-8 12:56:12 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
50星屑
本帖最后由 梦路 于 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

最佳答案

查看完整内容

以下这三段插入到YEP_SaveCore.js的底部去 Window_SaveInfo.prototype.isJson = function (content) { try { if (typeof JSON.parse(content) === "object") { return true; } } catch (e) { return false; } }; Window_SaveInfo.prototype.drawContents = function (dy) { if (!this._saveContents) { return setTimeout(this.drawContents.bind(this, dy), 50); } if (this.isJson(this._sa ...

Lv5.捕梦者

梦石
0
星屑
25584
在线时间
5286 小时
注册时间
2016-3-8
帖子
1651
2
发表于 2024-9-8 12:56:13 | 只看该作者
本帖最后由 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. };

评分

参与人数 1+1 收起 理由
梦路 + 1 可以了~大佬NB!

查看全部评分

回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
4693
在线时间
831 小时
注册时间
2019-11-7
帖子
347
3
发表于 2024-9-8 13:12:05 | 只看该作者

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

如图,没有删除了
回复

使用道具 举报

Lv4.逐梦者

梦石
4
星屑
1079
在线时间
254 小时
注册时间
2016-2-16
帖子
24
4
 楼主| 发表于 2024-9-8 13:15:18 | 只看该作者
青衣blackcloth 发表于 2024-9-8 13:12
有个傻瓜办法,就是注释掉删除,这样就不报错了

如图,没有删除了

就是想保留删除存档功能

点评

我这没有代码水平,只能解决出问题的地方,看看其他大佬吧,哈哈  发表于 2024-9-8 13:22
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-20 23:23

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表