import { state } from "../state" ; import { StorageManager } from "../storage" ; import { MbgMenu } from "./menu_mbg" ; import { MbpMenu } from "./menu_mbp" ; let mbgMenu ; let mbpMenu ; const switchingMessage = document . querySelector ( '#switching-message' ) as HTMLDivElement ; /** Sets the menu to the given modification. */ export const setMenu = async ( type ) => { state . menu ?. hide ( ) ; if ( state . menu ) switchingMessage . classList . remove ( 'hidden' ) ; document . querySelector ( '#favicon' ) . setAttribute ( 'href' , ( type === 'gold' ) ? "./assets/img/marble-blast-gold-logo.png" : "./assets/img/mbp.png" ) ; if ( type === 'gold' ) { if ( mbgMenu ) { state . modification = 'gold' ; state . menu = mbgMenu ; mbgMenu . show ( ) ; } else { mbgMenu = new MbgMenu ( ) ; state . modification = 'gold' ; state . menu = mbgMenu ; await mbgMenu . init ( ) ; if ( mbpMenu ) mbgMenu . show ( ) ; } } else { if ( mbpMenu ) { state . modification = 'platinum' ; state . menu = mbpMenu ; mbpMenu . show ( ) ; } else { mbpMenu = new MbpMenu ( ) ; state . modification = 'platinum' ; state . menu = mbpMenu ; await mbpMenu . init ( ) ; if ( mbgMenu ) mbpMenu . show ( ) ; } } switchingMessage . classList . add ( 'hidden' ) ; StorageManager . data . modification = type ; StorageManager . store ( ) ; } ;