diff options
-rw-r--r-- | README.markdown | 27 | ||||
-rw-r--r-- | main.go | 4 | ||||
-rw-r--r-- | mapwidget.go | 41 | ||||
-rw-r--r-- | region_wrapper.go | 16 |
4 files changed, 44 insertions, 44 deletions
diff --git a/README.markdown b/README.markdown index 15b33d8..dda5a90 100644 --- a/README.markdown +++ b/README.markdown @@ -18,16 +18,35 @@ If you are done, click `File > Save`. ## WARNING -Although everythung seems to work, please make a backup of your maps, just in case. +Although everything seems to work, please make a backup of your maps, just in case. + +## Precompiled versions + +* Linux (64bit): [biomed-linux64.tar.bz2](http://kch42.de/progs/biomed/biomed-linux64.tar.bz2) +* Windows (32bit, tested with Win8): [biomed-win32.zip](biomed-win32.zip) ## Dependencies / System Requirements -biomed works good on Linux. It also should work on Windows and Mac OSX. I currently try to compile it for Windows. Since I do not own a Mac, I can't compile / test for OSX. +You need a recent version of GTK 2.x. If you are on Linux, you probably already have it installed (if not, you should be able to find it in your package manager). For Windows you need the [GTK all in one bundle](http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip), unpack all `*.dll` files from the `bin` directory in the directory that contains `biomed.exe`. -You need a recent version of GTK 2.x. If you are on Linux, you probably already +biomed works on Linux and Windows. It also should work on Mac OSX, but since I do not own a Mac, I can't test it. ## Compiling -You will need Go (1.1 or greater) and the development files for GTK 2.x. +### Linux + +You will need Go (1.1 or greater) and the development files for GTK 2.x. Both should be available from your package manager. + +Create a directory that contains the directories `bin`, `src` and `pkg` and set the `GOPATH` environment variable to that directory. + +Then compiling is done by running: `go get github.com/kch42/biomed` + +### Windows + +Install Go (1.1 or greater) from [golang.org](http://golang.org/doc/install). + +Create a directory that contains the directories `bin`, `src` and `pkg` and set the `GOPATH` environment variable to that directory. + +Follow these instructions for installing go-gtk: [http://stackoverflow.com/questions/16999498/how-to-set-up-gtk-for-go/17042596#17042596](http://stackoverflow.com/questions/16999498/how-to-set-up-gtk-for-go/17042596#17042596) Then compiling is done by running: `go get github.com/kch42/biomed` @@ -135,7 +135,7 @@ func (g *GUI) mkMenuBar() *gtk.MenuBar { } func (g *GUI) betaWarning() { - dlg := gtk.NewMessageDialog(g.window, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "This software is currently in beta.\nAlthough everythung seems to work, you should make a backup of your maps, just in case!") + dlg := gtk.NewMessageDialog(g.window, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "This software is currently in beta.\nAlthough everything seems to work, you should make a backup of your maps, just in case!") dlg.Run() dlg.Destroy() } @@ -198,7 +198,7 @@ func (g *GUI) mkSidebar() *gtk.ScrolledWindow { drawHBox.PackStart(draw, true, true, 0) drawHBox.PackStart(gtk.NewLabel("Radius:"), false, false, 3) drawHBox.PackEnd(drawRadius, false, false, 3) - draw.Connect("toggled", g.mkUpdateToolFx(draw, NewDrawTool(func() int { return int(drawRadius.GetValue()) }))) + draw.Connect("toggled", g.mkUpdateToolFx(draw, NewDrawTool(func() int { return drawRadius.GetValueAsInt() }))) vbox.PackStart(fill, false, false, 3) vbox.PackStart(drawHBox, false, false, 3) diff --git a/mapwidget.go b/mapwidget.go index e9cd97c..cb8c874 100644 --- a/mapwidget.go +++ b/mapwidget.go @@ -41,8 +41,6 @@ type MapWidget struct { bg *gdk.Pixmap regWrap *RegionWrapper - - redraw chan bool } func (mw *MapWidget) calcChunkRect() { @@ -53,7 +51,7 @@ func (mw *MapWidget) DArea() *gtk.DrawingArea { return mw.dArea } func (mw *MapWidget) SetShowBiomes(b bool) { mw.showBiomes = b - mw.redraw <- true + mw.updateGUI() } func (mw *MapWidget) SetFixSnowIce(b bool) { mw.regWrap.SetFixSnowIce(b) } @@ -98,18 +96,14 @@ func (mw *MapWidget) movement(ctx *glib.CallbackContext) { mw.offX += mw.mx1 - mw.mx2 mw.offZ += mw.my1 - mw.my2 - gdk.ThreadsLeave() - mw.redraw <- true - gdk.ThreadsEnter() + mw.updateGUI() } } if mw.continueTool { mw.regWrap.UseTool(x, z) - gdk.ThreadsLeave() - mw.redraw <- true - gdk.ThreadsEnter() + mw.updateGUI() } mw.mx1, mw.my1 = mw.mx2, mw.my2 @@ -142,9 +136,7 @@ func (mw *MapWidget) buttonChanged(ctx *glib.CallbackContext) { z := (mw.offZ + int(bev.Y)) / zoom mw.regWrap.UseTool(x, z) - gdk.ThreadsLeave() - mw.redraw <- true - gdk.ThreadsEnter() + mw.updateGUI() if !mw.regWrap.ToolSingleClick() { mw.continueTool = true @@ -196,17 +188,16 @@ func (mw *MapWidget) configure() { if !mw.isInit { mw.offX = -(mw.w / 2) mw.offZ = -(mw.h / 2) - mw.updateChunkBounds() mw.isInit = true } + mw.updateChunkBounds() + mw.pixmap = gdk.NewPixmap(mw.dArea.GetWindow().GetDrawable(), mw.w, mw.h, 24) mw.pixmapGC = gdk.NewGC(mw.pixmap.GetDrawable()) mw.drawBg() - gdk.ThreadsLeave() - mw.redraw <- true - gdk.ThreadsEnter() + mw.updateGUI() } func (mw *MapWidget) compose() { @@ -234,30 +225,24 @@ func (mw *MapWidget) expose() { mw.dArea.GetWindow().GetDrawable().DrawDrawable(mw.pixmapGC, mw.pixmap.GetDrawable(), 0, 0, 0, 0, -1, -1) } -func (mw *MapWidget) guiUpdater() { - for _ = range mw.redraw { - gdk.ThreadsEnter() - mw.compose() - mw.expose() - mw.dArea.GetWindow().Invalidate(nil, false) - gdk.ThreadsLeave() - } +func (mw *MapWidget) updateGUI() { + mw.compose() + mw.expose() + mw.dArea.GetWindow().Invalidate(nil, false) } func NewMapWidget(guicbs GUICallbacks) *MapWidget { dArea := gtk.NewDrawingArea() - redraw := make(chan bool) mw := &MapWidget{ dArea: dArea, guicbs: guicbs, - redraw: redraw, showBiomes: true, - regWrap: NewRegionWrapper(redraw, guicbs), mx1: -1, my1: -1, } - go mw.guiUpdater() + + mw.regWrap = NewRegionWrapper(mw.updateGUI, guicbs) dArea.Connect("configure-event", mw.configure) dArea.Connect("expose-event", mw.expose) diff --git a/region_wrapper.go b/region_wrapper.go index 1139de5..a56f8dd 100644 --- a/region_wrapper.go +++ b/region_wrapper.go @@ -17,7 +17,7 @@ type RegionWrapper struct { Biotiles map[XZPos]*gdk.Pixmap bioCache map[XZPos][]mcmap.Biome - redraw chan<- bool + redraw func() guicbs GUICallbacks toolsEnabled bool @@ -118,9 +118,7 @@ func (rw *RegionWrapper) tileUpdater() { rw.Maptiles[pos], rw.Biotiles[pos], rw.bioCache[pos] = renderTile(chunk) chunk.MarkUnused() - gdk.ThreadsLeave() - rw.redraw <- true - gdk.ThreadsEnter() + rw.redraw() } } } @@ -158,14 +156,12 @@ func (rw *RegionWrapper) flushTiles() { return } - gdk.ThreadsEnter() for _, mt := range rw.Maptiles { mt.Unref() } for _, bt := range rw.Biotiles { bt.Unref() } - gdk.ThreadsLeave() rw.Maptiles = make(map[XZPos]*gdk.Pixmap) rw.Biotiles = make(map[XZPos]*gdk.Pixmap) @@ -173,9 +169,7 @@ func (rw *RegionWrapper) flushTiles() { } func (rw *RegionWrapper) Save() { - gdk.ThreadsLeave() rw.flushTiles() - gdk.ThreadsEnter() if err := rw.region.Flush(); err != nil { rw.guicbs.reportFail(fmt.Sprintf("Error while flushing cache: %s", err)) @@ -204,7 +198,9 @@ func (rw *RegionWrapper) UseTool(x, z int) { rw.guicbs.setBusy(false) rw.toolsEnabled = true - rw.redraw <- true + gdk.ThreadsEnter() + rw.redraw() + gdk.ThreadsLeave() }() } else { rw.tool.Do(rw.bio, rw, x, z) @@ -348,7 +344,7 @@ func (rw *RegionWrapper) UpdateTiles() { rw.tileUpdates <- true } -func NewRegionWrapper(redraw chan<- bool, guicbs GUICallbacks) *RegionWrapper { +func NewRegionWrapper(redraw func(), guicbs GUICallbacks) *RegionWrapper { rw := &RegionWrapper{ redraw: redraw, tileUpdates: make(chan bool), |