mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Prevent continuous rendering getting stuck on or off
This commit is contained in:
@@ -49,7 +49,7 @@ public class Forge implements ApplicationListener {
|
||||
private static SplashScreen splashScreen;
|
||||
private static KeyInputAdapter keyInputAdapter;
|
||||
private static boolean exited;
|
||||
private static boolean initialLoadFinished;
|
||||
private static int continuousRenderingCount = 1; //initialize to 1 since continuous rendering is the default
|
||||
private static final Stack<FScreen> screens = new Stack<FScreen>();
|
||||
public static HostedMatch hostedMatch;
|
||||
|
||||
@@ -109,8 +109,7 @@ public class Forge implements ApplicationListener {
|
||||
}
|
||||
|
||||
private void afterDbLoaded() {
|
||||
initialLoadFinished = true;
|
||||
Gdx.graphics.setContinuousRendering(false); //save power consumption by disabling continuous rendering once assets loaded
|
||||
stopContinuousRendering(); //save power consumption by disabling continuous rendering once assets loaded
|
||||
|
||||
FSkin.loadFull(splashScreen);
|
||||
|
||||
@@ -130,8 +129,17 @@ public class Forge implements ApplicationListener {
|
||||
return deviceAdapter;
|
||||
}
|
||||
|
||||
public static boolean isInitialLoadFinished() {
|
||||
return initialLoadFinished;
|
||||
public static void startContinuousRendering() {
|
||||
if (++continuousRenderingCount == 1) {
|
||||
//only set continuous rendering to true if needed
|
||||
Gdx.graphics.setContinuousRendering(true);
|
||||
}
|
||||
}
|
||||
public static void stopContinuousRendering() {
|
||||
if (continuousRenderingCount > 0 && --continuousRenderingCount == 0) {
|
||||
//only set continuous rendering to false if all continuous rendering requests have been ended
|
||||
Gdx.graphics.setContinuousRendering(false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showMenu() {
|
||||
|
||||
@@ -15,7 +15,7 @@ public abstract class ForgeAnimation {
|
||||
|
||||
activeAnimations.add(this);
|
||||
if (activeAnimations.size() == 1) { //if first animation being started, ensure continuous rendering turned on
|
||||
Gdx.graphics.setContinuousRendering(true);
|
||||
Forge.startContinuousRendering();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,7 @@ public abstract class ForgeAnimation {
|
||||
}
|
||||
|
||||
if (activeAnimations.isEmpty()) { //when all animations have ended, turn continuous rendering back off
|
||||
if (Forge.isInitialLoadFinished()) { //don't turn back on continuous rendering if initial load isn't finished yet
|
||||
Gdx.graphics.setContinuousRendering(false);
|
||||
}
|
||||
Forge.stopContinuousRendering();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,9 +42,7 @@ public abstract class ForgeAnimation {
|
||||
animation.onEnd(true);
|
||||
}
|
||||
activeAnimations.clear();
|
||||
if (Forge.isInitialLoadFinished()) { //don't turn back on continuous rendering if initial load isn't finished yet
|
||||
Gdx.graphics.setContinuousRendering(false);
|
||||
}
|
||||
Forge.stopContinuousRendering();
|
||||
}
|
||||
|
||||
//return true if animation should continue, false to stop the animation
|
||||
|
||||
@@ -19,8 +19,7 @@ package forge.screens.settings;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.UiCommand;
|
||||
import forge.download.GuiDownloadService;
|
||||
import forge.download.GuiDownloadZipService;
|
||||
@@ -45,7 +44,7 @@ public class GuiDownloader extends FDialog {
|
||||
private final UiCommand cmdClose = new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
Gdx.graphics.setContinuousRendering(false);
|
||||
Forge.stopContinuousRendering();
|
||||
service.setCancel(true);
|
||||
hide();
|
||||
if (callback != null) {
|
||||
@@ -91,7 +90,7 @@ public class GuiDownloader extends FDialog {
|
||||
progressBar.reset();
|
||||
progressBar.setShowProgressTrail(true);
|
||||
progressBar.setDescription("Scanning for existing items...");
|
||||
Gdx.graphics.setContinuousRendering(true);
|
||||
Forge.startContinuousRendering();
|
||||
|
||||
show();
|
||||
|
||||
@@ -99,7 +98,7 @@ public class GuiDownloader extends FDialog {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!(service instanceof GuiDownloadZipService)) { //retain continuous rendering for zip service
|
||||
Gdx.graphics.setContinuousRendering(false);
|
||||
Forge.stopContinuousRendering();
|
||||
}
|
||||
progressBar.setShowProgressTrail(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user