Cursor changes when tool is selected.

This commit is contained in:
Sander Schobers 2020-05-23 16:03:18 +02:00
parent 2f5f682a59
commit 820d0f109a

View File

@ -107,39 +107,45 @@ func (r *terrainRenderer) Handle(ctx ui.Context, event ui.Event) bool {
} }
} }
if r.hover != nil && r.game.Tool().Type() == "plant-flower" { tool := r.game.Tool().Type()
terrain := r.game.Terrain if r.hover != nil {
temp := func() string { if tool != "none" {
temp := terrain.Temp.Value(r.hover.X, r.hover.Y) ctx.Renderer().SetMouseCursor(ui.MouseCursorPointer)
switch { }
case temp < .3: if tool == "plant-flower" {
return "very cold" terrain := r.game.Terrain
case temp < .4: temp := func() string {
return "cold" temp := terrain.Temp.Value(r.hover.X, r.hover.Y)
case temp > .7: switch {
return "very hot" case temp < .3:
case temp > .6: return "very cold"
return "hot" case temp < .4:
default: return "cold"
return "moderate" case temp > .7:
} return "very hot"
}() case temp > .6:
humid := func() string { return "hot"
humid := terrain.Humid.Value(r.hover.X, r.hover.Y) default:
switch { return "moderate"
case humid < .3: }
return " and very arid" }()
case humid < .4: humid := func() string {
return " and arid" humid := terrain.Humid.Value(r.hover.X, r.hover.Y)
case humid > .7: switch {
return " and very damp" case humid < .3:
case humid > .6: return " and very arid"
return " and damp" case humid < .4:
default: return " and arid"
return "" case humid > .7:
} return " and very damp"
}() case humid > .6:
ctx.ShowTooltip(fmt.Sprintf("It is %s%s over here", temp, humid)) return " and damp"
default:
return ""
}
}()
ctx.ShowTooltip(fmt.Sprintf("It is %s%s over here", temp, humid))
}
} }
return false return false
} }