Added tooltips when planting flowers.
This commit is contained in:
parent
ef6a60e155
commit
064ec4619d
7
game.go
7
game.go
@ -261,7 +261,12 @@ func (g *Game) TogglePause(ctx ui.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) Tool() Tool { return g.tool }
|
func (g *Game) Tool() Tool {
|
||||||
|
if g.tool == nil {
|
||||||
|
return &NoTool{}
|
||||||
|
}
|
||||||
|
return g.tool
|
||||||
|
}
|
||||||
|
|
||||||
func (g *Game) ToolChanged() ui.EventHandler { return &g.toolChanged }
|
func (g *Game) ToolChanged() ui.EventHandler { return &g.toolChanged }
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ func (c *GameControls) Handle(ctx ui.Context, event ui.Event) bool {
|
|||||||
case ui.KeyR:
|
case ui.KeyR:
|
||||||
c.dialogs.ShowResearch(ctx)
|
c.dialogs.ShowResearch(ctx)
|
||||||
case ui.KeyEscape:
|
case ui.KeyEscape:
|
||||||
if c.game.Tool() == nil {
|
if c.game.Tool().Type() == "none" {
|
||||||
c.dialogs.ShowIntro(ctx)
|
c.dialogs.ShowIntro(ctx)
|
||||||
} else {
|
} else {
|
||||||
c.game.CancelTool(ctx)
|
c.game.CancelTool(ctx)
|
||||||
|
@ -31,7 +31,7 @@ func (h *Herbarium) Reset() {
|
|||||||
})
|
})
|
||||||
h.Add("loosestrife", FlowerDescriptor{
|
h.Add("loosestrife", FlowerDescriptor{
|
||||||
Name: "Loosestrife",
|
Name: "Loosestrife",
|
||||||
Description: "A simple flower that will spread in temperate and wet climates.",
|
Description: "A simple flower that will spread in temperate and damp climates.",
|
||||||
IconTemplate: "flower-loosestrife-%s",
|
IconTemplate: "flower-loosestrife-%s",
|
||||||
BuyPrice: 100,
|
BuyPrice: 100,
|
||||||
SellPrice: 20,
|
SellPrice: 20,
|
||||||
|
@ -106,6 +106,41 @@ func (r *terrainRenderer) Handle(ctx ui.Context, event ui.Event) bool {
|
|||||||
r.isometric.PanTile(geom.PtF32(1, -1))
|
r.isometric.PanTile(geom.PtF32(1, -1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if r.hover != nil && r.game.Tool().Type() == "plant-flower" {
|
||||||
|
terrain := r.game.Terrain
|
||||||
|
temp := func() string {
|
||||||
|
temp := terrain.Temp.Value(r.hover.X, r.hover.Y)
|
||||||
|
switch {
|
||||||
|
case temp < .3:
|
||||||
|
return "very cold"
|
||||||
|
case temp < .4:
|
||||||
|
return "cold"
|
||||||
|
case temp > .7:
|
||||||
|
return "very hot"
|
||||||
|
case temp > .6:
|
||||||
|
return "hot"
|
||||||
|
default:
|
||||||
|
return "moderate"
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
humid := func() string {
|
||||||
|
humid := terrain.Humid.Value(r.hover.X, r.hover.Y)
|
||||||
|
switch {
|
||||||
|
case humid < .3:
|
||||||
|
return " and very arid"
|
||||||
|
case humid < .4:
|
||||||
|
return " and arid"
|
||||||
|
case humid > .7:
|
||||||
|
return " and very damp"
|
||||||
|
case humid > .6:
|
||||||
|
return " and damp"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
ctx.ShowTooltip(fmt.Sprintf("It is %s%s over here", temp, humid))
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
tools.go
6
tools.go
@ -17,6 +17,12 @@ func (t *PlantFlowerTool) ClickedTile(game *Game, tile geom.Point) {
|
|||||||
game.PlantFlower(t.FlowerID, tile)
|
game.PlantFlower(t.FlowerID, tile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NoTool struct{}
|
||||||
|
|
||||||
|
func (t *NoTool) Type() string { return "none" }
|
||||||
|
|
||||||
|
func (t *NoTool) ClickedTile(*Game, geom.Point) {}
|
||||||
|
|
||||||
type ShovelTool struct{}
|
type ShovelTool struct{}
|
||||||
|
|
||||||
func (t *ShovelTool) Type() string { return "shovel" }
|
func (t *ShovelTool) Type() string { return "shovel" }
|
||||||
|
Loading…
Reference in New Issue
Block a user