Advertisement
Jragyn

[MV] J_statusscreen

Aug 31st, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // J-Status Screen Revamp v1.0
  3. //=============================================================================
  4. // Changelog:
  5. //  v1.0: Developed and soft-released.
  6. /*:
  7. @plugindesc Alters the status screen to display all details and parameters. Click "Help..." for more details.
  8. @author J
  9. @help
  10. REQUIRES: J_base
  11. No commands are used outside of initial setup.
  12.  
  13. Make certain all elements are defined for all actors
  14. or else the status screen may display inaccurate strength/weaknesses!
  15. Additionally, elements were displayed based on a standard of 10x elements.
  16. Using less or more than 10x may also cause issues.
  17.  
  18. NOTE: Resolution of 1280x720 is what this was designed at.
  19. It will not display properly at lower resolutions, and is untested at higher.
  20. Coincidently, yanfly.moe has a core-engine that provides resolution modification.
  21.  
  22. Also, the base IconSet.png does not have all of the icons used for this.
  23. Feel free to modify them as you please, or download yanfly's VXace modification
  24. of the IconSet.
  25.  */
  26.  
  27. var Imported = Imported || {};
  28. Imported.J_revamp_statusscreen = true;
  29.  
  30. var J = J || {};
  31.  
  32. J.Parameters = PluginManager.parameters('J_revamp_statusscreen');
  33. J.Param = J.Param || {};
  34. J.Icon = J.Icon || {};
  35.  
  36. /*=========================================================================== |
  37. |  Window_Status()                                                            |
  38. |    This is an overwrite of the original Status Screen.                      |
  39. |    Likely incompatible with other scripts that deal with this screen.       |
  40. | ===========================================================================*/
  41.  
  42. var lh = 36;
  43. Window_Status.prototype.refresh = function () {
  44.     this.contents.clear();
  45.     if (this._actor) {
  46.         this.draw_block_header(0);
  47.         this.drawHorzLine(lh * 5);
  48.         this.draw_block_explife(lh * 0);
  49.         this.drawEquipments(660, 0);
  50.     }
  51. };
  52.  
  53. // draws the top section for face/name/class/nickname details.
  54. Window_Status.prototype.draw_block_header = function (y) {
  55.     this.drawActorFace(this._actor, 12, y);
  56.     this.drawActorName(this._actor, 6, y);
  57.     this.drawActorLevel(this._actor, 0, lh * 4);
  58.     this.drawActorClass(this._actor, 80, lh * 4);//y);
  59. };
  60.  
  61. // draws the status-icons/hp-mp/experience details.
  62. Window_Status.prototype.draw_block_explife = function (y) {
  63.     this.drawActorHp(this._actor, 160, y + lh * 1, 180);
  64.     this.drawActorMp(this._actor, 160, y + lh * 2, 180);
  65.     this.drawActorIcons(this._actor, 240, y + lh * 3);
  66.     this.drawExpInfo(370, y);
  67. };
  68.  
  69. // Draws a horizontal line at Y coordinate.
  70. Window_Status.prototype.drawHorzLine = function (y) {
  71.     var lineY = y + this.lineHeight() / 2 - 1;
  72.     this.contents.paintOpacity = 48;
  73.     this.contents.fillRect(0, lineY, this.contentsWidth(), 2, this.lineColor());
  74.     this.contents.paintOpacity = 255;
  75. };
  76. Window_Status.prototype.lineColor = function () {
  77.     return this.normalColor();
  78. };
  79.  
  80. // Draws the details regarding EXP and EXP2next.
  81. Window_Status.prototype.drawExpInfo = function (x, y) {
  82.     var lineHeight = this.lineHeight();
  83.     var expTotal = TextManager.expTotal.format(TextManager.exp);
  84.     var expNext = TextManager.expNext.format(TextManager.level);
  85.     var value1 = this._actor.currentExp();
  86.     var value2 = this._actor.nextRequiredExp();
  87.     if (this._actor.isMaxLevel()) {
  88.         value1 = '-------';
  89.         value2 = '-------';
  90.     }
  91.     this.changeTextColor(this.systemColor());
  92.     this.drawText(expTotal, x, y + lineHeight * 0, 270);
  93.     this.drawText(expNext, x, y + lineHeight * 2, 270);
  94.     this.resetTextColor();
  95.     this.drawText(value1, x, y + lineHeight * 1, 270, 'right');
  96.     this.drawText(value2, x, y + lineHeight * 3, 270, 'right');
  97. };
  98.  
  99. // Draws the actual equipment currently equipped.
  100. // Though it will draw all equipments, having more than the default
  101. //   will likely create overlap.
  102. Window_Status.prototype.drawEquipments = function (x, y) {
  103.     var equips = this._actor.equips();
  104.     var count = Math.min(equips.length, this.maxEquipmentLines());
  105.     for (var i = 0; i < count; i++) {
  106.         this.drawItemName(equips[i], x, y + (lh-6) * i);
  107.     }
  108. };
  109.  
  110. // Draws the default "profile", including face portrait and level#.
  111. Window_Status.prototype.drawProfile = function (x, y) {
  112.     this.drawTextEx(this._actor.profile(), x, y);
  113. };
  114.  
  115. Window_Status.prototype.maxEquipmentLines = function () {
  116.     return 6;
  117. };
  118.  
  119. /*=========================================================================== |
  120. |  Window_Param_Choice()                                                      |
  121. |    This is the window that displays an actor's parameters and handles       |
  122. |    the cursor for selecting a parameter.                                    |
  123. | ===========================================================================*/
  124.  
  125. function Window_Param_Choice() {
  126.     this.initialize.apply(this, arguments);
  127. }
  128.  
  129. Window_Param_Choice.prototype = Object.create(Window_Selectable.prototype);
  130. Window_Param_Choice.prototype.constructor = Window_Param_Choice;
  131.  
  132. Window_Param_Choice.prototype.initialize = function (x, y, w, h) {
  133.     var width = w;
  134.     var height = h;
  135.     Window_Selectable.prototype.initialize.call(this, x, y, width, height)
  136.     this._pendingIndex = -1;
  137.     this.refresh();
  138. };
  139.  
  140. Window_Param_Choice.prototype.setActor = function (actor) {
  141.     if (this._actor !== actor) {
  142.         this._actor = actor;
  143.         this.refresh();
  144.     }
  145. };
  146.  
  147. // Changes the column count to 3 for the B/S/X parameters.
  148. Window_Param_Choice.prototype.maxCols = function () {
  149.     return 3;
  150. };
  151.  
  152. // Fixes the total item count to 30 for a 10x3 grid.
  153. Window_Param_Choice.prototype.maxItems = function () {
  154.     return 30;
  155. };
  156.  
  157. // Alters the item height to be 40 instead of 48.
  158. Window_Param_Choice.prototype.itemHeight = function () {
  159.     return 40;
  160. };
  161.  
  162. // Fixes the width of each column to be 350, from a formula.
  163. Window_Param_Choice.prototype.itemWidth = function () {
  164.     return 350;
  165. };
  166.  
  167. // Handles the refreshing of all status items drawn in the screen.
  168. Window_Param_Choice.prototype.refresh = function () {
  169.     if (this.contents) {
  170.         this.contents.clear();
  171.         this.drawAllItems();
  172.     }
  173. };
  174.  
  175. // Does the actual drawing of each item throughout the selectable window.
  176. Window_Param_Choice.prototype.drawAllItems = function () {
  177.     var topIndex = this.topIndex();
  178.     var actor = $gameParty.menuActor();
  179.     for (var i = 0; i < this.maxPageItems() ; i++) {
  180.         var index = topIndex + i;
  181.         if (index < this.maxItems()) {
  182.             this.drawItem(index);
  183.         }
  184.     }
  185.     this.drawAllElements(actor);
  186. };
  187.  
  188. // The recipe for how to draw each item.
  189. // This includes drawing icons, the names, and the actual parameter itself.
  190. // It looks this complicated because I couldn't math how to get the right
  191. //   params to draw in the right columns.
  192. Window_Param_Choice.prototype.drawItem = function (index) {
  193.     var rect = this.itemRectForText(index);
  194.     var align = 'left';
  195.     var grid = this.convertIndex(index);
  196.     var actor = $gameParty.menuActor();
  197.     this.resetTextColor();
  198.     if (index == 0 || index == 3 || index == 6 || index == 9 || index == 12 || index == 15 || index == 18 || index == 21) {
  199.         this.drawIcon(IconManager.bParams(grid), rect.x, rect.y)
  200.         this.drawText(TextManager.param(grid), rect.x + 36, rect.y, rect.width, align);
  201.         this.drawText(Math.round(actor.param(grid)), rect.x, rect.y, rect.width, 'right');
  202.     };
  203.     if (index == 1 || index == 4 || index == 7 || index == 10 || index == 13 || index == 16 || index == 19 || index == 22 || index == 25 || index == 28) {
  204.         this.drawIcon(IconManager.sParams(grid), rect.x, rect.y)
  205.         this.drawText(TextManager.sparam(grid), rect.x + 36, rect.y, rect.width, align);
  206.         this.drawText(Math.round((actor.sparam(grid)*100)-100), rect.x, rect.y, rect.width, 'right');
  207.     }
  208.     if (index == 2 || index == 5 || index == 8 || index == 11 || index == 14 || index == 17 || index == 20 || index == 23 || index == 26 || index == 29) {
  209.         this.drawIcon(IconManager.xParams(grid), rect.x, rect.y)
  210.         this.drawText(TextManager.xparam(grid), rect.x + 36, rect.y, rect.width, align);
  211.         this.drawText(Math.round(actor.xparam(grid)*100), rect.x, rect.y, rect.width, 'right');
  212.     }
  213. };
  214.  
  215. // Handles the drawing of elemental strengths and resistances.
  216. // Draws both icons and numeric values based on traits; if no value is present, 100 is written default.
  217. // Numerics are colored accordingly to strength/weakness.
  218. Window_Param_Choice.prototype.drawAllElements = function (actor) {
  219.     var a = actor;
  220.     var elems = actor.traitsSet(11);
  221.     var x = Graphics.width - 160;
  222.     for (var i = 0; i < $dataSystem.elements.length-1; i++) {
  223.         var y = (lh+4) * i;
  224.         var icon = IconManager.elemIcons(i + 1);
  225.         this.drawIcon(icon, x, y);
  226.         var e = a.elementRate(elems[i]);
  227.         this.changeTextColor(this.textColor(this.elemColor(e)));
  228.         this.drawText(e * 100, x + 32, y, 100);
  229.         this.resetTextColor();
  230.  
  231.         this.drawText("%", x + 108, y, 100);
  232.     }
  233. }
  234.  
  235. Window_Param_Choice.prototype.elemColor = function (rate) {
  236.     var col = 0;
  237.     rate *= 100;
  238.     if (rate <= 0) { // 0% dmg
  239.         col = 7;
  240.     }
  241.     else if (rate > 0 && rate <= 50) { // 1-50 % dmg
  242.         col = 4;
  243.     }
  244.     else if (rate > 50 && rate <= 99) { // 51-99 % dmg
  245.         col = 1;
  246.     }
  247.     else if (rate == 100) { // 100 % dmg (not modified)
  248.         col = 0;
  249.     }
  250.     else if (rate > 100 && rate <= 150) { // 101-150 % dmg
  251.         col = 14;
  252.     }
  253.     else if (rate > 150 && rate <= 200) { // 151-200 % dmg
  254.         col = 2;
  255.     }
  256.     else if (rate > 200) { // 201+ % dmg
  257.         col = 18;
  258.     }
  259.     return col;
  260. }
  261.  
  262.  
  263. // Converts the index of a grid to align with the idea of three vertical columns.
  264. Window_Param_Choice.prototype.convertIndex = function (index) {
  265.     var i = index;
  266.     switch (i) {
  267.         case 0:  return 0;  case 1:  return 0;  case 2:  return 0;
  268.         case 3:  return 1;  case 4:  return 1;  case 5:  return 1;
  269.         case 6:  return 2;  case 7:  return 2;  case 8:  return 2;
  270.         case 9:  return 3;  case 10: return 3;  case 11: return 3;
  271.         case 12: return 4;  case 13: return 4;  case 14: return 4;
  272.         case 15: return 5;  case 16: return 5;  case 17: return 5;
  273.         case 18: return 6;  case 19: return 6;  case 20: return 6;
  274.         case 21: return 7;  case 22: return 7;  case 23: return 7;
  275.         case 24: return 0;  case 25: return 8;  case 26: return 8;
  276.         case 27: return 0;  case 28: return 9;  case 29: return 9;
  277.     }
  278.     // note: case 24/27 are supposed to be unreachable.
  279. }
  280.  
  281. // Draws the box for each item of the Param_Choice window.
  282. Window_Param_Choice.prototype.itemRectForText = function (index) {
  283.     var rect = this.itemRect(index);
  284.     rect.x += this.textPadding();
  285.     rect.width -= this.textPadding() * 2;
  286.     return rect;
  287. };
  288.  
  289. // Draws the box... period.
  290. Window_Param_Choice.prototype.itemRect = function (index) {
  291.     var rect = new Rectangle();
  292.     var maxCols = this.maxCols();
  293.     rect.width = this.itemWidth();
  294.     rect.height = this.itemHeight();
  295.     rect.x = index % maxCols * (rect.width + this.spacing()) - this._scrollX;
  296.     rect.y = Math.floor(index / maxCols) * rect.height - this._scrollY;
  297.     return rect;
  298. };
  299.  
  300. // Hooks into the method of processCursorMove
  301. // to draw in the description of each stat based on real (not converted) index.
  302. Window_Param_Choice.prototype.processCursorMove = function () {
  303.     Window_Selectable.prototype.processCursorMove.call(this);
  304.     this.refresh();
  305.     var txt = TextManager.param.desc(this.index());
  306.     this.drawText(txt, 0, 430, txt.width);
  307. };
  308.  
  309. /*=========================================================================== |
  310. |  Scene_Status()                                                             |
  311. |    This is the modified Scene_Status that handles the new windows.          |
  312. | ===========================================================================*/
  313.  
  314. function Scene_Status() {
  315.     this.initialize.apply(this, arguments);
  316. }
  317.  
  318. Scene_Status.prototype = Object.create(Scene_MenuBase.prototype);
  319. Scene_Status.prototype.constructor = Scene_Status;
  320.  
  321. Scene_Status.prototype.initialize = function () {
  322.     Scene_MenuBase.prototype.initialize.call(this);
  323. };
  324.  
  325. // New initialization of the Scene_Status to draw all windows.
  326. Scene_Status.prototype.create = function () {
  327.     Scene_MenuBase.prototype.create.call(this);
  328.     this.createStatusWindow();
  329.     this.createParamWindow();
  330.     this.refreshActor();
  331. };
  332.  
  333. // Updated to also update the Window_Param_Choice.
  334. Scene_Status.prototype.refreshActor = function () {
  335.     var actor = this.actor();
  336.     this._statusWindow.setActor(actor);
  337.     this._paramWindow.setActor(actor);
  338. };
  339.  
  340. // Makes sure the Window_Param_Choice is activated when changing actor.
  341. Scene_Status.prototype.onActorChange = function () {
  342.     this.refreshActor();
  343.     this._paramWindow.activate();
  344. };
  345.  
  346. // Original creation of status window
  347. Scene_Status.prototype.createStatusWindow = function () {
  348.     this._statusWindow = new Window_Status();
  349.     this._statusWindow.setHandler('cancel', this.popScene.bind(this));
  350.     this._statusWindow.setHandler('pagedown', this.nextActor.bind(this));
  351.     this._statusWindow.setHandler('pageup', this.previousActor.bind(this));
  352.     this.addWindow(this._statusWindow);
  353. }
  354.  
  355. // Creates the window and the handler for the new Window_Param_Choice
  356. Scene_Status.prototype.createParamWindow = function () {
  357.     this._paramWindow = new Window_Param_Choice(0, 200, Graphics.width, 520);
  358.     this._paramWindow.setHandler('cancel', this.popScene.bind(this));
  359.     this._paramWindow.setHandler('pagedown', this.nextActor.bind(this));
  360.     this._paramWindow.setHandler('pageup', this.previousActor.bind(this));
  361.     this.addWindow(this._paramWindow);
  362.     this._paramWindow.refresh();
  363.     this._paramWindow.active = true;
  364.     this._paramWindow.select(0);
  365. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement