A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

65 lines
1.7KB

  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. super.listen(eventName, callback, owner, once);
  23. return this;
  24. }
  25. throw new ValueError("Window object has no event named '" + eventName +"'.");
  26. }
  27. unlisten(eventName, callback, owner=null){
  28. if (window.hasOwnProperty(eventName)){
  29. super.unlisten(eventName, callback, owner);
  30. if (super.event_listener_count(eventName) == 0){
  31. window[eventName] = undefined;
  32. }
  33. }
  34. return this;
  35. }
  36. unlisten_event(eventName){
  37. if (window.hasOwnProperty(eventName)){
  38. super.unlisten_event(eventName);
  39. window[eventName] = undefined;
  40. }
  41. return this;
  42. }
  43. unlisten_all(){
  44. var we = this.watchedEvents;
  45. super.unlisten_all();
  46. for (var i=0; i < we.length; i++){
  47. if (window.hasOwnProperty(we[i])){
  48. window[we[i]] = undefined;
  49. }
  50. }
  51. return this;
  52. }
  53. }
  54. const instance = new EventWindow();
  55. Object.freeze(instance);
  56. export default instance;