import * as RE from 'rogue-engine';

export default class MainMenuComponent extends RE.Component {
  awake() {
    this.loadUi()
  }

  async loadUi() {
    let htmlContents = await (await fetch(RE.getStaticPath("mainmenu.html"))).text()
    RE.Runtime.uiContainer.innerHTML = htmlContents

    const startButton = document.getElementById("start-button")
    if(startButton) {
      startButton.addEventListener("click", this.onStartButtonClick.bind(this))
    }
  }
  
  onStartButtonClick() {
    RE.App.loadScene("MainScene")
  }
}

RE.registerComponent(MainMenuComponent);
        
