Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Valerio Maggio
2019-08-25 12:37:35 +02:00
158 changed files with 473 additions and 425 deletions

View File

@@ -95,7 +95,7 @@ public class ComputerUtil {
sa.setHostCard(game.getAction().moveToStack(source, sa)); sa.setHostCard(game.getAction().moveToStack(source, sa));
} }
if (sa.isCopied()) { if (!sa.isCopied()) {
sa.resetPaidHash(); sa.resetPaidHash();
} }

View File

@@ -163,6 +163,10 @@ public final class ImageKeys {
for (String ext : FILE_EXTENSIONS) { for (String ext : FILE_EXTENSIONS) {
File file = new File(dir, filename + ext); File file = new File(dir, filename + ext);
if (file.exists()) { if (file.exists()) {
if (file.isDirectory()) {
file.delete();
continue;
}
return file; return file;
} }
} }

View File

@@ -292,6 +292,7 @@ public class AnimateEffect extends AnimateEffectBase {
addedStaticAbilities, timestamp); addedStaticAbilities, timestamp);
c.removeChangedName(timestamp); c.removeChangedName(timestamp);
c.updateStateForView();
game.fireEvent(new GameEventCardStatsChanged(c)); game.fireEvent(new GameEventCardStatsChanged(c));

View File

@@ -79,7 +79,7 @@ public abstract class AnimateEffectBase extends SpellAbilityEffect {
} }
if (sa.hasParam("RemoveLandTypes")) { if (sa.hasParam("RemoveLandTypes")) {
removeCreatureTypes = true; removeLandTypes = true;
} }
if (sa.hasParam("RemoveCreatureTypes")) { if (sa.hasParam("RemoveCreatureTypes")) {
removeCreatureTypes = true; removeCreatureTypes = true;

View File

@@ -874,6 +874,15 @@ public class CardProperty {
} }
} }
return false; return false;
case "TriggeredCard":
final Object triggeringObject = source.getTriggeringObject(restriction.substring("Triggered".length()));
if (!(triggeringObject instanceof Card)) {
return false;
}
if (card.sharesCardTypeWith((Card) triggeringObject)) {
return true;
}
return false;
case "EachTopLibrary": case "EachTopLibrary":
final CardCollection cards = new CardCollection(); final CardCollection cards = new CardCollection();
for (Player p : game.getPlayers()) { for (Player p : game.getPlayers()) {
@@ -1067,34 +1076,6 @@ public class CardProperty {
if (p == null || !controller.equals(game.getNextPlayerAfter(p, direction))) { if (p == null || !controller.equals(game.getNextPlayerAfter(p, direction))) {
return false; return false;
} }
} else if (property.startsWith("sharesTypeWith")) {
if (property.equals("sharesTypeWith")) {
if (!card.sharesTypeWith(source)) {
return false;
}
} else {
final String restriction = property.split("sharesTypeWith ")[1];
final Card checkCard;
if (restriction.startsWith("Triggered")) {
final Object triggeringObject = source.getTriggeringObject(restriction.substring("Triggered".length()));
if (!(triggeringObject instanceof Card)) {
return false;
}
checkCard = (Card) triggeringObject;
} else if (restriction.startsWith("Remembered")) {
final Object rememberedObject = source.getFirstRemembered();
if (!(rememberedObject instanceof Card)) {
return false;
}
checkCard = (Card) rememberedObject;
} else {
return false;
}
if (!card.sharesTypeWith(checkCard)) {
return false;
}
}
} else if (property.startsWith("hasKeyword")) { } else if (property.startsWith("hasKeyword")) {
// "withFlash" would find Flashback cards, add this to fix Mystical Teachings // "withFlash" would find Flashback cards, add this to fix Mystical Teachings
if (!card.hasKeyword(property.substring(10))) { if (!card.hasKeyword(property.substring(10))) {

View File

@@ -83,6 +83,7 @@ public enum TriggerType {
SetInMotion(TriggerSetInMotion.class), SetInMotion(TriggerSetInMotion.class),
Shuffled(TriggerShuffled.class), Shuffled(TriggerShuffled.class),
SpellAbilityCast(TriggerSpellAbilityCast.class), SpellAbilityCast(TriggerSpellAbilityCast.class),
SpellAbilityCopy(TriggerSpellAbilityCopy.class),
SpellCast(TriggerSpellAbilityCast.class), SpellCast(TriggerSpellAbilityCast.class),
SpellCopy(TriggerSpellAbilityCopy.class), SpellCopy(TriggerSpellAbilityCopy.class),
Surveil(TriggerSurveil.class), Surveil(TriggerSurveil.class),

View File

@@ -334,6 +334,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
if (sp.isSpell()) { if (sp.isSpell()) {
game.getTriggerHandler().runTrigger(TriggerType.SpellCopy, runParams, false); game.getTriggerHandler().runTrigger(TriggerType.SpellCopy, runParams, false);
} }
game.getTriggerHandler().runTrigger(TriggerType.SpellAbilityCopy, runParams, false);
} }
// Run BecomesTarget triggers // Run BecomesTarget triggers

View File

@@ -7,6 +7,7 @@
<uses-sdk <uses-sdk
android:minSdkVersion="19" android:minSdkVersion="19"
android:targetSdkVersion="21" /> android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/> <uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
@@ -14,13 +15,14 @@
<application <application
android:allowBackup="true" android:allowBackup="true"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:icon="@mipmap/ic_launcher"
android:icon="@drawable/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name" android:label="@string/app_name"
android:largeHeap="true"> android:largeHeap="true">
<activity <activity
android:name=".Main" android:name=".Main"
android:label="@string/app_name"> android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />

Binary file not shown.

Binary file not shown.

View File

@@ -102,7 +102,7 @@
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-android</artifactId> <artifactId>gdx-backend-android</artifactId>
<version>1.5.5</version> <version>1.9.10</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#f0f0f0</color>
</resources>

View File

@@ -17,6 +17,8 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.os.PowerManager; import android.os.PowerManager;
import android.provider.Settings;
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import android.view.WindowManager; import android.view.WindowManager;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
@@ -35,6 +37,8 @@ import java.io.OutputStream;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
public class Main extends AndroidApplication { public class Main extends AndroidApplication {
public int time = -2;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -235,13 +239,17 @@ public class Main extends AndroidApplication {
@Override @Override
public void preventSystemSleep(final boolean preventSleep) { public void preventSystemSleep(final boolean preventSleep) {
if (time == -2)
time = Settings.System.getInt(getContentResolver(), SCREEN_OFF_TIMEOUT, 0);
FThreads.invokeInEdtNowOrLater(new Runnable() { //must set window flags from EDT thread FThreads.invokeInEdtNowOrLater(new Runnable() { //must set window flags from EDT thread
@Override @Override
public void run() { public void run() {
if (preventSleep) { if (preventSleep) {
Settings.System.putInt(getContentResolver(), SCREEN_OFF_TIMEOUT, Integer.MAX_VALUE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} }
else { else {
Settings.System.putInt(getContentResolver(), SCREEN_OFF_TIMEOUT, time);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} }
} }

View File

@@ -14,6 +14,13 @@ final class ImageLoader extends CacheLoader<String, BufferedImage> {
public BufferedImage load(String key) { public BufferedImage load(String key) {
File file = ImageKeys.getImageFile(key); File file = ImageKeys.getImageFile(key);
if (file != null) { if (file != null) {
if (!file.exists()) {
return null;
}
if (file.isDirectory()) {
file.delete();
return null;
}
try { try {
return ImageIO.read(file); return ImageIO.read(file);
} }

View File

@@ -28,18 +28,35 @@ public class SwingImageFetcher extends ImageFetcher {
private void doFetch(String urlToDownload) throws IOException { private void doFetch(String urlToDownload) throws IOException {
URL url = new URL(urlToDownload); URL url = new URL(urlToDownload);
System.out.println("Attempting to fetch: " + url); System.out.println("Attempting to fetch: " + url);
java.net.URLConnection c = url.openConnection(); BufferedImage image = ImageIO.read(url);
c.setRequestProperty("User-Agent", "");
BufferedImage image = ImageIO.read(c.getInputStream());
// First, save to a temporary file so that nothing tries to read // First, save to a temporary file so that nothing tries to read
// a partial download. // a partial download.
File destFile = new File(destPath + ".tmp"); File destFile = new File(destPath + ".tmp");
destFile.mkdirs(); // need to check directory folder for mkdir
ImageIO.write(image, "jpg", destFile); destFile.getParentFile().mkdirs();
// Now, rename it to the correct name. if (ImageIO.write(image, "jpg", destFile)) {
destFile.renameTo(new File(destPath)); // Now, rename it to the correct name.
System.out.println("Saved image to " + destPath); if (destFile.renameTo(new File(destPath))) {
SwingUtilities.invokeLater(notifyObservers); System.out.println("Saved image to " + destPath);
SwingUtilities.invokeLater(notifyObservers);
} else {
System.err.println("Failed to rename image to " + destPath);
}
} else {
System.err.println("Failed to save image from " + url + " as jpeg");
// try to save image as png instead
if (ImageIO.write(image, "png", destFile)) {
String newPath = destPath.replace(".jpg", ".png");
if (destFile.renameTo(new File(newPath))) {
System.out.println("Saved image to " + newPath);
SwingUtilities.invokeLater(notifyObservers);
} else {
System.err.println("Failed to rename image to " + newPath);
}
} else {
System.err.println("Failed to save image from " + url + " as png");
}
}
} }
public void run() { public void run() {
@@ -48,7 +65,7 @@ public class SwingImageFetcher extends ImageFetcher {
doFetch(urlToDownload); doFetch(urlToDownload);
break; break;
} catch (IOException e) { } catch (IOException e) {
System.out.println("Failed to download card [" + destPath + "] image: " + e.getMessage()); System.err.println("Failed to download card [" + destPath + "] image: " + e.getMessage());
} }
} }
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -73,7 +73,7 @@
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-robovm</artifactId> <artifactId>gdx-backend-robovm</artifactId>
<version>1.5.5</version> <version>1.9.10</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -60,7 +60,7 @@
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-lwjgl</artifactId> <artifactId>gdx-backend-lwjgl</artifactId>
<version>1.5.5</version> <version>1.9.10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
@@ -71,7 +71,7 @@
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-freetype-platform</artifactId> <artifactId>gdx-freetype-platform</artifactId>
<version>1.5.5</version> <version>1.9.10</version>
<classifier>natives-desktop</classifier> <classifier>natives-desktop</classifier>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/commons-cli/commons-cli --> <!-- https://mvnrepository.com/artifact/commons-cli/commons-cli -->

Binary file not shown.

View File

@@ -63,12 +63,12 @@
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx</artifactId> <artifactId>gdx</artifactId>
<version>1.5.5</version> <version>1.9.10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-freetype</artifactId> <artifactId>gdx-freetype</artifactId>
<version>1.5.5</version> <version>1.9.10</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -4,8 +4,6 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
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.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
@@ -20,7 +18,7 @@ import forge.assets.FSkinColor;
import forge.assets.FSkinFont; import forge.assets.FSkinFont;
import forge.toolbox.FDisplayObject; import forge.toolbox.FDisplayObject;
import forge.util.Utils; import forge.util.Utils;
import forge.util.TextBounds;
import java.util.Stack; import java.util.Stack;
public class Graphics { public class Graphics {
@@ -602,10 +600,10 @@ public class Graphics {
batch.draw(image, adjustX(x), adjustY(y, h), originX - x, h - (originY - y), w, h, 1, 1, rotation, srcX, srcY, srcWidth, srcHeight, false, false); batch.draw(image, adjustX(x), adjustY(y, h), originX - x, h - (originY - y), w, h, 1, 1, rotation, srcX, srcY, srcWidth, srcHeight, false, false);
} }
public void drawText(String text, FSkinFont font, FSkinColor skinColor, float x, float y, float w, float h, boolean wrap, HAlignment horzAlignment, boolean centerVertically) { public void drawText(String text, FSkinFont font, FSkinColor skinColor, float x, float y, float w, float h, boolean wrap, int horzAlignment, boolean centerVertically) {
drawText(text, font, skinColor.getColor(), x, y, w, h, wrap, horzAlignment, centerVertically); drawText(text, font, skinColor.getColor(), x, y, w, h, wrap, horzAlignment, centerVertically);
} }
public void drawText(String text, FSkinFont font, Color color, float x, float y, float w, float h, boolean wrap, HAlignment horzAlignment, boolean centerVertically) { public void drawText(String text, FSkinFont font, Color color, float x, float y, float w, float h, boolean wrap, int horzAlignment, boolean centerVertically) {
if (alphaComposite < 1) { if (alphaComposite < 1) {
color = FSkinColor.alphaColor(color, color.a * alphaComposite); color = FSkinColor.alphaColor(color, color.a * alphaComposite);
} }
@@ -660,7 +658,7 @@ public class Graphics {
} }
//use nifty trick with multiple text renders to draw outlined text //use nifty trick with multiple text renders to draw outlined text
public void drawOutlinedText(String text, FSkinFont skinFont, Color textColor, Color outlineColor, float x, float y, float w, float h, boolean wrap, HAlignment horzAlignment, boolean centerVertically) { public void drawOutlinedText(String text, FSkinFont skinFont, Color textColor, Color outlineColor, float x, float y, float w, float h, boolean wrap, int horzAlignment, boolean centerVertically) {
drawText(text, skinFont, outlineColor, x - 1, y, w, h, wrap, horzAlignment, centerVertically); drawText(text, skinFont, outlineColor, x - 1, y, w, h, wrap, horzAlignment, centerVertically);
drawText(text, skinFont, outlineColor, x, y - 1, w, h, wrap, horzAlignment, centerVertically); drawText(text, skinFont, outlineColor, x, y - 1, w, h, wrap, horzAlignment, centerVertically);
drawText(text, skinFont, outlineColor, x - 1, y - 1, w, h, wrap, horzAlignment, centerVertically); drawText(text, skinFont, outlineColor, x - 1, y - 1, w, h, wrap, horzAlignment, centerVertically);

View File

@@ -8,7 +8,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
import forge.Graphics; import forge.Graphics;
public class GifAnimation extends ForgeAnimation { public class GifAnimation extends ForgeAnimation {
private final Animation animation; private final Animation<TextureRegion> animation;
private TextureRegion currentFrame; private TextureRegion currentFrame;
private float stateTime; private float stateTime;

View File

@@ -5,13 +5,8 @@ import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.*;
import com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData; import com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
import com.badlogic.gdx.graphics.g2d.PixmapPacker;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
import com.badlogic.gdx.graphics.glutils.PixmapTextureData; import com.badlogic.gdx.graphics.glutils.PixmapTextureData;
@@ -19,8 +14,8 @@ import com.badlogic.gdx.utils.Array;
import forge.FThreads; import forge.FThreads;
import forge.properties.ForgeConstants; import forge.properties.ForgeConstants;
import forge.util.FileUtil; import forge.util.FileUtil;
import forge.util.TextBounds;
import forge.util.Utils; import forge.util.Utils;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -31,6 +26,7 @@ public class FSkinFont {
private static final String TTF_FILE = "font1.ttf"; private static final String TTF_FILE = "font1.ttf";
private static final Map<Integer, FSkinFont> fonts = new HashMap<Integer, FSkinFont>(); private static final Map<Integer, FSkinFont> fonts = new HashMap<Integer, FSkinFont>();
private static final GlyphLayout layout = new GlyphLayout();
static { static {
FileUtil.ensureDirectoryExists(ForgeConstants.FONTS_DIR); FileUtil.ensureDirectoryExists(ForgeConstants.FONTS_DIR);
@@ -98,15 +94,22 @@ public class FSkinFont {
// Expose methods from font that updates scale as needed // Expose methods from font that updates scale as needed
public TextBounds getBounds(CharSequence str) { public TextBounds getBounds(CharSequence str) {
updateScale(); //must update scale before measuring text updateScale(); //must update scale before measuring text
return font.getBounds(str); layout.setText(font, str);
return new TextBounds(layout.width, layout.height);
} }
public TextBounds getMultiLineBounds(CharSequence str) { public TextBounds getMultiLineBounds(CharSequence str) {
updateScale(); updateScale();
return font.getMultiLineBounds(str); layout.setText(font, str);
return new TextBounds(layout.width, layout.height);
} }
public TextBounds getWrappedBounds(CharSequence str, float wrapWidth) { public TextBounds getWrappedBounds(CharSequence str, float wrapWidth) {
updateScale(); updateScale();
return font.getWrappedBounds(str, wrapWidth); layout.setText(font, str);
layout.width = wrapWidth;
return new TextBounds(layout.width, layout.height);
} }
public float getAscent() { public float getAscent() {
updateScale(); updateScale();
@@ -121,20 +124,16 @@ public class FSkinFont {
return font.getLineHeight(); return font.getLineHeight();
} }
public void draw(SpriteBatch batch, String text, Color color, float x, float y, float w, boolean wrap, HAlignment horzAlignment) { public void draw(SpriteBatch batch, String text, Color color, float x, float y, float w, boolean wrap, int horzAlignment) {
updateScale(); updateScale();
font.setColor(color); font.setColor(color);
if (wrap) { font.draw(batch, text, x, y, w, horzAlignment, wrap);
font.drawWrapped(batch, text, x, y, w, horzAlignment);
} else {
font.drawMultiLine(batch, text, x, y, w, horzAlignment);
}
} }
//update scale of font if needed //update scale of font if needed
private void updateScale() { private void updateScale() {
if (font.getScaleX() != scale) { if (font.getScaleX() != scale) {
font.setScale(scale); font.getData().setScale(scale);
} }
} }
@@ -187,7 +186,7 @@ public class FSkinFont {
//only generate images for characters that could be used by Forge //only generate images for characters that could be used by Forge
String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890\"!?'.,;:()[]{}<>|/@\\^$-%+=#_&*\u2014\u2022"; String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890\"!?'.,;:()[]{}<>|/@\\^$-%+=#_&*\u2014\u2022";
chars += "ÁÉÍÓÚáéíóúÀÈÌÒÙàèìòùÑñÄËÏÖÜäëïöüẞß";
final PixmapPacker packer = new PixmapPacker(pageSize, pageSize, Pixmap.Format.RGBA8888, 2, false); final PixmapPacker packer = new PixmapPacker(pageSize, pageSize, Pixmap.Format.RGBA8888, 2, false);
final FreeTypeFontParameter parameter = new FreeTypeFontParameter(); final FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.characters = chars; parameter.characters = chars;
@@ -200,7 +199,7 @@ public class FSkinFont {
FThreads.invokeInEdtNowOrLater(new Runnable() { FThreads.invokeInEdtNowOrLater(new Runnable() {
@Override @Override
public void run() { public void run() {
TextureRegion[] textureRegions = new TextureRegion[pages.size]; Array<TextureRegion> textureRegions = new Array<>();
for (int i = 0; i < pages.size; i++) { for (int i = 0; i < pages.size; i++) {
PixmapPacker.Page p = pages.get(i); PixmapPacker.Page p = pages.get(i);
Texture texture = new Texture(new PixmapTextureData(p.getPixmap(), p.getPixmap().getFormat(), false, false)) { Texture texture = new Texture(new PixmapTextureData(p.getPixmap(), p.getPixmap().getFormat(), false, false)) {
@@ -211,7 +210,7 @@ public class FSkinFont {
} }
}; };
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest); texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
textureRegions[i] = new TextureRegion(texture); textureRegions.addAll(new TextureRegion(texture));
} }
font = new BitmapFont(fontData, textureRegions, true); font = new BitmapFont(fontData, textureRegions, true);

View File

@@ -6,14 +6,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
import forge.Graphics; import forge.Graphics;
import forge.card.CardFaceSymbols; import forge.card.CardFaceSymbols;
import forge.model.FModel; import forge.model.FModel;
import forge.properties.ForgePreferences; import forge.properties.ForgePreferences;
import forge.properties.ForgePreferences.FPref; import forge.properties.ForgePreferences.FPref;
import forge.util.TextBounds;
//Encodes text for drawing with symbols and reminder text //Encodes text for drawing with symbols and reminder text
public class TextRenderer { public class TextRenderer {
@@ -528,10 +527,10 @@ public class TextRenderer {
return getCurrentBounds(); return getCurrentBounds();
} }
public void drawText(Graphics g, String text, FSkinFont skinFont, FSkinColor skinColor, float x, float y, float w, float h, float visibleStartY, float visibleHeight, boolean wrap0, HAlignment horzAlignment, boolean centerVertically) { public void drawText(Graphics g, String text, FSkinFont skinFont, FSkinColor skinColor, float x, float y, float w, float h, float visibleStartY, float visibleHeight, boolean wrap0, int horzAlignment, boolean centerVertically) {
drawText(g, text, skinFont, skinColor.getColor(), x, y, w, h, visibleStartY, visibleHeight, wrap0, horzAlignment, centerVertically); drawText(g, text, skinFont, skinColor.getColor(), x, y, w, h, visibleStartY, visibleHeight, wrap0, horzAlignment, centerVertically);
} }
public void drawText(Graphics g, String text, FSkinFont skinFont, Color color, float x, float y, float w, float h, float visibleStartY, float visibleHeight, boolean wrap0, HAlignment horzAlignment, boolean centerVertically) { public void drawText(Graphics g, String text, FSkinFont skinFont, Color color, float x, float y, float w, float h, float visibleStartY, float visibleHeight, boolean wrap0, int horzAlignment, boolean centerVertically) {
setProps(text, skinFont, w, h, wrap0); setProps(text, skinFont, w, h, wrap0);
if (needClip) { //prevent text flowing outside region if couldn't shrink it to fit if (needClip) { //prevent text flowing outside region if couldn't shrink it to fit
g.startClip(x, y, w, h); g.startClip(x, y, w, h);
@@ -542,13 +541,13 @@ public class TextRenderer {
float[] alignmentOffsets = new float[lineWidths.size()]; float[] alignmentOffsets = new float[lineWidths.size()];
for (int i = 0; i < lineWidths.size(); i++) { for (int i = 0; i < lineWidths.size(); i++) {
switch (horzAlignment) { switch (horzAlignment) {
case LEFT: case Align.left:
alignmentOffsets[i] = 0; alignmentOffsets[i] = 0;
break; break;
case CENTER: case Align.center:
alignmentOffsets[i] = Math.max((width - lineWidths.get(i)) / 2, 0); alignmentOffsets[i] = Math.max((width - lineWidths.get(i)) / 2, 0);
break; break;
case RIGHT: case Align.right:
alignmentOffsets[i] = Math.max(width - lineWidths.get(i), 0); alignmentOffsets[i] = Math.max(width - lineWidths.get(i), 0);
break; break;
} }
@@ -603,7 +602,7 @@ public class TextRenderer {
else if (inReminderText) { else if (inReminderText) {
color = FSkinColor.alphaColor(color, ALPHA_COMPOSITE); color = FSkinColor.alphaColor(color, ALPHA_COMPOSITE);
} }
g.drawText(text, font, color, x + offsetX, y + offsetY, w, h, false, HAlignment.LEFT, false); g.drawText(text, font, color, x + offsetX, y + offsetY, w, h, false, Align.left, false);
} }
} }

View File

@@ -2,7 +2,7 @@ package forge.card;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import forge.Graphics; import forge.Graphics;
import forge.assets.*; import forge.assets.*;
@@ -175,7 +175,7 @@ public class CardImageRenderer {
CardFaceSymbols.drawManaCost(g, otherManaCost, x + w - manaCostWidth, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE); CardFaceSymbols.drawManaCost(g, otherManaCost, x + w - manaCostWidth, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE);
//draw "//" between two parts of mana cost //draw "//" between two parts of mana cost
manaCostWidth += NAME_FONT.getBounds("//").width + HEADER_PADDING; manaCostWidth += NAME_FONT.getBounds("//").width + HEADER_PADDING;
g.drawText("//", NAME_FONT, Color.BLACK, x + w - manaCostWidth, y, w, h, false, HAlignment.LEFT, true); g.drawText("//", NAME_FONT, Color.BLACK, x + w - manaCostWidth, y, w, h, false, Align.left, true);
} }
manaCostWidth += CardFaceSymbols.getWidth(mainManaCost, MANA_SYMBOL_SIZE) + HEADER_PADDING; manaCostWidth += CardFaceSymbols.getWidth(mainManaCost, MANA_SYMBOL_SIZE) + HEADER_PADDING;
CardFaceSymbols.drawManaCost(g, mainManaCost, x + w - manaCostWidth, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE); CardFaceSymbols.drawManaCost(g, mainManaCost, x + w - manaCostWidth, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE);
@@ -183,7 +183,7 @@ public class CardImageRenderer {
//draw name for card //draw name for card
x += padding; x += padding;
w -= 2 * padding; w -= 2 * padding;
g.drawText(state.getName(), NAME_FONT, Color.BLACK, x, y, w - manaCostWidth - padding, h, false, HAlignment.LEFT, true); g.drawText(state.getName(), NAME_FONT, Color.BLACK, x, y, w - manaCostWidth - padding, h, false, Align.left, true);
} }
public static final FBufferedImage forgeArt; public static final FBufferedImage forgeArt;
@@ -221,7 +221,7 @@ public class CardImageRenderer {
//draw type //draw type
x += padding; x += padding;
g.drawText(CardDetailUtil.formatCardType(state, canShow), TYPE_FONT, Color.BLACK, x, y, w, h, false, HAlignment.LEFT, true); g.drawText(CardDetailUtil.formatCardType(state, canShow), TYPE_FONT, Color.BLACK, x, y, w, h, false, Align.left, true);
} }
//use text renderer to handle mana symbols and reminder text //use text renderer to handle mana symbols and reminder text
@@ -268,7 +268,7 @@ public class CardImageRenderer {
y += padding; y += padding;
w -= 2 * padding; w -= 2 * padding;
h -= 2 * padding; h -= 2 * padding;
cardTextRenderer.drawText(g, text, TEXT_FONT, Color.BLACK, x, y, w, h, y, h, true, HAlignment.LEFT, true); cardTextRenderer.drawText(g, text, TEXT_FONT, Color.BLACK, x, y, w, h, y, h, true, Align.left, true);
} }
} }
@@ -313,7 +313,7 @@ public class CardImageRenderer {
x += (boxWidth - totalPieceWidth) / 2; x += (boxWidth - totalPieceWidth) / 2;
for (int i = 0; i < pieces.size(); i++) { for (int i = 0; i < pieces.size(); i++) {
g.drawText(pieces.get(i), PT_FONT, Color.BLACK, x, y, w, h, false, HAlignment.LEFT, true); g.drawText(pieces.get(i), PT_FONT, Color.BLACK, x, y, w, h, false, Align.left, true);
x += pieceWidths[i]; x += pieceWidths[i];
} }
} }
@@ -451,7 +451,7 @@ public class CardImageRenderer {
CardFaceSymbols.drawManaCost(g, otherManaCost, x + w - manaCostWidth, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE); CardFaceSymbols.drawManaCost(g, otherManaCost, x + w - manaCostWidth, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE);
//draw "//" between two parts of mana cost //draw "//" between two parts of mana cost
manaCostWidth += NAME_FONT.getBounds("//").width + HEADER_PADDING; manaCostWidth += NAME_FONT.getBounds("//").width + HEADER_PADDING;
g.drawText("//", NAME_FONT, Color.BLACK, x + w - manaCostWidth, y, w, h, false, HAlignment.LEFT, true); g.drawText("//", NAME_FONT, Color.BLACK, x + w - manaCostWidth, y, w, h, false, Align.left, true);
} }
manaCostWidth += CardFaceSymbols.getWidth(mainManaCost, MANA_SYMBOL_SIZE) + HEADER_PADDING; manaCostWidth += CardFaceSymbols.getWidth(mainManaCost, MANA_SYMBOL_SIZE) + HEADER_PADDING;
CardFaceSymbols.drawManaCost(g, mainManaCost, x + w - manaCostWidth, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE); CardFaceSymbols.drawManaCost(g, mainManaCost, x + w - manaCostWidth, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE);
@@ -460,7 +460,7 @@ public class CardImageRenderer {
//draw name for card //draw name for card
x += padding; x += padding;
w -= 2 * padding; w -= 2 * padding;
g.drawText(CardDetailUtil.formatCardName(card, canShow, state == card.getAlternateState()), NAME_FONT, Color.BLACK, x, y, w - manaCostWidth - padding, h, false, HAlignment.LEFT, true); g.drawText(CardDetailUtil.formatCardName(card, canShow, state == card.getAlternateState()), NAME_FONT, Color.BLACK, x, y, w - manaCostWidth - padding, h, false, Align.left, true);
//draw type and set label for card //draw type and set label for card
y += h; y += h;
@@ -478,7 +478,7 @@ public class CardImageRenderer {
w -= setWidth; //reduce available width for type w -= setWidth; //reduce available width for type
} }
g.drawText(CardDetailUtil.formatCardType(state, canShow), TYPE_FONT, Color.BLACK, x, y, w, h, false, HAlignment.LEFT, true); g.drawText(CardDetailUtil.formatCardType(state, canShow), TYPE_FONT, Color.BLACK, x, y, w, h, false, Align.left, true);
} }
private static void drawDetailsTextBox(Graphics g, CardStateView state, GameView gameView, boolean canShow, Color[] colors, float x, float y, float w, float h) { private static void drawDetailsTextBox(Graphics g, CardStateView state, GameView gameView, boolean canShow, Color[] colors, float x, float y, float w, float h) {
@@ -491,14 +491,14 @@ public class CardImageRenderer {
y += padY; y += padY;
w -= 2 * padX; w -= 2 * padX;
h -= 2 * padY; h -= 2 * padY;
cardTextRenderer.drawText(g, CardDetailUtil.composeCardText(state, gameView, canShow), TEXT_FONT, Color.BLACK, x, y, w, h, y, h, true, HAlignment.LEFT, false); cardTextRenderer.drawText(g, CardDetailUtil.composeCardText(state, gameView, canShow), TEXT_FONT, Color.BLACK, x, y, w, h, y, h, true, Align.left, false);
} }
private static void drawDetailsIdAndPtBox(Graphics g, CardView card, CardStateView state, boolean canShow, Color idForeColor, Color[] colors, float x, float y, float w, float h) { private static void drawDetailsIdAndPtBox(Graphics g, CardView card, CardStateView state, boolean canShow, Color idForeColor, Color[] colors, float x, float y, float w, float h) {
float idWidth = 0; float idWidth = 0;
if (canShow) { if (canShow) {
String idText = CardDetailUtil.formatCardId(state); String idText = CardDetailUtil.formatCardId(state);
g.drawText(idText, TYPE_FONT, idForeColor, x, y + TYPE_FONT.getCapHeight() / 2, w, h, false, HAlignment.LEFT, false); g.drawText(idText, TYPE_FONT, idForeColor, x, y + TYPE_FONT.getCapHeight() / 2, w, h, false, Align.left, false);
idWidth = TYPE_FONT.getBounds(idText).width; idWidth = TYPE_FONT.getBounds(idText).width;
} }
@@ -513,6 +513,6 @@ public class CardImageRenderer {
fillColorBackground(g, colors, x, y, w, h); fillColorBackground(g, colors, x, y, w, h);
g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h); g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h);
g.drawText(ptText, PT_FONT, Color.BLACK, x, y, w, h, false, HAlignment.CENTER, true); g.drawText(ptText, PT_FONT, Color.BLACK, x, y, w, h, false, Align.center, true);
} }
} }

View File

@@ -1,6 +1,6 @@
package forge.card; package forge.card;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import forge.item.PaperCard; import forge.item.PaperCard;
@@ -14,7 +14,7 @@ public class CardListPreview extends FLabel {
public CardListPreview(FChoiceList<PaperCard> list0) { public CardListPreview(FChoiceList<PaperCard> list0) {
super(new FLabel.Builder().iconScaleFactor(1).insets(new Vector2(0, 0)) super(new FLabel.Builder().iconScaleFactor(1).insets(new Vector2(0, 0))
.iconInBackground(true).align(HAlignment.CENTER)); .iconInBackground(true).align(Align.center));
list = list0; list = list0;
} }

View File

@@ -7,13 +7,13 @@ import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
import com.badlogic.gdx.graphics.g2d.PixmapPacker; import com.badlogic.gdx.graphics.g2d.PixmapPacker;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
import com.badlogic.gdx.graphics.glutils.PixmapTextureData; import com.badlogic.gdx.graphics.glutils.PixmapTextureData;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import forge.CachedCardImage; import forge.CachedCardImage;
import forge.FThreads; import forge.FThreads;
@@ -40,7 +40,7 @@ import forge.screens.match.MatchController;
import forge.toolbox.FList; import forge.toolbox.FList;
import forge.util.Utils; import forge.util.Utils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import forge.util.TextBounds;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -95,6 +95,7 @@ public class CardRenderer {
private static Map<Integer, BitmapFont> counterFonts = new HashMap<>(); private static Map<Integer, BitmapFont> counterFonts = new HashMap<>();
private static final Color counterBackgroundColor = new Color(0f, 0f, 0f, 0.9f); private static final Color counterBackgroundColor = new Color(0f, 0f, 0f, 0.9f);
private static final Map<CounterType, Color> counterColorCache = new HashMap<>(); private static final Map<CounterType, Color> counterColorCache = new HashMap<>();
private static final GlyphLayout layout = new GlyphLayout();
static { static {
try { try {
@@ -261,7 +262,7 @@ public class CardRenderer {
if (suffix != null) { if (suffix != null) {
name += suffix; name += suffix;
} }
g.drawText(name, font, foreColor, x, y, w, h, false, HAlignment.CENTER, true); g.drawText(name, font, foreColor, x, y, w, h, false, Align.center, true);
} }
} }
@@ -310,7 +311,7 @@ public class CardRenderer {
CardFaceSymbols.drawManaCost(g, otherManaCost, x + w - manaCostWidth + MANA_COST_PADDING, y, MANA_SYMBOL_SIZE); CardFaceSymbols.drawManaCost(g, otherManaCost, x + w - manaCostWidth + MANA_COST_PADDING, y, MANA_SYMBOL_SIZE);
//draw "//" between two parts of mana cost //draw "//" between two parts of mana cost
manaCostWidth += font.getBounds("//").width + MANA_COST_PADDING; manaCostWidth += font.getBounds("//").width + MANA_COST_PADDING;
g.drawText("//", font, foreColor, x + w - manaCostWidth + MANA_COST_PADDING, y, w, MANA_SYMBOL_SIZE, false, HAlignment.LEFT, true); g.drawText("//", font, foreColor, x + w - manaCostWidth + MANA_COST_PADDING, y, w, MANA_SYMBOL_SIZE, false, Align.left, true);
} }
manaCostWidth += CardFaceSymbols.getWidth(mainManaCost, MANA_SYMBOL_SIZE); manaCostWidth += CardFaceSymbols.getWidth(mainManaCost, MANA_SYMBOL_SIZE);
CardFaceSymbols.drawManaCost(g, mainManaCost, x + w - manaCostWidth, y, MANA_SYMBOL_SIZE); CardFaceSymbols.drawManaCost(g, mainManaCost, x + w - manaCostWidth, y, MANA_SYMBOL_SIZE);
@@ -323,7 +324,7 @@ public class CardRenderer {
if (suffix != null) { if (suffix != null) {
name += suffix; name += suffix;
} }
g.drawText(name, font, foreColor, x, y, w - manaCostWidth - cardArtWidth - FList.PADDING, MANA_SYMBOL_SIZE, false, HAlignment.LEFT, true); g.drawText(name, font, foreColor, x, y, w - manaCostWidth - cardArtWidth - FList.PADDING, MANA_SYMBOL_SIZE, false, Align.left, true);
if (compactMode) { if (compactMode) {
return; //skip second line if rendering in compact mode return; //skip second line if rendering in compact mode
@@ -350,7 +351,7 @@ public class CardRenderer {
else if (card.getCurrentState().getType().hasSubtype("Vehicle")) { else if (card.getCurrentState().getType().hasSubtype("Vehicle")) {
type += String.format(" [%s / %s]", power, toughness); type += String.format(" [%s / %s]", power, toughness);
} }
g.drawText(type, typeFont, foreColor, x, y, availableTypeWidth, lineHeight, false, HAlignment.LEFT, true); g.drawText(type, typeFont, foreColor, x, y, availableTypeWidth, lineHeight, false, Align.left, true);
} }
public static boolean cardListItemTap(List<?> cards, int selectedIndex, ActivateHandler activateHandler, float x, float y, int count, boolean compactMode) { public static boolean cardListItemTap(List<?> cards, int selectedIndex, ActivateHandler activateHandler, float x, float y, int count, boolean compactMode) {
@@ -379,7 +380,7 @@ public class CardRenderer {
Color backColor = getRarityColor(rarity); Color backColor = getRarityColor(rarity);
Color foreColor = FSkinColor.getHighContrastColor(backColor); Color foreColor = FSkinColor.getHighContrastColor(backColor);
g.fillRect(backColor, x, y, w, h); g.fillRect(backColor, x, y, w, h);
g.drawText(set, font, foreColor, x, y, w, h, false, HAlignment.CENTER, true); g.drawText(set, font, foreColor, x, y, w, h, false, Align.center, true);
} }
public static void drawCard(Graphics g, IPaperCard pc, float x, float y, float w, float h, CardStackPosition pos) { public static void drawCard(Graphics g, IPaperCard pc, float x, float y, float w, float h, CardStackPosition pos) {
@@ -447,7 +448,7 @@ public class CardRenderer {
//draw name and mana cost overlays if card is small or default card image being used //draw name and mana cost overlays if card is small or default card image being used
if (h <= NAME_COST_THRESHOLD && canShow) { if (h <= NAME_COST_THRESHOLD && canShow) {
if (showCardNameOverlay(card)) { if (showCardNameOverlay(card)) {
g.drawOutlinedText(details.getName(), FSkinFont.forHeight(h * 0.18f), Color.WHITE, Color.BLACK, x + padding, y + padding, w - 2 * padding, h * 0.4f, true, HAlignment.LEFT, false); g.drawOutlinedText(details.getName(), FSkinFont.forHeight(h * 0.18f), Color.WHITE, Color.BLACK, x + padding, y + padding, w - 2 * padding, h * 0.4f, true, Align.left, false);
} }
if (showCardManaCostOverlay(card)) { if (showCardManaCostOverlay(card)) {
float manaSymbolSize = w / 4; float manaSymbolSize = w / 4;
@@ -476,7 +477,7 @@ public class CardRenderer {
if (canShow && showCardIdOverlay(card)) { if (canShow && showCardIdOverlay(card)) {
FSkinFont idFont = FSkinFont.forHeight(h * 0.12f); FSkinFont idFont = FSkinFont.forHeight(h * 0.12f);
float idHeight = idFont.getCapHeight(); float idHeight = idFont.getCapHeight();
g.drawOutlinedText(String.valueOf(card.getId()), idFont, Color.WHITE, Color.BLACK, x + padding, y + h - idHeight - padding, w, h, false, HAlignment.LEFT, false); g.drawOutlinedText(String.valueOf(card.getId()), idFont, Color.WHITE, Color.BLACK, x + padding, y + h - idHeight - padding, w, h, false, Align.left, false);
} }
if (card.getCounters() != null && !card.getCounters().isEmpty()) { if (card.getCounters() != null && !card.getCounters().isEmpty()) {
@@ -556,7 +557,11 @@ public class CardRenderer {
maxCounters = Math.max(maxCounters, numberOfCounters); maxCounters = Math.max(maxCounters, numberOfCounters);
} }
if (counterBoxBaseWidth + font.getBounds(String.valueOf(maxCounters)).width > w) { //if (counterBoxBaseWidth + font.getBounds(String.valueOf(maxCounters)).width > w) {
layout.setText(font, String.valueOf(maxCounters));
if (counterBoxBaseWidth + layout.width > w) {
drawCounterImage(card, g, x, y, w, h); drawCounterImage(card, g, x, y, w, h);
return; return;
} }
@@ -567,7 +572,9 @@ public class CardRenderer {
final CounterType counter = counterEntry.getKey(); final CounterType counter = counterEntry.getKey();
final int numberOfCounters = counterEntry.getValue(); final int numberOfCounters = counterEntry.getValue();
final float counterBoxRealWidth = counterBoxBaseWidth + font.getBounds(String.valueOf(numberOfCounters)).width + 4; //final float counterBoxRealWidth = counterBoxBaseWidth + font.getBounds(String.valueOf(numberOfCounters)).width + 4;
layout.setText(font, String.valueOf(numberOfCounters));
final float counterBoxRealWidth = counterBoxBaseWidth + layout.width + 4;
final float counterYOffset = spaceFromTopOfCard - (currentCounter++ * (counterBoxHeight + counterBoxSpacing)); final float counterYOffset = spaceFromTopOfCard - (currentCounter++ * (counterBoxHeight + counterBoxSpacing));
@@ -579,8 +586,8 @@ public class CardRenderer {
Color counterColor = counterColorCache.get(counter); Color counterColor = counterColorCache.get(counter);
drawText(g, counter.getCounterOnCardDisplayName(), font, counterColor, x + 2 + additionalXOffset, counterYOffset, counterBoxRealWidth, counterBoxHeight, HAlignment.LEFT); drawText(g, counter.getCounterOnCardDisplayName(), font, counterColor, x + 2 + additionalXOffset, counterYOffset, counterBoxRealWidth, counterBoxHeight, Align.left);
drawText(g, String.valueOf(numberOfCounters), font, counterColor, x + counterBoxBaseWidth - 4f - additionalXOffset, counterYOffset, counterBoxRealWidth, counterBoxHeight, HAlignment.LEFT); drawText(g, String.valueOf(numberOfCounters), font, counterColor, x + counterBoxBaseWidth - 4f - additionalXOffset, counterYOffset, counterBoxRealWidth, counterBoxHeight, Align.left);
} }
@@ -588,13 +595,14 @@ public class CardRenderer {
private static final int GL_BLEND = GL20.GL_BLEND; private static final int GL_BLEND = GL20.GL_BLEND;
private static void drawText(Graphics g, String text, BitmapFont font, Color color, float x, float y, float w, float h, HAlignment horizontalAlignment) { private static void drawText(Graphics g, String text, BitmapFont font, Color color, float x, float y, float w, float h, int horizontalAlignment) {
if (color.a < 1) { //enable blending so alpha colored shapes work properly if (color.a < 1) { //enable blending so alpha colored shapes work properly
Gdx.gl.glEnable(GL_BLEND); Gdx.gl.glEnable(GL_BLEND);
} }
TextBounds textBounds = font.getMultiLineBounds(text); layout.setText(font, text);
TextBounds textBounds = new TextBounds(layout.width, layout.height);
float textHeight = textBounds.height; float textHeight = textBounds.height;
if (h > textHeight) { if (h > textHeight) {
@@ -602,7 +610,7 @@ public class CardRenderer {
} }
font.setColor(color); font.setColor(color);
font.drawMultiLine(g.getBatch(), text, g.adjustX(x), g.adjustY(y, 0), w, horizontalAlignment); font.draw(g.getBatch(), text, g.adjustX(x), g.adjustY(y, 0), w, horizontalAlignment, true);
if (color.a < 1) { if (color.a < 1) {
Gdx.gl.glDisable(GL_BLEND); Gdx.gl.glDisable(GL_BLEND);
@@ -685,7 +693,7 @@ public class CardRenderer {
//draw card damage above P/T box if needed //draw card damage above P/T box if needed
if (card.getDamage() > 0) { if (card.getDamage() > 0) {
g.drawOutlinedText(">" + card.getDamage() + "<", font, Color.RED, Color.WHITE, x, y - h + padding, w, h, false, HAlignment.CENTER, true); g.drawOutlinedText(">" + card.getDamage() + "<", font, Color.RED, Color.WHITE, x, y - h + padding, w, h, false, Align.center, true);
} }
g.fillRect(color, x, y, w, h); g.fillRect(color, x, y, w, h);
@@ -693,7 +701,7 @@ public class CardRenderer {
x += padding; x += padding;
for (int i = 0; i < pieces.size(); i++) { for (int i = 0; i < pieces.size(); i++) {
g.drawText(pieces.get(i), font, Color.BLACK, x, y, w, h, false, HAlignment.LEFT, true); g.drawText(pieces.get(i), font, Color.BLACK, x, y, w, h, false, Align.left, true);
x += pieceWidths.get(i); x += pieceWidths.get(i);
} }
} }
@@ -771,7 +779,8 @@ public class CardRenderer {
@Override @Override
public void run() { public void run() {
TextureRegion[] textureRegions = new TextureRegion[pages.size]; //TextureRegion[] textureRegions = new TextureRegion[pages.size];
Array<TextureRegion> textureRegions = new Array<>();
for (int i = 0; i < pages.size; i++) { for (int i = 0; i < pages.size; i++) {
PixmapPacker.Page p = pages.get(i); PixmapPacker.Page p = pages.get(i);
Texture texture = new Texture(new PixmapTextureData(p.getPixmap(), p.getPixmap().getFormat(), false, false)) { Texture texture = new Texture(new PixmapTextureData(p.getPixmap(), p.getPixmap().getFormat(), false, false)) {
@@ -782,7 +791,8 @@ public class CardRenderer {
} }
}; };
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest); texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
textureRegions[i] = new TextureRegion(texture); //textureRegions[i] = new TextureRegion(texture);
textureRegions.add(new TextureRegion(texture));
} }
counterFonts.put(fontSize, new BitmapFont(fontData, textureRegions, true)); counterFonts.put(fontSize, new BitmapFont(fontData, textureRegions, true));

View File

@@ -5,8 +5,8 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Align;
import forge.Forge; import forge.Forge;
import forge.Graphics; import forge.Graphics;
@@ -281,10 +281,10 @@ public class CardZoom extends FOverlay {
if (currentActivateAction != null) { if (currentActivateAction != null) {
g.fillRect(FDialog.MSG_BACK_COLOR, 0, 0, w, messageHeight); g.fillRect(FDialog.MSG_BACK_COLOR, 0, 0, w, messageHeight);
g.drawText("Swipe up to " + currentActivateAction, FDialog.MSG_FONT, FDialog.MSG_FORE_COLOR, 0, 0, w, messageHeight, false, HAlignment.CENTER, true); g.drawText("Swipe up to " + currentActivateAction, FDialog.MSG_FONT, FDialog.MSG_FORE_COLOR, 0, 0, w, messageHeight, false, Align.center, true);
} }
g.fillRect(FDialog.MSG_BACK_COLOR, 0, h - messageHeight, w, messageHeight); g.fillRect(FDialog.MSG_BACK_COLOR, 0, h - messageHeight, w, messageHeight);
g.drawText("Swipe down to switch to " + (zoomMode ? "detail" : "picture") + " view", FDialog.MSG_FONT, FDialog.MSG_FORE_COLOR, 0, h - messageHeight, w, messageHeight, false, HAlignment.CENTER, true); g.drawText("Swipe down to switch to " + (zoomMode ? "detail" : "picture") + " view", FDialog.MSG_FONT, FDialog.MSG_FORE_COLOR, 0, h - messageHeight, w, messageHeight, false, Align.center, true);
} }
@Override @Override

View File

@@ -48,7 +48,7 @@ import forge.toolbox.FTextArea;
import forge.util.Callback; import forge.util.Callback;
import forge.util.Utils; import forge.util.Utils;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import java.util.Map; import java.util.Map;
@@ -122,7 +122,7 @@ public class AddBasicLandsDialog extends FDialog {
callback = callback0; callback = callback0;
currentDeck = deck; currentDeck = deck;
lblDeckInfo.setAlignment(HAlignment.CENTER); lblDeckInfo.setAlignment(Align.center);
lblDeckInfo.setFont(FSkinFont.get(12)); lblDeckInfo.setFont(FSkinFont.get(12));
cbLandSet.setFont(lblLandSet.getFont()); cbLandSet.setFont(lblLandSet.getFont());
@@ -322,7 +322,7 @@ public class AddBasicLandsDialog extends FDialog {
card = generateCard(artIndex); //generate card for display card = generateCard(artIndex); //generate card for display
} }
}); });
lblCount = add(new FLabel.Builder().text("0").font(FSkinFont.get(18)).align(HAlignment.CENTER).build()); lblCount = add(new FLabel.Builder().text("0").font(FSkinFont.get(18)).align(Align.center).build());
btnSubtract = add(new FLabel.ButtonBuilder().icon(FSkinImage.MINUS).command(new FEventHandler() { btnSubtract = add(new FLabel.ButtonBuilder().icon(FSkinImage.MINUS).command(new FEventHandler() {
@Override @Override
public void handleEvent(FEvent e) { public void handleEvent(FEvent e) {

View File

@@ -41,7 +41,7 @@ import forge.util.storage.IStorage;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import java.util.ArrayList; import java.util.ArrayList;
@@ -524,7 +524,7 @@ public class FDeckChooser extends FScreen {
cmbDeckTypes.addItem(DeckType.RANDOM_DECK); cmbDeckTypes.addItem(DeckType.RANDOM_DECK);
break; break;
} }
cmbDeckTypes.setAlignment(HAlignment.CENTER); cmbDeckTypes.setAlignment(Align.center);
restoreSavedState(); restoreSavedState();
cmbDeckTypes.setChangedHandler(new FEventHandler() { cmbDeckTypes.setChangedHandler(new FEventHandler() {
@Override @Override

View File

@@ -1,8 +1,8 @@
package forge.deck; package forge.deck;
import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Align;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
@@ -239,8 +239,8 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
protected final DeckHeader deckHeader = add(new DeckHeader()); protected final DeckHeader deckHeader = add(new DeckHeader());
protected final FLabel lblName = deckHeader.add(new FLabel.Builder().font(FSkinFont.get(16)).insets(new Vector2(Utils.scale(5), 0)).build()); protected final FLabel lblName = deckHeader.add(new FLabel.Builder().font(FSkinFont.get(16)).insets(new Vector2(Utils.scale(5), 0)).build());
private final FLabel btnSave = deckHeader.add(new FLabel.Builder().icon(FSkinImage.SAVE).align(HAlignment.CENTER).pressedColor(Header.BTN_PRESSED_COLOR).build()); private final FLabel btnSave = deckHeader.add(new FLabel.Builder().icon(FSkinImage.SAVE).align(Align.center).pressedColor(Header.BTN_PRESSED_COLOR).build());
private final FLabel btnMoreOptions = deckHeader.add(new FLabel.Builder().text("...").font(FSkinFont.get(20)).align(HAlignment.CENTER).pressedColor(Header.BTN_PRESSED_COLOR).build()); private final FLabel btnMoreOptions = deckHeader.add(new FLabel.Builder().text("...").font(FSkinFont.get(20)).align(Align.center).pressedColor(Header.BTN_PRESSED_COLOR).build());
public FDeckEditor(EditorType editorType0, DeckProxy editDeck, boolean showMainDeck) { public FDeckEditor(EditorType editorType0, DeckProxy editDeck, boolean showMainDeck) {
this(editorType0, editDeck.getName(), editDeck.getPath(), null, showMainDeck); this(editorType0, editDeck.getName(), editDeck.getPath(), null, showMainDeck);

View File

@@ -1,8 +1,6 @@
package forge.error; package forge.error;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
import forge.Forge; import forge.Forge;
import forge.Graphics; import forge.Graphics;
import forge.assets.FSkinColor; import forge.assets.FSkinColor;
@@ -15,6 +13,7 @@ import forge.toolbox.FEvent.FEventHandler;
import forge.toolbox.FScrollPane; import forge.toolbox.FScrollPane;
import forge.toolbox.FTextArea; import forge.toolbox.FTextArea;
import forge.util.Callback; import forge.util.Callback;
import forge.util.TextBounds;
import forge.util.Utils; import forge.util.Utils;
public class BugReportDialog extends FScreen { //use screen rather than dialog so screen with bug isn't rendered public class BugReportDialog extends FScreen { //use screen rather than dialog so screen with bug isn't rendered
@@ -148,7 +147,7 @@ public class BugReportDialog extends FScreen { //use screen rather than dialog s
@Override @Override
public void drawBackground(Graphics g) { public void drawBackground(Graphics g) {
g.fillRect(BACK_COLOR, 0, 0, getWidth(), getHeight()); g.fillRect(BACK_COLOR, 0, 0, getWidth(), getHeight());
g.drawText(text, FONT, FORE_COLOR, PADDING - getScrollLeft(), PADDING - getScrollTop(), getScrollWidth() - 2 * PADDING, getScrollHeight() - 2 * PADDING, false, HAlignment.LEFT, false); g.drawText(text, FONT, FORE_COLOR, PADDING - getScrollLeft(), PADDING - getScrollTop(), getScrollWidth() - 2 * PADDING, getScrollHeight() - 2 * PADDING, false, Align.left, false);
} }
@Override @Override

View File

@@ -20,7 +20,7 @@ import forge.toolbox.FList;
import forge.toolbox.FList.CompactModeHandler; import forge.toolbox.FList.CompactModeHandler;
import forge.util.Utils; import forge.util.Utils;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import java.util.Map.Entry; import java.util.Map.Entry;
@@ -118,7 +118,7 @@ public final class DeckManager extends ItemManager<DeckProxy> implements IHasGam
if (DeckManager.this.getConfig().getCols().size() == 1) { if (DeckManager.this.getConfig().getCols().size() == 1) {
//if just string column, just draw deck string value //if just string column, just draw deck string value
g.drawText(deck.toString(), font, foreColor, x, y, w, h, false, HAlignment.LEFT, true); g.drawText(deck.toString(), font, foreColor, x, y, w, h, false, Align.left, true);
return; return;
} }
@@ -131,7 +131,7 @@ public final class DeckManager extends ItemManager<DeckProxy> implements IHasGam
if (!deck.getPath().isEmpty()) { //render path after name if needed if (!deck.getPath().isEmpty()) { //render path after name if needed
name += " (" + deck.getPath().substring(1) + ")"; name += " (" + deck.getPath().substring(1) + ")";
} }
g.drawText(name, font, foreColor, x, y, availableNameWidth, IMAGE_SIZE, false, HAlignment.LEFT, true); g.drawText(name, font, foreColor, x, y, availableNameWidth, IMAGE_SIZE, false, Align.left, true);
x += availableNameWidth + FList.PADDING; x += availableNameWidth + FList.PADDING;
CardFaceSymbols.drawColorSet(g, deckColor, x, y, IMAGE_SIZE); CardFaceSymbols.drawColorSet(g, deckColor, x, y, IMAGE_SIZE);
@@ -158,7 +158,7 @@ public final class DeckManager extends ItemManager<DeckProxy> implements IHasGam
sideSize = 0; //show sideboard as 0 if empty sideSize = 0; //show sideboard as 0 if empty
} }
g.drawText(deck.getFormatsString() + " (" + mainSize + " / " + sideSize + ")", font, foreColor, x, y, availableFormatWidth, lineHeight, false, HAlignment.LEFT, true); g.drawText(deck.getFormatsString() + " (" + mainSize + " / " + sideSize + ")", font, foreColor, x, y, availableFormatWidth, lineHeight, false, Align.left, true);
x += availableFormatWidth + CardRenderer.SET_BOX_MARGIN; x += availableFormatWidth + CardRenderer.SET_BOX_MARGIN;
y -= CardRenderer.SET_BOX_MARGIN; y -= CardRenderer.SET_BOX_MARGIN;

View File

@@ -18,8 +18,8 @@
package forge.itemmanager; package forge.itemmanager;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Align;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
@@ -83,7 +83,7 @@ public abstract class ItemManager<T extends InventoryItem> extends FContainer im
private final FLabel btnView = new FLabel.ButtonBuilder() private final FLabel btnView = new FLabel.ButtonBuilder()
.iconScaleFactor(0.9f).build(); //icon set later .iconScaleFactor(0.9f).build(); //icon set later
private final FLabel btnAdvancedSearchOptions = new FLabel.Builder() private final FLabel btnAdvancedSearchOptions = new FLabel.Builder()
.selectable(true).align(HAlignment.CENTER) .selectable(true).align(Align.center)
.icon(FSkinImage.SETTINGS).iconScaleFactor(0.9f) .icon(FSkinImage.SETTINGS).iconScaleFactor(0.9f)
.build(); .build();

View File

@@ -3,7 +3,7 @@ package forge.itemmanager;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import com.google.common.base.Function; import com.google.common.base.Function;
import forge.Graphics; import forge.Graphics;
@@ -67,7 +67,7 @@ public class SpellShopManager extends ItemManager<InventoryItem> {
CardRenderer.drawCardListItem(g, font, foreColor, (PaperCard)value.getKey(), value.getValue(), getItemSuffix(value), x, y, w, h, compactModeHandler.isCompactMode()); CardRenderer.drawCardListItem(g, font, foreColor, (PaperCard)value.getKey(), value.getValue(), getItemSuffix(value), x, y, w, h, compactModeHandler.isCompactMode());
} }
else { else {
g.drawText(value.getValue().toString() + " " + value.getKey().toString(), font, foreColor, x + cardArtWidth, y, w - cardArtWidth, h, false, HAlignment.LEFT, true); g.drawText(value.getValue().toString() + " " + value.getKey().toString(), font, foreColor, x + cardArtWidth, y, w - cardArtWidth, h, false, Align.left, true);
Texture image = ImageCache.getImage(value.getKey()); Texture image = ImageCache.getImage(value.getKey());
if (image != null) { if (image != null) {
float imageRatio = (float)image.getWidth() / (float)image.getHeight(); float imageRatio = (float)image.getWidth() / (float)image.getHeight();
@@ -87,7 +87,7 @@ public class SpellShopManager extends ItemManager<InventoryItem> {
g.fillRect(backColor, x - FList.PADDING, y, cardArtWidth, priceHeight); g.fillRect(backColor, x - FList.PADDING, y, cardArtWidth, priceHeight);
g.drawImage(FSkinImage.QUEST_COINSTACK, x, y, priceHeight, priceHeight); g.drawImage(FSkinImage.QUEST_COINSTACK, x, y, priceHeight, priceHeight);
float offset = priceHeight * 1.1f; float offset = priceHeight * 1.1f;
g.drawText(fnGetPrice.apply(value).toString(), font, foreColor, x + offset, y, cardArtWidth - offset - 2 * FList.PADDING, priceHeight, false, HAlignment.LEFT, true); g.drawText(fnGetPrice.apply(value).toString(), font, foreColor, x + offset, y, cardArtWidth - offset - 2 * FList.PADDING, priceHeight, false, Align.left, true);
} }
@Override @Override

View File

@@ -1,6 +1,6 @@
package forge.itemmanager.filters; package forge.itemmanager.filters;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@@ -97,7 +97,7 @@ public class AdvancedSearchFilter<T extends InventoryItem> extends ItemFilter<T>
private String toolTipText; private String toolTipText;
private FiltersLabel() { private FiltersLabel() {
super(new FLabel.Builder().align(HAlignment.LEFT).parseSymbols(true).font(ListLabelFilter.LABEL_FONT)); super(new FLabel.Builder().align(Align.left).parseSymbols(true).font(ListLabelFilter.LABEL_FONT));
} }
@Override @Override
@@ -231,12 +231,12 @@ public class AdvancedSearchFilter<T extends InventoryItem> extends ItemFilter<T>
private AdvancedSearch.Filter<T> filter; private AdvancedSearch.Filter<T> filter;
private Filter() { private Filter() {
btnNotBeforeParen = add(new FLabel.Builder().align(HAlignment.CENTER).text("NOT").selectable().build()); btnNotBeforeParen = add(new FLabel.Builder().align(Align.center).text("NOT").selectable().build());
btnOpenParen = add(new FLabel.Builder().align(HAlignment.CENTER).text("(").selectable().build()); btnOpenParen = add(new FLabel.Builder().align(Align.center).text("(").selectable().build());
btnNotAfterParen = add(new FLabel.Builder().align(HAlignment.CENTER).text("NOT").selectable().build()); btnNotAfterParen = add(new FLabel.Builder().align(Align.center).text("NOT").selectable().build());
btnFilter = add(new FLabel.ButtonBuilder().parseSymbols(true).build()); btnFilter = add(new FLabel.ButtonBuilder().parseSymbols(true).build());
btnCloseParen = add(new FLabel.Builder().align(HAlignment.CENTER).selectable().text(")").build()); btnCloseParen = add(new FLabel.Builder().align(Align.center).selectable().text(")").build());
btnAnd = add(new FLabel.Builder().align(HAlignment.CENTER).text("AND").selectable().command(new FEventHandler() { btnAnd = add(new FLabel.Builder().align(Align.center).text("AND").selectable().command(new FEventHandler() {
@Override @Override
public void handleEvent(FEvent e) { public void handleEvent(FEvent e) {
if (btnAnd.isSelected()) { if (btnAnd.isSelected()) {
@@ -248,7 +248,7 @@ public class AdvancedSearchFilter<T extends InventoryItem> extends ItemFilter<T>
} }
} }
}).build()); }).build());
btnOr = add(new FLabel.Builder().align(HAlignment.CENTER).text("OR").selectable().command(new FEventHandler() { btnOr = add(new FLabel.Builder().align(Align.center).text("OR").selectable().command(new FEventHandler() {
@Override @Override
public void handleEvent(FEvent e) { public void handleEvent(FEvent e) {
if (btnOr.isSelected()) { if (btnOr.isSelected()) {

View File

@@ -24,7 +24,7 @@ import forge.util.Utils;
import java.util.*; import java.util.*;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
public abstract class FormatFilter<T extends InventoryItem> extends ItemFilter<T> { public abstract class FormatFilter<T extends InventoryItem> extends ItemFilter<T> {
@@ -231,7 +231,7 @@ public abstract class FormatFilter<T extends InventoryItem> extends ItemFilter<T
float textHeight = h; float textHeight = h;
h *= 0.66f; h *= 0.66f;
g.drawText(value.toString(), font, foreColor, x, y, w - h - FList.PADDING, textHeight, false, HAlignment.LEFT, true); g.drawText(value.toString(), font, foreColor, x, y, w - h - FList.PADDING, textHeight, false, Align.left, true);
x += w - h; x += w - h;
y += (textHeight - h) / 2; y += (textHeight - h) / 2;

View File

@@ -1,6 +1,6 @@
package forge.itemmanager.filters; package forge.itemmanager.filters;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.utils.Align;
import forge.Forge; import forge.Forge;
import forge.Graphics; import forge.Graphics;
import forge.assets.FSkinColor; import forge.assets.FSkinColor;
@@ -132,7 +132,7 @@ public class HistoricFormatSelect extends FScreen {
float textHeight = h; float textHeight = h;
h *= 0.66f; h *= 0.66f;
g.drawText(value.toString(), font, foreColor, x, y, w - h - FList.PADDING, textHeight, false, BitmapFont.HAlignment.LEFT, true); g.drawText(value.toString(), font, foreColor, x, y, w - h - FList.PADDING, textHeight, false, Align.left, true);
x += w - h; x += w - h;
y += (textHeight - h) / 2; y += (textHeight - h) / 2;

View File

@@ -1,7 +1,6 @@
package forge.itemmanager.filters; package forge.itemmanager.filters;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import forge.assets.FSkinFont; import forge.assets.FSkinFont;
import forge.item.InventoryItem; import forge.item.InventoryItem;
import forge.itemmanager.ItemManager; import forge.itemmanager.ItemManager;
@@ -60,7 +59,7 @@ public abstract class ListLabelFilter<T extends InventoryItem> extends ItemFilte
private class ListLabel extends FLabel { private class ListLabel extends FLabel {
private ListLabel() { private ListLabel() {
super(new FLabel.Builder().align(HAlignment.LEFT).font(LABEL_FONT)); super(new FLabel.Builder().align(Align.left).font(LABEL_FONT));
} }
@Override @Override

View File

@@ -1,6 +1,6 @@
package forge.itemmanager.filters; package forge.itemmanager.filters;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
@@ -101,7 +101,7 @@ public class TextSearchFilter<T extends InventoryItem> extends ItemFilter<T> {
@Override @Override
public void draw(Graphics g) { public void draw(Graphics g) {
super.draw(g); super.draw(g);
g.drawText(ratio, renderedFont, GHOST_TEXT_COLOR, 0, 0, getWidth() - PADDING, getHeight(), false, HAlignment.RIGHT, true); g.drawText(ratio, renderedFont, GHOST_TEXT_COLOR, 0, 0, getWidth() - PADDING, getHeight(), false, Align.right, true);
} }
} }
} }

View File

@@ -3,7 +3,7 @@ package forge.itemmanager.filters;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import forge.assets.FImage; import forge.assets.FImage;
import forge.item.InventoryItem; import forge.item.InventoryItem;
@@ -70,7 +70,7 @@ public abstract class ToggleButtonsFilter<T extends InventoryItem> extends ItemF
private ToggleButton(FImage icon) { private ToggleButton(FImage icon) {
super(new FLabel.Builder() super(new FLabel.Builder()
.icon(icon).iconScaleFactor(1f) .icon(icon).iconScaleFactor(1f)
.align(HAlignment.CENTER) .align(Align.center)
.selectable(true).selected(true) .selectable(true).selected(true)
.command(new FEventHandler() { .command(new FEventHandler() {
@Override @Override

View File

@@ -1,6 +1,6 @@
package forge.itemmanager.filters; package forge.itemmanager.filters;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import forge.card.CardRules; import forge.card.CardRules;
@@ -55,7 +55,7 @@ public abstract class ValueRangeFilter<T extends InventoryItem> extends ItemFilt
lowerBound = addSpinner(widget, true); lowerBound = addSpinner(widget, true);
String text = "<= " + this.getCaption() + " <="; String text = "<= " + this.getCaption() + " <=";
label = new FLabel.Builder().text(text).align(HAlignment.CENTER).font(ListLabelFilter.LABEL_FONT).build(); label = new FLabel.Builder().text(text).align(Align.center).font(ListLabelFilter.LABEL_FONT).build();
widget.add(label); widget.add(label);
upperBound = addSpinner(widget, false); upperBound = addSpinner(widget, false);

View File

@@ -37,9 +37,9 @@ import java.util.Map.Entry;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Align;
public class ImageView<T extends InventoryItem> extends ItemView<T> { public class ImageView<T extends InventoryItem> extends ItemView<T> {
private static final float PADDING = Utils.scale(5); private static final float PADDING = Utils.scale(5);
@@ -789,7 +789,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
float x = GROUP_HEADER_GLYPH_WIDTH + PADDING + 1; float x = GROUP_HEADER_GLYPH_WIDTH + PADDING + 1;
float y = 0; float y = 0;
String caption = name + " (" + items.size() + ")"; String caption = name + " (" + items.size() + ")";
g.drawText(caption, GROUP_HEADER_FONT, GROUP_HEADER_FORE_COLOR, x, y, getWidth(), GROUP_HEADER_HEIGHT, false, HAlignment.LEFT, true); g.drawText(caption, GROUP_HEADER_FONT, GROUP_HEADER_FORE_COLOR, x, y, getWidth(), GROUP_HEADER_HEIGHT, false, Align.left, true);
x += GROUP_HEADER_FONT.getBounds(caption).width + PADDING; x += GROUP_HEADER_FONT.getBounds(caption).width + PADDING;
y += GROUP_HEADER_HEIGHT / 2; y += GROUP_HEADER_HEIGHT / 2;
g.drawLine(GROUP_HEADER_LINE_THICKNESS, GROUP_HEADER_LINE_COLOR, x, y, getWidth(), y); g.drawLine(GROUP_HEADER_LINE_THICKNESS, GROUP_HEADER_LINE_COLOR, x, y, getWidth(), y);
@@ -963,7 +963,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
} }
else { else {
g.fillRect(Color.BLACK, x, y, w, h); g.fillRect(Color.BLACK, x, y, w, h);
g.drawText(item.getName(), GROUP_HEADER_FONT, Color.WHITE, x + PADDING, y + PADDING, w - 2 * PADDING, h - 2 * PADDING, true, HAlignment.CENTER, false); g.drawText(item.getName(), GROUP_HEADER_FONT, Color.WHITE, x + PADDING, y + PADDING, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, false);
} }
} }
} }

View File

@@ -1,13 +1,12 @@
package forge.menu; package forge.menu;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
import forge.Graphics; import forge.Graphics;
import forge.assets.FSkinColor; import forge.assets.FSkinColor;
import forge.assets.FSkinFont; import forge.assets.FSkinFont;
import forge.assets.TextRenderer; import forge.assets.TextRenderer;
import forge.toolbox.FDisplayObject; import forge.toolbox.FDisplayObject;
import forge.util.TextBounds;
import forge.util.Utils; import forge.util.Utils;
public class FMagnifyView extends FDropDown { public class FMagnifyView extends FDropDown {
@@ -66,6 +65,6 @@ public class FMagnifyView extends FDropDown {
public void drawBackground(Graphics g) { public void drawBackground(Graphics g) {
super.drawBackground(g); super.drawBackground(g);
g.fillRect(backColor, 0, 0, getWidth(), getHeight()); g.fillRect(backColor, 0, 0, getWidth(), getHeight());
renderer.drawText(g, text, font, foreColor, PADDING - getScrollLeft(), PADDING - getScrollTop(), getScrollWidth() - 2 * PADDING, getScrollHeight() - 2 * PADDING, 0, getHeight(), true, HAlignment.LEFT, false); renderer.drawText(g, text, font, foreColor, PADDING - getScrollLeft(), PADDING - getScrollTop(), getScrollWidth() - 2 * PADDING, getScrollHeight() - 2 * PADDING, 0, getHeight(), true, Align.left, false);
} }
} }

View File

@@ -1,6 +1,6 @@
package forge.menu; package forge.menu;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.Timer;
import com.badlogic.gdx.utils.Timer.Task; import com.badlogic.gdx.utils.Timer.Task;
@@ -135,10 +135,10 @@ public class FMenuItem extends FDisplayObject implements IButton {
} }
if (textRenderer == null) { if (textRenderer == null) {
g.drawText(text, FONT, FORE_COLOR, x, 0, w - x - GAP_X, h, false, HAlignment.LEFT, true); g.drawText(text, FONT, FORE_COLOR, x, 0, w - x - GAP_X, h, false, Align.left, true);
} }
else { else {
textRenderer.drawText(g, text, FONT, FORE_COLOR, x, 0, w - x - GAP_X, h, 0, h, false, HAlignment.LEFT, true); textRenderer.drawText(g, text, FONT, FORE_COLOR, x, 0, w - x - GAP_X, h, 0, h, false, Align.left, true);
} }
//draw separator line //draw separator line

View File

@@ -1,6 +1,6 @@
package forge.menu; package forge.menu;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import forge.Graphics; import forge.Graphics;
import forge.assets.FSkinColor; import forge.assets.FSkinColor;
@@ -99,6 +99,6 @@ public class FMenuTab extends FDisplayObject {
y = PADDING; y = PADDING;
w = getWidth() - 2 * PADDING; w = getWidth() - 2 * PADDING;
h = getHeight() - 2 * PADDING; h = getHeight() - 2 * PADDING;
g.drawText(text, FONT, foreColor, x, y, w, h, false, HAlignment.CENTER, true); g.drawText(text, FONT, foreColor, x, y, w, h, false, Align.center, true);
} }
} }

View File

@@ -1,8 +1,6 @@
package forge.menu; package forge.menu;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
import forge.Forge; import forge.Forge;
import forge.Graphics; import forge.Graphics;
import forge.assets.FSkinColor; import forge.assets.FSkinColor;
@@ -10,6 +8,7 @@ import forge.assets.FSkinFont;
import forge.assets.FSkinColor.Colors; import forge.assets.FSkinColor.Colors;
import forge.screens.FScreen; import forge.screens.FScreen;
import forge.toolbox.FDisplayObject; import forge.toolbox.FDisplayObject;
import forge.util.TextBounds;
import forge.util.Utils; import forge.util.Utils;
public class FTooltip extends FDropDown { public class FTooltip extends FDropDown {
@@ -68,6 +67,6 @@ public class FTooltip extends FDropDown {
@Override @Override
public void drawBackground(Graphics g) { public void drawBackground(Graphics g) {
super.drawBackground(g); super.drawBackground(g);
g.drawText(text, FONT, FORE_COLOR, PADDING - getScrollLeft(), PADDING - getScrollTop(), getScrollWidth() - 2 * PADDING, getScrollHeight() - 2 * PADDING, true, HAlignment.LEFT, false); g.drawText(text, FONT, FORE_COLOR, PADDING - getScrollLeft(), PADDING - getScrollTop(), getScrollWidth() - 2 * PADDING, getScrollHeight() - 2 * PADDING, true, Align.left, false);
} }
} }

View File

@@ -3,8 +3,8 @@ package forge.screens;
import java.util.List; import java.util.List;
import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Align;
import forge.Forge; import forge.Forge;
import forge.Graphics; import forge.Graphics;
@@ -197,13 +197,13 @@ public abstract class FScreen extends FContainer {
protected final FLabel btnBack, lblCaption; protected final FLabel btnBack, lblCaption;
public DefaultHeader(String headerCaption) { public DefaultHeader(String headerCaption) {
btnBack = add(new FLabel.Builder().icon(new BackIcon(HEIGHT, HEIGHT)).pressedColor(BTN_PRESSED_COLOR).align(HAlignment.CENTER).command(new FEventHandler() { btnBack = add(new FLabel.Builder().icon(new BackIcon(HEIGHT, HEIGHT)).pressedColor(BTN_PRESSED_COLOR).align(Align.center).command(new FEventHandler() {
@Override @Override
public void handleEvent(FEvent e) { public void handleEvent(FEvent e) {
Forge.back(); Forge.back();
} }
}).build()); }).build());
lblCaption = add(new FLabel.Builder().text(headerCaption).font(FONT).align(HAlignment.CENTER).build()); lblCaption = add(new FLabel.Builder().text(headerCaption).font(FONT).align(Align.center).build());
} }
@Override @Override
@@ -245,7 +245,7 @@ public abstract class FScreen extends FContainer {
public MenuHeader(String headerCaption, FPopupMenu menu0) { public MenuHeader(String headerCaption, FPopupMenu menu0) {
super(headerCaption); super(headerCaption);
menu = menu0; menu = menu0;
btnMenu = add(new FLabel.Builder().icon(new MenuIcon(HEIGHT, HEIGHT)).pressedColor(BTN_PRESSED_COLOR).align(HAlignment.CENTER).command(new FEventHandler() { btnMenu = add(new FLabel.Builder().icon(new MenuIcon(HEIGHT, HEIGHT)).pressedColor(BTN_PRESSED_COLOR).align(Align.center).command(new FEventHandler() {
@Override @Override
public void handleEvent(FEvent e) { public void handleEvent(FEvent e) {
menu.show(btnMenu, 0, HEIGHT); menu.show(btnMenu, 0, HEIGHT);

View File

@@ -1,6 +1,6 @@
package forge.screens; package forge.screens;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import forge.FThreads; import forge.FThreads;
import forge.Forge; import forge.Forge;
@@ -95,6 +95,6 @@ public class LoadingOverlay extends FOverlay {
y += padding; y += padding;
g.drawImage(FSkinImage.LOGO, (getWidth() - logoSize) / 2f, y, logoSize, logoSize); g.drawImage(FSkinImage.LOGO, (getWidth() - logoSize) / 2f, y, logoSize, logoSize);
y += logoSize + padding; y += logoSize + padding;
g.drawText(caption, FONT, FORE_COLOR, x, y, panelWidth, getHeight(), false, HAlignment.CENTER, false); g.drawText(caption, FONT, FORE_COLOR, x, y, panelWidth, getHeight(), false, Align.center, false);
} }
} }

View File

@@ -2,7 +2,7 @@ package forge.screens;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import forge.Forge; import forge.Forge;
import forge.Graphics; import forge.Graphics;
@@ -94,7 +94,7 @@ public class SplashScreen extends FContainer {
String disclaimer = "Forge is not affiliated in any way with Wizards of the Coast.\n" String disclaimer = "Forge is not affiliated in any way with Wizards of the Coast.\n"
+ "Forge is open source software, released under the GNU Public License."; + "Forge is open source software, released under the GNU Public License.";
g.drawText(disclaimer, disclaimerFont, FProgressBar.SEL_FORE_COLOR, g.drawText(disclaimer, disclaimerFont, FProgressBar.SEL_FORE_COLOR,
x, y, w, disclaimerHeight, true, HAlignment.CENTER, true); x, y, w, disclaimerHeight, true, Align.center, true);
float padding = 20f / 450f * w; float padding = 20f / 450f * w;
float pbHeight = 57f / 450f * h; float pbHeight = 57f / 450f * h;
@@ -103,6 +103,6 @@ public class SplashScreen extends FContainer {
g.draw(progressBar); g.draw(progressBar);
String version = "v. " + Forge.CURRENT_VERSION + " (Alpha)"; String version = "v. " + Forge.CURRENT_VERSION + " (Alpha)";
g.drawText(version, disclaimerFont, FProgressBar.SEL_FORE_COLOR, x, getHeight() - disclaimerHeight, w, disclaimerHeight, false, HAlignment.CENTER, true); g.drawText(version, disclaimerFont, FProgressBar.SEL_FORE_COLOR, x, getHeight() - disclaimerHeight, w, disclaimerHeight, false, Align.center, true);
} }
} }

View File

@@ -1,6 +1,6 @@
package forge.screens; package forge.screens;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import forge.Forge; import forge.Forge;
import forge.Graphics; import forge.Graphics;
@@ -183,7 +183,7 @@ public class TabPageScreen<T extends TabPageScreen<T>> extends FScreen {
public TabHeader(TabPage<T>[] tabPages0, boolean showBackButton) { public TabHeader(TabPage<T>[] tabPages0, boolean showBackButton) {
tabPages = tabPages0; tabPages = tabPages0;
if (showBackButton) { if (showBackButton) {
btnBack = add(new FLabel.Builder().icon(new BackIcon(BACK_BUTTON_WIDTH, BACK_BUTTON_WIDTH)).pressedColor(BTN_PRESSED_COLOR).align(HAlignment.CENTER).command(new FEventHandler() { btnBack = add(new FLabel.Builder().icon(new BackIcon(BACK_BUTTON_WIDTH, BACK_BUTTON_WIDTH)).pressedColor(BTN_PRESSED_COLOR).align(Align.center).command(new FEventHandler() {
@Override @Override
public void handleEvent(FEvent e) { public void handleEvent(FEvent e) {
Forge.back(); Forge.back();
@@ -365,7 +365,7 @@ public class TabPageScreen<T extends TabPageScreen<T>> extends FScreen {
if (parentScreen.showCompactTabs() && !isLandscapeMode) { if (parentScreen.showCompactTabs() && !isLandscapeMode) {
h -= 2 * padding; h -= 2 * padding;
if (icon == null) { if (icon == null) {
g.drawText(caption, TAB_FONT, TAB_FORE_COLOR, padding, padding, w, h, false, HAlignment.CENTER, true); g.drawText(caption, TAB_FONT, TAB_FORE_COLOR, padding, padding, w, h, false, Align.center, true);
} }
else { else {
//center combination of icon and text //center combination of icon and text
@@ -393,13 +393,13 @@ public class TabPageScreen<T extends TabPageScreen<T>> extends FScreen {
x += iconOffset; x += iconOffset;
w -= iconOffset; w -= iconOffset;
g.startClip(x, y, w, h); g.startClip(x, y, w, h);
g.drawText(caption, font, TAB_FORE_COLOR, x, y, w, h, false, HAlignment.LEFT, true); g.drawText(caption, font, TAB_FORE_COLOR, x, y, w, h, false, Align.left, true);
g.endClip(); g.endClip();
} }
} }
else { else {
float y = h - padding - TAB_FONT.getCapHeight(); float y = h - padding - TAB_FONT.getCapHeight();
g.drawText(caption, TAB_FONT, TAB_FORE_COLOR, padding, y - padding, w, h - y + padding, false, HAlignment.CENTER, true); g.drawText(caption, TAB_FONT, TAB_FORE_COLOR, padding, y - padding, w, h - y + padding, false, Align.center, true);
if (icon != null) { if (icon != null) {
float iconHeight = y - 2 * padding; float iconHeight = y - 2 * padding;

View File

@@ -1,8 +1,8 @@
package forge.screens.achievements; package forge.screens.achievements;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Align;
import forge.Forge; import forge.Forge;
import forge.Graphics; import forge.Graphics;
@@ -54,7 +54,7 @@ public class AchievementsScreen extends FScreen {
AchievementCollection.buildComboBox(cbCollections); AchievementCollection.buildComboBox(cbCollections);
cbCollections.setSelectedIndex(0); cbCollections.setSelectedIndex(0);
cbCollections.setAlignment(HAlignment.CENTER); cbCollections.setAlignment(Align.center);
cbCollections.setChangedHandler(new FEventHandler() { cbCollections.setChangedHandler(new FEventHandler() {
@Override @Override
public void handleEvent(FEvent e) { public void handleEvent(FEvent e) {
@@ -271,11 +271,11 @@ public class AchievementsScreen extends FScreen {
if (plateY + plateHeight > 0) { if (plateY + plateHeight > 0) {
g.drawImage((FImage)achievement.getImage(), x + trophyOffset, y, trophyImageWidth, trophyHeight); g.drawImage((FImage)achievement.getImage(), x + trophyOffset, y, trophyImageWidth, trophyHeight);
g.drawImage(FSkinImage.TROPHY_PLATE, x + plateOffset, plateY, plateWidth, plateHeight); g.drawImage(FSkinImage.TROPHY_PLATE, x + plateOffset, plateY, plateWidth, plateHeight);
g.drawText(achievement.getDisplayName(), titleFont, FORE_COLOR, x + plateOffset + plateWidth * 0.075f, plateY + plateHeight * 0.05f, plateWidth * 0.85f, titleHeight, false, HAlignment.CENTER, true); g.drawText(achievement.getDisplayName(), titleFont, FORE_COLOR, x + plateOffset + plateWidth * 0.075f, plateY + plateHeight * 0.05f, plateWidth * 0.85f, titleHeight, false, Align.center, true);
String subTitle = achievement.getSubTitle(false); String subTitle = achievement.getSubTitle(false);
if (subTitle != null) { if (subTitle != null) {
g.drawText(subTitle, subTitleFont, FORE_COLOR, x + plateOffset + plateWidth * 0.075f, plateY + plateHeight * 0.6f, plateWidth * 0.85f, subTitleHeight, false, HAlignment.CENTER, true); g.drawText(subTitle, subTitleFont, FORE_COLOR, x + plateOffset + plateWidth * 0.075f, plateY + plateHeight * 0.6f, plateWidth * 0.85f, subTitleHeight, false, Align.center, true);
} }
if (achievement == selectedAchievement) { if (achievement == selectedAchievement) {
@@ -338,40 +338,40 @@ public class AchievementsScreen extends FScreen {
y += PADDING; y += PADDING;
w -= 2 * PADDING; w -= 2 * PADDING;
h -= 2 * PADDING; h -= 2 * PADDING;
g.drawText(selectedAchievement.getDisplayName(), NAME_FONT, TEXT_COLOR, x, y, w, h, false, HAlignment.LEFT, false); g.drawText(selectedAchievement.getDisplayName(), NAME_FONT, TEXT_COLOR, x, y, w, h, false, Align.left, false);
y += NAME_FONT.getLineHeight(); y += NAME_FONT.getLineHeight();
if (subTitle != null) { if (subTitle != null) {
g.drawText(subTitle, DESC_FONT, TEXT_COLOR, x, y, w, h, false, HAlignment.LEFT, false); g.drawText(subTitle, DESC_FONT, TEXT_COLOR, x, y, w, h, false, Align.left, false);
y += DESC_FONT.getLineHeight(); y += DESC_FONT.getLineHeight();
} }
y += PADDING; y += PADDING;
if (sharedDesc != null) { if (sharedDesc != null) {
g.drawText(selectedAchievement.isSpecial() ? sharedDesc : sharedDesc + "...", DESC_FONT, TEXT_COLOR, g.drawText(selectedAchievement.isSpecial() ? sharedDesc : sharedDesc + "...", DESC_FONT, TEXT_COLOR,
x, y, w, h, false, HAlignment.LEFT, false); x, y, w, h, false, Align.left, false);
y += DESC_FONT.getLineHeight(); y += DESC_FONT.getLineHeight();
} }
if (mythicDesc != null) { if (mythicDesc != null) {
g.drawText(selectedAchievement.isSpecial() ? mythicDesc : "(Mythic) " + mythicDesc, DESC_FONT, //handle flavor text here too g.drawText(selectedAchievement.isSpecial() ? mythicDesc : "(Mythic) " + mythicDesc, DESC_FONT, //handle flavor text here too
selectedAchievement.earnedMythic() ? TEXT_COLOR : NOT_EARNED_COLOR, selectedAchievement.earnedMythic() ? TEXT_COLOR : NOT_EARNED_COLOR,
x, y, w, h, false, HAlignment.LEFT, false); x, y, w, h, false, Align.left, false);
y += DESC_FONT.getLineHeight(); y += DESC_FONT.getLineHeight();
} }
if (rareDesc != null) { if (rareDesc != null) {
g.drawText("(Rare) " + rareDesc, DESC_FONT, g.drawText("(Rare) " + rareDesc, DESC_FONT,
selectedAchievement.earnedRare() ? TEXT_COLOR : NOT_EARNED_COLOR, selectedAchievement.earnedRare() ? TEXT_COLOR : NOT_EARNED_COLOR,
x, y, w, h, false, HAlignment.LEFT, false); x, y, w, h, false, Align.left, false);
y += DESC_FONT.getLineHeight(); y += DESC_FONT.getLineHeight();
} }
if (uncommonDesc != null) { if (uncommonDesc != null) {
g.drawText("(Uncommon) " + uncommonDesc, DESC_FONT, g.drawText("(Uncommon) " + uncommonDesc, DESC_FONT,
selectedAchievement.earnedUncommon() ? TEXT_COLOR : NOT_EARNED_COLOR, selectedAchievement.earnedUncommon() ? TEXT_COLOR : NOT_EARNED_COLOR,
x, y, w, h, false, HAlignment.LEFT, false); x, y, w, h, false, Align.left, false);
y += DESC_FONT.getLineHeight(); y += DESC_FONT.getLineHeight();
} }
if (commonDesc != null) { if (commonDesc != null) {
g.drawText("(Common) " + commonDesc, DESC_FONT, g.drawText("(Common) " + commonDesc, DESC_FONT,
selectedAchievement.earnedCommon() ? TEXT_COLOR : NOT_EARNED_COLOR, selectedAchievement.earnedCommon() ? TEXT_COLOR : NOT_EARNED_COLOR,
x, y, w, h, false, HAlignment.LEFT, false); x, y, w, h, false, Align.left, false);
} }
} }
} }

View File

@@ -19,7 +19,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
public class AvatarSelector extends FScreen { public class AvatarSelector extends FScreen {
public static int getRandomAvatar(List<Integer> usedAvatars) { public static int getRandomAvatar(List<Integer> usedAvatars) {
@@ -87,7 +87,7 @@ public class AvatarSelector extends FScreen {
} }
private void addAvatarLabel(final FImage img, final int index) { private void addAvatarLabel(final FImage img, final int index) {
final FLabel lbl = new FLabel.Builder().icon(img).iconScaleFactor(0.95f).align(HAlignment.CENTER) final FLabel lbl = new FLabel.Builder().icon(img).iconScaleFactor(0.95f).align(Align.center)
.iconInBackground(true).selectable(true).selected(currentIndex == index) .iconInBackground(true).selectable(true).selected(currentIndex == index)
.build(); .build();

View File

@@ -6,7 +6,7 @@ import forge.deck.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import forge.FThreads; import forge.FThreads;
@@ -413,10 +413,10 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
float totalHeight = h; float totalHeight = h;
h = font.getMultiLineBounds(text).height + SettingsScreen.SETTING_PADDING; h = font.getMultiLineBounds(text).height + SettingsScreen.SETTING_PADDING;
g.drawText(text, font, foreColor, x, y, w, h, false, HAlignment.LEFT, false); g.drawText(text, font, foreColor, x, y, w, h, false, Align.left, false);
value.draw(g, font, foreColor, x, y, w, h); value.draw(g, font, foreColor, x, y, w, h);
h += SettingsScreen.SETTING_PADDING; h += SettingsScreen.SETTING_PADDING;
g.drawText(value.gameType.getDescription(), SettingsScreen.DESC_FONT, SettingsScreen.DESC_COLOR, x, y + h, w, totalHeight - h + SettingsScreen.getInsets(w), true, HAlignment.LEFT, false); g.drawText(value.gameType.getDescription(), SettingsScreen.DESC_FONT, SettingsScreen.DESC_COLOR, x, y + h, w, totalHeight - h + SettingsScreen.getInsets(w), true, Align.left, false);
} }
} }
} }

View File

@@ -5,8 +5,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@@ -835,7 +834,7 @@ public class PlayerPanel extends FContainer {
/** Adds a pre-styled FLabel component with the specified title. */ /** Adds a pre-styled FLabel component with the specified title. */
private FLabel newLabel(String title) { private FLabel newLabel(String title) {
return new FLabel.Builder().text(title).font(LABEL_FONT).align(HAlignment.RIGHT).build(); return new FLabel.Builder().text(title).font(LABEL_FONT).align(Align.right).build();
} }
private static final ImmutableList<String> genderOptions = ImmutableList.of("Male", "Female", "Any"); private static final ImmutableList<String> genderOptions = ImmutableList.of("Male", "Female", "Any");

View File

@@ -6,8 +6,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.FThreads; import forge.FThreads;
import forge.Graphics; import forge.Graphics;
@@ -253,8 +252,8 @@ public class LoadGauntletScreen extends LaunchScreen {
String progress = completed + " / " + opponents + " (" + percent.format((double)completed / (double)opponents) + ")"; String progress = completed + " / " + opponents + " (" + percent.format((double)completed / (double)opponents) + ")";
float progressWidth = font.getBounds(progress).width + SettingsScreen.SETTING_PADDING; float progressWidth = font.getBounds(progress).width + SettingsScreen.SETTING_PADDING;
g.drawText(name, font, foreColor, x, y, w - progressWidth, h, false, HAlignment.LEFT, false); g.drawText(name, font, foreColor, x, y, w - progressWidth, h, false, Align.left, false);
g.drawText(progress, font, foreColor, x, y, w, h, false, HAlignment.RIGHT, false); g.drawText(progress, font, foreColor, x, y, w, h, false, Align.right, false);
h += SettingsScreen.SETTING_PADDING; h += SettingsScreen.SETTING_PADDING;
y += h; y += h;
@@ -263,8 +262,8 @@ public class LoadGauntletScreen extends LaunchScreen {
String timestamp = value.getTimestamp(); String timestamp = value.getTimestamp();
font = FSkinFont.get(12); font = FSkinFont.get(12);
float timestampWidth = font.getBounds(timestamp).width + SettingsScreen.SETTING_PADDING; float timestampWidth = font.getBounds(timestamp).width + SettingsScreen.SETTING_PADDING;
g.drawText(value.getUserDeck() == null ? "(none)" : value.getUserDeck().getName(), font, SettingsScreen.DESC_COLOR, x, y, w - timestampWidth, h, false, HAlignment.LEFT, false); g.drawText(value.getUserDeck() == null ? "(none)" : value.getUserDeck().getName(), font, SettingsScreen.DESC_COLOR, x, y, w - timestampWidth, h, false, Align.left, false);
g.drawText(timestamp, font, SettingsScreen.DESC_COLOR, x + w - timestampWidth + SettingsScreen.SETTING_PADDING, y, w, h, false, HAlignment.LEFT, false); g.drawText(timestamp, font, SettingsScreen.DESC_COLOR, x + w - timestampWidth + SettingsScreen.SETTING_PADDING, y, w, h, false, Align.left, false);
} }
}); });
} }

View File

@@ -3,7 +3,7 @@ package forge.screens.home;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import forge.Forge; import forge.Forge;
import forge.Graphics; import forge.Graphics;
import forge.assets.FSkinColor; import forge.assets.FSkinColor;
@@ -247,7 +247,7 @@ public class HomeScreen extends FScreen {
public void draw(Graphics g) { public void draw(Graphics g) {
if (Forge.isLandscapeMode()) { if (Forge.isLandscapeMode()) {
//draw text only for Landscape mode //draw text only for Landscape mode
g.drawText(getText(), getFont(), getForeColor(), 0, 0, getWidth(), getHeight(), false, HAlignment.LEFT, true); g.drawText(getText(), getFont(), getForeColor(), 0, 0, getWidth(), getHeight(), false, Align.left, true);
} }
else { //draw buttons normally for portrait mode else { //draw buttons normally for portrait mode
super.draw(g); super.draw(g);

View File

@@ -1,6 +1,6 @@
package forge.screens.limited; package forge.screens.limited;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import forge.FThreads; import forge.FThreads;
import forge.Forge; import forge.Forge;
@@ -39,7 +39,7 @@ public class LoadDraftScreen extends LaunchScreen {
private final FLabel lblTip = add(new FLabel.Builder() private final FLabel lblTip = add(new FLabel.Builder()
.text("Double-tap to edit deck (Long-press to view)") .text("Double-tap to edit deck (Long-press to view)")
.textColor(FLabel.INLINE_LABEL_COLOR) .textColor(FLabel.INLINE_LABEL_COLOR)
.align(HAlignment.CENTER).font(FSkinFont.get(12)).build()); .align(Align.center).font(FSkinFont.get(12)).build());
private final FSkinFont GAME_MODE_FONT= FSkinFont.get(12); private final FSkinFont GAME_MODE_FONT= FSkinFont.get(12);
private final FLabel lblMode = add(new FLabel.Builder().text("Mode:").font(GAME_MODE_FONT).build()); private final FLabel lblMode = add(new FLabel.Builder().text("Mode:").font(GAME_MODE_FONT).build());

View File

@@ -1,6 +1,6 @@
package forge.screens.limited; package forge.screens.limited;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.utils.Align;
import forge.FThreads; import forge.FThreads;
import forge.Forge; import forge.Forge;
@@ -39,7 +39,7 @@ public class LoadSealedScreen extends LaunchScreen {
private final FLabel lblTip = add(new FLabel.Builder() private final FLabel lblTip = add(new FLabel.Builder()
.text("Double-tap to edit deck (Long-press to view)") .text("Double-tap to edit deck (Long-press to view)")
.textColor(FLabel.INLINE_LABEL_COLOR) .textColor(FLabel.INLINE_LABEL_COLOR)
.align(HAlignment.CENTER).font(FSkinFont.get(12)).build()); .align(Align.center).font(FSkinFont.get(12)).build());
private final FSkinFont GAME_MODE_FONT= FSkinFont.get(12); private final FSkinFont GAME_MODE_FONT= FSkinFont.get(12);
private final FLabel lblMode = add(new FLabel.Builder().text("Mode:").font(GAME_MODE_FONT).build()); private final FLabel lblMode = add(new FLabel.Builder().text("Mode:").font(GAME_MODE_FONT).build());

View File

@@ -3,6 +3,7 @@ package forge.screens.match;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import forge.properties.ForgeConstants;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.Input.Keys;
@@ -507,8 +508,8 @@ public class MatchScreen extends FScreen {
float w = getWidth() - x; float w = getWidth() - x;
if(FModel.getPreferences().getPrefBoolean(FPref.UI_DYNAMIC_PLANECHASE_BG) if(FModel.getPreferences().getPrefBoolean(FPref.UI_DYNAMIC_PLANECHASE_BG)
&& hasActivePlane()) && hasActivePlane()) //TODO: scale BG to correct aspect ratio/crop center
setPlanarBG(g, getPlaneName(), x, y, w, midField); setPlanarBG(g, getPlaneName(), x, y, w, ForgeConstants.isGdxPortLandscape ? getHeight() : midField);
else else
g.drawImage(FSkinTexture.BG_MATCH, x, y, w, midField + bottomPlayerPanel.getField().getHeight() - y); g.drawImage(FSkinTexture.BG_MATCH, x, y, w, midField + bottomPlayerPanel.getField().getHeight() - y);
} }
@@ -880,7 +881,7 @@ public class MatchScreen extends FScreen {
case "Mirrored Depths": case "Mirrored Depths":
g.drawImage(FSkinTexture.BG_PLANE77, x, y, w, midField + bottomPlayerPanel.getField().getHeight() - y); g.drawImage(FSkinTexture.BG_PLANE77, x, y, w, midField + bottomPlayerPanel.getField().getHeight() - y);
break; break;
case "Talon_Gates": case "Talon Gates":
g.drawImage(FSkinTexture.BG_PLANE78, x, y, w, midField + bottomPlayerPanel.getField().getHeight() - y); g.drawImage(FSkinTexture.BG_PLANE78, x, y, w, midField + bottomPlayerPanel.getField().getHeight() - y);
break; break;

Some files were not shown because too many files have changed in this diff Show More