import * as RE from 'rogue-engine';
import AsyncLoader from './Library/AsyncLoader';

export default class TitleScreenControl extends RE.Component {

  @RE.props.text()
  introScene = "Combat Screen"
  
  @RE.props.text()
  creditsScene = "Credits"
  
  loader = new AsyncLoader()
  awake() {

  }

  start() {
    this.loader.loadStaticText("title-screen.html").then(html => {
      RE.Runtime.uiContainer.innerHTML = html

      document.getElementById("play-button").addEventListener("mouseup", () => {
        RE.App.loadScene(this.introScene)
      })
      document.getElementById("play-button").addEventListener("touchend", () => {
        RE.App.loadScene(this.introScene)
      })

      document.getElementById("credits-button").addEventListener("mouseup", () => {
        RE.App.loadScene(this.creditsScene)
      })
      document.getElementById("credits-button").addEventListener("touchend", () => {
        RE.App.loadScene(this.creditsScene)
      })
    })
  }

  update() {

  }
}

RE.registerComponent(TitleScreenControl);
