diff --git a/changelog.txt b/changelog.txt index 41701c8788..52534e826a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -58,6 +58,7 @@ Template for new versions: - `caravan`: optionally display items within bins in bring goods to depot screen - `gui/gm-editor`: display in the title bar whether the editor window is scanning for live updates - `gui/design`: change "auto commit" hotkey from ``c`` to ``Alt-c`` to avoid conflict with the default keybinding for z-level down +- `gui/liquids`: support removing river sources by converting them into stone floors ## Removed diff --git a/gui/liquids.lua b/gui/liquids.lua index 8adb71d56a..4eda71242a 100644 --- a/gui/liquids.lua +++ b/gui/liquids.lua @@ -68,7 +68,7 @@ function SpawnLiquid:init() { label = "Magma", value = df.tile_liquid.Magma, pen = COLOR_RED }, { label = "River", value = df.tiletype.RiverSource, pen = COLOR_BLUE }, }, - initial_option = 0, + initial_option = df.tile_liquid.Water, on_change = function(new, _) self.type = new self.tile = SpawnLiquidCursor[new] @@ -84,10 +84,11 @@ function SpawnLiquid:init() { label = "Click", value = SpawnLiquidPaintMode.CLICK, pen = COLOR_WHITE }, { label = "Drag ", value = SpawnLiquidPaintMode.DRAG, pen = COLOR_WHITE }, }, - initial_option = 1, + initial_option = SpawnLiquidPaintMode.DRAG, on_change = function(new, _) self.paint_mode = new end, }, widgets.CycleHotkeyLabel{ + view_id = 'mode1', frame = {l = 18, b = 2}, label = 'Mode:', auto_width = true, @@ -98,9 +99,28 @@ function SpawnLiquid:init() { label = "Remove", value = SpawnLiquidMode.REMOVE, pen = COLOR_WHITE }, { label = "Clean ", value = SpawnLiquidMode.CLEAN, pen = COLOR_WHITE }, }, - initial_option = 1, - on_change = function(new, _) self.mode = new end, - disabled = function() return self.type == df.tiletype.RiverSource end + initial_option = SpawnLiquidMode.SET, + on_change = function(new, _) + self.mode = new + self.subviews.mode2:setOption(new) + end, + visible = function() return self.type ~= df.tiletype.RiverSource end + }, + widgets.CycleHotkeyLabel{ + view_id = 'mode2', + frame = {l = 18, b = 2}, + label = 'Mode:', + auto_width = true, + key = 'CUSTOM_X', + options = { + { label = "Set ", value = SpawnLiquidMode.SET, pen = COLOR_WHITE }, + { label = "Remove", value = SpawnLiquidMode.REMOVE, pen = COLOR_WHITE }, + }, + on_change = function(new, _) + self.mode = new + self.subviews.mode1:setOption(new) + end, + visible = function() return self.type == df.tiletype.RiverSource end }, } end @@ -143,9 +163,22 @@ function SpawnLiquid:spawn(pos) tile.water_salt = false tile.water_stagnant = false elseif self.type == df.tiletype.RiverSource then - map_block.tiletype[pos.x % 16][pos.y % 16] = df.tiletype.RiverSource - - liquids.spawnLiquid(pos, 7, df.tile_liquid.Water) + if self.mode == SpawnLiquidMode.REMOVE then + local commands = { + 'f', 'any', ';', + 'f', 'sp', 'river_source', ';', + 'p', 'any', ';', + 'p', 's', 'floor', ';', + 'p', 'sp', 'normal', ';', + 'p', 'm', 'stone', ';', + } + dfhack.run_command('tiletypes-command', table.unpack(commands)) + dfhack.run_command('tiletypes-here', '--quiet', ('--cursor=%d,%d,%d'):format(pos2xyz(pos))) + liquids.spawnLiquid(pos, 0, df.tile_liquid.Water) + else + map_block.tiletype[pos.x % 16][pos.y % 16] = df.tiletype.RiverSource + liquids.spawnLiquid(pos, 7, df.tile_liquid.Water) + end else liquids.spawnLiquid(pos, self:getLiquidLevel(pos), self.type) end