Browse Source

Readded GlobalEvents to CTRLPalettes HA!

dev-tmpl
Bryan Miller 6 years ago
parent
commit
c3e3161bf2
1 changed files with 17 additions and 0 deletions
  1. +17
    -0
      app/js/ui/CTRLPalettes.js

+ 17
- 0
app/js/ui/CTRLPalettes.js View File

import GlobalEvents from "/app/js/EventCaller.js";
import {NESPalette} from "/app/js/NESPalette.js"; import {NESPalette} from "/app/js/NESPalette.js";


const ATTRIB_NESIDX = "nesidx"; const ATTRIB_NESIDX = "nesidx";


var self = this; var self = this;


// ------------------------------------------------------------------------------------
// Defining hooks for the main system palette interactions.
// ------------------------------------------------------------------------------------
var handle_syspalette_clicked = function(event){ var handle_syspalette_clicked = function(event){
if (self.__activePaletteEl !== null && this.hasAttribute(ATTRIB_NESIDX)){ if (self.__activePaletteEl !== null && this.hasAttribute(ATTRIB_NESIDX)){
var idx = parseInt(this.getAttribute(ATTRIB_NESIDX), 16); var idx = parseInt(this.getAttribute(ATTRIB_NESIDX), 16);
}); });




// ------------------------------------------------------------------------------------
// Defining hooks for the drawing palette interactions.
// ------------------------------------------------------------------------------------
var handle_palcolor_clicked = function(event){ var handle_palcolor_clicked = function(event){
if (this.hasAttribute(ATTRIB_PALIDX) && this.hasAttribute(ATTRIB_COLIDX)){ if (this.hasAttribute(ATTRIB_PALIDX) && this.hasAttribute(ATTRIB_COLIDX)){
if (this !== self.__activePaletteEl){ if (this !== self.__activePaletteEl){
el.addEventListener("click", handle_palcolor_clicked); el.addEventListener("click", handle_palcolor_clicked);
} }
}); });

// ------------------------------------------------------------------------------------
// Setting some hooks to watch for some global events.
// ------------------------------------------------------------------------------------
var handle_set_app_palette(p){
if (p instanceof NESPalette){
self.palette = p;
}
}
GlobalEvents.listen("set_app_palette", handle_syspalette_changed);
} }


get palette(){ get palette(){

Loading…
Cancel
Save