Commit 6e2ac756 authored by Michael Kamensky's avatar Michael Kamensky

Merge branch 'newBranch' into 'master'

Rounded Border Highlight

See merge request core-developers/forge!2240
parents c52960ea f06994e7
......@@ -63,6 +63,9 @@ public class Forge implements ApplicationListener {
public static float heigtModifier = 0.0f;
private static boolean isloadingaMatch = false;
public static boolean showFPS = false;
public static boolean enableUIMask = false;
public static boolean enablePreloadExtendedArt = false;
public static String locale = "en-US";
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0) {
if (GuiBase.getInterface() == null) {
......@@ -105,8 +108,10 @@ public class Forge implements ApplicationListener {
FSkin.loadLight(skinName, splashScreen);
textureFiltering = prefs.getPrefBoolean(FPref.UI_LIBGDX_TEXTURE_FILTERING);
showFPS = prefs.getPrefBoolean(FPref.UI_SHOW_FPS);
enableUIMask = prefs.getPrefBoolean(FPref.UI_ENABLE_BORDER_MASKING);
enablePreloadExtendedArt = prefs.getPrefBoolean(FPref.UI_ENABLE_PRELOAD_EXTENDED_ART);
locale = prefs.getPref(FPref.UI_LANGUAGE);
final Localizer localizer = Localizer.getInstance();
......@@ -121,15 +126,15 @@ public class Forge implements ApplicationListener {
FModel.initialize(splashScreen.getProgressBar(), null);
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblLoadingFonts"));
FSkinFont.preloadAll(prefs.getPref(FPref.UI_LANGUAGE));
FSkinFont.preloadAll(locale);
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblLoadingCardTranslations"));
CardTranslation.preloadTranslation(prefs.getPref(FPref.UI_LANGUAGE));
CardTranslation.preloadTranslation(locale);
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblFinishingStartup"));
//add reminder to preload
if (prefs.getPrefBoolean(FPref.UI_ENABLE_PRELOAD_EXTENDED_ART))
if (enablePreloadExtendedArt)
splashScreen.getProgressBar().setDescription("Preload Extended Art...");
Gdx.app.postRunnable(new Runnable() {
@Override
......@@ -145,7 +150,7 @@ public class Forge implements ApplicationListener {
}
private void preloadExtendedArt() {
if (!FModel.getPreferences().getPrefBoolean(FPref.UI_ENABLE_PRELOAD_EXTENDED_ART))
if (!enablePreloadExtendedArt)
return;
List<String> keys = new ArrayList<>();
File[] directories = new File(ForgeConstants.CACHE_CARD_PICS_DIR).listFiles(new FileFilter() {
......
......@@ -16,6 +16,7 @@ import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFont
import com.badlogic.gdx.graphics.glutils.PixmapTextureData;
import com.badlogic.gdx.utils.Array;
import forge.FThreads;
import forge.Forge;
import forge.properties.ForgeConstants;
import forge.util.FileUtil;
import forge.util.TextBounds;
......@@ -360,7 +361,8 @@ public class FSkinFont {
//generate from zh-CN.properties,and cardnames-zh-CN.txt
//forge generate 3000+ characters cache need Take some time(MIN_FONT_SIZE - MAX_FONT_SIZE all size)
//maybe using libgdx-hiero generate font cache is better
chars += "●、。「」『』一丁七万三上下不与丑专且世丘业丛东丝两严丧个中"
if (Forge.locale.equals("zh-CN"))
chars += "●、。「」『』一丁七万三上下不与丑专且世丘业丛东丝两严丧个中"
+ "丰临丸丹为主丽举乃久么义之乌乍乐乔乖乘乙九也乡书乱乳乾了予争"
+ "事二于云互五井亘亚些亡交亥亦产享京亮亲亵人亿什仁仅仆仇今介仍"
+ "从仑仓仕他仗付仙代令以仪们仰仲件价任份仿伊伍伏伐休众优伙会伟"
......
......@@ -8,12 +8,14 @@ import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.TextureData;
import com.badlogic.gdx.graphics.glutils.PixmapTextureData;
import forge.FThreads;
import org.cache2k.integration.CacheLoader;
import forge.Forge;
import forge.ImageKeys;
final class ImageLoader extends CacheLoader<String, Texture> {
Texture n;
@Override
public Texture load(String key) {
boolean extendedArt = false;
......@@ -44,23 +46,28 @@ final class ImageLoader extends CacheLoader<String, Texture> {
public Texture generateTexture(FileHandle fh, Texture t, boolean textureFilter) {
if (t == null || fh == null)
return t;
Pixmap pImage = new Pixmap(fh);
int w = pImage.getWidth();
int h = pImage.getHeight();
int radius = (h - w) / 8;
Pixmap pMask = createRoundedRectangle(w, h, radius, Color.RED);
drawPixelstoMask(pImage, pMask);
TextureData textureData = new PixmapTextureData(
pMask, //pixmap to use
Pixmap.Format.RGBA8888,
textureFilter, //use mipmaps
false, true);
t = new Texture(textureData);
if (textureFilter)
t.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
pImage.dispose();
pMask.dispose();
return t;
FThreads.invokeInEdtNowOrLater(new Runnable() {
@Override
public void run() {
Pixmap pImage = new Pixmap(fh);
int w = pImage.getWidth();
int h = pImage.getHeight();
int radius = (h - w) / 8;
Pixmap pMask = createRoundedRectangle(w, h, radius, Color.RED);
drawPixelstoMask(pImage, pMask);
TextureData textureData = new PixmapTextureData(
pMask, //pixmap to use
Pixmap.Format.RGBA8888,
textureFilter, //use mipmaps
false, true);
n = new Texture(textureData);
if (textureFilter)
n.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
pImage.dispose();
pMask.dispose();
}
});
return n;
}
public Pixmap createRoundedRectangle(int width, int height, int cornerRadius, Color color) {
Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888);
......
......@@ -2,14 +2,13 @@ package forge.card;
import com.badlogic.gdx.graphics.Texture;
import forge.Forge;
import forge.Graphics;
import forge.assets.FImage;
import forge.assets.ImageCache;
import forge.card.CardRenderer.CardStackPosition;
import forge.game.card.CardView;
import forge.item.PaperCard;
import forge.model.FModel;
import forge.properties.ForgePreferences;
import forge.toolbox.FCardPanel;
public class CardImage implements FImage {
......@@ -19,9 +18,6 @@ public class CardImage implements FImage {
public CardImage(PaperCard card0) {
card = card0;
}
private static boolean isPreferenceEnabled(ForgePreferences.FPref preferenceName) {
return FModel.getPreferences().getPrefBoolean(preferenceName);
}
@Override
public float getWidth() {
......@@ -38,11 +34,10 @@ public class CardImage implements FImage {
@Override
public void draw(Graphics g, float x, float y, float w, float h) {
boolean mask = isPreferenceEnabled(ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING);
if (image == null) { //attempt to retrieve card image if needed
image = ImageCache.getImage(card);
if (image == null) {
if (mask) //render this if mask is still loading
if (Forge.enableUIMask) //render this if mask is still loading
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(card), false, x, y, w, h, CardStackPosition.Top);
return; //can't draw anything if can't be loaded yet
......@@ -53,7 +48,7 @@ public class CardImage implements FImage {
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(card), false, x, y, w, h, CardStackPosition.Top);
}
else {
if (mask) {
if (Forge.enableUIMask) {
if (ImageCache.isExtendedArt(card))
g.drawImage(image, x, y, w, h);
else {
......
......@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.utils.Align;
import com.google.common.collect.ImmutableList;
import forge.Forge;
import forge.Graphics;
import forge.assets.FBufferedImage;
import forge.assets.FSkinColor;
......@@ -325,7 +326,6 @@ public class CardImageRenderer {
}
public static void drawZoom(Graphics g, CardView card, GameView gameView, boolean altState, float x, float y, float w, float h, float dispW, float dispH, boolean isCurrentCard) {
boolean mask = isPreferenceEnabled(ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING);
final Texture image = ImageCache.getImage(card.getState(altState).getImageKey(MatchController.instance.getLocalPlayers()), true);
if (image == null) { //draw details if can't draw zoom
drawDetails(g, card, gameView, altState, x, y, w, h);
......@@ -354,7 +354,7 @@ public class CardImageRenderer {
boolean rotateSplit = FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_SPLIT_CARDS);
boolean rotatePlane = FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_PLANE_OR_PHENOMENON);
if (rotatePlane && (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane())) {
if (mask){
if (Forge.enableUIMask){
if (ImageCache.isExtendedArt(card))
g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90);
else {
......@@ -370,7 +370,7 @@ public class CardImageRenderer {
g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90);
} else if (rotateSplit && isCurrentCard && card.isSplitCard() && canLook) {
boolean isAftermath = card.getText().contains("Aftermath") || card.getAlternateState().getOracleText().contains("Aftermath");
if (mask) {
if (Forge.enableUIMask) {
if (ImageCache.isExtendedArt(card))
g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90);
else {
......@@ -386,7 +386,7 @@ public class CardImageRenderer {
g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90);
}
else {
if (mask) {
if (Forge.enableUIMask) {
if (ImageCache.isExtendedArt(card))
g.drawImage(image, x, y, w, h);
else {
......@@ -560,8 +560,4 @@ public class CardImageRenderer {
g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h);
g.drawText(ptText, PT_FONT, Color.BLACK, x, y, w, h, false, Align.center, true);
}
private static boolean isPreferenceEnabled(ForgePreferences.FPref preferenceName) {
return FModel.getPreferences().getPrefBoolean(preferenceName);
}
}
......@@ -16,6 +16,7 @@ import com.badlogic.gdx.graphics.glutils.PixmapTextureData;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Array;
import forge.CachedCardImage;
import forge.Forge;
import forge.FThreads;
import forge.Graphics;
import forge.StaticData;
......@@ -394,7 +395,6 @@ public class CardRenderer {
}
public static void drawCard(Graphics g, IPaperCard pc, float x, float y, float w, float h, CardStackPosition pos) {
boolean mask = isPreferenceEnabled(FPref.UI_ENABLE_BORDER_MASKING);
Texture image = new RendererCachedCardImage(pc, false).getImage();
float radius = (h - w)/8;
......@@ -403,7 +403,7 @@ public class CardRenderer {
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(pc), false, x, y, w, h, pos);
}
else {
if (mask) {
if (Forge.enableUIMask) {
if (ImageCache.isExtendedArt(pc))
g.drawImage(image, x, y, w, h);
else {
......@@ -423,14 +423,13 @@ public class CardRenderer {
}
}
else {
if (mask) //render this if mask is still loading
if (Forge.enableUIMask) //render this if mask is still loading
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(pc), false, x, y, w, h, pos);
else //draw cards without textures as just a black rectangle
g.fillRect(Color.BLACK, x, y, w, h);
}
}
public static void drawCard(Graphics g, CardView card, float x, float y, float w, float h, CardStackPosition pos, boolean rotate) {
boolean mask = isPreferenceEnabled(FPref.UI_ENABLE_BORDER_MASKING);
Texture image = new RendererCachedCardImage(card, false).getImage();
float radius = (h - w)/8;
......@@ -441,7 +440,7 @@ public class CardRenderer {
else {
if(FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_PLANE_OR_PHENOMENON)
&& (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane()) && rotate){
if (mask) {
if (Forge.enableUIMask) {
if (ImageCache.isExtendedArt(card))
g.drawRotatedImage(image, x, y, w, h, x + w / 2, y + h / 2, -90);
else {
......@@ -453,7 +452,7 @@ public class CardRenderer {
g.drawRotatedImage(image, x, y, w, h, x + w / 2, y + h / 2, -90);
}
else {
if (mask) {
if (Forge.enableUIMask) {
if (ImageCache.isExtendedArt(card))
g.drawImage(image, x, y, w, h);
else {
......@@ -469,7 +468,7 @@ public class CardRenderer {
drawFoilEffect(g, card, x, y, w, h, false);
}
else {
if (mask) //render this if mask is still loading
if (Forge.enableUIMask) //render this if mask is still loading
CardImageRenderer.drawCardImage(g, card, false, x, y, w, h, pos);
else //draw cards without textures as just a black rectangle
g.fillRect(Color.BLACK, x, y, w, h);
......
package forge.itemmanager.views;
import forge.Forge;
import forge.Forge.KeyInputAdapter;
import forge.Graphics;
import forge.assets.FImage;
......@@ -181,7 +182,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
getPnlOptions().add(cbPileByOptions);
Group group = new Group(""); //add default group
groups.add(group);
groups.add(group);
getScroller().add(group);
}
......@@ -300,7 +301,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
updateLayout(false);
return;
}
float offsetTop = focalItem0.getTop() - getScrollValue();
updateLayout(false);
setScrollValue(focalItem0.getTop() - offsetTop);
......@@ -891,7 +892,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
public void draw(Graphics g) {
final float visibleTop = getScrollValue();
final float visibleBottom = visibleTop + getScroller().getHeight();
ItemInfo skippedItem = null;
for (ItemInfo itemInfo : items) {
if (itemInfo.getBottom() < visibleTop) {
......@@ -954,9 +955,18 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
final float w = getWidth();
final float h = getHeight();
if (selected) {
g.fillRect(Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE,
w + 2 * SEL_BORDER_SIZE, h + 2 * SEL_BORDER_SIZE);
if (selected) { //if round border is enabled, the select highlight is also rounded..
if (Forge.enableUIMask) {
//fillroundrect has rough/aliased corner
g.fillRoundRect(Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE,
w + 2 * SEL_BORDER_SIZE, h + 2 * SEL_BORDER_SIZE, (h - w) / 10);
//drawroundrect has GL_SMOOTH to `smoothen/faux` the aliased corner
g.drawRoundRect(1f, Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE,
w + 1.5f * SEL_BORDER_SIZE, h + 1.5f * SEL_BORDER_SIZE, (h - w) / 10);
}
else //default rectangle highlight
g.fillRect(Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE,
w + 2 * SEL_BORDER_SIZE, h + 2 * SEL_BORDER_SIZE);
}
if (item instanceof PaperCard) {
......
......@@ -260,7 +260,7 @@ public class SettingsPage extends TabPage<SettingsScreen> {
TabPageScreen.COMPACT_TABS = FModel.getPreferences().getPrefBoolean(FPref.UI_COMPACT_TABS);
parentScreen.revalidate();
}
}, 4);
},4);
lstSettings.addItem(new BooleanSetting(FPref.UI_COMPACT_LIST_ITEMS,
localizer.getMessage("lblCompactListItems"),
localizer.getMessage("nlCompactListItems")),
......@@ -302,32 +302,42 @@ public class SettingsPage extends TabPage<SettingsScreen> {
localizer.getMessage("nlDisableCardEffect")),
4);
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_BORDER_MASKING,
"Enable Round Border Mask",
"When enabled, the card corners are rounded (Preferably Card with Full Borders)."),
4);
"Enable Round Border Mask",
"When enabled, the card corners are rounded (Preferably Card with Full Borders)."){
@Override
public void select() {
super.select();
//update
Forge.enableUIMask = FModel.getPreferences().getPrefBoolean(FPref.UI_ENABLE_BORDER_MASKING);
}
},4);
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_PRELOAD_EXTENDED_ART,
"Preload Extended Art Cards",
"When enabled, Preloads Extended Art Cards to Cache on Startup."),
4);
"Preload Extended Art Cards",
"When enabled, Preloads Extended Art Cards to Cache on Startup."){
@Override
public void select() {
super.select();
//update
Forge.enablePreloadExtendedArt = FModel.getPreferences().getPrefBoolean(FPref.UI_ENABLE_PRELOAD_EXTENDED_ART);
}
},4);
lstSettings.addItem(new BooleanSetting(FPref.UI_SHOW_FPS,
"Show FPS Display",
"When enabled, show the FPS Display (Experimental)."){
@Override
public void select() {
super.select();
//update
Forge.showFPS = FModel.getPreferences().getPrefBoolean(FPref.UI_SHOW_FPS);
}
},4);
"Show FPS Display",
"When enabled, show the FPS Display (Experimental)."){
@Override
public void select() {
super.select();
//update
Forge.showFPS = FModel.getPreferences().getPrefBoolean(FPref.UI_SHOW_FPS);
}
},4);
lstSettings.addItem(new CustomSelectSetting(FPref.UI_CARD_COUNTER_DISPLAY_TYPE,
localizer.getMessage("cbpCounterDisplayType"),
localizer.getMessage("nlCounterDisplayType"),
new String[]{
ForgeConstants.CounterDisplayType.TEXT.getName(), ForgeConstants.CounterDisplayType.IMAGE.getName(),
ForgeConstants.CounterDisplayType.HYBRID.getName(), ForgeConstants.CounterDisplayType.OLD_WHEN_SMALL.getName()}),
localizer.getMessage("cbpCounterDisplayType"),
localizer.getMessage("nlCounterDisplayType"),
new String[]{
ForgeConstants.CounterDisplayType.TEXT.getName(), ForgeConstants.CounterDisplayType.IMAGE.getName(),
ForgeConstants.CounterDisplayType.HYBRID.getName(), ForgeConstants.CounterDisplayType.OLD_WHEN_SMALL.getName()}),
4);
//Card Overlays
lstSettings.addItem(new BooleanSetting(FPref.UI_SHOW_CARD_OVERLAYS,
localizer.getMessage("lblShowCardOverlays"),
......@@ -353,7 +363,6 @@ public class SettingsPage extends TabPage<SettingsScreen> {
localizer.getMessage("lblShowAbilityIconsOverlays"),
localizer.getMessage("nlShowAbilityIconsOverlays")),
5);
//Vibration Options
lstSettings.addItem(new BooleanSetting(FPref.UI_VIBRATE_ON_LIFE_LOSS,
localizer.getMessage("lblVibrateWhenLosingLife"),
......@@ -363,7 +372,6 @@ public class SettingsPage extends TabPage<SettingsScreen> {
localizer.getMessage("lblVibrateAfterLongPress"),
localizer.getMessage("nlVibrateAfterLongPress")),
6);
//Sound Options
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_SOUNDS,
localizer.getMessage("cbEnableSounds"),
......@@ -378,7 +386,7 @@ public class SettingsPage extends TabPage<SettingsScreen> {
//update background music when this setting changes
SoundSystem.instance.changeBackgroundTrack();
}
}, 7);
},7);
/*lstSettings.addItem(new BooleanSetting(FPref.UI_ALT_SOUND_SYSTEM,
"Use Alternate Sound System",
"Use the alternate sound system (only use if you have issues with sound not playing or disappearing)."),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment