mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-07-26 11:24:38 -04:00
Red stamina bar (#809)
* Fixed a typo. Make stamina bar red wehan below 25% * make linter happy
This commit is contained in:
parent
bbc716f682
commit
bb9789d700
@ -43,7 +43,8 @@ const (
|
|||||||
globeHeight = 80
|
globeHeight = 80
|
||||||
globeWidth = 80
|
globeWidth = 80
|
||||||
hoverLabelOuterPad = 5
|
hoverLabelOuterPad = 5
|
||||||
mouseBtnActionsTreshhold = 0.25
|
mouseBtnActionsThreshold = 0.25
|
||||||
|
percentStaminaBarLow = 0.25
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -204,6 +205,7 @@ const (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
lightBrownAlpha72 = 0xaf8848c8
|
lightBrownAlpha72 = 0xaf8848c8
|
||||||
|
redAlpha72 = 0xff0000c8
|
||||||
whiteAlpha100 = 0xffffffff
|
whiteAlpha100 = 0xffffffff
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -658,8 +660,8 @@ func (g *GameControls) OnMouseButtonRepeat(event d2interface.MouseEvent) bool {
|
|||||||
lastLeft := now - g.lastLeftBtnActionTime
|
lastLeft := now - g.lastLeftBtnActionTime
|
||||||
lastRight := now - g.lastRightBtnActionTime
|
lastRight := now - g.lastRightBtnActionTime
|
||||||
inRect := !g.isInActiveMenusRect(event.X(), event.Y())
|
inRect := !g.isInActiveMenusRect(event.X(), event.Y())
|
||||||
shouldDoLeft := lastLeft >= mouseBtnActionsTreshhold
|
shouldDoLeft := lastLeft >= mouseBtnActionsThreshold
|
||||||
shouldDoRight := lastRight >= mouseBtnActionsTreshhold
|
shouldDoRight := lastRight >= mouseBtnActionsThreshold
|
||||||
|
|
||||||
if isLeft && shouldDoLeft && inRect && !g.hero.IsCasting() {
|
if isLeft && shouldDoLeft && inRect && !g.hero.IsCasting() {
|
||||||
g.lastLeftBtnActionTime = now
|
g.lastLeftBtnActionTime = now
|
||||||
@ -1079,6 +1081,10 @@ func (g *GameControls) renderHUD(target d2interface.Surface) error {
|
|||||||
staminaPercent := g.hero.Stats.Stamina / float64(g.hero.Stats.MaxStamina)
|
staminaPercent := g.hero.Stats.Stamina / float64(g.hero.Stats.MaxStamina)
|
||||||
|
|
||||||
staminaBarColor := d2util.Color(lightBrownAlpha72)
|
staminaBarColor := d2util.Color(lightBrownAlpha72)
|
||||||
|
if staminaPercent < percentStaminaBarLow {
|
||||||
|
staminaBarColor = d2util.Color(redAlpha72)
|
||||||
|
}
|
||||||
|
|
||||||
target.DrawRect(int(staminaPercent*staminaBarWidth), staminaBarHeight, staminaBarColor)
|
target.DrawRect(int(staminaPercent*staminaBarWidth), staminaBarHeight, staminaBarColor)
|
||||||
target.Pop()
|
target.Pop()
|
||||||
target.Pop()
|
target.Pop()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user