()
| 5853 | this.elements.cheatRows = rows; |
| 5854 | } |
| 5855 | updateCheatUI() { |
| 5856 | if (!this.gameManager) return; |
| 5857 | this.elements.cheatRows.innerHTML = ""; |
| 5858 | |
| 5859 | const addToMenu = (desc, checked, code, is_permanent, i) => { |
| 5860 | const row = this.createElement("div"); |
| 5861 | row.classList.add("ejs_cheat_row"); |
| 5862 | const input = this.createElement("input"); |
| 5863 | input.type = "checkbox"; |
| 5864 | input.checked = checked; |
| 5865 | input.value = i; |
| 5866 | input.id = "ejs_cheat_switch_" + i; |
| 5867 | row.appendChild(input); |
| 5868 | const label = this.createElement("label"); |
| 5869 | label.for = "ejs_cheat_switch_" + i; |
| 5870 | label.innerText = desc; |
| 5871 | row.appendChild(label); |
| 5872 | label.addEventListener("click", (e) => { |
| 5873 | input.checked = !input.checked; |
| 5874 | this.cheats[i].checked = input.checked; |
| 5875 | this.cheatChanged(input.checked, code, i); |
| 5876 | this.saveSettings(); |
| 5877 | }) |
| 5878 | if (!is_permanent) { |
| 5879 | const close = this.createElement("a"); |
| 5880 | close.classList.add("ejs_cheat_row_button"); |
| 5881 | close.innerText = "×"; |
| 5882 | row.appendChild(close); |
| 5883 | close.addEventListener("click", (e) => { |
| 5884 | this.cheatChanged(false, code, i); |
| 5885 | this.cheats.splice(i, 1); |
| 5886 | this.updateCheatUI(); |
| 5887 | this.saveSettings(); |
| 5888 | }) |
| 5889 | } |
| 5890 | this.elements.cheatRows.appendChild(row); |
| 5891 | this.cheatChanged(checked, code, i); |
| 5892 | } |
| 5893 | this.gameManager.resetCheat(); |
| 5894 | for (let i = 0; i < this.cheats.length; i++) { |
| 5895 | addToMenu(this.cheats[i].desc, this.cheats[i].checked, this.cheats[i].code, this.cheats[i].is_permanent, i); |
| 5896 | } |
| 5897 | } |
| 5898 | cheatChanged(checked, code, index) { |
| 5899 | if (!this.gameManager) return; |
| 5900 | this.gameManager.setCheat(index, checked, code); |
no test coverage detected