查看: 7683|回复: 26

[原创发布] 【MV·道具栏New提示】新获得道具在物品栏里绘制个New!

[复制链接]

无限の剣制

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

开拓者贵宾

发表于 2018-12-30 08:12:36 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 VIPArcher 于 2019-1-7 19:10 编辑

2019/1/7 更新了一下
修正了使用图标时没有正确使用坐标偏移量的bug
添加了一个开关设置,设定的开关开启时获得新道具将不会被记录为新道具
帖子里添加了一张效果图展示使用效果
QQ图片20190107152520.png
获得新道具的时候在物品栏道具图标下添加一个 NEW! 的小图标
  1. //=============================================================================
  2. // VIPArcher_ShowNewItem.js
  3. //-----------------------------------------------------------------------------
  4. // Project1 论坛:https://rpg.blue/ 使用或转载请保留以上信息。
  5. //=============================================================================
  6. /*:
  7. * 说明: 用到的素材储存于 img/system 文件夹中
  8. * @plugindesc 获得新道具时在物品栏列表中添加一个 New 的小图标
  9. * 图标可以使用自定的单独素材或者 IconSet.png 里的图标
  10. * @author VIPArcher
  11. *
  12. * @param NewIcon
  13. * @desc 设置为 数字 时使用 IconSet.png 中对应位置的图标
  14. * 设置为 字符串 时使用 system 目录中对应文件名的素材
  15. * @default NewIcon
  16. * @dir img/system/
  17. * @type file
  18. *
  19. * @param Switch
  20. * @desc 不记录新物品开关,此开启时获得任何物品都不记录为新道具
  21. * 默认: 0 (不使用开关控制)
  22. * @default 0
  23. * @type switch
  24. *
  25. * @param OffsetX
  26. * @desc 图标相对位置的 X 坐标偏移
  27. * 默认: 0
  28. * @default 0
  29. * @type number
  30. *
  31. * @param OffsetY
  32. * @desc 图标相对位置的 Y 坐标偏移
  33. * 默认: 0
  34. * @default 0
  35. * @type number
  36. *
  37. * @help 这个插件没有需要操作的指令,不需要帮助。
  38. */
  39. var VIPArcher = VIPArcher || {};
  40. VIPArcher.ShowNewItem = {};
  41. VIPArcher.ShowNewItem.version = '1.1.0';
  42. VIPArcher.ShowNewItem.Parameters = PluginManager.parameters('VIPArcher_ShowNewItem');
  43. var newIcon = VIPArcher.ShowNewItem.Parameters["NewIcon"] || "NewIcon";
  44. VIPArcher.ShowNewItem.NewIcon = isNaN(newIcon) ? String(newIcon) : Number(newIcon);
  45. VIPArcher.ShowNewItem.Switch  = Number(VIPArcher.ShowNewItem.Parameters["Switch"])  || 0;
  46. VIPArcher.ShowNewItem.OffsetX = Number(VIPArcher.ShowNewItem.Parameters["OffsetX"]) || 0;
  47. VIPArcher.ShowNewItem.OffsetY = Number(VIPArcher.ShowNewItem.Parameters["OffsetY"]) || 0;

  48. void function() {
  49.     var ShowNewItem = VIPArcher.ShowNewItem;
  50.     var _Scene_Boot_loadSystemImages = Scene_Boot.loadSystemImages;
  51.     Scene_Boot.loadSystemImages = function() {
  52.         _Scene_Boot_loadSystemImages.call(this);
  53.         if (isNaN(ShowNewItem.NewIcon)) {
  54.             ImageManager.reserveSystem(ShowNewItem.NewIcon);
  55.         }
  56.     };
  57.     var _Game_Party_initAllItems = Game_Party.prototype.initAllItems;
  58.     Game_Party.prototype.initAllItems = function() {
  59.         _Game_Party_initAllItems.call(this);
  60.         this._newIconList = {'I': {}, 'W': {}, 'A': {}};
  61.     };
  62.     Game_Party.prototype._newItemContainer = function(item) {
  63.         if (!item) {
  64.             return null;
  65.         } else if (DataManager.isItem(item)) {
  66.             return this._newIconList['I'];
  67.         } else if (DataManager.isWeapon(item)) {
  68.             return this._newIconList['W'];
  69.         } else if (DataManager.isArmor(item)) {
  70.             return this._newIconList['A'];
  71.         } else {
  72.             return null;
  73.         }
  74.     };
  75.     Game_Party.prototype._setNewIcon = function(item) {
  76.         var container = this._newItemContainer(item);
  77.         if (container && !this.itemIsNew(item)) container[item.id] = true;
  78.     };
  79.     Game_Party.prototype.itemIsNew = function(item) {
  80.         var container = this._newItemContainer(item);
  81.         if (container) {
  82.             return container[item.id];
  83.         } else {
  84.             return null;
  85.         }
  86.     };
  87.     Game_Party.prototype.removeNewIcon = function(item) {
  88.         var container = this._newItemContainer(item);
  89.         if (container) delete container[item.id];
  90.     };
  91.     var _Game_Party_gainItem = Game_Party.prototype.gainItem;
  92.     Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
  93.         _Game_Party_gainItem.call(this, item, amount, includeEquip);
  94.         if (amount > 0 && !$gameSwitches.value(ShowNewItem.Switch)) this._setNewIcon(item);
  95.     };
  96.     var _Window_ItemList_drawItem = Window_ItemList.prototype.drawItem;
  97.     Window_ItemList.prototype.drawItem = function(index) {
  98.         _Window_ItemList_drawItem.call(this, index);
  99.         var item = this._data[index];
  100.         if (item && $gameParty.itemIsNew(item)) {
  101.             var rect = this.itemRect(index);
  102.             rect.width -= this.textPadding();
  103.             this.changePaintOpacity(this.isEnabled(item));
  104.             this.drawNewFlag(item, rect.x, rect.y);
  105.             this.changePaintOpacity(1);
  106.         }
  107.     };
  108.     Window_ItemList.prototype.drawNewFlag = function(item, x, y) {
  109.         var offsetX = ShowNewItem.OffsetX + 2;
  110.         var offsetY = ShowNewItem.OffsetY + 2;
  111.         if (isNaN(ShowNewItem.NewIcon)) {
  112.             var bitmap = ImageManager.loadSystem(ShowNewItem.NewIcon);
  113.             this.contents.blt(bitmap, 0, 0, bitmap.width, bitmap.height, x + offsetX, y + offsetY);
  114.         } else {
  115.             this.drawIcon(ShowNewItem.NewIcon, x + offsetX, y + offsetY);
  116.         }
  117.     };
  118.     var _Window_ItemList_select = Window_ItemList.prototype.select;
  119.     Window_ItemList.prototype.select = function(index) {
  120.         if (this.index() >=0) this.removeNewIcon();
  121.         _Window_ItemList_select.call(this, index);
  122.     };
  123.     Window_ItemList.prototype.removeNewIcon = function() {
  124.         $gameParty.removeNewIcon(this.item());
  125.         this.redrawItem(this.index());
  126.     };
  127.     var _Game_Actor_tradeItemWithParty = Game_Actor.prototype.tradeItemWithParty;
  128.     Game_Actor.prototype.tradeItemWithParty = function(newItem, oldItem) {
  129.         var _result = _Game_Actor_tradeItemWithParty.call(this, newItem, oldItem);
  130.         $gameParty.removeNewIcon(oldItem);
  131.         return _result;
  132.     };
  133. }();
