Advertisement
jerry2810

Map_Bars

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