Skip to content

gui/liquids - Add brush radius and shape mode - #1649

Open
Bitlytic wants to merge 1 commit into
DFHack:masterfrom
Bitlytic:drag-liquids
Open

Bitlytic wants to merge 1 commit into
DFHack:masterfrom
Bitlytic:drag-liquids

Conversation

@Bitlytic

Copy link
Copy Markdown

This adds a brush size property when the gui/liquids mode is set to Drag or Click. In these modes the brush can also be changed to either a square or round brush

liquids-brush-compressed.mp4

Additional Changes

This includes a small fix where the UI and actual paint mode were out of sync when gui/liquids was first opened.

@ab9rf
ab9rf requested a review from SilasD October 15, 2026 19:37

@SilasD SilasD left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The brush painting code looks solid.

I am requesting removal of the dynamic menu text positioning (the element hiding), in favor of graying out elements that don't affect the current operation mode.

Comment thread gui/liquids.lua
Comment on lines +49 to +50
if type(k) == "string" then
if k:startswith("level_increase") or k:startswith("level_decrease") then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, okay, why are we doing this?

A: seems to be because we we want to adjust both level_decrease and level_decrease_glyph, an dthe same for level_increase and level_increase_glyph.

not sure I like this. I guess it's no worse than the other layout elements, which are also hardcoded.

I'm tempted to say 'use a callback to calculate this dynamically' but that is kind of advanced.

so the effect of this code is to hide the "Decrease radius" and "Increase radius" labels if the Paint mode is Area.
this is opposed to just graying out both labels, the way that "Increase level" is grayed out when the liquid level is 7/7.

the effect here is that UI elements appear and disappear as modes change.

(later) Okay, I've been thinking about this off-and-on for most of a day. I don't like hiding those labels. I strongly believe menu-like UI elements should gray out when they are not valid input.

Important

Please change the label code so that the Increase radius and Decrease radius labels gray out when not valid.

I think that means this entire function can be deleted.

Comment thread gui/liquids.lua
end


return ([[Click to spawn %s with %s/7 %s]]):format(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

There's no need for this to use [[longstring]] marks, "double-quotes" are preferred.

Suggested change
return ([[Click to spawn %s with %s/7 %s]]):format(
return ("Click to spawn %s with %s/7 %s"):format(

Comment thread gui/liquids.lua
Comment on lines +267 to +275
function SpawnLiquid:increaseBrushSize()
self.brush_radius = math.min(self.brush_radius + 1, 10)
end

function SpawnLiquid:decreaseBrushSize()
self.brush_radius = math.max(self.brush_radius - 1, 0)
end


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

setting the brush radius to 1, 2, 3, 4, etc. results in brush sizes of 1x1, 3x3, 5x5, 7x7, etc.
radius 10 yields a brush of 21x21, I think.
it might be useful to increment it by 0.5, which would also yield brush sizes of 2x2, 4x4, 6x6, etc.
the minimum would still have to be 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants