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