A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
924B

  1. import GlobalEvents from "/app/js/common/EventCaller.js";
  2. function handle_emitter(event){
  3. if (this.hasAttribute("emit")){
  4. var args = [this.getAttribute("emit")];
  5. if (this.hasAttribute("emit-args")){
  6. try {
  7. var j = JSON.parse(this.getAttribute("emit-args"));
  8. if (j instanceof Array){
  9. args.concat(j);
  10. } else {
  11. args.push(j);
  12. }
  13. } catch (e) {
  14. console.log("Failed to emit '" + args[0] + "'. Attribute 'emit-args' contains malformed JSON.");
  15. }
  16. }
  17. GlobalEvents.emit.apply(GlobalEvents, args);
  18. }
  19. }
  20. export default {
  21. initialize: function(){
  22. var elist = document.querySelectorAll("[emit]");
  23. elist.forEach(function(el){
  24. el.addEventListener("click", handle_emitter);
  25. });
  26. },
  27. initialize_element: function(el){
  28. if (el.hasAttribute("emit")){
  29. el.addEventListener("click", handle_emitter);
  30. }
  31. }
  32. }