Advertisement
jerry2810

Map_Bars

Nov 2nd, 2015
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Map_Bars.js
  3. //=============================================================================
  4. //v1.1 Special Version that goes positive and negative.
  5. /*:
  6.  * @plugindesc Makes bars yo!
  7.  * @author Jeremy Cannady
  8.  *
  9.  * @param Bar 1 X starting
  10.  * @desc Select x position.
  11.  * @default 0
  12.  *
  13.  * @param Bar 1 Y starting
  14.  * @desc Select the y position.
  15.  * @default 550
  16.  *
  17.  * @param Bar 1 Width
  18.  * @desc Select the width.
  19.  * @default 750
  20.  *
  21.  * @param Bar 1 Height
  22.  * @desc Select the height.
  23.  * @default 20
  24.  *
  25.  * @param Bar 1 color 1
  26.  * @desc Select the color.
  27.  * @default 3
  28.  *
  29.  * @param Bar 1 color 2
  30.  * @desc Select the color.
  31.  * @default 3
  32.  *
  33.  * @param Bar 1 color 3
  34.  * @desc Select the color.
  35.  * @default 10
  36.  *
  37.  * @param Bar 1 color 4
  38.  * @desc Select the color.
  39.  * @default 10
  40.  *
  41.  * @param Bar 1 Text x
  42.  * @desc Select the x.
  43.  * @default 0
  44.  *
  45.  * @param Bar 1 Text y
  46.  * @desc Select the y.
  47.  * @default 0
  48.  *
  49.  * @param Bar 1 EnabledMap
  50.  * @desc On True or false.
  51.  * @default true
  52.  *
  53.  * @param Bar 1 EnabledBattle
  54.  * @desc On True or false.
  55.  * @default true
  56.  * @help Cool bars!
  57.  *
  58. */
  59.  
  60. (function(){
  61. var parameters = PluginManager.parameters('Map_Bars');
  62. var bar1EnabledMap = parameters['Bar 1 EnabledMap'];
  63. var bar1EnabledBattle = parameters['Bar 1 EnabledBattle'];
  64. var bar1x = parseInt(parameters['Bar 1 X starting']);
  65. var bar1y = parseInt(parameters['Bar 1 Y starting']);
  66. var bar1w = parseInt(parameters['Bar 1 Width']);
  67. var bar1h = parseInt(parameters['Bar 1 Height']);
  68. var b1c1 = parseInt(parameters['Bar 1 color 1']);
  69. var b1c2 = parseInt(parameters['Bar 1 color 2']);
  70. var b1c3 = parseInt(parameters['Bar 1 color 3']);
  71. var b1c4 = parseInt(parameters['Bar 1 color 4']);
  72. var b1tx = parseInt(parameters['Bar 1 Text x']);
  73. var b1ty = parseInt(parameters['Bar 1 Text y']);
  74.  
  75. //
  76. var b1maxValue = 100;
  77. var b1CurrentValue = 50;
  78. var b1rate = b1CurrentValue/b1maxValue;
  79. //
  80.  
  81.  
  82. function Map_Bar1() { this.initialize.apply(this, arguments); }
  83. Map_Bar1.prototype = Object.create(Window_Base.prototype);
  84. Map_Bar1.prototype.constructor = Map_Bar1;
  85.  
  86. Map_Bar1.prototype.initialize = function(x, y, width, height) {
  87.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  88.     this.deactivate();
  89.     this.update();
  90. };
  91.  
  92. Map_Bar1.prototype.update = function() {
  93.     Window_Base.prototype.update.call(this);
  94.     this.contents.clear();
  95.     this.drawBar1(bar1x, bar1y, bar1w);
  96. };
  97.  
  98. Map_Bar1.prototype.drawBar1 = function( x, y, width) {
  99.     this.opacity = 0;
  100.     this.makeFontSmaller();
  101.     var color1 = this.textColor(b1c1);
  102.     var color2 = this.textColor(b1c2);
  103.     var color3 = this.textColor(b1c3);
  104.     var color5 = this.textColor(b1c4);
  105.    
  106.     if(b1rate>b1maxValue){
  107.         b1rate = 1;
  108.     };
  109.    
  110.     if(b1rate >= 0){
  111.         this.drawGauge1(x, y, width, b1rate , color1, color2);
  112.     }else{
  113.         rate = -b1rate;
  114.         this.drawGauge1Neg(x, y, width, rate, color1, color2);
  115.     };
  116.    
  117.     this.drawText('var/varMax', x , y - this.lineHeight(), width, 'center');
  118.    
  119.  };
  120.  Window_Base.prototype.drawGauge1 = function(x, y, width, rate, color1, color2) {
  121.     var fillW = Math.floor(width * rate / 2);
  122.     this.contents.fillRect(x, y, width, bar1h, this.gaugeBackColor());
  123.     this.contents.gradientFillRect(x+width/2, y, fillW, bar1h, color1, color2);
  124. };
  125.  
  126.  Window_Base.prototype.drawGauge1Neg = function(x, y, width, rate, color1, color2) {
  127.     var fillW = Math.floor(width * rate / 2);
  128.     this.contents.fillRect(x, y, width, bar1h, this.gaugeBackColor());
  129.     this.contents.gradientFillRect(x + width/2 -fillW, y, fillW, bar1h, color3, color4);
  130. };
  131.  
  132. Scene_Map.prototype.createBar1 = function() {
  133. this.Bar1 = new Map_Bar1(0, 0, 816, 624);
  134. this.addChild(this.Bar1);
  135. };
  136.  
  137. var alias_createDisplayObjectsMap =  Scene_Map.prototype.createDisplayObjects;
  138. Scene_Map.prototype.createDisplayObjects = function() {
  139. alias_createDisplayObjectsMap.call(this);
  140.     if(bar1EnabledMap == 'true'){
  141.         this.createBar1();
  142.     };
  143. };
  144.  
  145. Scene_Battle.prototype.createBar1 = function() {
  146.     this.Bar1 = new Map_Bar1(0, 0, 816, 624);
  147.     this.addChild(this.Bar1);
  148. };
  149.  
  150. var battleWindows = Scene_Battle.prototype.createAllWindows;
  151. Scene_Battle.prototype.createAllWindows = function() {
  152.     battleWindows.call(this)
  153.     if(bar1EnabledBattle == 'true'){
  154.         this.createBar1();
  155.     };
  156. };
  157.  
  158. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement