mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Refactor FSkin to use Assetmanager
This commit is contained in:
@@ -104,8 +104,8 @@ public class Forge implements ApplicationListener {
|
||||
public static boolean enablePreloadExtendedArt = false;
|
||||
public static boolean isTabletDevice = false;
|
||||
public static String locale = "en-US";
|
||||
public Assets cardAssets = new Assets();
|
||||
public Assets otherAssets = new Assets();
|
||||
public Assets cardAssets;
|
||||
public Assets otherAssets;
|
||||
public static boolean hdbuttons = false;
|
||||
public static boolean hdstart = false;
|
||||
public static boolean isPortraitMode = false;
|
||||
@@ -166,7 +166,8 @@ public class Forge implements ApplicationListener {
|
||||
// don't allow to read and process
|
||||
ForgeConstants.SPRITE_CARDBG_FILE = "";
|
||||
}
|
||||
|
||||
cardAssets = new Assets();
|
||||
otherAssets = new Assets();
|
||||
graphics = new Graphics();
|
||||
splashScreen = new SplashScreen();
|
||||
frameRate = new FrameRate();
|
||||
@@ -219,50 +220,44 @@ public class Forge implements ApplicationListener {
|
||||
ImageCache.initCache(cacheSize);
|
||||
|
||||
//load model on background thread (using progress bar to report progress)
|
||||
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
|
||||
FThreads.invokeInBackgroundThread(() -> {
|
||||
//see if app or assets need updating
|
||||
AssetsDownloader.checkForUpdates(splashScreen, enableSentry, locale);
|
||||
if (exited) {
|
||||
return;
|
||||
} //don't continue if user chose to exit or couldn't download required assets
|
||||
|
||||
safeToClose = false;
|
||||
ImageKeys.setIsLibGDXPort(GuiBase.getInterface().isLibgdxPort());
|
||||
FModel.initialize(splashScreen.getProgressBar(), null);
|
||||
safeToClose = false;
|
||||
ImageKeys.setIsLibGDXPort(GuiBase.getInterface().isLibgdxPort());
|
||||
FModel.initialize(splashScreen.getProgressBar(), null);
|
||||
|
||||
splashScreen.getProgressBar().setDescription(getLocalizer().getMessage("lblLoadingFonts"));
|
||||
FSkinFont.preloadAll(locale);
|
||||
splashScreen.getProgressBar().setDescription(getLocalizer().getMessage("lblLoadingFonts"));
|
||||
FSkinFont.preloadAll(locale);
|
||||
|
||||
splashScreen.getProgressBar().setDescription(getLocalizer().getMessage("lblLoadingCardTranslations"));
|
||||
CardTranslation.preloadTranslation(locale, ForgeConstants.LANG_DIR);
|
||||
splashScreen.getProgressBar().setDescription(getLocalizer().getMessage("lblLoadingCardTranslations"));
|
||||
CardTranslation.preloadTranslation(locale, ForgeConstants.LANG_DIR);
|
||||
|
||||
splashScreen.getProgressBar().setDescription(getLocalizer().getMessage("lblFinishingStartup"));
|
||||
splashScreen.getProgressBar().setDescription(getLocalizer().getMessage("lblFinishingStartup"));
|
||||
|
||||
//add reminder to preload
|
||||
if (enablePreloadExtendedArt) {
|
||||
if (autoCache)
|
||||
splashScreen.getProgressBar().setDescription(getLocalizer().getMessage("lblPreloadExtendedArt") + "\nDetected RAM: " + totalDeviceRAM + "MB. Cache size: " + cacheSize);
|
||||
else
|
||||
splashScreen.getProgressBar().setDescription(getLocalizer().getMessage("lblPreloadExtendedArt"));
|
||||
} else {
|
||||
if (autoCache)
|
||||
splashScreen.getProgressBar().setDescription(getLocalizer().getMessage("lblFinishingStartup") + "\nDetected RAM: " + totalDeviceRAM + "MB. Cache size: " + cacheSize);
|
||||
else
|
||||
splashScreen.getProgressBar().setDescription(getLocalizer().getMessage("lblFinishingStartup"));
|
||||
}
|
||||
|
||||
Gdx.app.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
afterDbLoaded();
|
||||
/* call preloadExtendedArt here, if we put it above we will *
|
||||
* get error: No OpenGL context found in the current thread. */
|
||||
preloadExtendedArt();
|
||||
}
|
||||
});
|
||||
//add reminder to preload
|
||||
if (enablePreloadExtendedArt) {
|
||||
if (autoCache)
|
||||
splashScreen.getProgressBar().setDescription(getLocalizer().getMessage("lblPreloadExtendedArt") + "\nDetected RAM: " + totalDeviceRAM + "MB. Cache size: " + cacheSize);
|
||||
else
|
||||
splashScreen.getProgressBar().setDescription(getLocalizer().getMessage("lblPreloadExtendedArt"));
|
||||
} else {
|
||||
if (autoCache)
|
||||
splashScreen.getProgressBar().setDescription(getLocalizer().getMessage("lblFinishingStartup") + "\nDetected RAM: " + totalDeviceRAM + "MB. Cache size: " + cacheSize);
|
||||
else
|
||||
splashScreen.getProgressBar().setDescription(getLocalizer().getMessage("lblFinishingStartup"));
|
||||
}
|
||||
|
||||
Gdx.app.postRunnable(() -> {
|
||||
afterDbLoaded();
|
||||
/* call preloadExtendedArt here, if we put it above we will *
|
||||
* get error: No OpenGL context found in the current thread. */
|
||||
preloadExtendedArt();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -380,52 +375,35 @@ public class Forge implements ApplicationListener {
|
||||
FModel.getPreferences().save();
|
||||
}
|
||||
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//load skin full
|
||||
FSkin.loadFull(splashScreen);
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//load Drafts
|
||||
preloadBoosterDrafts();
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//selection transition
|
||||
setTransitionScreen(new TransitionScreen(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (selector.equals("Classic")) {
|
||||
openHomeDefault();
|
||||
clearSplashScreen();
|
||||
} else if (selector.equals("Adventure")) {
|
||||
openAdventure();
|
||||
clearSplashScreen();
|
||||
} else if (splashScreen != null) {
|
||||
splashScreen.setShowModeSelector(true);
|
||||
} else {//default mode in case splashscreen is null at some point as seen on resume..
|
||||
openHomeDefault();
|
||||
clearSplashScreen();
|
||||
}
|
||||
//start background music
|
||||
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS);
|
||||
safeToClose = true;
|
||||
clearTransitionScreen();
|
||||
}
|
||||
}, Forge.takeScreenshot(), false, false, true, false));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
FThreads.invokeInBackgroundThread(() -> FThreads.invokeInEdtLater(() -> {
|
||||
//load skin full
|
||||
FSkin.loadFull(splashScreen);
|
||||
FThreads.invokeInBackgroundThread(() -> {
|
||||
//load Drafts
|
||||
preloadBoosterDrafts();
|
||||
FThreads.invokeInEdtLater(() -> {
|
||||
//selection transition
|
||||
setTransitionScreen(new TransitionScreen(() -> {
|
||||
if (selector.equals("Classic")) {
|
||||
openHomeDefault();
|
||||
clearSplashScreen();
|
||||
} else if (selector.equals("Adventure")) {
|
||||
openAdventure();
|
||||
clearSplashScreen();
|
||||
} else if (splashScreen != null) {
|
||||
splashScreen.setShowModeSelector(true);
|
||||
} else {//default mode in case splashscreen is null at some point as seen on resume..
|
||||
openHomeDefault();
|
||||
clearSplashScreen();
|
||||
}
|
||||
//start background music
|
||||
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS);
|
||||
safeToClose = true;
|
||||
clearTransitionScreen();
|
||||
}, Forge.takeScreenshot(), false, false, true, false));
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
public static void setCursor(TextureRegion textureRegion, String name) {
|
||||
@@ -757,32 +735,26 @@ public class Forge implements ApplicationListener {
|
||||
}
|
||||
|
||||
public static void switchToClassic() {
|
||||
setTransitionScreen(new TransitionScreen(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ImageCache.disposeTextures();
|
||||
isMobileAdventureMode = false;
|
||||
GuiBase.setIsAdventureMode(false);
|
||||
setCursor(FSkin.getCursor().get(0), "0");
|
||||
altZoneTabs = FModel.getPreferences().getPrefBoolean(FPref.UI_ALT_PLAYERZONETABS);
|
||||
Gdx.input.setInputProcessor(getInputProcessor());
|
||||
clearTransitionScreen();
|
||||
openHomeDefault();
|
||||
exited = false;
|
||||
}
|
||||
setTransitionScreen(new TransitionScreen(() -> {
|
||||
ImageCache.disposeTextures();
|
||||
isMobileAdventureMode = false;
|
||||
GuiBase.setIsAdventureMode(false);
|
||||
setCursor(FSkin.getCursor().get(0), "0");
|
||||
altZoneTabs = FModel.getPreferences().getPrefBoolean(FPref.UI_ALT_PLAYERZONETABS);
|
||||
Gdx.input.setInputProcessor(getInputProcessor());
|
||||
clearTransitionScreen();
|
||||
openHomeDefault();
|
||||
exited = false;
|
||||
}, Forge.takeScreenshot(), false, false));
|
||||
}
|
||||
|
||||
public static void switchToAdventure() {
|
||||
setTransitionScreen(new TransitionScreen(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ImageCache.disposeTextures();
|
||||
clearCurrentScreen();
|
||||
clearTransitionScreen();
|
||||
openAdventure();
|
||||
exited = false;
|
||||
}
|
||||
setTransitionScreen(new TransitionScreen(() -> {
|
||||
ImageCache.disposeTextures();
|
||||
clearCurrentScreen();
|
||||
clearTransitionScreen();
|
||||
openAdventure();
|
||||
exited = false;
|
||||
}, null, false, true));
|
||||
}
|
||||
|
||||
@@ -936,19 +908,11 @@ public class Forge implements ApplicationListener {
|
||||
}
|
||||
|
||||
public static void delayedSwitchBack() {
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
clearTransitionScreen();
|
||||
clearCurrentScreen();
|
||||
switchToLast();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
FThreads.invokeInBackgroundThread(() -> FThreads.invokeInEdtLater(() -> {
|
||||
clearTransitionScreen();
|
||||
clearCurrentScreen();
|
||||
switchToLast();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -990,8 +954,8 @@ public class Forge implements ApplicationListener {
|
||||
currentScreen.onClose(null);
|
||||
currentScreen = null;
|
||||
}
|
||||
ImageCache.disposeTextureManager();
|
||||
Config.instance().disposeTextureAtlasManager();
|
||||
cardAssets.dispose();
|
||||
otherAssets.dispose();
|
||||
Dscreens.clear();
|
||||
graphics.dispose();
|
||||
SoundSystem.instance.dispose();
|
||||
@@ -1000,7 +964,15 @@ public class Forge implements ApplicationListener {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Retrieve assets.
|
||||
* @param other if set to true returns otherAssets otherwise returns cardAssets
|
||||
*/
|
||||
public static Assets getAssets(boolean other) {
|
||||
if (other)
|
||||
return ((Forge)Gdx.app.getApplicationListener()).otherAssets;
|
||||
else
|
||||
return ((Forge)Gdx.app.getApplicationListener()).cardAssets;
|
||||
}
|
||||
public static boolean switchScene(Scene newScene) {
|
||||
if (currentScene != null) {
|
||||
if (!currentScene.leave())
|
||||
|
||||
@@ -1132,6 +1132,7 @@ public class Graphics {
|
||||
P.setColor(1f,1f,1f,1f);
|
||||
P.drawPixel(0, 0);
|
||||
dummyTexture = new Texture(P);
|
||||
P.dispose();
|
||||
}
|
||||
return dummyTexture;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ 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.assets.Assets;
|
||||
import forge.deck.Deck;
|
||||
import forge.gui.GuiBase;
|
||||
import forge.localinstance.properties.ForgeConstants;
|
||||
@@ -26,7 +26,6 @@ public class Config {
|
||||
private static Config currentConfig;
|
||||
private final String prefix;
|
||||
private final HashMap<String, FileHandle> Cache = new HashMap<String, FileHandle>();
|
||||
private final Assets atlasAssets = new Assets();
|
||||
private final ConfigData configData;
|
||||
private final String[] adventures;
|
||||
private SettingData settingsData;
|
||||
@@ -121,11 +120,11 @@ public class Config {
|
||||
|
||||
public TextureAtlas getAtlas(String spriteAtlas) {
|
||||
String fileName = getFile(spriteAtlas).path();
|
||||
if (!atlasAssets.manager().contains(fileName, TextureAtlas.class)) {
|
||||
atlasAssets.manager().load(fileName, TextureAtlas.class);
|
||||
atlasAssets.manager().finishLoadingAsset(fileName);
|
||||
if (!Forge.getAssets(true).manager.contains(fileName, TextureAtlas.class)) {
|
||||
Forge.getAssets(true).manager.load(fileName, TextureAtlas.class);
|
||||
Forge.getAssets(true).manager.finishLoadingAsset(fileName);
|
||||
}
|
||||
return atlasAssets.manager().get(fileName);
|
||||
return Forge.getAssets(true).manager.get(fileName);
|
||||
}
|
||||
public SettingData getSettingData()
|
||||
{
|
||||
@@ -143,7 +142,4 @@ public class Config {
|
||||
handle.writeString(json.prettyPrint(json.toJson(settingsData, SettingData.class)),false);
|
||||
|
||||
}
|
||||
public void disposeTextureAtlasManager() {
|
||||
atlasAssets.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,6 @@ import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
public class Assets implements Disposable {
|
||||
public AssetManager manager = new AssetManager(new AbsoluteFileHandleResolver());
|
||||
public AssetManager manager() {
|
||||
return manager;
|
||||
}
|
||||
@Override
|
||||
public void dispose() {
|
||||
manager.dispose();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package forge.assets;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.assets.loaders.TextureLoader;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
@@ -19,6 +21,7 @@ import forge.localinstance.skin.FSkinProp;
|
||||
import forge.model.FModel;
|
||||
import forge.screens.LoadingOverlay;
|
||||
import forge.screens.SplashScreen;
|
||||
import forge.screens.TransitionScreen;
|
||||
import forge.toolbox.FProgressBar;
|
||||
import forge.util.WordUtil;
|
||||
|
||||
@@ -50,38 +53,27 @@ public class FSkin {
|
||||
prefs.setPref(FPref.UI_SKIN, skinName);
|
||||
prefs.save();
|
||||
|
||||
//load skin
|
||||
loaded = false; //reset this temporarily until end of loadFull()
|
||||
|
||||
final LoadingOverlay loader = new LoadingOverlay("Loading new theme...");
|
||||
loader.show(); //show loading overlay then delay running remaining logic so UI can respond
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
Forge.setTransitionScreen(new TransitionScreen(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadLight(skinName, null);
|
||||
loadFull(null);
|
||||
loader.setCaption("Loading fonts...");
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
FThreads.invokeInBackgroundThread(() -> FThreads.invokeInEdtLater(() -> {
|
||||
final LoadingOverlay loader = new LoadingOverlay(Forge.getLocalizer().getMessageorUseDefault("lblRestartInFewSeconds", "Forge will restart after a few seconds..."), true);
|
||||
loader.show();
|
||||
FThreads.invokeInBackgroundThread(() -> {
|
||||
FSkinFont.deleteCachedFiles(); //delete cached font files so font can be update for new skin
|
||||
FThreads.delayInEDT(2000, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FSkinFont.deleteCachedFiles(); //delete cached font files so font can be update for new skin
|
||||
FSkinFont.updateAll();
|
||||
//CardImageRenderer.forceStaticFieldUpdate();
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loader.hide();
|
||||
}
|
||||
Forge.clearTransitionScreen();
|
||||
FThreads.invokeInEdtLater(() -> {
|
||||
Forge.restart(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}));
|
||||
}
|
||||
});
|
||||
}, null, false, true));
|
||||
}
|
||||
public static void loadLight(String skinName, final SplashScreen splashScreen,FileHandle prefDir) {
|
||||
preferredDir = prefDir;
|
||||
@@ -96,6 +88,7 @@ public class FSkin {
|
||||
* the skin name
|
||||
*/
|
||||
public static void loadLight(String skinName, final SplashScreen splashScreen) {
|
||||
AssetManager manager = Forge.getAssets(true).manager;
|
||||
preferredName = skinName.toLowerCase().replace(' ', '_');
|
||||
|
||||
//reset hd buttons/icons
|
||||
@@ -137,25 +130,25 @@ public class FSkin {
|
||||
//load theme logo while changing skins
|
||||
final FileHandle theme_logo = getSkinFile("hd_logo.png");
|
||||
if (theme_logo.exists()) {
|
||||
Texture txOverlay = new Texture(theme_logo, true);
|
||||
txOverlay.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
hdLogo = txOverlay;
|
||||
manager.load(theme_logo.path(), Texture.class, new TextureLoader.TextureParameter(){{genMipMaps = true; minFilter = Texture.TextureFilter.MipMapLinearLinear; magFilter = Texture.TextureFilter.Linear;}});
|
||||
manager.finishLoadingAsset(theme_logo.path());
|
||||
hdLogo = manager.get(theme_logo.path());
|
||||
} else {
|
||||
hdLogo = null;
|
||||
}
|
||||
final FileHandle duals_overlay = getDefaultSkinFile("overlay_alpha.png");
|
||||
if (duals_overlay.exists()) {
|
||||
Texture txAlphaLines = new Texture(duals_overlay, true);
|
||||
txAlphaLines.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
overlay_alpha = txAlphaLines;
|
||||
manager.load(duals_overlay.path(), Texture.class, new TextureLoader.TextureParameter(){{genMipMaps = true; minFilter = Texture.TextureFilter.MipMapLinearLinear; magFilter = Texture.TextureFilter.Linear;}});
|
||||
manager.finishLoadingAsset(duals_overlay.path());
|
||||
overlay_alpha = manager.get(duals_overlay.path());
|
||||
} else {
|
||||
overlay_alpha = null;
|
||||
}
|
||||
final FileHandle splatter_overlay = getDefaultSkinFile("splatter.png");
|
||||
if (splatter_overlay.exists()) {
|
||||
Texture txSplatter = new Texture(splatter_overlay, true);
|
||||
txSplatter.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
splatter = txSplatter;
|
||||
manager.load(splatter_overlay.path(), Texture.class, new TextureLoader.TextureParameter(){{genMipMaps = true; minFilter = Texture.TextureFilter.MipMapLinearLinear; magFilter = Texture.TextureFilter.Linear;}});
|
||||
manager.finishLoadingAsset(splatter_overlay.path());
|
||||
splatter = manager.get(splatter_overlay.path());
|
||||
} else {
|
||||
splatter = null;
|
||||
}
|
||||
@@ -172,16 +165,17 @@ public class FSkin {
|
||||
}
|
||||
|
||||
try {
|
||||
Texture txSplash = new Texture(f);
|
||||
final int w = txSplash.getWidth();
|
||||
final int h = txSplash.getHeight();
|
||||
manager.load(f.path(), Texture.class);
|
||||
manager.finishLoadingAsset(f.path());
|
||||
final int w = manager.get(f.path(), Texture.class).getWidth();
|
||||
final int h = manager.get(f.path(), Texture.class).getHeight();
|
||||
|
||||
if (f2.exists()) {
|
||||
Texture txSplashHD = new Texture(f2, true);
|
||||
txSplashHD.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
splashScreen.setBackground(new TextureRegion(txSplashHD));
|
||||
manager.load(f2.path(), Texture.class, new TextureLoader.TextureParameter(){{genMipMaps = true; minFilter = Texture.TextureFilter.MipMapLinearLinear; magFilter = Texture.TextureFilter.Linear;}});
|
||||
manager.finishLoadingAsset(f2.path());
|
||||
splashScreen.setBackground(new TextureRegion(manager.get(f2.path(), Texture.class)));
|
||||
} else {
|
||||
splashScreen.setBackground(new TextureRegion(txSplash, 0, 0, w, h - 100));
|
||||
splashScreen.setBackground(new TextureRegion(manager.get(f.path(), Texture.class), 0, 0, w, h - 100));
|
||||
}
|
||||
|
||||
Pixmap pxSplash = new Pixmap(f);
|
||||
@@ -226,9 +220,14 @@ public class FSkin {
|
||||
avatars.clear();
|
||||
sleeves.clear();
|
||||
|
||||
boolean textureFilter = Forge.isTextureFilteringEnabled();
|
||||
TextureLoader.TextureParameter parameter = new TextureLoader.TextureParameter();
|
||||
if (Forge.isTextureFilteringEnabled()) {
|
||||
parameter.genMipMaps = true;
|
||||
parameter.minFilter = Texture.TextureFilter.MipMapLinearLinear;
|
||||
parameter.magFilter = Texture.TextureFilter.Linear;
|
||||
}
|
||||
|
||||
final Map<String, Texture> textures = new HashMap<>();
|
||||
AssetManager manager = Forge.getAssets(true).manager;
|
||||
|
||||
// Grab and test various sprite files.
|
||||
final FileHandle f1 = getDefaultSkinFile(SourceFile.ICONS.getFilename());
|
||||
@@ -255,24 +254,24 @@ public class FSkin {
|
||||
*/
|
||||
|
||||
try {
|
||||
textures.put(f1.path(), new Texture(f1));
|
||||
manager.load(f1.path(), Texture.class);
|
||||
manager.finishLoadingAsset(f1.path());
|
||||
Pixmap preferredIcons = new Pixmap(f1);
|
||||
if (f2.exists()) {
|
||||
textures.put(f2.path(), new Texture(f2));
|
||||
manager.load(f2.path(), Texture.class);
|
||||
manager.finishLoadingAsset(f2.path());
|
||||
preferredIcons = new Pixmap(f2);
|
||||
}
|
||||
|
||||
textures.put(f3.path(), new Texture(f3));
|
||||
manager.load(f3.path(), Texture.class);
|
||||
manager.finishLoadingAsset(f3.path());
|
||||
if (f6.exists()) {
|
||||
textures.put(f6.path(), new Texture(f6));
|
||||
}
|
||||
else {
|
||||
textures.put(f6.path(), textures.get(f3.path()));
|
||||
manager.load(f6.path(), Texture.class);
|
||||
manager.finishLoadingAsset(f6.path());
|
||||
}
|
||||
if (f7.exists()){
|
||||
Texture t = new Texture(f7, true);
|
||||
//t.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
textures.put(f7.path(), t);
|
||||
manager.load(f7.path(), Texture.class, new TextureLoader.TextureParameter(){{genMipMaps = true;}});
|
||||
manager.finishLoadingAsset(f7.path());
|
||||
}
|
||||
|
||||
//hdbuttons
|
||||
@@ -280,9 +279,8 @@ public class FSkin {
|
||||
if (GuiBase.isAndroid() && Forge.totalDeviceRAM <5000) {
|
||||
Forge.hdbuttons = false;
|
||||
} else {
|
||||
Texture t = new Texture(f11, true);
|
||||
t.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
textures.put(f11.path(), t);
|
||||
manager.load(f11.path(), Texture.class, new TextureLoader.TextureParameter(){{genMipMaps = true; minFilter = Texture.TextureFilter.MipMapLinearLinear; magFilter = Texture.TextureFilter.Linear;}});
|
||||
manager.finishLoadingAsset(f11.path());
|
||||
Forge.hdbuttons = true;
|
||||
}
|
||||
} else { Forge.hdbuttons = false; } //how to refresh buttons when a theme don't have hd buttons?
|
||||
@@ -290,9 +288,8 @@ public class FSkin {
|
||||
if (GuiBase.isAndroid() && Forge.totalDeviceRAM <5000) {
|
||||
Forge.hdstart = false;
|
||||
} else {
|
||||
Texture t = new Texture(f12, true);
|
||||
t.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
textures.put(f12.path(), t);
|
||||
manager.load(f12.path(), Texture.class, new TextureLoader.TextureParameter(){{genMipMaps = true; minFilter = Texture.TextureFilter.MipMapLinearLinear; magFilter = Texture.TextureFilter.Linear;}});
|
||||
manager.finishLoadingAsset(f12.path());
|
||||
Forge.hdstart = true;
|
||||
}
|
||||
} else { Forge.hdstart = false; }
|
||||
@@ -305,13 +302,13 @@ public class FSkin {
|
||||
for (FSkinImage image : FSkinImage.values()) {
|
||||
if (GuiBase.isAndroid()) {
|
||||
if (Forge.totalDeviceRAM>5000)
|
||||
image.load(textures, preferredIcons);
|
||||
image.load(manager, preferredIcons);
|
||||
else if (image.toString().equals("HDMULTI"))
|
||||
image.load(textures, preferredIcons);
|
||||
image.load(manager, preferredIcons);
|
||||
else if (!image.toString().startsWith("HD"))
|
||||
image.load(textures, preferredIcons);
|
||||
image.load(manager, preferredIcons);
|
||||
} else {
|
||||
image.load(textures, preferredIcons);
|
||||
image.load(manager, preferredIcons);
|
||||
}
|
||||
}
|
||||
for (FSkinTexture texture : FSkinTexture.values()) {
|
||||
@@ -324,23 +321,21 @@ public class FSkin {
|
||||
int counter = 0;
|
||||
int scount = 0;
|
||||
Color pxTest;
|
||||
Pixmap pxDefaultAvatars, pxPreferredAvatars, pxDefaultSleeves, pxCracks;
|
||||
Texture txDefaultAvatars, txPreferredAvatars, txDefaultSleeves, txCracks;
|
||||
Pixmap pxDefaultAvatars, pxPreferredAvatars, pxDefaultSleeves;
|
||||
|
||||
pxDefaultAvatars = new Pixmap(f4);
|
||||
pxDefaultSleeves = new Pixmap(f8);
|
||||
txDefaultAvatars = new Texture(f4, textureFilter);
|
||||
if (textureFilter)
|
||||
txDefaultAvatars.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
txDefaultSleeves = new Texture(f8, textureFilter);
|
||||
if (textureFilter)
|
||||
txDefaultSleeves.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
|
||||
//default avatar
|
||||
manager.load(f4.path(), Texture.class, parameter);
|
||||
manager.finishLoadingAsset(f4.path());
|
||||
//sleeves first set
|
||||
manager.load(f8.path(), Texture.class, parameter);
|
||||
manager.finishLoadingAsset(f8.path());
|
||||
//preferred avatar
|
||||
if (f5.exists()) {
|
||||
pxPreferredAvatars = new Pixmap(f5);
|
||||
txPreferredAvatars = new Texture(f5, textureFilter);
|
||||
if (textureFilter)
|
||||
txPreferredAvatars.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
manager.load(f5.path(), Texture.class, parameter);
|
||||
manager.finishLoadingAsset(f5.path());
|
||||
|
||||
final int pw = pxPreferredAvatars.getWidth();
|
||||
final int ph = pxPreferredAvatars.getHeight();
|
||||
@@ -350,7 +345,7 @@ public class FSkin {
|
||||
if (i == 0 && j == 0) { continue; }
|
||||
pxTest = new Color(pxPreferredAvatars.getPixel(i + 50, j + 50));
|
||||
if (pxTest.a == 0) { continue; }
|
||||
FSkin.avatars.put(counter++, new TextureRegion(txPreferredAvatars, i, j, 100, 100));
|
||||
FSkin.avatars.put(counter++, new TextureRegion(manager.get(f5.path(), Texture.class), i, j, 100, 100));
|
||||
}
|
||||
}
|
||||
pxPreferredAvatars.dispose();
|
||||
@@ -365,24 +360,11 @@ public class FSkin {
|
||||
if (i == 0 && j == 0) { continue; }
|
||||
pxTest = new Color(pxDefaultAvatars.getPixel(i + 50, j + 50));
|
||||
if (pxTest.a == 0) { continue; }
|
||||
FSkin.avatars.put(counter++, new TextureRegion(txDefaultAvatars, i, j, 100, 100));
|
||||
FSkin.avatars.put(counter++, new TextureRegion(manager.get(f4.path(), Texture.class), i, j, 100, 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final int aw = pxDefaultAvatars.getWidth();
|
||||
final int ah = pxDefaultAvatars.getHeight();
|
||||
|
||||
for (int j = 0; j < ah; j += 100) {
|
||||
for (int i = 0; i < aw; i += 100) {
|
||||
if (i == 0 && j == 0) { continue; }
|
||||
pxTest = new Color(pxDefaultAvatars.getPixel(i + 50, j + 50));
|
||||
if (pxTest.a == 0) { continue; }
|
||||
FSkin.avatars.put(counter++, new TextureRegion(txDefaultAvatars, i, j, 100, 100));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final int sw = pxDefaultSleeves.getWidth();
|
||||
final int sh = pxDefaultSleeves.getHeight();
|
||||
|
||||
@@ -390,15 +372,14 @@ public class FSkin {
|
||||
for (int i = 0; i < sw; i += 360) {
|
||||
pxTest = new Color(pxDefaultSleeves.getPixel(i + 180, j + 250));
|
||||
if (pxTest.a == 0) { continue; }
|
||||
FSkin.sleeves.put(scount++, new TextureRegion(txDefaultSleeves, i, j, 360, 500));
|
||||
FSkin.sleeves.put(scount++, new TextureRegion(manager.get(f8.path(), Texture.class), i, j, 360, 500));
|
||||
}
|
||||
}
|
||||
|
||||
//re init second set of sleeves
|
||||
pxDefaultSleeves = new Pixmap(f9);
|
||||
txDefaultSleeves = new Texture(f9, textureFilter);
|
||||
if (textureFilter)
|
||||
txDefaultSleeves.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
manager.load(f9.path(), Texture.class, parameter);
|
||||
manager.finishLoadingAsset(f9.path());
|
||||
|
||||
final int sw2 = pxDefaultSleeves.getWidth();
|
||||
final int sh2 = pxDefaultSleeves.getHeight();
|
||||
@@ -407,50 +388,47 @@ public class FSkin {
|
||||
for (int i = 0; i < sw2; i += 360) {
|
||||
pxTest = new Color(pxDefaultSleeves.getPixel(i + 180, j + 250));
|
||||
if (pxTest.a == 0) { continue; }
|
||||
FSkin.sleeves.put(scount++, new TextureRegion(txDefaultSleeves, i, j, 360, 500));
|
||||
FSkin.sleeves.put(scount++, new TextureRegion(manager.get(f9.path(), Texture.class), i, j, 360, 500));
|
||||
}
|
||||
}
|
||||
//cracks
|
||||
pxCracks = new Pixmap(f17);
|
||||
txCracks = new Texture(f17, textureFilter);
|
||||
manager.load(f17.path(), Texture.class, parameter);
|
||||
manager.finishLoadingAsset(f17.path());
|
||||
int crackCount = 0;
|
||||
if (textureFilter)
|
||||
txCracks.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
int x = j * 200;
|
||||
for(int i = 0; i < 4; i++) {
|
||||
int y = i * 279;
|
||||
FSkin.cracks.put(crackCount++, new TextureRegion(txCracks, x, y, 200, 279));
|
||||
FSkin.cracks.put(crackCount++, new TextureRegion(manager.get(f17.path(), Texture.class), x, y, 200, 279));
|
||||
}
|
||||
}
|
||||
|
||||
//borders
|
||||
Texture bordersBW = new Texture(f10);
|
||||
FSkin.borders.put(0, new TextureRegion(bordersBW, 2, 2, 672, 936));
|
||||
FSkin.borders.put(1, new TextureRegion(bordersBW, 676, 2, 672, 936));
|
||||
manager.load(f10.path(), Texture.class);
|
||||
manager.finishLoadingAsset(f10.path());
|
||||
FSkin.borders.put(0, new TextureRegion(manager.get(f10.path(), Texture.class), 2, 2, 672, 936));
|
||||
FSkin.borders.put(1, new TextureRegion(manager.get(f10.path(), Texture.class), 676, 2, 672, 936));
|
||||
//deckboxes
|
||||
Texture deckboxes = new Texture(f13, textureFilter);
|
||||
if (textureFilter)
|
||||
deckboxes.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
manager.load(f13.path(), Texture.class, parameter);
|
||||
manager.finishLoadingAsset(f13.path());
|
||||
//gold bg
|
||||
FSkin.deckbox.put(0, new TextureRegion(deckboxes, 2, 2, 488, 680));
|
||||
FSkin.deckbox.put(0, new TextureRegion(manager.get(f13.path(), Texture.class), 2, 2, 488, 680));
|
||||
//deck box for card art
|
||||
FSkin.deckbox.put(1, new TextureRegion(deckboxes, 492, 2, 488, 680));
|
||||
FSkin.deckbox.put(1, new TextureRegion(manager.get(f13.path(), Texture.class), 492, 2, 488, 680));
|
||||
//generic deck box
|
||||
FSkin.deckbox.put(2, new TextureRegion(deckboxes, 982, 2, 488, 680));
|
||||
FSkin.deckbox.put(2, new TextureRegion(manager.get(f13.path(), Texture.class), 982, 2, 488, 680));
|
||||
//cursor
|
||||
Texture cursors = new Texture(f19);
|
||||
FSkin.cursor.put(0, new TextureRegion(cursors, 0, 0, 32, 32)); //default
|
||||
FSkin.cursor.put(1, new TextureRegion(cursors, 32, 0, 32, 32)); //magnify on
|
||||
FSkin.cursor.put(2, new TextureRegion(cursors, 64, 0, 32, 32)); // magnify off
|
||||
manager.load(f19.path(), Texture.class);
|
||||
manager.finishLoadingAsset(f19.path());
|
||||
FSkin.cursor.put(0, new TextureRegion(manager.get(f19.path(), Texture.class), 0, 0, 32, 32)); //default
|
||||
FSkin.cursor.put(1, new TextureRegion(manager.get(f19.path(), Texture.class), 32, 0, 32, 32)); //magnify on
|
||||
FSkin.cursor.put(2, new TextureRegion(manager.get(f19.path(), Texture.class), 64, 0, 32, 32)); // magnify off
|
||||
|
||||
Forge.setCursor(cursor.get(0), "0");
|
||||
|
||||
preferredIcons.dispose();
|
||||
pxDefaultAvatars.dispose();
|
||||
pxDefaultSleeves.dispose();
|
||||
pxCracks.dispose();
|
||||
}
|
||||
catch (final Exception e) {
|
||||
System.err.println("FSkin$loadFull: Missing a sprite (default icons, "
|
||||
|
||||
@@ -3,6 +3,7 @@ package forge.assets;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
@@ -38,7 +39,7 @@ public class FSkinFont {
|
||||
private static final int MAX_FONT_SIZE_MANY_GLYPHS = 36;
|
||||
|
||||
private static final String TTF_FILE = "font1.ttf";
|
||||
private static final ObjectMap<Integer, FSkinFont> fonts = new ObjectMap<>();
|
||||
private static final HashMap<Integer, FSkinFont> fonts = new HashMap<>();
|
||||
|
||||
private static final String commonCharacterSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklm"
|
||||
+ "nopqrstuvwxyz1234567890\"!?'.,;:()[]{}<>|/@\\^$-%+=#_&*\u2014"
|
||||
@@ -395,24 +396,34 @@ public class FSkinFont {
|
||||
fontName += Forge.locale;
|
||||
}
|
||||
FileHandle fontFile = Gdx.files.absolute(ForgeConstants.FONTS_DIR + fontName + ".fnt");
|
||||
final boolean[] found = {false};
|
||||
if (fontFile != null && fontFile.exists()) {
|
||||
final BitmapFontData data = new BitmapFontData(fontFile, false);
|
||||
String finalFontName = fontName;
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
@Override
|
||||
public void run() { //font must be initialized on UI thread
|
||||
font = new BitmapFont(data, (TextureRegion)null, true);
|
||||
try {
|
||||
font = new BitmapFont(data, (TextureRegion) null, true);
|
||||
found[0] = true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
found[0] = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (Forge.locale.equals("zh-CN") || Forge.locale.equals("ja-JP") && !Forge.forcedEnglishonCJKMissing) {
|
||||
String ttfName = Forge.CJK_Font;
|
||||
FileHandle ttfFile = Gdx.files.absolute(ForgeConstants.FONTS_DIR + ttfName + ".ttf");
|
||||
if (ttfFile != null && ttfFile.exists()) {
|
||||
generateFont(ttfFile, fontName, fontSize);
|
||||
}
|
||||
} else {
|
||||
generateFont(FSkin.getSkinFile(TTF_FILE), fontName, fontSize);
|
||||
}
|
||||
if (found[0])
|
||||
return;
|
||||
//not found generate
|
||||
if (Forge.locale.equals("zh-CN") || Forge.locale.equals("ja-JP") && !Forge.forcedEnglishonCJKMissing) {
|
||||
String ttfName = Forge.CJK_Font;
|
||||
FileHandle ttfFile = Gdx.files.absolute(ForgeConstants.FONTS_DIR + ttfName + ".ttf");
|
||||
if (ttfFile != null && ttfFile.exists()) {
|
||||
generateFont(ttfFile, fontName, fontSize);
|
||||
}
|
||||
} else {
|
||||
generateFont(FSkin.getSkinFile(TTF_FILE), fontName, fontSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package forge.assets;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.assets.loaders.TextureLoader.TextureParameter;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
@@ -536,19 +536,22 @@ public enum FSkinImage implements FImage {
|
||||
FSkin.getImages().put(skinProp, this);
|
||||
}
|
||||
|
||||
public void load(Map<String, Texture> textures, Pixmap preferredIcons) {
|
||||
public void load(AssetManager manager, Pixmap preferredIcons) {
|
||||
String filename = sourceFile.getFilename();
|
||||
FileHandle preferredFile = FSkin.getSkinFile(filename);
|
||||
Texture texture = textures.get(preferredFile.path());
|
||||
Texture texture = manager.get(preferredFile.path(), Texture.class, false);
|
||||
if (texture == null) {
|
||||
if (preferredFile.exists()) {
|
||||
try {
|
||||
if (Forge.isTextureFilteringEnabled()){
|
||||
texture = new Texture(preferredFile, true);
|
||||
texture.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
} else {
|
||||
texture = new Texture(preferredFile);
|
||||
TextureParameter parameter = new TextureParameter();
|
||||
if (Forge.isTextureFilteringEnabled()) {
|
||||
parameter.genMipMaps = true;
|
||||
parameter.minFilter = Texture.TextureFilter.MipMapLinearLinear;
|
||||
parameter.magFilter = Texture.TextureFilter.Linear;
|
||||
}
|
||||
manager.load(preferredFile.path(), Texture.class, parameter);
|
||||
manager.finishLoadingAsset(preferredFile.path());
|
||||
texture = manager.get(preferredFile.path(), Texture.class);
|
||||
}
|
||||
catch (final Exception e) {
|
||||
System.err.println("Failed to load skin file: " + preferredFile);
|
||||
@@ -615,16 +618,19 @@ public enum FSkinImage implements FImage {
|
||||
|
||||
//use default file if can't use preferred file
|
||||
FileHandle defaultFile = FSkin.getDefaultSkinFile(filename);
|
||||
texture = textures.get(defaultFile.path());
|
||||
texture = manager.get(defaultFile.path(), Texture.class, false);
|
||||
if (texture == null) {
|
||||
if (defaultFile.exists()) {
|
||||
try {
|
||||
if (Forge.isTextureFilteringEnabled()){
|
||||
texture = new Texture(defaultFile, true);
|
||||
texture.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||
} else {
|
||||
texture = new Texture(defaultFile);
|
||||
TextureParameter parameter = new TextureParameter();
|
||||
if (Forge.isTextureFilteringEnabled()) {
|
||||
parameter.genMipMaps = true;
|
||||
parameter.minFilter = Texture.TextureFilter.MipMapLinearLinear;
|
||||
parameter.magFilter = Texture.TextureFilter.Linear;
|
||||
}
|
||||
manager.load(defaultFile.path(), Texture.class, parameter);
|
||||
manager.finishLoadingAsset(defaultFile.path());
|
||||
texture = manager.get(defaultFile.path(), Texture.class);
|
||||
}
|
||||
catch (final Exception e) {
|
||||
System.err.println("Failed to load skin file: " + defaultFile);
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.Texture.TextureWrap;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.localinstance.properties.ForgeConstants;
|
||||
|
||||
@@ -127,7 +128,9 @@ public enum FSkinTexture implements FImage {
|
||||
FileHandle preferredFile = isPlane ? FSkin.getCachePlanechaseFile(filename) : FSkin.getSkinFile(filename);
|
||||
if (preferredFile.exists()) {
|
||||
try {
|
||||
texture = new Texture(preferredFile);
|
||||
Forge.getAssets(true).manager.load(preferredFile.path(), Texture.class);
|
||||
Forge.getAssets(true).manager.finishLoadingAsset(preferredFile.path());
|
||||
texture = Forge.getAssets(true).manager.get(preferredFile.path(), Texture.class);
|
||||
}
|
||||
catch (final Exception e) {
|
||||
System.err.println("Failed to load skin file: " + preferredFile);
|
||||
@@ -145,7 +148,9 @@ public enum FSkinTexture implements FImage {
|
||||
|
||||
if (defaultFile.exists()) {
|
||||
try {
|
||||
texture = new Texture(defaultFile);
|
||||
Forge.getAssets(true).manager.load(defaultFile.path(), Texture.class);
|
||||
Forge.getAssets(true).manager.finishLoadingAsset(defaultFile.path());
|
||||
texture = Forge.getAssets(true).manager.get(defaultFile.path(), Texture.class);
|
||||
}
|
||||
catch (final Exception e) {
|
||||
System.err.println("Failed to load skin file: " + defaultFile);
|
||||
|
||||
@@ -115,10 +115,6 @@ public class ImageCache {
|
||||
CardRenderer.clearcardArtCache();
|
||||
((Forge)Gdx.app.getApplicationListener()).cardAssets.manager().clear();
|
||||
}
|
||||
public static void disposeTextureManager() {
|
||||
((Forge)Gdx.app.getApplicationListener()).cardAssets.dispose();
|
||||
((Forge)Gdx.app.getApplicationListener()).otherAssets.dispose();
|
||||
}
|
||||
|
||||
public static Texture getImage(InventoryItem ii) {
|
||||
String imageKey = ii.getImageKey(false);
|
||||
@@ -271,17 +267,19 @@ public class ImageCache {
|
||||
return null;
|
||||
}
|
||||
String fileName = file.getPath();
|
||||
//load to assetmanager
|
||||
Forge.getAssets(otherCache).manager.load(fileName, Texture.class, Forge.isTextureFilteringEnabled() ? filtered : defaultParameter);
|
||||
Forge.getAssets(otherCache).manager.finishLoadingAsset(fileName);
|
||||
//return loaded assets
|
||||
if (otherCache) {
|
||||
((Forge)Gdx.app.getApplicationListener()).otherAssets.manager().load(fileName, Texture.class, Forge.isTextureFilteringEnabled() ? filtered : defaultParameter);
|
||||
((Forge)Gdx.app.getApplicationListener()).otherAssets.manager().finishLoadingAsset(fileName);
|
||||
return ((Forge)Gdx.app.getApplicationListener()).otherAssets.manager().get(fileName, Texture.class, false);
|
||||
return Forge.getAssets(true).manager.get(fileName, Texture.class, false);
|
||||
} else {
|
||||
((Forge)Gdx.app.getApplicationListener()).cardAssets.manager().load(fileName, Texture.class, Forge.isTextureFilteringEnabled() ? filtered : defaultParameter);
|
||||
((Forge)Gdx.app.getApplicationListener()).cardAssets.manager().finishLoadingAsset(fileName);
|
||||
Texture t = ((Forge)Gdx.app.getApplicationListener()).cardAssets.manager().get(fileName, Texture.class, false);
|
||||
Texture t = Forge.getAssets(false).manager.get(fileName, Texture.class, false);
|
||||
//if full bordermasking is enabled, update the border color
|
||||
if (Forge.enableUIMask.equals("Full")) {
|
||||
boolean borderless = isBorderless(imageKey);
|
||||
updateBorders(t.toString(), borderless ? Pair.of(Color.valueOf("#171717").toString(), false): isCloserToWhite(getpixelColor(t)));
|
||||
//if borderless, generate new texture from the asset and store
|
||||
if (borderless) {
|
||||
generatedCards.put(imageKey, generateTexture(new FileHandle(file), t, Forge.isTextureFilteringEnabled()));
|
||||
}
|
||||
|
||||
@@ -59,11 +59,17 @@ public class LoadingOverlay extends FOverlay {
|
||||
}
|
||||
|
||||
private String caption;
|
||||
private boolean textMode = false;
|
||||
|
||||
public LoadingOverlay(String caption0) {
|
||||
caption = caption0;
|
||||
}
|
||||
|
||||
public LoadingOverlay(String caption0, boolean textOnly) {
|
||||
caption = caption0;
|
||||
textMode = textOnly;
|
||||
}
|
||||
|
||||
public void setCaption(String caption0) {
|
||||
caption = caption0;
|
||||
}
|
||||
@@ -79,34 +85,38 @@ public class LoadingOverlay extends FOverlay {
|
||||
|
||||
@Override
|
||||
public void drawOverlay(Graphics g) {
|
||||
float x = INSETS;
|
||||
float panelWidth = getWidth() - 2 * INSETS;
|
||||
if (!textMode) {
|
||||
float x = INSETS;
|
||||
float panelWidth = getWidth() - 2 * INSETS;
|
||||
|
||||
if (Forge.isLandscapeMode()) {
|
||||
panelWidth = getHeight() - 2 * INSETS;
|
||||
x = (getWidth() - panelWidth) / 2;
|
||||
if (Forge.isLandscapeMode()) {
|
||||
panelWidth = getHeight() - 2 * INSETS;
|
||||
x = (getWidth() - panelWidth) / 2;
|
||||
}
|
||||
|
||||
float padding = panelWidth * INSETS_FACTOR;
|
||||
float logoSize = panelWidth * LOGO_SIZE_FACTOR;
|
||||
float fontHeight = FONT.getCapHeight();
|
||||
float panelHeight = logoSize + fontHeight + 4 * padding;
|
||||
|
||||
float y = (getHeight() - panelHeight) / 2;
|
||||
float oldAlpha = g.getfloatAlphaComposite();
|
||||
//dark translucent back..
|
||||
g.setAlphaComposite(0.6f);
|
||||
g.fillRect(Color.BLACK, 0, 0, getWidth(), getHeight());
|
||||
g.setAlphaComposite(oldAlpha);
|
||||
//overlay
|
||||
g.fillRect(BACK_COLOR, x, y, panelWidth, panelHeight);
|
||||
g.drawRect(Utils.scale(2), FORE_COLOR, x, y, panelWidth, panelHeight);
|
||||
y += padding;
|
||||
if (FSkin.hdLogo == null)
|
||||
g.drawImage(FSkinImage.LOGO, (getWidth() - logoSize) / 2f, y, logoSize, logoSize);
|
||||
else
|
||||
g.drawImage(FSkin.hdLogo, (getWidth() - logoSize) / 2f, y, logoSize, logoSize);
|
||||
y += logoSize + padding;
|
||||
g.drawText(caption, FONT, FORE_COLOR, x, y, panelWidth, getHeight(), false, Align.center, false);
|
||||
} else {
|
||||
g.drawText(caption, FONT, FORE_COLOR, 0, 0, getWidth(), getHeight(), true, Align.center, true);
|
||||
}
|
||||
|
||||
float padding = panelWidth * INSETS_FACTOR;
|
||||
float logoSize = panelWidth * LOGO_SIZE_FACTOR;
|
||||
float fontHeight = FONT.getCapHeight();
|
||||
float panelHeight = logoSize + fontHeight + 4 * padding;
|
||||
|
||||
float y = (getHeight() - panelHeight) / 2;
|
||||
float oldAlpha = g.getfloatAlphaComposite();
|
||||
//dark translucent back..
|
||||
g.setAlphaComposite(0.6f);
|
||||
g.fillRect(Color.BLACK, 0, 0, getWidth(), getHeight());
|
||||
g.setAlphaComposite(oldAlpha);
|
||||
//overlay
|
||||
g.fillRect(BACK_COLOR, x, y, panelWidth, panelHeight);
|
||||
g.drawRect(Utils.scale(2), FORE_COLOR, x, y, panelWidth, panelHeight);
|
||||
y += padding;
|
||||
if (FSkin.hdLogo == null)
|
||||
g.drawImage(FSkinImage.LOGO, (getWidth() - logoSize) / 2f, y, logoSize, logoSize);
|
||||
else
|
||||
g.drawImage(FSkin.hdLogo, (getWidth() - logoSize) / 2f, y, logoSize, logoSize);
|
||||
y += logoSize + padding;
|
||||
g.drawText(caption, FONT, FORE_COLOR, x, y, panelWidth, getHeight(), false, Align.center, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2849,6 +2849,7 @@ lblNewVersionAvailable=Neue Version vorhanden
|
||||
lblNewVersionDownloading=Lade neue Version...
|
||||
lblForgeHasBeenUpdateRestartForgeToUseNewVersion=Forge wurde heruntergeladen. Du solltest die Datei entpacken und Forge neu starten.
|
||||
lblExitNowConfirm=Jetzt verlassen?
|
||||
lblRestartInFewSeconds=Forge wird nach ein paar Sekunden neu starten ...
|
||||
#OnlineChatScreen.java
|
||||
lblEnterMessageToSend=Nachricht zum Senden eingeben
|
||||
#OnlineLobbyScreen.java
|
||||
|
||||
@@ -2852,6 +2852,7 @@ lblNewVersionAvailable=New Version Available
|
||||
lblNewVersionDownloading=Download the new version..
|
||||
lblForgeHasBeenUpdateRestartForgeToUseNewVersion=Forge has been downloaded. You should extract the package and restart Forge for the new version.
|
||||
lblExitNowConfirm=Exit now?
|
||||
lblRestartInFewSeconds=Forge will restart after a few seconds...
|
||||
#OnlineChatScreen.java
|
||||
lblEnterMessageToSend=Enter message to send
|
||||
#OnlineLobbyScreen.java
|
||||
|
||||
@@ -2852,6 +2852,7 @@ lblNewVersionAvailable=Nueva versión disponible
|
||||
lblNewVersionDownloading=Descarga la nueva versión ...
|
||||
lblForgeHasBeenUpdateRestartForgeToUseNewVersion=Forge se ha descargado. Extrae el fichero y reinicia Forge para cargar la nueva versión.
|
||||
lblExitNowConfirm=¿Salir ahora?
|
||||
lblRestartInFewSeconds=Forge se reiniciará después de unos segundos ...
|
||||
#OnlineChatScreen.java
|
||||
lblEnterMessageToSend=Introduce el mensaje a enviar
|
||||
#OnlineLobbyScreen.java
|
||||
|
||||
@@ -2855,6 +2855,7 @@ lblNewVersionAvailable=Nuova versione disponibile
|
||||
lblNewVersionDownloading=Scaricamento nuova versione...
|
||||
lblForgeHasBeenUpdateRestartForgeToUseNewVersion=Forge è stato scaricato. Devi estrarre i dati dal file compresso e riavviare Forge.
|
||||
lblExitNowConfirm=Vuoi uscire ora?
|
||||
lblRestartInFewSeconds=Forge si riavvierà dopo pochi secondi ...
|
||||
#OnlineChatScreen.java
|
||||
lblEnterMessageToSend=Inserisci il messaggio da inviare
|
||||
#OnlineLobbyScreen.java
|
||||
|
||||
@@ -2851,6 +2851,7 @@ lblNewVersionAvailable=新しいバージョンを見つかりました
|
||||
lblNewVersionDownloading=新しいバージョンをダウンロード中...
|
||||
lblForgeHasBeenUpdateRestartForgeToUseNewVersion=Forge のダウンロードが完了しました。パッケージを解凍して Forge を再起動してください。
|
||||
lblExitNowConfirm=終了しますか?
|
||||
lblRestartInFewSeconds=Forge は数秒後に再起動します...
|
||||
#OnlineChatScreen.java
|
||||
lblEnterMessageToSend=送るメッセージを入力
|
||||
#OnlineLobbyScreen.java
|
||||
|
||||
@@ -2941,6 +2941,7 @@ lblNewVersionAvailable=Nova Versão Disponível
|
||||
lblNewVersionDownloading=Baixar a nova versão..
|
||||
lblForgeHasBeenUpdateRestartForgeToUseNewVersion=O Forge foi baixado. Você deve extrair o pacote e reiniciar o Forge para a nova versão.
|
||||
lblExitNowConfirm=Sair agora?
|
||||
lblRestartInFewSeconds=Forge irá reiniciar depois de alguns segundos ...
|
||||
#OnlineChatScreen.java
|
||||
lblEnterMessageToSend=Digite a mensagem a enviar
|
||||
#OnlineLobbyScreen.java
|
||||
|
||||
@@ -2834,6 +2834,7 @@ lblNewVersionAvailable=有新版本可用
|
||||
lblNewVersionDownloading=下载新版本中
|
||||
lblForgeHasBeenUpdateRestartForgeToUseNewVersion=Forge已经下载好。你应该解压压缩包并使用新版本的Forge重启游戏。
|
||||
lblExitNowConfirm=现在退出吗?
|
||||
lblRestartInFewSeconds=Forge 将在几秒钟后重新启动...
|
||||
#OnlineChatScreen.java
|
||||
lblEnterMessageToSend=输入要发送的信息
|
||||
#OnlineLobbyScreen.java
|
||||
|
||||
Reference in New Issue
Block a user