Skip to content

Commit

Permalink
Fixed rendering issues with drawing regions
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed Nov 14, 2023
1 parent e2d0f59 commit c638bd3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion demo/src/main/scala/demo/CloneTilesScene.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ object CloneTilesScene extends Scene[Unit, Unit, Unit]:
viewModel: Unit
): Outcome[SceneUpdateFragment] =
val tiles =
terminal.toCloneTiles(CloneId("demo"), Point.zero, RoguelikeTiles.Size10x10.charCrops) { (fg, bg) =>
terminal.toCloneTiles(
CloneId("demo"),
Point.zero,
RoguelikeTiles.Size10x10.charCrops
) { (fg, bg) =>
Graphic(10, 10, TerminalMaterial(Assets.tileMap, fg, bg))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ final class RogueTerminalEmulator(
maxTileCount: Int,
region: Rectangle
): TerminalEntity =
TerminalEntity(tileSheet, size, charSize, toTileBatch(region), maxTileCount)
TerminalEntity(tileSheet, region.size, charSize, toTileBatch(region), maxTileCount)

private def toCloneTileData(
position: Point,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ final case class TerminalEmulator(size: Size, charMap: QuadTree[MapTile]) extend
maxTileCount: Int,
region: Rectangle
): TerminalEntity =
TerminalEntity(tileSheet, size, charSize, toTileBatch(region), maxTileCount)
TerminalEntity(tileSheet, region.size, charSize, toTileBatch(region), maxTileCount)

private def toCloneTileData(
position: Point,
Expand Down Expand Up @@ -139,7 +139,7 @@ final case class TerminalEmulator(size: Size, charMap: QuadTree[MapTile]) extend

val combinations: Batch[((CloneId, RGBA, RGBA), Batch[(Point, MapTile)])] =
Batch.fromMap(
toPositionedBatch
positionedBatch
.groupBy(p =>
(makeId(p._2.foreground, p._2.background), p._2.foreground, p._2.background)
)
Expand Down Expand Up @@ -202,7 +202,9 @@ final case class TerminalEmulator(size: Size, charMap: QuadTree[MapTile]) extend
* (but the position is given), does not fill in gaps.
*/
def toPositionedBatch(region: Rectangle): Batch[(Point, MapTile)] =
charMap.toBatchWithPosition.filter(p => region.contains(p._1.toPoint)).map(p => p._1.toPoint -> p._2)
charMap.toBatchWithPosition
.filter(p => region.contains(p._1.toPoint))
.map(p => p._1.toPoint -> p._2)

def |+|(otherConsole: Terminal): TerminalEmulator =
combine(otherConsole)
Expand Down

0 comments on commit c638bd3

Please sign in to comment.