查看: 3856|回复: 0

[搬运汉化] 【脚本】找不到png文件时尝试读取jpg文件

[复制链接]
梦石
0
星屑
50
在线时间
289 小时
注册时间
2014-12-12
回帖
138
发表于 2015-12-4 12:27:22 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 余烬之中 于 2015-12-4 16:30 编辑

排版混乱 标题不明 内容含糊 诚意不足 不予发卡 只给点糖 已代编辑       —— by 余烬之中

脚本功能:找不到png格式文件时自动尝试读取jpg格式文件
作者:Procraftynation

自定义参数:Prioritize JPG
可以设置为 true 或者 false
如果设置为true 那么读取png时先尝试读取jpg 没有jpg才读取png
否则就只在没有png的时候才读取jpg
默认是 false

脚本
  1. /*:
  2. * @plugindesc v1.0 Tries to load jpg files if no png found
  3. * @author Procraftynation - procrastination done right!
  4. *
  5. * @param Prioritize JPG
  6. * @desc Tries to load jpg files first before trying png
  7. * Values: true | false
  8. * @default false
  9. */

  10. var Imported = Imported || {};
  11. Imported.DEX_TryJPG = true;
  12. (function() {
  13.    var DEX = DEX || {}; //DEX's main object
  14.    DEX.TryJPG = DEX.TryJPG || {}; // tombstone object for functions and aliases
  15.    
  16.    DEX.TryJPG.jpgFirst = String(PluginManager.parameters('DEX_TryJPG')["Prioritize JPG"]);//true or false
  17.    
  18.    //'function overrides' will depend on the Prioritize JPG flag.
  19.    if(eval(DEX.TryJPG.jpgFirst)) {
  20.       ImageManager.loadBitmap = function(folder, filename, hue, smooth) {
  21.          if (filename) {
  22.            var path = folder + encodeURIComponent(filename) + '.jpg';//changed from png to jpg
  23.            var bitmap = this.loadNormalBitmap(path, hue || 0);
  24.            bitmap.smooth = smooth;
  25.            return bitmap;
  26.          } else {
  27.            return this.loadEmptyBitmap();
  28.          }
  29.       };
  30.       Bitmap.prototype._onError = function() {
  31.          if(!this._triedPNG) {
  32.             //change extension file to png assuming the last 3 characters of src is jpg
  33.             this._image.src = this._image.src.substr(0,this._image.src.length-3) + 'png';
  34.             this._triedPNG = true;
  35.          } else {
  36.             this._hasError = true;
  37.          }
  38.       };
  39.    } else {
  40.       Bitmap.prototype._onError = function() {
  41.          if(!this._triedJPG) {
  42.             //change extension file to jpg assuming the last 3 characters of src is png
  43.             this._image.src = this._image.src.substr(0,this._image.src.length-3) + 'jpg';
  44.             this._triedJPG = true;
  45.          } else {
  46.             this._hasError = true;
  47.          }
  48.       };
  49.    }
  50. })();
复制代码

评分

参与人数 1星屑 +166 收起 理由
余烬之中 + 166 搬运

查看全部评分

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部