<commit_before>/*
 * MelonJS Game Engine
 * Copyright (C) 2011 - 2013, <NAME>
 * http://www.melonjs.org
 *
 * a simple debug panel plugin
 * usage : me.plugin.register(debugPanel, "debug");
 *
 * you can then use me.plugin.debug.show() or me.plugin.debug.hide() 
 * to show or hide the panel, or press respectively the "S" and "H" keys.
 * 
 * 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 || {};
	
	/**
	 * @class
	 * @public
	 * @extends me.plugin.Base
	 * @memberOf me
	 * @constructor
	 */
	debugPanel = me.plugin.Base.extend(
	/** @scope me.debug.Panel.prototype */
	{

		// Object "Game Unique Identifier"
		GUID : null,

		// to hold the debug options 
		// clickable rect area
		area : {},
		
		// panel position and size
		rect : null,
		
		// for z ordering
		// make it ridiculously high
		z : Infinity,
		
		// visibility flag
		visible : false,
		
		// minimum melonJS version expected
		version : "1.0.0",

		/** @private */
		init : function(showKey, hideKey) {
			// call the parent constructor
			this.parent();
			
			this.rect = new me.Rect(new me.Vector2d(0, 0), me.video.getWidth(), 35);
			
			// set the object GUID value
			this.GUID = "debug-" + me.utils.createGUID();

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

			// persistent
			this.isPersistent = true;

			// a floating object
			this.floating = true;

			// renderable
			this.isRenderable = 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');

			// clickable areas
			this.area.renderHitBox = new me.Rect(new me.Vector2d(160,5),15,15);
			this.area.renderVelocity = new me.Rect(new me.Vector2d(165,18),15,15);

			this.area.renderDirty = new me.Rect(new me.Vector2d(270,5),15,15);
			this.area.renderCollisionMap = new me.Rect(new me.Vector2d(270,18),15,15);

			// some internal string/length
			this.help_str	  = "(s)how/(h)ide";
			this.help_str_len = this.font.measureText(me.video.getSystemContext(), this.help_str).width;
			this.fps_str_len = this.font.measureText(me.video.getSystemContext(), "00/00 fps").width;

			// enable the FPS counter
			me.debug.displayFPS = true;

			// bind the "S" and "H" keys
			me.input.bindKey(showKey || me.input.KEY.S, "show");
			me.input.bindKey(hideKey || me.input.KEY.H, "hide");

			// memory heap sample points
			this.samples = [];

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

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

			// make it visible
			this.show();
		},


		/**
		 * patch system fn to draw debug information
		 */
		patchSystemFn : function() {

			// add a few new debug flag (if not yet defined)
			me.debug.renderHitBox = me.debug.renderHitBox || false;
			me.debug.renderVelocity = me.debug.renderVelocity || false;
			var _this = this;
			// patch timer.js
			me.plugin.patch(me.timer, "update", function (time) {
				// call the original me.timer.update function
				this.parent(time);

				// call the FPS counter
				me.timer.countFPS();
			});

			// patch sprite.js
			me.plugin.patch(me.SpriteObject, "draw", function (context) { 
				// call the original me.game.draw function
				this.parent(context);

				// draw the sprite rectangle
				if (me.debug.renderHitBox) {
					context.strokeStyle =  "green";
					context.strokeRect(this.left, this.top, this.width, this.height);
				}
			});

			// patch state.js
			me.plugin.patch(me.ScreenObject, 'onUpdateFrame', function(time) {
				if ((++this.frame%this.frameRate)===0) {
					var frameUpdateStartTime = me.timer.getTime();
					// reset the frame counter
					this.frame = 0;

					// update the timer
					me.timer.update(time);

					// update all games object
					me.game.update(time);
					_this.frameUpdateTime = me.timer.getTime() - frameUpdateStartTime;
				}<commit_msg>[debug] fixed the update time in the debug panel<commit_after>/*
 * MelonJS Game Engine
 * Copyright (C) 2011 - 2013, <NAME>
 * http://www.melonjs.org
 *
 * a simple debug panel plugin
 * usage : me.plugin.register(debugPanel, "debug");
 *
 * you can then use me.plugin.debug.show() or me.plugin.debug.hide() 
 * to show or hide the panel, or press respectively the "S" and "H" keys.
 * 
 * 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 || {};
	
	/**
	 * @class
	 * @public
	 * @extends me.plugin.Base
	 * @memberOf me
	 * @constructor
	 */
	debugPanel = me.plugin.Base.extend(
	/** @scope me.debug.Panel.prototype */
	{

		// Object "Game Unique Identifier"
		GUID : null,

		// to hold the debug options 
		// clickable rect area
		area : {},
		
		// panel position and size
		rect : null,
		
		// for z ordering
		// make it ridiculously high
		z : Infinity,
		
		// visibility flag
		visible : false,
		
		// minimum melonJS version expected
		version : "1.0.0",

		/** @private */
		init : function(showKey, hideKey) {
			// call the parent constructor
			this.parent();
			
			this.rect = new me.Rect(new me.Vector2d(0, 0), me.video.getWidth(), 35);
			
			// set the object GUID value
			this.GUID = "debug-" + me.utils.createGUID();

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

			// persistent
			this.isPersistent = true;

			// a floating object
			this.floating = true;

			// renderable
			this.isRenderable = 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');

			// clickable areas
			this.area.renderHitBox = new me.Rect(new me.Vector2d(160,5),15,15);
			this.area.renderVelocity = new me.Rect(new me.Vector2d(165,18),15,15);

			this.area.renderDirty = new me.Rect(new me.Vector2d(270,5),15,15);
			this.area.renderCollisionMap = new me.Rect(new me.Vector2d(270,18),15,15);

			// some internal string/length
			this.help_str	  = "(s)how/(h)ide";
			this.help_str_len = this.font.measureText(me.video.getSystemContext(), this.help_str).width;
			this.fps_str_len = this.font.measureText(me.video.getSystemContext(), "00/00 fps").width;

			// enable the FPS counter
			me.debug.displayFPS = true;

			// bind the "S" and "H" keys
			me.input.bindKey(showKey || me.input.KEY.S, "show");
			me.input.bindKey(hideKey || me.input.KEY.H, "hide");

			// memory heap sample points
			this.samples = [];

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

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

			// make it visible
			this.show();
		},


		/**
		 * patch system fn to draw debug information
		 */
		patchSystemFn : function() {

			// add a few new debug flag (if not yet defined)
			me.debug.renderHitBox = me.debug.renderHitBox || false;
			me.debug.renderVelocity = me.debug.renderVelocity || false;
			var _this = this;
			// patch timer.js
			me.plugin.patch(me.timer, "update", function (time) {
				// call the original me.timer.update function
				this.parent(time);

				// call the FPS counter
				me.timer.countFPS();
			});

			// patch sprite.js
			me.plugin.patch(me.SpriteObject, "draw", function (context) { 
				// call the original me.game.draw function
				this.parent(context);

				// draw the sprite rectangle
				if (me.debug.renderHitBox) {
					context.strokeStyle =  "green";
					context.strokeRect(this.left, this.top, this.width, this.height);
				}
			});

			// patch state.js
			me.plugin.patch(me.ScreenObject, 'onUpdateFrame', function(time) {
				if ((++this.frame%this.frameRate)===0) {
					var frameUpdateStartTime = Date.now();
					// reset the frame counter
					this.frame = 0;
					
					// update the timer
					me.timer.update(time);

					// update all games object
					me.game.update(time);

					// calculate the update time
					_this.frameUpdateTime = Date.now() - frameUpdateStartTime;
				}
{'fraction_non_alphanumeric': 0.14136959451182163, 'fraction_numerical': 0.015190493691044958, 'mean_word_length': 2.7261524418073937, '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': '5295656', 'n_tokens_mistral': 3236, 'n_tokens_neox': 2640, 'n_words': 700}