mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
fix bug while switching game modes and forcing an exit
- aldo update new_game_mobile.json
This commit is contained in:
@@ -134,6 +134,7 @@ public class Forge implements ApplicationListener {
|
|||||||
GuiBase.setDeviceInfo(deviceName, AndroidRelease, AndroidAPI, totalRAM);
|
GuiBase.setDeviceInfo(deviceName, AndroidRelease, AndroidAPI, totalRAM);
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Forge() {
|
private Forge() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,8 +172,7 @@ public class Forge implements ApplicationListener {
|
|||||||
String skinName;
|
String skinName;
|
||||||
if (FileUtil.doesFileExist(ForgeConstants.MAIN_PREFS_FILE)) {
|
if (FileUtil.doesFileExist(ForgeConstants.MAIN_PREFS_FILE)) {
|
||||||
skinName = prefs.getPref(FPref.UI_SKIN);
|
skinName = prefs.getPref(FPref.UI_SKIN);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
skinName = "default"; //use default skin if preferences file doesn't exist yet
|
skinName = "default"; //use default skin if preferences file doesn't exist yet
|
||||||
}
|
}
|
||||||
FSkin.loadLight(skinName, splashScreen);
|
FSkin.loadLight(skinName, splashScreen);
|
||||||
@@ -208,7 +208,9 @@ public class Forge implements ApplicationListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
//see if app or assets need updating
|
//see if app or assets need updating
|
||||||
AssetsDownloader.checkForUpdates(splashScreen);
|
AssetsDownloader.checkForUpdates(splashScreen);
|
||||||
if (exited) { return; } //don't continue if user chose to exit or couldn't download required assets
|
if (exited) {
|
||||||
|
return;
|
||||||
|
} //don't continue if user chose to exit or couldn't download required assets
|
||||||
|
|
||||||
ImageKeys.setIsLibGDXPort(GuiBase.getInterface().isLibgdxPort());
|
ImageKeys.setIsLibGDXPort(GuiBase.getInterface().isLibgdxPort());
|
||||||
FModel.initialize(splashScreen.getProgressBar(), null);
|
FModel.initialize(splashScreen.getProgressBar(), null);
|
||||||
@@ -250,6 +252,7 @@ public class Forge implements ApplicationListener {
|
|||||||
public static InputProcessor getInputProcessor() {
|
public static InputProcessor getInputProcessor() {
|
||||||
return inputProcessor;
|
return inputProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Graphics getGraphics() {
|
public static Graphics getGraphics() {
|
||||||
return graphics;
|
return graphics;
|
||||||
}
|
}
|
||||||
@@ -273,10 +276,12 @@ public class Forge implements ApplicationListener {
|
|||||||
if (!filteredkeys.isEmpty())
|
if (!filteredkeys.isEmpty())
|
||||||
ImageCache.preloadCache(filteredkeys);
|
ImageCache.preloadCache(filteredkeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void preloadBoosterDrafts() {
|
private void preloadBoosterDrafts() {
|
||||||
//preloading of custom drafts
|
//preloading of custom drafts
|
||||||
BoosterDraft.initializeCustomDrafts();
|
BoosterDraft.initializeCustomDrafts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openHomeScreen(int index, FScreen lastMatch) {
|
public static void openHomeScreen(int index, FScreen lastMatch) {
|
||||||
openScreen(HomeScreen.instance);
|
openScreen(HomeScreen.instance);
|
||||||
HomeScreen.instance.openMenu(index);
|
HomeScreen.instance.openMenu(index);
|
||||||
@@ -291,6 +296,7 @@ public class Forge implements ApplicationListener {
|
|||||||
/*for (FScreen fScreen : Dscreens)
|
/*for (FScreen fScreen : Dscreens)
|
||||||
System.out.println(fScreen.toString());*/
|
System.out.println(fScreen.toString());*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openHomeDefault() {
|
public static void openHomeDefault() {
|
||||||
GuiBase.setIsAdventureMode(false);
|
GuiBase.setIsAdventureMode(false);
|
||||||
openHomeScreen(-1, null); //default for startup
|
openHomeScreen(-1, null); //default for startup
|
||||||
@@ -300,6 +306,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
stopContinuousRendering(); //save power consumption by disabling continuous rendering once assets loaded
|
stopContinuousRendering(); //save power consumption by disabling continuous rendering once assets loaded
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openAdventure() {
|
public static void openAdventure() {
|
||||||
//continuous rendering is needed for adventure mode
|
//continuous rendering is needed for adventure mode
|
||||||
startContinuousRendering();
|
startContinuousRendering();
|
||||||
@@ -314,8 +321,11 @@ public class Forge implements ApplicationListener {
|
|||||||
sceneType.instance.resLoaded();
|
sceneType.instance.resLoaded();
|
||||||
}
|
}
|
||||||
switchScene(SceneType.StartScene.instance);
|
switchScene(SceneType.StartScene.instance);
|
||||||
} catch (Exception e) { e.printStackTrace(); }
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void afterDbLoaded() {
|
protected void afterDbLoaded() {
|
||||||
//init here to fix crash if the assets are missing
|
//init here to fix crash if the assets are missing
|
||||||
transitionTexture = new Texture(GuiBase.isAndroid() ? Gdx.files.internal("fallback_skin").child("transition.png") : Gdx.files.classpath("fallback_skin").child("transition.png"));
|
transitionTexture = new Texture(GuiBase.isAndroid() ? Gdx.files.internal("fallback_skin").child("transition.png") : Gdx.files.classpath("fallback_skin").child("transition.png"));
|
||||||
@@ -364,6 +374,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCursor(TextureRegion textureRegion, String name) {
|
public static void setCursor(TextureRegion textureRegion, String name) {
|
||||||
if (GuiBase.isAndroid())
|
if (GuiBase.isAndroid())
|
||||||
return;
|
return;
|
||||||
@@ -444,9 +455,11 @@ public class Forge implements ApplicationListener {
|
|||||||
cursorName = name;
|
cursorName = name;
|
||||||
pm.dispose();
|
pm.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setGdxCursor(Cursor c) {
|
static void setGdxCursor(Cursor c) {
|
||||||
Gdx.graphics.setCursor(c);
|
Gdx.graphics.setCursor(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Clipboard getClipboard() {
|
public static Clipboard getClipboard() {
|
||||||
return clipboard;
|
return clipboard;
|
||||||
}
|
}
|
||||||
@@ -461,6 +474,7 @@ public class Forge implements ApplicationListener {
|
|||||||
Gdx.graphics.setContinuousRendering(true);
|
Gdx.graphics.setContinuousRendering(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stopContinuousRendering() {
|
public static void stopContinuousRendering() {
|
||||||
if (continuousRenderingCount > 0 && --continuousRenderingCount == 0) {
|
if (continuousRenderingCount > 0 && --continuousRenderingCount == 0) {
|
||||||
//only set continuous rendering to false if all continuous rendering requests have been ended
|
//only set continuous rendering to false if all continuous rendering requests have been ended
|
||||||
@@ -477,14 +491,12 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void adjustHeightModifier(float DisplayW, float DisplayH) {
|
public static void adjustHeightModifier(float DisplayW, float DisplayH) {
|
||||||
if(isLandscapeMode())
|
if (isLandscapeMode()) {//TODO: Fullscreen support for Display without screen controls
|
||||||
{//TODO: Fullscreen support for Display without screen controls
|
|
||||||
float aspectratio = DisplayW / DisplayH;
|
float aspectratio = DisplayW / DisplayH;
|
||||||
if (aspectratio > 1.82f) {/* extra wide */
|
if (aspectratio > 1.82f) {/* extra wide */
|
||||||
setHeightModifier(200.0f);
|
setHeightModifier(200.0f);
|
||||||
extrawide = "extrawide";
|
extrawide = "extrawide";
|
||||||
}
|
} else if (aspectratio > 1.7f) {/* wide */
|
||||||
else if(aspectratio > 1.7f) {/* wide */
|
|
||||||
setHeightModifier(100.0f);
|
setHeightModifier(100.0f);
|
||||||
extrawide = "wide";
|
extrawide = "wide";
|
||||||
}
|
}
|
||||||
@@ -509,6 +521,7 @@ public class Forge implements ApplicationListener {
|
|||||||
public static void back() {
|
public static void back() {
|
||||||
back(false);
|
back(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void back(boolean clearlastMatch) {
|
public static void back(boolean clearlastMatch) {
|
||||||
if (isMobileAdventureMode) {
|
if (isMobileAdventureMode) {
|
||||||
return;
|
return;
|
||||||
@@ -554,7 +567,9 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void restart(boolean silent) {
|
public static void restart(boolean silent) {
|
||||||
if (exited) { return; } //don't allow exiting multiple times
|
if (exited) {
|
||||||
|
return;
|
||||||
|
} //don't allow exiting multiple times
|
||||||
|
|
||||||
Callback<Boolean> callback = new Callback<Boolean>() {
|
Callback<Boolean> callback = new Callback<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -570,8 +585,7 @@ public class Forge implements ApplicationListener {
|
|||||||
|
|
||||||
if (silent) {
|
if (silent) {
|
||||||
callback.run(true);
|
callback.run(true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
FOptionPane.showConfirmDialog(
|
FOptionPane.showConfirmDialog(
|
||||||
localizer.getMessage("lblAreYouSureYouWishRestartForge"), localizer.getMessage("lblRestartForge"),
|
localizer.getMessage("lblAreYouSureYouWishRestartForge"), localizer.getMessage("lblRestartForge"),
|
||||||
localizer.getMessage("lblRestart"), localizer.getMessage("lblCancel"), callback);
|
localizer.getMessage("lblRestart"), localizer.getMessage("lblCancel"), callback);
|
||||||
@@ -579,7 +593,9 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void exit(boolean silent) {
|
public static void exit(boolean silent) {
|
||||||
if (exited) { return; } //don't allow exiting multiple times
|
if (exited) {
|
||||||
|
return;
|
||||||
|
} //don't allow exiting multiple times
|
||||||
|
|
||||||
final Localizer localizer = Localizer.getInstance();
|
final Localizer localizer = Localizer.getInstance();
|
||||||
final String title = Forge.isLandscapeMode() && GuiBase.isAndroid() ? "" : localizer.getMessage("lblExitForge");
|
final String title = Forge.isLandscapeMode() && GuiBase.isAndroid() ? "" : localizer.getMessage("lblExitForge");
|
||||||
@@ -603,8 +619,7 @@ public class Forge implements ApplicationListener {
|
|||||||
|
|
||||||
if (silent) {
|
if (silent) {
|
||||||
callback.run(0);
|
callback.run(0);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
FOptionPane.showOptionDialog(localizer.getMessage("lblAreYouSureYouWishExitForge"), title,
|
FOptionPane.showOptionDialog(localizer.getMessage("lblAreYouSureYouWishExitForge"), title,
|
||||||
FOptionPane.QUESTION_ICON, options, 0, callback);
|
FOptionPane.QUESTION_ICON, options, 0, callback);
|
||||||
}
|
}
|
||||||
@@ -613,8 +628,11 @@ public class Forge implements ApplicationListener {
|
|||||||
public static void openScreen(final FScreen screen0) {
|
public static void openScreen(final FScreen screen0) {
|
||||||
openScreen(screen0, false);
|
openScreen(screen0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openScreen(final FScreen screen0, final boolean replaceBackScreen) {
|
public static void openScreen(final FScreen screen0, final boolean replaceBackScreen) {
|
||||||
if (currentScreen == screen0) { return; }
|
if (currentScreen == screen0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (currentScreen == null) {
|
if (currentScreen == null) {
|
||||||
Dscreens.addFirst(screen0);
|
Dscreens.addFirst(screen0);
|
||||||
@@ -681,6 +699,7 @@ public class Forge implements ApplicationListener {
|
|||||||
public static void clearCurrentScreen() {
|
public static void clearCurrentScreen() {
|
||||||
currentScreen = null;
|
currentScreen = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void switchToClassic() {
|
public static void switchToClassic() {
|
||||||
setTransitionScreen(new TransitionScreen(new Runnable() {
|
setTransitionScreen(new TransitionScreen(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -690,11 +709,13 @@ public class Forge implements ApplicationListener {
|
|||||||
setCursor(FSkin.getCursor().get(0), "0");
|
setCursor(FSkin.getCursor().get(0), "0");
|
||||||
altZoneTabs = FModel.getPreferences().getPrefBoolean(FPref.UI_ALT_PLAYERZONETABS);
|
altZoneTabs = FModel.getPreferences().getPrefBoolean(FPref.UI_ALT_PLAYERZONETABS);
|
||||||
Gdx.input.setInputProcessor(getInputProcessor());
|
Gdx.input.setInputProcessor(getInputProcessor());
|
||||||
openHomeDefault();
|
|
||||||
clearTransitionScreen();
|
clearTransitionScreen();
|
||||||
|
openHomeDefault();
|
||||||
|
exited = false;
|
||||||
}
|
}
|
||||||
}, ScreenUtils.getFrameBufferTexture(), false, false));
|
}, ScreenUtils.getFrameBufferTexture(), false, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void switchToAdventure() {
|
public static void switchToAdventure() {
|
||||||
setTransitionScreen(new TransitionScreen(new Runnable() {
|
setTransitionScreen(new TransitionScreen(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -702,12 +723,15 @@ public class Forge implements ApplicationListener {
|
|||||||
clearCurrentScreen();
|
clearCurrentScreen();
|
||||||
clearTransitionScreen();
|
clearTransitionScreen();
|
||||||
openAdventure();
|
openAdventure();
|
||||||
|
exited = false;
|
||||||
}
|
}
|
||||||
}, ScreenUtils.getFrameBufferTexture(), false, false));
|
}, ScreenUtils.getFrameBufferTexture(), false, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setTransitionScreen(TransitionScreen screen) {
|
public static void setTransitionScreen(TransitionScreen screen) {
|
||||||
transitionScreen = screen;
|
transitionScreen = screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearTransitionScreen() {
|
public static void clearTransitionScreen() {
|
||||||
transitionScreen = null;
|
transitionScreen = null;
|
||||||
}
|
}
|
||||||
@@ -715,6 +739,7 @@ public class Forge implements ApplicationListener {
|
|||||||
public static void clearSplashScreen() {
|
public static void clearSplashScreen() {
|
||||||
splashScreen = null;
|
splashScreen = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setCurrentScreen(FScreen screen0) {
|
private static void setCurrentScreen(FScreen screen0) {
|
||||||
String toNewScreen = screen0 != null ? screen0.toString() : "";
|
String toNewScreen = screen0 != null ? screen0.toString() : "";
|
||||||
String previousScreen = currentScreen != null ? currentScreen.toString() : "";
|
String previousScreen = currentScreen != null ? currentScreen.toString() : "";
|
||||||
@@ -727,8 +752,7 @@ public class Forge implements ApplicationListener {
|
|||||||
currentScreen = screen0;
|
currentScreen = screen0;
|
||||||
currentScreen.setSize(screenWidth, screenHeight);
|
currentScreen.setSize(screenWidth, screenHeight);
|
||||||
currentScreen.onActivate();
|
currentScreen.onActivate();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
graphics.end();
|
graphics.end();
|
||||||
//check if sentry is enabled, if not it will call the gui interface but here we end the graphics so we only send it via sentry..
|
//check if sentry is enabled, if not it will call the gui interface but here we end the graphics so we only send it via sentry..
|
||||||
if (BugReporter.isSentryEnabled())
|
if (BugReporter.isSentryEnabled())
|
||||||
@@ -763,16 +787,14 @@ public class Forge implements ApplicationListener {
|
|||||||
try {
|
try {
|
||||||
float delta = Gdx.graphics.getDeltaTime();
|
float delta = Gdx.graphics.getDeltaTime();
|
||||||
float transitionTime = 0.2f;
|
float transitionTime = 0.2f;
|
||||||
if(sceneWasSwapped)
|
if (sceneWasSwapped) {
|
||||||
{
|
|
||||||
sceneWasSwapped = false;
|
sceneWasSwapped = false;
|
||||||
animationTimeout = transitionTime;
|
animationTimeout = transitionTime;
|
||||||
Gdx.gl.glClearColor(0, 0, 0, 1);
|
Gdx.gl.glClearColor(0, 0, 0, 1);
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(animationTimeout>=0)
|
if (animationTimeout >= 0) {
|
||||||
{
|
|
||||||
Gdx.gl.glClearColor(0, 0, 0, 1);
|
Gdx.gl.glClearColor(0, 0, 0, 1);
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
animationBatch.begin();
|
animationBatch.begin();
|
||||||
@@ -783,20 +805,16 @@ public class Forge implements ApplicationListener {
|
|||||||
animationBatch.draw(transitionTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
animationBatch.draw(transitionTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
animationBatch.draw(transitionTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
animationBatch.draw(transitionTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
animationBatch.end();
|
animationBatch.end();
|
||||||
if(animationTimeout<0)
|
if (animationTimeout < 0) {
|
||||||
{
|
|
||||||
currentScene.render();
|
currentScene.render();
|
||||||
storeScreen();
|
storeScreen();
|
||||||
Gdx.gl.glClearColor(0, 0, 0, 1);
|
Gdx.gl.glClearColor(0, 0, 0, 1);
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(animationTimeout>=-transitionTime)
|
if (animationTimeout >= -transitionTime) {
|
||||||
{
|
|
||||||
Gdx.gl.glClearColor(0, 0, 0, 1);
|
Gdx.gl.glClearColor(0, 0, 0, 1);
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
animationBatch.begin();
|
animationBatch.begin();
|
||||||
@@ -844,8 +862,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
graphics.end();
|
graphics.end();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
graphics.end();
|
graphics.end();
|
||||||
//check if sentry is enabled, if not it will call the gui interface but here we end the graphics so we only send it via sentry..
|
//check if sentry is enabled, if not it will call the gui interface but here we end the graphics so we only send it via sentry..
|
||||||
if (BugReporter.isSentryEnabled())
|
if (BugReporter.isSentryEnabled())
|
||||||
@@ -854,6 +871,7 @@ public class Forge implements ApplicationListener {
|
|||||||
if (showFPS)
|
if (showFPS)
|
||||||
frameRate.render();
|
frameRate.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void delayedSwitchBack() {
|
public static void delayedSwitchBack() {
|
||||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -869,6 +887,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resize(int width, int height) {
|
public void resize(int width, int height) {
|
||||||
try {
|
try {
|
||||||
@@ -876,12 +895,10 @@ public class Forge implements ApplicationListener {
|
|||||||
screenHeight = height;
|
screenHeight = height;
|
||||||
if (currentScreen != null) {
|
if (currentScreen != null) {
|
||||||
currentScreen.setSize(width, height);
|
currentScreen.setSize(width, height);
|
||||||
}
|
} else if (splashScreen != null) {
|
||||||
else if (splashScreen != null) {
|
|
||||||
splashScreen.setSize(width, height);
|
splashScreen.setSize(width, height);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
graphics.end();
|
graphics.end();
|
||||||
//check if sentry is enabled, if not it will call the gui interface but here we end the graphics so we only send it via sentry..
|
//check if sentry is enabled, if not it will call the gui interface but here we end the graphics so we only send it via sentry..
|
||||||
if (BugReporter.isSentryEnabled())
|
if (BugReporter.isSentryEnabled())
|
||||||
@@ -915,8 +932,8 @@ public class Forge implements ApplicationListener {
|
|||||||
SoundSystem.instance.dispose();
|
SoundSystem.instance.dispose();
|
||||||
try {
|
try {
|
||||||
ExceptionHandler.unregisterErrorHandling();
|
ExceptionHandler.unregisterErrorHandling();
|
||||||
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
catch (Exception e) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean switchScene(Scene newScene) {
|
public static boolean switchScene(Scene newScene) {
|
||||||
@@ -935,8 +952,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static void storeScreen() {
|
protected static void storeScreen() {
|
||||||
if(!(currentScene instanceof ForgeScene))
|
if (!(currentScene instanceof ForgeScene)) {
|
||||||
{
|
|
||||||
if (lastScreenTexture != null)
|
if (lastScreenTexture != null)
|
||||||
lastScreenTexture.getTexture().dispose();
|
lastScreenTexture.getTexture().dispose();
|
||||||
lastScreenTexture = ScreenUtils.getFrameBufferTexture();
|
lastScreenTexture = ScreenUtils.getFrameBufferTexture();
|
||||||
@@ -944,10 +960,10 @@ public class Forge implements ApplicationListener {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Scene switchToLast() {
|
public static Scene switchToLast() {
|
||||||
|
|
||||||
if(lastScene.size!=0)
|
if (lastScene.size != 0) {
|
||||||
{
|
|
||||||
storeScreen();
|
storeScreen();
|
||||||
currentScene = lastScene.get(lastScene.size - 1);
|
currentScene = lastScene.get(lastScene.size - 1);
|
||||||
currentScene.enter();
|
currentScene.enter();
|
||||||
@@ -957,13 +973,16 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//log message to Forge.log file
|
//log message to Forge.log file
|
||||||
public static void log(Object message) {
|
public static void log(Object message) {
|
||||||
System.out.println(message);
|
System.out.println(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startKeyInput(KeyInputAdapter adapter) {
|
public static void startKeyInput(KeyInputAdapter adapter) {
|
||||||
if (keyInputAdapter == adapter) { return; }
|
if (keyInputAdapter == adapter) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (keyInputAdapter != null) {
|
if (keyInputAdapter != null) {
|
||||||
keyInputAdapter.onInputEnd(); //make sure previous adapter is ended
|
keyInputAdapter.onInputEnd(); //make sure previous adapter is ended
|
||||||
}
|
}
|
||||||
@@ -972,7 +991,9 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean endKeyInput() {
|
public static boolean endKeyInput() {
|
||||||
if (keyInputAdapter == null) { return false; }
|
if (keyInputAdapter == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
keyInputAdapter.onInputEnd();
|
keyInputAdapter.onInputEnd();
|
||||||
keyInputAdapter = null;
|
keyInputAdapter = null;
|
||||||
MainInputProcessor.keyTyped = false;
|
MainInputProcessor.keyTyped = false;
|
||||||
@@ -982,6 +1003,8 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void exitAnimation(boolean restart) {
|
static void exitAnimation(boolean restart) {
|
||||||
|
if (transitionScreen != null)
|
||||||
|
return; //finish transition incase exit is touched
|
||||||
if (closingScreen == null) {
|
if (closingScreen == null) {
|
||||||
closingScreen = new ClosingScreen(restart);
|
closingScreen = new ClosingScreen(restart);
|
||||||
}
|
}
|
||||||
@@ -989,23 +1012,32 @@ public class Forge implements ApplicationListener {
|
|||||||
|
|
||||||
public static abstract class KeyInputAdapter {
|
public static abstract class KeyInputAdapter {
|
||||||
public abstract FDisplayObject getOwner();
|
public abstract FDisplayObject getOwner();
|
||||||
|
|
||||||
public abstract boolean allowTouchInput();
|
public abstract boolean allowTouchInput();
|
||||||
|
|
||||||
public abstract boolean keyTyped(char ch);
|
public abstract boolean keyTyped(char ch);
|
||||||
|
|
||||||
public abstract boolean keyDown(int keyCode);
|
public abstract boolean keyDown(int keyCode);
|
||||||
|
|
||||||
public abstract void onInputEnd();
|
public abstract void onInputEnd();
|
||||||
|
|
||||||
//also allow handling of keyUp but don't require it
|
//also allow handling of keyUp but don't require it
|
||||||
public boolean keyUp(int keyCode) { return false; }
|
public boolean keyUp(int keyCode) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isCtrlKeyDown() {
|
public static boolean isCtrlKeyDown() {
|
||||||
return Gdx.input.isKeyPressed(Keys.CONTROL_LEFT) || Gdx.input.isKeyPressed(Keys.CONTROL_RIGHT);
|
return Gdx.input.isKeyPressed(Keys.CONTROL_LEFT) || Gdx.input.isKeyPressed(Keys.CONTROL_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isShiftKeyDown() {
|
public static boolean isShiftKeyDown() {
|
||||||
return Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT);
|
return Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAltKeyDown() {
|
public static boolean isAltKeyDown() {
|
||||||
return Gdx.input.isKeyPressed(Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Keys.ALT_RIGHT);
|
return Gdx.input.isKeyPressed(Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Keys.ALT_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isModifierKey(int keyCode) {
|
public static boolean isModifierKey(int keyCode) {
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
case Keys.CONTROL_LEFT:
|
case Keys.CONTROL_LEFT:
|
||||||
@@ -1125,6 +1157,8 @@ public class Forge implements ApplicationListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown(int x, int y, int pointer, int button) {
|
public boolean touchDown(int x, int y, int pointer, int button) {
|
||||||
|
if (transitionScreen != null)
|
||||||
|
return false;
|
||||||
if (pointer == 0) { //don't change listeners when second finger goes down for zoom
|
if (pointer == 0) { //don't change listeners when second finger goes down for zoom
|
||||||
updatePotentialListeners(x, y);
|
updatePotentialListeners(x, y);
|
||||||
if (keyInputAdapter != null) {
|
if (keyInputAdapter != null) {
|
||||||
@@ -1146,8 +1180,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
BugReporter.reportException(ex);
|
BugReporter.reportException(ex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1162,8 +1195,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
BugReporter.reportException(ex);
|
BugReporter.reportException(ex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1178,8 +1210,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
BugReporter.reportException(ex);
|
BugReporter.reportException(ex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1197,8 +1228,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
BugReporter.reportException(ex);
|
BugReporter.reportException(ex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1213,8 +1243,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
BugReporter.reportException(ex);
|
BugReporter.reportException(ex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1229,8 +1258,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
BugReporter.reportException(ex);
|
BugReporter.reportException(ex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1245,8 +1273,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
BugReporter.reportException(ex);
|
BugReporter.reportException(ex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1261,8 +1288,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
BugReporter.reportException(ex);
|
BugReporter.reportException(ex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1277,8 +1303,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
BugReporter.reportException(ex);
|
BugReporter.reportException(ex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1286,6 +1311,7 @@ public class Forge implements ApplicationListener {
|
|||||||
|
|
||||||
//mouseMoved and scrolled events for desktop version
|
//mouseMoved and scrolled events for desktop version
|
||||||
private int mouseMovedX, mouseMovedY;
|
private int mouseMovedX, mouseMovedY;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseMoved(int screenX, int screenY) {
|
public boolean mouseMoved(int screenX, int screenY) {
|
||||||
magnify = true;
|
magnify = true;
|
||||||
@@ -1300,8 +1326,7 @@ public class Forge implements ApplicationListener {
|
|||||||
for (FDisplayObject listener : potentialListeners) {
|
for (FDisplayObject listener : potentialListeners) {
|
||||||
listener.setHovered(false);
|
listener.setHovered(false);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
BugReporter.reportException(ex);
|
BugReporter.reportException(ex);
|
||||||
}
|
}
|
||||||
updatePotentialListeners(screenX, screenY);
|
updatePotentialListeners(screenX, screenY);
|
||||||
@@ -1319,8 +1344,7 @@ public class Forge implements ApplicationListener {
|
|||||||
boolean handled;
|
boolean handled;
|
||||||
if (KeyInputAdapter.isShiftKeyDown()) {
|
if (KeyInputAdapter.isShiftKeyDown()) {
|
||||||
handled = pan(mouseMovedX, mouseMovedY, -Utils.AVG_FINGER_WIDTH * amountX, 0, false);
|
handled = pan(mouseMovedX, mouseMovedY, -Utils.AVG_FINGER_WIDTH * amountX, 0, false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
handled = pan(mouseMovedX, mouseMovedY, 0, -Utils.AVG_FINGER_HEIGHT * amountY, true);
|
handled = pan(mouseMovedX, mouseMovedY, 0, -Utils.AVG_FINGER_HEIGHT * amountY, true);
|
||||||
}
|
}
|
||||||
if (panStop(mouseMovedX, mouseMovedY)) {
|
if (panStop(mouseMovedX, mouseMovedY)) {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
"text": "Avatar:",
|
"text": "Avatar:",
|
||||||
"width": 128,
|
"width": 128,
|
||||||
"height": 32,
|
"height": 32,
|
||||||
|
"font" : "black",
|
||||||
"x": 104,
|
"x": 104,
|
||||||
"y": 58
|
"y": 58
|
||||||
},
|
},
|
||||||
@@ -39,6 +40,7 @@
|
|||||||
"text": "Name:",
|
"text": "Name:",
|
||||||
"width": 128,
|
"width": 128,
|
||||||
"height": 32,
|
"height": 32,
|
||||||
|
"font" : "black",
|
||||||
"x": 104,
|
"x": 104,
|
||||||
"y": 90
|
"y": 90
|
||||||
},
|
},
|
||||||
@@ -47,6 +49,7 @@
|
|||||||
"text": "Race:",
|
"text": "Race:",
|
||||||
"width": 128,
|
"width": 128,
|
||||||
"height": 32,
|
"height": 32,
|
||||||
|
"font" : "black",
|
||||||
"x": 104,
|
"x": 104,
|
||||||
"y": 124
|
"y": 124
|
||||||
},
|
},
|
||||||
@@ -55,6 +58,7 @@
|
|||||||
"text": "Gender:",
|
"text": "Gender:",
|
||||||
"width": 128,
|
"width": 128,
|
||||||
"height": 32,
|
"height": 32,
|
||||||
|
"font" : "black",
|
||||||
"x": 104,
|
"x": 104,
|
||||||
"y": 154
|
"y": 154
|
||||||
},
|
},
|
||||||
@@ -63,6 +67,7 @@
|
|||||||
"text": "Difficulty:",
|
"text": "Difficulty:",
|
||||||
"width": 128,
|
"width": 128,
|
||||||
"height": 32,
|
"height": 32,
|
||||||
|
"font" : "black",
|
||||||
"x": 104,
|
"x": 104,
|
||||||
"y": 186
|
"y": 186
|
||||||
},
|
},
|
||||||
@@ -71,6 +76,7 @@
|
|||||||
"text": "Deck:",
|
"text": "Deck:",
|
||||||
"width": 128,
|
"width": 128,
|
||||||
"height": 32,
|
"height": 32,
|
||||||
|
"font" : "black",
|
||||||
"x": 104,
|
"x": 104,
|
||||||
"y": 218
|
"y": 218
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user