optionsui.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import gsap from "gsap"
  2. import { closeMainMenuUI, openMainMenuUI } from "./mainmenuui"
  3. export function optionsUI(game, stageData) {
  4. document.getElementById("options-container").addEventListener('click', () => {
  5. hideOptionsUI(game, stageData)
  6. })
  7. document.getElementById("options-panel").addEventListener('click', event => {
  8. event.stopPropagation()
  9. })
  10. document.getElementById("options-back-button").addEventListener('click', () => {
  11. hideOptionsUI(game, stageData)
  12. })
  13. document.getElementById("master-volume").addEventListener('change', (event) => {
  14. const value = document.getElementById("master-volume").value
  15. stageData.adjustMasterVolume(value)
  16. })
  17. document.getElementById("music-volume").addEventListener('change', (event) => {
  18. const value = document.getElementById("music-volume").value
  19. stageData.adjustMusicVolume(value)
  20. })
  21. }
  22. export function showOptionsUI(game, stageData) {
  23. document.getElementById("options-container").style.display = "flex"
  24. const panel = document.getElementById("options-panel")
  25. gsap.to(panel, {x: 0, duration: 0.8, onComplete: () => {
  26. }})
  27. closeMainMenuUI(game, stageData)
  28. }
  29. export function hideOptionsUI(game, stageData) {
  30. const panel = document.getElementById("options-panel")
  31. gsap.to(panel, {x: -1024, duration: 0.8, onComplete: () => {
  32. document.getElementById("options-container").style.display = "none"
  33. }})
  34. openMainMenuUI(game, stageData)
  35. }