//=============================================================================
// 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;
};
}();