summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2013-08-16 20:03:21 +0200
committerKevin Chabowski <kevin@kch42.de>2013-08-16 20:03:21 +0200
commit2fbe2467aa907f323ce5fe7fa7f5ebc2ee93c8ba (patch)
treeb79908dd23b7406b1b3fc103f50dc296d1caa3ee
parent82a18a1cc4d5c8b1a4c3d030e5d617000a858246 (diff)
downloadbiomed-2fbe2467aa907f323ce5fe7fa7f5ebc2ee93c8ba.tar.gz
biomed-2fbe2467aa907f323ce5fe7fa7f5ebc2ee93c8ba.tar.bz2
biomed-2fbe2467aa907f323ce5fe7fa7f5ebc2ee93c8ba.zip
Enabled setting the Biome of the MapWidget
-rw-r--r--main.go2
-rw-r--r--mapwidget.go4
-rw-r--r--tools.go12
3 files changed, 11 insertions, 7 deletions
diff --git a/main.go b/main.go
index 04c2850..107ec8f 100644
--- a/main.go
+++ b/main.go
@@ -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() {
diff --git a/tools.go b/tools.go
index b75480f..11b6cef 100644
--- a/tools.go
+++ b/tools.go
@@ -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)