diff options
-rw-r--r-- | main.go | 2 | ||||
-rw-r--r-- | mapwidget.go | 4 | ||||
-rw-r--r-- | tools.go | 12 |
3 files changed, 11 insertions, 7 deletions
@@ -249,7 +249,7 @@ func (g *GUI) setTool(t Tool) { } func (g *GUI) setBiome(bio mcmap.Biome) { - fmt.Println(bio) + g.mapw.SetBiome(bio) } func (g *GUI) showbiomesToggled() { diff --git a/mapwidget.go b/mapwidget.go index cb6d3e1..a493c9a 100644 --- a/mapwidget.go +++ b/mapwidget.go @@ -112,6 +112,10 @@ func (mw *MapWidget) SetTool(t Tool) { mw.tool = t } +func (mw *MapWidget) SetBiome(bio mcmap.Biome) { + mw.bio = bio +} + func (mw *MapWidget) DArea() *gtk.DrawingArea { return mw.dArea } func (mw *MapWidget) doTileCmds() { @@ -5,8 +5,8 @@ import ( ) type BiomeGetSetter interface { - GetBiome(x, z int) (mcmap.Biome, bool) - SetBiome(x, z int, bio mcmap.Biome) + GetBiomeAt(x, z int) (mcmap.Biome, bool) + SetBiomeAt(x, z int, bio mcmap.Biome) } type XZPos struct { @@ -32,7 +32,7 @@ func (d *drawTool) Do(bio mcmap.Biome, biogs BiomeGetSetter, x, z int) { for xp := x - (rad - 1); xp < x+rad; xp++ { for zp := z - (rad - 1); zp < z+rad; zp++ { - biogs.SetBiome(xp, zp, bio) + biogs.SetBiomeAt(xp, zp, bio) } } } @@ -46,14 +46,14 @@ type fillTool struct{} func (f *fillTool) SingleClick() bool { return true } func (f *fillTool) Do(bio mcmap.Biome, biogs BiomeGetSetter, x, z int) { - if oldbio, ok := biogs.GetBiome(x, z); ok { + if oldbio, ok := biogs.GetBiomeAt(x, z); ok { floodfill(oldbio, bio, biogs, x, z) } } func floodfill(oldbio, newbio mcmap.Biome, biogs BiomeGetSetter, x, z int) { - if bio, ok := biogs.GetBiome(x, z); ok && (bio == oldbio) { - biogs.SetBiome(x, z, newbio) + if bio, ok := biogs.GetBiomeAt(x, z); ok && (bio == oldbio) { + biogs.SetBiomeAt(x, z, newbio) floodfill(oldbio, newbio, biogs, x-1, z) floodfill(oldbio, newbio, biogs, x+1, z) |