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

Project1

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

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

[复制链接]

Lv4.逐梦者 (版主)

无限の剣制

梦石
0
星屑
9956
在线时间
5019 小时
注册时间
2013-2-28
帖子
5030

开拓者贵宾

跳转到指定楼层
1
发表于 2018-12-30 08:12:36 | 显示全部楼层 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

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

2019/1/7 更新了一下
修正了使用图标时没有正确使用坐标偏移量的bug
添加了一个开关设置,设定的开关开启时获得新道具将不会被记录为新道具
帖子里添加了一张效果图展示使用效果

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

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

评分

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

查看全部评分

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

本版积分规则

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

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

GMT+8, 2024-5-3 10:27

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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