Merge branch 'adventure' into 'master'
Fixed major thread bug in adventure matches See merge request core-developers/forge!5763
@@ -1,6 +1,5 @@
|
|||||||
package forge.adventure;
|
package forge.adventure;
|
||||||
|
|
||||||
import com.badlogic.gdx.ApplicationAdapter;
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.graphics.Pixmap;
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
@@ -9,17 +8,20 @@ import com.badlogic.gdx.graphics.g2d.Batch;
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import com.badlogic.gdx.utils.Clipboard;
|
||||||
import com.badlogic.gdx.utils.ScreenUtils;
|
import com.badlogic.gdx.utils.ScreenUtils;
|
||||||
|
import forge.Forge;
|
||||||
import forge.Graphics;
|
import forge.Graphics;
|
||||||
import forge.adventure.scene.ForgeScene;
|
import forge.adventure.scene.ForgeScene;
|
||||||
import forge.adventure.scene.Scene;
|
import forge.adventure.scene.Scene;
|
||||||
import forge.adventure.scene.SceneType;
|
import forge.adventure.scene.SceneType;
|
||||||
import forge.adventure.util.Config;
|
import forge.adventure.util.Config;
|
||||||
|
import forge.interfaces.IDeviceAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application adapter the handle switching and fading between scenes
|
* Application adapter the handle switching and fading between scenes
|
||||||
*/
|
*/
|
||||||
public class AdventureApplicationAdapter extends ApplicationAdapter {
|
public class AdventureApplicationAdapter extends Forge {
|
||||||
public static AdventureApplicationAdapter instance;
|
public static AdventureApplicationAdapter instance;
|
||||||
Scene currentScene = null;
|
Scene currentScene = null;
|
||||||
Array<Scene> lastScene = new Array<>();
|
Array<Scene> lastScene = new Array<>();
|
||||||
@@ -42,7 +44,8 @@ public class AdventureApplicationAdapter extends ApplicationAdapter {
|
|||||||
public TextureRegion getLastScreenTexture() {
|
public TextureRegion getLastScreenTexture() {
|
||||||
return lastScreenTexture;
|
return lastScreenTexture;
|
||||||
}
|
}
|
||||||
public AdventureApplicationAdapter() {
|
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;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +66,6 @@ public class AdventureApplicationAdapter extends ApplicationAdapter {
|
|||||||
public void resize(int w, int h) {
|
public void resize(int w, int h) {
|
||||||
currentWidth = w;
|
currentWidth = w;
|
||||||
currentHeight = h;
|
currentHeight = h;
|
||||||
StartAdventure.app.resize(w, h);
|
|
||||||
super.resize(w, h);
|
super.resize(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +116,7 @@ public class AdventureApplicationAdapter extends ApplicationAdapter {
|
|||||||
for (forge.adventure.scene.SceneType entry : SceneType.values()) {
|
for (forge.adventure.scene.SceneType entry : SceneType.values()) {
|
||||||
entry.instance.create();
|
entry.instance.create();
|
||||||
}
|
}
|
||||||
|
super.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,97 +6,34 @@ import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
|||||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
||||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Clipboard;
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Clipboard;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.utils.Clipboard;
|
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.FrameRate;
|
|
||||||
import forge.GuiMobile;
|
|
||||||
import forge.adventure.scene.SettingsScene;
|
|
||||||
import forge.adventure.util.Config;
|
import forge.adventure.util.Config;
|
||||||
import forge.assets.AssetsDownloader;
|
|
||||||
import forge.assets.FSkin;
|
import forge.assets.FSkin;
|
||||||
import forge.assets.FSkinFont;
|
|
||||||
import forge.assets.ImageCache;
|
|
||||||
import forge.error.ExceptionHandler;
|
|
||||||
import forge.gui.FThreads;
|
|
||||||
import forge.gui.GuiBase;
|
import forge.gui.GuiBase;
|
||||||
import forge.interfaces.IDeviceAdapter;
|
|
||||||
import forge.localinstance.properties.ForgeConstants;
|
|
||||||
import forge.localinstance.properties.ForgePreferences;
|
|
||||||
import forge.model.FModel;
|
|
||||||
import forge.screens.FScreen;
|
|
||||||
import forge.screens.SplashScreen;
|
|
||||||
import forge.sound.MusicPlaylist;
|
import forge.sound.MusicPlaylist;
|
||||||
import forge.sound.SoundSystem;
|
import forge.sound.SoundSystem;
|
||||||
import forge.util.BuildInfo;
|
import forge.util.BuildInfo;
|
||||||
import forge.util.CardTranslation;
|
|
||||||
import forge.util.FileUtil;
|
|
||||||
import forge.util.Localizer;
|
|
||||||
import io.sentry.Sentry;
|
import io.sentry.Sentry;
|
||||||
import io.sentry.SentryClient;
|
import io.sentry.SentryClient;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayDeque;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Deque;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper to start forge first (splash screen and resources loading)
|
* Wrapper to start forge first (splash screen and resources loading)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class StartAdventure extends AdventureApplicationAdapter {
|
class StartAdventure extends AdventureApplicationAdapter {
|
||||||
private static final int continuousRenderingCount = 1; //initialize to 1 since continuous rendering is the default
|
|
||||||
private static final Deque<FScreen> Dscreens = new ArrayDeque<>();
|
|
||||||
private static final boolean isloadingaMatch = false;
|
|
||||||
public static String extrawide = "default";
|
|
||||||
public static float heigtModifier = 0.0f;
|
|
||||||
public static boolean showFPS = false;
|
|
||||||
public static boolean altPlayerLayout = false;
|
|
||||||
public static boolean altZoneTabs = false;
|
|
||||||
public static String enableUIMask = "Crop";
|
|
||||||
public static boolean enablePreloadExtendedArt = false;
|
|
||||||
public static boolean isTabletDevice = false;
|
|
||||||
public static String locale = "en-US";
|
|
||||||
public static boolean hdbuttons = false;
|
|
||||||
public static boolean hdstart = false;
|
|
||||||
public static boolean isPortraitMode = false;
|
|
||||||
public static boolean gameInProgress = false;
|
|
||||||
public static boolean disposeTextures = false;
|
|
||||||
public static int cacheSize = 400;
|
|
||||||
public static int totalDeviceRAM = 0;
|
|
||||||
public static int androidVersion = 0;
|
|
||||||
public static boolean autoCache = false;
|
|
||||||
public static int lastButtonIndex = 0;
|
|
||||||
public static String CJK_Font = "";
|
|
||||||
public static Forge app;
|
|
||||||
private static Clipboard clipboard;
|
|
||||||
private static IDeviceAdapter deviceAdapter;
|
|
||||||
private static FrameRate frameRate;
|
|
||||||
private static FScreen currentScreen;
|
|
||||||
private static SplashScreen splashScreen;
|
|
||||||
private static Forge.KeyInputAdapter keyInputAdapter;
|
|
||||||
private static boolean exited;
|
|
||||||
private static boolean textureFiltering = false;
|
|
||||||
private static boolean destroyThis = false;
|
|
||||||
|
|
||||||
public StartAdventure() {
|
|
||||||
|
|
||||||
super();
|
public StartAdventure( ) {
|
||||||
|
|
||||||
|
super(new Lwjgl3Clipboard(), new DesktopAdapter(""), Files.exists(Paths.get("./res"))?"./":"../forge-gui/", true, false, 0, true, 0, "", "");
|
||||||
Forge.isTabletDevice = true;
|
Forge.isTabletDevice = true;
|
||||||
Forge.isPortraitMode = false;
|
Forge.isPortraitMode = false;
|
||||||
Forge.hdbuttons = true;
|
Forge.hdbuttons = true;
|
||||||
Forge.hdstart = true;
|
Forge.hdstart = true;
|
||||||
|
|
||||||
String path= Files.exists(Paths.get("./res"))?"./":"../forge-gui/";
|
|
||||||
|
|
||||||
app = (Forge) Forge.getApp(new Lwjgl3Clipboard(), new DesktopAdapter(""), path, true, false, 0, true, 0, "", "");
|
|
||||||
|
|
||||||
clipboard = new Lwjgl3Clipboard();
|
|
||||||
GuiBase.setUsingAppDirectory(false); //obb directory on android uses the package name as entrypoint
|
|
||||||
GuiBase.setInterface(new GuiMobile(path));
|
|
||||||
GuiBase.enablePropertyConfig(true);
|
|
||||||
isPortraitMode = true;
|
isPortraitMode = true;
|
||||||
totalDeviceRAM = 0;
|
totalDeviceRAM = 0;
|
||||||
GuiBase.setDeviceInfo("", "", 0, 0);
|
GuiBase.setDeviceInfo("", "", 0, 0);
|
||||||
@@ -135,129 +72,29 @@ class StartAdventure extends AdventureApplicationAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
//install our error handler
|
//install our error handler
|
||||||
ExceptionHandler.registerErrorHandling();
|
FSkin.loadLight("default", splashScreen,Config.instance().getFile("skin"));
|
||||||
splashScreen = new SplashScreen();
|
|
||||||
frameRate = new FrameRate();
|
|
||||||
/*
|
|
||||||
Set CatchBackKey here and exit the app when you hit the
|
|
||||||
back button while the textures,fonts,etc are still loading,
|
|
||||||
to prevent rendering issue when you try to restart
|
|
||||||
the app again (seems it doesnt dispose correctly...?!?)
|
|
||||||
*/
|
|
||||||
Gdx.input.setCatchKey(Input.Keys.BACK, true);
|
|
||||||
destroyThis = true; //Prevent back()
|
|
||||||
ForgePreferences prefs = SettingsScene.Preference = new ForgePreferences();
|
|
||||||
|
|
||||||
|
|
||||||
String skinName;
|
|
||||||
if (FileUtil.doesFileExist(ForgeConstants.MAIN_PREFS_FILE)) {
|
|
||||||
skinName = prefs.getPref(ForgePreferences.FPref.UI_SKIN);
|
|
||||||
} else {
|
|
||||||
skinName = "default"; //use default skin if preferences file doesn't exist yet
|
|
||||||
}
|
|
||||||
FSkin.loadLight(skinName, splashScreen,Config.instance().getFile("skin"));
|
|
||||||
|
|
||||||
textureFiltering = prefs.getPrefBoolean(ForgePreferences.FPref.UI_LIBGDX_TEXTURE_FILTERING);
|
|
||||||
showFPS = prefs.getPrefBoolean(ForgePreferences.FPref.UI_SHOW_FPS);
|
|
||||||
altPlayerLayout = prefs.getPrefBoolean(ForgePreferences.FPref.UI_ALT_PLAYERINFOLAYOUT);
|
|
||||||
altZoneTabs = prefs.getPrefBoolean(ForgePreferences.FPref.UI_ALT_PLAYERZONETABS);
|
|
||||||
enableUIMask = prefs.getPref(ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING);
|
|
||||||
if (prefs.getPref(ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING).equals("true")) //override old settings if not updated
|
|
||||||
enableUIMask = "Full";
|
|
||||||
else if (prefs.getPref(ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING).equals("false"))
|
|
||||||
enableUIMask = "Off";
|
|
||||||
enablePreloadExtendedArt = prefs.getPrefBoolean(ForgePreferences.FPref.UI_ENABLE_PRELOAD_EXTENDED_ART);
|
|
||||||
locale = prefs.getPref(ForgePreferences.FPref.UI_LANGUAGE);
|
|
||||||
autoCache = prefs.getPrefBoolean(ForgePreferences.FPref.UI_AUTO_CACHE_SIZE);
|
|
||||||
disposeTextures = prefs.getPrefBoolean(ForgePreferences.FPref.UI_ENABLE_DISPOSE_TEXTURES);
|
|
||||||
CJK_Font = prefs.getPref(ForgePreferences.FPref.UI_CJK_FONT);
|
|
||||||
|
|
||||||
if (autoCache) {
|
|
||||||
//increase cacheSize for devices with RAM more than 5GB, default is 400. Some phones have more than 10GB RAM (Mi 10, OnePlus 8, S20, etc..)
|
|
||||||
if (totalDeviceRAM > 5000) //devices with more than 10GB RAM will have 800 Cache size, 600 Cache size for morethan 5GB RAM
|
|
||||||
cacheSize = totalDeviceRAM > 10000 ? 800 : 600;
|
|
||||||
}
|
|
||||||
//init cache
|
|
||||||
ImageCache.initCache(cacheSize);
|
|
||||||
final Localizer localizer = Localizer.getInstance();
|
|
||||||
|
|
||||||
//load model on background thread (using progress bar to report progress)
|
//load model on background thread (using progress bar to report progress)
|
||||||
super.create();
|
super.create();
|
||||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
//see if app or assets need updating
|
|
||||||
AssetsDownloader.checkForUpdates(splashScreen);
|
|
||||||
if (exited) {
|
|
||||||
return;
|
|
||||||
} //don't continue if user chose to exit or couldn't download required assets
|
|
||||||
|
|
||||||
FModel.initialize(splashScreen.getProgressBar(), null);
|
|
||||||
|
|
||||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblLoadingFonts"));
|
|
||||||
FSkinFont.preloadAll(locale);
|
|
||||||
|
|
||||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblLoadingCardTranslations"));
|
|
||||||
CardTranslation.preloadTranslation(locale, ForgeConstants.LANG_DIR);
|
|
||||||
|
|
||||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblFinishingStartup"));
|
|
||||||
|
|
||||||
//add reminder to preload
|
|
||||||
if (enablePreloadExtendedArt) {
|
|
||||||
if (autoCache)
|
|
||||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblPreloadExtendedArt") + "\nDetected RAM: " + totalDeviceRAM + "MB. Cache size: " + cacheSize);
|
|
||||||
else
|
|
||||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblPreloadExtendedArt"));
|
|
||||||
} else {
|
|
||||||
if (autoCache)
|
|
||||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblFinishingStartup") + "\nDetected RAM: " + totalDeviceRAM + "MB. Cache size: " + cacheSize);
|
|
||||||
else
|
|
||||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblFinishingStartup"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Gdx.app.postRunnable(new Runnable() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
protected void afterDbLoaded()
|
||||||
|
{
|
||||||
|
FSkin.loadLight("default", splashScreen,Config.instance().getFile("skin"));
|
||||||
FSkin.loadFull(splashScreen);
|
FSkin.loadFull(splashScreen);
|
||||||
|
|
||||||
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS); //start background music
|
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS); //start background music
|
||||||
destroyThis = false; //Allow back()
|
|
||||||
Gdx.input.setCatchKey(Input.Keys.MENU, true);
|
Gdx.input.setCatchKey(Input.Keys.MENU, true);
|
||||||
//openHomeScreen(-1); //default for startup
|
//openHomeScreen(-1, null); //default for startup
|
||||||
splashScreen = null;
|
splashScreen = null;
|
||||||
|
afterDBloaded = true;
|
||||||
|
|
||||||
|
|
||||||
//adjust height modifier
|
//adjust height modifier
|
||||||
|
adjustHeightModifier(getScreenWidth(), getScreenHeight());
|
||||||
//update landscape mode preference if it doesn't match what the app loaded as
|
|
||||||
if (!FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_LANDSCAPE_MODE)) {
|
|
||||||
FModel.getPreferences().setPref(ForgePreferences.FPref.UI_LANDSCAPE_MODE, true);
|
|
||||||
FModel.getPreferences().save();
|
|
||||||
}
|
|
||||||
|
|
||||||
resLoaded();
|
resLoaded();
|
||||||
if (!enablePreloadExtendedArt)
|
|
||||||
return;
|
|
||||||
List<String> borderlessCardlistkeys = FileUtil.readFile(ForgeConstants.BORDERLESS_CARD_LIST_FILE);
|
|
||||||
if (borderlessCardlistkeys.isEmpty())
|
|
||||||
return;
|
|
||||||
List<String> filteredkeys = new ArrayList<>();
|
|
||||||
for (String cardname : borderlessCardlistkeys) {
|
|
||||||
File image = new File(ForgeConstants.CACHE_CARD_PICS_DIR + ForgeConstants.PATH_SEPARATOR + cardname + ".jpg");
|
|
||||||
if (image.exists())
|
|
||||||
filteredkeys.add(cardname);
|
|
||||||
}
|
|
||||||
if (!filteredkeys.isEmpty())
|
|
||||||
ImageCache.preloadCache(filteredkeys);
|
|
||||||
/* call preloadExtendedArt here, if we put it above we will *
|
|
||||||
* get error: No OpenGL context found in the current thread. */
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package forge.adventure.character;
|
package forge.adventure.character;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.*;
|
import com.badlogic.gdx.graphics.g2d.*;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.ObjectSet;
|
|
||||||
import forge.adventure.stage.SpriteGroup;
|
import forge.adventure.stage.SpriteGroup;
|
||||||
import forge.adventure.util.Config;
|
import forge.adventure.util.Config;
|
||||||
|
|
||||||
@@ -30,8 +28,10 @@ public class CharacterSprite extends MapActor {
|
|||||||
|
|
||||||
protected void load(String path) {
|
protected void load(String path) {
|
||||||
TextureAtlas atlas = Config.instance().getAtlas(path);
|
TextureAtlas atlas = Config.instance().getAtlas(path);
|
||||||
|
/*
|
||||||
for (Texture texture : new ObjectSet.ObjectSetIterator<>( atlas.getTextures()))
|
for (Texture texture : new ObjectSet.ObjectSetIterator<>( atlas.getTextures()))
|
||||||
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
|
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
|
||||||
|
*/
|
||||||
animations.clear();
|
animations.clear();
|
||||||
for (AnimationTypes stand : AnimationTypes.values()) {
|
for (AnimationTypes stand : AnimationTypes.values()) {
|
||||||
if (stand == AnimationTypes.Avatar) {
|
if (stand == AnimationTypes.Avatar) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package forge.adventure.data;
|
package forge.adventure.data;
|
||||||
|
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
@@ -28,7 +27,9 @@ public class HeroListData {
|
|||||||
instance = json.fromJson(HeroListData.class, handle);
|
instance = json.fromJson(HeroListData.class, handle);
|
||||||
instance.avatarSprites = Config.instance().getAtlas(instance.avatar);
|
instance.avatarSprites = Config.instance().getAtlas(instance.avatar);
|
||||||
|
|
||||||
|
/*
|
||||||
instance.avatarSprites.getTextures().first().setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
|
instance.avatarSprites.getTextures().first().setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
package forge.adventure.scene;
|
package forge.adventure.scene;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import forge.LobbyPlayer;
|
import forge.LobbyPlayer;
|
||||||
import forge.adventure.AdventureApplicationAdapter;
|
import forge.adventure.AdventureApplicationAdapter;
|
||||||
import forge.adventure.character.EnemySprite;
|
import forge.adventure.character.EnemySprite;
|
||||||
import forge.adventure.character.PlayerSprite;
|
import forge.adventure.character.PlayerSprite;
|
||||||
import forge.assets.FSkin;
|
|
||||||
import forge.screens.FScreen;
|
|
||||||
import forge.screens.match.MatchController;
|
|
||||||
import forge.adventure.util.Current;
|
|
||||||
import forge.adventure.util.Config;
|
import forge.adventure.util.Config;
|
||||||
|
import forge.adventure.util.Current;
|
||||||
import forge.adventure.world.AdventurePlayer;
|
import forge.adventure.world.AdventurePlayer;
|
||||||
|
import forge.assets.FSkin;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.game.GameRules;
|
import forge.game.GameRules;
|
||||||
import forge.game.GameType;
|
import forge.game.GameType;
|
||||||
@@ -19,6 +18,10 @@ import forge.gamemodes.match.HostedMatch;
|
|||||||
import forge.gui.interfaces.IGuiGame;
|
import forge.gui.interfaces.IGuiGame;
|
||||||
import forge.player.GamePlayerUtil;
|
import forge.player.GamePlayerUtil;
|
||||||
import forge.player.PlayerControllerHuman;
|
import forge.player.PlayerControllerHuman;
|
||||||
|
import forge.screens.FScreen;
|
||||||
|
import forge.screens.match.MatchController;
|
||||||
|
import forge.sound.MusicPlaylist;
|
||||||
|
import forge.sound.SoundSystem;
|
||||||
import forge.trackable.TrackableCollection;
|
import forge.trackable.TrackableCollection;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -44,12 +47,16 @@ public class DuelScene extends ForgeScene {
|
|||||||
|
|
||||||
|
|
||||||
public void GameEnd() {
|
public void GameEnd() {
|
||||||
|
Gdx.app.postRunnable(() -> {
|
||||||
|
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS); //start background music
|
||||||
Scene last= AdventureApplicationAdapter.instance.switchToLast();
|
Scene last= AdventureApplicationAdapter.instance.switchToLast();
|
||||||
|
|
||||||
if(last instanceof HudScene)
|
if(last instanceof HudScene)
|
||||||
{
|
{
|
||||||
((HudScene)last).stage.setWinner(humanPlayer == hostedMatch.getGame().getMatch().getWinner());
|
((HudScene)last).stage.setWinner(humanPlayer == hostedMatch.getGame().getMatch().getWinner());
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,22 @@ public class SettingsScene extends UIScene {
|
|||||||
AdventureApplicationAdapter.instance.switchToLast();
|
AdventureApplicationAdapter.instance.switchToLast();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
private void addInputField(String name, ForgePreferences.FPref pref) {
|
||||||
|
|
||||||
|
|
||||||
|
TextField box = Controls.newTextField("");
|
||||||
|
box.setText(Preference.getPref(pref));
|
||||||
|
box.addListener(new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
|
Preference.setPref(pref, ((TextField) actor).getText());
|
||||||
|
Preference.save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
addLabel(name);
|
||||||
|
settingGroup.add(box).align(Align.right);
|
||||||
|
}
|
||||||
private void addCheckBox(String name, ForgePreferences.FPref pref) {
|
private void addCheckBox(String name, ForgePreferences.FPref pref) {
|
||||||
|
|
||||||
|
|
||||||
@@ -184,6 +200,16 @@ public class SettingsScene extends UIScene {
|
|||||||
addCheckBox(localizer.getMessage("cbImageFetcher"), ForgePreferences.FPref.UI_ENABLE_ONLINE_IMAGE_FETCHER);
|
addCheckBox(localizer.getMessage("cbImageFetcher"), ForgePreferences.FPref.UI_ENABLE_ONLINE_IMAGE_FETCHER);
|
||||||
|
|
||||||
|
|
||||||
|
addCheckBox(localizer.getMessage("lblBattlefieldTextureFiltering"), ForgePreferences.FPref.UI_LIBGDX_TEXTURE_FILTERING);
|
||||||
|
addCheckBox(localizer.getMessage("lblAltZoneTabs"), ForgePreferences.FPref.UI_ALT_PLAYERZONETABS);
|
||||||
|
addCheckBox(localizer.getMessage("lblAnimatedCardTapUntap"), ForgePreferences.FPref.UI_ANIMATED_CARD_TAPUNTAP);
|
||||||
|
addCheckBox(localizer.getMessage("lblBorderMaskOption"), ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING);
|
||||||
|
addCheckBox(localizer.getMessage("lblPreloadExtendedArtCards"), ForgePreferences.FPref.UI_ENABLE_PRELOAD_EXTENDED_ART);
|
||||||
|
addCheckBox(localizer.getMessage("lblAutoCacheSize"), ForgePreferences.FPref.UI_AUTO_CACHE_SIZE);
|
||||||
|
addCheckBox(localizer.getMessage("lblDisposeTextures"), ForgePreferences.FPref.UI_ENABLE_DISPOSE_TEXTURES);
|
||||||
|
addInputField(localizer.getMessage("lblDisposeTextures"), ForgePreferences.FPref.UI_LANGUAGE);
|
||||||
|
|
||||||
|
|
||||||
settingGroup.row();
|
settingGroup.row();
|
||||||
ui.onButtonPress("return", () -> back());
|
ui.onButtonPress("return", () -> back());
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static forge.adventure.data.RewardData.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class to deck generation and card filtering
|
* Utility class to deck generation and card filtering
|
||||||
*/
|
*/
|
||||||
@@ -275,9 +277,9 @@ public class CardUtil {
|
|||||||
Deck deck= new Deck(data.name);
|
Deck deck= new Deck(data.name);
|
||||||
if(data.template==null)
|
if(data.template==null)
|
||||||
{
|
{
|
||||||
deck.getOrCreate(DeckSection.Main).addAllFlat(RewardData.generateAllCards(Arrays.asList(data.mainDeck), true));
|
deck.getOrCreate(DeckSection.Main).addAllFlat(generateAllCards(Arrays.asList(data.mainDeck), true));
|
||||||
if(data.sideBoard!=null)
|
if(data.sideBoard!=null)
|
||||||
deck.getOrCreate(DeckSection.Sideboard).addAllFlat(RewardData.generateAllCards(Arrays.asList(data.sideBoard), true));
|
deck.getOrCreate(DeckSection.Sideboard).addAllFlat(generateAllCards(Arrays.asList(data.sideBoard), true));
|
||||||
return deck;
|
return deck;
|
||||||
}
|
}
|
||||||
float count=data.template.count;
|
float count=data.template.count;
|
||||||
@@ -286,7 +288,7 @@ public class CardUtil {
|
|||||||
List<RewardData> dataArray= generateRewards(data.template,spells*0.5f,new int[]{1,2});
|
List<RewardData> dataArray= generateRewards(data.template,spells*0.5f,new int[]{1,2});
|
||||||
dataArray.addAll(generateRewards(data.template,spells*0.3f,new int[]{3,4,5}));
|
dataArray.addAll(generateRewards(data.template,spells*0.3f,new int[]{3,4,5}));
|
||||||
dataArray.addAll(generateRewards(data.template,spells*0.2f,new int[]{6,7,8}));
|
dataArray.addAll(generateRewards(data.template,spells*0.2f,new int[]{6,7,8}));
|
||||||
List<PaperCard> nonLand=RewardData.generateAllCards(dataArray, true);
|
List<PaperCard> nonLand= generateAllCards(dataArray, true);
|
||||||
|
|
||||||
nonLand.addAll(fillWithLands(nonLand,data.template));
|
nonLand.addAll(fillWithLands(nonLand,data.template));
|
||||||
deck.getOrCreate(DeckSection.Main).addAllFlat(nonLand);
|
deck.getOrCreate(DeckSection.Main).addAllFlat(nonLand);
|
||||||
@@ -442,7 +444,7 @@ public class CardUtil {
|
|||||||
rewards.addAll(Arrays.asList(sub1,sub2,sub3,sub4,sub5,sub6,sub7,sub8,sub9));
|
rewards.addAll(Arrays.asList(sub1,sub2,sub3,sub4,sub5,sub6,sub7,sub8,sub9));
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<PaperCard> ret = new ArrayList<>(RewardData.generateAllCards(rewards, true));
|
Collection<PaperCard> ret = new ArrayList<>(generateAllCards(rewards, true));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Tooltip;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||||
import com.badlogic.gdx.utils.Disposable;
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
|
import forge.Forge;
|
||||||
import forge.adventure.scene.RewardScene;
|
import forge.adventure.scene.RewardScene;
|
||||||
import forge.adventure.scene.Scene;
|
import forge.adventure.scene.Scene;
|
||||||
import forge.assets.FSkin;
|
import forge.assets.FSkin;
|
||||||
@@ -136,7 +137,8 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
|||||||
|
|
||||||
private void setCardImage(Texture img) {
|
private void setCardImage(Texture img) {
|
||||||
image=img;
|
image=img;
|
||||||
image.setFilter(Texture.TextureFilter.Linear,Texture.TextureFilter.Linear);
|
if(Forge.isTextureFilteringEnabled())
|
||||||
|
image.setFilter(Texture.TextureFilter.MipMapLinearLinear,Texture.TextureFilter.Linear);
|
||||||
TextureRegionDrawable drawable=new TextureRegionDrawable(new TextureRegion(image));
|
TextureRegionDrawable drawable=new TextureRegionDrawable(new TextureRegion(image));
|
||||||
drawable.setMinSize((Scene.GetIntendedHeight()/ RewardScene.CARD_WIDTH_TO_HEIGHT)*0.95f,Scene.GetIntendedHeight()*0.95f);
|
drawable.setMinSize((Scene.GetIntendedHeight()/ RewardScene.CARD_WIDTH_TO_HEIGHT)*0.95f,Scene.GetIntendedHeight()*0.95f);
|
||||||
toolTipImage=new Image(drawable);
|
toolTipImage=new Image(drawable);
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package forge.adventure.world;
|
package forge.adventure.world;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.ObjectSet;
|
|
||||||
import forge.adventure.data.BiomeSpriteData;
|
import forge.adventure.data.BiomeSpriteData;
|
||||||
import forge.adventure.util.Config;
|
import forge.adventure.util.Config;
|
||||||
|
|
||||||
@@ -22,9 +20,9 @@ public class BiomeSprites {
|
|||||||
public Sprite getSprite(String name, int seed) {
|
public Sprite getSprite(String name, int seed) {
|
||||||
if (textureAtlasBuffer == null) {
|
if (textureAtlasBuffer == null) {
|
||||||
textureAtlasBuffer = Config.instance().getAtlas(textureAtlas);
|
textureAtlasBuffer = Config.instance().getAtlas(textureAtlas);
|
||||||
for (Texture texture : new ObjectSet.ObjectSetIterator<>(textureAtlasBuffer.getTextures())) {
|
/*for (Texture texture : new ObjectSet.ObjectSetIterator<>(textureAtlasBuffer.getTextures())) {
|
||||||
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
|
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
if (!spriteBuffer.containsKey(name)) {
|
if (!spriteBuffer.containsKey(name)) {
|
||||||
spriteBuffer.put(name, new Array<Sprite>());
|
spriteBuffer.put(name, new Array<Sprite>());
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
package forge;
|
package forge;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Application;
|
import com.badlogic.gdx.Application;
|
||||||
import com.badlogic.gdx.ApplicationListener;
|
import com.badlogic.gdx.ApplicationListener;
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input.Keys;
|
import com.badlogic.gdx.Input.Keys;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.utils.Clipboard;
|
import com.badlogic.gdx.utils.Clipboard;
|
||||||
|
|
||||||
import forge.animation.ForgeAnimation;
|
import forge.animation.ForgeAnimation;
|
||||||
import forge.assets.AssetsDownloader;
|
import forge.assets.AssetsDownloader;
|
||||||
import forge.assets.FSkin;
|
import forge.assets.FSkin;
|
||||||
@@ -31,21 +27,19 @@ import forge.screens.home.NewGameMenu;
|
|||||||
import forge.screens.match.MatchController;
|
import forge.screens.match.MatchController;
|
||||||
import forge.sound.MusicPlaylist;
|
import forge.sound.MusicPlaylist;
|
||||||
import forge.sound.SoundSystem;
|
import forge.sound.SoundSystem;
|
||||||
import forge.toolbox.FContainer;
|
import forge.toolbox.*;
|
||||||
import forge.toolbox.FDisplayObject;
|
import forge.util.*;
|
||||||
import forge.toolbox.FGestureAdapter;
|
|
||||||
import forge.toolbox.FOptionPane;
|
import java.io.File;
|
||||||
import forge.toolbox.FOverlay;
|
import java.util.ArrayDeque;
|
||||||
import forge.util.Callback;
|
import java.util.ArrayList;
|
||||||
import forge.util.CardTranslation;
|
import java.util.Deque;
|
||||||
import forge.util.FileUtil;
|
import java.util.List;
|
||||||
import forge.util.Localizer;
|
|
||||||
import forge.util.Utils;
|
|
||||||
|
|
||||||
public class Forge implements ApplicationListener {
|
public class Forge implements ApplicationListener {
|
||||||
public static final String CURRENT_VERSION = "1.6.45.001";
|
public static final String CURRENT_VERSION = "1.6.45.001";
|
||||||
|
|
||||||
private static final ApplicationListener app = new Forge();
|
private static ApplicationListener app = null;
|
||||||
private static Clipboard clipboard;
|
private static Clipboard clipboard;
|
||||||
private static IDeviceAdapter deviceAdapter;
|
private static IDeviceAdapter deviceAdapter;
|
||||||
private static int screenWidth;
|
private static int screenWidth;
|
||||||
@@ -53,7 +47,7 @@ public class Forge implements ApplicationListener {
|
|||||||
private static Graphics graphics;
|
private static Graphics graphics;
|
||||||
private static FrameRate frameRate;
|
private static FrameRate frameRate;
|
||||||
private static FScreen currentScreen;
|
private static FScreen currentScreen;
|
||||||
private static SplashScreen splashScreen;
|
protected static SplashScreen splashScreen;
|
||||||
private static KeyInputAdapter keyInputAdapter;
|
private static KeyInputAdapter keyInputAdapter;
|
||||||
private static boolean exited;
|
private static boolean exited;
|
||||||
private static int continuousRenderingCount = 1; //initialize to 1 since continuous rendering is the default
|
private static int continuousRenderingCount = 1; //initialize to 1 since continuous rendering is the default
|
||||||
@@ -88,6 +82,7 @@ public class Forge implements ApplicationListener {
|
|||||||
public static int mouseButtonID = 0;
|
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) {
|
||||||
|
app = new Forge();
|
||||||
if (GuiBase.getInterface() == null) {
|
if (GuiBase.getInterface() == null) {
|
||||||
clipboard = clipboard0;
|
clipboard = clipboard0;
|
||||||
deviceAdapter = deviceAdapter0;
|
deviceAdapter = deviceAdapter0;
|
||||||
@@ -102,7 +97,21 @@ public class Forge implements ApplicationListener {
|
|||||||
GuiBase.setDeviceInfo(deviceName, AndroidRelease, AndroidAPI, totalRAM);
|
GuiBase.setDeviceInfo(deviceName, AndroidRelease, AndroidAPI, totalRAM);
|
||||||
return app;
|
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() {
|
private Forge() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +252,7 @@ public class Forge implements ApplicationListener {
|
|||||||
System.out.println(fScreen.toString());*/
|
System.out.println(fScreen.toString());*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void afterDbLoaded() {
|
protected void afterDbLoaded() {
|
||||||
stopContinuousRendering(); //save power consumption by disabling continuous rendering once assets loaded
|
stopContinuousRendering(); //save power consumption by disabling continuous rendering once assets loaded
|
||||||
|
|
||||||
FSkin.loadFull(splashScreen);
|
FSkin.loadFull(splashScreen);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"template":
|
"template":
|
||||||
{
|
{
|
||||||
"count":60,
|
"count":60,
|
||||||
"colors":["Blue"],
|
"colors":["Blue","Green"],
|
||||||
"tribe":"Merfolk",
|
"tribe":"Merfolk",
|
||||||
"rares":0.8
|
"rares":0.8
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
forge-gui/res/adventure/Shandalar/skin/bg_day.jpg
Normal file
|
After Width: | Height: | Size: 130 KiB |
BIN
forge-gui/res/adventure/Shandalar/skin/bg_night.jpg
Normal file
|
After Width: | Height: | Size: 95 KiB |
BIN
forge-gui/res/adventure/Shandalar/skin/grid_icons.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
forge-gui/res/adventure/Shandalar/skin/overlay_alpha.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
forge-gui/res/adventure/Shandalar/skin/splatter.png
Normal file
|
After Width: | Height: | Size: 127 KiB |
BIN
forge-gui/res/adventure/Shandalar/skin/sprite_cardbg.png
Normal file
|
After Width: | Height: | Size: 2.8 MiB |
BIN
forge-gui/res/adventure/Shandalar/skin/sprite_cracks.png
Normal file
|
After Width: | Height: | Size: 489 KiB |
BIN
forge-gui/res/adventure/Shandalar/skin/sprite_setlogo.png
Normal file
|
After Width: | Height: | Size: 195 KiB |
BIN
forge-gui/res/adventure/Shandalar/skin/sprite_watermark.png
Normal file
|
After Width: | Height: | Size: 354 KiB |
@@ -236,11 +236,11 @@
|
|||||||
"rewards": [
|
"rewards": [
|
||||||
{
|
{
|
||||||
"count":4,
|
"count":4,
|
||||||
"colors": ["black","white"]
|
"colors": ["blue","green"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"count":4,
|
"count":4,
|
||||||
"colors": ["black","white"],
|
"colors": ["blue","green"],
|
||||||
"colorType": "MultiColor"
|
"colorType": "MultiColor"
|
||||||
}]
|
}]
|
||||||
},{
|
},{
|
||||||
|
|||||||