Advertisement
Jragyn

[MV] J_equipscreen

Sep 20th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // J-Equip Screen Revamp v1.0
  3. //=============================================================================
  4. // Changelog:
  5. //  v0.1: WIP plugin creatin.
  6. /*:
  7. @plugindesc Alters the equipscreen to provide greater detail about equipped items and their impacts on characters.
  8. @author J
  9. @help
  10. REQUIRES: J_base
  11. No commands are used outside of initial setup.
  12.  
  13. NOTE: Resolution of 1280x720 is what this was designed at.
  14. It will not display properly at lower resolutions, and is untested at higher.
  15. Coincidently, yanfly.moe has a core-engine that provides resolution modification.
  16.  
  17. Also, the base IconSet.png does not have all of the icons used for this.
  18. Feel free to modify them as you please, or download yanfly's VXace modification
  19. of the IconSet.
  20.  */
  21. //-----------------------------------------------------------------------------
  22. // Scene_Equip
  23. //
  24. // The scene class of the equipment screen.
  25.  
  26. function Scene_Equip() {
  27.     this.initialize.apply(this, arguments);
  28. }
  29.  
  30. Scene_Equip.prototype = Object.create(Scene_MenuBase.prototype);
  31. Scene_Equip.prototype.constructor = Scene_Equip;
  32.  
  33. Scene_Equip.prototype.initialize = function () {
  34.     Scene_MenuBase.prototype.initialize.call(this);
  35. };
  36.  
  37. Scene_Equip.prototype.create = function () {
  38.     Scene_MenuBase.prototype.create.call(this);
  39.     this.createHelpWindow();
  40.     this.createStatusWindow();
  41.     this.createCommandWindow();
  42.     this.createSlotWindow();
  43.     this.createItemWindow();
  44.     this.refreshActor();
  45.     this._helpWindow.y = SceneManager._screenHeight - this._helpWindow.height;
  46. };
  47.  
  48. Scene_Equip.prototype.createStatusWindow = function () {
  49.     this._statusWindow = new Window_EquipStatus(0, 0);
  50.     this.addWindow(this._statusWindow);
  51. };
  52.  
  53. Scene_Equip.prototype.createCommandWindow = function () {
  54.     var wx = this._statusWindow.width;
  55.     var wy = 0;
  56.     var ww = Graphics.boxWidth - this._statusWindow.width;
  57.     this._commandWindow = new Window_EquipCommand(wx, wy, ww);
  58.     this._commandWindow.setHelpWindow(this._helpWindow);
  59.     this._commandWindow.setHandler('equip', this.commandEquip.bind(this));
  60.     this._commandWindow.setHandler('optimize', this.commandOptimize.bind(this));
  61.     this._commandWindow.setHandler('clear', this.commandClear.bind(this));
  62.     this._commandWindow.setHandler('cancel', this.popScene.bind(this));
  63.     this._commandWindow.setHandler('pagedown', this.nextActor.bind(this));
  64.     this._commandWindow.setHandler('pageup', this.previousActor.bind(this));
  65.     this.addWindow(this._commandWindow);
  66. };
  67.  
  68. Scene_Equip.prototype.createSlotWindow = function () {
  69.     var wx = this._statusWindow.width;
  70.     var wy = this._commandWindow.y + this._commandWindow.height;
  71.     var ww = Graphics.boxWidth - this._statusWindow.width;
  72.     var wh = this._statusWindow.height - this._commandWindow.height;
  73.     this._slotWindow = new Window_EquipSlot(wx, wy, ww, wh);
  74.     this._slotWindow.setHelpWindow(this._helpWindow);
  75.     this._slotWindow.setStatusWindow(this._statusWindow);
  76.     this._slotWindow.setHandler('ok', this.onSlotOk.bind(this));
  77.     this._slotWindow.setHandler('cancel', this.onSlotCancel.bind(this));
  78.     this.addWindow(this._slotWindow);
  79. };
  80.  
  81. Scene_Equip.prototype.createItemWindow = function () {
  82.     var wx = 0;
  83.     var wy = this._statusWindow.height;
  84.     var ww = Graphics.boxWidth;
  85.     var wh = Graphics.boxHeight - wy - this._helpWindow.height;
  86.     this._itemWindow = new Window_EquipItem(wx, wy, ww, wh);
  87.     this._itemWindow.setHelpWindow(this._helpWindow);
  88.     this._itemWindow.setStatusWindow(this._statusWindow);
  89.     this._itemWindow.setHandler('ok', this.onItemOk.bind(this));
  90.     this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
  91.     this._slotWindow.setItemWindow(this._itemWindow);
  92.     this.addWindow(this._itemWindow);
  93. };
  94.  
  95. Scene_Equip.prototype.refreshActor = function () {
  96.     var actor = this.actor();
  97.     this._statusWindow.setActor(actor);
  98.     this._slotWindow.setActor(actor);
  99.     this._itemWindow.setActor(actor);
  100. };
  101.  
  102. Scene_Equip.prototype.commandEquip = function () {
  103.     this._slotWindow.activate();
  104.     this._slotWindow.select(0);
  105. };
  106.  
  107. Scene_Equip.prototype.commandOptimize = function () {
  108.     SoundManager.playEquip();
  109.     this.actor().optimizeEquipments();
  110.     this._statusWindow.refresh();
  111.     this._slotWindow.refresh();
  112.     this._commandWindow.activate();
  113. };
  114.  
  115. Scene_Equip.prototype.commandClear = function () {
  116.     SoundManager.playEquip();
  117.     this.actor().clearEquipments();
  118.     this._statusWindow.refresh();
  119.     this._slotWindow.refresh();
  120.     this._commandWindow.activate();
  121. };
  122.  
  123. Scene_Equip.prototype.onSlotOk = function () {
  124.     this._itemWindow.activate();
  125.     this._itemWindow.select(0);
  126. };
  127.  
  128. Scene_Equip.prototype.onSlotCancel = function () {
  129.     this._slotWindow.deselect();
  130.     this._commandWindow.activate();
  131. };
  132.  
  133. Scene_Equip.prototype.onItemOk = function () {
  134.     SoundManager.playEquip();
  135.     this.actor().changeEquip(this._slotWindow.index(), this._itemWindow.item());
  136.     this._slotWindow.activate();
  137.     this._slotWindow.refresh();
  138.     this._itemWindow.deselect();
  139.     this._itemWindow.refresh();
  140.     this._statusWindow.refresh();
  141. };
  142.  
  143. Scene_Equip.prototype.onItemCancel = function () {
  144.     this._slotWindow.activate();
  145.     this._itemWindow.deselect();
  146. };
  147.  
  148. Scene_Equip.prototype.onActorChange = function () {
  149.     this.refreshActor();
  150.     this._commandWindow.activate();
  151. };
  152.  
  153. //==================================================================
  154.  
  155. /*=========================================================================== |
  156. |  Window_EquipStatus()                                                            |
  157. |    This is an overwrite of the original Status Screen.                      |
  158. |    Likely incompatible with other scripts that deal with this screen.       |
  159. | ===========================================================================*/
  160.  
  161. function Window_EquipStatus() {
  162.     this.initialize.apply(this, arguments);
  163. }
  164.  
  165. Window_EquipStatus.prototype = Object.create(Window_Base.prototype);
  166. Window_EquipStatus.prototype.constructor = Window_EquipStatus;
  167.  
  168. Window_EquipStatus.prototype.initialize = function (x, y) {
  169.     var width = this.windowWidth();
  170.     var height = this.windowHeight();
  171.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  172.     this._actor = null;
  173.     this._tempActor = null;
  174.     this.refresh();
  175. };
  176.  
  177. Window_EquipStatus.prototype.windowWidth = function () {
  178.     return 448;
  179. };
  180.  
  181. Window_EquipStatus.prototype.windowHeight = function () {
  182.     return this.fittingHeight(this.numVisibleRows());
  183. };
  184.  
  185. Window_EquipStatus.prototype.numVisibleRows = function () {
  186.     return 10;
  187. };
  188.  
  189. Window_EquipStatus.prototype.setActor = function (actor) {
  190.     if (this._actor !== actor) {
  191.         this._actor = actor;
  192.         this.refresh();
  193.     }
  194. };
  195.  
  196. // draws the actual stats and whatnot for each parameter.
  197. Window_EquipStatus.prototype.refresh = function () {
  198.     this.contents.clear();
  199.     if (this._actor) {
  200.         this.drawActorName(this._actor, this.textPadding(), 0);
  201.         for (var i = 0; i < 8; i++) {
  202.             this.drawItem(0, (this.lineHeight()-4) * (1 + i), i, 0);
  203.         }
  204.         for (var j = 0; j < 10; j++) {
  205.            this.drawItem(144, (this.lineHeight()-4) * (1 + j), j, 1);
  206.         }
  207.         for (var k = 0; k < 10; k++) {
  208.            this.drawItem(288, (this.lineHeight()-4) * (1 + k), k, 2);
  209.         }
  210.     }
  211. };
  212.  
  213. Window_EquipStatus.prototype.setTempActor = function (tempActor) {
  214.     if (this._tempActor !== tempActor) {
  215.         this._tempActor = tempActor;
  216.         this.refresh();
  217.     }
  218. };
  219.  
  220. Window_EquipStatus.prototype.drawItem = function (x, y, paramId, pType) {
  221.     this.contents.fontSize = 18;
  222.     switch (pType) {
  223.         case 0:
  224.             this.drawIcon(IconManager.bParams(paramId), x, y);
  225.             break;
  226.         case 1:
  227.             this.drawIcon(IconManager.sParams(paramId), x, y);
  228.             break;
  229.         case 2:
  230.             this.drawIcon(IconManager.xParams(paramId), x, y);
  231.             break;
  232.         default:
  233.             this.drawIcon(IconManager.bParams(paramId), x, y);
  234.             break;
  235.     }
  236.     if (this._actor) {
  237.         this.drawCurrentParam(x + 32, y, paramId, pType);
  238.     }
  239.     this.drawRightArrow(x + 72, y, pType);
  240.     if (this._tempActor) {
  241.         this.drawNewParam(x + 96, y, paramId, pType);
  242.     }
  243.     this.contents.fontSize = 28;
  244. };
  245.  
  246. Window_EquipStatus.prototype.drawCurrentParam = function (x, y, paramId, pType) {
  247.     this.resetTextColor();
  248.     switch (pType) {
  249.         case 0:
  250.             this.drawText(this._actor.param(paramId), x, y, 48, 'right');
  251.             break;
  252.         case 1:
  253.             this.drawText(this._actor.sparam(paramId)*100 -100, x, y, 48, 'right');
  254.             break;
  255.         case 2:
  256.             this.drawText(this._actor.xparam(paramId)*100, x, y, 48, 'right');
  257.             break;
  258.         default:
  259.             break;
  260.     }
  261. };
  262.  
  263. Window_EquipStatus.prototype.drawRightArrow = function (x, y, pType) {
  264.     this.changeTextColor(this.systemColor());
  265.     switch (pType) {
  266.         case 0:
  267.             this.drawText('\u25B8', x, y, 32, 'center');
  268.             break;
  269.         case 1:
  270.             this.drawText('%', x, y, 32, 'center');
  271.             break;
  272.         case 2:
  273.             this.drawText('%', x, y, 32, 'center');
  274.             break;
  275.         default:
  276.             break;
  277.     }
  278.  
  279. };
  280.  
  281. Window_EquipStatus.prototype.drawNewParam = function (x, y, paramId, pType) {
  282.     switch (pType) {
  283.         case 0:
  284.     var newValue = this._tempActor.param(paramId);
  285.     var diffvalue = newValue - this._actor.param(paramId);
  286.     this.changeTextColor(this.paramchangeTextColor(diffvalue));
  287.     this.drawText(newValue, x, y, 48, 'left');
  288.             break;
  289.         case 1:
  290.     var newValue = this._tempActor.sparam(paramId);
  291.     var diffvalue = newValue - this._actor.sparam(paramId);
  292.     this.changeTextColor(this.paramchangeTextColor(diffvalue));
  293.     this.drawText(newValue*100 -100, x, y, 48, 'left');
  294.             break;
  295.         case 2:
  296.     var newValue = this._tempActor.xparam(paramId);
  297.     var diffvalue = newValue - this._actor.xparam(paramId);
  298.     this.changeTextColor(this.paramchangeTextColor(diffvalue));
  299.     this.drawText(newValue*100, x, y, 48, 'left');
  300.             break;
  301.         default:
  302.             break;
  303.     }
  304. };
  305.  
  306. //-----------------------------------------------------------------------------
  307. // Window_EquipCommand
  308. //
  309. // The window for selecting a command on the equipment screen.
  310.  
  311. function Window_EquipCommand() {
  312.     this.initialize.apply(this, arguments);
  313. }
  314.  
  315. Window_EquipCommand.prototype = Object.create(Window_HorzCommand.prototype);
  316. Window_EquipCommand.prototype.constructor = Window_EquipCommand;
  317.  
  318. Window_EquipCommand.prototype.initialize = function (x, y, width) {
  319.     this._windowWidth = width;
  320.     Window_HorzCommand.prototype.initialize.call(this, x, y);
  321. };
  322.  
  323. Window_EquipCommand.prototype.windowWidth = function () {
  324.     return this._windowWidth;
  325. };
  326.  
  327. Window_EquipCommand.prototype.maxCols = function () {
  328.     return 3;
  329. };
  330.  
  331. Window_EquipCommand.prototype.makeCommandList = function () {
  332.     this.addCommand(TextManager.equip2, 'equip');
  333.     this.addCommand(TextManager.optimize, 'optimize');
  334.     this.addCommand(TextManager.clear, 'clear');
  335. };
  336.  
  337.  
  338. //-----------------------------------------------------------------------------
  339. // Window_EquipSlot
  340. //
  341. // The window for selecting an equipment slot on the equipment screen.
  342.  
  343. function Window_EquipSlot() {
  344.     this.initialize.apply(this, arguments);
  345. }
  346.  
  347. Window_EquipSlot.prototype = Object.create(Window_Selectable.prototype);
  348. Window_EquipSlot.prototype.constructor = Window_EquipSlot;
  349.  
  350. Window_EquipSlot.prototype.initialize = function (x, y, width, height) {
  351.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  352.     this._actor = null;
  353.     this.refresh();
  354. };
  355.  
  356. Window_EquipSlot.prototype.setActor = function (actor) {
  357.     if (this._actor !== actor) {
  358.         this._actor = actor;
  359.         this.refresh();
  360.     }
  361. };
  362.  
  363. Window_EquipSlot.prototype.update = function () {
  364.     Window_Selectable.prototype.update.call(this);
  365.     if (this._itemWindow) {
  366.         this._itemWindow.setSlotId(this.index());
  367.     }
  368. };
  369.  
  370. Window_EquipSlot.prototype.maxItems = function () {
  371.     return this._actor ? this._actor.equipSlots().length : 0;
  372. };
  373.  
  374. Window_EquipSlot.prototype.item = function () {
  375.     return this._actor ? this._actor.equips()[this.index()] : null;
  376. };
  377.  
  378. Window_EquipSlot.prototype.drawItem = function (index) {
  379.     if (this._actor) {
  380.         var rect = this.itemRectForText(index);
  381.         this.changeTextColor(this.systemColor());
  382.         this.changePaintOpacity(this.isEnabled(index));
  383.         this.drawText(this.slotName(index), rect.x, rect.y, 138, this.lineHeight());
  384.         this.drawItemName(this._actor.equips()[index], rect.x + 138, rect.y);
  385.         this.changePaintOpacity(true);
  386.     }
  387. };
  388.  
  389. Window_EquipSlot.prototype.slotName = function (index) {
  390.     var slots = this._actor.equipSlots();
  391.     return this._actor ? $dataSystem.equipTypes[slots[index]] : '';
  392. };
  393.  
  394. Window_EquipSlot.prototype.isEnabled = function (index) {
  395.     return this._actor ? this._actor.isEquipChangeOk(index) : false;
  396. };
  397.  
  398. Window_EquipSlot.prototype.isCurrentItemEnabled = function () {
  399.     return this.isEnabled(this.index());
  400. };
  401.  
  402. Window_EquipSlot.prototype.setStatusWindow = function (statusWindow) {
  403.     this._statusWindow = statusWindow;
  404.     this.callUpdateHelp();
  405. };
  406.  
  407. Window_EquipSlot.prototype.setItemWindow = function (itemWindow) {
  408.     this._itemWindow = itemWindow;
  409.     this.update();
  410. };
  411.  
  412. Window_EquipSlot.prototype.updateHelp = function () {
  413.     Window_Selectable.prototype.updateHelp.call(this);
  414.     this.setHelpWindowItem(this.item());
  415.     if (this._statusWindow) {
  416.         this._statusWindow.setTempActor(null);
  417.     }
  418. };
  419.  
  420. //-----------------------------------------------------------------------------
  421. // Window_EquipItem
  422. //
  423. // The window for selecting an equipment item on the equipment screen.
  424.  
  425. function Window_EquipItem() {
  426.     this.initialize.apply(this, arguments);
  427. }
  428.  
  429. Window_EquipItem.prototype = Object.create(Window_ItemList.prototype);
  430. Window_EquipItem.prototype.constructor = Window_EquipItem;
  431.  
  432. Window_EquipItem.prototype.initialize = function (x, y, width, height) {
  433.     Window_ItemList.prototype.initialize.call(this, x, y, width, height);
  434.     this._actor = null;
  435.     this._slotId = 0;
  436. };
  437.  
  438. Window_EquipItem.prototype.setActor = function (actor) {
  439.     if (this._actor !== actor) {
  440.         this._actor = actor;
  441.         this.refresh();
  442.         this.resetScroll();
  443.     }
  444. };
  445.  
  446. Window_EquipItem.prototype.setSlotId = function (slotId) {
  447.     if (this._slotId !== slotId) {
  448.         this._slotId = slotId;
  449.         this.refresh();
  450.         this.resetScroll();
  451.     }
  452. };
  453.  
  454. Window_EquipItem.prototype.includes = function (item) {
  455.     if (item === null) {
  456.         return true;
  457.     }
  458.     if (this._slotId < 0 || item.etypeId !== this._actor.equipSlots()[this._slotId]) {
  459.         return false;
  460.     }
  461.     return this._actor.canEquip(item);
  462. };
  463.  
  464. Window_EquipItem.prototype.isEnabled = function (item) {
  465.     return true;
  466. };
  467.  
  468. Window_EquipItem.prototype.selectLast = function () {
  469. };
  470.  
  471. Window_EquipItem.prototype.setStatusWindow = function (statusWindow) {
  472.     this._statusWindow = statusWindow;
  473.     this.callUpdateHelp();
  474. };
  475.  
  476. Window_EquipItem.prototype.updateHelp = function () {
  477.     Window_ItemList.prototype.updateHelp.call(this);
  478.     if (this._actor && this._statusWindow) {
  479.         var actor = JsonEx.makeDeepCopy(this._actor);
  480.         actor.forceChangeEquip(this._slotId, this.item());
  481.         this._statusWindow.setTempActor(actor);
  482.     }
  483. };
  484.  
  485. Window_EquipItem.prototype.playOkSound = function () {
  486. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement