mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Flesh out Setting screen structure
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -16037,6 +16037,7 @@ forge-m-base/src/forge/toolbox/FContainer.java -text
|
|||||||
forge-m-base/src/forge/toolbox/FDisplayObject.java -text
|
forge-m-base/src/forge/toolbox/FDisplayObject.java -text
|
||||||
forge-m-base/src/forge/toolbox/FLabel.java -text
|
forge-m-base/src/forge/toolbox/FLabel.java -text
|
||||||
forge-m-base/src/forge/toolbox/FProgressBar.java -text
|
forge-m-base/src/forge/toolbox/FProgressBar.java -text
|
||||||
|
forge-m-base/src/forge/toolbox/FScrollPane.java -text
|
||||||
forge-m-base/src/forge/utils/Constants.java -text
|
forge-m-base/src/forge/utils/Constants.java -text
|
||||||
forge-m-base/src/forge/utils/FileLocation.java -text
|
forge-m-base/src/forge/utils/FileLocation.java -text
|
||||||
forge-m-base/src/forge/utils/Utils.java -text
|
forge-m-base/src/forge/utils/Utils.java -text
|
||||||
|
|||||||
@@ -1,20 +1,84 @@
|
|||||||
package forge.screens.settings;
|
package forge.screens.settings;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import forge.assets.FSkin;
|
import forge.assets.FSkin;
|
||||||
import forge.screens.FScreen;
|
import forge.screens.FScreen;
|
||||||
import forge.toolbox.FComboBox;
|
import forge.toolbox.FComboBox;
|
||||||
|
import forge.toolbox.FContainer;
|
||||||
|
import forge.toolbox.FLabel;
|
||||||
|
import forge.toolbox.FScrollPane;
|
||||||
|
|
||||||
public class SettingsScreen extends FScreen {
|
public class SettingsScreen extends FScreen {
|
||||||
private FComboBox<String> cmbTheme;
|
private static final float INSETS_FACTOR = 0.025f;
|
||||||
|
private static final float GAP_Y_FACTOR = 0.01f;
|
||||||
|
|
||||||
|
private final FScrollPane scroller = add(new FScrollPane());
|
||||||
|
private final List<SettingPanel> settingPanels = new ArrayList<SettingPanel>();
|
||||||
|
|
||||||
public SettingsScreen() {
|
public SettingsScreen() {
|
||||||
super(true, "Settings", true);
|
super(true, "Settings", false);
|
||||||
|
|
||||||
cmbTheme = add(new FComboBox<>(FSkin.getAllSkins()));
|
addPanel(new ComboBoxPanel<String>("Theme", FSkin.getAllSkins()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addPanel(SettingPanel panel) {
|
||||||
|
scroller.add(panel);
|
||||||
|
settingPanels.add(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLayout(float startY, float width, float height) {
|
protected void doLayout(float startY, float width, float height) {
|
||||||
cmbTheme.setBounds(20, startY + 20, width - 40, 25);
|
float dy = height * GAP_Y_FACTOR;
|
||||||
|
scroller.setBounds(0, startY + dy, width, height - startY - dy);
|
||||||
|
|
||||||
|
float x = width * INSETS_FACTOR;
|
||||||
|
float y = 0;
|
||||||
|
float panelWidth = width - 2 * x;
|
||||||
|
float panelHeight;
|
||||||
|
|
||||||
|
for (SettingPanel panel : settingPanels) {
|
||||||
|
panelHeight = panel.getPreferredHeight();
|
||||||
|
panel.setBounds(x, y, panelWidth, panelHeight);
|
||||||
|
y += panelHeight + dy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private abstract class SettingPanel extends FContainer {
|
||||||
|
public abstract float getPreferredHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ComboBoxPanel<E> extends SettingPanel {
|
||||||
|
private final FLabel label;
|
||||||
|
private final FComboBox<E> comboBox;
|
||||||
|
|
||||||
|
public ComboBoxPanel(String labelText) {
|
||||||
|
this(labelText, new FComboBox<E>());
|
||||||
|
}
|
||||||
|
public ComboBoxPanel(String labelText, E[] items) {
|
||||||
|
this(labelText, new FComboBox<E>(items));
|
||||||
|
}
|
||||||
|
public ComboBoxPanel(String labelText, Iterable<E> items) {
|
||||||
|
this(labelText, new FComboBox<E>(items));
|
||||||
|
}
|
||||||
|
|
||||||
|
private ComboBoxPanel(String labelText, FComboBox<E> comboBox0) {
|
||||||
|
label = add(new FLabel.Builder().text(labelText).build());
|
||||||
|
comboBox = add(comboBox0);
|
||||||
|
label.setHeight(FComboBox.PREFERRED_HEIGHT - 6);
|
||||||
|
comboBox.setHeight(FComboBox.PREFERRED_HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doLayout(float width, float height) {
|
||||||
|
label.setBounds(0, 0, width, label.getHeight());
|
||||||
|
comboBox.setBounds(0, label.getHeight(), width, comboBox.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getPreferredHeight() {
|
||||||
|
return label.getHeight() + comboBox.getHeight();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
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.utils.Utils;
|
||||||
|
|
||||||
public class FComboBox<E> extends FDisplayObject {
|
public class FComboBox<E> extends FDisplayObject {
|
||||||
|
public static final float PREFERRED_HEIGHT = Utils.AVG_FINGER_HEIGHT * 0.7f;
|
||||||
|
|
||||||
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 BACK_COLOR = FSkinColor.get(Colors.CLR_THEME2);
|
private static final FSkinColor BACK_COLOR = FSkinColor.get(Colors.CLR_THEME2);
|
||||||
private static final FSkinColor BORDER_COLOR = BACK_COLOR.getContrastColor(10);
|
private static final FSkinColor BORDER_COLOR = BACK_COLOR.getContrastColor(10);
|
||||||
@@ -84,16 +86,10 @@ public class FComboBox<E> extends FDisplayObject {
|
|||||||
g.fillRect(BACK_COLOR, 0, 0, w, h);
|
g.fillRect(BACK_COLOR, 0, 0, w, h);
|
||||||
g.drawRect(BORDER_COLOR, 0, 0, w, h);
|
g.drawRect(BORDER_COLOR, 0, 0, w, h);
|
||||||
|
|
||||||
float shapeWidth = 8;
|
float shapeWidth = PREFERRED_HEIGHT / 3;
|
||||||
float shapeHeight = 8;
|
float shapeHeight = shapeWidth;
|
||||||
float x = w - shapeWidth - 6;
|
float x = w - 2 * (shapeWidth - 1);
|
||||||
float y = h / 2 - 1;
|
float y = h / 2 - 1;
|
||||||
if (getHeight() > 26) { //increase arrow size if taller combo box
|
|
||||||
shapeWidth += 2;
|
|
||||||
shapeHeight += 2;
|
|
||||||
x -= 4;
|
|
||||||
y--;
|
|
||||||
}
|
|
||||||
g.fillTriangle(FORE_COLOR, x, y, x + shapeWidth, y, x + (shapeWidth / 2), y + (shapeHeight / 2));
|
g.fillTriangle(FORE_COLOR, x, y, x + shapeWidth, y, x + (shapeWidth / 2), y + (shapeHeight / 2));
|
||||||
|
|
||||||
E selectedItem = getSelectedItem();
|
E selectedItem = getSelectedItem();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class FLabel extends FDisplayObject {
|
|||||||
public static class Builder {
|
public static class Builder {
|
||||||
//========== Default values for FLabel are set here.
|
//========== Default values for FLabel are set here.
|
||||||
private float bldIconScaleFactor = 0.8f;
|
private float bldIconScaleFactor = 0.8f;
|
||||||
private int bldFontSize = 14;
|
private int bldFontSize = 12;
|
||||||
private HAlignment bldAlignment = HAlignment.LEFT;
|
private HAlignment bldAlignment = HAlignment.LEFT;
|
||||||
private Vector2 bldInsets = new Vector2(0, 0);
|
private Vector2 bldInsets = new Vector2(0, 0);
|
||||||
|
|
||||||
|
|||||||
8
forge-m-base/src/forge/toolbox/FScrollPane.java
Normal file
8
forge-m-base/src/forge/toolbox/FScrollPane.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package forge.toolbox;
|
||||||
|
|
||||||
|
public class FScrollPane extends FContainer {
|
||||||
|
@Override
|
||||||
|
protected void doLayout(float width, float height) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user