mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Prevent flickering when multiple dialogs appear in quick succession
This commit is contained in:
@@ -81,7 +81,7 @@ public class ImageCache {
|
|||||||
* and cannot be loaded from disk. pass -1 for width and/or height to avoid resizing in that dimension.
|
* and cannot be loaded from disk. pass -1 for width and/or height to avoid resizing in that dimension.
|
||||||
*/
|
*/
|
||||||
public static BufferedImage getImage(final CardView card, final int width, final int height) {
|
public static BufferedImage getImage(final CardView card, final int width, final int height) {
|
||||||
final String key = card.getOriginal().getImageKey();
|
final String key = card.getOriginal().getImageKey(false);
|
||||||
return scaleImage(key, width, height, true);
|
return scaleImage(key, width, height, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public final class FImageUtil {
|
|||||||
* For flip cards, returns the un-flipped image.
|
* For flip cards, returns the un-flipped image.
|
||||||
*/
|
*/
|
||||||
public static BufferedImage getImage(final CardStateView card) {
|
public static BufferedImage getImage(final CardStateView card) {
|
||||||
BufferedImage image = ImageCache.getOriginalImage(card.getImageKey(), true);
|
BufferedImage image = ImageCache.getOriginalImage(card.getImageKey(false), true);
|
||||||
final int foilIndex = card.getFoilIndex();
|
final int foilIndex = card.getFoilIndex();
|
||||||
if (image != null && foilIndex > 0) {
|
if (image != null && foilIndex > 0) {
|
||||||
image = getImageWithFoilEffect(image, foilIndex);
|
image = getImageWithFoilEffect(image, foilIndex);
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class ImageCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Texture getImage(CardView card) {
|
public static Texture getImage(CardView card) {
|
||||||
final String key = card.getOriginal().getImageKey();
|
final String key = card.getOriginal().getImageKey(false);
|
||||||
return getImage(key, true);
|
return getImage(key, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class CardRenderer {
|
|||||||
float w = width - 2 * x;
|
float w = width - 2 * x;
|
||||||
float h = height - 2 * y;
|
float h = height - 2 * y;
|
||||||
|
|
||||||
final Texture image = ImageCache.getImage(card.getOriginal().getImageKey(), true);
|
final Texture image = ImageCache.getImage(card.getOriginal().getImageKey(false), true);
|
||||||
if (image == ImageCache.defaultImage) { //support drawing card image manually if card image not found
|
if (image == ImageCache.defaultImage) { //support drawing card image manually if card image not found
|
||||||
float ratio = h / w;
|
float ratio = h / w;
|
||||||
if (ratio > FCardPanel.ASPECT_RATIO) {
|
if (ratio > FCardPanel.ASPECT_RATIO) {
|
||||||
@@ -221,7 +221,7 @@ public class CardRenderer {
|
|||||||
return getCardArt(ImageKeys.getImageKey(pc, false), pc.getRules().getSplitType() == CardSplitType.Split);
|
return getCardArt(ImageKeys.getImageKey(pc, false), pc.getRules().getSplitType() == CardSplitType.Split);
|
||||||
}
|
}
|
||||||
public static FImageComplex getCardArt(CardView card) {
|
public static FImageComplex getCardArt(CardView card) {
|
||||||
return getCardArt(card.getOriginal().getImageKey(), card.isSplitCard());
|
return getCardArt(card.getOriginal().getImageKey(true), card.isSplitCard());
|
||||||
}
|
}
|
||||||
public static FImageComplex getCardArt(String imageKey, boolean isSplitCard) {
|
public static FImageComplex getCardArt(String imageKey, boolean isSplitCard) {
|
||||||
FImageComplex cardArt = cardArtCache.get(imageKey);
|
FImageComplex cardArt = cardArtCache.get(imageKey);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package forge.toolbox;
|
package forge.toolbox;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import com.badlogic.gdx.Input.Keys;
|
import com.badlogic.gdx.Input.Keys;
|
||||||
@@ -52,6 +53,7 @@ public abstract class FOverlay extends FContainer {
|
|||||||
@Override
|
@Override
|
||||||
public void run () {
|
public void run () {
|
||||||
tempOverlay.hide();
|
tempOverlay.hide();
|
||||||
|
tempOverlay = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -80,22 +82,14 @@ public abstract class FOverlay extends FContainer {
|
|||||||
}
|
}
|
||||||
else if (!hidingAll) { //hiding all handles cleaning up overlay collection
|
else if (!hidingAll) { //hiding all handles cleaning up overlay collection
|
||||||
if (overlays.get(overlays.size() - 1) == this) {
|
if (overlays.get(overlays.size() - 1) == this) {
|
||||||
overlays.pop();
|
//after removing the top overlay, delay hiding overlay for a brief period
|
||||||
|
|
||||||
//after removing the top overlay, put up an empty overlay for a brief period
|
|
||||||
//to prevent back color flickering if another popup immediately follows
|
//to prevent back color flickering if another popup immediately follows
|
||||||
if (tempOverlay != this) {
|
if (tempOverlay != this) {
|
||||||
if (tempOverlay == null) {
|
tempOverlay = this;
|
||||||
tempOverlay = new FOverlay() {
|
|
||||||
@Override
|
|
||||||
protected void doLayout(float width, float height) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
tempOverlay.backColor = backColor;
|
|
||||||
tempOverlay.show();
|
|
||||||
Timer.schedule(hideTempOverlayTask, 0.025f);
|
Timer.schedule(hideTempOverlayTask, 0.025f);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
overlays.pop();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
overlays.remove(this);
|
overlays.remove(this);
|
||||||
@@ -154,8 +148,17 @@ public abstract class FOverlay extends FContainer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildTouchListeners(float screenX, float screenY, ArrayList<FDisplayObject> listeners) {
|
||||||
|
if (tempOverlay == this) { return; } //suppress touch events if waiting to be hidden
|
||||||
|
|
||||||
|
super.buildTouchListeners(screenX, screenY, listeners);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyDown(int keyCode) {
|
public boolean keyDown(int keyCode) {
|
||||||
|
if (tempOverlay == this) { return false; } //suppress key events if waiting to be hidden
|
||||||
|
|
||||||
if (keyCode == Keys.ESCAPE || keyCode == Keys.BACK) {
|
if (keyCode == Keys.ESCAPE || keyCode == Keys.BACK) {
|
||||||
if (Forge.endKeyInput()) { return true; }
|
if (Forge.endKeyInput()) { return true; }
|
||||||
|
|
||||||
|
|||||||
@@ -823,8 +823,8 @@ public class CardView extends GameEntityView {
|
|||||||
/**
|
/**
|
||||||
* @return the imageKey
|
* @return the imageKey
|
||||||
*/
|
*/
|
||||||
public String getImageKey() {
|
public String getImageKey(boolean ignoreMayBeShown) {
|
||||||
return mayBeShown ? imageKey : ImageKeys.HIDDEN_CARD;
|
return mayBeShown || ignoreMayBeShown ? imageKey : ImageKeys.HIDDEN_CARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user