复制代码

使用到的素材(放到目录  img/system 中):

32*32

32*32

评分

参与人数 8赞 +8 收起 理由
tuxyin + 1 塞糖
if216 + 1 我很赞同
百里_飞柳 + 1 塞糖
j296196585 + 1 精品文章
白嫩白嫩的 + 1 塞糖
wabcmcc + 1 精品文章
liz_fly + 1 塞糖
言物之石 + 1 精品文章

查看全部评分

梦石
0
星屑
5185
在线时间
611 小时
注册时间
2017-10-21
回帖
321
发表于 2019-1-7 11:35:14 | 显示全部楼层
本帖最后由 微笑的迪妮莎 于 2019-1-7 11:36 编辑

会出错呢大佬
可能跟我用的其他插件冲突吧

点评

哦,报错是第46行,好像是图片地址的识别问题。  发表于 2019-1-7 14:58
具体是什么错误呢?顺便我写的时候用的是MV1.6,旧版本MV可能会不兼容  发表于 2019-1-7 11:37
回复

使用道具 举报

梦石
0
星屑
22794
在线时间
2623 小时
注册时间
2015-7-4
回帖
918
发表于 2019-1-7 13:39:25 | 显示全部楼层
用自定义图标会报错,用系统图标可以显示,但会覆盖物品原有图标,插件参数无法调整坐标。

