Compare commits

..

No commits in common. "ee7f99166c5626dac11bf85e420b1f83ba395778" and "1008b7b34bad0b9ace53d88a679d64ee643d2e47" have entirely different histories.

5 changed files with 5 additions and 26 deletions

View File

@ -11,14 +11,6 @@ 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) {

View File

@ -22,7 +22,6 @@ func EmptyEvent(fn EventFn) EventContextFn {
type ControlBase struct {
Bounds Rectangle
IsDisabled bool
IsMouseOver bool
OnLeftMouseButtonClick EventContextFn
@ -37,7 +36,7 @@ func (b *ControlBase) Handle(ctx *Context, event sdl.Event) bool {
case *sdl.MouseMotionEvent:
b.IsMouseOver = b.Bounds.IsPointInside(e.X, e.Y)
case *sdl.MouseButtonEvent:
if !b.IsDisabled && b.IsMouseOver && e.Button == sdl.BUTTON_LEFT && e.Type == sdl.MOUSEBUTTONDOWN {
if b.IsMouseOver && e.Button == sdl.BUTTON_LEFT && e.Type == sdl.MOUSEBUTTONDOWN {
return b.Invoke(ctx, b.OnLeftMouseButtonClick)
}
case *sdl.WindowEvent:

View File

@ -120,10 +120,7 @@ func (c *GameControls) Init(ctx *Context) error {
c.menu.Background = MustHexColor("#356dad")
c.menu.Buttons = []Control{
NewIconButtonConfig("control-settings", c.dialogs.ShowSettings, func(b *IconButton) {
b.IsDisabled = true
b.IconDisabled = "#afafaf"
}),
NewIconButton("control-settings", c.dialogs.ShowSettings),
NewIconButton("control-save", func(*Context) { c.game.Save() }),
NewIconButton("control-load", func(ctx *Context) {
c.game.Load()

View File

@ -20,6 +20,7 @@ type IconButton struct {
IconHover HoverEffect
IsActive bool
IsDisabled bool
}
func NewIconButton(icon string, onClick EventContextFn) *IconButton {
@ -43,16 +44,6 @@ 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)
}

View File

@ -34,7 +34,7 @@ func (r *terrainRenderer) Init(ctx *Context) error {
func isControlKeyDown() bool {
state := sdl.GetKeyboardState()
return state[sdl.SCANCODE_LCTRL] == 1 || state[sdl.SCANCODE_RCTRL] == 1 || state[sdl.SCANCODE_LGUI] == 1 || state[sdl.SCANCODE_RGUI] == 1
return state[sdl.SCANCODE_LCTRL] == 1 || state[sdl.SCANCODE_RCTRL] == 1
}
func (r *terrainRenderer) Handle(ctx *Context, event sdl.Event) bool {