Tweak some scaling for higher resolutions

This commit is contained in:
drdev
2014-05-11 15:15:04 +00:00
parent a8545035c7
commit e90fcc0fd3
3 changed files with 34 additions and 22 deletions

View File

@@ -1,11 +1,13 @@
package forge.menu; package forge.menu;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.Forge.Graphics; import forge.Forge.Graphics;
import forge.assets.FSkinColor; import forge.assets.FSkinColor;
import forge.assets.FSkinFont; import forge.assets.FSkinFont;
import forge.assets.FSkinColor.Colors; import forge.assets.FSkinColor.Colors;
import forge.toolbox.FDisplayObject; import forge.toolbox.FDisplayObject;
import forge.util.Utils;
public class FMenuTab extends FDisplayObject { public class FMenuTab extends FDisplayObject {
private static final FSkinFont FONT = FSkinFont.get(12); private static final FSkinFont FONT = FSkinFont.get(12);
@@ -14,6 +16,9 @@ public class FMenuTab extends FDisplayObject {
private static final FSkinColor SEL_FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT); private static final FSkinColor SEL_FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
private static final FSkinColor FORE_COLOR = SEL_FORE_COLOR.alphaColor(0.5f); private static final FSkinColor FORE_COLOR = SEL_FORE_COLOR.alphaColor(0.5f);
private static final FSkinColor SEPARATOR_COLOR = SEL_FORE_COLOR.alphaColor(0.3f); private static final FSkinColor SEPARATOR_COLOR = SEL_FORE_COLOR.alphaColor(0.3f);
private static final float PADDING = Utils.scaleMin(2);
private static final float SEL_BORDER_WIDTH = Utils.scaleMin(2);
private static final float SEPARATOR_WIDTH = Utils.scaleX(1);
private final FMenuBar menuBar; private final FMenuBar menuBar;
private final FDropDown dropDown; private final FDropDown dropDown;
@@ -61,19 +66,17 @@ public class FMenuTab extends FDisplayObject {
@Override @Override
public void draw(Graphics g) { public void draw(Graphics g) {
float x, y, w, h; float x, y, w, h;
float paddingX = 2;
float paddingY = 2;
FSkinColor foreColor; FSkinColor foreColor;
if (dropDown.isVisible()) { if (dropDown.isVisible()) {
x = paddingX; //round so lines show up reliably x = PADDING; //round so lines show up reliably
y = paddingY; y = PADDING;
w = getWidth() - 2 * x + 1; w = getWidth() - 2 * x + 1;
h = getHeight() - y + 1; h = getHeight() - y + 1;
g.startClip(x, y, w, h); g.startClip(x, y, w, h);
g.fillRect(SEL_BACK_COLOR, x, y, w, h); g.fillRect(SEL_BACK_COLOR, x, y, w, h);
g.drawRect(2, SEL_BORDER_COLOR, x, y, w, h); g.drawRect(SEL_BORDER_WIDTH, SEL_BORDER_COLOR, x, y, w, h);
g.endClip(); g.endClip();
foreColor = SEL_FORE_COLOR; foreColor = SEL_FORE_COLOR;
@@ -85,12 +88,12 @@ public class FMenuTab extends FDisplayObject {
//draw right separator //draw right separator
x = getWidth(); x = getWidth();
y = getHeight() / 4; y = getHeight() / 4;
g.drawLine(1, SEPARATOR_COLOR, x, y, x, getHeight() - y); g.drawLine(SEPARATOR_WIDTH, SEPARATOR_COLOR, x, y, x, getHeight() - y);
x = paddingX; x = PADDING;
y = paddingY; y = PADDING;
w = getWidth() - 2 * paddingX; w = getWidth() - 2 * PADDING;
h = getHeight() - 2 * paddingY; 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, HAlignment.CENTER, true);
} }
} }

View File

@@ -99,10 +99,15 @@ public class VManaPool extends VDisplayArea {
public void draw(Graphics g) { public void draw(Graphics g) {
float textHeight = FONT.getFont().getCapHeight(); float textHeight = FONT.getFont().getCapHeight();
float gapY = textHeight / 4f; float gapY = textHeight / 4f;
float w = image.getWidth();
float h = image.getHeight(); float maxImageHeight = getHeight() - textHeight - 3 * gapY;
float h = image.getNearestHQHeight(maxImageHeight);
if (h > maxImageHeight) {
h /= 2;
}
float w = image.getWidth() * h / image.getHeight();
float x = (getWidth() - w) / 2; float x = (getWidth() - w) / 2;
float y = (getHeight() - h - textHeight - gapY) / 2; float y = gapY + (maxImageHeight - h) / 2;
g.drawImage(image, x, y, w, h); g.drawImage(image, x, y, w, h);

View File

@@ -18,12 +18,14 @@ import forge.screens.match.FControl;
import forge.screens.match.MatchScreen; import forge.screens.match.MatchScreen;
import forge.toolbox.FContainer; import forge.toolbox.FContainer;
import forge.toolbox.FDisplayObject; import forge.toolbox.FDisplayObject;
import forge.util.Utils;
public class VPlayerPanel extends FContainer { public class VPlayerPanel extends FContainer {
private static final FSkinFont LIFE_FONT = FSkinFont.get(18); private static final FSkinFont LIFE_FONT = FSkinFont.get(18);
private static final FSkinFont INFO_FONT = FSkinFont.get(12); private static final FSkinFont INFO_FONT = FSkinFont.get(12);
private static final FSkinColor INFO_FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT); private static final FSkinColor INFO_FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
private static final FSkinColor DISPLAY_AREA_BACK_COLOR = FSkinColor.get(Colors.CLR_INACTIVE).alphaColor(0.5f); private static final FSkinColor DISPLAY_AREA_BACK_COLOR = FSkinColor.get(Colors.CLR_INACTIVE).alphaColor(0.5f);
private static final float INFO_TAB_PADDING = Utils.scaleMin(2);
private final Player player; private final Player player;
private final VPhaseIndicator phaseIndicator; private final VPhaseIndicator phaseIndicator;
@@ -240,8 +242,6 @@ public class VPlayerPanel extends FContainer {
@Override @Override
public void draw(Graphics g) { public void draw(Graphics g) {
float x, y, w, h; float x, y, w, h;
float paddingX = 2;
float paddingY = 2;
if (selectedTab == this) { if (selectedTab == this) {
y = 0; y = 0;
@@ -249,18 +249,18 @@ public class VPlayerPanel extends FContainer {
h = getHeight(); h = getHeight();
float yAcross; float yAcross;
if (isFlipped()) { if (isFlipped()) {
y += paddingY; y += INFO_TAB_PADDING;
yAcross = y; yAcross = y;
y--; y--;
h++; h++;
} }
else { else {
h -= paddingY; h -= INFO_TAB_PADDING;
yAcross = h; yAcross = h;
y--; y--;
h += 2; h += 2;
} }
g.fillRect(DISPLAY_AREA_BACK_COLOR, 0, isFlipped() ? paddingY : 0, w, getHeight() - paddingY); g.fillRect(DISPLAY_AREA_BACK_COLOR, 0, isFlipped() ? INFO_TAB_PADDING : 0, w, getHeight() - INFO_TAB_PADDING);
g.startClip(-1, y, w + 2, h); //use clip to ensure all corners connect g.startClip(-1, y, w + 2, h); //use clip to ensure all corners connect
g.drawLine(1, MatchScreen.BORDER_COLOR, 0, yAcross, w, yAcross); g.drawLine(1, MatchScreen.BORDER_COLOR, 0, yAcross, w, yAcross);
g.drawLine(1, MatchScreen.BORDER_COLOR, 0, y, 0, h); g.drawLine(1, MatchScreen.BORDER_COLOR, 0, y, 0, h);
@@ -268,13 +268,17 @@ public class VPlayerPanel extends FContainer {
g.endClip(); g.endClip();
} }
h = Math.round(getHeight() * 0.7f / 20f) * 20f; //round to nearest 20 so images look ok float maxImageWidth = getWidth() - INFO_FONT.getFont().getBounds("0").width - 3 * INFO_TAB_PADDING;
w = h; w = icon.getNearestHQWidth(maxImageWidth);
x = paddingX; if (w > maxImageWidth) {
w /= 2;
}
h = icon.getHeight() * w / icon.getWidth();
x = INFO_TAB_PADDING;
y = (getHeight() - h) / 2; y = (getHeight() - h) / 2;
g.drawImage(icon, x, y, w, h); g.drawImage(icon, x, y, w, h);
x += w * 1.1f; x += w + INFO_TAB_PADDING;
g.drawText(value, INFO_FONT, INFO_FORE_COLOR, x, 0, getWidth() - x + 1, getHeight(), false, HAlignment.LEFT, true); g.drawText(value, INFO_FONT, INFO_FORE_COLOR, x, 0, getWidth() - x + 1, getHeight(), false, HAlignment.LEFT, true);
} }
} }