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文字以内のものにしてください。

154 行
3.6KB

  1. import GlobalEvents from "/app/js/common/EventCaller.js";
  2. import NESBank from "/app/js/models/NESBank.js";
  3. var ELCtrl = null;
  4. var ELSel = null;
  5. var ELLab = null;
  6. var ELOff = null;
  7. var SURF = null;
  8. function OpenControls(){
  9. if (ELCtrl !== null && SURF !== null){
  10. switch(SURF.access_mode){
  11. case NESBank.ACCESSMODE_8K:
  12. ELSel.value = "8K";
  13. ELLab.classList.add("hidden");
  14. break;
  15. case NESBank.ACCESSMODE_4K:
  16. ELSel.value = "4K"; break;
  17. case NESBank.ACCESSMODE_2K:
  18. ELSel.value = "2K"; break;
  19. case NESBank.ACCESSMODE_1K:
  20. ELSel.value = "1K"; break;
  21. break;
  22. case NESBank.ACCESSMODE_1T:
  23. ElSel.value = "1T"; break;
  24. }
  25. if (ELSel.value !== "8K"){
  26. ELLab.classList.remove("hidden");
  27. ELOff.setAttribute("max", SURF.access_offset_length - 1);
  28. ELOff.value = SURF.access_offset;
  29. //ELOff.setAttribute("value", SURF.access_offset);
  30. }
  31. ELCtrl.classList.remove("hidden");
  32. }
  33. }
  34. function CloseControls(){
  35. if (ELCtrl !== null){
  36. ELCtrl.classList.add("hidden");
  37. }
  38. }
  39. function HANDLE_SurfChange(surf){
  40. if (surf instanceof NESBank){
  41. SURF = surf;
  42. OpenControls();
  43. } else {
  44. SURF = null;
  45. CloseControls();
  46. }
  47. }
  48. function HANDLE_ModeChange(){
  49. if (ELCtrl !== null && SURF !== null){
  50. var val = this.options[this.selectedIndex].value;
  51. switch(val){
  52. case "8K":
  53. SURF.access_mode = NESBank.ACCESSMODE_8K;
  54. ELLab.classList.add("hidden");
  55. break;
  56. case "4K":
  57. SURF.access_mode = NESBank.ACCESSMODE_4K; break;
  58. case "2K":
  59. SURF.access_mode = NESBank.ACCESSMODE_2K; break;
  60. case "1K":
  61. SURF.access_mode = NESBank.ACCESSMODE_1K; break;
  62. case "1T":
  63. SURF.access_mode = NESBank.ACCESSMODE_1T; break;
  64. }
  65. if (SURF.access_mode !== NESBank.ACCESSMODE_8K){
  66. ELLab.classList.remove("hidden");
  67. //ELOff.setAttribute("value", SURF.access_offset);
  68. ELOff.setAttribute("max", SURF.access_offset_length - 1);
  69. ELOff.value = SURF.access_offset;
  70. }
  71. }
  72. }
  73. function HANDLE_OffsetChange(){
  74. if (ELCtrl !== null && SURF !== null){
  75. var val = parseInt(this.value);
  76. SURF.access_offset = val;
  77. }
  78. }
  79. class CTRLBankTools{
  80. constructor(){
  81. GlobalEvents.listen("change_surface", HANDLE_SurfChange);
  82. }
  83. close(){
  84. if (ELSel)
  85. ELSel.removeEventListener("change", HANDLE_ModeChange);
  86. if (ELOff)
  87. ELOff.removeEventListener("change", HANDLE_OffsetChange);
  88. if (ELCtrl)
  89. ELCtrl.classList.add("hidden");
  90. ELCTRL = null;
  91. ELSel = null;
  92. ELLab = null;
  93. ELOff = null;
  94. }
  95. initialize(){
  96. if (ELCtrl === null){
  97. ELCtrl = document.querySelector(".painter-bank-controls");
  98. if (!ELCtrl){
  99. console.log("ERROR: Failed to find 'painter-bank-controls' element");
  100. return;
  101. }
  102. ELSel = ELCtrl.querySelector(".painter-bank-mode");
  103. if (!ELSel){
  104. this.close();
  105. console.log("ERROR: Failed to find 'painter-bank-mode' element.");
  106. return;
  107. }
  108. ELLab = ELCtrl.querySelector(".painter-bank-offset");
  109. if (!ELLab){
  110. this.close();
  111. console.log("ERROR: Failed to find 'painter-bank-offset' element.");
  112. return;
  113. }
  114. ELOff = ELLab.querySelector("#offset-select");
  115. if (!ELOff){
  116. this.close();
  117. console.log("ERROR: Failed to find 'offset-select' element.");
  118. return;
  119. }
  120. ELSel.addEventListener("change", HANDLE_ModeChange);
  121. ELOff.addEventListener("change", HANDLE_OffsetChange);
  122. OpenControls();
  123. }
  124. }
  125. }
  126. const instance = new CTRLBankTools();
  127. export default instance;