mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Support screen with one or more tab pages and use for settings screen
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1145,6 +1145,7 @@ forge-gui-mobile/src/forge/menu/FTooltip.java -text
|
|||||||
forge-gui-mobile/src/forge/screens/FScreen.java -text
|
forge-gui-mobile/src/forge/screens/FScreen.java -text
|
||||||
forge-gui-mobile/src/forge/screens/LaunchScreen.java -text
|
forge-gui-mobile/src/forge/screens/LaunchScreen.java -text
|
||||||
forge-gui-mobile/src/forge/screens/SplashScreen.java -text
|
forge-gui-mobile/src/forge/screens/SplashScreen.java -text
|
||||||
|
forge-gui-mobile/src/forge/screens/TabPageScreen.java -text
|
||||||
forge-gui-mobile/src/forge/screens/constructed/AvatarSelector.java -text
|
forge-gui-mobile/src/forge/screens/constructed/AvatarSelector.java -text
|
||||||
forge-gui-mobile/src/forge/screens/constructed/ConstructedScreen.java -text
|
forge-gui-mobile/src/forge/screens/constructed/ConstructedScreen.java -text
|
||||||
forge-gui-mobile/src/forge/screens/draft/DraftScreen.java -text
|
forge-gui-mobile/src/forge/screens/draft/DraftScreen.java -text
|
||||||
@@ -1175,6 +1176,7 @@ forge-gui-mobile/src/forge/screens/match/winlose/LimitedWinLose.java -text
|
|||||||
forge-gui-mobile/src/forge/screens/match/winlose/ViewWinLose.java -text
|
forge-gui-mobile/src/forge/screens/match/winlose/ViewWinLose.java -text
|
||||||
forge-gui-mobile/src/forge/screens/quest/QuestScreen.java -text
|
forge-gui-mobile/src/forge/screens/quest/QuestScreen.java -text
|
||||||
forge-gui-mobile/src/forge/screens/sealed/SealedScreen.java -text
|
forge-gui-mobile/src/forge/screens/sealed/SealedScreen.java -text
|
||||||
|
forge-gui-mobile/src/forge/screens/settings/SettingsPage.java -text
|
||||||
forge-gui-mobile/src/forge/screens/settings/SettingsScreen.java -text
|
forge-gui-mobile/src/forge/screens/settings/SettingsScreen.java -text
|
||||||
forge-gui-mobile/src/forge/toolbox/DualListBox.java -text
|
forge-gui-mobile/src/forge/toolbox/DualListBox.java -text
|
||||||
forge-gui-mobile/src/forge/toolbox/FButton.java -text
|
forge-gui-mobile/src/forge/toolbox/FButton.java -text
|
||||||
|
|||||||
@@ -83,21 +83,20 @@ public abstract class FScreen extends FContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Header extends FContainer {
|
public static abstract class Header extends FContainer {
|
||||||
protected static final FSkinColor BTN_PRESSED_COLOR = TEXTURE_OVERLAY_COLOR.alphaColor(1f);
|
public static final FSkinColor BTN_PRESSED_COLOR = TEXTURE_OVERLAY_COLOR.alphaColor(1f);
|
||||||
protected static final FSkinColor LINE_COLOR = BTN_PRESSED_COLOR.stepColor(-40);
|
public static final FSkinColor LINE_COLOR = BTN_PRESSED_COLOR.stepColor(-40);
|
||||||
protected static final FSkinColor BACK_COLOR = BTN_PRESSED_COLOR.stepColor(-80);
|
public static final FSkinColor BACK_COLOR = BTN_PRESSED_COLOR.stepColor(-80);
|
||||||
protected static final float LINE_THICKNESS = Utils.scaleY(1);
|
public static final float LINE_THICKNESS = Utils.scaleY(1);
|
||||||
|
|
||||||
public abstract float getPreferredHeight();
|
public abstract float getPreferredHeight();
|
||||||
}
|
}
|
||||||
private static class DefaultHeader extends Header {
|
private static class DefaultHeader extends Header {
|
||||||
protected static final float HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.8f);
|
private static final float HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.8f);
|
||||||
private static final FSkinFont FONT = FSkinFont.get(16);
|
private static final FSkinFont FONT = FSkinFont.get(16);
|
||||||
|
|
||||||
private final FLabel lblCaption, btnBack;
|
private final FLabel btnBack, lblCaption;
|
||||||
|
|
||||||
public DefaultHeader(String headerCaption) {
|
public DefaultHeader(String headerCaption) {
|
||||||
lblCaption = add(new FLabel.Builder().text(headerCaption).font(FONT).align(HAlignment.CENTER).build());
|
|
||||||
btnBack = add(new FLabel.Builder().icon(new BackIcon(HEIGHT, HEIGHT)).pressedColor(BTN_PRESSED_COLOR).align(HAlignment.CENTER).command(new FEventHandler() {
|
btnBack = add(new FLabel.Builder().icon(new BackIcon(HEIGHT, HEIGHT)).pressedColor(BTN_PRESSED_COLOR).align(HAlignment.CENTER).command(new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
@@ -105,6 +104,7 @@ public abstract class FScreen extends FContainer {
|
|||||||
}
|
}
|
||||||
}).build());
|
}).build());
|
||||||
btnBack.setSize(HEIGHT, HEIGHT);
|
btnBack.setSize(HEIGHT, HEIGHT);
|
||||||
|
lblCaption = add(new FLabel.Builder().text(headerCaption).font(FONT).align(HAlignment.CENTER).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -125,16 +125,16 @@ public abstract class FScreen extends FContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLayout(float width, float height) {
|
protected void doLayout(float width, float height) {
|
||||||
lblCaption.setBounds(0, 0, width, height);
|
lblCaption.setBounds(height, 0, width - 2 * height, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class BackIcon implements FImage {
|
protected static class BackIcon implements FImage {
|
||||||
private static final float THICKNESS = Utils.scaleMax(3);
|
private static final float THICKNESS = Utils.scaleMax(3);
|
||||||
private static final FSkinColor COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
private static final FSkinColor COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||||
|
|
||||||
private final float width, height;
|
private final float width, height;
|
||||||
private BackIcon(float width0, float height0) {
|
public BackIcon(float width0, float height0) {
|
||||||
width = width0;
|
width = width0;
|
||||||
height = height0;
|
height = height0;
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ public abstract class FScreen extends FContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics g, float x, float y, float w, float h) {
|
public void draw(Graphics g, float x, float y, float w, float h) {
|
||||||
float xMid = x + w / 3;
|
float xMid = x + w * 0.4f;
|
||||||
float yMid = y + h / 2;
|
float yMid = y + h / 2;
|
||||||
float offsetX = h / 8;
|
float offsetX = h / 8;
|
||||||
float offsetY = w / 4;
|
float offsetY = w / 4;
|
||||||
|
|||||||
176
forge-gui-mobile/src/forge/screens/TabPageScreen.java
Normal file
176
forge-gui-mobile/src/forge/screens/TabPageScreen.java
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
package forge.screens;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||||
|
|
||||||
|
import forge.Forge;
|
||||||
|
import forge.Forge.Graphics;
|
||||||
|
import forge.assets.FImage;
|
||||||
|
import forge.assets.FSkinColor;
|
||||||
|
import forge.assets.FSkinFont;
|
||||||
|
import forge.assets.FSkinColor.Colors;
|
||||||
|
import forge.toolbox.FContainer;
|
||||||
|
import forge.toolbox.FDisplayObject;
|
||||||
|
import forge.toolbox.FEvent;
|
||||||
|
import forge.toolbox.FLabel;
|
||||||
|
import forge.toolbox.FScrollPane;
|
||||||
|
import forge.toolbox.FEvent.FEventHandler;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
|
public class TabPageScreen extends FScreen {
|
||||||
|
private final TabPage[] tabPages;
|
||||||
|
private TabPage selectedPage;
|
||||||
|
|
||||||
|
public TabPageScreen(TabPage[] tabPages0) {
|
||||||
|
super(new TabHeader(tabPages0));
|
||||||
|
|
||||||
|
tabPages = tabPages0;
|
||||||
|
for (TabPage tabPage : tabPages) {
|
||||||
|
tabPage.parentScreen = this;
|
||||||
|
add(tabPage);
|
||||||
|
tabPage.setVisible(false);
|
||||||
|
}
|
||||||
|
setSelectedPage(tabPages[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TabPage getSelectedPage() {
|
||||||
|
return selectedPage;
|
||||||
|
}
|
||||||
|
public void setSelectedPage(TabPage tabPage0) {
|
||||||
|
if (selectedPage == tabPage0) { return; }
|
||||||
|
|
||||||
|
if (selectedPage != null) {
|
||||||
|
selectedPage.setVisible(false);
|
||||||
|
}
|
||||||
|
selectedPage = tabPage0;
|
||||||
|
if (selectedPage != null) {
|
||||||
|
selectedPage.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doLayout(float startY, float width, float height) {
|
||||||
|
height -= startY;
|
||||||
|
for (TabPage tabPage : tabPages) {
|
||||||
|
tabPage.setBounds(0, startY, width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class TabHeader extends Header {
|
||||||
|
public static final float HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 1.6f);
|
||||||
|
public static final float TAB_WIDTH = HEIGHT * 1.2f;
|
||||||
|
private static final float BACK_BUTTON_WIDTH = HEIGHT / 2;
|
||||||
|
private static final FSkinColor SEPARATOR_COLOR = BACK_COLOR.stepColor(-40);
|
||||||
|
|
||||||
|
private final FLabel btnBack;
|
||||||
|
private final FScrollPane scroller;
|
||||||
|
|
||||||
|
public TabHeader(TabPage[] tabPages) {
|
||||||
|
btnBack = add(new FLabel.Builder().iconScaleAuto(false).icon(new BackIcon(BACK_BUTTON_WIDTH, BACK_BUTTON_WIDTH)).pressedColor(BTN_PRESSED_COLOR).align(HAlignment.CENTER).command(new FEventHandler() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(FEvent e) {
|
||||||
|
Forge.back();
|
||||||
|
}
|
||||||
|
}).build());
|
||||||
|
btnBack.setSize(BACK_BUTTON_WIDTH, HEIGHT);
|
||||||
|
|
||||||
|
scroller = add(new FScrollPane() {
|
||||||
|
@Override
|
||||||
|
protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) {
|
||||||
|
float x = 0;
|
||||||
|
for (FDisplayObject tab : getChildren()) {
|
||||||
|
tab.setBounds(x, 0, TAB_WIDTH, visibleHeight);
|
||||||
|
x += TAB_WIDTH;
|
||||||
|
}
|
||||||
|
return new ScrollBounds(x, visibleHeight);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (TabPage tabPage : tabPages) {
|
||||||
|
scroller.add(tabPage.createTab());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getPreferredHeight() {
|
||||||
|
return HEIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawBackground(Graphics g) {
|
||||||
|
g.fillRect(BACK_COLOR, 0, 0, getWidth(), HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawOverlay(Graphics g) {
|
||||||
|
//draw right border for back button
|
||||||
|
float x = btnBack.getWidth() - LINE_THICKNESS / 2;
|
||||||
|
g.drawLine(LINE_THICKNESS, SEPARATOR_COLOR, x, 0, x, getHeight());
|
||||||
|
|
||||||
|
//draw bottom border for header
|
||||||
|
float y = HEIGHT - LINE_THICKNESS / 2;
|
||||||
|
g.drawLine(LINE_THICKNESS, LINE_COLOR, 0, y, getWidth(), y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doLayout(float width, float height) {
|
||||||
|
scroller.setBounds(btnBack.getWidth(), 0, width - btnBack.getWidth(), height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static abstract class TabPage extends FContainer {
|
||||||
|
private static final float TAB_PADDING = TabHeader.HEIGHT * 0.1f;
|
||||||
|
private static final FSkinColor SEL_TAB_COLOR = FSkinColor.get(Colors.CLR_ACTIVE);
|
||||||
|
private static final FSkinColor TAB_FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||||
|
private static final FSkinFont TAB_FONT = FSkinFont.get(12);
|
||||||
|
|
||||||
|
private TabPageScreen parentScreen;
|
||||||
|
private final String caption;
|
||||||
|
private final FImage icon;
|
||||||
|
|
||||||
|
protected TabPage(String caption0, FImage icon0) {
|
||||||
|
caption = caption0;
|
||||||
|
icon = icon0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FDisplayObject createTab() {
|
||||||
|
return new Tab();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Tab extends FDisplayObject {
|
||||||
|
@Override
|
||||||
|
public boolean tap(float x, float y, int count) {
|
||||||
|
parentScreen.setSelectedPage(TabPage.this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Graphics g) {
|
||||||
|
float w = getWidth();
|
||||||
|
float h = getHeight();
|
||||||
|
if (parentScreen.getSelectedPage() == TabPage.this) {
|
||||||
|
g.fillRect(SEL_TAB_COLOR, Header.LINE_THICKNESS / 2, 0, w - Header.LINE_THICKNESS, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
//draw caption
|
||||||
|
float y = h - TAB_PADDING - TAB_FONT.getCapHeight();
|
||||||
|
g.drawText(caption, TAB_FONT, TAB_FORE_COLOR, 0, y, w, h - y, false, HAlignment.CENTER, false);
|
||||||
|
|
||||||
|
//draw icon if one
|
||||||
|
if (icon != null) {
|
||||||
|
float iconHeight = y - 2 * TAB_PADDING;
|
||||||
|
float iconWidth = iconHeight * icon.getWidth() / icon.getHeight();
|
||||||
|
float maxWidth = w - 2 * TAB_PADDING;
|
||||||
|
if (iconWidth > maxWidth) {
|
||||||
|
iconHeight *= maxWidth / iconWidth;
|
||||||
|
iconWidth = maxWidth;
|
||||||
|
}
|
||||||
|
g.drawImage(icon, (w - iconWidth) / 2, (y - iconHeight) / 2, iconWidth, iconHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
//draw right border
|
||||||
|
float x = getWidth() - Header.LINE_THICKNESS / 2;
|
||||||
|
g.drawLine(Header.LINE_THICKNESS, TabHeader.SEPARATOR_COLOR, x, 0, x, h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
303
forge-gui-mobile/src/forge/screens/settings/SettingsPage.java
Normal file
303
forge-gui-mobile/src/forge/screens/settings/SettingsPage.java
Normal file
@@ -0,0 +1,303 @@
|
|||||||
|
package forge.screens.settings;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||||
|
|
||||||
|
import forge.Forge;
|
||||||
|
import forge.Forge.Graphics;
|
||||||
|
import forge.ai.AiProfileUtil;
|
||||||
|
import forge.assets.FSkin;
|
||||||
|
import forge.assets.FSkinColor;
|
||||||
|
import forge.assets.FSkinFont;
|
||||||
|
import forge.assets.FSkinImage;
|
||||||
|
import forge.game.GameLogEntryType;
|
||||||
|
import forge.model.FModel;
|
||||||
|
import forge.properties.ForgePreferences;
|
||||||
|
import forge.properties.ForgePreferences.FPref;
|
||||||
|
import forge.screens.FScreen;
|
||||||
|
import forge.screens.TabPageScreen.TabPage;
|
||||||
|
import forge.toolbox.FCheckBox;
|
||||||
|
import forge.toolbox.FGroupList;
|
||||||
|
import forge.toolbox.FList;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
|
public class SettingsPage extends TabPage {
|
||||||
|
private final FGroupList<Setting> lstSettings = add(new FGroupList<Setting>());
|
||||||
|
|
||||||
|
public SettingsPage() {
|
||||||
|
super("Settings", FSkinImage.SETTINGS);
|
||||||
|
|
||||||
|
lstSettings.setListItemRenderer(new SettingRenderer());
|
||||||
|
|
||||||
|
lstSettings.addGroup("General Settings");
|
||||||
|
lstSettings.addGroup("Gameplay Options");
|
||||||
|
lstSettings.addGroup("Random Deck Generation");
|
||||||
|
lstSettings.addGroup("Advanced Settings");
|
||||||
|
lstSettings.addGroup("Graphic Options");
|
||||||
|
//lstSettings.addGroup("Sound Options"); //TODO: Uncomment when sound supported
|
||||||
|
|
||||||
|
//General Settings
|
||||||
|
lstSettings.addItem(new CustomSelectSetting(FPref.UI_SKIN, "Theme",
|
||||||
|
"Sets the theme that determines how display components are skinned.",
|
||||||
|
FSkin.getAllSkins()) {
|
||||||
|
@Override
|
||||||
|
public void valueChanged(String newValue) {
|
||||||
|
FSkin.changeSkin(newValue);
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
//Gameplay Options
|
||||||
|
lstSettings.addItem(new CustomSelectSetting(FPref.UI_CURRENT_AI_PROFILE,
|
||||||
|
"AI Personality",
|
||||||
|
"Choose your AI opponent.",
|
||||||
|
AiProfileUtil.getProfilesArray()),
|
||||||
|
1);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.UI_ANTE,
|
||||||
|
"Play for Ante",
|
||||||
|
"Determines whether or not the game is played for ante."),
|
||||||
|
1);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.UI_ANTE_MATCH_RARITY,
|
||||||
|
"Match Ante Rarity",
|
||||||
|
"Attempts to make antes the same rarity for all players."),
|
||||||
|
1);
|
||||||
|
/*lstSettings.addItem(new BooleanSetting(FPref.UI_UPLOAD_DRAFT,
|
||||||
|
"Upload Draft Picks",
|
||||||
|
"Sends draft picks to Forge servers for analysis, to improve draft AI."),
|
||||||
|
1);*/
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_AI_CHEATS,
|
||||||
|
"Allow AI Cheating",
|
||||||
|
"Allow the AI to cheat to gain advantage (for personalities that have cheat shuffling options set)."),
|
||||||
|
1);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.UI_MANABURN,
|
||||||
|
"Mana Burn",
|
||||||
|
"Play with mana burn (from pre-Magic 2010 rules)."),
|
||||||
|
1);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.ENFORCE_DECK_LEGALITY,
|
||||||
|
"Deck Conformance",
|
||||||
|
"Enforces deck legality relevant to each environment (minimum deck sizes, max card count etc)."),
|
||||||
|
1);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.UI_CLONE_MODE_SOURCE,
|
||||||
|
"Clones Use Original Card Art",
|
||||||
|
"When enabled clones will use their original art instead of the cloned card's art."),
|
||||||
|
1);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.MATCHPREF_PROMPT_FREE_BLOCKS,
|
||||||
|
"Free Block Handling",
|
||||||
|
"When enabled, if you would have to pay 0 to block, pay automatically without prompt."),
|
||||||
|
1);
|
||||||
|
|
||||||
|
//Random Deck Generation
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.DECKGEN_NOSMALL,
|
||||||
|
"Remove Small Creatures",
|
||||||
|
"Disables 1/1 and 0/X creatures in generated decks."),
|
||||||
|
2);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.DECKGEN_SINGLETONS,
|
||||||
|
"Singleton Mode",
|
||||||
|
"Disables non-land duplicates in generated decks."),
|
||||||
|
2);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.DECKGEN_ARTIFACTS,
|
||||||
|
"Remove Artifacts",
|
||||||
|
"Disables artifact cards in generated decks."),
|
||||||
|
2);
|
||||||
|
|
||||||
|
//Advanced Settings
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.DEV_MODE_ENABLED,
|
||||||
|
"Developer Mode",
|
||||||
|
"Enables menu with functions for testing during development.") {
|
||||||
|
@Override
|
||||||
|
public void select() {
|
||||||
|
super.select();
|
||||||
|
//update DEV_MODE flag when preference changes
|
||||||
|
ForgePreferences.DEV_MODE = FModel.getPreferences().getPrefBoolean(FPref.DEV_MODE_ENABLED);
|
||||||
|
}
|
||||||
|
}, 3);
|
||||||
|
lstSettings.addItem(new CustomSelectSetting(FPref.DEV_LOG_ENTRY_TYPE,
|
||||||
|
"Game Log Verbosity",
|
||||||
|
"Changes how much information is displayed in the game log. Sorted by least to most verbose.",
|
||||||
|
GameLogEntryType.class),
|
||||||
|
3);
|
||||||
|
|
||||||
|
//Graphic Options
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.UI_OVERLAY_FOIL_EFFECT,
|
||||||
|
"Display Foil Overlay",
|
||||||
|
"Displays foil cards with the visual foil overlay effect."),
|
||||||
|
4);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.UI_RANDOM_FOIL,
|
||||||
|
"Random Foil",
|
||||||
|
"Adds foil effect to random cards."),
|
||||||
|
4);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.UI_RANDOM_ART_IN_POOLS,
|
||||||
|
"Randomize Card Art",
|
||||||
|
"Generates cards with random art in generated limited mode card pools."),
|
||||||
|
4);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.UI_HIDE_REMINDER_TEXT,
|
||||||
|
"Hide Reminder Text",
|
||||||
|
"Hide reminder text in Card Detail pane."),
|
||||||
|
4);
|
||||||
|
|
||||||
|
//Sound Options
|
||||||
|
/*lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_SOUNDS,
|
||||||
|
"Enable Sounds",
|
||||||
|
"Enable sound effects during the game."),
|
||||||
|
5);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.UI_ALT_SOUND_SYSTEM,
|
||||||
|
"Use Alternate Sound System",
|
||||||
|
"Use the alternate sound system (only use if you have issues with sound not playing or disappearing)."),
|
||||||
|
5);*/ //TODO: Uncomment when sound supported
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doLayout(float width, float height) {
|
||||||
|
lstSettings.setBounds(0, 0, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
private abstract class Setting {
|
||||||
|
protected String label;
|
||||||
|
protected String description;
|
||||||
|
protected FPref pref;
|
||||||
|
|
||||||
|
public Setting(FPref pref0, String label0, String description0) {
|
||||||
|
label = label0;
|
||||||
|
description = description0;
|
||||||
|
pref = pref0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void select();
|
||||||
|
public abstract void drawPrefValue(Graphics g, FSkinFont font, FSkinColor color, float x, float y, float width, float height);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class BooleanSetting extends Setting {
|
||||||
|
public BooleanSetting(FPref pref0, String label0, String description0) {
|
||||||
|
super(pref0, label0, description0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void select() {
|
||||||
|
FModel.getPreferences().setPref(pref, !FModel.getPreferences().getPrefBoolean(pref));
|
||||||
|
FModel.getPreferences().save();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawPrefValue(Graphics g, FSkinFont font, FSkinColor color, float x, float y, float w, float h) {
|
||||||
|
x += w - h;
|
||||||
|
w = h;
|
||||||
|
FCheckBox.drawCheckBox(g, SettingsScreen.DESC_COLOR, color, FModel.getPreferences().getPrefBoolean(pref), x, y, w, h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CustomSelectSetting extends Setting {
|
||||||
|
private final List<String> options = new ArrayList<String>();
|
||||||
|
|
||||||
|
public CustomSelectSetting(FPref pref0, String label0, String description0, String[] options0) {
|
||||||
|
super(pref0, label0 + ":", description0);
|
||||||
|
|
||||||
|
for (String option : options0) {
|
||||||
|
options.add(option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public CustomSelectSetting(FPref pref0, String label0, String description0, Iterable<String> options0) {
|
||||||
|
super(pref0, label0 + ":", description0);
|
||||||
|
|
||||||
|
for (String option : options0) {
|
||||||
|
options.add(option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public <E extends Enum<E>> CustomSelectSetting(FPref pref0, String label0, String description0, Class<E> enumData) {
|
||||||
|
super(pref0, label0 + ":", description0);
|
||||||
|
|
||||||
|
for (E option : enumData.getEnumConstants()) {
|
||||||
|
options.add(option.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void valueChanged(String newValue) {
|
||||||
|
FModel.getPreferences().setPref(pref, newValue);
|
||||||
|
FModel.getPreferences().save();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void select() {
|
||||||
|
Forge.openScreen(new CustomSelectScreen());
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CustomSelectScreen extends FScreen {
|
||||||
|
private final FList<String> lstOptions;
|
||||||
|
private final String currentValue = FModel.getPreferences().getPref(pref);
|
||||||
|
|
||||||
|
private CustomSelectScreen() {
|
||||||
|
super("Select " + label.substring(0, label.length() - 1));
|
||||||
|
lstOptions = add(new FList<String>(options));
|
||||||
|
lstOptions.setListItemRenderer(new FList.DefaultListItemRenderer<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean tap(String value, float x, float y, int count) {
|
||||||
|
if (!value.equals(currentValue)) {
|
||||||
|
valueChanged(value);
|
||||||
|
}
|
||||||
|
Forge.back();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawValue(Graphics g, String value, FSkinFont font, FSkinColor foreColor, boolean pressed, float x, float y, float w, float h) {
|
||||||
|
float offset = w * SettingsScreen.INSETS_FACTOR - FList.PADDING; //increase padding for settings items
|
||||||
|
x += offset;
|
||||||
|
y += offset;
|
||||||
|
w -= 2 * offset;
|
||||||
|
h -= 2 * offset;
|
||||||
|
|
||||||
|
g.drawText(value, font, foreColor, x, y, w, h, false, HAlignment.LEFT, true);
|
||||||
|
|
||||||
|
float radius = h / 3;
|
||||||
|
x += w - radius;
|
||||||
|
y += h / 2;
|
||||||
|
g.drawCircle(Utils.scaleMin(1), SettingsScreen.DESC_COLOR, x, y, radius);
|
||||||
|
if (value.equals(currentValue)) {
|
||||||
|
g.fillCircle(foreColor, x, y, radius / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doLayout(float startY, float width, float height) {
|
||||||
|
lstOptions.setBounds(0, startY, width, height - startY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawPrefValue(Graphics g, FSkinFont font, FSkinColor color, float x, float y, float w, float h) {
|
||||||
|
g.drawText(FModel.getPreferences().getPref(pref), font, color, x, y, w, h, false, HAlignment.RIGHT, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SettingRenderer extends FList.ListItemRenderer<Setting> {
|
||||||
|
@Override
|
||||||
|
public float getItemHeight() {
|
||||||
|
return SettingsScreen.SETTING_HEIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean tap(Setting value, float x, float y, int count) {
|
||||||
|
value.select();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawValue(Graphics g, Setting value, FSkinFont font, FSkinColor color, boolean pressed, float x, float y, float w, float h) {
|
||||||
|
float offset = w * SettingsScreen.INSETS_FACTOR - FList.PADDING; //increase padding for settings items
|
||||||
|
x += offset;
|
||||||
|
y += offset;
|
||||||
|
w -= 2 * offset;
|
||||||
|
h -= 2 * offset;
|
||||||
|
|
||||||
|
float totalHeight = h;
|
||||||
|
h = font.getMultiLineBounds(value.label).height + SettingsScreen.SETTING_PADDING;
|
||||||
|
|
||||||
|
g.drawText(value.label, font, color, x, y, w, h, false, HAlignment.LEFT, false);
|
||||||
|
value.drawPrefValue(g, font, color, x, y, w, h);
|
||||||
|
h += SettingsScreen.SETTING_PADDING;
|
||||||
|
g.drawText(value.description, SettingsScreen.DESC_FONT, SettingsScreen.DESC_COLOR, x, y + h, w, totalHeight - h + w * SettingsScreen.INSETS_FACTOR, true, HAlignment.LEFT, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,312 +1,28 @@
|
|||||||
package forge.screens.settings;
|
package forge.screens.settings;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
|
||||||
|
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.Forge.Graphics;
|
|
||||||
import forge.ai.AiProfileUtil;
|
|
||||||
import forge.assets.FSkin;
|
|
||||||
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.game.GameLogEntryType;
|
import forge.screens.TabPageScreen;
|
||||||
import forge.model.FModel;
|
|
||||||
import forge.properties.ForgePreferences;
|
|
||||||
import forge.properties.ForgePreferences.FPref;
|
|
||||||
import forge.screens.FScreen;
|
|
||||||
import forge.toolbox.FCheckBox;
|
|
||||||
import forge.toolbox.FGroupList;
|
|
||||||
import forge.toolbox.FList;
|
|
||||||
import forge.util.Utils;
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class SettingsScreen extends FScreen {
|
public class SettingsScreen extends TabPageScreen {
|
||||||
public static final float INSETS_FACTOR = 0.025f;
|
public static final float INSETS_FACTOR = 0.025f;
|
||||||
public static final FSkinFont DESC_FONT = FSkinFont.get(11);
|
public static final FSkinFont DESC_FONT = FSkinFont.get(11);
|
||||||
public static final FSkinColor DESC_COLOR = FSkinColor.get(Colors.CLR_TEXT).alphaColor(0.5f);
|
public static final FSkinColor DESC_COLOR = FSkinColor.get(Colors.CLR_TEXT).alphaColor(0.5f);
|
||||||
private static final float SETTING_HEIGHT = Utils.AVG_FINGER_HEIGHT + Utils.scaleY(12);
|
protected static final float SETTING_HEIGHT = Utils.AVG_FINGER_HEIGHT + Utils.scaleY(12);
|
||||||
private static final float SETTING_PADDING = Utils.scaleY(5);
|
protected static final float SETTING_PADDING = Utils.scaleY(5);
|
||||||
|
|
||||||
private final FGroupList<Setting> lstSettings = add(new FGroupList<Setting>());
|
|
||||||
|
|
||||||
public SettingsScreen() {
|
public SettingsScreen() {
|
||||||
super("Settings");
|
super(new TabPage[] {
|
||||||
lstSettings.setListItemRenderer(new SettingRenderer());
|
new SettingsPage()
|
||||||
|
});
|
||||||
lstSettings.addGroup("General Settings");
|
// TODO Auto-generated constructor stub
|
||||||
lstSettings.addGroup("Gameplay Options");
|
|
||||||
lstSettings.addGroup("Random Deck Generation");
|
|
||||||
lstSettings.addGroup("Advanced Settings");
|
|
||||||
lstSettings.addGroup("Graphic Options");
|
|
||||||
//lstSettings.addGroup("Sound Options"); //TODO: Uncomment when sound supported
|
|
||||||
|
|
||||||
//General Settings
|
|
||||||
lstSettings.addItem(new CustomSelectSetting(FPref.UI_SKIN, "Theme",
|
|
||||||
"Sets the theme that determines how display components are skinned.",
|
|
||||||
FSkin.getAllSkins()) {
|
|
||||||
@Override
|
|
||||||
public void valueChanged(String newValue) {
|
|
||||||
FSkin.changeSkin(newValue);
|
|
||||||
}
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
//Gameplay Options
|
|
||||||
lstSettings.addItem(new CustomSelectSetting(FPref.UI_CURRENT_AI_PROFILE,
|
|
||||||
"AI Personality",
|
|
||||||
"Choose your AI opponent.",
|
|
||||||
AiProfileUtil.getProfilesArray()),
|
|
||||||
1);
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_ANTE,
|
|
||||||
"Play for Ante",
|
|
||||||
"Determines whether or not the game is played for ante."),
|
|
||||||
1);
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_ANTE_MATCH_RARITY,
|
|
||||||
"Match Ante Rarity",
|
|
||||||
"Attempts to make antes the same rarity for all players."),
|
|
||||||
1);
|
|
||||||
/*lstSettings.addItem(new BooleanSetting(FPref.UI_UPLOAD_DRAFT,
|
|
||||||
"Upload Draft Picks",
|
|
||||||
"Sends draft picks to Forge servers for analysis, to improve draft AI."),
|
|
||||||
1);*/
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_AI_CHEATS,
|
|
||||||
"Allow AI Cheating",
|
|
||||||
"Allow the AI to cheat to gain advantage (for personalities that have cheat shuffling options set)."),
|
|
||||||
1);
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_MANABURN,
|
|
||||||
"Mana Burn",
|
|
||||||
"Play with mana burn (from pre-Magic 2010 rules)."),
|
|
||||||
1);
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.ENFORCE_DECK_LEGALITY,
|
|
||||||
"Deck Conformance",
|
|
||||||
"Enforces deck legality relevant to each environment (minimum deck sizes, max card count etc)."),
|
|
||||||
1);
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_CLONE_MODE_SOURCE,
|
|
||||||
"Clones Use Original Card Art",
|
|
||||||
"When enabled clones will use their original art instead of the cloned card's art."),
|
|
||||||
1);
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.MATCHPREF_PROMPT_FREE_BLOCKS,
|
|
||||||
"Free Block Handling",
|
|
||||||
"When enabled, if you would have to pay 0 to block, pay automatically without prompt."),
|
|
||||||
1);
|
|
||||||
|
|
||||||
//Random Deck Generation
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.DECKGEN_NOSMALL,
|
|
||||||
"Remove Small Creatures",
|
|
||||||
"Disables 1/1 and 0/X creatures in generated decks."),
|
|
||||||
2);
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.DECKGEN_SINGLETONS,
|
|
||||||
"Singleton Mode",
|
|
||||||
"Disables non-land duplicates in generated decks."),
|
|
||||||
2);
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.DECKGEN_ARTIFACTS,
|
|
||||||
"Remove Artifacts",
|
|
||||||
"Disables artifact cards in generated decks."),
|
|
||||||
2);
|
|
||||||
|
|
||||||
//Advanced Settings
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.DEV_MODE_ENABLED,
|
|
||||||
"Developer Mode",
|
|
||||||
"Enables menu with functions for testing during development.") {
|
|
||||||
@Override
|
|
||||||
public void select() {
|
|
||||||
super.select();
|
|
||||||
//update DEV_MODE flag when preference changes
|
|
||||||
ForgePreferences.DEV_MODE = FModel.getPreferences().getPrefBoolean(FPref.DEV_MODE_ENABLED);
|
|
||||||
}
|
|
||||||
}, 3);
|
|
||||||
lstSettings.addItem(new CustomSelectSetting(FPref.DEV_LOG_ENTRY_TYPE,
|
|
||||||
"Game Log Verbosity",
|
|
||||||
"Changes how much information is displayed in the game log. Sorted by least to most verbose.",
|
|
||||||
GameLogEntryType.class),
|
|
||||||
3);
|
|
||||||
|
|
||||||
//Graphic Options
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_OVERLAY_FOIL_EFFECT,
|
|
||||||
"Display Foil Overlay",
|
|
||||||
"Displays foil cards with the visual foil overlay effect."),
|
|
||||||
4);
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_RANDOM_FOIL,
|
|
||||||
"Random Foil",
|
|
||||||
"Adds foil effect to random cards."),
|
|
||||||
4);
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_RANDOM_ART_IN_POOLS,
|
|
||||||
"Randomize Card Art",
|
|
||||||
"Generates cards with random art in generated limited mode card pools."),
|
|
||||||
4);
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_HIDE_REMINDER_TEXT,
|
|
||||||
"Hide Reminder Text",
|
|
||||||
"Hide reminder text in Card Detail pane."),
|
|
||||||
4);
|
|
||||||
|
|
||||||
//Sound Options
|
|
||||||
/*lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_SOUNDS,
|
|
||||||
"Enable Sounds",
|
|
||||||
"Enable sound effects during the game."),
|
|
||||||
5);
|
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_ALT_SOUND_SYSTEM,
|
|
||||||
"Use Alternate Sound System",
|
|
||||||
"Use the alternate sound system (only use if you have issues with sound not playing or disappearing)."),
|
|
||||||
5);*/ //TODO: Uncomment when sound supported
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showMenu() {
|
public void showMenu() {
|
||||||
Forge.back(); //hide settings screen when menu button pressed
|
Forge.back(); //hide settings screen when menu button pressed
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doLayout(float startY, float width, float height) {
|
|
||||||
lstSettings.setBounds(0, startY, width, height - startY);
|
|
||||||
}
|
|
||||||
|
|
||||||
private abstract class Setting {
|
|
||||||
protected String label;
|
|
||||||
protected String description;
|
|
||||||
protected FPref pref;
|
|
||||||
|
|
||||||
public Setting(FPref pref0, String label0, String description0) {
|
|
||||||
label = label0;
|
|
||||||
description = description0;
|
|
||||||
pref = pref0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void select();
|
|
||||||
public abstract void drawPrefValue(Graphics g, FSkinFont font, FSkinColor color, float x, float y, float width, float height);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class BooleanSetting extends Setting {
|
|
||||||
public BooleanSetting(FPref pref0, String label0, String description0) {
|
|
||||||
super(pref0, label0, description0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void select() {
|
|
||||||
FModel.getPreferences().setPref(pref, !FModel.getPreferences().getPrefBoolean(pref));
|
|
||||||
FModel.getPreferences().save();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawPrefValue(Graphics g, FSkinFont font, FSkinColor color, float x, float y, float w, float h) {
|
|
||||||
x += w - h;
|
|
||||||
w = h;
|
|
||||||
FCheckBox.drawCheckBox(g, DESC_COLOR, color, FModel.getPreferences().getPrefBoolean(pref), x, y, w, h);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CustomSelectSetting extends Setting {
|
|
||||||
private final List<String> options = new ArrayList<String>();
|
|
||||||
|
|
||||||
public CustomSelectSetting(FPref pref0, String label0, String description0, String[] options0) {
|
|
||||||
super(pref0, label0 + ":", description0);
|
|
||||||
|
|
||||||
for (String option : options0) {
|
|
||||||
options.add(option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public CustomSelectSetting(FPref pref0, String label0, String description0, Iterable<String> options0) {
|
|
||||||
super(pref0, label0 + ":", description0);
|
|
||||||
|
|
||||||
for (String option : options0) {
|
|
||||||
options.add(option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public <E extends Enum<E>> CustomSelectSetting(FPref pref0, String label0, String description0, Class<E> enumData) {
|
|
||||||
super(pref0, label0 + ":", description0);
|
|
||||||
|
|
||||||
for (E option : enumData.getEnumConstants()) {
|
|
||||||
options.add(option.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void valueChanged(String newValue) {
|
|
||||||
FModel.getPreferences().setPref(pref, newValue);
|
|
||||||
FModel.getPreferences().save();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void select() {
|
|
||||||
Forge.openScreen(new CustomSelectScreen());
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CustomSelectScreen extends FScreen {
|
|
||||||
private final FList<String> lstOptions;
|
|
||||||
private final String currentValue = FModel.getPreferences().getPref(pref);
|
|
||||||
|
|
||||||
private CustomSelectScreen() {
|
|
||||||
super("Select " + label.substring(0, label.length() - 1));
|
|
||||||
lstOptions = add(new FList<String>(options));
|
|
||||||
lstOptions.setListItemRenderer(new FList.DefaultListItemRenderer<String>() {
|
|
||||||
@Override
|
|
||||||
public boolean tap(String value, float x, float y, int count) {
|
|
||||||
if (!value.equals(currentValue)) {
|
|
||||||
valueChanged(value);
|
|
||||||
}
|
|
||||||
Forge.back();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawValue(Graphics g, String value, FSkinFont font, FSkinColor foreColor, boolean pressed, float x, float y, float w, float h) {
|
|
||||||
float offset = w * INSETS_FACTOR - FList.PADDING; //increase padding for settings items
|
|
||||||
x += offset;
|
|
||||||
y += offset;
|
|
||||||
w -= 2 * offset;
|
|
||||||
h -= 2 * offset;
|
|
||||||
|
|
||||||
g.drawText(value, font, foreColor, x, y, w, h, false, HAlignment.LEFT, true);
|
|
||||||
|
|
||||||
float radius = h / 3;
|
|
||||||
x += w - radius;
|
|
||||||
y += h / 2;
|
|
||||||
g.drawCircle(Utils.scaleMin(1), DESC_COLOR, x, y, radius);
|
|
||||||
if (value.equals(currentValue)) {
|
|
||||||
g.fillCircle(foreColor, x, y, radius / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doLayout(float startY, float width, float height) {
|
|
||||||
lstOptions.setBounds(0, startY, width, height - startY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawPrefValue(Graphics g, FSkinFont font, FSkinColor color, float x, float y, float w, float h) {
|
|
||||||
g.drawText(FModel.getPreferences().getPref(pref), font, color, x, y, w, h, false, HAlignment.RIGHT, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SettingRenderer extends FList.ListItemRenderer<Setting> {
|
|
||||||
@Override
|
|
||||||
public float getItemHeight() {
|
|
||||||
return SETTING_HEIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean tap(Setting value, float x, float y, int count) {
|
|
||||||
value.select();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawValue(Graphics g, Setting value, FSkinFont font, FSkinColor color, boolean pressed, float x, float y, float w, float h) {
|
|
||||||
float offset = w * INSETS_FACTOR - FList.PADDING; //increase padding for settings items
|
|
||||||
x += offset;
|
|
||||||
y += offset;
|
|
||||||
w -= 2 * offset;
|
|
||||||
h -= 2 * offset;
|
|
||||||
|
|
||||||
float totalHeight = h;
|
|
||||||
h = font.getMultiLineBounds(value.label).height + SETTING_PADDING;
|
|
||||||
|
|
||||||
g.drawText(value.label, font, color, x, y, w, h, false, HAlignment.LEFT, false);
|
|
||||||
value.drawPrefValue(g, font, color, x, y, w, h);
|
|
||||||
h += SETTING_PADDING;
|
|
||||||
g.drawText(value.description, DESC_FONT, DESC_COLOR, x, y + h, w, totalHeight - h + w * INSETS_FACTOR, true, HAlignment.LEFT, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user