diff --git a/color.go b/color.go index fc953d1..a12f61e 100644 --- a/color.go +++ b/color.go @@ -11,6 +11,14 @@ var Transparent = sdl.Color{R: 0, G: 0, B: 0, A: 0} var TransparentWhite = sdl.Color{R: 255, G: 255, B: 255, A: 31} var White = sdl.Color{R: 255, G: 255, B: 255, A: 255} +func HexColor(s string) (sdl.Color, error) { + c, err := img.HexColor(s) + if err != nil { + return sdl.Color{}, err + } + return sdl.Color(c), nil +} + func MustHexColor(s string) sdl.Color { return sdl.Color(img.MustHexColor(s)) } func SetDrawColor(renderer *sdl.Renderer, color sdl.Color) { diff --git a/gamecontrols.go b/gamecontrols.go index 512ebe5..4294e0b 100644 --- a/gamecontrols.go +++ b/gamecontrols.go @@ -120,7 +120,10 @@ func (c *GameControls) Init(ctx *Context) error { c.menu.Background = MustHexColor("#356dad") c.menu.Buttons = []Control{ - NewIconButton("control-settings", c.dialogs.ShowSettings), + NewIconButtonConfig("control-settings", c.dialogs.ShowSettings, func(b *IconButton) { + b.IsDisabled = true + b.IconDisabled = "#afafaf" + }), NewIconButton("control-save", func(*Context) { c.game.Save() }), NewIconButton("control-load", func(ctx *Context) { c.game.Load() diff --git a/iconbutton.go b/iconbutton.go index 71f3768..6682ea3 100644 --- a/iconbutton.go +++ b/iconbutton.go @@ -43,6 +43,16 @@ func (b *IconButton) activeTexture(ctx *Context) *Texture { if texture != nil { return texture } + + texture = ctx.Textures.Texture(b.Icon) + if len(b.IconDisabled) == 0 { + return texture + } + color, err := HexColor(b.IconDisabled) + if err == nil { + texture.SetColor(color) + } + return texture } return ctx.Textures.Texture(b.Icon) }