diff --git a/src/infinity/NearInfinity.java b/src/infinity/NearInfinity.java index a536ae76a..7bb2a13a2 100644 --- a/src/infinity/NearInfinity.java +++ b/src/infinity/NearInfinity.java @@ -48,6 +48,12 @@ public final class NearInfinity extends JFrame implements ActionListener, ViewableContainer { + static { + // XXX: Works around a known bug in Java's Swing layouts when using FocusTraversalPolicy + // Note: Required for Area Viewer's JTree control; must be set before executing main() + System.setProperty("java.util.Arrays.useLegacyMergeSort", "true"); + } + private static final int[] JAVA_VERSION = {1, 6}; // the minimum java version supported private static final JTextArea consoletext = new JTextArea(); diff --git a/src/infinity/gui/layeritem/AnimatedLayerItem.java b/src/infinity/gui/layeritem/AnimatedLayerItem.java index c054da04e..d61661204 100644 --- a/src/infinity/gui/layeritem/AnimatedLayerItem.java +++ b/src/infinity/gui/layeritem/AnimatedLayerItem.java @@ -32,12 +32,6 @@ * Represents a game resource structure visually as a bitmap animation. * @author argent77 */ -/* - * TODO: Add proper support for mirrored animations (mirrored on Y axis) - * - sprites are already mirrored correctly - * - center position has yet to be mirrored - * Example map using mirrored animationsL AR3016 - */ public class AnimatedLayerItem extends AbstractLayerItem implements LayerItemListener, ActionListener { // lookup table for alpha transparency on blended animations diff --git a/src/infinity/resource/are/viewer/TilesetRenderer.java b/src/infinity/resource/are/viewer/TilesetRenderer.java index 216f78999..bd4b3792a 100644 --- a/src/infinity/resource/are/viewer/TilesetRenderer.java +++ b/src/infinity/resource/are/viewer/TilesetRenderer.java @@ -8,6 +8,8 @@ import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; import java.awt.Image; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; @@ -493,6 +495,21 @@ public void reload(boolean force) updateDisplay(b || force); } + @Override + public void paint(Graphics g) + { + // checking whether VolatileImage instance needs to be updated + if (getImage() != null && getImage() instanceof VolatileImage) { + VolatileImage image = (VolatileImage)getImage(); + GraphicsConfiguration gc = + GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); + if (image.validate(gc) == VolatileImage.IMAGE_RESTORED) { + updateDisplay(true); + } + } + super.paint(g); + } + protected void updateSize() { if (isInitialized()) { @@ -536,17 +553,9 @@ protected void paintCanvas(Graphics g) private boolean updateImageSize() { if (isInitialized()) { - Image curImg = getImage(); - if (curImg == null || curImg.getWidth(null) != getMapWidth(false) || - curImg.getHeight(null) != getMapHeight(false)) { - if (curImg != null) { - curImg = null; - } - Image newImg = ColorConvert.createVolatileImage(getMapWidth(false), getMapHeight(false), false); - if (newImg == null) { - return false; - } - setImage(newImg); + if (getImage() == null || getImage().getWidth(null) != getMapWidth(false) || + getImage().getHeight(null) != getMapHeight(false)) { + setImage(ColorConvert.createVolatileImage(getMapWidth(false), getMapHeight(false), false)); } updateSize(); return true;