cinematics select background

This commit is contained in:
M. Sz 2020-11-10 07:59:17 +01:00
parent e20d544a8c
commit 2eda3827ce
3 changed files with 25 additions and 214 deletions

View File

@ -962,6 +962,7 @@ func (a *App) ToCredits() {
a.screen.SetNextScreen(d2gamescreen.CreateCredits(a, a.asset, a.renderer, a.ui))
}
// ToCinematics forces the game to transition to the cinematics menu
func (a *App) ToCinematics() {
a.screen.SetNextScreen(d2gamescreen.CreateCinematics(a, a.asset, a.renderer, a.ui))
}

View File

@ -33,8 +33,7 @@ const (
// --- Cinematics ---
//CinematicsBackground = "/data/global/ui/FrontEnd/CinematicsSelectionEXP.dc6"
CinematicsBackground = "/data/global/ui/CharSelect/creditsbckgexpand.dc6"
CinematicsBackground = "/data/global/ui/FrontEnd/CinematicsSelectionEXP.dc6"
// --- Character Select Screen ---

View File

@ -1,32 +1,26 @@
package d2gamescreen
import (
//"bufio"
"fmt"
"log"
//"os"
//"path"
//"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2video"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
//"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2video"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2screen"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2ui"
)
const (
cinematicsX, cinematicsY = 100, 100
a1BtnX, a1BtnY = 264, 100
a2BtnX, a2BtnY = 264, 160
a3BtnX, a3BtnY = 264, 220
a4BtnX, a4BtnY = 264, 280
cinematicsX, cinematicsY = 240, 90
a1BtnX, a1BtnY = 264, 160
a2BtnX, a2BtnY = 264, 205
a3BtnX, a3BtnY = 264, 250
a4BtnX, a4BtnY = 264, 295
endCreditClassBtnX, endCreditClassBtnY = 264, 340
a5BtnX, a5BtnY = 264, 400
endCreditExpBtnX, endCreditExpBtnY = 264, 460
cinematicsExitBtnX, cinematicsExitBtnY = 264, 540
a5BtnX, a5BtnY = 264, 385
endCreditExpBtnX, endCreditExpBtnY = 264, 430
cinematicsExitBtnX, cinematicsExitBtnY = 340, 470
)
// Cinematics represents the cinematics screen
@ -68,42 +62,19 @@ func CreateCinematics(
func (v *Cinematics) OnLoad(loading d2screen.LoadingState) {
var err error
fmt.Println("\n\ninitializing background\n\n")
v.cinematicsBackground, err = v.uiManager.NewSprite(d2resource.CinematicsBackground, d2resource.PaletteSky)
if err != nil {
fmt.Println("\n\nerror occured\n\n")
log.Print(err)
}
fmt.Println("\n\nsetting position\n\n")
v.cinematicsBackground.SetPosition(0, 0)
v.cinematicsBackground.SetPosition(cinematicsX, cinematicsY)
loading.Progress(twentyPercent)
v.createButtons()
/*loading.Progress(fourtyPercent)
fileData, err := v.asset.LoadFile(d2resource.CreditsText)
if err != nil {
loading.Error(err)
return
}
loading.Progress(fourtyPercent)
loading.Progress(sixtyPercent)
creditData, err := d2util.Utf16BytesToString(fileData[2:])
if err != nil {
log.Print(err)
}
v.creditsText = strings.Split(creditData, "\r\n")
for i := range v.creditsText {
v.creditsText[i] = strings.Trim(v.creditsText[i], " ")
}
loading.Progress(eightyPercent)
v.creditsText = append(v.LoadContributors(), v.creditsText...)*/
}
func (v *Cinematics) createButtons() {
@ -112,11 +83,11 @@ func (v *Cinematics) createButtons() {
Act 2: Dessert Journay
Act 3: Mephisto's Jungle
Act 4: Enter Hell
Act 5:
end Credit Classic:
end Credit Expansion:
Act 5: Search For Ball
end Credit Classic: Terror's End
end Credit Expansion: Destruction's End
*/
v.cinematicsExitBtn = v.uiManager.NewButton(d2ui.ButtonTypeWide, "CANCEL")
v.cinematicsExitBtn = v.uiManager.NewButton(d2ui.ButtonTypeMedium, "CANCEL")
v.cinematicsExitBtn.SetPosition(cinematicsExitBtnX, cinematicsExitBtnY)
v.cinematicsExitBtn.OnActivated(func() { v.onCinematicsExitBtnClicked() })
@ -136,18 +107,17 @@ func (v *Cinematics) createButtons() {
v.a4Btn.SetPosition(a4BtnX, a4BtnY)
v.a4Btn.OnActivated(func() { v.onA4BtnClicked() })
v.endCreditClassBtn = v.uiManager.NewButton(d2ui.ButtonTypeWide, "DiabloII Classic End Credit")
v.endCreditClassBtn = v.uiManager.NewButton(d2ui.ButtonTypeWide, "TERROR'S END")
v.endCreditClassBtn.SetPosition(endCreditClassBtnX, endCreditClassBtnY)
v.endCreditClassBtn.OnActivated(func() { v.onEndCreditClassBtnClicked() })
v.a5Btn = v.uiManager.NewButton(d2ui.ButtonTypeWide, "DiabloII Act 5 video")
v.a5Btn = v.uiManager.NewButton(d2ui.ButtonTypeWide, "SEARCH FOR BAAL")
v.a5Btn.SetPosition(a5BtnX, a5BtnY)
v.a5Btn.OnActivated(func() { v.onA5BtnClicked() })
v.endCreditExpBtn = v.uiManager.NewButton(d2ui.ButtonTypeWide, "DiabloII Expansion End Credit")
v.endCreditExpBtn = v.uiManager.NewButton(d2ui.ButtonTypeWide, "DESTRUCTION'S END")
v.endCreditExpBtn.SetPosition(endCreditExpBtnX, endCreditExpBtnY)
v.endCreditExpBtn.OnActivated(func() { v.onEndCreditExpBtnClicked() })
}
func (v *Cinematics) onCinematicsExitBtnClicked() {
@ -185,176 +155,17 @@ func (v *Cinematics) onEndCreditExpBtnClicked() {
func (v *Cinematics) playVideo(path string) {
videoBytes, err := v.asset.LoadFile(path)
if err != nil {
log.Printf(err.Error())
log.Print(err)
return
}
v.videoDecoder = d2video.CreateBinkDecoder(videoBytes)
}
/*
// Render renders the credits screen
func (v *Credits) Render(screen d2interface.Surface) {
err := v.creditsBackground.RenderSegmented(screen, 4, 3, 0)
func (v *Cinematics) Render(screen d2interface.Surface) {
err := v.cinematicsBackground.RenderSegmented(screen, 2, 3, 0)
if err != nil {
return
}
for _, label := range v.labels {
if label.Available {
continue
}
label.Label.Render(screen)
}
}
// Advance runs the update logic on the credits screen
func (v *Credits) Advance(tickTime float64) error {
v.cycleTime += tickTime
for v.cycleTime >= secondsPerCycle {
v.cycleTime -= secondsPerCycle
v.cyclesTillNextLine--
if !v.doneWithCredits && v.cyclesTillNextLine <= 0 {
v.addNextItem()
}
for _, label := range v.labels {
if label.Available {
continue
}
if label.Label.Y-1 < -15 {
label.Available = true
continue
}
label.Label.Y--
}
}
return nil
}
func (v *Credits) onExitButtonClicked() {
v.navigator.ToMainMenu()
}
func (v *Credits) addNextItem() {
if len(v.creditsText) == 0 {
v.doneWithCredits = true
return
}
text := v.creditsText[0]
v.creditsText = v.creditsText[1:]
if text == "" {
if v.creditsText[0][0] == '*' {
v.cyclesTillNextLine = 38
return
}
v.cyclesTillNextLine = 19
return
}
isHeading := text[0] == '*'
isNextHeading := len(v.creditsText) > 0 && len(v.creditsText[0]) > 0 && v.creditsText[0][0] == '*'
isNextSpace := len(v.creditsText) > 0 && v.creditsText[0] == ""
var label = v.getNewFontLabel(isHeading)
if isHeading {
label.SetText(text[1:])
} else {
label.SetText(text)
}
isDoubled, isNextHeading := v.setItemLabelPosition(label, isHeading, isNextHeading, isNextSpace)
switch {
case isHeading && isNextHeading:
v.cyclesTillNextLine = 38
case isNextHeading:
if isDoubled {
v.cyclesTillNextLine = 38
} else {
v.cyclesTillNextLine = 57
}
case isHeading:
v.cyclesTillNextLine = 38
default:
v.cyclesTillNextLine = 19
}
}
const (
itemLabelY = 605
itemLabelX = 400
itemLabel2offsetX = 10
halfItemLabel2offsetX = itemLabel2offsetX / 2
)
func (v *Credits) setItemLabelPosition(label *d2ui.Label, isHeading, isNextHeading, isNextSpace bool) (isDoubled, nextHeading bool) {
width, _ := label.GetSize()
half := 2
halfWidth := width / half
if !isHeading && !isNextHeading && !isNextSpace {
isDoubled = true
// Gotta go side by side
label.SetPosition(itemLabelX-width, itemLabelY)
text2 := v.creditsText[0]
v.creditsText = v.creditsText[1:]
nextHeading = len(v.creditsText) > 0 && len(v.creditsText[0]) > 0 && v.creditsText[0][0] == '*'
label2 := v.getNewFontLabel(isHeading)
label2.SetText(text2)
label2.SetPosition(itemLabelX+itemLabel2offsetX, itemLabelY)
return isDoubled, nextHeading
}
label.SetPosition(itemLabelX+halfItemLabel2offsetX-halfWidth, itemLabelY)
return isDoubled, isNextHeading
}
const (
lightRed = 0xff5852ff
beige = 0xc6b296ff
)
func (v *Credits) getNewFontLabel(isHeading bool) *d2ui.Label {
for _, label := range v.labels {
if label.Available {
label.Available = false
if isHeading {
label.Label.Color[0] = rgbaColor(lightRed)
} else {
label.Label.Color[0] = rgbaColor(beige)
}
return label.Label
}
}
newLabelItem := &labelItem{
Available: false,
IsHeading: isHeading,
Label: v.uiManager.NewLabel(d2resource.FontFormal10, d2resource.PaletteSky),
}
if isHeading {
newLabelItem.Label.Color[0] = rgbaColor(lightRed)
} else {
newLabelItem.Label.Color[0] = rgbaColor(beige)
}
v.labels = append(v.labels, newLabelItem)
return newLabelItem.Label
}*/