mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-01-15 05:47:19 -05:00
783993470e
* fixed lint error in d2app/app.go * go fmt entire project * adding doc.go for d2records * fixed lint issues in d2core/d2map * fixed lint error in d2interface/palette.go * fixed lint error in d2core/d2hero/hero_state_factory.go * adding dov.go to d2common/d2geom * fixing lint errors in d2common/d2loader * adding doc.go to d2common/d2cache * adding doc files for d2datautils, d2util, d2path * adding package doc strings for mapgen, in-geam help screen, and tcp client connection * removed all cuddling lint errors * changed stamina equality check to '<=' instead of '<'
54 lines
936 B
Go
54 lines
936 B
Go
package d2gui
|
|
|
|
import (
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
|
)
|
|
|
|
type buttonState int
|
|
|
|
const (
|
|
buttonStateDefault buttonState = iota
|
|
buttonStatePressed
|
|
buttonStatePressedToggled
|
|
)
|
|
|
|
const (
|
|
grey = 0x404040ff
|
|
)
|
|
|
|
// Button is a user actionable drawable toggle switch
|
|
type Button struct {
|
|
widgetBase
|
|
|
|
width int
|
|
height int
|
|
state buttonState
|
|
surfaces []d2interface.Surface
|
|
}
|
|
|
|
func (b *Button) onMouseButtonDown(_ d2interface.MouseEvent) bool {
|
|
b.state = buttonStatePressed
|
|
|
|
return false
|
|
}
|
|
|
|
func (b *Button) onMouseButtonUp(_ d2interface.MouseEvent) bool {
|
|
b.state = buttonStateDefault
|
|
|
|
return false
|
|
}
|
|
|
|
func (b *Button) onMouseLeave(_ d2interface.MouseMoveEvent) bool {
|
|
b.state = buttonStateDefault
|
|
|
|
return false
|
|
}
|
|
|
|
func (b *Button) render(target d2interface.Surface) error {
|
|
return target.Render(b.surfaces[b.state])
|
|
}
|
|
|
|
func (b *Button) getSize() (width, height int) {
|
|
return b.width, b.height
|
|
}
|