<commit_before>/*
 * MelonJS Game Engine
 * Copyright (C) 2011 - 2018 <NAME>
 * http://www.melonjs.org
 *
 * a simple particle debug panel plugin
 * usage : me.plugin.register.defer(this, me.debug.ParticlePanel, "particledebug");
 *
 * note :
 * Heap Memory information is available under Chrome when using
 * the "--enable-memory-info" parameter to launch Chrome
 */

(function () {

    // ensure that me.debug is defined
    me.debug = me.debug || {};

    var ParticlePanel = me.Renderable.extend({

        /** @private */
        init : function () {
            // call the super constructor
            this._super(me.Renderable, "init", [ 0, me.video.renderer.getHeight() - 60, 200, 60 ]);

            // minimum melonJS version expected
            this.version = "6.0.0";

            // to hold the debug options
            // clickable rect area
            this.area = {};

            // for z ordering
            // make it ridiculously high
            this.pos.z = Infinity;

            // visibility flag
            this.visible = true;

            // set the object GUID value
            this.GUID = "particledebug-" + me.utils.createGUID();

            // set the object entity name
            this.name = "me.particleDebugPanel";

            // persistent
            this.isPersistent = true;

            // a floating object
            this.floating = true;

            // always update, even when not visible
            this.alwaysUpdate = true;

            // create a default font, with fixed char width
            this.font = new me.Font("courier", 10, "white");

            // sample points
            this.frameUpdateTimeSamples = [];
            this.frameDrawTimeSamples = [];
            this.updateTimeSamples = [];
            this.drawTimeSamples = [];
            this.updateTime = 0;
            this.drawTime = 0;
            this.updateTimeAvg = 0;
            this.drawTimeAvg = 0;
            this.frameUpdateTimeAvg = 0;
            this.frameDrawTimeAvg = 0;

            this.emitterCount = 0;
            this.particleCount = 0;

            //patch patch patch !
            this.patchSystemFn();

            // add the debug panel to the game world
            me.game.world.addChild(this, Infinity);
        },


        /**
         * patch system fn to draw debug information
         */
        patchSystemFn : function () {
            var _this = this;
            var now = Date.now;
            if (window.performance && window.performance.now) {
                now = window.performance.now.bind(window.performance);
            }

            // patch me.ParticleEmitter.init
            me.plugin.patch(me.ParticleEmitter, "init", function (x, y, image) {
                this._patched(x, y, image);
                _this.emitterCount++;
            });

            // patch me.ParticleEmitter.destroy
            me.plugin.patch(me.ParticleEmitter, "destroy", function () {
                this._patched();
                _this.emitterCount--;
            });

            // patch me.Particle.init
            me.plugin.patch(me.Particle, "init", function (emitter) {
                this._patched(emitter);
                _this.particleCount++;
            });

            // patch me.Particle.destroy
            me.Particle.prototype.destroy = function () {
                _this.particleCount--;
            };

            // patch me.game.update
            me.plugin.patch(me.game, "update", function (dt) {
                var startTime = now();
                this._patched(dt);
                // calculate the update time (can't we use [dt] here ?)
                _this.frameUpdateTimeSamples.push(now() - startTime);
            });

            // patch me.game.draw
            me.plugin.patch(me.game, "draw", function () {
                var startTime = now();
                this._patched();
                // calculate the drawing time
                _this.frameDrawTimeSamples.push(now() - startTime);
            });

            // patch me.ParticleContainer.update
            me.plugin.patch(me.ParticleContainer, "update", function (dt) {
                var startTime = now();
                var value = this._patched(dt);
                // calculate the update time (can't we use [dt] here ?)
                _this.updateTime += now() - startTime;
                return value;
            });

            // patch me.ParticleContainer.draw
            me.plugin.patch(me.ParticleContainer, "draw", function (renderer, rect) {
                var startTime = now();
                this._patched(renderer, rect);
                // calculate the drawing time
                _this.drawTime += now() - startTime;
            });
        },<commit_msg>[#393] fix a regression on the particle debug panel<commit_after>/*
 * MelonJS Game Engine
 * Copyright (C) 2011 - 2018 <NAME>
 * http://www.melonjs.org
 *
 * a simple particle debug panel plugin
 * usage : me.plugin.register.defer(this, me.debug.ParticlePanel, "particledebug");
 *
 * note :
 * Heap Memory information is available under Chrome when using
 * the "--enable-memory-info" parameter to launch Chrome
 */

(function () {

    // ensure that me.debug is defined
    me.debug = me.debug || {};

    var ParticlePanel = me.Renderable.extend({

        /** @private */
        init : function () {
            // call the super constructor
            this._super(me.Renderable, "init", [ 0, me.video.renderer.getHeight() - 60, 200, 60 ]);

            // minimum melonJS version expected
            this.version = "6.0.0";

            // to hold the debug options
            // clickable rect area
            this.area = {};

            // for z ordering
            // make it ridiculously high
            this.pos.z = Infinity;

            // visibility flag
            this.visible = true;

            // set the object GUID value
            this.GUID = "particledebug-" + me.utils.createGUID();

            // set the object entity name
            this.name = "me.particleDebugPanel";

            // persistent
            this.isPersistent = true;

            // a floating object
            this.floating = true;

            // always update, even when not visible
            this.alwaysUpdate = true;

            // create a default font, with fixed char width
            this.font = new me.Font("courier", 10, "white");

            // sample points
            this.frameUpdateTimeSamples = [];
            this.frameDrawTimeSamples = [];
            this.updateTimeSamples = [];
            this.drawTimeSamples = [];
            this.updateTime = 0;
            this.drawTime = 0;
            this.updateTimeAvg = 0;
            this.drawTimeAvg = 0;
            this.frameUpdateTimeAvg = 0;
            this.frameDrawTimeAvg = 0;

            this.emitterCount = 0;
            this.particleCount = 0;

            //patch patch patch !
            this.patchSystemFn();

            // add the debug panel to the game world
            me.game.world.addChild(this, Infinity);
        },


        /**
         * patch system fn to draw debug information
         */
        patchSystemFn : function () {
            var _this = this;
            var now = Date.now;
            if (window.performance && window.performance.now) {
                now = window.performance.now.bind(window.performance);
            }

            // patch me.ParticleEmitter.init
            me.plugin.patch(me.ParticleEmitter, "init", function (x, y, image) {
                this._patched.apply(this, arguments);
                _this.emitterCount++;
            });

            // patch me.ParticleEmitter.destroy
            me.plugin.patch(me.ParticleEmitter, "destroy", function () {
                this._patched.apply(this, arguments);
                _this.emitterCount--;
            });

            // patch me.Particle.init
            me.plugin.patch(me.Particle, "init", function (emitter) {
                this._patched.apply(this, arguments);
                _this.particleCount++;
            });

            // patch me.Particle.destroy
            me.Particle.prototype.destroy = function () {
                _this.particleCount--;
            };

            // patch me.game.update
            me.plugin.patch(me.game, "update", function (dt) {
                var startTime = now();
                this._patched.apply(this, arguments);
                // calculate the update time (can't we use [dt] here ?)
                _this.frameUpdateTimeSamples.push(now() - startTime);
            });

            // patch me.game.draw
            me.plugin.patch(me.game, "draw", function () {
                var startTime = now();
                this._patched.apply(this, arguments);
                // calculate the drawing time
                _this.frameDrawTimeSamples.push(now() - startTime);
            });

            // patch me.ParticleContainer.update
            me.plugin.patch(me.ParticleContainer, "update", function (dt) {
                var startTime = now();
                var value = this._patched.apply(this, arguments);
                // calculate the update time (can't we use [dt] here ?)
                _this.updateTime += now() - startTime;
                return value;
            });

            // patch me.ParticleContainer.draw
            me.plugin.patch(me.ParticleContainer, "draw", function (renderer, rect) {
                var startTime = now();
                this._patched.apply(this, arguments);
                // calculate the drawing time
                _this.drawTime += now() - startTime;
            });
        },
{'fraction_non_alphanumeric': 0.11231547434706307, 'fraction_numerical': 0.006297099205120264, 'mean_word_length': 1.4415322580645162, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4314544', 'n_tokens_mistral': 2618, 'n_tokens_neox': 2433, 'n_words': 616}