Guest User

RPG Maker MV Portraits Plugin

a guest
Oct 30th, 2015
973
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.87 KB | None | 0 0
  1. //=============================================================================
  2. // Portraits.js
  3. //=============================================================================
  4.  
  5. var Imported = Imported || {};
  6. Imported.Portraits = true;
  7. var Portraits = Portraits || {};
  8.  
  9. /*:
  10. * @plugindesc Display Battlers Portraits
  11. * @author Michael Dionne
  12. *
  13. * @help ....
  14. * @param Bars Horizontal Padding
  15. * @desc Use this to set horizontal alignment for HP and MP bars (for 4 rows, recommended value is -60; for 6 rows, 30; for 8 rows, 75):
  16. * @default -60
  17. *
  18. * @param Global Window Vertical Margin
  19. * @desc Use this to set vertical alignment for the whole window:
  20. * @default 13
  21. *
  22. * @param Actors Quantity
  23. * @desc Use this to change the quantity of actors to show in the BattleStatus window:
  24. * @default 4
  25. *
  26. * @param ATB Compatibility
  27. * @desc Set this to 1 to be compatible with Ellye's Simple ATB plugin (if set to 0, ATB will still work but it won't display the ATB bar in the BattleStatus window):
  28. * @default 0
  29. *
  30. * @param TP and ATB Enabled
  31. * @desc Set this to 1 if you have ATB Compatibility to 1 AND also want to display TP, to give an extra line for all bars to have enough space to show up (however, the BattleCommand window won't be aligned vertically with the BattleStatus window):
  32. * @default 0
  33. *
  34. */
  35.  
  36. (function() {
  37.  
  38.  
  39. Window_BattleStatus.prototype.initialize = function()
  40. {
  41. Portraits.Parameters = PluginManager.parameters('Portraits');
  42. Portraits.Param = Portraits.Param || {};
  43. Portraits.Param.globalwindowverticalmargin = Number(Portraits.Parameters['Global Window Vertical Margin'] || 13);
  44. Portraits.Param.barshorizontalpadding = Number(Portraits.Parameters['Bars Horizontal Padding'] || -60);
  45. Portraits.Param.actorsquantity = Number(Portraits.Parameters['Actors Quantity'] || 4);
  46. Portraits.Param.atbcompatibility = Number(Portraits.Parameters['ATB Compatibility'] || 0);
  47. Portraits.Param.atbandtp = Number(Portraits.Parameters['TP and ATB Enabled'] || 0);
  48.  
  49. var width = this.windowWidth();
  50. var height = this.windowHeight();
  51. var lineHeight = this.lineHeight();
  52. var linesqt = 5;
  53.  
  54. if (Portraits.Param.atbandtp == 1)
  55. {
  56. var linesqt = 6;
  57.  
  58. }
  59.  
  60. height = lineHeight*linesqt;
  61. var x = Graphics.boxWidth - width;
  62. var y = Graphics.boxHeight - height;
  63. var selectable = Window_Selectable.prototype.initialize.call(this, x, y + Portraits.Param.globalwindowverticalmargin, width, height);
  64. this.refresh();
  65. this.openness = 0;
  66. };
  67.  
  68.  
  69. Window_BattleStatus.prototype.drawItem = function(index)
  70. {
  71. var actor = $gameParty.battleMembers()[index];
  72. this.drawBasicArea(this.basicAreaRect(index), actor);
  73. this.drawGaugeArea(this.gaugeAreaRect(index), actor);
  74. };
  75.  
  76.  
  77. Window_BattleStatus.prototype.basicAreaRect = function(index)
  78. {
  79. var rect = this.itemRectForText(index);
  80. rect.width -= this.gaugeAreaWidth() + 15;
  81. return rect;
  82. };
  83.  
  84.  
  85. Window_BattleStatus.prototype.numVisibleRows = function()
  86. {
  87. return 1;
  88. };
  89.  
  90.  
  91. Window_BattleStatus.prototype.maxCols = function()
  92. {
  93. return Portraits.Param.actorsquantity;
  94. };
  95.  
  96.  
  97. Window_BattleStatus.prototype.gaugeAreaRect = function(index)
  98. {
  99. var rect = this.itemRectForText(index);
  100. rect.x += rect.width - this.gaugeAreaWidth() + Portraits.Param.barshorizontalpadding;
  101. rect.width = this.gaugeAreaWidth();
  102. return rect;
  103. };
  104.  
  105.  
  106. Window_BattleStatus.prototype.gaugeAreaWidth = function()
  107. {
  108. return 330;
  109. };
  110.  
  111.  
  112. Window_BattleStatus.prototype.drawBasicArea = function(rect, actor)
  113. {
  114. var lineHeight = this.lineHeight();
  115. this.drawActorFace(actor, rect.x+0, rect.y + lineHeight * 0, 110, 142);
  116. this.drawActorName(actor, rect.x, rect.y + lineHeight * 0, 150);
  117. this.drawActorIcons(actor, rect.x + 156, rect.y + lineHeight * 0, rect.width - 156);
  118.  
  119. };
  120.  
  121.  
  122. Window_BattleStatus.prototype.drawGaugeArea = function(rect, actor)
  123. {
  124.  
  125. if ($dataSystem.optDisplayTp)
  126. {
  127. if (Portraits.Param.atbcompatibility == 0)
  128. {
  129. this.drawGaugeAreaWithTp(rect, actor);
  130. }
  131.  
  132. else if (Portraits.Param.atbcompatibility == 1)
  133. {
  134. this.drawGaugeAreaWithTpWithATB(rect, actor);
  135. }
  136. }
  137.  
  138. else
  139. {
  140.  
  141. if (Portraits.Param.atbcompatibility == 0)
  142. {
  143. this.drawGaugeAreaWithoutTp(rect, actor);
  144. }
  145.  
  146. else if (Portraits.Param.atbcompatibility == 1)
  147. {
  148. this.drawGaugeAreaWithoutTpWithATB(rect, actor);
  149. }
  150.  
  151.  
  152. }
  153.  
  154. };
  155.  
  156.  
  157. Window_BattleStatus.prototype.drawGaugeAreaWithTp = function(rect, actor)
  158. {
  159. var lineHeight = this.lineHeight();
  160. this.drawActorHp(actor, rect.x+156, rect.y + lineHeight * 1, 88);
  161. this.drawActorMp(actor, rect.x+156, rect.y + lineHeight * 2, 88);
  162. this.drawActorTp(actor, rect.x+156, rect.y + lineHeight * 3, 88);
  163. };
  164.  
  165.  
  166. Window_BattleStatus.prototype.drawGaugeAreaWithTpWithATB = function(rect, actor)
  167. {
  168. var lineHeight = this.lineHeight();
  169. this.drawActorHp(actor, rect.x+156, rect.y + lineHeight * 1, 88);
  170. this.drawActorMp(actor, rect.x+156, rect.y + lineHeight * 2, 88);
  171. this.drawActorTp(actor, rect.x+156, rect.y + lineHeight * 3, 88);
  172. this.drawActorATB(actor, rect.x+156, rect.y + lineHeight * 4, 88);
  173. };
  174.  
  175.  
  176. Window_BattleStatus.prototype.drawGaugeAreaWithoutTp = function(rect, actor)
  177. {
  178. var lineHeight = this.lineHeight();
  179. this.drawActorHp(actor, rect.x + 156, rect.y + lineHeight * 2, 88);
  180. this.drawActorMp(actor, rect.x + 156, rect.y + lineHeight * 3, 88);
  181. };
  182.  
  183.  
  184. Window_BattleStatus.prototype.drawGaugeAreaWithoutTpWithATB = function(rect, actor)
  185. {
  186. var lineHeight = this.lineHeight();
  187. this.drawActorHp(actor, rect.x + 156, rect.y + lineHeight * 1, 88);
  188. this.drawActorMp(actor, rect.x + 156, rect.y + lineHeight * 2, 88);
  189. this.drawActorATB(actor, rect.x + 156, rect.y + lineHeight * 3, 88);
  190. };
  191.  
  192.  
  193. Window_Selectable.prototype.itemHeight = function()
  194. {
  195. console.log(this.maxCols);
  196. return this.lineHeight();
  197. };
  198.  
  199.  
  200. })();
  201.  
  202.  
  203.  
  204.  
  205. (function() {
  206.  
  207. var _Window_Base_new = Window_Base.prototype.create;
  208.  
  209.  
  210. Window_Base.prototype.create = function()
  211. {
  212. _Window_Base_new.call(this);
  213. this.createDisplayObjects();
  214. };
  215.  
  216.  
  217. Window_Base.prototype.drawGauge = function(x, y, width, rate, color1, color2)
  218. {
  219. var fillW = Math.floor(width * rate);
  220. var gaugeY = y + this.lineHeight() - 19;
  221. var lineHeight = this.lineHeight();
  222. this.contents.fillRect(x, gaugeY, width, 16, this.gaugeBackColor());
  223. this.contents.gradientFillRect(x, gaugeY, fillW, 16, color1, color2);
  224. };
  225.  
  226.  
  227. Window_Base.prototype.drawActorHp = function(actor, x, y, width)
  228. {
  229. width = width || 186;
  230. var color1 = '#ff9933';
  231. var color2 = '#ffcc66';
  232. this.drawGauge(x, y, width, actor.hpRate(), color1, color2);
  233. this.drawText(TextManager.hpA, x, y, 44);
  234. this.drawCurrentAndMax(actor.hp, actor.mhp, x, y, width,
  235. this.hpColor(actor), this.normalColor());
  236. };
  237.  
  238.  
  239. Window_Base.prototype.drawActorMp = function(actor, x, y, width)
  240. {
  241. width = width || 186;
  242. var color1 = '#3399ff';
  243. var color2 = '#66ccff';
  244. this.drawGauge(x, y, width, actor.mpRate(), color1, color2);
  245. this.drawText(TextManager.mpA, x, y, 44);
  246. this.drawCurrentAndMax(actor.mp, actor.mmp, x, y, width,
  247. this.mpColor(actor), this.normalColor());
  248. };
  249.  
  250.  
  251. Window_Base.prototype.drawActorATB = function(actor, x, y, width)
  252. {
  253. width = width || 186;
  254. var color1 = '#3399ff';
  255. var color2 = '#66ccff';
  256. this.drawGauge(x, y, width, actor.atbRate(), color1, color2);
  257. this.drawText("AT", x, y, 44);
  258. };
  259.  
  260.  
  261. Window_Base.prototype.drawActorTp = function(actor, x, y, width)
  262. {
  263. width = width || 96;
  264. var color1 = this.tpGaugeColor1();
  265. var color2 = this.tpGaugeColor2();
  266. this.drawGauge(x, y, width, actor.tpRate(), color1, color2);
  267. this.drawText(TextManager.tpA, x, y, 44);
  268. this.changeTextColor(this.tpColor(actor));
  269. this.drawText(actor.tp, x + width - 64, y, 64, 'right');
  270. };
  271.  
  272.  
  273.  
  274. })();
Advertisement
Add Comment
Please, Sign In to add comment