2019-10-24 09:31:59 -04:00
|
|
|
package OpenDiablo2
|
|
|
|
|
|
|
|
import (
|
2019-10-24 19:13:30 -04:00
|
|
|
"image/color"
|
|
|
|
|
2019-10-25 19:12:42 -04:00
|
|
|
"github.com/essial/OpenDiablo2/Common"
|
2019-10-25 18:40:27 -04:00
|
|
|
"github.com/essial/OpenDiablo2/Palettes"
|
|
|
|
|
2019-10-24 11:26:07 -04:00
|
|
|
"github.com/essial/OpenDiablo2/ResourcePaths"
|
2019-10-24 09:31:59 -04:00
|
|
|
"github.com/hajimehoshi/ebiten"
|
|
|
|
)
|
|
|
|
|
2019-10-25 18:40:27 -04:00
|
|
|
// MainMenu represents the main menu
|
2019-10-24 09:31:59 -04:00
|
|
|
type MainMenu struct {
|
2019-10-25 18:40:27 -04:00
|
|
|
engine *Engine
|
2019-10-25 19:12:42 -04:00
|
|
|
trademarkBackground *Common.Sprite
|
|
|
|
background *Common.Sprite
|
|
|
|
diabloLogoLeft *Common.Sprite
|
|
|
|
diabloLogoRight *Common.Sprite
|
|
|
|
diabloLogoLeftBack *Common.Sprite
|
|
|
|
diabloLogoRightBack *Common.Sprite
|
2019-10-25 18:40:27 -04:00
|
|
|
copyrightLabel *UILabel
|
|
|
|
copyrightLabel2 *UILabel
|
|
|
|
showTrademarkScreen bool
|
|
|
|
leftButtonHeld bool
|
2019-10-24 09:31:59 -04:00
|
|
|
}
|
|
|
|
|
2019-10-25 18:40:27 -04:00
|
|
|
// CreateMainMenu creates an instance of MainMenu
|
2019-10-24 09:31:59 -04:00
|
|
|
func CreateMainMenu(engine *Engine) *MainMenu {
|
|
|
|
result := &MainMenu{
|
2019-10-25 18:40:27 -04:00
|
|
|
engine: engine,
|
|
|
|
showTrademarkScreen: true,
|
2019-10-24 09:31:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2019-10-25 18:40:27 -04:00
|
|
|
// Load is called to load the resources for the main menu
|
2019-10-24 09:31:59 -04:00
|
|
|
func (v *MainMenu) Load() {
|
2019-10-25 18:40:27 -04:00
|
|
|
v.engine.PlayBGM(ResourcePaths.BGMTitle)
|
2019-10-24 09:31:59 -04:00
|
|
|
go func() {
|
2019-10-24 19:13:30 -04:00
|
|
|
loadStep := 1.0 / 8.0
|
2019-10-25 18:40:27 -04:00
|
|
|
v.engine.LoadingProgress = 0
|
2019-10-24 19:13:30 -04:00
|
|
|
{
|
2019-10-25 18:40:27 -04:00
|
|
|
v.copyrightLabel = CreateUILabel(v.engine, ResourcePaths.FontFormal12, Palettes.Static)
|
|
|
|
v.copyrightLabel.Alignment = UILabelAlignCenter
|
|
|
|
v.copyrightLabel.SetText("Diablo 2 is © Copyright 2000-2016 Blizzard Entertainment")
|
|
|
|
v.copyrightLabel.ColorMod = color.RGBA{188, 168, 140, 255}
|
|
|
|
v.copyrightLabel.MoveTo(400, 500)
|
|
|
|
v.engine.LoadingProgress += loadStep
|
2019-10-24 19:13:30 -04:00
|
|
|
}
|
|
|
|
{
|
2019-10-25 18:40:27 -04:00
|
|
|
v.copyrightLabel2 = CreateUILabel(v.engine, ResourcePaths.FontFormal12, Palettes.Static)
|
|
|
|
v.copyrightLabel2.Alignment = UILabelAlignCenter
|
|
|
|
v.copyrightLabel2.SetText("All Rights Reserved.")
|
|
|
|
v.copyrightLabel2.ColorMod = color.RGBA{188, 168, 140, 255}
|
|
|
|
v.copyrightLabel2.MoveTo(400, 525)
|
|
|
|
v.engine.LoadingProgress += loadStep
|
2019-10-24 19:13:30 -04:00
|
|
|
}
|
|
|
|
{
|
2019-10-25 18:40:27 -04:00
|
|
|
v.background = v.engine.LoadSprite(ResourcePaths.GameSelectScreen, Palettes.Sky)
|
|
|
|
v.background.MoveTo(0, 0)
|
|
|
|
v.engine.LoadingProgress += loadStep
|
2019-10-24 19:13:30 -04:00
|
|
|
}
|
|
|
|
{
|
2019-10-25 18:40:27 -04:00
|
|
|
v.trademarkBackground = v.engine.LoadSprite(ResourcePaths.TrademarkScreen, Palettes.Sky)
|
|
|
|
v.trademarkBackground.MoveTo(0, 0)
|
|
|
|
v.engine.LoadingProgress += loadStep
|
2019-10-24 19:13:30 -04:00
|
|
|
}
|
|
|
|
{
|
2019-10-25 18:40:27 -04:00
|
|
|
v.diabloLogoLeft = v.engine.LoadSprite(ResourcePaths.Diablo2LogoFireLeft, Palettes.Units)
|
|
|
|
v.diabloLogoLeft.Blend = true
|
|
|
|
v.diabloLogoLeft.Animate = true
|
|
|
|
v.diabloLogoLeft.MoveTo(400, 120)
|
|
|
|
v.engine.LoadingProgress += loadStep
|
2019-10-24 19:13:30 -04:00
|
|
|
}
|
|
|
|
{
|
2019-10-25 18:40:27 -04:00
|
|
|
v.diabloLogoRight = v.engine.LoadSprite(ResourcePaths.Diablo2LogoFireRight, Palettes.Units)
|
|
|
|
v.diabloLogoRight.Blend = true
|
|
|
|
v.diabloLogoRight.Animate = true
|
|
|
|
v.diabloLogoRight.MoveTo(400, 120)
|
|
|
|
v.engine.LoadingProgress += loadStep
|
2019-10-24 19:13:30 -04:00
|
|
|
}
|
|
|
|
{
|
2019-10-25 18:40:27 -04:00
|
|
|
v.diabloLogoLeftBack = v.engine.LoadSprite(ResourcePaths.Diablo2LogoBlackLeft, Palettes.Units)
|
|
|
|
v.diabloLogoLeftBack.MoveTo(400, 120)
|
|
|
|
v.engine.LoadingProgress += loadStep
|
2019-10-24 19:13:30 -04:00
|
|
|
}
|
|
|
|
{
|
2019-10-25 18:40:27 -04:00
|
|
|
v.diabloLogoRightBack = v.engine.LoadSprite(ResourcePaths.Diablo2LogoBlackRight, Palettes.Units)
|
|
|
|
v.diabloLogoRightBack.MoveTo(400, 120)
|
|
|
|
v.engine.LoadingProgress = 1.0
|
2019-10-24 19:13:30 -04:00
|
|
|
}
|
2019-10-24 09:31:59 -04:00
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
2019-10-25 18:40:27 -04:00
|
|
|
// Unload unloads the data for the main menu
|
2019-10-24 09:31:59 -04:00
|
|
|
func (v *MainMenu) Unload() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-10-25 18:40:27 -04:00
|
|
|
// Render renders the main menu
|
2019-10-24 09:31:59 -04:00
|
|
|
func (v *MainMenu) Render(screen *ebiten.Image) {
|
2019-10-25 18:40:27 -04:00
|
|
|
if v.showTrademarkScreen {
|
|
|
|
v.trademarkBackground.DrawSegments(screen, 4, 3, 0)
|
2019-10-24 09:31:59 -04:00
|
|
|
} else {
|
2019-10-25 18:40:27 -04:00
|
|
|
v.background.DrawSegments(screen, 4, 3, 0)
|
2019-10-24 09:31:59 -04:00
|
|
|
}
|
2019-10-25 18:40:27 -04:00
|
|
|
v.diabloLogoLeftBack.Draw(screen)
|
|
|
|
v.diabloLogoRightBack.Draw(screen)
|
|
|
|
v.diabloLogoLeft.Draw(screen)
|
|
|
|
v.diabloLogoRight.Draw(screen)
|
2019-10-24 09:31:59 -04:00
|
|
|
|
2019-10-25 18:40:27 -04:00
|
|
|
if v.showTrademarkScreen {
|
|
|
|
v.copyrightLabel.Draw(screen)
|
|
|
|
v.copyrightLabel2.Draw(screen)
|
2019-10-24 09:31:59 -04:00
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-25 18:40:27 -04:00
|
|
|
// Update runs the update logic on the main menu
|
2019-10-24 09:31:59 -04:00
|
|
|
func (v *MainMenu) Update() {
|
2019-10-25 18:40:27 -04:00
|
|
|
if v.showTrademarkScreen {
|
|
|
|
if v.engine.CursorButtonPressed(CursorButtonLeft) {
|
|
|
|
v.leftButtonHeld = true
|
|
|
|
v.showTrademarkScreen = false
|
2019-10-25 15:06:47 -04:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2019-10-24 09:31:59 -04:00
|
|
|
}
|