Advertisement
jerry2810

Map_Bars

Nov 2nd, 2015
48
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 Enabled
  50.  * @desc On True or false.
  51.  * @default true
  52.  *
  53.  * @help Cool bars!
  54.  *
  55. */
  56.  
  57. (function(){
  58. var parameters = PluginManager.parameters('Map_Bars');
  59. var bar1Enabled = parameters['Bar 1 Enabled'];
  60. var bar1x = parseInt(parameters['Bar 1 X starting']);
  61. var bar1y = parseInt(parameters['Bar 1 Y starting']);
  62. var bar1w = parseInt(parameters['Bar 1 Width']);
  63. var bar1h = parseInt(parameters['Bar 1 Height']);
  64. var b1c1 = parseInt(parameters['Bar 1 color 1']);
  65. var b1c2 = parseInt(parameters['Bar 1 color 2']);
  66. var b1c3 = parseInt(parameters['Bar 1 color 3']);
  67. var b1c4 = parseInt(parameters['Bar 1 color 4']);
  68. var b1tx = parseInt(parameters['Bar 1 Text x']);
  69. var b1ty = parseInt(parameters['Bar 1 Text y']);
  70.  
  71. //
  72. var b1maxValue = 100;
  73. var b1CurrentValue = 50;
  74. var b1rate = b1CurrentValue/b1maxValue;
  75. //
  76.  
  77.  
  78. function Map_Bar1() { this.initialize.apply(this, arguments); }
  79. Map_Bar1.prototype = Object.create(Window_Base.prototype);
  80. Map_Bar1.prototype.constructor = Map_Bar1;
  81.  
  82. Map_Bar1.prototype.initialize = function(x, y, width, height) {
  83.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  84.     this.deactivate();
  85.     this.update();
  86. };
  87.  
  88. Map_Bar1.prototype.update = function() {
  89.     Window_Base.prototype.update.call(this);
  90.     this.contents.clear();
  91.     this.drawBar1(bar1x, bar1y, bar1w);
  92. };
  93.  
  94. Map_Bar1.prototype.drawBar1 = function( x, y, width) {
  95.     this.opacity = 0;
  96.     this.makeFontSmaller();
  97.     var color1 = this.textColor(b1c1);
  98.     var color2 = this.textColor(b1c2);
  99.     var color3 = this.textColor(b1c3);
  100.     var color5 = this.textColor(b1c4);
  101.    
  102.     if(b1rate>b1maxValue){
  103.         b1rate = 1;
  104.     };
  105.    
  106.     if(b1rate >= 0){
  107.         this.drawGauge1(x, y, width, b1rate , color1, color2);
  108.     }else{
  109.         rate = -b1rate;
  110.         this.drawGauge1Neg(x, y, width, rate, color1, color2);
  111.     };
  112.    
  113.     this.drawText('var/varMax', x , y - this.lineHeight(), width, 'center');
  114.    
  115.  };
  116.  Window_Base.prototype.drawGauge1 = function(x, y, width, rate, color1, color2) {
  117.     var fillW = Math.floor(width * rate / 2);
  118.     this.contents.fillRect(x, y, width, bar1h, this.gaugeBackColor());
  119.     this.contents.gradientFillRect(x+width/2, y, fillW, bar1h, color1, color2);
  120. };
  121.  
  122.  Window_Base.prototype.drawGauge1Neg = function(x, y, width, rate, color1, color2) {
  123.     var fillW = Math.floor(width * rate / 2);
  124.     this.contents.fillRect(x, y, width, bar1h, this.gaugeBackColor());
  125.     this.contents.gradientFillRect(x + width/2 -fillW, y, fillW, bar1h, color3, color4);
  126. };
  127.  
  128. Scene_Map.prototype.createBar1 = function() {
  129. this.Bar1 = new Map_Bar1(0, 0, 816, 624);
  130. this.addChild(this.Bar1);
  131. };
  132.  
  133. var alias_createDisplayObjects= Scene_Map.prototype.createDisplayObjects;
  134. Scene_Map.prototype.createDisplayObjects = function() {
  135. alias_createDisplayObjects.call(this);
  136.     if(bar1Enabled == 'true'){
  137.         this.createBar1();
  138.     };
  139. };
  140. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement