Advertisement
Double_X

DoubleX RMMV Popularized ATB Bar v100d

Feb 19th, 2016 (edited)
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*============================================================================
  2.  *    ## Plugin Info                                                          
  3.  *----------------------------------------------------------------------------
  4.  *    # Plugin Name                                                          
  5.  *      DoubleX RMMV Popularized ATB Bar                                      
  6.  *----------------------------------------------------------------------------
  7.  *    # Terms Of Use                                                          
  8.  *      You shall keep this plugin's Plugin Info part's contents intact      
  9.  *      You shalln't claim that this plugin's written by anyone other than    
  10.  *      DoubleX or his aliases                                                
  11.  *      None of the above applies to DoubleX or his aliases                  
  12.  *----------------------------------------------------------------------------
  13.  *    # Prerequisites                                                        
  14.  *      Plugins:                                                              
  15.  *      1. DoubleX RMMV Popularized ATB Core                                  
  16.  *      Abilities:                                                            
  17.  *      1. Little Javascript coding proficiency to fully utilize this plugin  
  18.  *----------------------------------------------------------------------------
  19.  *    # Links                                                                
  20.  *      This plugin:                                                          
  21.  *      1. http://pastebin.com/fVNeBpks                                      
  22.  *      Video:                                                                
  23.  *      1. https://www.youtube.com/watch?v=xY_HrHi0e5M                        
  24.  *      Mentioned Patreon Supporters:
  25.  *      https://www.patreon.com/posts/71738797
  26.  *----------------------------------------------------------------------------
  27.  *    # Author                                                                
  28.  *      DoubleX                                                              
  29.  *----------------------------------------------------------------------------
  30.  *    # Changelog                                                            
  31.  *      v1.00d(GMT 0600 19-5-2021):                                          
  32.  *      1. Fixed all notetags not working bug
  33.  *      v1.00c(GMT 1700 16-9-2016):                                          
  34.  *      1. Improved this plugin's effectiveness, efficiency and robustness    
  35.  *      v1.00b(GMT 1400 31-5-2016):                                          
  36.  *      1. Improved this plugin's effectiveness, efficiency and readibility  
  37.  *      v1.00a(GMT 1500 19-2-2016):                                          
  38.  *      1. 1st completed version of this plugin finished                      
  39.  *============================================================================*/
  40. /*:
  41.  * @plugindesc Lets users set when/how ATB bars are shown on battler sprites
  42.  * @author DoubleX
  43.  *
  44.  * @param bar_show
  45.  * @desc Sets the code as bar_show determining when the battler ATB bars will be
  46.  *       shown on the battler sprites
  47.  *       It'll only be used by battlers not using <patb bar show: code> notetags
  48.  *       Available bar_show codes:
  49.  *       always - The battler ATB bars will always be shown on the enemy sprites
  50.  *       defeat - The actor ATB bars will always be shown on the actor sprites
  51.  *                while the enemy ATB bars will only be shown on the enemy
  52.  *                sprites for those being defeated before
  53.  *                This code will only be available if DoubleX RMMV Death Records
  54.  *                is used
  55.  *       Setting bar_show as an unavailable code means the battler ATB bars will
  56.  *       never be shown on the battler sprites
  57.  * @default always
  58.  *
  59.  * @param bar_w
  60.  * @desc Sets the width of the ATB bars shown on the battler sprites as bar_w
  61.  *       It'll only be used by battlers not using any <patb bar w: w> notetag
  62.  * @default 87
  63.  *
  64.  * @param bar_h
  65.  * @desc Sets the height of the ATB bars shown on the battler sprites as bar_h
  66.  *       It'll only be used by battlers not using any <patb bar h: h> notetag
  67.  * @default 16
  68.  *
  69.  * @param bar_x
  70.  * @desc Sets the x offset of the ATB bars shown on the battler sprites as bar_x
  71.  *       It'll only be used by battlers not using any <patb bar x: x> notetag
  72.  * @default 0
  73.  *
  74.  * @param bar_y
  75.  * @desc Sets the y offset of the ATB bars shown on the battler sprites as bar_y
  76.  *       It'll only be used by battlers not using any <patb bar y: y> notetag
  77.  * @default 0
  78.  *
  79.  * @param bar_opacity
  80.  * @desc Sets the opacity of the ATB bars shown on the battler sprites as
  81.  *       bar_opacity
  82.  *       It'll only be used by battlers not using any
  83.  *       <patb bar opacity: opacity> notetag
  84.  * @default 255
  85.  *
  86.  * @param bar_text_size
  87.  * @desc Sets the size of the description text of the ATB bars shown on the
  88.  *       battler sprites as bar_text_size
  89.  *       It'll only be used by battlers not using any <patb bar text size: size>
  90.  *       notetag
  91.  * @default 13
  92.  *
  93.  * @help
  94.  * The default plugin file name is DoubleX RMMV Popularized ATB Bar v100d
  95.  * If you want to change that, you must edit the value of
  96.  * DoubleX_RMMV.PATB_Bar_File, which must be done via opening this plugin js
  97.  * file directly
  98.  *============================================================================
  99.  *    ## Notetag Info                                                        
  100.  *----------------------------------------------------------------------------
  101.  *    # Actor/Class/Weapon/Armor/Enemy/State Notetags:                        
  102.  *      State notetags take the highest priority, followed by enemy, weapon,  
  103.  *      armor, class and actor                                                
  104.  *      The 1st notetag that's being read by the battler will be used        
  105.  *      1. <patb bar show: code>                                              
  106.  *         - Sets the code determining when the battler ATB bars will be shown
  107.  *           on the battler sprites as code                                  
  108.  *           Available codes are those of bar_show                            
  109.  *         - Setting code as an unavailable code means the battler ATB bars  
  110.  *           will never be shown on the battler sprites                      
  111.  *      2. <patb bar w: w>                                                    
  112.  *         - Sets the width of the ATB bars shown on the battler sprites as w
  113.  *      3. <patb bar h: h>                                                    
  114.  *         - Sets the height of the ATB bars shown on the battler sprites as h
  115.  *      4. <patb bar x: x>                                                    
  116.  *         - Sets the x offset of the ATB bars shown on the battler sprites as
  117.  *           x                                                                
  118.  *      5. <patb bar y: y>                                                    
  119.  *         - Sets the y offset of the ATB bars shown on the battler sprites as
  120.  *           y                                                                
  121.  *      6. <patb bar opacity: opacity>                                        
  122.  *         - Sets the opacity of the ATB bars shown on the battler sprites as
  123.  *           opacity                                                          
  124.  *      7. <patb bar text size: size>                                        
  125.  *         - Sets the size of the description text of the ATB bars shown on  
  126.  *           the battler sprites as size                                      
  127.  *============================================================================
  128.  *    ## Plugin Call Info                                                    
  129.  *----------------------------------------------------------------------------
  130.  *    # Configuration manipulations                                          
  131.  *      1. $gameSystem.patb.param                                            
  132.  *         - Returns the value of param listed in the plugin manager          
  133.  *      2. $gameSystem.patb.param = val                                      
  134.  *         - Sets the value of param listed in the plugin manager as val      
  135.  *         - All $gameSystem.patb.param changes will be saved                
  136.  *    # Actor/Class/Weapon/Armor/Enemy/State manipulations                    
  137.  *      1. meta.patb_bar_show                                                
  138.  *         - Returns the code determining when the battler ATB bars will be  
  139.  *           shown on the battler sprites                                    
  140.  *      2. meta.patb_bar_show = code                                          
  141.  *         - Sets the code determining when the battler ATB bars will be shown
  142.  *           on the battler sprites as code                                  
  143.  *         - All meta.patb_bar_show changes can be saved if                  
  144.  *           DoubleX RMMV Dynamic Data is used                                
  145.  *      3. meta.patb_bar_w                                                    
  146.  *         - Returns the width of the ATB bars shown on the battler sprites  
  147.  *      4. meta.patb_bar_w = w                                                
  148.  *         - Sets the width of the ATB bars shown on the battler sprites as w
  149.  *         - All meta.patb_bar_w changes can be saved if                      
  150.  *           DoubleX RMMV Dynamic Data is used                                
  151.  *      5. meta.patb_bar_h                                                    
  152.  *         - Returns the height of the ATB bars shown on the battler sprites  
  153.  *      6. meta.patb_bar_w = h                                                
  154.  *         - Sets the height of the ATB bars shown on the battler sprites as h
  155.  *         - All meta.patb_bar_h changes can be saved if                      
  156.  *           DoubleX RMMV Dynamic Data is used                                
  157.  *      7. meta.patb_bar_x                                                    
  158.  *         - Returns the x offset of the ATB bars shown on the battler sprites
  159.  *      8. meta.patb_bar_y = x                                                
  160.  *         - Sets the x offset of the ATB bars shown on the battler sprites as
  161.  *           x                                                                
  162.  *         - All meta.patb_bar_x changes can be saved if                      
  163.  *           DoubleX RMMV Dynamic Data is used                                
  164.  *      9. meta.patb_bar_y                                                    
  165.  *         - Returns the y offset of the ATB bars shown on the battler sprites
  166.  *      10. meta.patb_bar_y = y                                              
  167.  *          - Sets the y offset of the ATB bars shown on the battler sprites  
  168.  *            as y                                                            
  169.  *          - All meta.patb_bar_y changes can be saved if                    
  170.  *            DoubleX RMMV Dynamic Data is used                              
  171.  *      11. meta.patb_bar_opacity                                            
  172.  *          - Returns the opacity of the ATB bars shown on the battler sprites
  173.  *      12. meta.patb_bar_opacity = opacity                                  
  174.  *          - Sets the opacity of the ATB bars shown on the battler sprites  
  175.  *            as opacity                                                      
  176.  *          - All meta.patb_bar_opacity changes can be saved if              
  177.  *            DoubleX RMMV Dynamic Data is used                              
  178.  *      13. meta.patb_bar_text_size                                          
  179.  *          - Returns the size of the description text of the ATB bars shown  
  180.  *            on the battler sprites                                          
  181.  *      14. meta.patb_bar_text_size = size                                    
  182.  *          - Sets the size of the description text of the ATB bars shown on  
  183.  *            the battler sprites as size                                    
  184.  *          - All meta.patb_bar_size changes can be saved if                  
  185.  *            DoubleX RMMV Dynamic Data is used                              
  186.  *============================================================================
  187.  */
  188.  
  189. "use strict";
  190. var DoubleX_RMMV = DoubleX_RMMV || {};
  191. DoubleX_RMMV["PATB Bar"] = "v1.00d";
  192.  
  193. // The plugin file name must be the same as DoubleX_RMMV.PATB_Bar_File
  194. DoubleX_RMMV.PATB_Bar_File = "DoubleX RMMV Popularized ATB Bar v100d";
  195.  
  196. /*============================================================================
  197.  *    ## Plugin Implementations                                              
  198.  *       You need not edit this part as it's about how this plugin works      
  199.  *----------------------------------------------------------------------------
  200.  *    # Plugin Support Info:                                                  
  201.  *      1. Prerequisites                                                      
  202.  *         - Basic knowledge of this plugin on the user level, the default    
  203.  *           battle system implementations and the atb system concepts        
  204.  *         - Some Javascript coding proficiency to fully comprehend this      
  205.  *           plugin                                                          
  206.  *      2. Function documentation                                            
  207.  *         - The 1st part describes why this function's rewritten/extended for
  208.  *           rewritten/extended functions or what the function does for new  
  209.  *           functions                                                        
  210.  *         - The 2nd part describes what the arguments of the function are    
  211.  *         - The 3rd part informs which version rewritten, extended or created
  212.  *           this function                                                    
  213.  *         - The 4th part informs whether the function's rewritten or new    
  214.  *         - The 5th part informs whether the function's a real or potential  
  215.  *           hotspot                                                          
  216.  *         - The 6th part describes how this function works for new functions
  217.  *           only, and describes the parts added, removed or rewritten for    
  218.  *           rewritten or extended functions only                            
  219.  *         Example:                                                          
  220.  * /*----------------------------------------------------------------------
  221.  *  *    Why rewrite/extended/What this function does                      
  222.  *  *----------------------------------------------------------------------*/
  223. /* // arguments: What these arguments are                                    
  224.  * function_name = function(arguments) { // Version X+; Rewrite/New; Hotspot  
  225.  *     // Added/Removed/Rewritten to do something/How this function works    
  226.  *     function_name_code;                                                    
  227.  *     //                                                                    
  228.  * } // function_name                                                        
  229.  *----------------------------------------------------------------------------*/
  230.  
  231. function Window_Patb_Bar() { this.initialize.apply(this, arguments); }
  232.  
  233. if (DoubleX_RMMV["PATB Core"]) {
  234.  
  235. /*----------------------------------------------------------------------------*/
  236.  
  237. /*----------------------------------------------------------------------------
  238.  *    # Edit class: DataManager                                              
  239.  *----------------------------------------------------------------------------*/
  240.  
  241. // data: The data to have its notetags read
  242. DataManager.load_patb_bar_data_notes = DataManager.load_patb_data_notes;
  243. DataManager.load_patb_data_notes = function(data) {
  244.     this.load_patb_bar_data_notes(data);
  245.     this.load_patb_bar_notes(data); // Added
  246. }; // DataManager.load_patb_data_notes
  247.  
  248. // data: The data to have its notetags read
  249. DataManager.load_patb_bar_notes = function(data) { // New
  250.     var meta = data.meta;
  251.     var show = /< *patb +bar +show *: *(\w+)*>/i;
  252.     var w = /< *patb +bar +w *: *(\d+)*>/i;
  253.     var h = /< *patb +bar +h *: *(\d+)*>/i;
  254.     var x = /< *patb +bar +x *: *(\d+)*>/i;
  255.     var y = /< *patb +bar +y *: *(\d+)*>/i;
  256.     var opacity = /< *patb +bar +opacity *: *(\d+)*>/i;
  257.     var size = /< *patb +bar +text +size *: *(\d+)*>/i;
  258.     data.note.split(/[\r\n]+/).forEach(function(line) {
  259.         if (line.match(show)) { return meta.patb_bar_show = RegExp.$1; }
  260.         if (line.match(w)) { return meta.patb_bar_w = +RegExp.$1; }
  261.         if (line.match(h)) { return meta.patb_bar_h = +RegExp.$1; }
  262.         if (line.match(x)) { return meta.patb_bar_x = +RegExp.$1; }
  263.         if (line.match(y)) { return meta.patb_bar_y = +RegExp.$1; }
  264.         if (line.match(opacity)) { return meta.patb_bar_opacity = +RegExp.$1; }
  265.         if (line.match(size)) { return meta.patb_bar_text_size = +RegExp.$1; }
  266.     });
  267. }; // DataManager.load_patb_bar_notes
  268.  
  269. /*----------------------------------------------------------------------------
  270.  *    # Edit class: Game_System                                              
  271.  *      - Stores the values of all configurations listed in the plugin manager
  272.  *----------------------------------------------------------------------------*/
  273.  
  274. Game_System.prototype.init_patb_bar_params =
  275. Game_System.prototype.init_patb_params;
  276. Game_System.prototype.init_patb_params = function() {
  277.     this.init_patb_bar_params();
  278.     // Added
  279.     var val, params;
  280.     params = PluginManager.parameters(DoubleX_RMMV.PATB_Bar_File);
  281.     Object.keys(params).forEach(function(param) {
  282.         val = +params[param];
  283.         this._patb[param] = isNaN(val) ? params[param] : val;
  284.     }, this);
  285.     //
  286. }; // Game_System.prototype.init_patb_params
  287.  
  288. /*----------------------------------------------------------------------------
  289.  *    # Edit class: Game_Battler                                              
  290.  *----------------------------------------------------------------------------*/
  291.  
  292. /*----------------------------------------------------------------------------
  293.  *    New private instance variables                                          
  294.  *----------------------------------------------------------------------------*/
  295. /* _patb_bar_show: The battler sprite ATB bar visibility flag
  296.  * _patb_bar_w: The battler sprite ATB bar width
  297.  * _patb_bar_h: The battler sprite ATB bar height
  298.  * _patb_bar_x: The battler sprite ATB bar x offset
  299.  * _patb_bar_y: The battler sprite ATB bar y offset
  300.  * _patb_bar_opacity: The battler sprite ATB bar opacity
  301.  * _patb_bar_text_size: The battler sprite ATB bar description text size
  302.  */
  303.  
  304. Game_Battler.prototype.init_patb_bar = Game_Battler.prototype.init_patb;
  305. Game_Battler.prototype.init_patb = function() {
  306.     this.init_patb_bar();
  307.     // Added
  308.     this._patb_battler_change.patb_bar_show = true;
  309.     this._patb_note_change.patb_bar_show = true;
  310.     this._patb_battler_change.patb_bar_w = true;
  311.     this._patb_note_change.patb_bar_w = true;
  312.     this._patb_battler_change.patb_bar_h = true;
  313.     this._patb_note_change.patb_bar_h = true;
  314.     this._patb_battler_change.patb_bar_x = true;
  315.     this._patb_note_change.patb_bar_x = true;
  316.     this._patb_battler_change.patb_bar_y = true;
  317.     this._patb_note_change.patb_bar_y = true;
  318.     this._patb_battler_change.patb_bar_opacity = true;
  319.     this._patb_note_change.patb_bar_opacity = true;
  320.     this._patb_battler_change.patb_bar_text_size = true;
  321.     this._patb_note_change.patb_bar_text_size = true;
  322.     //
  323. }; // Game_Battler.prototype.init_patb
  324.  
  325. // note: The battler sprite ATB bar notetag
  326. Game_Battler.prototype.patb_bar_note = function(note) { // New; Hotspot
  327.     if (this.are_patb_battler_changed("patb_" + note)) {
  328.         this.set_patb_bar_note(note);
  329.     }
  330.     return this["_patb_" + note];
  331. }; // Game_Battler.prototype.patb_bar_note
  332.  
  333. // note: The battler sprite ATB bar notetag
  334. Game_Battler.prototype.set_patb_bar_note = function(note) {
  335. // New; Potential Hotspot
  336.     var patb_note = "_patb_" + note;
  337.     this[patb_note] = this.set_patb_notes("patb_" + note);
  338.     if (!this[patb_note]) { this[patb_note] = $gameSystem.patb[note]; }
  339.     if (note !== "bar_show") { return; }
  340.     if (!this.isAlive()) { return this._patb_bar_show = false; }
  341.     if (this._patb_bar_show === "always") { return this._patb_bar_show = true; }
  342.     if (this._patb_bar_show === "defeat") {
  343.         return this._patb_bar_show = this.is_patb_defeated();
  344.     }
  345.     this._patb_bar_show = false;
  346. }; // Game_Battler.prototype.set_patb_bar_note
  347.  
  348. Game_Battler.prototype.is_patb_defeated = function() { // New; Potential Hotspot
  349.     return true; // This doesn't mean the battler's defeated before by default
  350. }; // Game_Battler.prototype.is_patb_defeated
  351.  
  352. /*----------------------------------------------------------------------------
  353.  *    # Edit class: Game_Enemy                                                
  354.  *----------------------------------------------------------------------------*/
  355.  
  356. Game_Enemy.prototype.is_patb_defeated = function() { // New; Potential Hotspot
  357.     if (!DoubleX_RMMV["Death Records"]) { return true; }
  358.     var death_record = this._enemyDeathRecords[enemyId];
  359.     return death_record && death_record > 0;
  360. }; // Game_Enemy.prototype.is_patb_defeated
  361.  
  362. /*----------------------------------------------------------------------------
  363.  *    # Edit class: Sprite_Battler                                            
  364.  *----------------------------------------------------------------------------*/
  365.  
  366. /*----------------------------------------------------------------------------
  367.  *    New private instance variable                                          
  368.  *----------------------------------------------------------------------------*/
  369. // _patb_bar: The battler sprite ATB bar
  370.  
  371. Sprite_Battler.prototype.initMembersPatbBar =
  372. Sprite_Battler.prototype.initMembers;
  373. Sprite_Battler.prototype.initMembers = function() {
  374.     this.initMembersPatbBar();
  375.     this.set_patb_bar(); // Added
  376. }; // Sprite_Battler.prototype.initMembers
  377.  
  378. /*----------------------------------------------------------------------------
  379.  *    Reconfigures the battler sprite ATB bar upon battler change            
  380.  *----------------------------------------------------------------------------*/
  381. Sprite_Battler.prototype.setBattlerPatbBar =
  382. Sprite_Battler.prototype.setBattler;
  383. Sprite_Battler.prototype.setBattler = function(battler) { // Hotspot
  384.     var change = battler !== this._battler; // Added
  385.     this.setBattlerPatbBar(battler);
  386.     if (battler && change) { this._patb_bar.battler = battler; } // Added
  387. }; // Sprite_Battler.prototype.setBattler
  388.  
  389. Sprite_Battler.prototype.updatePatbBar = Sprite_Battler.prototype.update;
  390. Sprite_Battler.prototype.update = function() { // Hotspot
  391.     this.updatePatbBar();
  392.     this._patb_bar.updateBar(); // Added
  393. }; // Sprite_Battler.prototype.update
  394.  
  395. Sprite_Battler.prototype.set_patb_bar = function() { // New
  396.     this._patb_bar = new Window_Patb_Bar();
  397.     this.addChild(this._patb_bar);
  398. }; // Sprite_Battler.prototype.set_patb_bar
  399.  
  400. /*----------------------------------------------------------------------------
  401.  *    # New class: Window_Patb_Bar                                            
  402.  *----------------------------------------------------------------------------*/
  403.  
  404. Window_Patb_Bar.prototype = Object.create(Window_Base.prototype);
  405. Window_Patb_Bar.prototype.constructor = Window_Patb_Bar;
  406.  
  407. /*----------------------------------------------------------------------------
  408.  *    New public instance variable                                            
  409.  *----------------------------------------------------------------------------*/
  410. Object.defineProperty(Window_Patb_Bar.prototype, 'battler', {
  411.     // The battler owning the battler sprite ATB bar
  412.     set: function(battler) { this._battler = battler; },
  413.     configurable: true
  414. });
  415.  
  416. /*----------------------------------------------------------------------------
  417.  *    New private instance variables                                          
  418.  *----------------------------------------------------------------------------*/
  419. /* _fillWidth: The battler sprite ATB bar fill width
  420.  * _redraw: The battler sprite ATB bar redraw flag
  421.  */
  422.  
  423. Window_Patb_Bar.prototype.initialize = function() {
  424.     var patb = $gameSystem.patb, x = patb.bar_x, y = patb.bar_y;
  425.     var w = patb.bar_w, h = patb.bar_h;
  426.     Window_Base.prototype.initialize.call(this, x, y, w, h);
  427.     this.opacity = 0; // Only the battler sprite ATB bar needs to be shown
  428. }; // Window_Patb_Bar.prototype.initialize
  429.  
  430. Window_Patb_Bar.prototype.standardFontSize = function() { // Hotspot
  431.     if (this._battler) {
  432.         return this._battler.patb_bar_note("bar_text_size");
  433.     }
  434.     return Window_Base.prototype.standardFontSize.call(this);
  435. }; // Window_Patb_Bar.prototype.standardFontSize
  436.  
  437. Window_Patb_Bar.prototype.standardPadding = function() { // Hotspot
  438.     return 0; // The whole window is just the battler sprite ATB bar
  439. }; // Window_Patb_Bar.prototype.standardPadding
  440.  
  441. Window_Patb_Bar.prototype.resetFontSettings = function() { // Hotspot
  442.     if (this.contents.fontSize === this.standardFontSize()) { return; }
  443.     Window_Base.prototype.resetFontSettings.call(this);
  444.     this._redraw = true;
  445. }; // Window_Patb_Bar.prototype.resetFontSettings
  446.  
  447. Window_Patb_Bar.prototype.updateBar = function() { // Hotspot
  448.     this.updateVisible();
  449.     if (!this.visible) { return; }
  450.     this.resetFontSettings();
  451.     this.updateNotes();
  452.     this.updateFillWidth();
  453.     if (this.needRedraw()) { this.redraw(); }
  454. }; // Window_Patb_Bar.prototype.updateBar
  455.  
  456. Window_Patb_Bar.prototype.updateVisible = function() { // Hotspot
  457.     if (!$gameSystem.is_patb()) { return this.visible = false; }
  458.     if (!BattleManager.can_update_patb()) { return this.visible = false; }
  459.     if (!this._battler) { return this.visible = false; } // It's to play safe
  460.     this.visible = this._battler.patb_bar_note("bar_show");
  461. }; // Window_Patb_Bar.prototype.updateVisible
  462.  
  463. Window_Patb_Bar.prototype.updateNotes = function() { // Hotspot
  464.     this.updateX();
  465.     this.updateY();
  466.     this.updateW();
  467.     this.updateH();
  468.     this.contentsOpacity = this._battler.patb_bar_note("bar_opacity");
  469. }; // Window_Patb_Bar.prototype.updateNotes
  470.  
  471. Window_Patb_Bar.prototype.updateX = function() { // v1.00b+; Hotspot
  472.     var newX = this._battler.patb_bar_note("bar_x");
  473.     if (this.x !== newX) { this.x = newX; }
  474. }; // Window_Patb_Bar.prototype.updateX
  475.  
  476. Window_Patb_Bar.prototype.updateY = function() { // v1.00b+; Hotspot
  477.     var newY = this._battler.patb_bar_note("bar_y");
  478.     if (this.y !== newY) { this.y = newY; }
  479. }; // Window_Patb_Bar.prototype.updateY
  480.  
  481. Window_Patb_Bar.prototype.updateW = function() { // Hotspot
  482.     var newW = this._battler.patb_bar_note("bar_w");
  483.     if (this.width === newW) return;
  484.     this.width = newW;
  485.     this._redraw = true;
  486. }; // Window_Patb_Bar.prototype.updateW
  487.  
  488. Window_Patb_Bar.prototype.updateH = function() { // Hotspot
  489.     var newH = this._battler.patb_bar_note("bar_h");
  490.     if (this.height === newH) return;
  491.     this.height = newH;
  492.     this._redraw = true;
  493. }; // Window_Patb_Bar.prototype.updateH
  494.  
  495. Window_Patb_Bar.prototype.updateFillWidth = function() { // Hotspot
  496.     var lastFillWidth = this._fillWidth, type = this._battler.patb_type();
  497.     this._fillWidth = this.width * this._battler.patb_fill_rate(type);
  498.     this._redraw = this._redraw || lastFillWidth !== this._fillWidth;
  499. }; // Window_Patb_Bar.prototype.updateFillWidth
  500.  
  501. /*----------------------------------------------------------------------------
  502.  *    Only redraws the ATB bar when it can change to boost performance        
  503.  *----------------------------------------------------------------------------*/
  504. Window_Patb_Bar.prototype.needRedraw = function() { // Hotspot
  505.     if (this._redraw) {
  506.         this._redraw = false;
  507.         return true;
  508.     }
  509.     return BattleManager.need_patb_refresh;
  510. }; // Window_Patb_Bar.prototype.needRedraw
  511.  
  512. Window_Patb_Bar.prototype.redraw = function() { // Potential Hotspot
  513.     var color = this.gaugeBackColor(), width = this._fillWidth;
  514.     this.contents.fillRect(0, 0, this.width, this.height, color);
  515.     var colors = this._battler.patb_colors(this._battler.patb_type());
  516.     var color1 = this.textColor(colors[0]), color2 = this.textColor(colors[1]);
  517.     this.contents.gradientFillRect(0, 0, width, this.height, color1, color2);
  518.     this.changeTextColor(this.systemColor());
  519.     var text = this._battler.patb_bar_text();
  520.     this.contents.drawText(text, 0, 0, this.textWidth(text), this.height);
  521. }; // Window_Patb_Bar.prototype.redraw
  522.  
  523. /*----------------------------------------------------------------------------*/
  524.  
  525. } else {
  526.     alert("To use PATB Bar, place it below PATB Core.");
  527. }
  528.  
  529. /*============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement