2019-10-24 09:31:59 -04:00
|
|
|
package OpenDiablo2
|
|
|
|
|
|
|
|
import (
|
2019-10-24 19:13:30 -04:00
|
|
|
"image/color"
|
|
|
|
|
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"
|
|
|
|
)
|
|
|
|
|
|
|
|
type MainMenu struct {
|
|
|
|
Engine *Engine
|
|
|
|
TrademarkBackground Sprite
|
|
|
|
Background Sprite
|
|
|
|
DiabloLogoLeft Sprite
|
|
|
|
DiabloLogoRight Sprite
|
|
|
|
DiabloLogoLeftBack Sprite
|
|
|
|
DiabloLogoRightBack Sprite
|
|
|
|
CopyrightLabel *UILabel
|
2019-10-24 19:13:30 -04:00
|
|
|
CopyrightLabel2 *UILabel
|
2019-10-24 09:31:59 -04:00
|
|
|
ShowTrademarkScreen bool
|
2019-10-25 15:06:47 -04:00
|
|
|
LeftButtonHeld bool
|
2019-10-24 09:31:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func CreateMainMenu(engine *Engine) *MainMenu {
|
|
|
|
result := &MainMenu{
|
|
|
|
Engine: engine,
|
|
|
|
ShowTrademarkScreen: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *MainMenu) Load() {
|
2019-10-25 15:06:47 -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-24 09:31:59 -04:00
|
|
|
v.Engine.LoadingProgress = 0
|
2019-10-24 19:13:30 -04:00
|
|
|
{
|
|
|
|
v.CopyrightLabel = CreateUILabel(v.Engine, ResourcePaths.FontFormal12, "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
|
|
|
|
}
|
|
|
|
{
|
|
|
|
v.CopyrightLabel2 = CreateUILabel(v.Engine, ResourcePaths.FontFormal12, "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
|
|
|
|
}
|
|
|
|
{
|
|
|
|
v.Background = v.Engine.LoadSprite(ResourcePaths.GameSelectScreen, v.Engine.Palettes["sky"])
|
|
|
|
v.Background.MoveTo(0, 0)
|
|
|
|
v.Engine.LoadingProgress += loadStep
|
|
|
|
}
|
|
|
|
{
|
|
|
|
v.TrademarkBackground = v.Engine.LoadSprite(ResourcePaths.TrademarkScreen, v.Engine.Palettes["sky"])
|
|
|
|
v.TrademarkBackground.MoveTo(0, 0)
|
|
|
|
v.Engine.LoadingProgress += loadStep
|
|
|
|
}
|
|
|
|
{
|
|
|
|
v.DiabloLogoLeft = v.Engine.LoadSprite(ResourcePaths.Diablo2LogoFireLeft, v.Engine.Palettes["units"])
|
|
|
|
v.DiabloLogoLeft.Blend = true
|
|
|
|
v.DiabloLogoLeft.Animate = true
|
|
|
|
v.DiabloLogoLeft.MoveTo(400, 120)
|
|
|
|
v.Engine.LoadingProgress += loadStep
|
|
|
|
}
|
|
|
|
{
|
|
|
|
v.DiabloLogoRight = v.Engine.LoadSprite(ResourcePaths.Diablo2LogoFireRight, v.Engine.Palettes["units"])
|
|
|
|
v.DiabloLogoRight.Blend = true
|
|
|
|
v.DiabloLogoRight.Animate = true
|
|
|
|
v.DiabloLogoRight.MoveTo(400, 120)
|
|
|
|
v.Engine.LoadingProgress += loadStep
|
|
|
|
}
|
|
|
|
{
|
|
|
|
v.DiabloLogoLeftBack = v.Engine.LoadSprite(ResourcePaths.Diablo2LogoBlackLeft, v.Engine.Palettes["units"])
|
|
|
|
v.DiabloLogoLeftBack.MoveTo(400, 120)
|
|
|
|
v.Engine.LoadingProgress += loadStep
|
|
|
|
}
|
|
|
|
{
|
|
|
|
v.DiabloLogoRightBack = v.Engine.LoadSprite(ResourcePaths.Diablo2LogoBlackRight, v.Engine.Palettes["units"])
|
|
|
|
v.DiabloLogoRightBack.MoveTo(400, 120)
|
|
|
|
v.Engine.LoadingProgress = 1.0
|
|
|
|
}
|
2019-10-24 09:31:59 -04:00
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *MainMenu) Unload() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *MainMenu) Render(screen *ebiten.Image) {
|
|
|
|
if v.ShowTrademarkScreen {
|
|
|
|
v.TrademarkBackground.DrawSegments(screen, 4, 3, 0)
|
|
|
|
} else {
|
|
|
|
v.Background.DrawSegments(screen, 4, 3, 0)
|
|
|
|
}
|
|
|
|
v.DiabloLogoLeftBack.Draw(screen)
|
|
|
|
v.DiabloLogoRightBack.Draw(screen)
|
|
|
|
v.DiabloLogoLeft.Draw(screen)
|
|
|
|
v.DiabloLogoRight.Draw(screen)
|
|
|
|
|
|
|
|
if v.ShowTrademarkScreen {
|
|
|
|
v.CopyrightLabel.Draw(screen)
|
2019-10-24 19:13:30 -04:00
|
|
|
v.CopyrightLabel2.Draw(screen)
|
2019-10-24 09:31:59 -04:00
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *MainMenu) Update() {
|
2019-10-25 15:06:47 -04:00
|
|
|
if v.ShowTrademarkScreen {
|
|
|
|
if v.Engine.CursorButtonPressed(CursorButtonLeft) {
|
|
|
|
v.LeftButtonHeld = true
|
|
|
|
v.ShowTrademarkScreen = false
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2019-10-24 09:31:59 -04:00
|
|
|
}
|