Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // ItemBook.js
- //=============================================================================
- /*:
- * @plugindesc v1.03 + SkottyTV Update 03 // Displays detailed statuses of items.
- * @author Yoji Ojima (Compatibility with YEP) / + SkottyTV (thx to DragonPC)
- *
- * @param ----- Functions -----
- *
- * @param Unknown Data
- * @desc The index name for an unknown item.
- * @default ??????
- *
- * @param AutoFill
- * @desc Decide if items will automaticly show up in the book
- * when collected. (true or false)
- * @default true
- *
- * @param Gold Icon
- * @desc Decide if you want to use the Gold Icon from
- * Yanfly Core Engine. (true or false)
- * @default true
- *
- * @param Items in Row
- * @desc Decide how many items you want to show in one row.
- * (default 1)
- * @default 1
- *
- * @param Show Key Items
- * @desc Decide if you want to show the Key Items.
- * (default true)
- * @default true
- *
- * @param ----- Visuals -----
- *
- * @param Price Text
- * @desc The text for "Price".
- * @default Price
- *
- * @param Equip Text
- * @desc The text for "Equip".
- * @default Equip
- *
- * @param Type Text
- * @desc The text for "Type".
- * @default Type
- *
- * @param Half Index Height
- * @desc Decide if you want to half the Index height. (default true)
- * @default true
- *
- * @param Show Price Switch
- * @desc Choose the switch ID that shows the price. (default 0)
- * @default 0
- *
- * @param Show Equip/Type Switch
- * @desc Choose the switch ID that shows the equip/type. (default 0)
- * @default 0
- *
- * @param Show Status Switch
- * @desc Choose the switch ID that shows the stats. (default 0)
- * @default 0
- *
- * @help
- *
- * ============================================================================
- * SkottyTV Update 01 ->
- *
- * - Decide if items will get an entry automaticly when they collected!
- * - Decide how many items appear in one row!
- * - Decide if you want to use the Gold Icon from Yanflys Core Engine!
- * - Advanced Visual upgrades!
- *
- * SkottyTV Update 02 ->
- *
- * - Visual upgrades!
- *
- * SkottyTV Update 03 ->
- *
- * - Decide if you want to half the Index height.
- * - Decide if you want to show Key Items.
- * - Advanced Visual upgrades!
- * - Use switches to enable different information!
- * (Price, Equip/Type, Stats)
- * ============================================================================
- *
- * Plugin Command:
- * ItemBook open # Open the item book screen
- * ItemBook add item 1 # Add item #1 to the item book
- * ItemBook add weapon 2 # Add weapon #2 to the item book
- * ItemBook add armor 3 # Add armor #3 to the item book
- * ItemBook remove item 4 # Remove item #4 from the item book
- * ItemBook remove weapon 5 # Remove weapon #5 from the item book
- * ItemBook remove armor 6 # Remove armor #6 from the item book
- * ItemBook complete # Complete the item book
- * ItemBook clear # Clear the item book
- *
- * Item (Weapon, Armor) Note:
- * <book:no> # This item does not appear in the item book
- */
- /*:ja
- * @plugindesc アイテム図鑑ã§ã™ã€‚アイテムã®è©³ç´°ãªã‚¹ãƒ†ãƒ¼ã‚¿ã‚¹ã‚’表示ã—ã¾ã™ã€‚
- * @author Yoji Ojima (Compatibility with YEP) / + SkottyTV (thx to DragonPC)
- *
- * @param Unknown Data
- * @desc 未確èªã®ã‚¢ã‚¤ãƒ†ãƒ ã®ç´¢å¼•åã§ã™ã€‚
- * @default ??????
- *
- * @param Price Text
- * @desc ã€Œä¾¡æ ¼ã€ã®æ–‡å—列ã§ã™ã€‚
- * @default ä¾¡æ ¼
- *
- * @param Equip Text
- * @desc 「装備ã€ã®æ–‡å—列ã§ã™ã€‚
- * @default 装備
- *
- * @param Type Text
- * @desc 「タイプã€ã®æ–‡å—列ã§ã™ã€‚
- * @default タイプ
- *
- * @param Gold Icon
- * @desc Decide if you want to use the Gold Icon from Yanfly Core Engine.
- * (true or false)
- * @default true
- *
- * @param AutoFill
- * @desc Decide if items will automaticly show up in the book
- * when collected. (true or false)
- * @default true
- *
- * @param Items in Row
- * @desc Decide how many items you want to show in one row.
- * (default 1)
- * @default 1
- *
- * @param Half Index Height
- * @desc Decide if you want to half the Index height.
- * (default true)
- * @default true
- *
- * @param Show Price Switch
- * @desc Choose the switch ID that shows the price.
- * (default 0)
- * @default 0
- *
- * @param Show Equip/Type Switch
- * @desc Choose the switch ID that shows the equip/type.
- * (default 0)
- * @default 0
- *
- * @param Show Status Switch
- * @desc Choose the switch ID that shows the stats.
- * (default 0)
- * @default 0
- *
- * @param Show Key Items
- * @desc Decide if you want to show the Key Items.
- * (default true)
- * @default true
- *
- * @help
- *
- * ============================================================================
- * SkottyTV Update 01 ->
- *
- * - Decide if items will get an entry automaticly when they collected!
- * - Decide how many items appear in one row!
- * - Decide if you want to use the Gold Icon from Yanflys Core Engine!
- * - Advanced Visual upgrades!
- *
- * SkottyTV Update 02 ->
- *
- * - Visual upgrades!
- *
- * SkottyTV Update 03 ->
- *
- * - Decide if you want to half the Index height.
- * - Decide if you want to show Key Items.
- * - Advanced Visual upgrades!
- * - Use switches to enable different information!
- * (Price, Equip/Type, Stats)
- * ============================================================================
- *
- * プラグインコマンド:
- * ItemBook open # 図鑑画é¢ã‚’é–‹ã
- * ItemBook add item 1 # Add item #1 to the item book
- * ItemBook add weapon 3 # æ¦å™¨ï¼“番を図鑑ã«è¿½åŠ
- * ItemBook add armor 4 # 防具4番を図鑑ã«è¿½åŠ
- * ItemBook remove weapon 2 # Remove weapon #2 from the item book
- * ItemBook remove armor 5 # 防具5番を図鑑ã‹ã‚‰å‰Šé™¤
- * ItemBook remove item 6 # アイテム6番を図鑑ã‹ã‚‰å‰Šé™¤
- * ItemBook complete # 図鑑を完æˆã•ã›ã‚‹
- * ItemBook clear # 図鑑をクリアã™ã‚‹
- *
- * アイテム(æ¦å™¨ã€é˜²å…·ï¼‰ã®ãƒ¡ãƒ¢:
- * <book:no> # 図鑑ã«è¼‰ã›ãªã„å ´åˆ
- */
- (function() {
- var parameters = PluginManager.parameters('ItemBook');
- var unknownData = String(parameters['Unknown Data'] || '??????');
- var priceText = String(parameters['Price Text'] || 'Price');
- var equipText = String(parameters['Equip Text'] || 'Equip');
- var typeText = String(parameters['Type Text'] || 'Type');
- var goldIcon = String(parameters['Gold Icon'] || 'true');
- var listRow = Number(parameters['Items in Row']);
- var autoFill = String(parameters['AutoFill'] || 'true');
- var IndexHeight = String(parameters['Half Index Height'] || 'true');
- var ShowStatus = Number(parameters['Show Status Switch']);
- var ShowPrice = Number(parameters['Show Price Switch']);
- var ShowType = Number(parameters['Show Equip/Type Switch']);
- var ShowKeyItems = String(parameters['Show Key Items'] || 'true');
- var _Game_Interpreter_pluginCommand =
- Game_Interpreter.prototype.pluginCommand;
- Game_Interpreter.prototype.pluginCommand = function(command, args) {
- _Game_Interpreter_pluginCommand.call(this, command, args);
- if (command === 'ItemBook') {
- switch (args[0]) {
- case 'open':
- SceneManager.push(Scene_ItemBook);
- break;
- case 'add':
- $gameSystem.addToItemBook(args[1], Number(args[2]));
- break;
- case 'remove':
- $gameSystem.removeFromItemBook(args[1], Number(args[2]));
- break;
- case 'complete':
- $gameSystem.completeItemBook();
- break;
- case 'clear':
- $gameSystem.clearItemBook();
- break;
- }
- }
- };
- Game_System.prototype.addToItemBook = function(type, dataId) {
- if (!this._ItemBookFlags) {
- this.clearItemBook();
- }
- var typeIndex = this.itemBookTypeToIndex(type);
- if (typeIndex >= 0) {
- this._ItemBookFlags[typeIndex][dataId] = true;
- }
- };
- Game_System.prototype.removeFromItemBook = function(type, dataId) {
- if (this._ItemBookFlags) {
- var typeIndex = this.itemBookTypeToIndex(type);
- if (typeIndex >= 0) {
- this._ItemBookFlags[typeIndex][dataId] = false;
- }
- }
- };
- Game_System.prototype.itemBookTypeToIndex = function(type) {
- switch (type) {
- case 'item':
- return 0;
- case 'weapon':
- return 1;
- case 'armor':
- return 2;
- default:
- return -1;
- }
- };
- Game_System.prototype.completeItemBook = function() {
- var i;
- this.clearItemBook();
- for (i = 1; i < $dataItems.length; i++) {
- this._ItemBookFlags[0][i] = true;
- }
- for (i = 1; i < $dataWeapons.length; i++) {
- this._ItemBookFlags[1][i] = true;
- }
- for (i = 1; i < $dataArmors.length; i++) {
- this._ItemBookFlags[2][i] = true;
- }
- };
- Game_System.prototype.clearItemBook = function() {
- this._ItemBookFlags = [[], [], []];
- };
- Game_System.prototype.isInItemBook = function(item) {
- if (this._ItemBookFlags && item) {
- var typeIndex = -1;
- if (DataManager.isItem(item)) {
- typeIndex = 0;
- } else if (DataManager.isWeapon(item)) {
- typeIndex = 1;
- } else if (DataManager.isArmor(item)) {
- typeIndex = 2;
- }
- if (typeIndex >= 0) {
- return !!this._ItemBookFlags[typeIndex][item.id];
- } else {
- return false;
- }
- } else {
- return false;
- }
- };
- 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 (item && amount > 0) {
- var type;
- if (DataManager.isItem(item)) {
- type = 'item';
- } else if (DataManager.isWeapon(item)) {
- type = 'weapon';
- } else if (DataManager.isArmor(item)) {
- type = 'armor';
- }
- if (autoFill === 'true') {
- $gameSystem.addToItemBook(type, item.id);
- }
- }
- };
- function Scene_ItemBook() {
- this.initialize.apply(this, arguments);
- }
- Scene_ItemBook.prototype = Object.create(Scene_MenuBase.prototype);
- Scene_ItemBook.prototype.constructor = Scene_ItemBook;
- Scene_ItemBook.prototype.initialize = function() {
- Scene_MenuBase.prototype.initialize.call(this);
- };
- Scene_ItemBook.prototype.create = function() {
- var w3 = Graphics.boxWidth / 3;
- var ww = (Graphics.boxWidth / 3)*2 + 2;
- var wh = Graphics.boxHeight / 10;
- Scene_MenuBase.prototype.create.call(this);
- this._indexWindow = new Window_ItemBookIndex(0, 0);
- this._indexWindow.setHandler('cancel', this.popScene.bind(this));
- this._statusWindow = new Window_ItemBookStatus(w3, 0, ww, wh*3);
- this._statusWindow2 = new Window_ItemBookStatus2(w3, wh*3, ww, wh*3);
- this._statusWindow3 = new Window_ItemBookStatus3(w3, (wh*6)-1, ww, (wh*4)+1);
- this.addWindow(this._indexWindow);
- this.addWindow(this._statusWindow);
- this.addWindow(this._statusWindow2);
- this.addWindow(this._statusWindow3);
- this._indexWindow.setStatusWindow(this._statusWindow);
- this._indexWindow.setStatusWindow2(this._statusWindow2);
- this._indexWindow.setStatusWindow3(this._statusWindow3);
- };
- function Window_ItemBookIndex() {
- this.initialize.apply(this, arguments);
- }
- Window_ItemBookIndex.prototype = Object.create(Window_Selectable.prototype);
- Window_ItemBookIndex.prototype.constructor = Window_ItemBookIndex;
- Window_ItemBookIndex.lastTopRow = 0;
- Window_ItemBookIndex.lastIndex = 0;
- Window_ItemBookIndex.prototype.initialize = function(x, y) {
- var width = Graphics.boxWidth / 3;
- if (IndexHeight === 'true') {
- var height = Graphics.boxHeight/2;
- }
- else{
- var height = Graphics.boxHeight;
- }
- Window_Selectable.prototype.initialize.call(this, x, y, width, height);
- this.refresh();
- this.setTopRow(Window_ItemBookIndex.lastTopRow);
- this.select(Window_ItemBookIndex.lastIndex);
- this.activate();
- };
- Window_ItemBookIndex.prototype.maxCols = function() {
- return listRow;
- };
- Window_ItemBookIndex.prototype.maxItems = function() {
- return this._list ? this._list.length : 0;
- };
- Window_ItemBookIndex.prototype.setStatusWindow = function(statusWindow) {
- this._statusWindow = statusWindow;
- this.updateStatus();
- };
- Window_ItemBookIndex.prototype.setStatusWindow2 = function(statusWindow2) {
- this._statusWindow2 = statusWindow2;
- this.updateStatus();
- };
- Window_ItemBookIndex.prototype.setStatusWindow3 = function(statusWindow3) {
- this._statusWindow3 = statusWindow3;
- this.updateStatus();
- };
- Window_ItemBookIndex.prototype.update = function() {
- Window_Selectable.prototype.update.call(this);
- this.updateStatus();
- };
- Window_ItemBookIndex.prototype.updateStatus = function() {
- if (this._statusWindow) {
- var item = this._list[this.index()];
- this._statusWindow.setItem(item);
- }
- if (this._statusWindow2) {
- var item = this._list[this.index()];
- this._statusWindow2.setItem(item);
- }
- if (this._statusWindow3) {
- var item = this._list[this.index()];
- this._statusWindow3.setItem(item);
- }
- };
- Window_ItemBookIndex.prototype.refresh = function() {
- var i, item;
- this._list = [];
- for (i = 1; i < Math.min(5000, $dataItems.length); i++) {
- item = $dataItems[i];
- if (item && item.name && item.itypeId === 1 && item.meta.book !== 'no') {
- this._list.push(item);
- }
- }
- if (ShowKeyItems === 'true') {
- for (i = 1; i < Math.min(5000, $dataItems.length); i++) {
- item = $dataItems[i];
- if (item && item.name && item.itypeId === 2 && item.meta.book !== 'no') {
- this._list.push(item);
- }
- }
- }
- for (i = 1; i < Math.min(5000, $dataWeapons.length); i++) {
- item = $dataWeapons[i];
- if (item && item.name && item.meta.book !== 'no') {
- this._list.push(item);
- }
- }
- for (i = 1; i < Math.min(5000, $dataArmors.length); i++) {
- item = $dataArmors[i];
- if (item && item.name && item.meta.book !== 'no') {
- this._list.push(item);
- }
- }
- this.createContents();
- this.drawAllItems();
- };
- Window_ItemBookIndex.prototype.drawItem = function(index) {
- var item = this._list[index];
- var rect = this.itemRect(index);
- var width = rect.width - this.textPadding();
- if ($gameSystem.isInItemBook(item)) {
- this.drawItemName(item, rect.x, rect.y, width);
- } else {
- var iw = Window_Base._iconWidth + 4;
- this.drawText(unknownData, rect.x + iw, rect.y, width - iw);
- }
- };
- Window_ItemBookIndex.prototype.processCancel = function() {
- Window_Selectable.prototype.processCancel.call(this);
- Window_ItemBookIndex.lastTopRow = this.topRow();
- Window_ItemBookIndex.lastIndex = this.index();
- };
- function Window_ItemBookStatus() {
- this.initialize.apply(this, arguments);
- }
- function Window_ItemBookStatus2() {
- this.initialize.apply(this, arguments);
- }
- function Window_ItemBookStatus3() {
- this.initialize.apply(this, arguments);
- }
- Window_ItemBookStatus.prototype = Object.create(Window_Base.prototype);
- Window_ItemBookStatus.prototype.constructor = Window_ItemBookStatus;
- Window_ItemBookStatus2.prototype = Object.create(Window_Base.prototype);
- Window_ItemBookStatus2.prototype.constructor = Window_ItemBookStatus2;
- Window_ItemBookStatus3.prototype = Object.create(Window_Base.prototype);
- Window_ItemBookStatus3.prototype.constructor = Window_ItemBookStatus3;
- Window_ItemBookStatus.prototype.initialize = function(x, y, width, height) {
- Window_Base.prototype.initialize.call(this, x, y, width, height);
- };
- Window_ItemBookStatus.prototype.setItem = function(item) {
- if (this._item !== item) {
- this._item = item;
- this.refresh();
- }
- };
- Window_ItemBookStatus2.prototype.setItem = function(item) {
- if (this._item !== item) {
- this._item = item;
- this.refresh();
- }
- };
- Window_ItemBookStatus3.prototype.setItem = function(item) {
- if (this._item !== item) {
- this._item = item;
- this.refresh();
- }
- };
- Window_ItemBookStatus.prototype.refresh = function() {
- var item = this._item;
- var x = 10;
- var y = 0;
- var lineHeight = this.lineHeight();
- this.contents.clear();
- if (!item || !$gameSystem.isInItemBook(item)) {
- return;
- }
- this.drawItemName(item, x-1, y);
- this.drawTextEx(item.description, 10, y + lineHeight*2);
- };
- Window_ItemBookStatus2.prototype.refresh = function() {
- var item = this._item;
- var x = 10;
- var y = 0;
- var lineHeight = this.lineHeight();
- this.contents.clear();
- if (!item || !$gameSystem.isInItemBook(item)) {
- return;
- }
- if ($gameSwitches.value(ShowPrice) === true || ShowPrice === 0) {
- var price = item.price > 0 ? item.price : '-';
- this.changeTextColor(this.systemColor());
- this.drawText(priceText + ':', x, y, 120);
- this.resetTextColor();
- if (goldIcon === 'true') {
- this.drawText(price, x+60, y, 145, 'right');
- this.drawIcon(Yanfly.Icon.Gold, x+210, y)
- } else {
- this.drawText(price, x+96, y, 145, 'right');
- }
- }
- if ($gameSwitches.value(ShowType) === true || ShowType === 0) {
- if (DataManager.isWeapon(item) || DataManager.isArmor(item)) {
- var etype = $dataSystem.equipTypes[item.etypeId];
- this.changeTextColor(this.systemColor());
- this.drawText(equipText + ':', x, y+lineHeight*3, 120);
- this.resetTextColor();
- this.drawText(etype, x + 120, y+lineHeight*3, 120, 'right');
- y += lineHeight*2;
- var type;
- if (DataManager.isWeapon(item)) {
- type = $dataSystem.weaponTypes[item.wtypeId];
- } else {
- type = $dataSystem.armorTypes[item.atypeId];
- }
- this.changeTextColor(this.systemColor());
- this.drawText(typeText + ':', x, y, 120);
- this.resetTextColor();
- this.drawText(type, x + 120, y, 120, 'right');
- x = this.textPadding() + 350;
- }
- }
- };
- Window_ItemBookStatus3.prototype.refresh = function() {
- var item = this._item;
- var x = 10;
- var y = 0;
- var lineHeight = this.lineHeight();
- this.contents.clear();
- if (!item || !$gameSystem.isInItemBook(item)) {
- return;
- }
- if ($gameSwitches.value(ShowStatus) === true || ShowStatus === 0) {
- if (DataManager.isWeapon(item) || DataManager.isArmor(item)) {
- for (var i = 0; i < 8; i++) {
- this.changeTextColor(this.systemColor());
- this.drawText(TextManager.param(i), x, y, 160);
- this.resetTextColor();
- this.drawText(item.params[i], x + 180, y, 60, 'right');
- y += lineHeight;
- }
- }
- }
- };
- })();
RAW Paste Data