add dialog to domain

This commit is contained in:
2023-07-04 20:56:09 +02:00
parent 74272c09f2
commit 88cf7620be
5 changed files with 53 additions and 31 deletions

View File

@@ -7,6 +7,8 @@ import (
"github.com/hajimehoshi/ebiten/text"
)
type DialogMap map[string]Dialog
type DialogLayout struct {
Background string
ChoiceFont FontLayout
@@ -33,7 +35,7 @@ func (dialog *Dialog) GetChoiceColor(i int) color.Color {
}
func (e *Engine) DialogDraw(screen *ebiten.Image) {
dialog := e.Domain.GetDialog()
dialog := e.Domain.GetDialog(e.KContext.Screen.Value)
face := GetFontFace(dialog.Layout.ChoiceFont)
@@ -44,7 +46,7 @@ func (e *Engine) DialogDraw(screen *ebiten.Image) {
}
func (e *Engine) DialogUpdate() {
dialog := e.Domain.GetDialog()
dialog := e.Domain.GetDialog(e.KContext.Screen.Value)
if e.Controller.UpPressed() && dialog.CurrentSelected != 0 {
dialog.CurrentSelected--
@@ -57,4 +59,5 @@ func (e *Engine) DialogUpdate() {
if e.Controller.Action0Pressed() {
dialog.Choices[dialog.CurrentSelected].Handler()
}
e.Domain.SetDialog(e.KContext.Screen.Value, dialog)
}

View File

@@ -13,7 +13,8 @@ type DomainInterface interface {
Init()
GetMenu(name string) Menu
SetMenu(name string, menu Menu)
GetDialog() Dialog
GetDialog(name string) Dialog
SetDialog(name string, menu Dialog)
}
type ScreenSettings struct {