/*: 2 * @target MV 3 * @plugindesc v1.0 对物品顺序进行重新排列。 4 * @author 2D_猫 5 * @url [url]https://space.bilibili.com/137028995[/url] 6 * 7 * @help 8 * * 使用方法:在数据库为物品命名时,物品名称前加上“x>”前缀,“x”是一个正整数,代 9 * 表该物品的排列优先级,也就是说,数字越小的物品在物品栏中越靠前。未加“x>”前缀 10 * 的物品,将按照该物品的默认顺序排列在加了“x>”前缀的物品的后面。 11 * 12 * * 使用条款:免费用于任何商业或非商业目的;允许在保留原作者信息的前提下修改代 13 * 码;请在你的项目中致谢“2D_猫”,谢谢!:) 14 * 15 * |\ /| _ 16 * |-\____/-| // 17 * | | // 18 * | O O |_______// 19 * \__^___/ \ 20 * | | 21 * / __ ______ \ 22 * / / \ \ / /\ \ 23 * /_/ \_\ /_/ \_\ 24 */ 25 26 (() => { 27 Window_ItemList.prototype.makeItemList = function() { 28 this._data = $gameParty.allItems().filter(item => this.includes(item)); 29 if (this.includes(null)) { 30 this._data.push(null); 31 } 32 33 // 按照“x>”顺序重新排序物品 34 this._data.sort((a, b) => { 35 let aOrderNum = parseInt(a.name.split(">")[0]); 36 if (aOrderNum.toString() === 'NaN') aOrderNum = Infinity; 37 let bOrderNum = parseInt(b.name.split(">")[0]); 38 if (bOrderNum.toString() === 'NaN') bOrderNum = Infinity; 39 40 return aOrderNum - bOrderNum; 41 }); 42 }; 43 44 Window_ItemList.prototype.drawItem = function(index) { 45 const item = this.itemAt(index); 46 47 if (item) { 48 // 获取物品去掉“x>”后的名称 49 let newItemName = item.name.split(">")[1]; 50 if (newItemName) item.newName = newItemName; 51 else item.newName = item.name; 52 53 const numberWidth = this.numberWidth(); 54 const rect = this.itemLineRect(index); 55 this.changePaintOpacity(this.isEnabled(item)); 56 this.drawItemName(item, rect.x, rect.y, rect.width - numberWidth); 57 this.drawItemNumber(item, rect.x, rect.y, rect.width); 58 this.changePaintOpacity(1); 59 } 60 }; 61 62 Window_Base.prototype.drawItemName = function(item, x, y, width) { 63 if (item) { 64 const iconY = y + (this.lineHeight() - ImageManager.iconHeight) / 2; 65 const textMargin = ImageManager.iconWidth + 4; 66 const itemWidth = Math.max(0, width - textMargin); 67 this.resetTextColor(); 68 this.drawIcon(item.iconIndex, x, iconY); 69 // 显示物品去掉“x>”后的名称 70 this.drawText(item.newName, x + textMargin, y, itemWidth); 71 } 72 }; 73 })();
//============================================================================= // XYZ_ItemSort.js //============================================================================= var Imported = Imported || {}; Imported.ItemSort = true; var XYZ = XYZ || {}; XYZ.ItemSort = XYZ.ItemSort || {}; XYZ.ItemSort.version = 1.00; /*: * @plugindesc 道具排序. * @author DawnKing * * @help * F8打开控制台 * getItemInfo(道具编号) 打印单个道具的排序优先 * getItemListInfo() 打印全部道具的排序优先,不进行排序 排除没填名字的 * getItemListInfoSort() 打印排序后的 道具输出情况,该顺序与游戏中的排序顺序一致 * */ XYZ.Parameters = PluginManager.parameters('XYZ_ItemSort'); // ============================================================================ // 重写 // ============================================================================ Window_ItemList.prototype.makeItemList = function() { this._data = $gameParty.allItems().filter(function(item) { return this.includes(item); }, this); if (this.includes(null)) { this._data.push(null); } this._data.sort(function(a, b) { var aLevel = a.meta['排序优先'] || 0; var bLevel = b.meta['排序优先'] || 0; return aLevel - bLevel; }); }; // Window_SkillList.prototype.makeItemList = function() { // if (this._actor) { // this._data = this._actor.skills().filter(function(item) { // return this.includes(item); // }, this); // this._data.sort(function(a, b) { // var aLevel = a.meta['排序优先'] || 0; // var bLevel = b.meta['排序优先'] || 0; // return aLevel - bLevel; // }); // } else { // this._data = []; // } // }; // ============================================================================ // 控制台调试方法 // ============================================================================ getItemInfo = function(itemId) { var item = $dataItems[itemId]; if (!item) { return; } if (item.name === '') { return; } console.log(item.name + ' --> 排序优先:' + (item.meta['排序优先'] || 0)) }; getItemListInfo = function() { for (var item of $dataItems) { if (!item) { continue; } if (item.name === '') { continue; } console.log(item.name + ' --> 排序优先:' + (item.meta['排序优先'] || 0)) } }; getItemListInfoSort = function() { var data = []; for (var item of $dataItems) { if (!item) { continue; } if (item.name === '') { continue; } data.push(item); } data.sort(function(a, b) { var aLevel = a.meta['排序优先'] || 0; var bLevel = b.meta['排序优先'] || 0; return aLevel - bLevel; }); for (var item of data) { if (!item) { continue; } if (item.name === '') { continue; } console.log(item.name + ' --> 排序优先:' + (item.meta['排序优先'] || 0)) } };
nhycs01 发表于 2023-1-11 00:27
用过以后说一下效果可以吗。我也想用,但是很怕会造成物品混乱了。
风雨妙 发表于 2023-1-11 18:37
在道具备注栏填
蜜橘团子 发表于 2023-1-11 19:10
我暂时没有用那个,因为那个要改名字,改名字是一件更严重的事情
如果要换插件什么的很麻烦,而且要改的 ...
nhycs01 发表于 2023-1-12 00:28
使用以后,我备注的,结果排到最后了……
小秋橙 发表于 2023-1-12 01:45
是的,我也跟原作者反映过“用备注是不是比改名字更好,改名字还要另外取消显示”,不过他好像觉得“备注 ...
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |