浏览代码

Can now switch between the sprite and tile palettes

dev
Bryan Miller 6 年前
父节点
当前提交
10172b3a19
共有 2 个文件被更改,包括 26 次插入3 次删除
  1. +19
    -2
      app/js/ctrls/CTRLPalettes.js
  2. +7
    -1
      views/paldraw.html

+ 19
- 2
app/js/ctrls/CTRLPalettes.js 查看文件

const ATTRIB_COLIDX = "cidx"; // This is the color index in the selected palette (0 - 3) const ATTRIB_COLIDX = "cidx"; // This is the color index in the selected palette (0 - 3)


const CLASS_BTN_ACTIVE = "pure-button-active"; const CLASS_BTN_ACTIVE = "pure-button-active";
const SELECT_ID_PALETTEMODE = "palette-mode";


var Active_Palette_Index = 0; var Active_Palette_Index = 0;
var Active_Color_Index = 0; var Active_Color_Index = 0;
if (idx >= 0 && idx < NESPalette.SystemColor.length){ if (idx >= 0 && idx < NESPalette.SystemColor.length){
var i = GetPaletteIndexes(self.__activePaletteEl); var i = GetPaletteIndexes(self.__activePaletteEl);
if (self.__palette !== null && i !== null){ if (self.__palette !== null && i !== null){
self.__NESPalette.set_palette_syscolor_index(i.pi, i.ci, idx);
self.__NESPalette.set_palette_syscolor_index(i.pi + ((self.__mode === 1) ? 4 : 0), i.ci, idx);
SetPaletteElStyle(self.__activePaletteEl, NESPalette.SystemColor[idx]); SetPaletteElStyle(self.__activePaletteEl, NESPalette.SystemColor[idx]);
} }
} }
} }
}); });



// ------------------------------------------------------------------------------------
// Defining hooks for palette mode swapping
// ------------------------------------------------------------------------------------
var el = document.querySelector("#" + SELECT_ID_PALETTEMODE);
if (el){
el.addEventListener("change", function(event){
switch(this.value){
case "sprite":
self.__mode = 1; break;
case "tile":
self.__mode = 0; break;
}
SetColorPaletteEls(self.__mode, self.__NESPalette);
});
}

// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
// Setting some hooks to watch for some global events. // Setting some hooks to watch for some global events.
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------

+ 7
- 1
views/paldraw.html 查看文件

<div class="pure-u-1-2"> <div class="pure-u-1-2">
<div class-"simple-padding"> <div class-"simple-padding">
Drawing Palettes
<label for="palette-mode">
Drawing Palettes
</label>
<select id="palette-mode">
<option value="sprite">Sprite Palettes</option>
<option value="tile" selected>Tile Palettes</option>
</select>
</div> </div>
<div class="pure-g"> <div class="pure-g">
<% for(var i=0; i < numpalettes; i++){ %> <% for(var i=0; i < numpalettes; i++){ %>

正在加载...
取消
保存