查看: 6242|回复: 3

[有事请教] [已解决]如何对物品icon图标大小进行修改

[复制链接]
梦石
0
星屑
281
在线时间
35 小时
注册时间
2018-7-3
回帖
4
发表于 2019-7-23 19:29:26 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 德邦之翼 于 2019-7-25 20:54 编辑

如果使用YEP的CoreEngine插件修改图标大小和行高的话会导致其他窗口的行高发生改变,因此想要只修改物品窗口的图标大小。写了一个简单的插件但是只能显示一个图标(也就是第一个),并且物品名称文字消失,求解问题出在哪里?
yep修改.png 这是用YEP插件修改的结果

自己插件.png 这是用自己写的插件的结果
自己的插件代码:

  1. //=============================================================================
  2. // ItemIconChange.js
  3. //=============================================================================
  4. /*:
  5. * @plugindesc 修改物品图标图片大小
  6. * @author 德邦之翼
  7. *
  8. * @param Icon Height
  9. * @desc The value of height of icons.
  10. * @default 32
  11. *
  12. * @param Icon Width
  13. * @desc The value of width of icons.
  14. * @default 32
  15. *
  16. * @help
  17. */

  18. (function() {
  19.     var parameters = [];
  20.     parameters = PluginManager.parameters('ItemIconChange');
  21.     var iconHight = String(parameters['Icon Height']);
  22.     var iconWidth = String(parameters['Icon Width']);
  23.     Window_ItemList._iconWidth  = iconWidth;
  24.     Window_ItemList._iconHeight = iconHight;
  25.    
  26.     Window_ItemList.prototype.lineHeight = function() {
  27.         return 106;
  28.     };
  29.    
  30.     Window_ItemList.prototype.drawIcon = function(iconIndex, x, y) {
  31.         var bitmap = ImageManager.loadSystem('IconSet');
  32.         var pw = Window_ItemList._iconWidth;
  33.         var ph = Window_ItemList._iconHeight;
  34.         var sx = iconIndex % 16 * pw;
  35.         var sy = Math.floor(iconIndex / 16) * ph;
  36.         console.log('sx =',sx,'sy =',sy,'x =',x,'y =',y);
  37.         this.contents.blt(bitmap, sx, sy, pw, ph, x, y);
  38.     };

  39.     Window_ItemList.prototype.drawItemName = function(item, x, y, width) {
  40.         width = width || 312;
  41.         if (item) {
  42.             var iconBoxWidth = Window_ItemList._iconWidth + 4;
  43.             this.resetTextColor();
  44.             this.drawIcon(item.iconIndex, x + 2, y + 2);
  45.             this.drawText(item.name, x + iconBoxWidth, y, width - iconBoxWidth);
  46.         }
  47.     };

  48.     Window_ItemList.prototype.processDrawIcon = function(iconIndex, textState) {
  49.         this.drawIcon(iconIndex, textState.x + 2, textState.y + 2);
  50.         textState.x += Window_ItemList._iconWidth + 4;
  51.     };

  52. })();
复制代码


YEP的coreEngine里是直接修改了Window_Base._iconWidth来达成的效果,然而我用自己写的方法直接修改Window_Base._iconWidth一样无法达成和YEP的插件一样的效果,这一点我毫无头绪。。。

评分

参与人数 1赞 +1 收起 理由
白嫩白嫩的 + 1 精品文章

查看全部评分

无限の剣制

梦石
0
星屑
10450
在线时间
5019 小时
注册时间
2013-2-28
回帖
4942

开拓者贵宾

发表于 2019-7-25 00:56:46 | 显示全部楼层
本帖最后由 VIPArcher 于 2019-7-25 01:00 编辑

看了一下你的脚本,第23和24行的
    var iconHight = String(parameters['Icon Height']);
    var iconWidth = String(parameters['Icon Width']);
应该改成
    var iconHight = Number(parameters['Icon Height']);
    var iconWidth = Number(parameters['Icon Width']);
否则iconHight 和 iconWidth 会被读取成字符串,在进行加减之类操作的时候会出现意料之外的情况
例如
  1. "32" + 4 = "324"
复制代码

其他问题就是你这个IconSet文件也得改成对应大小的素材文件。
  1. //=============================================================================
  2. // ItemIconChange.js
  3. //=============================================================================
  4. /*:
  5. * @plugindesc 修改物品图标图片大小
  6. * @author 德邦之翼
  7. *
  8. * @param Icon Height
  9. * @desc The value of height of icons.
  10. * @default 32
  11. * @type number
  12. *
  13. * @param Icon Width
  14. * @desc The value of width of icons.
  15. * @default 32
  16. * @type number
  17. *
  18. * @help
  19. */

  20. (function() {
  21.     var parameters = [];
  22.     parameters = PluginManager.parameters('ItemIconChange');
  23.     var iconHight = Number(parameters['Icon Height']);
  24.     var iconWidth = Number(parameters['Icon Width']);
  25.     Window_ItemList._iconWidth  = iconWidth;
  26.     Window_ItemList._iconHeight = iconHight;
  27.    
  28.     Window_ItemList.prototype.lineHeight = function() {
  29.         return 106;
  30.     };
  31.    
  32.     Window_ItemList.prototype.drawIcon = function(iconIndex, x, y) {
  33.         var bitmap = ImageManager.loadSystem('IconSet');
  34.         var pw = Window_ItemList._iconWidth;
  35.         var ph = Window_ItemList._iconHeight;
  36.         var sx = iconIndex % 16 * pw;
  37.         var sy = Math.floor(iconIndex / 16) * ph;
  38.         console.log('sx =',sx,'sy =',sy,'x =',x,'y =',y);
  39.         this.contents.blt(bitmap, sx, sy, pw, ph, x, y);
  40.     };

  41.     Window_ItemList.prototype.drawItemName = function(item, x, y, width) {
  42.         width = width || 312;
  43.         if (item) {
  44.             var iconBoxWidth = Window_ItemList._iconWidth + 4;
  45.             this.resetTextColor();
  46.             this.drawIcon(item.iconIndex, x + 2, y + 2);
  47.             this.drawText(item.name, x + iconBoxWidth, y, width - iconBoxWidth);
  48.         }
  49.     };

  50.     Window_ItemList.prototype.processDrawIcon = function(iconIndex, textState) {
  51.         this.drawIcon(iconIndex, textState.x + 2, textState.y + 2);
  52.         textState.x += Window_ItemList._iconWidth + 4;
  53.     };

  54. })();
复制代码

评分

参与人数 2赞 +2 收起 理由
白嫩白嫩的 + 1 塞糖
wabcmcc + 1 塞糖

查看全部评分

回复 1 0

使用道具 举报

梦石
0
星屑
281
在线时间
35 小时
注册时间
2018-7-3
回帖
4
 楼主| 发表于 2019-7-25 20:53:04 | 显示全部楼层
VIPArcher 发表于 2019-7-25 00:56
看了一下你的脚本,第23和24行的
    var iconHight = String(parameters['Icon Height']);
    var iconWi ...

感谢!修改之后能够成功运行了!犯了一个很傻的错误!

评分

参与人数 1赞 +1 收起 理由
白嫩白嫩的 + 1 塞糖

查看全部评分

回复

使用道具 举报

梦石
0
星屑
128
在线时间
11 小时
注册时间
2019-7-3
回帖
20
发表于 2019-7-26 00:38:46 | 显示全部楼层
这是要搞密室逃脱吗
承接游戏LOGO设计 +W信:amwdhqc
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部