package flow

func (f *Flow) linkNewGame() {
	// New game
	f.onClick(newGame, "2.1", f.setDriver(levelPly))  // New campaign button
	f.onClick(newGame, "2.2", f.setDriver(singles))   // Single scenario button
	f.onClick(newGame, "2.3", f.setDriver(randomMap)) // Random scenario button
	f.onClick(newGame, "2.4", f.setDriver(main))      // Back button

	f.linkLevelPly()
	f.linkSingles()
	f.linkRandomMap()
}

func (f *Flow) linkLevelPly() {
	// We want the default difficulty level to be Veteran, not Hero.
	// FIXME: Make the radio button respect changes via setValue
	resetLevel := func() {
		f.setValueBool(levelPly, "2.1", false)
		f.setValueBool(levelPly, "2.2", true)
	}
	resetLevel()

	f.onClick(levelPly, "2.5", func() { // Back button
		resetLevel()
		f.setDriverNow(newGame)
	})

	// FIXME: we should select a savegame if Mighty Hero is selected here
	// FIXME: we should show a movie here. Need an internal SMK player first
	// FIXME: we should set up new game state here!
	f.onClick(levelPly, "2.7", f.setDriver(bridge)) // Select button

	// Link children
	f.linkBridge()
}

func (f *Flow) linkSingles() {
	f.onClick(singles, "4.11", f.setDriver(newGame)) // Back button
}

func (f *Flow) linkRandomMap() {
	f.onClick(randomMap, "2.19", f.setDriver(newGame)) // Back button
}
