A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import GlobalEvents from "/app/js/common/EventCaller.js";
  2. import Utils from "/app/js/common/Utils.js";
  3. import Input from "/app/js/ui/Input.js";
  4. class Modal{
  5. constructor(){
  6. this.__currentModalEl = null;
  7. window.addEventListener("click", (function(event){
  8. if (event.target === this.__currentModalEl){
  9. this.close_modal();
  10. }
  11. }).bind(this));
  12. GlobalEvents.listen("modal-open", (function(target, event){
  13. var force = (event.hasOwnProperty("force")) ? event.force === true : false;
  14. if (event.hasOwnProperty("id") && typeof(event.id) === 'string'){
  15. this.open_modal_id(event.id, force);
  16. } else if (event.hasOwnProperty("cls") && typeof(event.cls) === 'string'){
  17. this.open_modal_class(event.cls, force);
  18. }
  19. }).bind(this));
  20. GlobalEvents.listen("modal-close", (function(target, event){
  21. this.close_modal();
  22. }).bind(this));
  23. // TODO: Deprecate this mechanic. Let other controllers directly handle input.
  24. GlobalEvents.listen("modal-submit", (function(target, event){
  25. if (!event.hasOwnProperty("subevent"))
  26. return;
  27. var ename = event.subevent;
  28. var vals = {};
  29. if (event.hasOwnProperty("ids")){
  30. var ids = event.ids.split(",");
  31. var cel = this.__currentModalEl;
  32. ids.forEach((item) => {
  33. var id = item.trim();
  34. var el = cel.querySelector("[name='" + id + "']");
  35. if (el) // TODO: Check if el is an INPUT node and switch between the node types.
  36. vals[id] = el.value;
  37. });
  38. }
  39. GlobalEvents.emit(ename, vals);
  40. if (event.hasOwnProperty("closeoncomplete"))
  41. this.close_modal();
  42. }).bind(this));
  43. }
  44. get currentModalElement(){
  45. return this.__currentModalEl;
  46. }
  47. open_modal_id(idname, force=false){
  48. var el = document.getElementById(idname);
  49. /*if (el.classList.contains("modal") && this.__currentModalEl !== el){
  50. if (this.__currentModalEl !== null && force)
  51. this.close_modal();
  52. if (this.__currentModalEl === null){
  53. if (el){
  54. return this.open_modal_element(el);
  55. }
  56. }
  57. }*/
  58. return (el) ? this.open_modal_element(el, force) : this;
  59. }
  60. open_modal_class(clsname, force=false){
  61. var el = document.querySelector((clsname.indexOf(".") < 0) ? "." + clsname : clsname);
  62. return (el) ? this.open_modal_element(el, force) : this;
  63. }
  64. open_modal_element(el, force=false){
  65. if (Utils.isElement(el)){
  66. if (el.classList.contains("modal") && this.__currentModalEl !== el){
  67. if (this.__currentModalEl !== null && force)
  68. this.close_modal();
  69. if (this.__currentModalEl === null){
  70. el.classList.add("modal-visible");
  71. this.__currentModalEl = el;
  72. }
  73. }
  74. }
  75. return this;
  76. }
  77. close_modal(){
  78. if (this.__currentModalEl !== null){
  79. this.__currentModalEl.classList.remove("modal-visible");
  80. this.__currentModalEl = null;
  81. }
  82. return this;
  83. }
  84. }
  85. const instance = new Modal();
  86. export default instance;