GetMenu, SetMenu

This commit is contained in:
2023-07-04 20:10:14 +02:00
parent 1451bd90c0
commit 74272c09f2
6 changed files with 82 additions and 69 deletions

View File

@@ -7,9 +7,11 @@ import (
type Domain struct {
Context Context
MenuMap konstructor.MenuMap
}
func (d *Domain) Init() {
d.InitMenu()
}
func (d *Domain) GetDialog() konstructor.Dialog {

View File

@@ -2,9 +2,76 @@ package domain
import (
"fmt"
"game/konstructor"
"image/color"
"os"
)
func (d *Domain) InitMenu() {
d.MenuMap = konstructor.MenuMap{
"MainMenu": {
CurrentSelected: 0,
Layout: konstructor.MenuLayout{
MenuItemFont: konstructor.FontLayout{
DPI: 72,
Size: 24,
Color: color.White,
SelectedColor: color.RGBA{R: 0, G: 255, B: 0, A: 100},
},
},
MenuItems: []konstructor.MenuItem{
{
ID: "start",
Label: "Start Game",
Handler: d.StartGame,
},
{
ID: "load",
Label: "Load Game",
Handler: d.LoadtGame,
},
{
ID: "exit",
Label: "Exit Game",
Handler: d.ExitGame,
},
},
},
"GameMenu": {
CurrentSelected: 0,
Layout: konstructor.MenuLayout{
MenuItemFont: konstructor.FontLayout{
DPI: 72,
Size: 24,
Color: color.White,
SelectedColor: color.RGBA{R: 0, G: 255, B: 0, A: 100},
},
},
MenuItems: []konstructor.MenuItem{
{
ID: "save",
Label: "Save Game",
Handler: d.SaveGame,
},
{
ID: "close",
Label: "Close Game",
Handler: d.CloseGame,
},
},
},
}
}
func (d *Domain) GetMenu(name string) konstructor.Menu {
value, _ := d.MenuMap[name]
return value
}
func (d *Domain) SetMenu(name string, menu konstructor.Menu) {
d.MenuMap[name] = menu
}
func (d *Domain) CloseGame() {
fmt.Println("Close game")
}