|
|
|
@ -523,12 +523,12 @@ impl Pane {
|
|
|
|
|
|
|
|
|
|
/// Draws the Pane at `(dx + self.position.0, dy + self.position.1)` on a [`TextSurface`].
|
|
|
|
|
/// Empty tiles will leave the `TextSurface` untouched, but tiles are free to modify the characters around them.
|
|
|
|
|
pub fn draw(&self, dx: i32, dy: i32, surface: &mut TextSurface) {
|
|
|
|
|
pub fn draw(&self, dx: i32, dy: i32, surface: &mut TextSurface, blink: Blink) {
|
|
|
|
|
for (x, y, tile) in self.tiles_iter() {
|
|
|
|
|
let x = x as i32 + dx + self.position.0 as i32;
|
|
|
|
|
let y = y as i32 + dy + self.position.1 as i32;
|
|
|
|
|
let ctx = DrawContext::new(self, (x, y), (dx, dy), blink.clone())
|
|
|
|
|
.unwrap_or_else(|| unreachable!());
|
|
|
|
|
|
|
|
|
|
tile.draw(x, y, surface);
|
|
|
|
|
tile.draw(surface, ctx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -561,7 +561,7 @@ mod test {
|
|
|
|
|
);
|
|
|
|
|
test_set_signal!(pane, (0, 0), Direction::Right);
|
|
|
|
|
|
|
|
|
|
pane.draw(0, 0, &mut surface);
|
|
|
|
|
pane.draw(0, 0, &mut surface, Blink::default());
|
|
|
|
|
|
|
|
|
|
assert_eq!(surface.get(0, 0).unwrap().ch, '-');
|
|
|
|
|
assert_eq!(surface.get(1, 0).unwrap().ch, '|');
|
|
|
|
@ -574,7 +574,7 @@ mod test {
|
|
|
|
|
|
|
|
|
|
// With offset (1, 0)
|
|
|
|
|
let mut surface = TextSurface::new(3, 3);
|
|
|
|
|
pane.draw(1, 0, &mut surface);
|
|
|
|
|
pane.draw(1, 0, &mut surface, Blink::default());
|
|
|
|
|
|
|
|
|
|
assert_eq!(surface.get(1, 0).unwrap().ch, '-');
|
|
|
|
|
assert_eq!(surface.get(2, 0).unwrap().ch, '|');
|
|
|
|
@ -587,7 +587,7 @@ mod test {
|
|
|
|
|
|
|
|
|
|
// With offset (0, 1)
|
|
|
|
|
let mut surface = TextSurface::new(3, 3);
|
|
|
|
|
pane.draw(0, 1, &mut surface);
|
|
|
|
|
pane.draw(0, 1, &mut surface, Blink::default());
|
|
|
|
|
|
|
|
|
|
assert_eq!(surface.get(0, 1).unwrap().ch, '-');
|
|
|
|
|
assert_eq!(surface.get(1, 1).unwrap().ch, '|');
|
|
|
|
@ -600,7 +600,7 @@ mod test {
|
|
|
|
|
|
|
|
|
|
// Draw outside of bounds with offset (2, 2)
|
|
|
|
|
let mut surface = TextSurface::new(3, 3);
|
|
|
|
|
pane.draw(2, 2, &mut surface);
|
|
|
|
|
pane.draw(2, 2, &mut surface, Blink::default());
|
|
|
|
|
|
|
|
|
|
assert_eq!(surface.get(2, 2).unwrap().ch, '-');
|
|
|
|
|
for y in 0..3 {
|
|
|
|
@ -632,7 +632,7 @@ mod test {
|
|
|
|
|
|
|
|
|
|
let mut surface = TextSurface::new(9, 9);
|
|
|
|
|
|
|
|
|
|
pane.draw(5, 3, &mut surface);
|
|
|
|
|
pane.draw(5, 3, &mut surface, Blink::default());
|
|
|
|
|
|
|
|
|
|
assert_eq!(surface.get(5 + 2, 3 + 1).unwrap().ch, '-');
|
|
|
|
|
assert_eq!(surface.get(5 + 3, 3 + 1).unwrap().ch, '|');
|
|
|
|
|