summaryrefslogtreecommitdiff
path: root/mapwidget.go
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2013-11-06 23:15:51 +0100
committerKevin Chabowski <kevin@kch42.de>2013-11-06 23:15:51 +0100
commit291506b5ed49ffbefd9046a9c9f5a297f3e198ab (patch)
tree63060f6cf67f8bb0d45acc995a95dd0f516609d5 /mapwidget.go
parent8150778cbdf2e2f72d300a548c669b07b6e98d0c (diff)
downloadbiomed-291506b5ed49ffbefd9046a9c9f5a297f3e198ab.tar.gz
biomed-291506b5ed49ffbefd9046a9c9f5a297f3e198ab.tar.bz2
biomed-291506b5ed49ffbefd9046a9c9f5a297f3e198ab.zip
Worlds are now opened by their level.dat and are centered properly.
The world spawn will be read from the level.dat and the view will be centered to that position.
Diffstat (limited to 'mapwidget.go')
-rw-r--r--mapwidget.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/mapwidget.go b/mapwidget.go
index e04b5eb..8fc2b71 100644
--- a/mapwidget.go
+++ b/mapwidget.go
@@ -63,6 +63,12 @@ func (mw *MapWidget) SetTool(t Tool) { mw.regWrap.SetTool(t) }
func (mw *MapWidget) Save() { mw.regWrap.Save() }
+func (mw *MapWidget) SetCenter(x, z int) {
+ mw.offX = x*zoom - mw.w/2
+ mw.offZ = z*zoom - mw.h/2
+ mw.updateChunkBounds()
+}
+
func (mw *MapWidget) updateChunkBounds() {
startX := int(math.Floor(float64(mw.offX) / tileSize))
startZ := int(math.Floor(float64(mw.offZ) / tileSize))