Advertisement
cekobico

Galv's Bust Menu - Edit

Jun 4th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //-----------------------------------------------------------------------------
  2. //  Galv's Bust Menu
  3. //-----------------------------------------------------------------------------
  4. //  For: RPGMAKER MV
  5. //  GALV_BustMenu.js
  6. //-----------------------------------------------------------------------------
  7. //  2016-03-28 - Version 1.7 - added ability to disable certain info with -1
  8. //  2016-02-12 - Version 1.6 - Added nickname, made changable actor display no.
  9. //  2016-01-12 - Version 1.5 - Fixed MAX level and EXP bar issue.
  10. //                           - compatibility: Rocketmancers prettier gauges
  11. //  2015-11-21 - Version 1.4 - fixed tiny JP alignment issue
  12. //  2015-11-21 - Version 1.3 - added compatiblity for Yanfly's JobPoints
  13. //  2015-11-19 - Version 1.2 - fixed issue with drawing single character bust
  14. //  2015-11-08 - Version 1.1 - added EXP bar and settings
  15. //  2015-11-07 - Version 1.0 - release
  16. //-----------------------------------------------------------------------------
  17. // Terms can be found at:
  18. // galvs-scripts.com
  19. //-----------------------------------------------------------------------------
  20.  
  21. var Imported = Imported || {};
  22. Imported.Galv_BustMenu = true;
  23.  
  24. var Galv = Galv || {};        // Galv's main object
  25. Galv.BM = Galv.BM || {};      // Galv's stuff
  26.  
  27. //-----------------------------------------------------------------------------
  28. /*:
  29.  * @plugindesc Changes the default actor layout in the main menu to use
  30.  * vertical "bust" or portrait graphics from /img/pictures/
  31.  * @author Galv - galvs-scripts.com
  32.  *
  33.  * @param Menu Actors
  34.  * @desc Number of actors that appear in the menu before scrolling (can be changed in-game)
  35.  * @default 3
  36.  *
  37.  * @param Menu Actor Rows
  38.  * @desc Number of rows of actors (cannot be changed in-game). You will need to change settings below to fit
  39.  * @default 1
  40.  *
  41.  * @param Name
  42.  * @desc Line number of actor's name
  43.  * -1 to not display
  44.  * @default 1
  45.  *
  46.  * @param Nickname
  47.  * @desc Line number of actor's name
  48.  * -1 to not display
  49.  * @default 0
  50.  *
  51.  * @param Class
  52.  * @desc Line number of actor's class
  53.  * -1 to not display
  54.  * @default 2
  55.  *
  56.  * @param Level
  57.  * @desc Line number of actor's level
  58.  * -1 to not display
  59.  * @default 3
  60.  *
  61.  * @param States
  62.  * @desc Line number of actor's state icons
  63.  * -1 to not display
  64.  * @default 13
  65.  *
  66.  * @param Bars
  67.  * @desc Line number of actor's hp/mp bars
  68.  * -1 to not display
  69.  * @default 14
  70.  *
  71.  * @param Show Exp Bar
  72.  * @desc Can be true or false to display exp bar or not
  73.  * @default true
  74.  *
  75.  * @param Exp Bar
  76.  * @desc Line number of actor's EXP bar
  77.  * -1 to not display
  78.  * @default 4
  79.  *
  80.  * @param JP
  81.  * @desc Line number of actor's JP (If Yanfly's JobPoints is installed)
  82.  * -1 to not display
  83.  * @default 2
  84.  *
  85.  * @param Exp Bar Height
  86.  * @desc Height of the EXP bar in pixels
  87.  * @default 10
  88.  *
  89.  * @param Show Exp Text
  90.  * @desc Can be true or false to display exp text on the bar or not
  91.  * @default true
  92.  *
  93.  * @param Exp Text
  94.  * @desc Text displayed before the exp-till-next-level number
  95.  * @default Next
  96.  *
  97.  * @param Max Exp Text
  98.  * @desc When actor reaches maximum level, this text is displayed on exp bar
  99.  * @default Max
  100.  *
  101.  * @param Exp Bar Color 1
  102.  * @desc Uses text color numbers from windowskin file. Will gradient into color 2
  103.  * @default 0
  104.  *
  105.  * @param Exp Bar Color 2
  106.  * @desc Uses text color numbers from windowskin file. Will gradient into color 1
  107.  * @default 8
  108.  *
  109.  * @param Bust Y
  110.  * @desc Y position of the bust image in pixels
  111.  * @default 100
  112.  *
  113.  * @param Bust Height
  114.  * @desc Height of the bust image in pixels
  115.  * @default 360
  116.  *
  117.  * @param -----------
  118.  * @desc
  119.  *
  120.  * @default
  121.  *
  122.  * @param Bust Offsets
  123.  * @desc See the help section for how to use this.
  124.  * @default
  125.  *
  126.  * @help
  127.  *   Galv's Bust Menu
  128.  * ----------------------------------------------------------------------------
  129.  * This plugin changes the layout of actors in the main menu. The plugin
  130.  * includes settings that allow you to change the positioning of the actor
  131.  * data (such as name, level, hp, image, etc.) including how many actors will
  132.  * appear on the menu screen. (NOTE: 1 actor is not working)
  133.  *
  134.  * The plugin displays bust images from /img/pictures/ folder based on the
  135.  * actor's face.  For example:
  136.  * If an actor uses the 2nd face from the "Actor1" faces file, then the bust
  137.  * will instead use /img/pictures/Actor1_2.png bust image.
  138.  *
  139.  * ----------------------------------------------------------------------------
  140.  *   Bust Offsets (Scroll down the plugin settings to find this)
  141.  * ----------------------------------------------------------------------------
  142.  * Bust images are centered in the actor positions, but sometimes the bust
  143.  * images are not centered themselves. This setting is used to tweak the x,y
  144.  * position of busts if required.
  145.  * To add an x,y offset to busts, add data to this setting as below:
  146.  *
  147.  *     bustImageName_1,x,y|bustImageName_2,x,y|bustImageName_3,x,y
  148.  *
  149.  * Each image and data are separated by a pipe (the "|" symbol). For example:
  150.  * Actor1_2,-10,0|Actor1_5,20,5
  151.  * The Actor1_2.png bust will be offset 10 pixels to the left
  152.  * The Actor1_5.png bust will be offset 20 pixels to the right, 5 pixels down
  153.  * ----------------------------------------------------------------------------
  154.  *   SCRIPT CALL
  155.  * ----------------------------------------------------------------------------
  156.  * $gameParty._bustActorCount = x;        // x is number of actors to display
  157.  * ----------------------------------------------------------------------------
  158.  */
  159.  
  160.  
  161. //-----------------------------------------------------------------------------
  162. //  CODE STUFFS
  163. //-----------------------------------------------------------------------------
  164.  
  165. (function() {
  166.  
  167. Galv.BM.a = Number(PluginManager.parameters('Galv_BustMenu')["Menu Actors"]);
  168. Galv.BM.ar = Number(PluginManager.parameters('Galv_BustMenu')["Menu Actor Rows"]);
  169. Galv.BM.name = Number(PluginManager.parameters('Galv_BustMenu')["Name"] - 1);
  170. Galv.BM.nickname = Number(PluginManager.parameters('Galv_BustMenu')["Nickname"] - 1);
  171. Galv.BM.class = Number(PluginManager.parameters('Galv_BustMenu')["Class"] - 1);
  172. Galv.BM.level = Number(PluginManager.parameters('Galv_BustMenu')["Level"] - 1);
  173. Galv.BM.bars = Number(PluginManager.parameters('Galv_BustMenu')["Bars"] - 1);
  174. Galv.BM.JP = Number(PluginManager.parameters('Galv_BustMenu')["JP"] - 1);
  175. Galv.BM.xp = Number(PluginManager.parameters('Galv_BustMenu')["Exp Bar"] - 1);
  176. Galv.BM.xpBar = PluginManager.parameters('Galv_BustMenu')["Show Exp Bar"] == "true" ? true : false;
  177. Galv.BM.xpText = PluginManager.parameters('Galv_BustMenu')["Show Exp Text"] == "true" ? true : false;
  178. Galv.BM.xpLabel = PluginManager.parameters('Galv_BustMenu')["Exp Text"];
  179. Galv.BM.xpHeight = PluginManager.parameters('Galv_BustMenu')["Exp Bar Height"];
  180. Galv.BM.maxTxt = PluginManager.parameters('Galv_BustMenu')["Max Exp Text"];
  181.  
  182. Galv.BM.xpCol1 = Number(PluginManager.parameters('Galv_BustMenu')["Exp Bar Color 1"]);
  183. Galv.BM.xpCol2 = Number(PluginManager.parameters('Galv_BustMenu')["Exp Bar Color 2"]);
  184. Galv.BM.icons = Number(PluginManager.parameters('Galv_BustMenu')["States"] - 1);
  185. Galv.BM.bust = Number(PluginManager.parameters('Galv_BustMenu')["Bust Y"]);
  186. Galv.BM.bustHeight = Number(PluginManager.parameters('Galv_BustMenu')["Bust Height"]);
  187. Galv.BM.offsets = function() {
  188.     var array = PluginManager.parameters('Galv_BustMenu')["Bust Offsets"].split("|");
  189.     var obj = {};
  190.     for (i = 0; i < array.length; i++) {
  191.         if (array[i]) {
  192.             var data = array[i].split(",");
  193.             obj[data[0]] = [Number(data[1]),Number(data[2])];
  194.         };
  195.     };
  196.     return obj;
  197. }();
  198.  
  199. //------------------------------------------------------------
  200. // COMPATIBILITY WITH ROCKETMANCER'S PRETTIER GAUGES
  201.  
  202.  
  203. if (PluginManager.parameters('PrettyGauges') && Object.keys(PluginManager.parameters('PrettyGauges')).length > 0) {
  204.     Galv.BM.rmplugin = true;
  205. };
  206. //------------------------------------------------------------
  207.  
  208.  
  209. var Galv_Game_Party_initialize = Game_Party.prototype.initialize;
  210. Game_Party.prototype.initialize = function() {
  211.     Galv_Game_Party_initialize.call(this);
  212.     this._bustActorCount = Galv.BM.a;
  213. };
  214.  
  215.  
  216. // OVERWRITE
  217. Window_MenuStatus.prototype.numVisibleRows = function() {return Galv.BM.ar};
  218. Window_MenuStatus.prototype.maxCols = function() {return $gameParty._bustActorCount};
  219. Window_Selectable.prototype.spacing = function() {return 0};
  220.  
  221. Window_MenuStatus.prototype.drawItemStatus = function(index) {
  222.     var actor = $gameParty.members()[index];
  223.     var rect = this.itemRect(index);
  224.     var x = rect.x;
  225.     var y = rect.y;
  226.     var width = rect.width - x - this.textPadding();
  227.     this.drawActorSimpleStatus(actor, x, y, width);
  228. };
  229.  
  230.  
  231. // OVERWRITE
  232. Window_MenuStatus.prototype.drawActorSimpleStatus = function(actor, x, y, width) {
  233.     var lineHeight = this.lineHeight();
  234.     var width = this.bustWidth();
  235.     var x = x + 5;
  236.     var width2 = Math.max(100, width - this.textPadding()) - 5;
  237.     if (Galv.BM.xp > -1) this.drawActorEXP(actor,x,y + lineHeight * Galv.BM.xp,width2)
  238.     if (Galv.BM.name > -1) this.drawActorName(actor, x, y + lineHeight * Galv.BM.name);
  239.     if (Galv.BM.nickname > -1) this.drawActorNickname(actor, x, y + lineHeight * Galv.BM.nickname);
  240.     if (Galv.BM.level > -1) this.drawActorLevel(actor, x, y + lineHeight * Galv.BM.level);
  241.     if (Galv.BM.icons > -1) this.drawActorIcons(actor, x, y + lineHeight * Galv.BM.icons);
  242.     if (Galv.BM.class > -1) this.drawActorClass(actor, x, y + lineHeight * Galv.BM.class, width2);
  243.     if (Galv.BM.bars > -1) {
  244.         this.drawActorHp(actor, x, y + lineHeight * Galv.BM.bars, width2);
  245.         this.drawActorMp(actor, x, y + lineHeight * (Galv.BM.bars + 1), width2);
  246.         if (Imported.YEP_CoreEngine && eval(Yanfly.Param.MenuTpGauge)) {
  247.             this.drawActorTp(actor, x, y + lineHeight * (Galv.BM.bars + 2), width2);
  248.         }
  249.     };
  250.     if (Imported.YEP_JobPoints && eval(Yanfly.Param.JpShowMenu)) {
  251.         var classId = actor.currentClass().id;
  252.         if (Galv.BM.JP > -1) this.drawActorJp(actor, classId, x, y + lineHeight * Galv.BM.JP, width2, 'right');
  253.     };
  254.  
  255. };
  256.  
  257.  
  258. Game_Actor.prototype.xpRate = function() {
  259.     return (this.nextLevelExp() - this.currentExp()) / (this.nextLevelExp() - this.currentLevelExp());
  260. };
  261.  
  262. Window_MenuStatus.prototype.drawActorEXP = function(actor, x, y, width) {
  263.     if (Galv.BM.xpBar) {
  264.         var color1 = this.xpGaugeColor1();
  265.         var color2 = this.xpGaugeColor2();
  266.         if (actor.isMaxLevel()) {
  267.             var xprate = 0;
  268.         } else {
  269.             var xprate = actor.xpRate();
  270.         };
  271.         this.drawExpGauge(x, y, width, xprate, color1, color2);
  272.     };
  273.     if (Galv.BM.xpText) {
  274.         this.changeTextColor(this.systemColor());
  275.         this.drawText(xprate > 0 ? Galv.BM.xpLabel : Galv.BM.maxTxt, x, y, this.textWidth());
  276.         this.changeTextColor(this.normalColor());
  277.         if (xprate > 0) this.drawText(actor.nextRequiredExp(), x, y, width,"right");
  278.     };
  279. };
  280.  
  281.  
  282.  
  283. if (Galv.BM.rmplugin) {
  284.     // IF ROCKETMANCER'S PRETTIER GAUGES PLUGIN
  285.  
  286.     var parameters = PluginManager.parameters('PrettyGauges');
  287.     var barTypeLeft = String(parameters['barType']).substring(0,1);
  288.     var barTypeRight = String(parameters['barType']).substring(1,2)
  289.     var outline = Number(parameters['outline'] || 0);
  290.     var barHeight = Number(parameters['barHeight'] || 0);
  291.     var outlineColor1 = String(parameters['outlineColor1']);
  292.     var outlineColor2 = String(parameters['outlineColor2']);
  293.     var backgroundColor1 = String(parameters['backgroundColor1']);
  294.     var backgroundColor2 = String(parameters['backgroundColor2']);
  295.     var hpColor1 = String(parameters['hpColor1']);
  296.     var hpColor2 = String(parameters['hpColor2']);
  297.     var mpColor1 = String(parameters['mpColor1']);
  298.     var mpColor2 = String(parameters['mpColor2']);
  299.     var tpColor1 = String(parameters['tpColor1']);
  300.     var tpColor2 = String(parameters['tpColor2']);
  301.  
  302.  
  303.     Window_Base.prototype.drawExpGauge = function(x, y, width, rate, color1, color2) {
  304.         var color3 = this.gaugeBackColor();
  305.         var fillW = Math.floor(width * rate).clamp(0, width);
  306.         var gaugeH = Galv.BM.xpHeight;
  307.         var gaugeY = y + this.lineHeight() - gaugeH - 2;
  308.         var fillW = Math.floor(width * rate);
  309.         var gaugeY = y + this.lineHeight() - gaugeH - 2;
  310.  
  311.         var fillW = Math.floor(width * rate);
  312.         var gaugeY = y + this.lineHeight() - 2 - barHeight;
  313.         this.contents.fillTrap(x, gaugeY, width, width, barHeight, this.gaugeBackColor1(),  this.gaugeBackColor2());
  314.         this.contents.fillTrap(x, gaugeY, width, fillW, barHeight, color1, color2);
  315.         if (outline) { this.contents.outlineTrap(x, gaugeY, width, barHeight, outlineColor1, outlineColor2)}
  316.  
  317.  
  318.     };
  319.  
  320.  
  321.  
  322. } else {
  323.     // IF GALV ONLY
  324.     Window_Base.prototype.drawExpGauge = function(dx, dy, dw, rate, color1, color2) {
  325.         var color3 = this.gaugeBackColor();
  326.         var fillW = Math.floor(dw * rate).clamp(0, dw);
  327.         var gaugeH = Galv.BM.xpHeight;
  328.         var gaugeY = dy + this.lineHeight() - gaugeH - 2;
  329.         var fillW = Math.floor(dw * rate);
  330.         var gaugeY = dy + this.lineHeight() - gaugeH - 2;
  331.         this.contents.fillRect(dx, gaugeY, dw, gaugeH, color3);
  332.         this.contents.gradientFillRect(dx, gaugeY, dw - fillW, gaugeH, color1, color2);
  333.     };
  334. };
  335.  
  336.  
  337.  
  338. Window_Base.prototype.xpGaugeColor1 = function() {
  339.     return this.textColor(Galv.BM.xpCol1);
  340. };
  341.  
  342. Window_Base.prototype.xpGaugeColor2 = function() {
  343.     return this.textColor(Galv.BM.xpCol2);
  344. };
  345.  
  346.  
  347. // Because blt didn't let you draw a bitmap if it was a tiny bit off
  348. Bitmap.prototype.unlimitedBlt = function(source, sx, sy, sw, sh, dx, dy, dw, dh) {
  349.     dw = dw || sw;
  350.     dh = dh || sh;
  351.         this._context.globalCompositeOperation = 'source-over';
  352.         this._context.drawImage(source._canvas, sx, sy, sw, sh, dx, dy, dw, dh);
  353.         this._setDirty();
  354. };
  355.  
  356. Window_MenuStatus.prototype.drawFace = function(faceName, faceIndex, x, y, width, height) {
  357.     var width = this.bustWidth();
  358.  
  359.     var bustName = faceName + "_" + (faceIndex + 1)
  360.     var bitmap = ImageManager.loadPicture(bustName);
  361.  
  362.     var ox = 0;
  363.     var oy = 0;
  364.     if (Galv.BM.offsets[bustName]) {
  365.         ox = Galv.BM.offsets[bustName][0] || 0;
  366.         oy = Galv.BM.offsets[bustName][1] || 0;
  367.     };
  368.  
  369.     var sw = width;
  370.     var sh = Galv.BM.bustHeight;
  371.     var dx = x - 1;
  372.     var dy = y + Galv.BM.bust;
  373.     var sx = bitmap.width / 2 - width / 2 - ox;
  374.     var sy = oy;
  375.     this.contents.unlimitedBlt(bitmap, sx, sy, sw, sh, dx, dy);
  376. };
  377.  
  378. Window_MenuStatus.prototype.bustWidth = function() {
  379.     return Math.floor((this.width - (this.standardPadding() * 2)) / this.maxCols());
  380. };
  381.  
  382.  
  383. Window_MenuStatus.prototype.cursorDown = function(wrap) {
  384.     var index = this.index();
  385.     var maxItems = this.maxItems();
  386.     var maxCols = this.maxCols();
  387.     if (index < maxItems - maxCols || (wrap && maxCols === 1)) {
  388.         this.select((index + maxCols) % maxItems);
  389.     } else {
  390.         this.select(maxItems - 1);
  391.     }
  392. };
  393.  
  394.  
  395. Window_MenuStatus.prototype.cursorUp = function(wrap) {
  396.     var index = this.index();
  397.     var maxItems = this.maxItems();
  398.     var maxCols = this.maxCols();
  399.     if (index >= maxCols || (wrap && maxCols === 1)) {
  400.         this.select((index - maxCols + maxItems) % maxItems);
  401.     } else {
  402.         this.select(0);
  403.     }
  404. };
  405.  
  406.  
  407. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement