mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Add try/catch to FContainer::draw() so screen doesn't bug out when something throws an exception during rendering
This commit is contained in:
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
import forge.Graphics;
|
import forge.Graphics;
|
||||||
|
import forge.error.BugReporter;
|
||||||
|
|
||||||
public abstract class FContainer extends FDisplayObject {
|
public abstract class FContainer extends FDisplayObject {
|
||||||
private final ArrayList<FDisplayObject> children = new ArrayList<FDisplayObject>();
|
private final ArrayList<FDisplayObject> children = new ArrayList<FDisplayObject>();
|
||||||
@@ -38,33 +39,38 @@ public abstract class FContainer extends FDisplayObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics g) {
|
public void draw(Graphics g) {
|
||||||
drawBackground(g);
|
try {
|
||||||
|
drawBackground(g);
|
||||||
boolean needOverlayDrawn = true;
|
|
||||||
for (FDisplayObject child : children) {
|
boolean needOverlayDrawn = true;
|
||||||
if (child.isVisible()) {
|
for (FDisplayObject child : children) {
|
||||||
if (child.drawAboveOverlay() && needOverlayDrawn) {
|
if (child.isVisible()) {
|
||||||
drawOverlay(g);
|
if (child.drawAboveOverlay() && needOverlayDrawn) {
|
||||||
needOverlayDrawn = false;
|
drawOverlay(g);
|
||||||
|
needOverlayDrawn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final boolean disabled = !child.isEnabled();
|
||||||
|
if (disabled) {
|
||||||
|
g.setAlphaComposite(DISABLED_COMPOSITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
g.draw(child);
|
||||||
|
|
||||||
|
if (disabled) {
|
||||||
|
g.resetAlphaComposite();
|
||||||
|
}
|
||||||
|
|
||||||
|
child.drawOnContainer(g); //give child an additional chance to draw additional content on container outside its bounds
|
||||||
}
|
}
|
||||||
|
}
|
||||||
final boolean disabled = !child.isEnabled();
|
|
||||||
if (disabled) {
|
if (needOverlayDrawn) {
|
||||||
g.setAlphaComposite(DISABLED_COMPOSITE);
|
drawOverlay(g);
|
||||||
}
|
|
||||||
|
|
||||||
g.draw(child);
|
|
||||||
|
|
||||||
if (disabled) {
|
|
||||||
g.resetAlphaComposite();
|
|
||||||
}
|
|
||||||
|
|
||||||
child.drawOnContainer(g); //give child an additional chance to draw additional content on container outside its bounds
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
if (needOverlayDrawn) {
|
BugReporter.reportException(ex);
|
||||||
drawOverlay(g);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user