From 438f69b9cba7fba60d739e33d56917ceb52e0eb0 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 14 Nov 2023 08:27:24 +0000 Subject: [PATCH] Fixed #18: Convert between TE and RTE --- .../starterkit/terminal/RogueTerminalEmulator.scala | 3 +++ .../roguelike/starterkit/terminal/TerminalEmulator.scala | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/roguelike-starterkit/src/main/scala/io/indigoengine/roguelike/starterkit/terminal/RogueTerminalEmulator.scala b/roguelike-starterkit/src/main/scala/io/indigoengine/roguelike/starterkit/terminal/RogueTerminalEmulator.scala index 091f2d8c..1194e251 100644 --- a/roguelike-starterkit/src/main/scala/io/indigoengine/roguelike/starterkit/terminal/RogueTerminalEmulator.scala +++ b/roguelike-starterkit/src/main/scala/io/indigoengine/roguelike/starterkit/terminal/RogueTerminalEmulator.scala @@ -252,6 +252,9 @@ final class RogueTerminalEmulator( def inset(otherConsole: Terminal, offset: Point): RogueTerminalEmulator = put(otherConsole.toPositionedBatch.filterNot(_._2 == Terminal.EmptyTile), offset) + def toTerminalEmulator: TerminalEmulator = + TerminalEmulator(size).inset(this, Point.zero) + object RogueTerminalEmulator: inline def pointToIndex(point: Point, gridWidth: Int): Int = diff --git a/roguelike-starterkit/src/main/scala/io/indigoengine/roguelike/starterkit/terminal/TerminalEmulator.scala b/roguelike-starterkit/src/main/scala/io/indigoengine/roguelike/starterkit/terminal/TerminalEmulator.scala index ec5ece03..baead178 100644 --- a/roguelike-starterkit/src/main/scala/io/indigoengine/roguelike/starterkit/terminal/TerminalEmulator.scala +++ b/roguelike-starterkit/src/main/scala/io/indigoengine/roguelike/starterkit/terminal/TerminalEmulator.scala @@ -90,9 +90,7 @@ final case class TerminalEmulator(size: Size, charMap: QuadTree[MapTile]) extend this.copy(charMap = charMap.removeElement(Vertex.fromPoint(coords))) def clear: TerminalEmulator = - this.copy(charMap = - QuadTree.empty[MapTile](size.width.toDouble, size.height.toDouble) - ) + this.copy(charMap = QuadTree.empty[MapTile](size.width.toDouble, size.height.toDouble)) def optimise: TerminalEmulator = this.copy(charMap = charMap.prune) @@ -222,6 +220,9 @@ final case class TerminalEmulator(size: Size, charMap: QuadTree[MapTile]) extend def inset(otherConsole: Terminal, offset: Point): TerminalEmulator = put(otherConsole.toPositionedBatch, offset) + def toRogueTerminalEmulator: RogueTerminalEmulator = + RogueTerminalEmulator(size).inset(this, Point.zero) + object TerminalEmulator: def apply(screenSize: Size): TerminalEmulator = TerminalEmulator(