GetMenu, SetMenu
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user