Show radio button icons on CustomSelect screen

This commit is contained in:
drdev
2014-03-06 06:10:31 +00:00
parent 3a4cb788c7
commit a65507a453
3 changed files with 84 additions and 4 deletions

View File

@@ -108,7 +108,7 @@ public class Forge implements ApplicationListener {
@Override @Override
public void render () { public void render () {
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); // Clear the screen. Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Clear the screen.
FContainer screen = currentScreen; FContainer screen = currentScreen;
if (screen == null) { if (screen == null) {
@@ -309,12 +309,19 @@ public class Forge implements ApplicationListener {
if (color.a != 0) { //enable blending so alpha colored shapes work properly if (color.a != 0) { //enable blending so alpha colored shapes work properly
Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glEnable(GL20.GL_BLEND);
} }
boolean needSmoothing = (x1 != x2 && y1 != y2);
if (needSmoothing) {
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH);
}
shapeRenderer.begin(ShapeType.Line); shapeRenderer.begin(ShapeType.Line);
shapeRenderer.setColor(color); shapeRenderer.setColor(color);
shapeRenderer.line(adjustX(x1), adjustY(y1, 0), adjustX(x2), adjustY(y2, 0)); shapeRenderer.line(adjustX(x1), adjustY(y1, 0), adjustX(x2), adjustY(y2, 0));
shapeRenderer.end(); shapeRenderer.end();
if (needSmoothing) {
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
}
if (color.a != 0) { if (color.a != 0) {
Gdx.gl.glDisable(GL20.GL_BLEND); Gdx.gl.glDisable(GL20.GL_BLEND);
} }
@@ -337,6 +344,9 @@ public class Forge implements ApplicationListener {
if (color.a != 0) { //enable blending so alpha colored shapes work properly if (color.a != 0) { //enable blending so alpha colored shapes work properly
Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glEnable(GL20.GL_BLEND);
} }
if (cornerRadius > 0) {
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH);
}
//adjust width/height so rectangle covers equivalent filled area //adjust width/height so rectangle covers equivalent filled area
w = Math.round(w - 1); w = Math.round(w - 1);
@@ -357,6 +367,9 @@ public class Forge implements ApplicationListener {
shapeRenderer.end(); shapeRenderer.end();
if (cornerRadius > 0) {
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
}
if (color.a != 0) { if (color.a != 0) {
Gdx.gl.glDisable(GL20.GL_BLEND); Gdx.gl.glDisable(GL20.GL_BLEND);
} }
@@ -431,6 +444,58 @@ public class Forge implements ApplicationListener {
batch.begin(); batch.begin();
} }
public void drawCircle(float thickness, FSkinColor skinColor, float x, float y, float radius) {
drawCircle(thickness, skinColor.getColor(), x, y, radius);
}
public void drawCircle(float thickness, Color color, float x, float y, float radius) {
batch.end(); //must pause batch while rendering shapes
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(GL10.GL_LINE_SMOOTH);
shapeRenderer.begin(ShapeType.Line);
shapeRenderer.setColor(color);
shapeRenderer.circle(adjustX(x), adjustY(y, 0), radius);
shapeRenderer.end();
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
if (color.a != 0) {
Gdx.gl.glDisable(GL20.GL_BLEND);
}
if (thickness > 1) {
Gdx.gl.glLineWidth(1);
}
batch.begin();
}
public void fillCircle(FSkinColor skinColor, float x, float y, float radius) {
fillCircle(skinColor.getColor(), x, y, radius);
}
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
Gdx.gl.glEnable(GL20.GL_BLEND);
}
shapeRenderer.begin(ShapeType.Filled);
shapeRenderer.setColor(color);
shapeRenderer.circle(adjustX(x), adjustY(y, 0), radius); //TODO: Make smoother
shapeRenderer.end();
if (color.a != 0) {
Gdx.gl.glDisable(GL20.GL_BLEND);
}
batch.begin();
}
public void fillTriangle(FSkinColor skinColor, float x1, float y1, float x2, float y2, float x3, float y3) { public void fillTriangle(FSkinColor skinColor, float x1, float y1, float x2, float y2, float x3, float y3) {
fillTriangle(skinColor.getColor(), x1, y1, x2, y2, x3, y3); fillTriangle(skinColor.getColor(), x1, y1, x2, y2, x3, y3);
} }

View File

@@ -126,6 +126,7 @@ public class SettingsScreen extends FScreen {
private class CustomSelectScreen extends FScreen { private class CustomSelectScreen extends FScreen {
private final FList<String> lstOptions; private final FList<String> lstOptions;
private final String currentValue = FModel.getPreferences().getPref(pref);
private CustomSelectScreen() { private CustomSelectScreen() {
super(true, "Select " + label.substring(0, label.length() - 1), false); super(true, "Select " + label.substring(0, label.length() - 1), false);
@@ -133,14 +134,28 @@ public class SettingsScreen extends FScreen {
lstOptions.setListItemRenderer(new FList.DefaultListItemRenderer<String>() { lstOptions.setListItemRenderer(new FList.DefaultListItemRenderer<String>() {
@Override @Override
public boolean tap(String value, float x, float y, int count) { public boolean tap(String value, float x, float y, int count) {
valueChanged(value); if (!value.equals(currentValue)) {
valueChanged(value);
}
Forge.back(); Forge.back();
return true; return true;
} }
@Override @Override
public void drawValue(Graphics g, String value, FSkinFont font, FSkinColor foreColor, float width, float height) { public void drawValue(Graphics g, String value, FSkinFont font, FSkinColor foreColor, float width, float height) {
super.drawValue(g, value, font, foreColor, width, height); float x = width * INSETS_FACTOR;
float y = 0;
width -= 2 * x;
g.drawText(value, font, foreColor, x, y, width, height, false, HAlignment.LEFT, true);
float radius = height / 5;
x += width - radius;
y = height / 2;
g.drawCircle(1, DESC_COLOR, x, y, radius);
if (value.equals(currentValue)) {
g.fillCircle(foreColor, x, y, radius / 2);
}
} }
}); });
} }

View File

@@ -15,7 +15,7 @@ public class FList<E> extends FScrollPane {
private static final float INSETS_FACTOR = 0.025f; private static final float INSETS_FACTOR = 0.025f;
private static final float GROUP_HEADER_HEIGHT = Utils.AVG_FINGER_HEIGHT * 0.6f; private static final float GROUP_HEADER_HEIGHT = Utils.AVG_FINGER_HEIGHT * 0.6f;
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT); private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
private static final FSkinColor PRESSED_COLOR = FSkinColor.get(Colors.CLR_THEME2).alphaColor(0.75f); private static final FSkinColor PRESSED_COLOR = FSkinColor.get(Colors.CLR_ACTIVE).alphaColor(0.9f);
private static final FSkinColor LINE_COLOR = FORE_COLOR.alphaColor(0.5f); private static final FSkinColor LINE_COLOR = FORE_COLOR.alphaColor(0.5f);
private final List<ListGroup> groups = new ArrayList<ListGroup>(); private final List<ListGroup> groups = new ArrayList<ListGroup>();