mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
fix startup
- todo figure out android...
This commit is contained in:
@@ -1,17 +1,10 @@
|
||||
package forge.adventure;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Clipboard;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import forge.Forge;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.assets.FSkin;
|
||||
import forge.gui.GuiBase;
|
||||
import forge.sound.MusicPlaylist;
|
||||
import forge.sound.SoundSystem;
|
||||
import forge.util.BuildInfo;
|
||||
import io.sentry.Sentry;
|
||||
import io.sentry.SentryClient;
|
||||
@@ -19,86 +12,6 @@ import io.sentry.SentryClient;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* Wrapper to start forge first (splash screen and resources loading)
|
||||
*
|
||||
*/
|
||||
class StartAdventure extends AdventureApplicationAdapter {
|
||||
|
||||
|
||||
public StartAdventure( ) {
|
||||
|
||||
super(new Lwjgl3Clipboard(), new DesktopAdapter(""), Files.exists(Paths.get("./res"))?"./":"../forge-gui/", true, false, 0, true, 0, "", "");
|
||||
Forge.isTabletDevice = true;
|
||||
Forge.isPortraitMode = false;
|
||||
Forge.hdbuttons = true;
|
||||
Forge.hdstart = true;
|
||||
|
||||
isPortraitMode = true;
|
||||
totalDeviceRAM = 0;
|
||||
GuiBase.setDeviceInfo("", "", 0, 0);
|
||||
GuiBase.setIsAdventureMode(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
if (splashScreen != null) {
|
||||
Gdx.gl.glClearColor(1, 0, 1, 1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Clear the screen.
|
||||
getGraphics().begin(getCurrentWidth(), getCurrentHeight());
|
||||
splashScreen.setSize(getCurrentWidth(), getCurrentHeight());
|
||||
splashScreen.screenPos.setSize(getCurrentWidth(), getCurrentHeight());
|
||||
if (splashScreen.getRotate180()) {
|
||||
getGraphics().startRotateTransform(getCurrentWidth() / 2f, getCurrentHeight() / 2f, 180);
|
||||
}
|
||||
splashScreen.draw(getGraphics());
|
||||
if (splashScreen.getRotate180()) {
|
||||
getGraphics().endTransform();
|
||||
}
|
||||
|
||||
getGraphics().end();
|
||||
} else {
|
||||
super.render();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
super.resize(width, height);
|
||||
if (splashScreen != null)
|
||||
splashScreen.setSize(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
//install our error handler
|
||||
FSkin.loadLight("default", splashScreen,Config.instance().getFile("skin"));
|
||||
|
||||
|
||||
//load model on background thread (using progress bar to report progress)
|
||||
super.create();
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void afterDbLoaded()
|
||||
{
|
||||
FSkin.loadLight("default", splashScreen,Config.instance().getFile("skin"));
|
||||
FSkin.loadFull(splashScreen);
|
||||
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS); //start background music
|
||||
Gdx.input.setCatchKey(Input.Keys.MENU, true);
|
||||
//openHomeScreen(-1, null); //default for startup
|
||||
splashScreen = null;
|
||||
afterDBloaded = true;
|
||||
|
||||
|
||||
//adjust height modifier
|
||||
adjustHeightModifier(getScreenWidth(), getScreenHeight());
|
||||
|
||||
resLoaded();
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Main entry point
|
||||
*/
|
||||
@@ -121,18 +34,19 @@ public class Main {
|
||||
|
||||
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
||||
config.setResizable(false);
|
||||
StartAdventure start=new StartAdventure();
|
||||
|
||||
if (Config.instance().getSettingData().fullScreen)
|
||||
{
|
||||
try {
|
||||
//todo figuure out fullscreen mode...
|
||||
if (Config.instance().getSettingData().fullScreen) {
|
||||
config.setFullscreenMode(Lwjgl3ApplicationConfiguration.getDisplayMode());
|
||||
} else {
|
||||
config.setWindowedMode(Config.instance().getSettingData().width, Config.instance().getSettingData().height);
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
|
||||
config.setWindowIcon(Config.instance().getFilePath("forge-adventure.png"));
|
||||
|
||||
new Lwjgl3Application(start, config);
|
||||
new Lwjgl3Application(Forge.getApp(new Lwjgl3Clipboard(), new DesktopAdapter(""), Files.exists(Paths.get("./res"))?"./":"../forge-gui/", true, false, 0, true, 0, "", "", true), config);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class Main extends AndroidApplication {
|
||||
new BreadcrumbBuilder().setMessage(message).build()
|
||||
);
|
||||
Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation);
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, true, totalRAM, isTabletDevice, AndroidAPI, AndroidRelease, getDeviceName()));
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, true, totalRAM, isTabletDevice, AndroidAPI, AndroidRelease, getDeviceName(), false));
|
||||
displayMessage(adapter, true, message);
|
||||
return;
|
||||
}
|
||||
@@ -236,7 +236,7 @@ public class Main extends AndroidApplication {
|
||||
new BreadcrumbBuilder().setMessage(message).build()
|
||||
);
|
||||
Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation);
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, true, totalRAM, isTabletDevice, AndroidAPI, AndroidRelease, getDeviceName()));
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, true, totalRAM, isTabletDevice, AndroidAPI, AndroidRelease, getDeviceName(), false));
|
||||
displayMessage(adapter, true, message);
|
||||
return;
|
||||
}
|
||||
@@ -267,7 +267,7 @@ public class Main extends AndroidApplication {
|
||||
isPortrait = true;
|
||||
//fake init for permission instruction
|
||||
Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation);
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, isPortrait, totalRAM, isTabletDevice, AndroidAPI, AndroidRelease, getDeviceName()));
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, isPortrait, totalRAM, isTabletDevice, AndroidAPI, AndroidRelease, getDeviceName(), false));
|
||||
displayMessage(adapter, false, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Main extends IOSApplication.Delegate {
|
||||
config.useCompass = false;
|
||||
ForgePreferences prefs = FModel.getPreferences();
|
||||
boolean propertyConfig = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_NETPLAY_COMPAT);//todo get totalRAM && isTabletDevice
|
||||
final ApplicationListener app = Forge.getApp(new IOSClipboard(), new IOSAdapter(), assetsDir, propertyConfig, false, 0, false, 0, "", "");
|
||||
final ApplicationListener app = Forge.getApp(new IOSClipboard(), new IOSAdapter(), assetsDir, propertyConfig, false, 0, false, 0, "", "", false);
|
||||
final IOSApplication iosApp = new IOSApplication(app, config);
|
||||
return iosApp;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class Main {
|
||||
ForgePreferences prefs = FModel.getPreferences();
|
||||
boolean propertyConfig = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_NETPLAY_COMPAT);
|
||||
new Lwjgl3Application(Forge.getApp(new Lwjgl3Clipboard(), new DesktopAdapter(switchOrientationFile),//todo get totalRAM && isTabletDevice
|
||||
desktopMode ? desktopModeAssetsDir : assetsDir, propertyConfig, false, 0, false, 0, "", ""), config);
|
||||
desktopMode ? desktopModeAssetsDir : assetsDir, propertyConfig, false, 0, false, 0, "", "", false), config);
|
||||
}
|
||||
|
||||
private static class DesktopAdapter implements IDeviceAdapter {
|
||||
|
||||
@@ -90,6 +90,7 @@ public class Forge implements ApplicationListener {
|
||||
public static boolean gameInProgress = false;
|
||||
public static boolean disposeTextures = false;
|
||||
public static boolean isMobileAdventureMode = false;
|
||||
public static boolean isDesktopAdventureMode = false;
|
||||
public static int cacheSize = 400;
|
||||
public static int totalDeviceRAM = 0;
|
||||
public static int androidVersion = 0;
|
||||
@@ -100,7 +101,7 @@ public class Forge implements ApplicationListener {
|
||||
public static boolean afterDBloaded = false;
|
||||
public static int mouseButtonID = 0;
|
||||
|
||||
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidAPI, String AndroidRelease, String deviceName) {
|
||||
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidAPI, String AndroidRelease, String deviceName, boolean startAdventure) {
|
||||
app = new Forge();
|
||||
if (GuiBase.getInterface() == null) {
|
||||
clipboard = clipboard0;
|
||||
@@ -112,25 +113,11 @@ public class Forge implements ApplicationListener {
|
||||
totalDeviceRAM = totalRAM;
|
||||
isTabletDevice = isTablet;
|
||||
androidVersion = AndroidAPI;
|
||||
isDesktopAdventureMode=startAdventure;
|
||||
}
|
||||
GuiBase.setDeviceInfo(deviceName, AndroidRelease, AndroidAPI, totalRAM);
|
||||
return app;
|
||||
}
|
||||
protected Forge(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidAPI, String AndroidRelease, String deviceName) {
|
||||
if (GuiBase.getInterface() == null) {
|
||||
clipboard = clipboard0;
|
||||
deviceAdapter = deviceAdapter0;
|
||||
GuiBase.setUsingAppDirectory(assetDir0.contains("forge.app")); //obb directory on android uses the package name as entrypoint
|
||||
GuiBase.setInterface(new GuiMobile(assetDir0));
|
||||
GuiBase.enablePropertyConfig(value);
|
||||
isPortraitMode = androidOrientation;
|
||||
totalDeviceRAM = totalRAM;
|
||||
isTabletDevice = isTablet;
|
||||
androidVersion = AndroidAPI;
|
||||
}
|
||||
GuiBase.setDeviceInfo(deviceName, AndroidRelease, AndroidAPI, totalRAM);
|
||||
app=this;
|
||||
}
|
||||
private Forge() {
|
||||
}
|
||||
|
||||
@@ -171,7 +158,7 @@ public class Forge implements ApplicationListener {
|
||||
else {
|
||||
skinName = "default"; //use default skin if preferences file doesn't exist yet
|
||||
}
|
||||
FSkin.loadLight(skinName, splashScreen);
|
||||
FSkin.loadLight(isDesktopAdventureMode ? "default" : skinName, splashScreen);
|
||||
|
||||
textureFiltering = prefs.getPrefBoolean(FPref.UI_LIBGDX_TEXTURE_FILTERING);
|
||||
showFPS = prefs.getPrefBoolean(FPref.UI_SHOW_FPS);
|
||||
@@ -282,6 +269,7 @@ public class Forge implements ApplicationListener {
|
||||
System.out.println(fScreen.toString());*/
|
||||
}
|
||||
public static void openHomeDefault() {
|
||||
GuiBase.setIsAdventureMode(false);
|
||||
openHomeScreen(-1, null); //default for startup
|
||||
splashScreen = null;
|
||||
if (isLandscapeMode()) { //open preferred new game screen by default if landscape mode
|
||||
@@ -292,6 +280,7 @@ public class Forge implements ApplicationListener {
|
||||
startContinuousRendering();
|
||||
final LoadingOverlay loader = new LoadingOverlay("Loading Adventure");
|
||||
loader.show();
|
||||
GuiBase.setIsAdventureMode(true);
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -323,20 +312,22 @@ public class Forge implements ApplicationListener {
|
||||
Gdx.input.setCatchKey(Keys.MENU, true);
|
||||
|
||||
afterDBloaded = true;
|
||||
if (isDesktopAdventureMode) {
|
||||
openAdventure();
|
||||
} else {
|
||||
//open splashscreen mode selector if landscape..
|
||||
if (isLandscapeMode())
|
||||
splashScreen.setShowModeSelector(true);
|
||||
else
|
||||
openHomeDefault();
|
||||
|
||||
boolean isLandscapeMode = isLandscapeMode();
|
||||
}
|
||||
|
||||
//adjust height modifier
|
||||
adjustHeightModifier(getScreenWidth(), getScreenHeight());
|
||||
|
||||
//update landscape mode preference if it doesn't match what the app loaded as
|
||||
if (FModel.getPreferences().getPrefBoolean(FPref.UI_LANDSCAPE_MODE) != isLandscapeMode) {
|
||||
FModel.getPreferences().setPref(FPref.UI_LANDSCAPE_MODE, isLandscapeMode);
|
||||
if (FModel.getPreferences().getPrefBoolean(FPref.UI_LANDSCAPE_MODE) != isLandscapeMode()) {
|
||||
FModel.getPreferences().setPref(FPref.UI_LANDSCAPE_MODE, isLandscapeMode());
|
||||
FModel.getPreferences().save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,203 +0,0 @@
|
||||
package forge.adventure;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Clipboard;
|
||||
import com.badlogic.gdx.utils.ScreenUtils;
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.adventure.scene.ForgeScene;
|
||||
import forge.adventure.scene.Scene;
|
||||
import forge.adventure.scene.SceneType;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.interfaces.IDeviceAdapter;
|
||||
|
||||
/**
|
||||
* Application adapter the handle switching and fading between scenes
|
||||
*/
|
||||
public class AdventureApplicationAdapter extends Forge {
|
||||
public static AdventureApplicationAdapter instance;
|
||||
static Scene currentScene = null;
|
||||
static Array<Scene> lastScene = new Array<>();
|
||||
private int currentWidth;
|
||||
private int currentHeight;
|
||||
private float animationTimeout;
|
||||
Batch animationBatch;
|
||||
Texture transitionTexture;
|
||||
static TextureRegion lastScreenTexture;
|
||||
private static boolean sceneWasSwapped =false;
|
||||
private static Graphics graphics;
|
||||
|
||||
public static Graphics getGraphics()
|
||||
{
|
||||
if(graphics==null)
|
||||
graphics=new Graphics();
|
||||
return graphics;
|
||||
}
|
||||
|
||||
public TextureRegion getLastScreenTexture() {
|
||||
return lastScreenTexture;
|
||||
}
|
||||
public AdventureApplicationAdapter(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidAPI, String AndroidRelease, String deviceName) {
|
||||
super(clipboard0, deviceAdapter0, assetDir0, value, androidOrientation, totalRAM, isTablet, AndroidAPI, AndroidRelease, deviceName);
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public int getCurrentWidth() {
|
||||
return currentWidth;
|
||||
}
|
||||
|
||||
public int getCurrentHeight() {
|
||||
return currentHeight;
|
||||
}
|
||||
|
||||
|
||||
public static Scene getCurrentScene() {
|
||||
return currentScene;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(int w, int h) {
|
||||
currentWidth = w;
|
||||
currentHeight = h;
|
||||
super.resize(w, h);
|
||||
}
|
||||
|
||||
public static boolean switchScene(Scene newScene) {
|
||||
|
||||
if (currentScene != null) {
|
||||
if (!currentScene.leave())
|
||||
return false;
|
||||
lastScene.add(currentScene);
|
||||
}
|
||||
storeScreen();
|
||||
sceneWasSwapped =true;
|
||||
currentScene = newScene;
|
||||
currentScene.enter();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected static void storeScreen() {
|
||||
if(!(currentScene instanceof ForgeScene))
|
||||
{
|
||||
if(lastScreenTexture!=null)
|
||||
lastScreenTexture.getTexture().dispose();
|
||||
lastScreenTexture = ScreenUtils.getFrameBufferTexture();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void resLoaded() {
|
||||
for (forge.adventure.scene.SceneType entry : SceneType.values()) {
|
||||
entry.instance.resLoaded();
|
||||
}
|
||||
//AdventureApplicationAdapter.CurrentAdapter.switchScene(SceneType.RewardScene.instance);
|
||||
|
||||
|
||||
switchScene(SceneType.StartScene.instance);
|
||||
animationBatch=new SpriteBatch();
|
||||
transitionTexture =new Texture(Config.instance().getFile("ui/transition.png"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
|
||||
Pixmap pm = new Pixmap(Config.instance().getFile("skin/cursor.png"));
|
||||
Gdx.graphics.setCursor(Gdx.graphics.newCursor(pm, 0, 0));
|
||||
pm.dispose();
|
||||
for (forge.adventure.scene.SceneType entry : SceneType.values()) {
|
||||
entry.instance.create();
|
||||
}
|
||||
super.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
float delta=Gdx.graphics.getDeltaTime();
|
||||
float transitionTime = 0.2f;
|
||||
if(sceneWasSwapped)
|
||||
{
|
||||
sceneWasSwapped =false;
|
||||
animationTimeout= transitionTime;
|
||||
Gdx.gl.glClearColor(0, 0, 0, 1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
return;
|
||||
}
|
||||
if(animationTimeout>=0)
|
||||
{
|
||||
Gdx.gl.glClearColor(0, 0, 0, 1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
animationBatch.begin();
|
||||
animationTimeout-=delta;
|
||||
animationBatch.setColor(1,1,1,1);
|
||||
animationBatch.draw(lastScreenTexture,0,0, Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
|
||||
animationBatch.setColor(1,1,1,1-(1/ transitionTime)*animationTimeout);
|
||||
animationBatch.draw(transitionTexture,0,0, Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
|
||||
animationBatch.draw(transitionTexture,0,0, Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
|
||||
animationBatch.end();
|
||||
if(animationTimeout<0)
|
||||
{
|
||||
currentScene.render();
|
||||
storeScreen();
|
||||
Gdx.gl.glClearColor(0, 0, 0, 1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(animationTimeout>=-transitionTime)
|
||||
{
|
||||
Gdx.gl.glClearColor(0, 0, 0, 1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
animationBatch.begin();
|
||||
animationTimeout-=delta;
|
||||
animationBatch.setColor(1,1,1,1);
|
||||
animationBatch.draw(lastScreenTexture,0,0, Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
|
||||
animationBatch.setColor(1,1,1,(1/ transitionTime)*(animationTimeout+ transitionTime));
|
||||
animationBatch.draw(transitionTexture,0,0, Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
|
||||
animationBatch.draw(transitionTexture,0,0, Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
|
||||
animationBatch.end();
|
||||
return;
|
||||
}
|
||||
currentScene.render();
|
||||
currentScene.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
for (forge.adventure.scene.SceneType entry : SceneType.values()) {
|
||||
entry.instance.dispose();
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
private Scene getLastScene() {
|
||||
return lastScene.size==0?null: lastScene.get(lastScene.size-1);
|
||||
}
|
||||
|
||||
public static Scene switchToLast() {
|
||||
|
||||
if(lastScene.size!=0)
|
||||
{
|
||||
storeScreen();
|
||||
currentScene = lastScene.get(lastScene.size-1);
|
||||
currentScene.enter();
|
||||
sceneWasSwapped =true;
|
||||
lastScene.removeIndex(lastScene.size-1);
|
||||
return currentScene;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.adventure.AdventureApplicationAdapter;
|
||||
import forge.animation.ForgeAnimation;
|
||||
import forge.assets.ImageCache;
|
||||
import forge.gamemodes.match.LobbySlotType;
|
||||
@@ -21,7 +18,6 @@ import java.util.List;
|
||||
public abstract class ForgeScene extends Scene implements IUpdateable {
|
||||
|
||||
//GameLobby lobby;
|
||||
Graphics localGraphics;
|
||||
ForgeInput input=new ForgeInput(this);
|
||||
@Override
|
||||
public void dispose() {
|
||||
@@ -29,42 +25,6 @@ public abstract class ForgeScene extends Scene implements IUpdateable {
|
||||
@Override
|
||||
public void render() {
|
||||
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Clear the screen.
|
||||
if (getScreen() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
localGraphics.begin(Forge.isMobileAdventureMode ? Forge.getScreenWidth() : AdventureApplicationAdapter.instance.getCurrentWidth(),
|
||||
Forge.isMobileAdventureMode ? Forge.getScreenHeight() : AdventureApplicationAdapter.instance.getCurrentHeight());
|
||||
getScreen().screenPos.setSize(Forge.isMobileAdventureMode ? Forge.getScreenWidth() : AdventureApplicationAdapter.instance.getCurrentWidth(),
|
||||
Forge.isMobileAdventureMode ? Forge.getScreenHeight() : AdventureApplicationAdapter.instance.getCurrentHeight());
|
||||
if (getScreen().getRotate180()) {
|
||||
localGraphics.startRotateTransform( Forge.isMobileAdventureMode ? Forge.getScreenWidth() / 2f : AdventureApplicationAdapter.instance.getCurrentWidth() / 2f,
|
||||
Forge.isMobileAdventureMode ? Forge.getScreenHeight() / 2f : AdventureApplicationAdapter.instance.getCurrentHeight() / 2f, 180);
|
||||
}
|
||||
getScreen().draw(localGraphics);
|
||||
if (getScreen().getRotate180()) {
|
||||
localGraphics.endTransform();
|
||||
}
|
||||
for (FOverlay overlay : FOverlay.getOverlays()) {
|
||||
if (overlay.isVisibleOnScreen(getScreen())) {
|
||||
overlay.screenPos.setSize(Forge.isMobileAdventureMode ? Forge.getScreenWidth() : AdventureApplicationAdapter.instance.getCurrentWidth(),
|
||||
Forge.isMobileAdventureMode ? Forge.getScreenHeight() : AdventureApplicationAdapter.instance.getCurrentHeight());
|
||||
overlay.setSize(Forge.isMobileAdventureMode ? Forge.getScreenWidth() : AdventureApplicationAdapter.instance.getCurrentWidth(),
|
||||
Forge.isMobileAdventureMode ? Forge.getScreenHeight() : AdventureApplicationAdapter.instance.getCurrentHeight()); //update overlay sizes as they're rendered
|
||||
if (overlay.getRotate180()) {
|
||||
localGraphics.startRotateTransform(AdventureApplicationAdapter.instance.getCurrentHeight() / 2f, AdventureApplicationAdapter.instance.getCurrentHeight() / 2f, 180);
|
||||
}
|
||||
overlay.draw(localGraphics);
|
||||
if (overlay.getRotate180()) {
|
||||
localGraphics.endTransform();
|
||||
}
|
||||
}
|
||||
}
|
||||
localGraphics.end();
|
||||
|
||||
//Batch.end();
|
||||
}
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
@@ -78,8 +38,7 @@ public abstract class ForgeScene extends Scene implements IUpdateable {
|
||||
public void enter() {
|
||||
FOverlay.hideAll();
|
||||
if(getScreen()!=null)
|
||||
getScreen().setSize(Forge.isMobileAdventureMode ? Forge.getScreenWidth() : AdventureApplicationAdapter.instance.getCurrentWidth(),
|
||||
Forge.isMobileAdventureMode ? Forge.getScreenHeight() : AdventureApplicationAdapter.instance.getCurrentHeight());
|
||||
getScreen().setSize(Forge.getScreenWidth(), Forge.getScreenHeight());
|
||||
|
||||
Forge.openScreen(getScreen());
|
||||
Gdx.input.setInputProcessor(input);
|
||||
@@ -94,7 +53,7 @@ public abstract class ForgeScene extends Scene implements IUpdateable {
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
localGraphics = Forge.getGraphics();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user