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.

56 lines
1.5KB

  1. import '/app/js/EventCaller.js'
  2. /**
  3. * Wraps the browser's window object around the EventCaller allowing the user to connect to system events
  4. * by listening for those events (ex: "onclick", "onresize", etc).
  5. *
  6. * Users should not directly set the window event handler functions if using this class.
  7. */
  8. export class EventWindow extends EventCaller{
  9. constructor(){
  10. super();
  11. }
  12. listen(eventName, callback, owner=null, once=false){
  13. if (window.hasOwnProperty(eventName)){
  14. if (window[eventName] === null || typeof(window[eventName]) === 'undefined'){
  15. window[eventName] = (function(event){
  16. this.emit(eventName, event);
  17. }).bind(this);
  18. }
  19. super.listen(eventName, callback, owner, once);
  20. return this;
  21. }
  22. throw new ValueError("Window object has no event named '" + eventName +"'.");
  23. }
  24. unlisten(eventName, callback, owner=null){
  25. if (window.hasOwnProperty(eventName)){
  26. super.unlisten(eventName, callback, owner);
  27. if (super.event_listener_count(eventName) == 0){
  28. window[eventName] = undefined;
  29. }
  30. }
  31. return this;
  32. }
  33. unlisten_event(eventName){
  34. if (window.hasOwnProperty(eventName)){
  35. super.unlisten_event(eventName);
  36. window[eventName] = undefined;
  37. }
  38. return this;
  39. }
  40. unlisten_all(){
  41. var we = this.watchedEvents;
  42. super.unlisten_all();
  43. for (var i=0; i < we.length; i++){
  44. if (window.hasOwnProperty(we[i])){
  45. window[we[i]] = undefined;
  46. }
  47. }
  48. return this;
  49. }
  50. }