GetMenu, SetMenu
This commit is contained in:
@@ -11,7 +11,6 @@ type Engine struct {
|
||||
Controller *Controller
|
||||
Settings *Settings
|
||||
KContext *KContext
|
||||
MenuMap MenuMap
|
||||
}
|
||||
|
||||
func (e *Engine) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
|
||||
@@ -11,6 +11,8 @@ type ContextInterface interface {
|
||||
|
||||
type DomainInterface interface {
|
||||
Init()
|
||||
GetMenu(name string) Menu
|
||||
SetMenu(name string, menu Menu)
|
||||
GetDialog() Dialog
|
||||
}
|
||||
|
||||
@@ -29,7 +31,6 @@ type Konstructor struct {
|
||||
Controller *Controller
|
||||
Settings *Settings
|
||||
KContext *KContext
|
||||
MenuMap MenuMap
|
||||
}
|
||||
|
||||
func (k Konstructor) Init() {
|
||||
@@ -37,7 +38,6 @@ func (k Konstructor) Init() {
|
||||
ebiten.SetWindowSize(k.Settings.Screen.Width, k.Settings.Screen.Height)
|
||||
ebiten.SetWindowTitle(k.Settings.Name)
|
||||
if err := ebiten.RunGame(&Engine{
|
||||
MenuMap: k.MenuMap,
|
||||
KContext: k.KContext,
|
||||
Domain: k.Domain,
|
||||
Controller: k.Controller,
|
||||
|
||||
@@ -35,7 +35,7 @@ func (menu *Menu) GetMenuItemColor(i int) color.Color {
|
||||
}
|
||||
|
||||
func (e *Engine) MenuDraw(screen *ebiten.Image) {
|
||||
menu := e.MenuMap[e.KContext.Screen.Value]
|
||||
menu := e.Domain.GetMenu(e.KContext.Screen.Value)
|
||||
face := GetFontFace(menu.Layout.MenuItemFont)
|
||||
|
||||
for i, menu_item := range menu.MenuItems {
|
||||
@@ -46,7 +46,7 @@ func (e *Engine) MenuDraw(screen *ebiten.Image) {
|
||||
}
|
||||
|
||||
func (e *Engine) MenuUpdate() {
|
||||
menu := e.MenuMap[e.KContext.Screen.Value]
|
||||
menu := e.Domain.GetMenu(e.KContext.Screen.Value)
|
||||
|
||||
if e.Controller.UpPressed() && menu.CurrentSelected != 0 {
|
||||
menu.CurrentSelected--
|
||||
@@ -60,5 +60,5 @@ func (e *Engine) MenuUpdate() {
|
||||
menu.MenuItems[menu.CurrentSelected].Handler()
|
||||
}
|
||||
|
||||
e.MenuMap[e.KContext.Screen.Value] = menu
|
||||
e.Domain.SetMenu(e.KContext.Screen.Value, menu)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user