From 291506b5ed49ffbefd9046a9c9f5a297f3e198ab Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Wed, 6 Nov 2013 23:15:51 +0100 Subject: 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. --- mapwidget.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'mapwidget.go') 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)) -- cgit v1.2.3-54-g00ecf