Skip to content

Commit

Permalink
Fixes issue where the screen's tiles weren't being reset when a compo…
Browse files Browse the repository at this point in the history
…nent was removed from the screen. So, you would see the component even after it was removed.
  • Loading branch information
Valkryst committed Jul 26, 2018
1 parent d407e70 commit da440c1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/com/valkryst/VTerminal/Screen.java
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,22 @@ public void removeComponent(final Component component) {
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. */
Expand Down

0 comments on commit da440c1

Please sign in to comment.