Files
ordoor/internal/flow/new_game.go

80 lines
2.2 KiB
Go
Raw Normal View History

2020-03-26 23:35:34 +00:00
package flow
import (
"code.ur.gs/lupine/ordoor/internal/ship"
)
2020-03-26 23:35:34 +00:00
func (f *Flow) linkNewGame() {
// New game
f.onClick(newGame, "2.1", f.setReturningDriver(newGame, levelPly)) // New campaign button
f.onClick(newGame, "2.2", f.setReturningDriver(newGame, singles)) // Single scenario button
f.onClick(newGame, "2.3", f.setReturningDriver(newGame, randomMap)) // Random scenario button
f.onClick(newGame, "2.4", f.returnToLastDriver(newGame)) // Back button
2020-03-26 23:35:34 +00:00
f.linkLevelPly()
f.linkSingles()
f.linkRandomMap()
}
func (f *Flow) resetLevelPlyInventorySelect() {
2020-03-26 23:35:34 +00:00
// FIXME: Make the radio button respect changes via setValue
for _, v := range []string{"2.1", "2.2", "2.3", "2.4"} {
f.setValueBool(levelPly, v, false)
}
switch f.ship.Difficulty {
case ship.DifficultyLevelMarine:
f.setValueBool(levelPly, "2.1", true)
case ship.DifficultyLevelVeteran:
2020-03-26 23:35:34 +00:00
f.setValueBool(levelPly, "2.2", true)
case ship.DifficultyLevelHero:
f.setValueBool(levelPly, "2.3", true)
case ship.DifficultyLevelMighty:
f.setValueBool(levelPly, "2.4", true)
2020-03-26 23:35:34 +00:00
}
}
2020-03-26 23:35:34 +00:00
func (f *Flow) linkLevelPly() {
2020-03-26 23:35:34 +00:00
f.onClick(levelPly, "2.5", func() { // Back button
f.resetLevelPlyInventorySelect() // FIXME: should use data binding
f.returnToLastDriverNow(levelPly)
2020-03-26 23:35:34 +00:00
})
// FIXME: we should be able to read the difficulty level from the group
f.onClick(levelPly, "2.7", func() { // Select button
if f.valueBool(levelPly, "2.1") {
f.ship.Difficulty = ship.DifficultyLevelMarine
}
if f.valueBool(levelPly, "2.2") {
f.ship.Difficulty = ship.DifficultyLevelVeteran
}
if f.valueBool(levelPly, "2.3") {
f.ship.Difficulty = ship.DifficultyLevelHero
}
if f.valueBool(levelPly, "2.4") {
// FIXME: we should select a savegame. Mighty Hero disables manual saves.
f.ship.Difficulty = ship.DifficultyLevelMighty
}
f.ship.NextScenario = f.generic.CampaignMaps[0]
// FIXME: we should show a movie here. Need an internal SMK player first
f.setDriverNow(bridge)
})
// Link children
f.linkBridge()
2020-03-26 23:35:34 +00:00
}
func (f *Flow) linkSingles() {
f.onClick(singles, "4.11", f.returnToLastDriver(singles)) // Back button
2020-03-26 23:35:34 +00:00
}
func (f *Flow) linkRandomMap() {
f.onClick(randomMap, "2.19", f.returnToLastDriver(randomMap)) // Back button
2020-03-26 23:35:34 +00:00
}