点评

哦!非常感谢!我修改了55行后也OK了。  发表于 2019-1-7 22:10
我找群友拿了1.5.1的MV代码测试了一下,好像没有什么问题,我目前没有1.5.0的源码能看,所以你能说明一下具体报错是什么吗?  发表于 2019-1-7 16:14
那我再添加一个1.5版本的脚本吧  发表于 2019-1-7 15:07
是的,我的MV用1.50,很多人都还在用旧版本哦,能兼容一下就更完美了。  发表于 2019-1-7 14:55
嗯,谢谢反馈,的确忘了用系统图标的时候加上坐标偏移的设置,自定义图标报错可能是因为你用的MV是旧版本  发表于 2019-1-7 14:14
回复

使用道具 举报

梦石
0
星屑
5185
在线时间
611 小时
注册时间
2017-10-21
回帖
321
发表于 2019-1-7 19:00:04 | 显示全部楼层
我游戏都进不去大佬
从新下载的
QQ图片20190107190052.png

点评

我的是1.51的,好的大佬我试试  发表于 2019-1-7 19:20
你试试把55行的ImageManager.reserveSystem(ShowNewItem.NewIcon);改成ImageManager.loadSystem(ShowNewItem.NewIcon);  发表于 2019-1-7 19:15
你也是MV 1.50 以前的版本吗  发表于 2019-1-7 19:11
回复

使用道具 举报

梦石
0
星屑
5185
在线时间
611 小时
注册时间
2017-10-21
回帖
321
发表于 2019-1-7 19:23:56 | 显示全部楼层
本帖最后由 微笑的迪妮莎 于 2019-1-7 19:25 编辑

大佬可以用了,不出错了,但是貌似不适用于我~~~
QQ图片20190107192450.png

QQ图片20190107192628.png

点评

嗯,其实你可以调整一下位置呗(×  发表于 2019-1-7 19:28
回复

使用道具 举报

梦石
0
星屑
5185
在线时间
611 小时
注册时间
2017-10-21
回帖
321
发表于 2019-1-7 19:38:08 | 显示全部楼层
原来如此  会用了  谢谢大佬的辛劳创作
QQ图片20190107193843.png
我已转发了 保留了版权

点评

好的大佬 已经加上了  发表于 2019-1-7 19:45
转载可以,但是要带上原帖链接。因为也许未来还有bug需要更新  发表于 2019-1-7 19:44
回复

使用道具 举报

梦石
0
星屑
122
在线时间
32 小时
注册时间
2019-3-20
回帖
28
发表于 2019-4-14 00:42:46 | 显示全部楼层
微笑的迪妮莎 发表于 2019-1-7 19:38
原来如此  会用了  谢谢大佬的辛劳创作

我已转发了 保留了版权

哥们,你的物品简介怎么弄的
回复

使用道具 举报

梦石
0
星屑
2228
在线时间
245 小时
注册时间
2019-3-23
回帖
18
发表于 2019-4-14 22:24:39 | 显示全部楼层
大佬,我在物品栏里面没有出现这个显示,但是在装备里面选装备就会显示,这是怎么回事呀

1

1

点评

可能是其他脚本改变了绘制的位置,或者修改了绘制道具的方法,只看截图我也看不出什么端倪(x  发表于 2019-4-14 23:57
回复

使用道具 举报

梦石
0
星屑
2228
在线时间
245 小时
注册时间
2019-3-23
回帖
18
发表于 2019-4-15 23:14:04 | 显示全部楼层
wesleylsw 发表于 2019-4-14 22:24
大佬,我在物品栏里面没有出现这个显示,但是在装备里面选装备就会显示,这是怎么回事呀 ...

装备里面是能看到这个标识,物品里面就不显示,我尝试把插件直接放在最后物品也不显示,不怎么会弄,能价个Q解决一下么,弄好有酬谢
回复

使用道具 举报

梦石
0
星屑
68
在线时间
31 小时
注册时间
2009-7-29
回帖
63
发表于 2020-1-29 15:11:21 | 显示全部楼层
感谢分享!

点评

你又开始灌水!!?  发表于 2020-1-29 15:20
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部