MCPcopy Create free account
hub / github.com/SolarLune/masterplan / Update

Method Update

gui.go:802–843  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

800}
801
802func (button *Button) Update() {
803
804 mousePos := globals.Mouse.Position()
805
806 if button.WorldSpace {
807 mousePos = globals.Mouse.WorldPosition()
808 }
809
810 alphaTarget := float32(1)
811 lineTarget := float32(1)
812
813 buttonRect := button.Rectangle()
814
815 if mousePos.Inside(buttonRect) && !button.Disabled && (globals.Mouse.CurrentCursor == CursorNormal || globals.State == StateCardLink) {
816
817 if globals.Mouse.Button(sdl.BUTTON_LEFT).Pressed() && (globals.State == StateNeutral || globals.State == StateCardLink || globals.State == StateContextMenu || globals.State == StateMapEditing || globals.State == StateTextEditing) {
818 if button.OnPressed != nil {
819
820 PlayUISound(UISoundTypeTap)
821
822 globals.Mouse.Button(sdl.BUTTON_LEFT).Consume()
823 button.OnPressed()
824 }
825 }
826
827 } else if button.FadeOnInactive {
828 alphaTarget = 0.7
829 lineTarget = 0
830 }
831
832 if button.Disabled {
833 alphaTarget = 0.3
834 }
835
836 button.Label.Alpha += ((alphaTarget - button.Label.Alpha) * 0.1)
837 button.LineWidth += (lineTarget - button.LineWidth) * 0.2
838
839 if len(button.Label.Text) > 0 {
840 button.Label.Update()
841 }
842
843}
844
845func (button *Button) Draw() {
846

Callers

nothing calls this directly

Calls 9

RectangleMethod · 0.95
PlayUISoundFunction · 0.85
WorldPositionMethod · 0.80
InsideMethod · 0.80
ButtonMethod · 0.80
ConsumeMethod · 0.80
UpdateMethod · 0.65
PositionMethod · 0.45
PressedMethod · 0.45

Tested by

no test coverage detected