mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
[Mobile] Add "Match: Number" Selection
This commit is contained in:
@@ -70,6 +70,10 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
|
|||||||
private final FLabel lblVariants = new FLabel.Builder().text(localizer.getMessage("lblVariants") + ":").font(VARIANTS_FONT).build();
|
private final FLabel lblVariants = new FLabel.Builder().text(localizer.getMessage("lblVariants") + ":").font(VARIANTS_FONT).build();
|
||||||
private final FComboBox<Object> cbVariants = new FComboBox<>();
|
private final FComboBox<Object> cbVariants = new FComboBox<>();
|
||||||
|
|
||||||
|
// Max games in a match frame and variables
|
||||||
|
private final FLabel lblGamesInMatch = new FLabel.Builder().text(localizer.getMessage("lblMatch") + ":").font(VARIANTS_FONT).build();
|
||||||
|
private final FComboBox<String> cbGamesInMatch = new FComboBox<>();
|
||||||
|
|
||||||
private final List<PlayerPanel> playerPanels = new ArrayList<>(MAX_PLAYERS);
|
private final List<PlayerPanel> playerPanels = new ArrayList<>(MAX_PLAYERS);
|
||||||
private final FScrollPane playersScroll = new FScrollPane() {
|
private final FScrollPane playersScroll = new FScrollPane() {
|
||||||
@Override
|
@Override
|
||||||
@@ -127,6 +131,20 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
|
|||||||
|
|
||||||
initLobby(lobby0);
|
initLobby(lobby0);
|
||||||
|
|
||||||
|
add(lblGamesInMatch);
|
||||||
|
add(cbGamesInMatch);
|
||||||
|
cbGamesInMatch.setFont(VARIANTS_FONT);
|
||||||
|
cbGamesInMatch.addItem("1");
|
||||||
|
cbGamesInMatch.addItem("3");
|
||||||
|
cbGamesInMatch.addItem("5");
|
||||||
|
cbGamesInMatch.setSelectedItem(FModel.getPreferences().getPref((FPref.UI_MATCHES_PER_GAME)));
|
||||||
|
cbGamesInMatch.setChangedHandler(new FEventHandler() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(FEvent e) {
|
||||||
|
FModel.getPreferences().setPref(FPref.UI_MATCHES_PER_GAME, cbGamesInMatch.getSelectedItem());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
add(lblVariants);
|
add(lblVariants);
|
||||||
add(cbVariants);
|
add(cbVariants);
|
||||||
cbVariants.setFont(VARIANTS_FONT);
|
cbVariants.setFont(VARIANTS_FONT);
|
||||||
@@ -207,6 +225,8 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
|
|||||||
btnStart.setEnabled(hasControl);
|
btnStart.setEnabled(hasControl);
|
||||||
lblVariants.setEnabled(hasControl);
|
lblVariants.setEnabled(hasControl);
|
||||||
cbVariants.setEnabled(hasControl);
|
cbVariants.setEnabled(hasControl);
|
||||||
|
lblGamesInMatch.setEnabled(hasControl);
|
||||||
|
cbGamesInMatch.setEnabled(hasControl);
|
||||||
lblPlayers.setEnabled(hasControl);
|
lblPlayers.setEnabled(hasControl);
|
||||||
cbPlayerCount.setEnabled(hasControl);
|
cbPlayerCount.setEnabled(hasControl);
|
||||||
while (lobby.getNumberOfSlots() < getNumPlayers()){
|
while (lobby.getNumberOfSlots() < getNumPlayers()){
|
||||||
@@ -252,23 +272,18 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
|
|||||||
float x = PADDING;
|
float x = PADDING;
|
||||||
float y = startY + PADDING;
|
float y = startY + PADDING;
|
||||||
float fieldHeight = cbPlayerCount.getHeight();
|
float fieldHeight = cbPlayerCount.getHeight();
|
||||||
if (Forge.isLandscapeMode()) {
|
lblVariants.setBounds(x, y, lblVariants.getAutoSizeBounds().width + PADDING / 2, fieldHeight);
|
||||||
lblVariants.setBounds(x, y, lblVariants.getAutoSizeBounds().width + PADDING / 2, fieldHeight);
|
x += lblVariants.getWidth();
|
||||||
x += lblVariants.getWidth();
|
cbVariants.setBounds(x, y, width - (x + lblGamesInMatch.getAutoSizeBounds().width + PADDING/2
|
||||||
cbVariants.setBounds(x, y, width - (x + lblPlayers.getAutoSizeBounds().width + PADDING/2 + Utils.AVG_FINGER_WIDTH + PADDING), fieldHeight);
|
+ lblPlayers.getAutoSizeBounds().width + (Utils.AVG_FINGER_WIDTH + PADDING)*2), fieldHeight);
|
||||||
x += cbVariants.getWidth();
|
x += cbVariants.getWidth();
|
||||||
lblPlayers.setBounds(x, y, lblPlayers.getAutoSizeBounds().width + PADDING / 2, fieldHeight);
|
lblPlayers.setBounds(x, y, lblPlayers.getAutoSizeBounds().width + PADDING / 2, fieldHeight);
|
||||||
x += lblPlayers.getWidth();
|
x += lblPlayers.getWidth();
|
||||||
cbPlayerCount.setBounds(x, y, Utils.AVG_FINGER_WIDTH, fieldHeight);
|
cbPlayerCount.setBounds(x, y, Utils.AVG_FINGER_WIDTH, fieldHeight);
|
||||||
} else {
|
x += cbPlayerCount.getWidth() + PADDING;
|
||||||
lblPlayers.setBounds(x, y, lblPlayers.getAutoSizeBounds().width + PADDING / 2, fieldHeight);
|
lblGamesInMatch.setBounds(x, y, lblGamesInMatch.getAutoSizeBounds().width + PADDING / 2, fieldHeight);
|
||||||
x += lblPlayers.getWidth();
|
x += lblGamesInMatch.getWidth();
|
||||||
cbPlayerCount.setBounds(x, y, Utils.AVG_FINGER_WIDTH, fieldHeight);
|
cbGamesInMatch.setBounds(x, y, Utils.AVG_FINGER_WIDTH, fieldHeight);
|
||||||
x += cbPlayerCount.getWidth() + PADDING;
|
|
||||||
lblVariants.setBounds(x, y, lblVariants.getAutoSizeBounds().width + PADDING / 2, fieldHeight);
|
|
||||||
x += lblVariants.getWidth();
|
|
||||||
cbVariants.setBounds(x, y, width - x - PADDING, fieldHeight);
|
|
||||||
}
|
|
||||||
y += cbPlayerCount.getHeight() + PADDING;
|
y += cbPlayerCount.getHeight() + PADDING;
|
||||||
playersScroll.setBounds(0, y, width, height - y);
|
playersScroll.setBounds(0, y, width, height - y);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user