void update() { avatarLabel.setEnabled(mayEdit); avatarLabel.setIcon( FSkin.getAvatars().get(Integer.valueOf(type == LobbySlotType.OPEN ? -1 : avatarIndex))); avatarLabel.repaintSelf(); txtPlayerName.setEnabled(mayEdit); txtPlayerName.setText(type == LobbySlotType.OPEN ? StringUtils.EMPTY : playerName); nameRandomiser.setEnabled(mayEdit); deckLabel.setVisible(mayEdit); deckBtn.setVisible(mayEdit); chkReady.setVisible(type == LobbySlotType.LOCAL || type == LobbySlotType.REMOTE); chkReady.setEnabled(mayEdit); closeBtn.setVisible(mayRemove); if (mayRemove) { radioHuman.setEnabled(mayControl); radioAi.setEnabled(mayControl); radioOpen.setEnabled(mayControl); } else { radioHuman.setVisible(mayControl); radioAi.setVisible(mayControl); radioOpen.setVisible(mayControl); } radioHuman.setSelected(type == LobbySlotType.LOCAL); radioAi.setSelected(type == LobbySlotType.AI); radioOpen.setSelected(type == LobbySlotType.OPEN); updateVariantControlsVisibility(); }
@Override protected void doLayout(float width, float height) { float x = PADDING; float y = PADDING; float fieldHeight = txtPlayerName.getHeight(); float avatarSize = 2 * fieldHeight + PADDING; float dy = fieldHeight + PADDING; avatarLabel.setBounds(x, y, avatarSize, avatarSize); x += avatarSize + PADDING; float w = width - x - fieldHeight - 2 * PADDING; txtPlayerName.setBounds(x, y, w, fieldHeight); x += w + PADDING; nameRandomiser.setBounds(x, y, fieldHeight, fieldHeight); y += dy; humanAiSwitch.setSize(humanAiSwitch.getAutoSizeWidth(fieldHeight), fieldHeight); x = width - humanAiSwitch.getWidth() - PADDING; humanAiSwitch.setPosition(x, y); w = x - avatarSize - 3 * PADDING; x = avatarSize + 2 * PADDING; if (cbArchenemyTeam.isVisible()) { cbArchenemyTeam.setBounds(x, y, w, fieldHeight); } else { cbTeam.setBounds(x, y, w, fieldHeight); } y += dy; x = PADDING; w = width - 2 * PADDING; if (btnCommanderDeck.isVisible()) { btnCommanderDeck.setBounds(x, y, w, fieldHeight); y += dy; } else if (btnTinyLeadersDeck.isVisible()) { btnTinyLeadersDeck.setBounds(x, y, w, fieldHeight); y += dy; } else if (btnDeck.isVisible()) { btnDeck.setBounds(x, y, w, fieldHeight); y += dy; } if (btnSchemeDeck.isVisible()) { btnSchemeDeck.setBounds(x, y, w, fieldHeight); y += dy; } if (btnPlanarDeck.isVisible()) { btnPlanarDeck.setBounds(x, y, w, fieldHeight); y += dy; } if (btnVanguardAvatar.isVisible()) { btnVanguardAvatar.setBounds(x, y, w, fieldHeight); } }
private void createNameEditor() { String name; if (index == 0) { name = FModel.getPreferences().getPref(FPref.PLAYER_NAME); if (name.isEmpty()) { name = "Human"; } } else { name = NameGenerator.getRandomName("Any", "Any", screen.getPlayerNames()); } txtPlayerName.setText(name); txtPlayerName.setFont(LABEL_FONT); txtPlayerName.setChangedHandler(nameChangedHandler); }
@Override public void focusLost(final FocusEvent e) { final Object source = e.getSource(); if (source instanceof FTextField) { // the text box final FTextField nField = (FTextField) source; final String newName = nField.getText().trim(); if (index == 0 && !StringUtils.isBlank(newName) && StringUtils.isAlphanumericSpace(newName) && prefs.getPref(FPref.PLAYER_NAME) != newName) { prefs.setPref(FPref.PLAYER_NAME, newName); prefs.save(); } lobby.firePlayerChangeListener(index); } }
/** * @param index * @return */ private void createNameEditor() { String name; if (index == 0) { name = FModel.getPreferences().getPref(FPref.PLAYER_NAME); if (name.isEmpty()) { name = "Human"; } } else { name = NameGenerator.getRandomName("Any", "Any", lobby.getPlayerNames()); } txtPlayerName.setText(name); txtPlayerName.setFocusable(true); txtPlayerName.setFont(FSkin.getFont(14)); txtPlayerName.addActionListener(lobby.nameListener); txtPlayerName.addFocusListener(nameFocusListener); }
@Override public void handleEvent(FEvent e) { final Object source = e.getSource(); if (source instanceof FTextField) { // the text box FTextField nField = (FTextField) source; String newName = nField.getText().trim(); if (index == 0 && !StringUtils.isBlank(newName) && StringUtils.isAlphanumericSpace(newName) && prefs.getPref(FPref.PLAYER_NAME) != newName) { prefs.setPref(FPref.PLAYER_NAME, newName); prefs.save(); if (allowNetworking) { screen.firePlayerChangeListener(index); } } } }
public void setMayEdit(boolean mayEdit0) { if (mayEdit == mayEdit0) { return; } mayEdit = mayEdit0; avatarLabel.setEnabled(mayEdit); txtPlayerName.setEnabled(mayEdit); nameRandomiser.setEnabled(mayEdit); humanAiSwitch.setEnabled(mayEdit); updateVariantControlsVisibility(); // if panel has height already, ensure height updated to account for button visibility changes if (getHeight() > 0) { screen.getPlayersScroll().revalidate(); } }
public float getPreferredHeight() { int rows = 3; if (!btnDeck.isVisible()) { rows--; } if (btnCommanderDeck.isVisible() || btnTinyLeadersDeck.isVisible()) { rows++; } if (btnSchemeDeck.isVisible()) { rows++; } if (btnPlanarDeck.isVisible()) { rows++; } if (btnVanguardAvatar.isVisible()) { rows++; } return rows * (txtPlayerName.getHeight() + PADDING) + PADDING; }
public void setPlayerName(final String string) { playerName = string; txtPlayerName.setText(string); }
String getPlayerName() { return txtPlayerName.getText(); }
public void setPlayerName(String string) { txtPlayerName.setText(string); }