Beispiel #1
0
  /**
   * @param index
   * @return
   */
  private FLabel createNameRandomizer() {
    final FLabel newNameBtn =
        new FLabel.Builder()
            .tooltip("Get a new random name")
            .iconInBackground(false)
            .icon(FSkin.getIcon(FSkinProp.ICO_EDIT))
            .hoverable(true)
            .opaque(false)
            .unhoveredAlpha(0.9f)
            .build();
    newNameBtn.setCommand(
        new UiCommand() {
          @Override
          public void run() {
            final String newName = lobby.getNewName();
            if (null == newName) {
              return;
            }
            txtPlayerName.setText(newName);

            if (index == 0) {
              prefs.setPref(FPref.PLAYER_NAME, newName);
              prefs.save();
            }
            txtPlayerName.requestFocus();
            lobby.changePlayerFocus(index);
          }
        });
    newNameBtn.addFocusListener(nameFocusListener);
    return newNameBtn;
  }
Beispiel #2
0
  private void createAvatar() {
    final String[] currentPrefs = FModel.getPreferences().getPref(FPref.UI_AVATARS).split(",");
    if (index < currentPrefs.length) {
      avatarIndex = Integer.parseInt(currentPrefs[index]);
      avatarLabel.setIcon(FSkin.getAvatars().get(avatarIndex));
    } else {
      setRandomAvatar(false);
    }

    avatarLabel.setToolTipText("L-click: Select avatar. R-click: Randomize avatar.");
    avatarLabel.addFocusListener(avatarFocusListener);
    avatarLabel.addMouseListener(avatarMouseListener);
  }