Fixes issue where the screen's tiles weren't being reset when a component was removed from the screen. So, you would see the component even after it was removed.
@@ -457,6 +457,22 @@ public class Screen {
for (final EventListener listener : component.getEventListeners()) {
removeListener(listener);
}
+
+ // Reset all of the tiles where the component used to be.
+ final int startX = component.getTiles().getXPosition();
+ final int startY = component.getTiles().getYPosition();
+
+ final int endX = startX + component.getTiles().getWidth();
+ final int endY = startY + component.getTiles().getHeight();
+
+ for (int y = startY ; y < endY ; y++) {
+ for (int x = startX ; x < endX ; x++) {
+ final Tile tile = tiles.getTileAt(x, y);
+ tile.reset();
+ tile.setBackgroundColor(colorPalette.getDefaultBackground());
+ tile.setForegroundColor(colorPalette.getDefaultForeground());
+ }
+ }
}
/** Removes all components from the screen. */
