mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
[Mobile] Refactor Deckbox ImageView
-fix Mana Icons and Deck Name on Portrait and Landscape Mode
This commit is contained in:
@@ -190,11 +190,17 @@ public class CardFaceSymbols {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void drawColorSet(Graphics g, ColorSet colorSet, float x, float y, final float imageSize) {
|
public static void drawColorSet(Graphics g, ColorSet colorSet, float x, float y, final float imageSize) {
|
||||||
|
drawColorSet(g, colorSet, x, y, imageSize, false);
|
||||||
|
}
|
||||||
|
public static void drawColorSet(Graphics g, ColorSet colorSet, float x, float y, final float imageSize, boolean vertical) {
|
||||||
final float dx = imageSize;
|
final float dx = imageSize;
|
||||||
|
|
||||||
for (final ManaCostShard s : colorSet.getOrderedShards()) {
|
for (final ManaCostShard s : colorSet.getOrderedShards()) {
|
||||||
drawSymbol(s.getImageKey(), g, x, y, imageSize, imageSize);
|
drawSymbol(s.getImageKey(), g, x, y, imageSize, imageSize);
|
||||||
x += dx;
|
if (!vertical)
|
||||||
|
x += dx;
|
||||||
|
else
|
||||||
|
y += dx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -227,8 +227,8 @@ public class FDeckChooser extends FScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivate() {
|
public void onActivate() {
|
||||||
//todo investigate why if we don't override, it will display blank for deckview when first activated
|
//somehow a loaded deck state from startup don't refresh accordingly for imageview so refresh it on first activation
|
||||||
if(isAi() && firstactivation) {
|
if(firstactivation) {
|
||||||
needRefreshOnActivate = true;
|
needRefreshOnActivate = true;
|
||||||
firstactivation = false;
|
firstactivation = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import forge.toolbox.FEvent.FEventHandler;
|
|||||||
import forge.toolbox.FLabel;
|
import forge.toolbox.FLabel;
|
||||||
import forge.toolbox.FScrollPane;
|
import forge.toolbox.FScrollPane;
|
||||||
import forge.util.Localizer;
|
import forge.util.Localizer;
|
||||||
|
import forge.util.TextUtil;
|
||||||
import forge.util.Utils;
|
import forge.util.Utils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -960,67 +961,89 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
final float y = getTop() - group.getTop() - getScrollValue();
|
final float y = getTop() - group.getTop() - getScrollValue();
|
||||||
final float w = getWidth();
|
final float w = getWidth();
|
||||||
final float h = getHeight();
|
final float h = getHeight();
|
||||||
|
Texture dpImg = null;
|
||||||
|
boolean deckSelectMode = false;
|
||||||
|
if (item instanceof DeckProxy) {
|
||||||
|
dpImg = ImageCache.getImage(item);
|
||||||
|
deckSelectMode = true;
|
||||||
|
}
|
||||||
if (selected) {
|
if (selected) {
|
||||||
//if round border is enabled, the select highlight is also rounded..
|
if (!deckSelectMode) {
|
||||||
if (Forge.enableUIMask) {
|
//if round border is enabled, the select highlight is also rounded..
|
||||||
//fillroundrect has rough/aliased corner
|
if (Forge.enableUIMask) {
|
||||||
g.fillRoundRect(Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE,
|
//fillroundrect has rough/aliased corner
|
||||||
w + 2 * SEL_BORDER_SIZE, h + 2 * SEL_BORDER_SIZE, (h - w) / 10);
|
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
|
//drawroundrect has GL_SMOOTH to `smoothen/faux` the aliased corner
|
||||||
g.drawRoundRect(1f, Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE,
|
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);
|
||||||
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);
|
||||||
}
|
}
|
||||||
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) {
|
if (item instanceof PaperCard) {
|
||||||
CardRenderer.drawCard(g, (PaperCard) item, x, y, w, h, pos);
|
CardRenderer.drawCard(g, (PaperCard) item, x, y, w, h, pos);
|
||||||
} else if (item instanceof DeckProxy) {
|
} else if (deckSelectMode) {
|
||||||
DeckProxy dp = ((DeckProxy) item);
|
DeckProxy dp = ((DeckProxy) item);
|
||||||
ColorSet deckColor = dp.getColor();
|
ColorSet deckColor = dp.getColor();
|
||||||
float scale = 0.75f;
|
float scale = 0.75f;
|
||||||
Texture img = ImageCache.getImage(item);
|
|
||||||
if (img != null) {//generated decks have missing info...
|
if (dpImg != null) {//generated decks have missing info...
|
||||||
|
if (selected)
|
||||||
|
g.fillRoundRect(Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE, w + 2 * SEL_BORDER_SIZE, w + 12 * SEL_BORDER_SIZE, (h - w) / 10);
|
||||||
if (Forge.enableUIMask){
|
if (Forge.enableUIMask){
|
||||||
//commander bg
|
//commander bg
|
||||||
g.drawImage(FSkin.getDeckbox().get(0),x, y, w, h);
|
g.drawImage(FSkin.getDeckbox().get(0),x, y, w, h);
|
||||||
TextureRegion tr = ImageCache.croppedBorderImage(img);
|
TextureRegion tr = ImageCache.croppedBorderImage(dpImg);
|
||||||
g.drawImage(tr, x+(w-w*scale)/2, y+(h-h*scale)/1.5f, w*scale, h*scale);
|
g.drawImage(tr, x+(w-w*scale)/2, y+(h-h*scale)/1.5f, w*scale, h*scale);
|
||||||
} else {
|
} else {
|
||||||
g.drawImage(img, x, y, w, h);
|
g.drawImage(dpImg, x, y, w, h);
|
||||||
}
|
}
|
||||||
|
//fake labelname shadow
|
||||||
|
g.drawText(item.getName(), GROUP_HEADER_FONT, Color.BLACK, (x + PADDING)-1f, (y + PADDING*2)+1f, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, false);
|
||||||
|
//labelname
|
||||||
g.drawText(item.getName(), GROUP_HEADER_FONT, Color.WHITE, x + PADDING, y + PADDING*2, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, false);
|
g.drawText(item.getName(), GROUP_HEADER_FONT, Color.WHITE, x + PADDING, y + PADDING*2, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, false);
|
||||||
} else {
|
} else {
|
||||||
if (!dp.isGeneratedDeck()){
|
if (!dp.isGeneratedDeck()){
|
||||||
FImageComplex card = CardRenderer.getCardArt(dp.getHighestCMCCard().getImageKey(false), false, false, false);
|
FImageComplex cardArt = CardRenderer.getCardArt(dp.getHighestCMCCard().getImageKey(false), false, false, false);
|
||||||
if (card != null){
|
//after getting cardArt we draw the selector first if selected here in deckSelectMode, we don't want to draw the selection before getting the cardArt
|
||||||
|
if (selected)
|
||||||
|
g.fillRoundRect(Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE, w + 2 * SEL_BORDER_SIZE, w + 12 * SEL_BORDER_SIZE, (h - w) / 10);
|
||||||
|
//draw the deckbox
|
||||||
|
if (cardArt != null){
|
||||||
//card art
|
//card art
|
||||||
card.draw(g, x+((w-w*scale)/2), y+((h-h*scale)/0.75f), w*scale, h*scale/1.85f);
|
cardArt.draw(g, x+((w-w*scale)/2), y+((h-h*scale)/3f), w*scale, h*scale/1.85f);
|
||||||
//deck box
|
//deck box
|
||||||
g.drawImage(FSkin.getDeckbox().get(1),x, y, w, h);
|
g.drawImage(FSkin.getDeckbox().get(1),x, y-(h*0.25f), w, h);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//generic box
|
//generic box
|
||||||
g.drawImage(FSkin.getDeckbox().get(2),x, y, w, h);
|
g.drawImage(FSkin.getDeckbox().get(2),x, y-(h*0.25f), w, h);
|
||||||
}
|
}
|
||||||
if (deckColor != null && Forge.isLandscapeMode()) { //todo scale mana icons for decks on portrait mode
|
if (deckColor != null) {
|
||||||
//deck color identity
|
//deck color identity
|
||||||
float symbolSize = IMAGE_SIZE;
|
float symbolSize = IMAGE_SIZE;
|
||||||
if (columnCount == 4)
|
if (Forge.isLandscapeMode()) {
|
||||||
symbolSize = IMAGE_SIZE * 1.25f;
|
if (columnCount == 4)
|
||||||
else if (columnCount == 3)
|
symbolSize = IMAGE_SIZE * 1.5f;
|
||||||
symbolSize = IMAGE_SIZE * 1.5f;
|
else if (columnCount == 3)
|
||||||
else if (columnCount == 2)
|
symbolSize = IMAGE_SIZE * 2f;
|
||||||
symbolSize = IMAGE_SIZE * 1.75f;
|
else if (columnCount == 2)
|
||||||
else if (columnCount == 1)
|
symbolSize = IMAGE_SIZE * 3f;
|
||||||
symbolSize = IMAGE_SIZE * 2f;
|
else if (columnCount == 1)
|
||||||
CardFaceSymbols.drawColorSet(g, deckColor, x +((w/2) - (CardFaceSymbols.getWidth(deckColor, symbolSize)/1.9f)), y + (h*0.8f), symbolSize);
|
symbolSize = IMAGE_SIZE * 4f;
|
||||||
|
} else {
|
||||||
|
if (columnCount > 2)
|
||||||
|
symbolSize = IMAGE_SIZE * (0.5f);
|
||||||
|
}
|
||||||
|
//vertical mana icons
|
||||||
|
CardFaceSymbols.drawColorSet(g, deckColor, x +(w-symbolSize), y+(h/8), symbolSize, true);
|
||||||
}
|
}
|
||||||
|
String deckname = TextUtil.fastReplace(item.getName(),"] #", "]\n#");
|
||||||
|
//deckname fakeshadow
|
||||||
|
g.drawText(deckname, GROUP_HEADER_FONT, Color.BLACK, (x + PADDING)-1f, (y + (h/10) + PADDING)+1f, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, true);
|
||||||
//deck name
|
//deck name
|
||||||
g.drawText(item.getName(), GROUP_HEADER_FONT, Color.WHITE, x + PADDING, y + (h/16) + PADDING, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, false);
|
g.drawText(deckname, GROUP_HEADER_FONT, Color.WHITE, x + PADDING, y + (h/10) + PADDING, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Texture img = ImageCache.getImage(item);
|
Texture img = ImageCache.getImage(item);
|
||||||
|
|||||||
Reference in New Issue
Block a user