Skip to content

Commit

Permalink
feature: adds border-fill to the border fill tool (#219)
Browse files Browse the repository at this point in the history
* feature: border fill

holding ctrl with the fill tool now fills the border only

* grammar fix

* review
  • Loading branch information
mc-oofert committed Jul 31, 2023
1 parent 49956b5 commit ac7e9c8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
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 @@ -51,6 +51,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
27 changes: 23 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 @@ -71,11 +72,29 @@ func (t *ToolFill) onStop(util.Point) {

// 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 imguiext.IsCtrlDown() {
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

0 comments on commit ac7e9c8

Please sign in to comment.