mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
Reformat sfx.core.js with tabs instead of spaces
This commit is contained in:
parent
8e466fedf4
commit
681de1d5e7
@ -1 +1 @@
|
|||||||
Subproject commit ff38d45b9686ccbd2e902477bde4cd7eb7d251e8
|
Subproject commit 57d8b4bed14b0b35d1d9753847ac39710e0d9be5
|
@ -21,7 +21,7 @@ export default class SFXCore extends Core {
|
|||||||
this.play("test", {
|
this.play("test", {
|
||||||
volume: volume / 100,
|
volume: volume / 100,
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadSoundpack(soundpack) {
|
async loadSoundpack(soundpack) {
|
||||||
@ -34,7 +34,7 @@ export default class SFXCore extends Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if is valid url with regex
|
// check if is valid url with regex
|
||||||
const urlRegex = /^(http|https):\/\/[^ "]+$/;
|
const urlRegex = /^(http|https):\/\/[^ "]+$/
|
||||||
|
|
||||||
if (urlRegex.test(soundpack)) {
|
if (urlRegex.test(soundpack)) {
|
||||||
const { data } = await axios.get(soundpack)
|
const { data } = await axios.get(soundpack)
|
||||||
@ -43,11 +43,15 @@ export default class SFXCore extends Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof soundpack.sounds !== "object") {
|
if (typeof soundpack.sounds !== "object") {
|
||||||
this.console.error(`Soundpack [${soundpack.id}] is not a valid soundpack.`)
|
this.console.error(
|
||||||
|
`Soundpack [${soundpack.id}] is not a valid soundpack.`,
|
||||||
|
)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
this.console.log(`Loading soundpack [${soundpack.id} | ${soundpack.name}] by ${soundpack.author} (${soundpack.version})`)
|
this.console.log(
|
||||||
|
`Loading soundpack [${soundpack.id} | ${soundpack.name}] by ${soundpack.author} (${soundpack.version})`,
|
||||||
|
)
|
||||||
|
|
||||||
for (const [name, path] of Object.entries(soundpack.sounds)) {
|
for (const [name, path] of Object.entries(soundpack.sounds)) {
|
||||||
this.soundsPool[name] = new Howl({
|
this.soundsPool[name] = new Howl({
|
||||||
@ -71,7 +75,9 @@ export default class SFXCore extends Core {
|
|||||||
if (typeof options.volume !== "undefined") {
|
if (typeof options.volume !== "undefined") {
|
||||||
audioInstance.volume(options.volume)
|
audioInstance.volume(options.volume)
|
||||||
} else {
|
} else {
|
||||||
audioInstance.volume((window.app.cores.settings.get("ui.general_volume") ?? 0) / 100)
|
audioInstance.volume(
|
||||||
|
(window.app.cores.settings.get("ui.general_volume") ?? 0) / 100,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
audioInstance.play()
|
audioInstance.play()
|
||||||
@ -79,7 +85,8 @@ export default class SFXCore extends Core {
|
|||||||
|
|
||||||
async handleClick(event) {
|
async handleClick(event) {
|
||||||
// search for closest button
|
// search for closest button
|
||||||
const button = event.target.closest("button") || event.target.closest(".ant-btn")
|
const button =
|
||||||
|
event.target.closest("button") || event.target.closest(".ant-btn")
|
||||||
|
|
||||||
// search for a slider
|
// search for a slider
|
||||||
const slider = event.target.closest("input[type=range]")
|
const slider = event.target.closest("input[type=range]")
|
||||||
@ -87,7 +94,11 @@ export default class SFXCore extends Core {
|
|||||||
// if button exist and has aria-checked attribute then play switch_on or switch_off
|
// if button exist and has aria-checked attribute then play switch_on or switch_off
|
||||||
if (button) {
|
if (button) {
|
||||||
if (button.hasAttribute("aria-checked")) {
|
if (button.hasAttribute("aria-checked")) {
|
||||||
return this.play(button.getAttribute("aria-checked") === "true" ? "component.switch_off" : "component.switch_on")
|
return this.play(
|
||||||
|
button.getAttribute("aria-checked") === "true"
|
||||||
|
? "component.switch_off"
|
||||||
|
: "component.switch_on",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.play("generic_click")
|
return this.play("generic_click")
|
||||||
@ -102,6 +113,12 @@ export default class SFXCore extends Core {
|
|||||||
async onInitialize() {
|
async onInitialize() {
|
||||||
await this.loadSoundpack()
|
await this.loadSoundpack()
|
||||||
|
|
||||||
document.addEventListener("click", (...args) => { this.handleClick(...args) }, true)
|
document.addEventListener(
|
||||||
|
"click",
|
||||||
|
(...args) => {
|
||||||
|
this.handleClick(...args)
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user