This commit is contained in:
2023-07-05 21:33:59 +02:00
parent 8775464c25
commit d61a491731
9 changed files with 44 additions and 26 deletions

View File

@@ -18,32 +18,28 @@ func (e *Engine) Layout(outsideWidth, outsideHeight int) (int, int) {
return e.Settings.Screen.Width, e.Settings.Screen.Height
}
func (e *Engine) ScreenTypeIs(name string) bool {
return e.KContext.Screen.Type == name
}
func (e *Engine) Update(screen *ebiten.Image) error {
e.WatchKeyPress()
if e.ScreenTypeIs("menu") {
if e.KContext.ScreenTypeIs("menu") {
e.MenuUpdate()
}
if e.ScreenTypeIs("dialog") {
if e.KContext.ScreenTypeIs("dialog") {
e.DialogUpdate()
}
if e.ScreenTypeIs("playground") {
if e.KContext.ScreenTypeIs("playground") {
e.PlaygroundUpdate()
}
return nil
}
func (e *Engine) Draw(screen *ebiten.Image) {
if e.ScreenTypeIs("menu") {
if e.KContext.ScreenTypeIs("menu") {
e.MenuDraw(screen)
}
if e.ScreenTypeIs("dialog") {
if e.KContext.ScreenTypeIs("dialog") {
e.DialogDraw(screen)
}
if e.ScreenTypeIs("playground") {
if e.KContext.ScreenTypeIs("playground") {
e.PlaygroundDraw(screen)
}
if e.Action3Pressed() {

View File

@@ -6,7 +6,7 @@ import (
)
func (e *Engine) DialogDraw(screen *ebiten.Image) {
dialog := e.Domain.GetDialog(e.KContext.Screen.Value)
dialog := e.Domain.GetDialog(e.KContext.ScreenValue)
face := GetFontFace(dialog.Layout.ChoiceFont)
@@ -17,7 +17,7 @@ func (e *Engine) DialogDraw(screen *ebiten.Image) {
}
func (e *Engine) DialogUpdate() {
dialog := e.Domain.GetDialog(e.KContext.Screen.Value)
dialog := e.Domain.GetDialog(e.KContext.ScreenValue)
if e.UpPressed() && dialog.CurrentSelected != 0 {
dialog.CurrentSelected--
@@ -30,5 +30,5 @@ func (e *Engine) DialogUpdate() {
if e.Action0Pressed() {
dialog.Choices[dialog.CurrentSelected].Handler()
}
e.Domain.SetDialog(e.KContext.Screen.Value, dialog)
e.Domain.SetDialog(e.KContext.ScreenValue, dialog)
}

View File

@@ -6,7 +6,7 @@ import (
)
func (e *Engine) MenuDraw(screen *ebiten.Image) {
menu := e.Domain.GetMenu(e.KContext.Screen.Value)
menu := e.Domain.GetMenu(e.KContext.ScreenValue)
face := GetFontFace(menu.Layout.MenuItemFont)
for i, menu_item := range menu.MenuItems {
@@ -17,7 +17,7 @@ func (e *Engine) MenuDraw(screen *ebiten.Image) {
}
func (e *Engine) MenuUpdate() {
menu := e.Domain.GetMenu(e.KContext.Screen.Value)
menu := e.Domain.GetMenu(e.KContext.ScreenValue)
if e.UpPressed() && menu.CurrentSelected != 0 {
menu.CurrentSelected--
@@ -31,5 +31,5 @@ func (e *Engine) MenuUpdate() {
menu.MenuItems[menu.CurrentSelected].Handler()
}
e.Domain.SetMenu(e.KContext.Screen.Value, menu)
e.Domain.SetMenu(e.KContext.ScreenValue, menu)
}