mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Fix lag I introduced. Just learned that we should never create an instance of a new object inside the render call, because it will create a new instance every draw call.
This commit is contained in:
@@ -3,6 +3,7 @@ package forge.card;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import forge.model.FModel;
|
||||||
import forge.properties.ForgeConstants;
|
import forge.properties.ForgeConstants;
|
||||||
import forge.properties.ForgePreferences;
|
import forge.properties.ForgePreferences;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -327,18 +328,12 @@ public class CardImageRenderer {
|
|||||||
|
|
||||||
public static void drawZoom(Graphics g, CardView card, GameView gameView, boolean altState, float x, float y, float w, float h, float dispW, float dispH, boolean isCurrentCard) {
|
public static void drawZoom(Graphics g, CardView card, GameView gameView, boolean altState, float x, float y, float w, float h, float dispW, float dispH, boolean isCurrentCard) {
|
||||||
final Texture image = ImageCache.getImage(card.getState(altState).getImageKey(MatchController.instance.getLocalPlayers()), true);
|
final Texture image = ImageCache.getImage(card.getState(altState).getImageKey(MatchController.instance.getLocalPlayers()), true);
|
||||||
ForgePreferences prefs = new ForgePreferences();
|
|
||||||
//rotate plane or phenomenon...
|
|
||||||
boolean rotateZoomDisplay = prefs != null
|
|
||||||
&& prefs.getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_PLANE_OR_PHENOMENON)
|
|
||||||
&& (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane());
|
|
||||||
boolean hideEffectCardImage = prefs != null
|
|
||||||
&& prefs.getPrefBoolean(ForgePreferences.FPref.UI_DISABLE_IMAGES_EFFECT_CARDS);
|
|
||||||
if (image == null) { //draw details if can't draw zoom
|
if (image == null) { //draw details if can't draw zoom
|
||||||
drawDetails(g, card, gameView, altState, x, y, w, h);
|
drawDetails(g, card, gameView, altState, x, y, w, h);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(card.isToken() && card.getCurrentState().getType().hasSubtype("Effect") && hideEffectCardImage){
|
if(card.isToken() && card.getCurrentState().getType().hasSubtype("Effect")
|
||||||
|
&& FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_DISABLE_IMAGES_EFFECT_CARDS)){
|
||||||
drawDetails(g, card, gameView, altState, x, y, w, h);
|
drawDetails(g, card, gameView, altState, x, y, w, h);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -351,7 +346,8 @@ public class CardImageRenderer {
|
|||||||
float new_h = h*wh_Adj;
|
float new_h = h*wh_Adj;
|
||||||
float new_x = ForgeConstants.isGdxPortLandscape && isCurrentCard ? (dispW - new_w) / 2:x;
|
float new_x = ForgeConstants.isGdxPortLandscape && isCurrentCard ? (dispW - new_w) / 2:x;
|
||||||
float new_y = ForgeConstants.isGdxPortLandscape && isCurrentCard ? (dispH - new_h) / 2:y;
|
float new_y = ForgeConstants.isGdxPortLandscape && isCurrentCard ? (dispH - new_h) / 2:y;
|
||||||
if(rotateZoomDisplay)
|
if(FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_PLANE_OR_PHENOMENON)
|
||||||
|
&& (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane()))
|
||||||
g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90);
|
g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90);
|
||||||
else
|
else
|
||||||
g.drawImage(image, x, y, w, h);
|
g.drawImage(image, x, y, w, h);
|
||||||
|
|||||||
@@ -364,19 +364,14 @@ public class CardRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void drawCard(Graphics g, CardView card, float x, float y, float w, float h, CardStackPosition pos, boolean rotate) {
|
public static void drawCard(Graphics g, CardView card, float x, float y, float w, float h, CardStackPosition pos, boolean rotate) {
|
||||||
ForgePreferences prefs = new ForgePreferences();
|
|
||||||
//rotate plane or phenomenon...
|
|
||||||
boolean rotateDisplay = prefs != null
|
|
||||||
&& prefs.getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_PLANE_OR_PHENOMENON)
|
|
||||||
&& (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane());
|
|
||||||
|
|
||||||
Texture image = ImageCache.getImage(card);
|
Texture image = ImageCache.getImage(card);
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
if (image == ImageCache.defaultImage) {
|
if (image == ImageCache.defaultImage) {
|
||||||
CardImageRenderer.drawCardImage(g, card, false, x, y, w, h, pos);
|
CardImageRenderer.drawCardImage(g, card, false, x, y, w, h, pos);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(rotateDisplay && rotate)
|
if(FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_PLANE_OR_PHENOMENON)
|
||||||
|
&& (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane()) && rotate)
|
||||||
g.drawRotatedImage(image, x, y, w, h, x + w / 2, y + h / 2, -90);
|
g.drawRotatedImage(image, x, y, w, h, x + w / 2, y + h / 2, -90);
|
||||||
else
|
else
|
||||||
g.drawImage(image, x, y, w, h);
|
g.drawImage(image, x, y, w, h);
|
||||||
|
|||||||
Reference in New Issue
Block a user