查看: 3815|回复: 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

[fold=脚本][pre lang="javascript"]/*:
* @plugindesc v1.0 Tries to load jpg files if no png found
* @author Procraftynation - procrastination done right!
*
* @param Prioritize JPG
* @desc Tries to load jpg files first before trying png
* Values: true | false
* @default false
*/

var Imported = Imported || {};
Imported.DEX_TryJPG = true;
(function() {
   var DEX = DEX || {}; //DEX's main object
   DEX.TryJPG = DEX.TryJPG || {}; // tombstone object for functions and aliases
   
   DEX.TryJPG.jpgFirst = String(PluginManager.parameters('DEX_TryJPG')["Prioritize JPG"]);//true or false
   
   //'function overrides' will depend on the Prioritize JPG flag.
   if(eval(DEX.TryJPG.jpgFirst)) {
      ImageManager.loadBitmap = function(folder, filename, hue, smooth) {
         if (filename) {
           var path = folder + encodeURIComponent(filename) + '.jpg';//changed from png to jpg
           var bitmap = this.loadNormalBitmap(path, hue || 0);
           bitmap.smooth = smooth;
           return bitmap;
         } else {
           return this.loadEmptyBitmap();
         }
      };
      Bitmap.prototype._onError = function() {
         if(!this._triedPNG) {
            //change extension file to png assuming the last 3 characters of src is jpg
            this._image.src = this._image.src.substr(0,this._image.src.length-3) + 'png';
            this._triedPNG = true;
         } else {
            this._hasError = true;
         }
      };
   } else {
      Bitmap.prototype._onError = function() {
         if(!this._triedJPG) {
            //change extension file to jpg assuming the last 3 characters of src is png
            this._image.src = this._image.src.substr(0,this._image.src.length-3) + 'jpg';
            this._triedJPG = true;
         } else {
            this._hasError = true;
         }
      };
   }
})();[/pre][/fold]

评分

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

查看全部评分

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

本版积分规则

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

在本版发帖返回顶部