Browse Source

CTRLBanksStore now has a getBankName() method which will return the name of the given bank if it's stored in the list, a getBank() method which will return the NESBank object under the given name (or null if no bank exists). Also has a new .keys property which is an array of all the current bank names in the store.

dev
Bryan Miller 5 years ago
parent
commit
671c2234e7
1 changed files with 20 additions and 0 deletions
  1. +20
    -0
      app/js/ctrls/CTRLBanksStore.js

+ 20
- 0
app/js/ctrls/CTRLBanksStore.js View File

@@ -194,6 +194,10 @@ class CTRLBanksStore{
return CurrentBank;
}

get keys(){
return Object.keys(Banks);
}

initialize(){
if (this.length <= 0){
this.createBank("Bank");
@@ -266,6 +270,22 @@ class CTRLBanksStore{
return this;
}

getBankName(b){
if (!(b instanceof NESBank))
throw new TypeError("Expected NESBank object.");
var keys = Object.keys(Banks);
for (let i=0; i < keys.length; i++){
if (Banks[keys[i]].bank.eq(b)){
return keys[i];
}
}
return null;
}

getBank(name){
return (name in Banks) ? Banks[name].bank : null;
}

clear(){
Object.keys(Banks).forEach((item) => {
Banks[item].el.parentNode.removeChild(Banks[item].el);

Loading…
Cancel
Save