move menu color to layout
This commit is contained in:
@@ -16,6 +16,8 @@ type MenuLayout struct {
|
|||||||
Background string
|
Background string
|
||||||
DPI float64
|
DPI float64
|
||||||
Size float64
|
Size float64
|
||||||
|
Color color.Color
|
||||||
|
SelectedColor color.Color
|
||||||
}
|
}
|
||||||
|
|
||||||
type MenuItem struct {
|
type MenuItem struct {
|
||||||
@@ -37,24 +39,26 @@ func (e *Engine) MenuDraw(screen *ebiten.Image) {
|
|||||||
for i, menu_item := range menu.MenuItems {
|
for i, menu_item := range menu.MenuItems {
|
||||||
var c color.Color
|
var c color.Color
|
||||||
if menu.CurrentSelected == i {
|
if menu.CurrentSelected == i {
|
||||||
c = color.RGBA{R: 0, G: 255, B: 0, A: 100}
|
c = menu.MenuLayout.SelectedColor
|
||||||
} else {
|
} else {
|
||||||
c = color.White
|
c = menu.MenuLayout.Color
|
||||||
}
|
}
|
||||||
text.Draw(screen, menu_item.Label+"\n", face, 8, 24*(i+1), c)
|
offset := int(menu.MenuLayout.Size) * (i + 1)
|
||||||
|
text.Draw(screen, menu_item.Label+"\n", face, 8, offset, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) MenuUpdate() {
|
func (e *Engine) MenuUpdate() {
|
||||||
menu := e.MenuMap[e.KContext.Screen.Value]
|
menu := e.MenuMap[e.KContext.Screen.Value]
|
||||||
if e.Controller.DownPressed() && menu.CurrentSelected != len(menu.MenuItems)-1 {
|
|
||||||
menu.CurrentSelected++
|
|
||||||
}
|
|
||||||
|
|
||||||
if e.Controller.UpPressed() && menu.CurrentSelected != 0 {
|
if e.Controller.UpPressed() && menu.CurrentSelected != 0 {
|
||||||
menu.CurrentSelected--
|
menu.CurrentSelected--
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if e.Controller.DownPressed() && menu.CurrentSelected != len(menu.MenuItems)-1 {
|
||||||
|
menu.CurrentSelected++
|
||||||
|
}
|
||||||
|
|
||||||
if e.Controller.Action0Pressed() {
|
if e.Controller.Action0Pressed() {
|
||||||
menu.MenuItems[menu.CurrentSelected].Handler()
|
menu.MenuItems[menu.CurrentSelected].Handler()
|
||||||
}
|
}
|
||||||
|
|||||||
5
main.go
5
main.go
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"game/domain"
|
"game/domain"
|
||||||
"game/konstructor"
|
"game/konstructor"
|
||||||
|
"image/color"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten"
|
"github.com/hajimehoshi/ebiten"
|
||||||
)
|
)
|
||||||
@@ -34,6 +35,8 @@ func main() {
|
|||||||
MenuLayout: konstructor.MenuLayout{
|
MenuLayout: konstructor.MenuLayout{
|
||||||
DPI: 72,
|
DPI: 72,
|
||||||
Size: 24,
|
Size: 24,
|
||||||
|
Color: color.White,
|
||||||
|
SelectedColor: color.RGBA{R: 0, G: 255, B: 0, A: 100},
|
||||||
},
|
},
|
||||||
MenuItems: []konstructor.MenuItem{
|
MenuItems: []konstructor.MenuItem{
|
||||||
{
|
{
|
||||||
@@ -58,6 +61,8 @@ func main() {
|
|||||||
MenuLayout: konstructor.MenuLayout{
|
MenuLayout: konstructor.MenuLayout{
|
||||||
DPI: 72,
|
DPI: 72,
|
||||||
Size: 24,
|
Size: 24,
|
||||||
|
Color: color.White,
|
||||||
|
SelectedColor: color.RGBA{R: 0, G: 255, B: 0, A: 100},
|
||||||
},
|
},
|
||||||
MenuItems: []konstructor.MenuItem{
|
MenuItems: []konstructor.MenuItem{
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user