mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Fix rendering logic
This commit is contained in:
@@ -344,10 +344,10 @@ public class Forge implements ApplicationListener {
|
||||
if (thickness > 1) {
|
||||
Gdx.gl.glLineWidth(thickness);
|
||||
}
|
||||
if (color.a != 0) { //enable blending so alpha colored shapes work properly
|
||||
boolean needSmoothing = (x1 != x2 && y1 != y2);
|
||||
if (color.a < 1 || needSmoothing) { //enable blending so alpha colored shapes work properly
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
}
|
||||
boolean needSmoothing = (x1 != x2 && y1 != y2);
|
||||
if (needSmoothing) {
|
||||
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH);
|
||||
}
|
||||
@@ -360,7 +360,7 @@ public class Forge implements ApplicationListener {
|
||||
if (needSmoothing) {
|
||||
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
|
||||
}
|
||||
if (color.a != 0) {
|
||||
if (color.a < 1 || needSmoothing) {
|
||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||
}
|
||||
if (thickness > 1) {
|
||||
@@ -379,7 +379,7 @@ public class Forge implements ApplicationListener {
|
||||
if (thickness > 1) {
|
||||
Gdx.gl.glLineWidth(thickness);
|
||||
}
|
||||
if (color.a != 0) { //enable blending so alpha colored shapes work properly
|
||||
if (color.a < 1 || cornerRadius > 0) { //enable blending so alpha colored shapes work properly
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
}
|
||||
if (cornerRadius > 0) {
|
||||
@@ -408,7 +408,7 @@ public class Forge implements ApplicationListener {
|
||||
if (cornerRadius > 0) {
|
||||
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
|
||||
}
|
||||
if (color.a != 0) {
|
||||
if (color.a < 1 || cornerRadius > 0) {
|
||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||
}
|
||||
if (thickness > 1) {
|
||||
@@ -427,9 +427,7 @@ public class Forge implements ApplicationListener {
|
||||
if (thickness > 1) {
|
||||
Gdx.gl.glLineWidth(thickness);
|
||||
}
|
||||
if (color.a != 0) { //enable blending so alpha colored shapes work properly
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
}
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH); //must be smooth to ensure edges aren't missed
|
||||
|
||||
shapeRenderer.begin(ShapeType.Line);
|
||||
@@ -438,9 +436,7 @@ public class Forge implements ApplicationListener {
|
||||
shapeRenderer.end();
|
||||
|
||||
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
|
||||
if (color.a != 0) {
|
||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||
}
|
||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||
if (thickness > 1) {
|
||||
Gdx.gl.glLineWidth(1);
|
||||
}
|
||||
@@ -454,7 +450,7 @@ public class Forge implements ApplicationListener {
|
||||
public void fillRect(Color color, float x, float y, float w, float h) {
|
||||
batch.end(); //must pause batch while rendering shapes
|
||||
|
||||
if (color.a != 0) { //enable blending so alpha colored shapes work properly
|
||||
if (color.a < 1) { //enable blending so alpha colored shapes work properly
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
}
|
||||
|
||||
@@ -463,7 +459,7 @@ public class Forge implements ApplicationListener {
|
||||
shapeRenderer.rect(adjustX(x), adjustY(y, h), w, h);
|
||||
shapeRenderer.end();
|
||||
|
||||
if (color.a != 0) {
|
||||
if (color.a < 1) {
|
||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||
}
|
||||
|
||||
@@ -479,9 +475,7 @@ public class Forge implements ApplicationListener {
|
||||
if (thickness > 1) {
|
||||
Gdx.gl.glLineWidth(thickness);
|
||||
}
|
||||
if (color.a != 0) { //enable blending so alpha colored shapes work properly
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
}
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH);
|
||||
|
||||
shapeRenderer.begin(ShapeType.Line);
|
||||
@@ -490,9 +484,7 @@ public class Forge implements ApplicationListener {
|
||||
shapeRenderer.end();
|
||||
|
||||
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
|
||||
if (color.a != 0) {
|
||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||
}
|
||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||
if (thickness > 1) {
|
||||
Gdx.gl.glLineWidth(1);
|
||||
}
|
||||
@@ -506,7 +498,7 @@ public class Forge implements ApplicationListener {
|
||||
public void fillCircle(Color color, float x, float y, float radius) {
|
||||
batch.end(); //must pause batch while rendering shapes
|
||||
|
||||
if (color.a != 0) { //enable blending so alpha colored shapes work properly
|
||||
if (color.a < 1) { //enable blending so alpha colored shapes work properly
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
}
|
||||
|
||||
@@ -515,7 +507,7 @@ public class Forge implements ApplicationListener {
|
||||
shapeRenderer.circle(adjustX(x), adjustY(y, 0), radius); //TODO: Make smoother
|
||||
shapeRenderer.end();
|
||||
|
||||
if (color.a != 0) {
|
||||
if (color.a < 1) {
|
||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||
}
|
||||
|
||||
@@ -528,7 +520,7 @@ public class Forge implements ApplicationListener {
|
||||
public void fillTriangle(Color color, float x1, float y1, float x2, float y2, float x3, float y3) {
|
||||
batch.end(); //must pause batch while rendering shapes
|
||||
|
||||
if (color.a != 0) { //enable blending so alpha colored shapes work properly
|
||||
if (color.a < 1) { //enable blending so alpha colored shapes work properly
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
}
|
||||
|
||||
@@ -537,7 +529,7 @@ public class Forge implements ApplicationListener {
|
||||
shapeRenderer.triangle(adjustX(x1), adjustY(y1, 0), adjustX(x2), adjustY(y2, 0), adjustX(x3), adjustY(y3, 0));
|
||||
shapeRenderer.end();
|
||||
|
||||
if (color.a != 0) {
|
||||
if (color.a < 1) {
|
||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||
}
|
||||
|
||||
@@ -556,7 +548,7 @@ public class Forge implements ApplicationListener {
|
||||
public void fillGradientRect(Color color1, Color color2, boolean vertical, float x, float y, float w, float h) {
|
||||
batch.end(); //must pause batch while rendering shapes
|
||||
|
||||
boolean needBlending = (color1.a != 0 || color2.a != 0);
|
||||
boolean needBlending = (color1.a < 1 || color2.a < 1);
|
||||
if (needBlending) { //enable blending so alpha colored shapes work properly
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public abstract class FDropDown extends FScrollPane {
|
||||
x = screenWidth - paneSize.getWidth();
|
||||
}
|
||||
|
||||
setBounds(x, y, paneSize.getWidth(), Math.min(paneSize.getHeight(), maxVisibleHeight));
|
||||
setBounds(Math.round(x), Math.round(y), Math.round(paneSize.getWidth()), Math.round(Math.min(paneSize.getHeight(), maxVisibleHeight)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,9 +107,7 @@ public abstract class FDropDown extends FScrollPane {
|
||||
protected void drawOverlay(Graphics g) {
|
||||
float w = getWidth();
|
||||
float h = getHeight();
|
||||
g.startClip(0, 0, w, h);
|
||||
g.drawRect(1.5f, BORDER_COLOR, 0, 0, w, h); //ensure border shows up on all sides
|
||||
g.endClip();
|
||||
g.drawRect(1, BORDER_COLOR, 0, 0, w, h); //ensure border shows up on all sides
|
||||
}
|
||||
|
||||
private class Backdrop extends FDisplayObject {
|
||||
|
||||
@@ -3,11 +3,13 @@ package forge.menu;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Forge.Graphics;
|
||||
import forge.screens.FScreen;
|
||||
import forge.toolbox.FContainer;
|
||||
import forge.utils.Utils;
|
||||
|
||||
public class FMenuBar extends FContainer {
|
||||
public static final float HEIGHT = Utils.AVG_FINGER_HEIGHT * 0.6f;
|
||||
public static final float HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.6f);
|
||||
|
||||
private final List<FMenuTab> tabs = new ArrayList<FMenuTab>();
|
||||
|
||||
@@ -27,15 +29,22 @@ public class FMenuBar extends FContainer {
|
||||
visibleTabCount++;
|
||||
}
|
||||
}
|
||||
float tabWidth;
|
||||
float x = 0;
|
||||
int tabWidth;
|
||||
int x = 0;
|
||||
float dx = (width - minWidth) / visibleTabCount;
|
||||
for (FMenuTab tab : tabs) {
|
||||
if (tab.isVisible()) {
|
||||
tabWidth = tab.getMinWidth() + dx;
|
||||
tabWidth = (int)(tab.getMinWidth() + dx);
|
||||
tab.setBounds(x, 0, tabWidth, height);
|
||||
x += tabWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(Graphics g) {
|
||||
float w = getWidth();
|
||||
float h = getHeight();
|
||||
g.fillRect(FScreen.HEADER_BACK_COLOR, 0, 0, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,15 +5,15 @@ import forge.Forge.Graphics;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.screens.FScreen;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
|
||||
public class FMenuTab extends FDisplayObject {
|
||||
private static final FSkinFont FONT = FSkinFont.get(12);
|
||||
private static final FSkinColor SEL_GRADIENT_BOTTOM = FDropDown.BORDER_COLOR;
|
||||
private static final FSkinColor SEL_GRADIENT_TOP = SEL_GRADIENT_BOTTOM.stepColor(30);
|
||||
private static final FSkinColor SEL_FORE_COLOR = SEL_GRADIENT_BOTTOM.getHighContrastColor();
|
||||
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT).alphaColor(0.5f);
|
||||
private static final FSkinColor SEL_BACK_COLOR = FSkinColor.get(Colors.CLR_ACTIVE);
|
||||
private static final FSkinColor SEL_BORDER_COLOR = FDropDown.BORDER_COLOR;
|
||||
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 SEPARATOR_COLOR = SEL_FORE_COLOR.alphaColor(0.3f);
|
||||
|
||||
private final FMenuBar menuBar;
|
||||
private final FDropDown dropDown;
|
||||
@@ -66,7 +66,16 @@ public class FMenuTab extends FDisplayObject {
|
||||
|
||||
FSkinColor foreColor;
|
||||
if (dropDown.isVisible()) {
|
||||
g.fillGradientRect(SEL_GRADIENT_TOP, SEL_GRADIENT_BOTTOM, true, paddingX, paddingY, getWidth() - 2 * paddingX, getHeight() - paddingY);
|
||||
x = paddingX; //round so lines show up reliably
|
||||
y = paddingY;
|
||||
w = getWidth() - 2 * x;
|
||||
h = getHeight() - y;
|
||||
|
||||
g.fillRect(SEL_BACK_COLOR, x, y, w, h);
|
||||
g.drawLine(1, SEL_BORDER_COLOR, x, y, x + w, y);
|
||||
g.drawLine(1, SEL_BORDER_COLOR, x, y, x, y + h);
|
||||
g.drawLine(1, SEL_BORDER_COLOR, x + w, y, x + w, y + h);
|
||||
|
||||
foreColor = SEL_FORE_COLOR;
|
||||
}
|
||||
else {
|
||||
@@ -76,7 +85,7 @@ public class FMenuTab extends FDisplayObject {
|
||||
//draw right separator
|
||||
x = getWidth();
|
||||
y = getHeight() / 4;
|
||||
g.drawLine(1, FScreen.HEADER_LINE_COLOR, x, y, x, getHeight() - y);
|
||||
g.drawLine(1, SEPARATOR_COLOR, x, y, x, getHeight() - y);
|
||||
|
||||
x = paddingX;
|
||||
y = paddingY;
|
||||
|
||||
Reference in New Issue
Block a user