Compare commits

..

3 Commits

7 changed files with 52 additions and 6 deletions

View File

@ -64,8 +64,8 @@ func NewConeflowerTraits() FlowerTraits {
Spread: 0.0005, Spread: 0.0005,
Life: 0.99993, Life: 0.99993,
Resistance: FlowerResistance{ Resistance: FlowerResistance{
Cold: 0.7, Cold: 0.6,
Hot: 0.8, Hot: 0.9,
Dry: 0.8, Dry: 0.8,
Wet: 0.5, Wet: 0.5,
}, },

View File

@ -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 }

View File

@ -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)

View File

@ -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,

View File

@ -41,7 +41,7 @@ func (b *IconButton) Render(ctx ui.Context) {
} }
func (b *IconButton) RenderActive(ctx ui.Context) { func (b *IconButton) RenderActive(ctx ui.Context) {
if b.Active && !b.Disabled && !b.IsOver() { if b.Active || (!b.Disabled && b.IsOver()) {
ctx.Renderer().FillRectangle(b.Bounds(), hoverTransparentColor) ctx.Renderer().FillRectangle(b.Bounds(), hoverTransparentColor)
} }
} }

View File

@ -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
} }

View File

@ -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" }