diff --git a/CHANGELOG.md b/CHANGELOG.md index 24d20c3..9a2ba6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ via the numeric keypad or the YUBN keys (à la Rogue). - [Open-ended excavate](https://gridmonger.johnnovak.net/manual/basic-editing.html#open-ended-excavate) option to aid in exploring tunnel-style dungeons. +- Option to pre-fill new levels with empty floors (for wall-style maps). - New [Arrow floor type](TODO) to represent moving floors and conveyor belts. - Option to select whether the Left/Right cursor keys perform strafing or turning in [Walk Mode](https://gridmonger.johnnovak.net/manual/moving-around.html#walk-mode). diff --git a/TODO b/TODO index 65bebfe..c02d450 100644 --- a/TODO +++ b/TODO @@ -16,7 +16,6 @@ TODO ==== - add unlink command - - prefill level with empty floor (for wall style maps) - finish diagonal movement (numpad, YUBN) - improve restoring the window's size on screen dimension changes diff --git a/src/actions.nim b/src/actions.nim index 012d468..6a10e9d 100644 --- a/src/actions.nim +++ b/src/actions.nim @@ -657,7 +657,7 @@ proc pasteSelection*(map; loc, undoLoc: Location, sb: SelectionBuffer, # {{{ addNewLevel*() proc addNewLevel*(map; loc: Location, locationName, levelName: string, elevation: int, - rows, cols: Natural, + rows, cols: Natural, fillFloorColor: Option[Natural], overrideCoordOpts: bool, coordOpts: CoordinateOptions, regionOpts: RegionOptions, notes: string; @@ -677,6 +677,13 @@ proc addNewLevel*(map; loc: Location, regionOpts, notes) newLevelId = newLevel.id + + if fillFloorColor.isSome: + var cell: Cell + cell.floor = fBlank + cell.floorColor = fillFloorColor.get.uint8 + newLevel.fill(cell) + m.setLevel(newLevel) var usd = usd diff --git a/src/level.nim b/src/level.nim index 9d19466..2ddb488 100644 --- a/src/level.nim +++ b/src/level.nim @@ -94,6 +94,14 @@ proc setWall*(l; r,c: Natural, dir: CardinalDir, w: Wall) = proc canSetWall*(l; r,c: Natural, dir: CardinalDir): bool {.inline.} = not l.isEmpty(r,c) or not l.isNeighbourCellEmpty(r,c, {dir}) +# }}} +# {{{ fill*() +proc fill*(l; rect: Rect[Natural], cell: Cell) = + l.cellGrid.fill(rect, cell) + +proc fill*(l; cell: Cell) = + l.cellGrid.fill(cell) + # }}} # }}} diff --git a/src/main.nim b/src/main.nim index 9d4a4a6..428e8d8 100644 --- a/src/main.nim +++ b/src/main.nim @@ -813,32 +813,33 @@ type LevelPropertiesDialogParams = object - activeTab: Natural + activeTab: Natural activateFirstTextField: bool # General tab - locationName: string - levelName: string - elevation: string - rows: string - cols: string + locationName: string + levelName: string + elevation: string + rows: string + cols: string + fillWithEmptyFloors: bool # Coordinates tab - overrideCoordOpts: bool - origin: Natural - rowStyle: Natural - columnStyle: Natural - rowStart: string - columnStart: string + overrideCoordOpts: bool + origin: Natural + rowStyle: Natural + columnStyle: Natural + rowStart: string + columnStart: string # Regions tab - enableRegions: bool - colsPerRegion: string - rowsPerRegion: string - perRegionCoords: bool + enableRegions: bool + colsPerRegion: string + rowsPerRegion: string + perRegionCoords: bool # Notes tab - notes: string + notes: string ResizeLevelDialogParams = object @@ -4726,6 +4727,12 @@ proc newLevelDialog(dlg: var LevelPropertiesDialogParams; a) = if dlg.activeTab == 0: # General commonLevelFields(dimensionsDisabled=false) + group: + koi.label("Fill with empty floors", style=a.theme.labelStyle) + + koi.nextItemHeight(DlgCheckBoxSize) + koi.checkBox(dlg.fillWithEmptyFloors, style=a.theme.checkBoxStyle) + elif dlg.activeTab == 1: # Coordinates group: koi.label("Override map settings", style=a.theme.labelStyle) @@ -4763,16 +4770,23 @@ proc newLevelDialog(dlg: var LevelPropertiesDialogParams; a) = rows = parseInt(dlg.rows) cols = parseInt(dlg.cols) + var fillFloorColor: Option[Natural] + let cur = actions.addNewLevel( a.doc.map, a.ui.cursor, + locationName = dlg.locationName, - levelName = dlg.levelName, - elevation = parseInt(dlg.elevation), - rows = rows, - cols = cols, - dlg.overrideCoordOpts, + levelName = dlg.levelName, + elevation = parseInt(dlg.elevation), + rows = rows, + cols = cols, + fillFloorColor = if dlg.fillWithEmptyFloors: + a.ui.currFloorColor.Natural.some + else: Natural.none, + + dlg.overrideCoordOpts, coordOpts = CoordinateOptions( origin: CoordinateOrigin(dlg.origin), rowStyle: CoordinateStyle(dlg.rowStyle), @@ -10776,7 +10790,6 @@ proc initApp(configFile: Option[string], mapFile: Option[string], ) else: appEvents.disableAutoSave() - # TODO init from config with a.ui.notesListState: currFilter.noteType = NoteTypeFilter.fullSet currFilter.orderBy = noType