A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

64 lines
1.6KB

  1. import {EventCaller} from '/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. class EventWindow extends EventCaller{
  9. constructor(){
  10. super();
  11. if (!EventWindow.instance)
  12. EventWindow.instance = this;
  13. return EventWindow.instance;
  14. }
  15. listen(eventName, callback, owner=null, once=false){
  16. if (window.hasOwnProperty(eventName)){
  17. if (window[eventName] === null || typeof(window[eventName]) === 'undefined'){
  18. window[eventName] = (function(event){
  19. this.emit(eventName, event);
  20. }).bind(this);
  21. }
  22. }
  23. super.listen(eventName, callback, owner, once);
  24. return this;
  25. }
  26. unlisten(eventName, callback, owner=null){
  27. super.unlisten(eventName, callback, owner);
  28. if (window.hasOwnProperty(eventName)){
  29. if (super.event_listener_count(eventName) == 0){
  30. window[eventName] = undefined;
  31. }
  32. }
  33. return this;
  34. }
  35. unlisten_event(eventName){
  36. super.unlisten_event(eventName);
  37. if (window.hasOwnProperty(eventName)){
  38. window[eventName] = undefined;
  39. }
  40. return this;
  41. }
  42. unlisten_all(){
  43. var we = this.watchedEvents;
  44. super.unlisten_all();
  45. for (var i=0; i < we.length; i++){
  46. if (window.hasOwnProperty(we[i])){
  47. window[we[i]] = undefined;
  48. }
  49. }
  50. return this;
  51. }
  52. }
  53. const instance = new EventWindow();
  54. Object.freeze(instance);
  55. export default instance;