Advertisement
rito_kun

Rito_XPBar_Menu

Nov 24th, 2015
1,577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Rito_XPBar_Menu.js
  3. //=============================================================================
  4. var Imported = Imported || {};
  5. Imported.Rito_XPBar_Menu = true;
  6. var Rito = Rito || {};
  7.  
  8. /*:
  9.  * @plugindesc Version 1.02
  10.  * Generation an Experience Jauge in menu for each actor.
  11.  * @author Rito
  12.  *
  13.  * @help Please credit me. Usage for commercial/free game.
  14.  *
  15.  *
  16.  * @param Color 1
  17.  * @desc Change the color jauge in the left.
  18.  * Default : #009700
  19.  * @default #009700
  20.  *
  21.  * @param Color 2
  22.  * @desc Change the color jauge in the right.
  23.  * Default : #00FF00
  24.  * @default #00FF00
  25.  *
  26.  * @param Width
  27.  * @desc Choice the wight to Exp Jauge.
  28.  * Default : 674 for resolution 1280*720.
  29.  * @default 674
  30.  *
  31.  * @param X Position
  32.  * @desc Change the position X of the Exp Jauge.
  33.  * Default : 318 for resolution 1280*720.
  34.  * @default 318
  35.  *
  36.  * @param Line Height
  37.  * @desc Choice the line of Exp Jauge (similar of Y Pos)
  38.  * Default : 3
  39.  * @default 3
  40.  *
  41.  * @param Show Required Exp / Max Lvl
  42.  * @desc Show the required Experience / max lvl text. (True / False)
  43.  * Default : True
  44.  * @default True
  45.  *
  46.  * @param Max Level Text
  47.  * @desc Displays the following message if the character reaches maximum level - Default : Max lvl
  48.  * @default Max lvl
  49.  */
  50. var parameters = PluginManager.parameters('Rito_XPBar_Menu');
  51.  
  52. Rito.Param = Rito.Param || {};
  53.  
  54. Rito.Param.lineHeight = Number(parameters['Line Height'] || 3);
  55. Rito.Param.color1 = String(parameters['Color 1'] || "#009700");
  56. Rito.Param.color2 = String(parameters['Color 2'] || "#00FF00");
  57. Rito.Param.width = Number(parameters['Width'] || 674);
  58. Rito.Param.x = Number(parameters['X Position'] || 318);
  59. Rito.Param.afficheTxt = String(parameters['Show Required Exp'] || "True");
  60. Rito.Param.TxtLvlMax = String(parameters['Max Level Text'] || "Max Lvl");
  61.  
  62. if (Rito.Param.lineHeight == 3){
  63.     if (Yanfly.Param.WindowPadding == undefined) { Yanfly.Param.WindowPadding = 18 } //Default variable
  64.     Window_SkillStatus.prototype.refresh = function() {
  65.         this.contents.clear();
  66.         if (this._actor) {
  67.             var w = this.width - this.padding * 2;
  68.             var h = this.height - this.padding * 2;
  69.                 if (!eval(true)) {
  70.                     var y = h / 2 - this.lineHeight() * 1.5;
  71.                 } else {
  72.                     var y = 0;
  73.                 }
  74.                 var xpad = Yanfly.Param.WindowPadding + Window_Base._faceWidth;
  75.         var width = w - xpad - this.textPadding();
  76.         this.drawActorFace(this._actor, 0, 0, Window_Base._faceWidth, h);
  77.         this.drawActorSimpleStatus(this._actor, xpad, y, width);
  78.     }
  79. };
  80. }
  81.  
  82. var _alias_DrawActorSimpleStatus = Window_Base.prototype.drawActorSimpleStatus;
  83. Window_Base.prototype.drawActorSimpleStatus = function(actor, x, y, width) {
  84.         _alias_DrawActorSimpleStatus.call(this,actor,x,y,width);
  85.         this.drawActorExp(actor, x, y + this.lineHeight() * Rito.Param.lineHeight);
  86. };
  87.  
  88. Window_Base.prototype.drawExpBar = function(Txt, x, y, width, color1, color2) {
  89.     var labelWidth = this.textWidth('HP');
  90.     var valueWidth = this.textWidth('00000000000000000000');
  91.     var slashWidth = "";
  92.     var x1 = x + width - valueWidth;
  93.     var x2 = x1 - slashWidth;
  94.     var x3 = x2 - valueWidth;
  95.     if (x3 >= x) {
  96.         this.changeTextColor(color1);
  97.         this.changeTextColor(color2);
  98.         this.drawText('/', x2, y, "", 'right');
  99.         this.drawText(Txt, x1, y, valueWidth, 'right');
  100.     } else {
  101.         this.changeTextColor(color1);
  102.     }
  103. };
  104.  
  105. Window_Base.prototype.drawActorExp = function(actor, x, y, width) {
  106.     if (Rito.Param.afficheTxt == "True") {
  107.         showTxt = actor.nextRequiredExp();
  108.         } else {
  109.         showTxt = "";
  110.     }
  111.    
  112.     width = Rito.Param.width;
  113.     x = Rito.Param.x;
  114.     var color1 = Rito.Param.color1;
  115.     var color2 = Rito.Param.color2;
  116.  
  117.     var exp = actor.currentExp() - actor.expForLevel(actor._level);
  118.     var Exp_suivant = actor.expForLevel(actor._level + 1) - actor.expForLevel(actor._level);
  119.  
  120.     var exp_rate = (exp / Exp_suivant);
  121.  
  122.     if (actor._level == actor.maxLevel()) {
  123.         if (Rito.Param.afficheTxt == "True") {
  124.             showTxt = Rito.Param.TxtLvlMax
  125.             } else {
  126.             showTxt = "";
  127.         }
  128.     exp_rate = 1
  129.     }
  130.     this.drawGauge(x, y, width, exp_rate, color1, color2);
  131.     this.changeTextColor(this.systemColor());
  132.     this.drawText(TextManager.expA, x, y, 44);
  133.     this.drawExpBar(showTxt, x, y, width, this.mpColor(actor), this.normalColor());
  134. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement