Removes unnecessary code from the removeComponent function.
Replaces debug printout with null check in the removeComponent function, when resetting tiles.
@@ -244,11 +244,6 @@ public class Layer extends Component {
}
}
- // Remove all of the component's listeners from the root screen:
- for (final EventListener listener : component.getEventListeners()) {
- rootScreen.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();
@@ -262,7 +257,8 @@ public class Layer extends Component {
if (tile != null) {
tile.reset();
- System.out.println(tile + " " + rootScreen + " " + rootScreen.getColorPalette());
+
+ if (rootScreen != null) {
tile.setBackgroundColor(rootScreen.getColorPalette().getDefaultBackground());
tile.setForegroundColor(rootScreen.getColorPalette().getDefaultForeground());
}
@@ -270,6 +266,7 @@ public class Layer extends Component {
}
}
}
+ }
/** Removes all components from the layer. */
public void removeAllComponents() {
