diff options
author | Kevin Chabowski <kevin@kch42.de> | 2013-08-17 22:29:42 +0200 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2013-08-17 22:29:42 +0200 |
commit | c15c92e507f37a476b29f391564b760c38f538a9 (patch) | |
tree | 280141ba126abd4a6ed3fa1b41a3821613b42f60 | |
parent | c66ff8779d0f40364a6f1ecdae8f6bafe790823b (diff) | |
download | biomed-c15c92e507f37a476b29f391564b760c38f538a9.tar.gz biomed-c15c92e507f37a476b29f391564b760c38f538a9.tar.bz2 biomed-c15c92e507f37a476b29f391564b760c38f538a9.zip |
Snow/Ice can now optionally be removed/added.
-rw-r--r-- | biome_infos.go | 27 | ||||
-rw-r--r-- | block_infos.go (renamed from blockcolors.go) | 167 | ||||
-rw-r--r-- | main.go | 15 | ||||
-rw-r--r-- | mapwidget.go | 57 |
4 files changed, 261 insertions, 5 deletions
diff --git a/biome_infos.go b/biome_infos.go index 7ee1d3c..e9daabb 100644 --- a/biome_infos.go +++ b/biome_infos.go @@ -58,3 +58,30 @@ var bioColors = map[mcmap.Biome]*gdk.Color{ mcmap.BioJungleHills: gdk.NewColor("#63bf54"), mcmap.BioUncalculated: gdk.NewColor("#333333"), } + +var coldBiome = map[mcmap.Biome]bool{ + mcmap.BioOcean: false, + mcmap.BioPlains: false, + mcmap.BioDesert: false, + mcmap.BioExtremeHills: false, + mcmap.BioForest: false, + mcmap.BioTaiga: true, + mcmap.BioSwampland: false, + mcmap.BioRiver: false, + mcmap.BioHell: false, + mcmap.BioSky: false, + mcmap.BioFrozenOcean: true, + mcmap.BioFrozenRiver: true, + mcmap.BioIcePlains: true, + mcmap.BioIceMountains: true, + mcmap.BioMushroomIsland: false, + mcmap.BioMushroomIslandShore: false, + mcmap.BioBeach: false, + mcmap.BioDesertHills: false, + mcmap.BioForestHills: false, + mcmap.BioTaigaHills: true, + mcmap.BioExtremeHillsEdge: false, + mcmap.BioJungle: false, + mcmap.BioJungleHills: false, + mcmap.BioUncalculated: false, +} diff --git a/blockcolors.go b/block_infos.go index bac126b..f06c308 100644 --- a/blockcolors.go +++ b/block_infos.go @@ -142,3 +142,170 @@ var blockColors = map[mcmap.BlockID]*gdk.Color{ mcmap.BlkHardenedClay: gdk.NewColor("#767a82"), mcmap.BlkBlockOfCoal: gdk.NewColor("#333333"), } + +var blockCanSnowIn = map[mcmap.BlockID]bool{ + mcmap.BlkAir: false, + mcmap.BlkStone: true, + mcmap.BlkGrassBlock: true, + mcmap.BlkDirt: true, + mcmap.BlkCobblestone: true, + mcmap.BlkWoodPlanks: true, + mcmap.BlkSaplings: false, + mcmap.BlkBedrock: true, + mcmap.BlkWater: false, + mcmap.BlkStationaryWater: false, + mcmap.BlkLava: false, + mcmap.BlkStationaryLava: false, + mcmap.BlkSand: true, + mcmap.BlkGravel: true, + mcmap.BlkGoldOre: true, + mcmap.BlkIronOre: true, + mcmap.BlkCoalOre: true, + mcmap.BlkWood: true, + mcmap.BlkLeaves: true, + mcmap.BlkSponge: true, + mcmap.BlkGlass: false, + mcmap.BlkLapisLazuliOre: true, + mcmap.BlkLapisLazuliBlock: true, + mcmap.BlkDispenser: true, + mcmap.BlkSandstone: true, + mcmap.BlkNoteBlock: true, + mcmap.BlkBed: false, + mcmap.BlkPoweredRail: false, + mcmap.BlkDetectorRail: false, + mcmap.BlkStickyPiston: true, + mcmap.BlkCobweb: false, + mcmap.BlkGrass: false, + mcmap.BlkDeadBush: false, + mcmap.BlkPiston: true, + mcmap.BlkPistonExtension: false, + mcmap.BlkWool: true, + mcmap.BlkBlockMovedByPiston: false, + mcmap.BlkDandelion: false, + mcmap.BlkRose: false, + mcmap.BlkBrownMushroom: false, + mcmap.BlkRedMushroom: false, + mcmap.BlkBlockOfGold: true, + mcmap.BlkBlockOfIron: true, + mcmap.BlkDoubleSlabs: true, + mcmap.BlkSlabs: false, + mcmap.BlkBricks: true, + mcmap.BlkTNT: true, + mcmap.BlkBookshelf: true, + mcmap.BlkMossStone: true, + mcmap.BlkObsidian: true, + mcmap.BlkTorch: false, + mcmap.BlkFire: false, + mcmap.BlkMonsterSpawner: true, + mcmap.BlkOakWoodStairs: true, + mcmap.BlkChest: false, + mcmap.BlkRedstoneWire: false, + mcmap.BlkDiamondOre: true, + mcmap.BlkBlockOfDiamond: true, + mcmap.BlkCraftingTable: true, + mcmap.BlkWheat: false, + mcmap.BlkFarmland: false, + mcmap.BlkFurnace: false, + mcmap.BlkBurningFurnace: false, + mcmap.BlkSignPost: false, + mcmap.BlkWoodenDoor: false, + mcmap.BlkLadders: false, + mcmap.BlkRail: false, + mcmap.BlkCobblestoneStairs: false, + mcmap.BlkWallSign: false, + mcmap.BlkLever: false, + mcmap.BlkStonePressurePlate: false, + mcmap.BlkIronDoor: false, + mcmap.BlkWoodenPressurePlate: false, + mcmap.BlkRedstoneOre: true, + mcmap.BlkGlowingRedstoneOre: true, + mcmap.BlkRedstoneTorchInactive: false, + mcmap.BlkRedstoneTorchActive: false, + mcmap.BlkStoneButton: false, + mcmap.BlkSnow: false, + mcmap.BlkIce: false, + mcmap.BlkSnowBlock: true, + mcmap.BlkCactus: false, + mcmap.BlkClay: true, + mcmap.BlkSugarCane: false, + mcmap.BlkJukebox: true, + mcmap.BlkFence: false, + mcmap.BlkPumpkin: true, + mcmap.BlkNetherrack: true, + mcmap.BlkSoulSand: true, + mcmap.BlkGlowstone: true, + mcmap.BlkNetherPortal: false, + mcmap.BlkJackOLantern: true, + mcmap.BlkCakeBlock: false, + mcmap.BlkRedstoneRepeaterInactive: false, + mcmap.BlkRedstoneRepeaterActive: false, + mcmap.BlkLockedChest: false, + mcmap.BlkTrapdoor: false, + mcmap.BlkMonsterEgg: false, + mcmap.BlkStoneBricks: true, + mcmap.BlkHugeBrownMushroom: true, + mcmap.BlkHugeRedMushroom: true, + mcmap.BlkIronBars: false, + mcmap.BlkGlassPane: false, + mcmap.BlkMelon: true, + mcmap.BlkPumpkinStem: false, + mcmap.BlkMelonStem: false, + mcmap.BlkVines: false, + mcmap.BlkFenceGate: false, + mcmap.BlkBrickStairs: false, + mcmap.BlkStoneBrickStairs: false, + mcmap.BlkMycelium: true, + mcmap.BlkLilyPad: false, + mcmap.BlkNetherBrick: true, + mcmap.BlkNetherBrickFence: false, + mcmap.BlkNetherBrickStairs: false, + mcmap.BlkNetherWart: false, + mcmap.BlkEnchantmentTable: false, + mcmap.BlkBrewingStand: false, + mcmap.BlkCauldron: false, + mcmap.BlkEndPortal: false, + mcmap.BlkEndPortalBlock: false, + mcmap.BlkEndStone: true, + mcmap.BlkDragonEgg: false, + mcmap.BlkRedstoneLampInactive: true, + mcmap.BlkRedstoneLampActive: true, + mcmap.BlkWoodenDoubleSlab: true, + mcmap.BlkWoodenSlab: false, + mcmap.BlkCocoa: false, + mcmap.BlkSandstoneStairs: false, + mcmap.BlkEmeraldOre: true, + mcmap.BlkEnderChest: false, + mcmap.BlkTripwireHook: false, + mcmap.BlkTripwire: false, + mcmap.BlkBlockOfEmerald: true, + mcmap.BlkSpruceWoodStairs: false, + mcmap.BlkBirchWoodStairs: false, + mcmap.BlkJungleWoodStairs: false, + mcmap.BlkCommandBlock: true, + mcmap.BlkBeacon: false, + mcmap.BlkCobblestoneWall: false, + mcmap.BlkFlowerPot: false, + mcmap.BlkCarrots: false, + mcmap.BlkPotatoes: false, + mcmap.BlkWoodenButton: false, + mcmap.BlkMobHead: false, + mcmap.BlkAnvil: false, + mcmap.BlkTrappedChest: false, + mcmap.BlkWeightedPressurePlateLight: false, + mcmap.BlkWeightedPressurePlateHeavy: false, + mcmap.BlkRedstoneComparatorInactive: false, + mcmap.BlkRedstoneComparatorActive: false, + mcmap.BlkDaylightSensor: false, + mcmap.BlkBlockOfRedstone: true, + mcmap.BlkNetherQuartzOre: true, + mcmap.BlkHopper: false, + mcmap.BlkBlockOfQuartz: true, + mcmap.BlkQuartzStairs: false, + mcmap.BlkActivatorRail: false, + mcmap.BlkDropper: false, + mcmap.BlkStainedClay: true, + mcmap.BlkHayBlock: true, + mcmap.BlkCarpet: false, + mcmap.BlkHardenedClay: true, + mcmap.BlkBlockOfCoal: true, +} @@ -10,9 +10,11 @@ import ( ) type GUI struct { - window *gtk.Window - statusbar *gtk.Statusbar + window *gtk.Window + statusbar *gtk.Statusbar + showbiomes *gtk.CheckButton + fixsnowice *gtk.CheckButton statusContext uint lastStatus string @@ -155,6 +157,11 @@ func (g *GUI) mkSidebar() *gtk.ScrolledWindow { g.showbiomes.Connect("toggled", g.showbiomesToggled) vbox.PackStart(g.showbiomes, false, false, 3) + g.fixsnowice = gtk.NewCheckButtonWithLabel("Fix Snow/Ice") + g.fixsnowice.SetTooltipText("Add Snow/Ice for Taiga/Ice Plains. Remove Snow/Ice for other biomes.") + g.fixsnowice.Connect("toggled", g.fixsnowiceToggled) + vbox.PackStart(g.fixsnowice, false, false, 3) + fill := gtk.NewRadioButtonWithLabel(nil, "Fill") fill.SetActive(true) fill.Connect("toggled", g.mkUpdateToolFx(fill, NewFillTool())) @@ -274,6 +281,10 @@ func (g *GUI) showbiomesToggled() { g.mapw.SetShowBiomes(g.showbiomes.GetActive()) } +func (g *GUI) fixsnowiceToggled() { + g.mapw.SetFixSnowIce(g.fixsnowice.GetActive()) +} + /*func (g *GUI) undo() { fmt.Println("Undo") }*/ diff --git a/mapwidget.go b/mapwidget.go index 37a05d0..3592e42 100644 --- a/mapwidget.go +++ b/mapwidget.go @@ -74,7 +74,7 @@ type MapWidget struct { isInit bool - showBiomes bool + showBiomes, fixSnowIce bool offX, offZ int mx1, mx2, my1, my2 int @@ -113,6 +113,10 @@ func (mw *MapWidget) SetShowBiomes(b bool) { mw.redraw <- true } +func (mw *MapWidget) SetFixSnowIce(b bool) { + mw.fixSnowIce = b +} + func (mw *MapWidget) SetTool(t Tool) { mw.tool = t } @@ -489,6 +493,44 @@ func (mw *MapWidget) SetBiomeAt(x, z int, bio mcmap.Biome) { } chunk.SetBiome(bx, bz, bio) + + var newcol *gdk.Color + if mw.fixSnowIce { + for y := chunk.Height(bx, bz); y >= 0; y-- { + if blk := chunk.Block(bx, y, bz); blk.ID != mcmap.BlkAir { + if coldBiome[bio] { + if (blk.ID == mcmap.BlkStationaryWater) || (blk.ID == mcmap.BlkWater) { + blk.ID = mcmap.BlkIce + newcol = blockColors[mcmap.BlkIce] + } else if blockCanSnowIn[blk.ID] { + if yFix := y + 1; yFix < mcmap.ChunkSizeY { + blkFix := chunk.Block(bx, yFix, bz) + blkFix.ID = mcmap.BlkSnow + blkFix.Data = 0x0 + newcol = blockColors[mcmap.BlkSnow] + } + } + } else { + if blk.ID == mcmap.BlkIce { + blk.ID = mcmap.BlkStationaryWater + blk.Data = 0x0 + newcol = blockColors[mcmap.BlkStationaryWater] + } else if blk.ID == mcmap.BlkSnow { + blk.ID = mcmap.BlkAir + for y2 := y - 1; y2 >= 0; y2-- { + if col, ok := blockColors[chunk.Block(bx, y2, bz).ID]; ok { + newcol = col + break + } + } + } + } + + break + } + } + } + chunk.MarkModified() // Update cache @@ -497,12 +539,21 @@ func (mw *MapWidget) SetBiomeAt(x, z int, bio mcmap.Biome) { } // Update tile - if tile, ok := mw.biotiles[pos]; ok { + if biotile, ok := mw.biotiles[pos]; ok { gdk.ThreadsEnter() - drawable := tile.GetDrawable() + + drawable := biotile.GetDrawable() gc := gdk.NewGC(drawable) gc.SetRgbFgColor(bioColors[bio]) drawable.DrawRectangle(gc, true, bx*zoom, bz*zoom, zoom, zoom) + + if newcol != nil { + drawable = mw.maptiles[pos].GetDrawable() + gc = gdk.NewGC(drawable) + gc.SetRgbFgColor(newcol) + drawable.DrawRectangle(gc, true, bx*zoom, bz*zoom, zoom, zoom) + } + gdk.ThreadsLeave() } } |