From 63b964614135f6381b5d55828714efb3783dfd04 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Sat, 2 Nov 2013 14:47:26 +0100 Subject: New biome infos are now passed to mapwidget --- main.go | 6 +++--- mapwidget.go | 10 ++++++++++ region_wrapper.go | 8 ++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 288b59d..ba60c97 100644 --- a/main.go +++ b/main.go @@ -21,8 +21,8 @@ type GUI struct { statusContext uint lastStatus string - biomes []BiomeInfo - bioVBox *gtk.VBox + biomes []BiomeInfo + bioVBox *gtk.VBox bioVBoxWrap *gtk.VBox mapw *MapWidget @@ -246,7 +246,7 @@ func (g *GUI) updateBiomeInfo() { vbox.ShowAll() g.bioVBox = vbox - // TODO: Update mapwidget + g.mapw.updateBioLookup(MkBiomeLookup(g.biomes)) } func (g *GUI) Init() { diff --git a/mapwidget.go b/mapwidget.go index 116f069..e04b5eb 100644 --- a/mapwidget.go +++ b/mapwidget.go @@ -233,6 +233,16 @@ func (mw *MapWidget) updateGUI() { mw.dArea.GetWindow().Invalidate(nil, false) } +func (mw *MapWidget) updateBioLookup(lookup BiomeLookup) { + mw.bioLookup = lookup + mw.regWrap.bioLookup = lookup + + if mw.regWrap.RegionLoaded() { + mw.regWrap.FlushTiles() + mw.regWrap.UpdateTiles() + } +} + func NewMapWidget(guicbs GUICallbacks, bioLookup BiomeLookup) *MapWidget { dArea := gtk.NewDrawingArea() diff --git a/region_wrapper.go b/region_wrapper.go index 9a4d958..d27d1ad 100644 --- a/region_wrapper.go +++ b/region_wrapper.go @@ -131,11 +131,11 @@ func (rw *RegionWrapper) tileUpdater() { func (rw *RegionWrapper) SetRegion(region *mcmap.Region) { if rw.RegionLoaded() { - rw.flushTiles() + rw.FlushTiles() } rw.region = NewCachedRegion(region, cacheSize) - rw.tileUpdates <- true + rw.UpdateTiles() } func (rw *RegionWrapper) SetChunkBounds(startX, startZ, endX, endZ int) { @@ -152,7 +152,7 @@ func (rw *RegionWrapper) SetFixSnowIce(b bool) { rw.fixSnowIce = b } func (rw *RegionWrapper) RegionLoaded() bool { return rw.region != nil } func (rw *RegionWrapper) ToolSingleClick() bool { return rw.tool.SingleClick() } -func (rw *RegionWrapper) flushTiles() { +func (rw *RegionWrapper) FlushTiles() { if err := rw.region.Flush(); err != nil { rw.guicbs.reportFail(fmt.Sprintf("Error while flushing cache: %s", err)) return @@ -171,7 +171,7 @@ func (rw *RegionWrapper) flushTiles() { } func (rw *RegionWrapper) Save() { - rw.flushTiles() + rw.FlushTiles() if err := rw.region.Flush(); err != nil { rw.guicbs.reportFail(fmt.Sprintf("Error while flushing cache: %s", err)) -- cgit v1.2.3-70-g09d2