2020-11-18 21:33:22 -05:00
|
|
|
package d2systems
|
2020-10-28 18:49:49 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gravestench/akara"
|
|
|
|
|
2020-11-18 21:33:22 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
2020-11-22 04:37:55 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
|
2020-10-28 18:49:49 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2020-11-22 04:37:55 -05:00
|
|
|
sceneKeyMainMenu = "Main Menu"
|
2020-10-28 18:49:49 -04:00
|
|
|
)
|
|
|
|
|
2020-11-22 04:37:55 -05:00
|
|
|
// NewMainMenuScene creates a new main menu scene. This is the first screen that the user
|
|
|
|
// will see when launching the game.
|
|
|
|
func NewMainMenuScene() *MainMenuScene {
|
|
|
|
scene := &MainMenuScene{
|
|
|
|
BaseScene: NewBaseScene(sceneKeyMainMenu),
|
2020-11-18 21:33:22 -05:00
|
|
|
}
|
2020-10-28 18:49:49 -04:00
|
|
|
|
2020-11-18 21:33:22 -05:00
|
|
|
return scene
|
2020-10-28 18:49:49 -04:00
|
|
|
}
|
|
|
|
|
2020-11-18 21:33:22 -05:00
|
|
|
// static check that MainMenuScene implements the scene interface
|
2020-11-22 04:37:55 -05:00
|
|
|
var _ d2interface.Scene = &MainMenuScene{}
|
2020-10-28 18:49:49 -04:00
|
|
|
|
2020-11-22 04:37:55 -05:00
|
|
|
// MainMenuScene represents the game's main menu, where users can select single or multi player,
|
|
|
|
// or start the map engine test.
|
|
|
|
type MainMenuScene struct {
|
2020-11-18 21:33:22 -05:00
|
|
|
*BaseScene
|
|
|
|
booted bool
|
2020-10-28 18:49:49 -04:00
|
|
|
}
|
|
|
|
|
2020-11-22 04:37:55 -05:00
|
|
|
// Init the main menu scene
|
2020-11-28 00:45:58 -05:00
|
|
|
func (s *MainMenuScene) Init(world *akara.World) {
|
|
|
|
s.World = world
|
|
|
|
|
2020-11-18 21:33:22 -05:00
|
|
|
s.Info("initializing ...")
|
2020-10-28 18:49:49 -04:00
|
|
|
}
|
|
|
|
|
2020-11-22 04:37:55 -05:00
|
|
|
func (s *MainMenuScene) boot() {
|
2020-11-18 21:33:22 -05:00
|
|
|
if !s.BaseScene.booted {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-11-22 04:37:55 -05:00
|
|
|
s.createTrademarkScreen()
|
2020-11-22 19:34:46 -05:00
|
|
|
s.createButtons()
|
|
|
|
s.createBackground()
|
2020-11-19 17:17:01 -05:00
|
|
|
|
2020-11-18 21:33:22 -05:00
|
|
|
s.booted = true
|
2020-10-28 18:49:49 -04:00
|
|
|
}
|
|
|
|
|
2020-11-22 04:37:55 -05:00
|
|
|
func (s *MainMenuScene) createBackground() {
|
2020-11-18 21:33:22 -05:00
|
|
|
s.Info("creating background")
|
2020-11-22 19:34:46 -05:00
|
|
|
s.Add.SegmentedSprite(0, 0, d2resource.GameSelectScreen, d2resource.PaletteSky, 4, 3, 0)
|
2020-10-28 18:49:49 -04:00
|
|
|
}
|
|
|
|
|
2020-11-22 04:37:55 -05:00
|
|
|
func (s *MainMenuScene) createButtons() {
|
2020-11-18 21:33:22 -05:00
|
|
|
s.Info("creating buttons")
|
2020-10-28 18:49:49 -04:00
|
|
|
}
|
|
|
|
|
2020-11-22 04:37:55 -05:00
|
|
|
func (s *MainMenuScene) createTrademarkScreen() {
|
2020-11-18 21:33:22 -05:00
|
|
|
s.Info("creating trademark screen")
|
2020-11-22 19:34:46 -05:00
|
|
|
s.Add.SegmentedSprite(0, 0, d2resource.TrademarkScreen, d2resource.PaletteSky, 4, 3, 0)
|
2020-11-18 21:33:22 -05:00
|
|
|
}
|
|
|
|
|
2020-11-22 04:37:55 -05:00
|
|
|
// Update the main menu scene
|
|
|
|
func (s *MainMenuScene) Update() {
|
2020-11-18 21:33:22 -05:00
|
|
|
if s.Paused() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if !s.booted {
|
|
|
|
s.boot()
|
|
|
|
}
|
2020-10-28 18:49:49 -04:00
|
|
|
|
2020-11-18 21:33:22 -05:00
|
|
|
s.BaseScene.Update()
|
2020-10-28 18:49:49 -04:00
|
|
|
}
|