From 15b2e7613fc67d137232ab51433307ffddae7e59 Mon Sep 17 00:00:00 2001 From: "M. Sz" Date: Tue, 10 Nov 2020 14:17:34 +0100 Subject: [PATCH] cinematics menu final commit --- d2game/d2gamescreen/cinematics.go | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/d2game/d2gamescreen/cinematics.go b/d2game/d2gamescreen/cinematics.go index bb3a857b..34019276 100644 --- a/d2game/d2gamescreen/cinematics.go +++ b/d2game/d2gamescreen/cinematics.go @@ -28,6 +28,7 @@ const ( // Cinematics represents the cinematics screen type Cinematics struct { cinematicsBackground *d2ui.Sprite + background *d2ui.Sprite a1Btn *d2ui.Button a2Btn *d2ui.Button a3Btn *d2ui.Button @@ -65,11 +66,19 @@ func CreateCinematics( } // OnLoad is called to load the resources for the credits screen -func (v *Cinematics) OnLoad(loading d2screen.LoadingState) { +func (v *Cinematics) OnLoad(_ d2screen.LoadingState) { var err error v.audioProvider.PlayBGM("") + v.background, err = v.uiManager.NewSprite(d2resource.GameSelectScreen, d2resource.PaletteSky) + + if err != nil { + log.Print(err) + } + + v.background.SetPosition(backgroundX, backgroundY) + v.cinematicsBackground, err = v.uiManager.NewSprite(d2resource.CinematicsBackground, d2resource.PaletteSky) if err != nil { @@ -78,19 +87,13 @@ func (v *Cinematics) OnLoad(loading d2screen.LoadingState) { v.cinematicsBackground.SetPosition(cinematicsX, cinematicsY) - loading.Progress(twentyPercent) - v.createButtons() - loading.Progress(fourtyPercent) v.cinematicsLabel = v.uiManager.NewLabel(d2resource.Font30, d2resource.PaletteStatic) v.cinematicsLabel.Alignment = d2gui.HorizontalAlignCenter v.cinematicsLabel.SetText("SELECT CINEMATIC") v.cinematicsLabel.Color[0] = rgbaColor(lightBrown) v.cinematicsLabel.SetPosition(cinematicsLabelX, cinematicsLabelY) - - loading.Progress(sixtyPercent) - loading.Progress(eightyPercent) } func (v *Cinematics) createButtons() { @@ -180,10 +183,21 @@ func (v *Cinematics) playVideo(path string) { // Render renders the credits screen func (v *Cinematics) Render(screen d2interface.Surface) { - err := v.cinematicsBackground.RenderSegmented(screen, 2, 2, 0) + err := v.background.RenderSegmented(screen, 4, 3, 0) + + if err != nil { + return + } + + err = v.cinematicsBackground.RenderSegmented(screen, 2, 2, 0) + if err != nil { return } v.cinematicsLabel.Render(screen) + + if err != nil { + return + } }