From 9789d4e6233d4c1ad0b6c7000002abedfc99b21a Mon Sep 17 00:00:00 2001 From: Shawn Meyer Date: Thu, 6 Feb 2014 16:49:18 -0600 Subject: [PATCH] Issue #8 Fixing crafty debug bar broken reference. The Crafty Modules cdn for community code sharing was killed. Moved references to pull locally. --- app/index.js | 4 + app/templates/_index.html | 7 +- .../src/libs/CraftyDebug/_craftyDebug.js | 149 +++++++++ .../src/libs/CraftyDebug/panels/_assets.js | 47 +++ .../src/libs/CraftyDebug/panels/_entities.js | 303 ++++++++++++++++++ changelog.txt | 5 + package.json | 2 +- 7 files changed, 515 insertions(+), 2 deletions(-) create mode 100644 app/templates/src/libs/CraftyDebug/_craftyDebug.js create mode 100644 app/templates/src/libs/CraftyDebug/panels/_assets.js create mode 100644 app/templates/src/libs/CraftyDebug/panels/_entities.js diff --git a/app/index.js b/app/index.js index 80d6475..b8e9ab9 100644 --- a/app/index.js +++ b/app/index.js @@ -55,6 +55,10 @@ CraftyGenerator.prototype.projectfiles = function projectfiles() { this.copy('src/libs/crafty/_crafty.js', 'app/src/libs/crafty/crafty.js'); this.copy('src/libs/crafty/_crafty.min.js', 'app/src/libs/crafty/crafty.min.js'); + + this.copy('src/libs/craftydebug/_craftyDebug.js', 'app/src/libs/craftydebug/craftyDebug.js'); + this.copy('src/libs/craftydebug/panels/_assets.js', 'app/src/libs/craftydebug/panels/assets.js'); + this.copy('src/libs/craftydebug/panels/_entities.js', 'app/src/libs/craftydebug/panels/entities.js'); }; CraftyGenerator.prototype.gruntfileJSON = function gruntfile() { diff --git a/app/templates/_index.html b/app/templates/_index.html index 5f8ee57..518ced0 100755 --- a/app/templates/_index.html +++ b/app/templates/_index.html @@ -25,6 +25,11 @@ + + + + + diff --git a/app/templates/src/libs/CraftyDebug/_craftyDebug.js b/app/templates/src/libs/CraftyDebug/_craftyDebug.js new file mode 100644 index 0000000..5212279 --- /dev/null +++ b/app/templates/src/libs/CraftyDebug/_craftyDebug.js @@ -0,0 +1,149 @@ +Crafty.extend({ + /**@ + * #Crafty.debug + * @category Utilities + */ + debugBar : { + panels : {}, + template : { + panels : [], + styles : [], + panelBoxes : [] + }, + utils : {}, + renders : {}, + + init : function(){ + Crafty.debugBar.template.panels.push('
  • Crafty '+Crafty.getVersion()+'
  • '+ + '
  • Graph
  • '); + // '
    '+ + // '
  • Play
  • '+ + // '
  • Pause
  • '+ + // '
  • Frame
  • '+ + // '
    '+ + + Crafty.debugBar.template.styles.push('.clear {clear:both}\n'+ + '#crafty-debug {position: fixed;left: 0;right: 0;height: 35px;margin: 0;z-index: 6000000;font: 12px Verdana, Arial, sans-serif;text-align: left;color: #FFF;bottom: 0;border-top: 1px solid #BBB;background: #3e3e3e; background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSI2JSIgc3RvcC1jb2xvcj0iIzNlM2UzZSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjclIiBzdG9wLWNvbG9yPSIjMjgyODI4IiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iOTklIiBzdG9wLWNvbG9yPSIjMWYxZjFmIiBzdG9wLW9wYWNpdHk9IjEiLz4KICA8L2xpbmVhckdyYWRpZW50PgogIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9InVybCgjZ3JhZC11Y2dnLWdlbmVyYXRlZCkiIC8+Cjwvc3ZnPg==);background: -moz-linear-gradient(top, #3e3e3e 6%, #282828 7%, #1f1f1f 99%); background: -webkit-gradient(linear, left top, left bottom, color-stop(6%,#3e3e3e), color-stop(7%,#282828), color-stop(99%,#1f1f1f)); background: -webkit-linear-gradient(top, #3e3e3e 6%,#282828 7%,#1f1f1f 99%); background: -o-linear-gradient(top, #3e3e3e 6%,#282828 7%,#1f1f1f 99%); background: -ms-linear-gradient(top, #3e3e3e 6%,#282828 7%,#1f1f1f 99%); background: linear-gradient(top, #3e3e3e 6%,#282828 7%,#1f1f1f 99%);}\n'+ + '#crafty-debug ul.menu {list-style-type: none;padding: 0;margin: 0;}\n'+ + '#crafty-debug ul.menu li{display: inline-block;white-space: nowrap;color: #2F2F2F;min-height: 28px;padding: 0px;float: left;cursor: default;}\n'+ + '#crafty-debug ul.menu li:hover {box-shadow: rgba(0, 0, 0, 0.3) 0 0 5px;}\n'+ + '#crafty-debug ul.menu li a{padding: 4px 10px 9px 10px;color: #FFF; display:block; text-decoration: none}\n'+ + '#crafty-debug ul.menu li a img {float:left; padding-top: 4px;}\n'+ + '#crafty-debug ul.menu li a .text {float:left; padding-top: 8px;}\n'+ + '#crafty-debug ul.menu li.version{font-weight: bold; min-width: 110px;}\n'+ + '#crafty-debug ul.menu .separator {float:left;height:35px;width:2px;background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAAjCAYAAAC+Rtu3AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA01pVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE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pointer;float:right;width:10px; height:10px;}\n'+ + '#crafty-debug .panel-box {display:none}\n'+ + '#crafty-debug .panel-box .content .header {width: 100%;padding: 5px 0px 0px 10px;margin-bottom: 5px;float:left;color: #FFF; background: #282828; background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIyJSIgc3RvcC1jb2xvcj0iIzI4MjgyOCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMxZjFmMWYiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);background: -moz-linear-gradient(top, #282828 2%, #1f1f1f 100%); /* FF3.6+ */background: -webkit-gradient(linear, left top, left bottom, color-stop(2%,#282828), color-stop(100%,#1f1f1f)); /* Chrome,Safari4+ */background: -webkit-linear-gradient(top, #282828 2%,#1f1f1f 100%); /* Chrome10+,Safari5.1+ */background: -o-linear-gradient(top, #282828 2%,#1f1f1f 100%); /* Opera 11.10+ */background: -ms-linear-gradient(top, #282828 2%,#1f1f1f 100%); /* IE10+ */background: linear-gradient(top, #282828 2%,#1f1f1f 100%);/* IE6-8 */margin-bottom: 0px;margin-right: 0px;}\n'+ + '#crafty-debug .panel-box .content .header .separator{display: inline-block;height: 26px;width: 2px;background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAAaCAYAAACdM43SAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA01pVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoMTMuMCAyMDEyMDMwNS5tLjQxNSAyMDEyLzAzLzA1OjIxOjAwOjAwKSAgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjcyODM2RkFDQTM0QTExRTE5MkEyQzE5MjI3QUIyMEVEIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjcyODM2RkFEQTM0QTExRTE5MkEyQzE5MjI3QUIyMEVEIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NzI4MzZGQUFBMzRBMTFFMTkyQTJDMTkyMjdBQjIwRUQiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6NzI4MzZGQUJBMzRBMTFFMTkyQTJDMTkyMjdBQjIwRUQiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz6S54I8AAAAJ0lEQVR42mLYsWOH6v///1VZGBgYGIGYgYkBCoYHA+Sv/yAGQIABAP8oBqam0rxQAAAAAElFTkSuQmCC");margin-top: -5px;float: right}\n'+ + '#crafty-debug .panel-box .btn{width:120px; height:15px;}\n'+ + '#crafty-debug .panel-box .btn{text-align: center; color: #FFFFFF;padding:2px; margin:5px 0px; cursor:pointer;}\n'+ + '#crafty-debug .panel-box .btn-red{border:1px solid #b90707; background: #d54848; background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSI4JSIgc3RvcC1jb2xvcj0iI2Q1NDg0OCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjglIiBzdG9wLWNvbG9yPSIjY2UyMDIwIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iOTklIiBzdG9wLWNvbG9yPSIjY2EwZjBmIiBzdG9wLW9wYWNpdHk9IjEiLz4KICA8L2xpbmVhckdyYWRpZW50PgogIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9InVybCgjZ3JhZC11Y2dnLWdlbmVyYXRlZCkiIC8+Cjwvc3ZnPg==); background: -moz-linear-gradient(top, #d54848 8%, #ce2020 8%, #ca0f0f 99%); background: -webkit-gradient(linear, left top, left bottom, color-stop(8%,#d54848), color-stop(8%,#ce2020), color-stop(99%,#ca0f0f)); background: -webkit-linear-gradient(top, #d54848 8%,#ce2020 8%,#ca0f0f 99%); background: -o-linear-gradient(top, #d54848 8%,#ce2020 8%,#ca0f0f 99%); background: -ms-linear-gradient(top, #d54848 8%,#ce2020 8%,#ca0f0f 99%); background: linear-gradient(top, #d54848 8%,#ce2020 8%,#ca0f0f 99%);}\n'+ + '#crafty-debug .panel-box .btn-black{border:1px solid #000000; background: #505050; background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSI2JSIgc3RvcC1jb2xvcj0iIzUwNTA1MCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjYlIiBzdG9wLWNvbG9yPSIjMjcyNzI3IiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzIwMjAyMCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=); background: -moz-linear-gradient(top, #505050 6%, #272727 6%, #202020 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(6%,#505050), color-stop(6%,#272727), color-stop(100%,#202020)); background: -webkit-linear-gradient(top, #505050 6%,#272727 6%,#202020 100%); background: -o-linear-gradient(top, #505050 6%,#272727 6%,#202020 100%); background: -ms-linear-gradient(top, #505050 6%,#272727 6%,#202020 100%); background: linear-gradient(top, #505050 6%,#272727 6%,#202020 100%);}\n'+ + '#crafty-debug .panel-box .btn-black.off{border:1px solid #616161; background: #bebebe; background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSI3JSIgc3RvcC1jb2xvcj0iI2JlYmViZSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjclIiBzdG9wLWNvbG9yPSIjYWVhZWFlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2EzYTNhMyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=); background: -moz-linear-gradient(top, #bebebe 7%, #aeaeae 7%, #a3a3a3 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(7%,#bebebe), color-stop(7%,#aeaeae), color-stop(100%,#a3a3a3)); background: -webkit-linear-gradient(top, #bebebe 7%,#aeaeae 7%,#a3a3a3 100%); background: -o-linear-gradient(top, #bebebe 7%,#aeaeae 7%,#a3a3a3 100%); background: -ms-linear-gradient(top, #bebebe 7%,#aeaeae 7%,#a3a3a3 100%); background: linear-gradient(top, #bebebe 7+%,#aeaeae 7%,#a3a3a3 100%);}\n'); + + }, + + show : function(){ + this._generateTemplate(); + }, + + /** + * Register new DebugBar panel + * @param Object object Panel object + * @return Object Crafty.debugBar + * + * Carfty.debugBar.registerPanel({ + * 'name' : Entities, //Required + * 'image' : image/png;base64, //or false if don't exist + * 'description' : 'Game entities', + * 'styles' : '.clear {clear:both}', //css styles for panel + * 'panelBox' : 'html for panel details box' + * }); + */ + registerPanel: function(object) { + Crafty.debugBar.panels[object.name] = { + 'name' : object.name, + 'image' : object.image, + 'description' : object.description, + 'styles' : object.styles + } + + Crafty.debugBar._setPanel(object); + Crafty.debugBar._setStyles(object); + Crafty.debugBar._setPanelBox(object); + + + return this; + }, + + _setPanel: function(panel) { + var image = ''; + + if (typeof panel.image != 'undefined') { + image = ''; + } + + Crafty.debugBar.template.panels.push('
  • '+ + ''+ + image+ + '
    '+panel.name+'
    '+ + '
    '+ + '
    '+ + '
  • '+ + '
    '); + return this; + }, + + _setStyles: function(panel) { + if (typeof panel.styles != 'undefined') { + Crafty.debugBar.template.styles.push(panel.styles); + } + + return this; + }, + + /** + * proposed structure of panel.panelBox: + * + *
    + *
    + *
    + *
    + * PROPERTIES + *
    + *
    + *
    + *
    + *
    + *
    + */ + _setPanelBox : function(panel) { + if (typeof panel.panelBox != 'undefined') { + Crafty.debugBar.template.panelBoxes.push(panel.panelBox); + } + + return this; + }, + + _generateTemplate : function(){ + var styles, + template; + + styles = ''; + $('head').append(styles); + + template = '
    '+ + ''+ + Crafty.debugBar.template.panelBoxes.join('')+ + '
    '; + + $('body').append(template); + } + } +}); + +Crafty.debugBar.init(); \ No newline at end of file diff --git a/app/templates/src/libs/CraftyDebug/panels/_assets.js b/app/templates/src/libs/CraftyDebug/panels/_assets.js new file mode 100644 index 0000000..613112e --- /dev/null +++ b/app/templates/src/libs/CraftyDebug/panels/_assets.js @@ -0,0 +1,47 @@ +(function(){ + + var styles = '#crafty-debug #assets-box{position: fixed;left: 110px;bottom: 35px;height: 200px;border: 1px solid #2F2F2F;display: none;background-color: white;border-bottom: 0px;padding-right: 10px;}\n'+ + '#crafty-debug #assets-box .list{height: 165px;width: 200px; float:left}\n'+ + '#crafty-debug #assets-box .list ul{color: #2F2F2F; height: 150px;width: 195px;overflow-y: scroll;padding-left: 5px;list-style-type: none;padding-right: 10px;font-size: 11px;margin-top: 0px;padding-top: 5px;}\n'+ + '#crafty-debug #assets-box .list ul li a{padding: 3px 0px 3px 0px;border-bottom: 1px dashed #BBB;color: #2F2F2F; display:block; text-decoration: none}\n' + ; + var assetsBox = '
    '+ + '
    '+ + '
    '+ + '
    ASSETS
    '+ + '
      '+ + '
      '+ + '
      '+ + '
      '; + + /*********** Renders ***********/ + + Crafty.debugBar.renders['renderAssetsList'] = function(e) { + $('#crafty-debug #assets-box .list ul#assets-box-list').append('
    • '+e.key+'
    • '); + }; + + /*********** Events ***********/ + + $('#crafty-debug ul.menu li.assets').live('click',function(){ + if ($('#assets-box').is(':visible')) { + $('#assets-box').hide(); + } else { + $('.panel-box').hide(); + $('#assets-box').show(); + } + }); + + Crafty.bind('NewAsset', function(e){ + Crafty.debugBar.renders['renderAssetsList'](e); + }); + + /*********** Register Panel ***********/ + + Crafty.debugBar.registerPanel({ + 'name' : 'Assets', + 'description' : 'Game assets', + 'styles': styles, + 'panelBox' : assetsBox, + }); + +})(); \ No newline at end of file diff --git a/app/templates/src/libs/CraftyDebug/panels/_entities.js b/app/templates/src/libs/CraftyDebug/panels/_entities.js new file mode 100644 index 0000000..c253583 --- /dev/null +++ b/app/templates/src/libs/CraftyDebug/panels/_entities.js @@ -0,0 +1,303 @@ +(function(){ + + var styles = '#crafty-debug ul.menu li.entities img{padding: 6px 8px 8px 0px;}\n'+ + '#crafty-debug #entities-box{position: fixed;left: 110px;bottom: 35px;height: 200px;border: 1px solid #2F2F2F;display: none;background-color: white;border-bottom: 0px;padding-right: 10px;}\n'+ + '#crafty-debug #entities-box .list{height: 145px;width: 150px; float:left}\n'+ + '#crafty-debug #entities-box .list ul{height: 130px;width: 145px;overflow-y: scroll;padding-left: 5px;list-style-type: none;padding-right: 10px;font-size: 11px;margin-top: 0px;padding-top: 5px;}\n'+ + '#crafty-debug #entities-box .list ul li a{padding: 3px 0px 3px 0px;border-bottom: 1px dashed #BBB;color: #2F2F2F; display:block; text-decoration: none}\n'+ + '#crafty-debug #entities-box .list input.search{padding: 3px;width: 115px;margin: 5px auto 0px auto;font-size: 11px;display: block; border: 1px solid #BBB;}\n'+ + '#crafty-debug #entities-box .properties{height: 190px;width: 130px;float: left;margin-left: 10px;color: #282828;}\n'+ + '#crafty-debug #entities-box .properties .content{padding-left: 10px;}\n'+ + '#crafty-debug #entities-box .components{height: 190px;width: 130px;float: left;margin-left: 10px;color: #282828;}\n'+ + '#crafty-debug #entities-box .components .content{padding-left: 10px;}\n'+ + '#crafty-debug #entities-box .options{height: 190px;width: 130px;float: left;margin-left: 10px;color: #282828;}\n'+ + '#crafty-debug #entities-box .options .content{padding-left: 10px; padding-top: 30px;}\n'+ + '#crafty-debug #entities-box .properties .single label {display: block;width: 45px;float: left;padding-top: 6px;text-align: right;margin-right: 15px;font-weight:bold;}\n'+ + '#crafty-debug #entities-box .properties .single input{float:left; width: 50px; font-size: 11px;}\n'+ + '#crafty-debug #entities-box .components{height: 145px;width: 160px; float:left}\n'+ + '#crafty-debug #entities-box .components ul{height: 130px;width: 145px;overflow-y: scroll;padding-left: 5px;list-style-type: none;padding-right: 10px;font-size: 11px;margin-top: 0px;padding-top: 5px;}\n'+ + '#crafty-debug #entities-box .components ul li{border-bottom: 1px dashed #BBB;}\n'+ + '#crafty-debug #entities-box .components ul li a{float:left; padding: 3px 0px 3px 0px;color: #2F2F2F; display:block; text-decoration: none}\n'+ + '#crafty-debug #entities-box .components ul li a.remove {float:right; color: #b60d0d}\n'+ + '#crafty-debug #entities-box .components input.search{float:left;padding: 3px;width: 115px;margin: 5px auto 0px auto;font-size: 11px;display: block; border: 1px solid #BBB;}\n'+ + '#crafty-debug #entities-box .components .addComponent {padding: 8px 0px 8px 4px;float: left;cursor: pointer; margin-right:5px;}\n' + ; + var entitiesBox = '
      '+ + '
      '+ + '
      '+ + '
      ENTITIES
      '+ + '
        '+ + ''+ + '
        '+ + '
        '+ + '
        PROPERTIES
        '+ + '
        '+ + '
        '+ + '
        '+ + '
        COMPONENTS
        '+ + ''+ + '
        '+ + '
        '+ + '
        OPTIONS
        '+ + '
        '+ + '
        '+ + '
        '+ + '
        '; + + /*********** Utils ***********/ + + Crafty.debugBar.utils['listEntities'] = function (filter) { + if(filter == '') { + filter = '*'; + } + + var entities = [], + e, + isNumber = function(filter){return !isNaN(parseFloat(filter)) && isFinite(filter)}; + + isID = isNumber(filter); + + // Save ids of single or many components. + if (isID) { + e = Crafty(parseInt(filter)); + entities.push({ id: e[0], e: e }); + } else if (filter !== '*') { + var ids = Crafty(filter), count = 0; + for (i in ids) { + if (count++ < 50) { + if (!isNumber(i)) { + continue; + }; + e = Crafty(ids[i]); + entities.push({ id: e[0], e: e }); + } + } + } else if (filter == '*') { + var es = Crafty('*'), count = 0; + for (en in es) { + if (es.hasOwnProperty(en) && typeof es[en] == "object") { + e = es[en]; + if (count++ < 50) { + entities.push({ id: e[0], e: e }); + } + } + }; + } + + return entities; + }; + + Crafty.debugBar.utils['addEntityComponent'] = function(el) { + var component = $('#crafty-debug #entities-box .components input.search').val(), + entity = $(el).data('entityId'); + + Crafty(entity).addComponent(component); + component = $('#crafty-debug #entities-box .components input.search').val(''); + Crafty.debugBar.renders.renderEntityComponents(Crafty(entity)); + }; + + Crafty.debugBar.utils['elementToTypedValue'] = function (element) { + if (element.data('type') == "number") { + return parseFloat(element.val()); + } else { + return element.val(); + } + }; + + /*********** Renders ***********/ + + Crafty.debugBar.renders['renderEntityDetails'] = function(entity) { + Crafty.debugBar.renders.renderEntityAttributes(entity); + Crafty.debugBar.renders.renderEntityComponents(entity); + Crafty.debugBar.renders.renderEntityOptions(entity); + }; + + Crafty.debugBar.renders['renderEntitesList'] = function(listEntities) { + var elements = []; + + if (listEntities.length == 0){ + return '

        No results

        '; + } + + for (i in listEntities) { + elements.push('
      • '+listEntities[i].e._entityName+'
      • '); + } + return elements.join(''); + }; + + Crafty.debugBar.renders['renderEntityAttributes'] = function(entity) { + var template = '
        '+ + '
        '+ + '
        '+ + '
        '+ + '
        '+ + '
        '+ + '
        '+ + '
        '+ + '
        '; + + $('#crafty-debug #entities-box .properties .content').html(template).show(); + }; + + Crafty.debugBar.renders['renderEntityComponents'] = function(entity) { + var components = []; + //var avaiableComponents = Crafty.components(); + var entityComponents = entity.__c; + + for (i in entityComponents) { + components.push('
      • '+i+'x
      • '); + } + + $('#entities-box .content .components .addComponent').data('entityId', entity[0]); + $('#entities-box .content .components .content').show(); + $('#entities-box .content .components .content #components-box-list').html(components.join('')); + }; + + Crafty.debugBar.renders['renderEntityOptions'] = function(entity){ + var template = '
        '+ + '
        draggable '+(entity.__c.draggable ? 'off' : 'on')+'
        '+ + '
        '+ (entity.visible ? 'hide' : 'show')+'
        '+ + '
        print to console
        '+ + '
        WiredHitBox '+(entity.__c.WiredHitBox ? 'off' : 'on') +'
        '+ + '
        remove
        '+ + '
        '; + + $('#crafty-debug #entities-box .options .content').html(template).show(); + }; + + /*********** Events ***********/ + + $('#entities-search').live('keyup',function(){ + $('#entities-box-list').html(Crafty.debugBar.renders.renderEntitesList(Crafty.debugBar.utils.listEntities($(this).val()))); + }); + + $('#crafty-debug ul.menu li.entities').live('click',function(){ + if ($('#entities-box').is(':visible')) { + $('#entities-box').hide(); + $('#entities-box .options .content').hide(); + } else { + $('.panel-box').hide(); + $('#entities-box').show(); + $('#entities-box-list').html(Crafty.debugBar.renders.renderEntitesList(Crafty.debugBar.utils.listEntities('*'))); + $('#entities-box .options .content').show(); + } + }); + + $('#crafty-debug #entities-box .list ul li a').live('click', function(){ + Crafty.debugBar.renders.renderEntityDetails(Crafty($(this).data('ent'))); + }); + + $('#crafty-debug #entities-box .components ul li a.remove').live('click', function(){ + var component = $(this).data('comp'), + entity = $(this).data('entityId'); + Crafty(entity).removeComponent(component, false); + Crafty.debugBar.renders.renderEntityComponents(Crafty(entity)); + }); + + /* Components mangement */ + $('#crafty-debug #entities-box .components .addComponent').live('click', function(){ + Crafty.debugBar.utils.addEntityComponent(this); + }); + + $('#crafty-debug #entities-box .components input.search').live('keypress', function(event) { + if ( event.which == 13 ) { + event.preventDefault(); + Crafty.debugBar.utils.addEntityComponent($('#crafty-debug #entities-box .components .addComponent')); + } + }); + + /* Attributes mangement */ + $('#crafty-debug #entities-box .properties .content input').live('keyup', function(){ + var attr = $(this).attr('name'), + entity = $(this).parent().parent(); + + Crafty(entity.data('ent')).attr(attr, Crafty.debugBar.utils.elementToTypedValue($(this))); + }); + + /* Options mangement */ + $('#crafty-debug #entities-box .options .visible').live('click', function(){ + var id = $(this).parent().data('ent'), + entity = Crafty(id), + btn = $(this); + + if (btn.hasClass('off')){ + entity.visible = true; + btn.removeClass('off'); + btn.html('hide'); + } else { + entity.visible = false; + btn.addClass('off'); + btn.html('show'); + } + }); + + $('#crafty-debug #entities-box .options .draggable').live('click', function(){ + var id = $(this).parent().data('ent'), + entity = Crafty(id), + btn = $(this); + + if (btn.hasClass('off')){ + entity.removeComponent('Draggable', false); + btn.removeClass('off'); + btn.html('draggable on'); + entity.unbind('Dragging'); + } else { + entity.addComponent('Draggable'); + btn.addClass('off'); + btn.html('draggable off'); + + entity.bind('Dragging', function(e) { + Crafty.debugBar.renders.renderEntityAttributes(entity); + }) + } + + Crafty.debugBar.renders.renderEntityComponents(entity); + }); + + $('#crafty-debug #entities-box .options .hitBox').live('click', function(){ + var id = $(this).parent().data('ent'), + entity = Crafty(id), + btn = $(this); + + if (btn.hasClass('off')){ + entity.removeComponent('WiredHitBox', false); + btn.removeClass('off'); + btn.html('WiredHitBox on'); + } else { + entity.addComponent('WiredHitBox'); + btn.addClass('off'); + btn.html('WiredHitBox off'); + } + + Crafty.debugBar.renders.renderEntityComponents(entity); + }); + + $('#crafty-debug #entities-box .options .console').live('click', function(){ + var entity = $(this).parent().data('ent'); + console.log(Crafty(entity)); + }); + + $('#crafty-debug #entities-box .options .remove').live('click', function(){ + var entity = $(this).parent().data('ent'); + Crafty(entity).destroy(); + + $('#entities-box-list').html(Crafty.debugBar.renders.renderEntitesList(Crafty.debugBar.utils.listEntities('*'))); + $('#crafty-debug #entities-box .properties .content').hide(); + $('#crafty-debug #entities-box .options .content').hide(); + $('#crafty-debug #entities-box .components .content').hide(); + }); + + /*********** Register Panel ***********/ + + Crafty.debugBar.registerPanel({ + 'name' : 'Entities', + 'image' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA01pVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6e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//or false if don't exist + 'description' : 'Game entities', + 'styles': styles, + 'panelBox' : entitiesBox, + }); + +})(); \ No newline at end of file diff --git a/changelog.txt b/changelog.txt index ec27477..cc69d4f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +v0.2.0 - 02-06-2014 + +* Removing the use of Crafty.modules as the community module page has been sunsetted. +* Referenced local copies of CraftyDebug.js. + v0.1.3 - 10-18-2013 * Fixing typo in minification packaging. diff --git a/package.json b/package.json index 25c75a1..2a6c808 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "generator-crafty", - "version": "0.1.3", + "version": "0.2.0", "description": "A Crafty.js generator for Yeoman. Provides Craft.js scaffolding based on CraftyBoilerplate (https://github.com/ahilles107/CraftyBoilerplate)", "keywords": [ "yeoman-generator",