mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Fix
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package forge.adventure;
|
||||
|
||||
import com.badlogic.gdx.ApplicationListener;
|
||||
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.glutils.HdpiMode;
|
||||
import forge.Forge;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.util.BuildInfo;
|
||||
@@ -34,11 +36,20 @@ public class Main {
|
||||
|
||||
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
||||
config.setResizable(false);
|
||||
ApplicationListener start = Forge.getApp(new Lwjgl3Clipboard(), new DesktopAdapter(""), Files.exists(Paths.get("./res"))?"./":"../forge-gui/", true, false, 0, true, 0, "", "");
|
||||
|
||||
//todo icon config && fullscreen mode
|
||||
config.setWindowedMode(1280, 720);
|
||||
if (Config.instance().getSettingData().fullScreen) {
|
||||
config.setFullscreenMode(Lwjgl3ApplicationConfiguration.getDisplayMode());
|
||||
config.setAutoIconify(true);
|
||||
config.setHdpiMode(HdpiMode.Logical);
|
||||
} else {
|
||||
config.setWindowedMode(Config.instance().getSettingData().width, Config.instance().getSettingData().height);
|
||||
}
|
||||
config.setTitle("Forge Mobile");
|
||||
config.setWindowIcon(Config.instance().getFilePath("forge-adventure.png"));
|
||||
|
||||
new Lwjgl3Application(Forge.getApp(new Lwjgl3Clipboard(), new DesktopAdapter(""), Files.exists(Paths.get("./res"))?"./":"../forge-gui/", true, false, 0, true, 0, "", "", true), config);
|
||||
|
||||
new Lwjgl3Application(start, 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(), false));
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, true, totalRAM, isTabletDevice, AndroidAPI, AndroidRelease, getDeviceName()));
|
||||
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(), false));
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, true, totalRAM, isTabletDevice, AndroidAPI, AndroidRelease, getDeviceName()));
|
||||
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(), false));
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, isPortrait, totalRAM, isTabletDevice, AndroidAPI, AndroidRelease, getDeviceName()));
|
||||
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, "", "", false);
|
||||
final ApplicationListener app = Forge.getApp(new IOSClipboard(), new IOSAdapter(), assetsDir, propertyConfig, false, 0, false, 0, "", "");
|
||||
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, "", "", false), config);
|
||||
desktopMode ? desktopModeAssetsDir : assetsDir, propertyConfig, false, 0, false, 0, "", ""), config);
|
||||
}
|
||||
|
||||
private static class DesktopAdapter implements IDeviceAdapter {
|
||||
|
||||
@@ -90,7 +90,6 @@ 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;
|
||||
@@ -101,7 +100,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, boolean startAdventure) {
|
||||
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidAPI, String AndroidRelease, String deviceName) {
|
||||
app = new Forge();
|
||||
if (GuiBase.getInterface() == null) {
|
||||
clipboard = clipboard0;
|
||||
@@ -113,7 +112,6 @@ public class Forge implements ApplicationListener {
|
||||
totalDeviceRAM = totalRAM;
|
||||
isTabletDevice = isTablet;
|
||||
androidVersion = AndroidAPI;
|
||||
isDesktopAdventureMode=startAdventure;
|
||||
}
|
||||
GuiBase.setDeviceInfo(deviceName, AndroidRelease, AndroidAPI, totalRAM);
|
||||
return app;
|
||||
@@ -158,7 +156,7 @@ public class Forge implements ApplicationListener {
|
||||
else {
|
||||
skinName = "default"; //use default skin if preferences file doesn't exist yet
|
||||
}
|
||||
FSkin.loadLight(isDesktopAdventureMode ? "default" : skinName, splashScreen);
|
||||
FSkin.loadLight(skinName, splashScreen);
|
||||
|
||||
textureFiltering = prefs.getPrefBoolean(FPref.UI_LIBGDX_TEXTURE_FILTERING);
|
||||
showFPS = prefs.getPrefBoolean(FPref.UI_SHOW_FPS);
|
||||
@@ -278,31 +276,15 @@ public class Forge implements ApplicationListener {
|
||||
}
|
||||
public static void openAdventure() {
|
||||
startContinuousRendering();
|
||||
if (!isDesktopAdventureMode) {
|
||||
final LoadingOverlay loader = new LoadingOverlay("Loading Adventure");
|
||||
loader.show();
|
||||
}
|
||||
GuiBase.setIsAdventureMode(true);
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//FSkin.loadLight("default", null, Config.instance().getFile("skin"));
|
||||
//FSkin.loadFull(splashScreen);
|
||||
splashScreen = null;
|
||||
isMobileAdventureMode = true;
|
||||
try {
|
||||
for (SceneType sceneType : SceneType.values()) {
|
||||
sceneType.instance.resLoaded();
|
||||
}
|
||||
switchScene(SceneType.StartScene.instance);
|
||||
} catch (Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
});
|
||||
splashScreen = null;
|
||||
isMobileAdventureMode = true;
|
||||
try {
|
||||
for (SceneType sceneType : SceneType.values()) {
|
||||
sceneType.instance.resLoaded();
|
||||
}
|
||||
});
|
||||
switchScene(SceneType.StartScene.instance);
|
||||
} catch (Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
protected void afterDbLoaded() {
|
||||
stopContinuousRendering(); //save power consumption by disabling continuous rendering once assets loaded
|
||||
@@ -314,15 +296,11 @@ 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();
|
||||
}
|
||||
//selection
|
||||
if (isLandscapeMode() && !GuiBase.isAndroid())
|
||||
splashScreen.setShowModeSelector(true);
|
||||
else
|
||||
openHomeDefault();
|
||||
|
||||
//adjust height modifier
|
||||
adjustHeightModifier(getScreenWidth(), getScreenHeight());
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
import forge.Forge;
|
||||
import forge.gui.GuiBase;
|
||||
import forge.gui.error.BugReporter;
|
||||
import forge.screens.match.MatchController;
|
||||
import forge.toolbox.FContainer;
|
||||
@@ -280,6 +281,20 @@ public class ForgeInput extends FGestureAdapter {
|
||||
public boolean mouseMoved(int x, int y) {
|
||||
mouseMovedX = x;
|
||||
mouseMovedY = y;
|
||||
//todo: mouse listener for android?
|
||||
if (GuiBase.isAndroid())
|
||||
return true;
|
||||
Forge.hoveredCount = 0;
|
||||
//reset
|
||||
try {
|
||||
for (FDisplayObject listener : potentialListeners) {
|
||||
listener.setHovered(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
}
|
||||
updatePotentialListeners(x, y);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.animation.ForgeAnimation;
|
||||
import forge.assets.ImageCache;
|
||||
import forge.gamemodes.match.LobbySlotType;
|
||||
@@ -18,6 +20,7 @@ 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() {
|
||||
@@ -25,6 +28,37 @@ 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.getScreenWidth(), Forge.getScreenHeight());
|
||||
getScreen().screenPos.setSize(Forge.getScreenWidth(), Forge.getScreenHeight());
|
||||
if (getScreen().getRotate180()) {
|
||||
localGraphics.startRotateTransform( Forge.getScreenWidth() / 2f, Forge.getScreenHeight() / 2f, 180);
|
||||
}
|
||||
getScreen().draw(localGraphics);
|
||||
if (getScreen().getRotate180()) {
|
||||
localGraphics.endTransform();
|
||||
}
|
||||
for (FOverlay overlay : FOverlay.getOverlays()) {
|
||||
if (overlay.isVisibleOnScreen(getScreen())) {
|
||||
overlay.screenPos.setSize(Forge.getScreenWidth(), Forge.getScreenHeight());
|
||||
overlay.setSize(Forge.getScreenWidth(), Forge.getScreenHeight()); //update overlay sizes as they're rendered
|
||||
if (overlay.getRotate180()) {
|
||||
localGraphics.startRotateTransform(Forge.getScreenWidth() / 2f, Forge.getScreenHeight() / 2f, 180);
|
||||
}
|
||||
overlay.draw(localGraphics);
|
||||
if (overlay.getRotate180()) {
|
||||
localGraphics.endTransform();
|
||||
}
|
||||
}
|
||||
}
|
||||
localGraphics.end();
|
||||
|
||||
//Batch.end();
|
||||
}
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
@@ -53,7 +87,7 @@ public abstract class ForgeScene extends Scene implements IUpdateable {
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
|
||||
localGraphics = Forge.getGraphics();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -171,31 +171,29 @@ public class SettingsScene extends UIScene {
|
||||
addLabel("Plane");
|
||||
settingGroup.add(plane).align(Align.right);
|
||||
|
||||
if (!Forge.isMobileAdventureMode) {
|
||||
addSettingField("Fullscreen", Config.instance().getSettingData().fullScreen, new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Config.instance().getSettingData().fullScreen=((CheckBox) actor).isChecked();
|
||||
Config.instance().saveSettings();
|
||||
}
|
||||
});
|
||||
addSettingField("Screen width", Config.instance().getSettingData().width, new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
String text=((TextField) actor).getText();
|
||||
Config.instance().getSettingData().width=text==null||text.isEmpty()?0:Integer.valueOf(text);
|
||||
Config.instance().saveSettings();
|
||||
}
|
||||
});
|
||||
addSettingField("Screen height", Config.instance().getSettingData().height, new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
String text=((TextField) actor).getText();
|
||||
Config.instance().getSettingData().height=text==null||text.isEmpty()?0:Integer.valueOf(text);
|
||||
Config.instance().saveSettings();
|
||||
}
|
||||
});
|
||||
}
|
||||
addSettingField("Fullscreen", Config.instance().getSettingData().fullScreen, new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Config.instance().getSettingData().fullScreen=((CheckBox) actor).isChecked();
|
||||
Config.instance().saveSettings();
|
||||
}
|
||||
});
|
||||
addSettingField("Screen width", Config.instance().getSettingData().width, new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
String text=((TextField) actor).getText();
|
||||
Config.instance().getSettingData().width=text==null||text.isEmpty()?0:Integer.valueOf(text);
|
||||
Config.instance().saveSettings();
|
||||
}
|
||||
});
|
||||
addSettingField("Screen height", Config.instance().getSettingData().height, new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
String text=((TextField) actor).getText();
|
||||
Config.instance().getSettingData().height=text==null||text.isEmpty()?0:Integer.valueOf(text);
|
||||
Config.instance().saveSettings();
|
||||
}
|
||||
});
|
||||
addCheckBox(localizer.getMessage("lblCardName"), ForgePreferences.FPref.UI_OVERLAY_CARD_NAME);
|
||||
addSettingSlider(localizer.getMessage("cbAdjustMusicVolume"), ForgePreferences.FPref.UI_VOL_MUSIC,0,100);
|
||||
addSettingSlider(localizer.getMessage("cbAdjustSoundsVolume"), ForgePreferences.FPref.UI_VOL_SOUNDS, 0,100);
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import com.badlogic.gdx.utils.JsonWriter;
|
||||
import forge.Forge;
|
||||
import forge.adventure.data.ConfigData;
|
||||
import forge.adventure.data.SettingData;
|
||||
import forge.deck.Deck;
|
||||
@@ -40,10 +41,8 @@ public class Config {
|
||||
}
|
||||
private Config() {
|
||||
|
||||
String path= Files.exists(Paths.get("./res"))?"./":"../forge-gui/";
|
||||
if (GuiBase.isAndroid())
|
||||
path = GuiBase.getInterface().getAssetsDir();
|
||||
adventures = new File(path + "/res/adventure").list();
|
||||
String path= GuiBase.isAndroid() ? ForgeConstants.ASSETS_DIR : Files.exists(Paths.get("./res"))?"./":"../forge-gui/";
|
||||
adventures = new File(GuiBase.isAndroid() ? ForgeConstants.ADVENTURE_DIR : path + "/res/adventure").list();
|
||||
try
|
||||
{
|
||||
settingsData = new Json().fromJson(SettingData.class, new FileHandle(ForgeConstants.USER_DIR + "/adventure/settings.json"));
|
||||
|
||||
@@ -359,17 +359,17 @@ public class MatchScreen extends FScreen {
|
||||
if (viewWinLose == null) {
|
||||
gameMenu.getChildAt(0).setEnabled(!game.isMulligan());
|
||||
gameMenu.getChildAt(1).setEnabled(!game.isMulligan());
|
||||
gameMenu.getChildAt(2).setEnabled(!game.isMulligan());
|
||||
if (Forge.isMobileAdventureMode)
|
||||
gameMenu.getChildAt(2).setEnabled(false);
|
||||
gameMenu.getChildAt(3).setEnabled(false);
|
||||
if (!Forge.isMobileAdventureMode) {
|
||||
gameMenu.getChildAt(2).setEnabled(!game.isMulligan());
|
||||
gameMenu.getChildAt(3).setEnabled(false);
|
||||
}
|
||||
} else {
|
||||
gameMenu.getChildAt(0).setEnabled(false);
|
||||
gameMenu.getChildAt(1).setEnabled(false);
|
||||
gameMenu.getChildAt(2).setEnabled(false);
|
||||
if (Forge.isMobileAdventureMode)
|
||||
if (!Forge.isMobileAdventureMode) {
|
||||
gameMenu.getChildAt(2).setEnabled(false);
|
||||
gameMenu.getChildAt(3).setEnabled(true);
|
||||
gameMenu.getChildAt(3).setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,22 +68,24 @@ public class VGameMenu extends FDropDownMenu {
|
||||
autoYields.show();
|
||||
}
|
||||
}));
|
||||
addItem(new FMenuItem(localizer.getMessage("lblSettings"), Forge.hdbuttons ? FSkinImage.HDPREFERENCE : FSkinImage.SETTINGS, new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
//pause game when spectating AI Match
|
||||
if (!MatchController.instance.hasLocalPlayers()) {
|
||||
if(!MatchController.instance.isGamePaused())
|
||||
MatchController.instance.pauseMatch();
|
||||
if (!Forge.isMobileAdventureMode) {
|
||||
addItem(new FMenuItem(localizer.getMessage("lblSettings"), Forge.hdbuttons ? FSkinImage.HDPREFERENCE : FSkinImage.SETTINGS, new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
//pause game when spectating AI Match
|
||||
if (!MatchController.instance.hasLocalPlayers()) {
|
||||
if(!MatchController.instance.isGamePaused())
|
||||
MatchController.instance.pauseMatch();
|
||||
}
|
||||
SettingsScreen.show(false);
|
||||
}
|
||||
SettingsScreen.show(false);
|
||||
}
|
||||
}));
|
||||
addItem(new FMenuItem(localizer.getMessage("lblShowWinLoseOverlay"), FSkinImage.ENDTURN, new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
MatchController.instance.showWinlose();
|
||||
}
|
||||
}));
|
||||
}));
|
||||
addItem(new FMenuItem(localizer.getMessage("lblShowWinLoseOverlay"), FSkinImage.ENDTURN, new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
MatchController.instance.showWinlose();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public final class ForgeConstants {
|
||||
public static final String PROFILE_TEMPLATE_FILE = PROFILE_FILE + ".example";
|
||||
|
||||
public static final String RES_DIR = ASSETS_DIR + "res" + PATH_SEPARATOR;
|
||||
public static final String ADVENTURE_DIR = RES_DIR + "adventure" + PATH_SEPARATOR;
|
||||
public static final String LISTS_DIR = RES_DIR + "lists" + PATH_SEPARATOR;
|
||||
public static final String SETLOOKUP_DIR = RES_DIR + "setlookup" + PATH_SEPARATOR;
|
||||
public static final String KEYWORD_LIST_FILE = LISTS_DIR + "NonStackingKWList.txt";
|
||||
|
||||
Reference in New Issue
Block a user