查看: 7544|回复: 26

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

[复制链接]

无限の剣制

梦石
0
星屑
10445
在线时间
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! 的小图标
[pre lang="javascript"]//=============================================================================
// VIPArcher_ShowNewItem.js
//-----------------------------------------------------------------------------
// Project1 论坛:https://rpg.blue/ 使用或转载请保留以上信息。
//=============================================================================
/*:
* 说明: 用到的素材储存于 img/system 文件夹中
* @plugindesc 获得新道具时在物品栏列表中添加一个 New 的小图标
* 图标可以使用自定的单独素材或者 IconSet.png 里的图标
* @author VIPArcher
*
* @param NewIcon
* @desc 设置为 数字 时使用 IconSet.png 中对应位置的图标
* 设置为 字符串 时使用 system 目录中对应文件名的素材
* @default NewIcon
* @dir img/system/
* @type file
*
* @param Switch
* @desc 不记录新物品开关,此开启时获得任何物品都不记录为新道具
* 默认: 0 (不使用开关控制)
* @default 0
* @type switch
*
* @param OffsetX
* @desc 图标相对位置的 X 坐标偏移
* 默认: 0
* @default 0
* @type number
*
* @param OffsetY
* @desc 图标相对位置的 Y 坐标偏移
* 默认: 0
* @default 0
* @type number
*
* @help 这个插件没有需要操作的指令,不需要帮助。
*/
var VIPArcher = VIPArcher || {};
VIPArcher.ShowNewItem = {};
VIPArcher.ShowNewItem.version = '1.1.0';
VIPArcher.ShowNewItem.Parameters = PluginManager.parameters('VIPArcher_ShowNewItem');
var newIcon = VIPArcher.ShowNewItem.Parameters["NewIcon"] || "NewIcon";
VIPArcher.ShowNewItem.NewIcon = isNaN(newIcon) ? String(newIcon) : Number(newIcon);
VIPArcher.ShowNewItem.Switch  = Number(VIPArcher.ShowNewItem.Parameters["Switch"])  || 0;
VIPArcher.ShowNewItem.OffsetX = Number(VIPArcher.ShowNewItem.Parameters["OffsetX"]) || 0;
VIPArcher.ShowNewItem.OffsetY = Number(VIPArcher.ShowNewItem.Parameters["OffsetY"]) || 0;

void function() {
    var ShowNewItem = VIPArcher.ShowNewItem;
    var _Scene_Boot_loadSystemImages = Scene_Boot.loadSystemImages;
    Scene_Boot.loadSystemImages = function() {
        _Scene_Boot_loadSystemImages.call(this);
        if (isNaN(ShowNewItem.NewIcon)) {
            ImageManager.reserveSystem(ShowNewItem.NewIcon);
        }
    };
    var _Game_Party_initAllItems = Game_Party.prototype.initAllItems;
    Game_Party.prototype.initAllItems = function() {
        _Game_Party_initAllItems.call(this);
        this._newIconList = {'I': {}, 'W': {}, 'A': {}};
    };
    Game_Party.prototype._newItemContainer = function(item) {
        if (!item) {
            return null;
        } else if (DataManager.isItem(item)) {
            return this._newIconList['I'];
        } else if (DataManager.isWeapon(item)) {
            return this._newIconList['W'];
        } else if (DataManager.isArmor(item)) {
            return this._newIconList['A'];
        } else {
            return null;
        }
    };
    Game_Party.prototype._setNewIcon = function(item) {
        var container = this._newItemContainer(item);
        if (container && !this.itemIsNew(item)) container[item.id] = true;
    };
    Game_Party.prototype.itemIsNew = function(item) {
        var container = this._newItemContainer(item);
        if (container) {
            return container[item.id];
        } else {
            return null;
        }
    };
    Game_Party.prototype.removeNewIcon = function(item) {
        var container = this._newItemContainer(item);
        if (container) delete container[item.id];
    };
    var _Game_Party_gainItem = Game_Party.prototype.gainItem;
    Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
        _Game_Party_gainItem.call(this, item, amount, includeEquip);
        if (amount > 0 && !$gameSwitches.value(ShowNewItem.Switch)) this._setNewIcon(item);
    };
    var _Window_ItemList_drawItem = Window_ItemList.prototype.drawItem;
    Window_ItemList.prototype.drawItem = function(index) {
        _Window_ItemList_drawItem.call(this, index);
        var item = this._data[index];
        if (item && $gameParty.itemIsNew(item)) {
            var rect = this.itemRect(index);
            rect.width -= this.textPadding();
            this.changePaintOpacity(this.isEnabled(item));
            this.drawNewFlag(item, rect.x, rect.y);
            this.changePaintOpacity(1);
        }
    };
    Window_ItemList.prototype.drawNewFlag = function(item, x, y) {
        var offsetX = ShowNewItem.OffsetX + 2;
        var offsetY = ShowNewItem.OffsetY + 2;
        if (isNaN(ShowNewItem.NewIcon)) {
            var bitmap = ImageManager.loadSystem(ShowNewItem.NewIcon);
            this.contents.blt(bitmap, 0, 0, bitmap.width, bitmap.height, x + offsetX, y + offsetY);
        } else {
            this.drawIcon(ShowNewItem.NewIcon, x + offsetX, y + offsetY);
        }
    };
    var _Window_ItemList_select = Window_ItemList.prototype.select;
    Window_ItemList.prototype.select = function(index) {
        if (this.index() >=0) this.removeNewIcon();
        _Window_ItemList_select.call(this, index);
    };
    Window_ItemList.prototype.removeNewIcon = function() {
        $gameParty.removeNewIcon(this.item());
        this.redrawItem(this.index());
    };
    var _Game_Actor_tradeItemWithParty = Game_Actor.prototype.tradeItemWithParty;
    Game_Actor.prototype.tradeItemWithParty = function(newItem, oldItem) {
        var _result = _Game_Actor_tradeItemWithParty.call(this, newItem, oldItem);
        $gameParty.removeNewIcon(oldItem);
        return _result;
    };
}();[/pre]
使用到的素材(放到目录  img/system 中):

32*32

32*32

评分

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

查看全部评分

梦石
0
星屑
5170
在线时间
610 小时
注册时间
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
星屑
22573
在线时间
2604 小时
注册时间
2015-7-4
回帖
917
发表于 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
星屑
5170
在线时间
610 小时
注册时间
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
星屑
5170
在线时间
610 小时
注册时间
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
星屑
5170
在线时间
610 小时
注册时间
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.

在本版发帖返回顶部