Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds border-fill to the border fill tool #219

Merged
merged 3 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/app/ui/cpwsarea/wsmap/pmap/panel_tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var (
w.Separator(),
w.Text("Fill the area with the selected object"),
w.Line(w.TextFrame("Hold Alt"), w.Text("Fill the selected area with the selected object with replace")),
w.Line(w.TextFrame("Hold Ctrl"), w.Text("Fill the area with the selected object, borders only")),
},
},
tools.TNGrab: {
Expand Down
28 changes: 24 additions & 4 deletions internal/app/ui/cpwsarea/wsmap/tools/fill.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"sdmm/internal/app/ui/cpwsarea/wsmap/pmap/overlay"

"sdmm/internal/imguiext"
"sdmm/internal/util"
)

Expand Down Expand Up @@ -69,13 +70,32 @@ func (t *ToolFill) onStop(util.Point) {
return
}

bordersOnly := imguiext.IsCtrlDown()
SpaiR marked this conversation as resolved.
Show resolved Hide resolved
// Fill the area.
if prefab, ok := ed.SelectedPrefab(); ok {
for x := t.fillArea.X1; x <= t.fillArea.X2; x++ {
fillTile := func(x, y int) {
coord := util.Point{X: x, Y: y, Z: t.start.Z}
tile := ed.Dmm().GetTile(coord)
t.basicPrefabAdd(tile, prefab)
}
if bordersOnly {
rows := []float32{t.fillArea.Y1, t.fillArea.Y2}
columns := []float32{t.fillArea.X1, t.fillArea.X2}
for x := t.fillArea.X1; x <= t.fillArea.X2; x++ {
for _, coordinate := range rows {
fillTile(int(x), int(coordinate))
}
}
for y := t.fillArea.Y1; y <= t.fillArea.Y2; y++ {
coord := util.Point{X: int(x), Y: int(y), Z: t.start.Z}
tile := ed.Dmm().GetTile(coord)
t.basicPrefabAdd(tile, prefab)
for _, coordinate := range columns {
fillTile(int(coordinate), int(y))
}
}
} else {
for x := t.fillArea.X1; x <= t.fillArea.X2; x++ {
for y := t.fillArea.Y1; y <= t.fillArea.Y2; y++ {
fillTile(int(x), int(y))
}
}
}

Expand Down