2019-11-06 22:12:15 -05:00
|
|
|
package scenes
|
2019-10-26 23:59:27 -04:00
|
|
|
|
|
|
|
import (
|
2019-11-06 22:12:15 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/common"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/palettedefs"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/resourcepaths"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/sound"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/ui"
|
2019-10-26 23:59:27 -04:00
|
|
|
"github.com/hajimehoshi/ebiten"
|
|
|
|
)
|
|
|
|
|
|
|
|
type CharacterSelect struct {
|
2019-11-06 22:12:15 -05:00
|
|
|
uiManager *ui.Manager
|
|
|
|
soundManager *sound.Manager
|
|
|
|
fileProvider common.FileProvider
|
2019-10-26 23:59:27 -04:00
|
|
|
sceneProvider SceneProvider
|
2019-11-06 22:12:15 -05:00
|
|
|
background *common.Sprite
|
|
|
|
newCharButton *ui.Button
|
|
|
|
convertCharButton *ui.Button
|
|
|
|
deleteCharButton *ui.Button
|
|
|
|
exitButton *ui.Button
|
|
|
|
okButton *ui.Button
|
2019-10-26 23:59:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func CreateCharacterSelect(
|
2019-11-06 22:12:15 -05:00
|
|
|
fileProvider common.FileProvider,
|
2019-10-26 23:59:27 -04:00
|
|
|
sceneProvider SceneProvider,
|
2019-11-06 22:12:15 -05:00
|
|
|
uiManager *ui.Manager,
|
|
|
|
soundManager *sound.Manager,
|
2019-10-26 23:59:27 -04:00
|
|
|
) *CharacterSelect {
|
|
|
|
result := &CharacterSelect{
|
|
|
|
uiManager: uiManager,
|
|
|
|
sceneProvider: sceneProvider,
|
|
|
|
fileProvider: fileProvider,
|
|
|
|
soundManager: soundManager,
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *CharacterSelect) Load() []func() {
|
2019-11-06 22:12:15 -05:00
|
|
|
v.soundManager.PlayBGM(resourcepaths.BGMTitle)
|
2019-10-26 23:59:27 -04:00
|
|
|
return []func(){
|
|
|
|
func() {
|
2019-11-06 22:12:15 -05:00
|
|
|
v.background = v.fileProvider.LoadSprite(resourcepaths.CharacterSelectionBackground, palettedefs.Sky)
|
2019-10-26 23:59:27 -04:00
|
|
|
v.background.MoveTo(0, 0)
|
|
|
|
},
|
|
|
|
func() {
|
2019-11-06 22:12:15 -05:00
|
|
|
v.newCharButton = ui.CreateButton(ui.ButtonTypeTall, v.fileProvider, common.CombineStrings(common.SplitIntoLinesWithMaxWidth(common.TranslateString("#831"), 15)))
|
2019-10-26 23:59:27 -04:00
|
|
|
v.newCharButton.MoveTo(33, 468)
|
2019-10-27 02:58:37 -04:00
|
|
|
v.newCharButton.OnActivated(func() { v.onNewCharButtonClicked() })
|
2019-10-26 23:59:27 -04:00
|
|
|
v.uiManager.AddWidget(v.newCharButton)
|
|
|
|
},
|
|
|
|
func() {
|
2019-11-06 22:12:15 -05:00
|
|
|
v.convertCharButton = ui.CreateButton(ui.ButtonTypeTall, v.fileProvider, common.CombineStrings(common.SplitIntoLinesWithMaxWidth(common.TranslateString("#825"), 15)))
|
2019-10-26 23:59:27 -04:00
|
|
|
v.convertCharButton.MoveTo(233, 468)
|
|
|
|
v.convertCharButton.SetEnabled(false)
|
|
|
|
v.uiManager.AddWidget(v.convertCharButton)
|
|
|
|
},
|
|
|
|
func() {
|
2019-11-06 22:12:15 -05:00
|
|
|
v.deleteCharButton = ui.CreateButton(ui.ButtonTypeTall, v.fileProvider, common.CombineStrings(common.SplitIntoLinesWithMaxWidth(common.TranslateString("#832"), 15)))
|
2019-10-26 23:59:27 -04:00
|
|
|
v.deleteCharButton.MoveTo(433, 468)
|
|
|
|
v.deleteCharButton.SetEnabled(false)
|
|
|
|
v.uiManager.AddWidget(v.deleteCharButton)
|
|
|
|
},
|
|
|
|
func() {
|
2019-11-06 22:12:15 -05:00
|
|
|
v.exitButton = ui.CreateButton(ui.ButtonTypeMedium, v.fileProvider, common.TranslateString("#970"))
|
2019-10-26 23:59:27 -04:00
|
|
|
v.exitButton.MoveTo(33, 537)
|
|
|
|
v.exitButton.OnActivated(func() { v.onExitButtonClicked() })
|
|
|
|
v.uiManager.AddWidget(v.exitButton)
|
|
|
|
},
|
|
|
|
func() {
|
2019-11-06 22:12:15 -05:00
|
|
|
v.okButton = ui.CreateButton(ui.ButtonTypeMedium, v.fileProvider, common.TranslateString("#971"))
|
2019-10-26 23:59:27 -04:00
|
|
|
v.okButton.MoveTo(625, 537)
|
|
|
|
v.okButton.SetEnabled(false)
|
|
|
|
v.uiManager.AddWidget(v.okButton)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-27 02:58:37 -04:00
|
|
|
func (v *CharacterSelect) onNewCharButtonClicked() {
|
|
|
|
v.sceneProvider.SetNextScene(CreateSelectHeroClass(v.fileProvider, v.sceneProvider, v.uiManager, v.soundManager))
|
|
|
|
}
|
|
|
|
|
2019-10-26 23:59:27 -04:00
|
|
|
func (v *CharacterSelect) onExitButtonClicked() {
|
2019-10-27 19:00:38 -04:00
|
|
|
mainMenu := CreateMainMenu(v.fileProvider, v.sceneProvider, v.uiManager, v.soundManager)
|
|
|
|
mainMenu.ShowTrademarkScreen = false
|
|
|
|
v.sceneProvider.SetNextScene(mainMenu)
|
2019-10-26 23:59:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v *CharacterSelect) Unload() {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *CharacterSelect) Render(screen *ebiten.Image) {
|
|
|
|
v.background.DrawSegments(screen, 4, 3, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *CharacterSelect) Update(tickTime float64) {
|
|
|
|
}
|