Пример #1
0
        @Override
        public final void onLeftClick(final MouseEvent e) {
          if (!avatarLabel.isEnabled()) {
            return;
          }

          final FLabel avatar = (FLabel) e.getSource();

          lobby.changePlayerFocus(index);
          avatar.requestFocusInWindow();

          final AvatarSelector aSel =
              new AvatarSelector(playerName, avatarIndex, lobby.getUsedAvatars());
          for (final FLabel lbl : aSel.getSelectables()) {
            lbl.setCommand(
                new UiCommand() {
                  @Override
                  public void run() {
                    setAvatarIndex(Integer.valueOf(lbl.getName().substring(11)));
                    aSel.setVisible(false);
                  }
                });
          }

          aSel.setVisible(true);
          aSel.dispose();

          if (index < 2) {
            lobby.updateAvatarPrefs();
          }

          lobby.firePlayerChangeListener(index);
        }
Пример #2
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;
  }
Пример #3
0
  private FLabel createNameRandomizer() {
    final FLabel newNameBtn =
        new FLabel.Builder().iconInBackground(false).icon(FSkinImage.EDIT).opaque(false).build();
    newNameBtn.setCommand(
        new FEventHandler() {
          @Override
          public void handleEvent(FEvent e) {
            getNewName(
                new Callback<String>() {
                  @Override
                  public void run(String newName) {
                    if (newName == null) {
                      return;
                    }

                    txtPlayerName.setText(newName);

                    if (index == 0) {
                      prefs.setPref(FPref.PLAYER_NAME, newName);
                      prefs.save();
                    }
                    if (allowNetworking) {
                      screen.firePlayerChangeListener(index);
                    }
                  }
                });
          }
        });
    return newNameBtn;
  }
Пример #4
0
  protected FLabel addToggleButton(JPanel widget, SkinImage icon, String tooltip) {
    final FLabel button =
        new FLabel.Builder()
            .icon(icon)
            .iconScaleAuto(false)
            .fontSize(11)
            .tooltip(tooltip)
            .hoverable()
            .selectable(true)
            .selected(true)
            .build();

    button.setCommand(
        new UiCommand() {
          @Override
          public void run() {
            if (lockFiltering) {
              return;
            }
            applyChange();
          }
        });

    this.buttons.add(button);
    widget.add(button);
    return button;
  }
Пример #5
0
 private void createAvatar() {
   String[] currentPrefs = prefs.getPref(FPref.UI_AVATARS).split(",");
   if (index < currentPrefs.length) {
     setAvatarIndex(Integer.parseInt(currentPrefs[index]));
   } else {
     setAvatarIndex(AvatarSelector.getRandomAvatar(screen.getUsedAvatars()));
   }
   avatarLabel.setCommand(avatarCommand);
 }
Пример #6
0
 /** @param index */
 private void addHandlersDeckSelector() {
   deckBtn.setCommand(
       new Runnable() {
         @Override
         public void run() {
           lobby.setCurrentGameMode(GameType.Constructed);
           deckBtn.requestFocusInWindow();
           lobby.changePlayerFocus(index, GameType.Constructed);
         }
       });
 }
Пример #7
0
 private FLabel createCloseButton() {
   final FLabel closeBtn =
       new FLabel.Builder()
           .tooltip("Remove")
           .iconInBackground(false)
           .icon(FSkin.getIcon(FSkinProp.ICO_CLOSE))
           .hoverable(true)
           .build();
   closeBtn.setCommand(
       new Runnable() {
         @Override
         public final void run() {
           if (type == LobbySlotType.REMOTE
               && !SOptionPane.showConfirmDialog(
                   String.format("Really kick %s?", playerName), "Kick", false)) {
             return;
           }
           lobby.removePlayer(index);
         }
       });
   return closeBtn;
 }
Пример #8
0
  /** @param index */
  private void addHandlersToVariantsControls() {
    // Archenemy buttons
    scmDeckSelectorBtn.setCommand(
        new Runnable() {
          @Override
          public final void run() {
            lobby.setCurrentGameMode(
                lobby.hasVariant(GameType.Archenemy)
                    ? GameType.Archenemy
                    : GameType.ArchenemyRumble);
            scmDeckSelectorBtn.requestFocusInWindow();
            lobby.changePlayerFocus(index);
          }
        });

    scmDeckEditor.setCommand(
        new UiCommand() {
          @Override
          public void run() {
            lobby.setCurrentGameMode(
                lobby.hasVariant(GameType.Archenemy)
                    ? GameType.Archenemy
                    : GameType.ArchenemyRumble);
            final Predicate<PaperCard> predSchemes =
                new Predicate<PaperCard>() {
                  @Override
                  public final boolean apply(final PaperCard arg0) {
                    return arg0.getRules().getType().isScheme();
                  }
                };

            Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_ARCHENEMY);
            CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(
                new CEditorVariant(
                    FModel.getDecks().getScheme(),
                    predSchemes,
                    DeckSection.Schemes,
                    FScreen.DECK_EDITOR_ARCHENEMY,
                    CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture()));
          }
        });

    // Commander buttons
    cmdDeckSelectorBtn.setCommand(
        new Runnable() {
          @Override
          public void run() {
            lobby.setCurrentGameMode(
                lobby.hasVariant(GameType.TinyLeaders) ? GameType.TinyLeaders : GameType.Commander);
            cmdDeckSelectorBtn.requestFocusInWindow();
            lobby.changePlayerFocus(index);
          }
        });

    cmdDeckEditor.setCommand(
        new UiCommand() {
          @Override
          public void run() {
            if (lobby.hasVariant(GameType.TinyLeaders)) {
              lobby.setCurrentGameMode(GameType.TinyLeaders);
              Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_TINY_LEADERS);
              CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(
                  new CEditorCommander(CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture(), true));
            } else {
              lobby.setCurrentGameMode(GameType.Commander);
              Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_COMMANDER);
              CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(
                  new CEditorCommander(
                      CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture(), false));
            }
          }
        });

    // Planechase buttons
    pchDeckSelectorBtn.setCommand(
        new Runnable() {
          @Override
          public void run() {
            lobby.setCurrentGameMode(GameType.Planechase);
            pchDeckSelectorBtn.requestFocusInWindow();
            lobby.changePlayerFocus(index, GameType.Planechase);
          }
        });

    pchDeckEditor.setCommand(
        new UiCommand() {
          @Override
          public void run() {
            lobby.setCurrentGameMode(GameType.Planechase);
            final Predicate<PaperCard> predPlanes =
                new Predicate<PaperCard>() {
                  @Override
                  public boolean apply(final PaperCard arg0) {
                    return arg0.getRules().getType().isPlane()
                        || arg0.getRules().getType().isPhenomenon();
                  }
                };

            Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_PLANECHASE);
            CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(
                new CEditorVariant(
                    FModel.getDecks().getPlane(),
                    predPlanes,
                    DeckSection.Planes,
                    FScreen.DECK_EDITOR_PLANECHASE,
                    CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture()));
          }
        });

    // Vanguard buttons
    vgdSelectorBtn.setCommand(
        new Runnable() {
          @Override
          public void run() {
            lobby.setCurrentGameMode(GameType.Vanguard);
            vgdSelectorBtn.requestFocusInWindow();
            lobby.changePlayerFocus(index, GameType.Vanguard);
          }
        });
  }
Пример #9
0
  public PlayerPanel(
      final LobbyScreen screen0,
      final boolean allowNetworking0,
      final int index0,
      final LobbySlot slot,
      final boolean mayEdit0,
      final boolean mayControl0) {
    super();
    screen = screen0;
    allowNetworking = allowNetworking0;
    if (allowNetworking) {
      humanAiSwitch = new FToggleSwitch("Not Ready", "Ready");
    } else {
      humanAiSwitch = new FToggleSwitch("Human", "AI");
    }
    index = index0;
    populateTeamsComboBoxes();
    setTeam(slot.getTeam());
    setIsArchenemy(slot.isArchenemy());
    setType(slot.getType());
    setPlayerName(slot.getName());
    setAvatarIndex(slot.getAvatarIndex());

    btnDeck.setEnabled(false); // disable deck button until done loading decks

    boolean isAi = isAi();
    deckChooser =
        new FDeckChooser(
            GameType.Constructed,
            isAi,
            new FEventHandler() {
              @Override
              public void handleEvent(FEvent e) {
                btnDeck.setEnabled(true);
                btnDeck.setText(
                    deckChooser.getSelectedDeckType().toString()
                        + ": "
                        + Lang.joinHomogenous(
                            ((DeckManager) e.getSource()).getSelectedItems(),
                            DeckProxy.FN_GET_NAME));
              }
            });
    lstCommanderDecks =
        new FDeckChooser(
            GameType.Commander,
            isAi,
            new FEventHandler() {
              @Override
              public void handleEvent(FEvent e) {
                btnCommanderDeck.setText(
                    "Commander Deck: " + ((DeckManager) e.getSource()).getSelectedItem().getName());
              }
            });
    lstTinyLeadersDecks =
        new FDeckChooser(
            GameType.TinyLeaders,
            isAi,
            new FEventHandler() {
              @Override
              public void handleEvent(FEvent e) {
                btnTinyLeadersDeck.setText(
                    "Tiny Leaders Deck: "
                        + ((DeckManager) e.getSource()).getSelectedItem().getName());
              }
            });
    lstSchemeDecks =
        new FDeckChooser(
            GameType.Archenemy,
            isAi,
            new FEventHandler() {
              @Override
              public void handleEvent(FEvent e) {
                btnSchemeDeck.setText(
                    "Scheme Deck: " + ((DeckManager) e.getSource()).getSelectedItem().getName());
              }
            });
    lstPlanarDecks =
        new FDeckChooser(
            GameType.Planechase,
            isAi,
            new FEventHandler() {
              @Override
              public void handleEvent(FEvent e) {
                btnPlanarDeck.setText(
                    "Planar Deck: " + ((DeckManager) e.getSource()).getSelectedItem().getName());
              }
            });
    lstVanguardAvatars =
        new FVanguardChooser(
            isAi,
            new FEventHandler() {
              @Override
              public void handleEvent(FEvent e) {
                btnVanguardAvatar.setText(
                    "Vanguard: " + ((CardManager) e.getSource()).getSelectedItem().getName());
              }
            });

    createAvatar();
    add(avatarLabel);

    createNameEditor();
    add(newLabel("Name:"));
    add(txtPlayerName);

    nameRandomiser = createNameRandomizer();
    add(nameRandomiser);

    humanAiSwitch.setChangedHandler(humanAiSwitched);
    add(humanAiSwitch);

    add(newLabel("Team:"));
    cbTeam.setChangedHandler(teamChangedHandler);
    cbArchenemyTeam.setChangedHandler(teamChangedHandler);
    add(cbTeam);
    add(cbArchenemyTeam);

    add(btnDeck);
    btnDeck.setCommand(
        new FEventHandler() {
          @Override
          public void handleEvent(FEvent e) {
            deckChooser.setHeaderCaption("Select Deck for " + txtPlayerName.getText());
            Forge.openScreen(deckChooser);
          }
        });
    add(btnCommanderDeck);
    btnCommanderDeck.setCommand(
        new FEventHandler() {
          @Override
          public void handleEvent(FEvent e) {
            lstCommanderDecks.setHeaderCaption(
                "Select Commander Deck for " + txtPlayerName.getText());
            Forge.openScreen(lstCommanderDecks);
          }
        });
    add(btnTinyLeadersDeck);
    btnTinyLeadersDeck.setCommand(
        new FEventHandler() {
          @Override
          public void handleEvent(FEvent e) {
            lstTinyLeadersDecks.setHeaderCaption(
                "Select Tiny Leaders Deck for " + txtPlayerName.getText());
            Forge.openScreen(lstTinyLeadersDecks);
          }
        });
    add(btnSchemeDeck);
    btnSchemeDeck.setCommand(
        new FEventHandler() {
          @Override
          public void handleEvent(FEvent e) {
            lstSchemeDecks.setHeaderCaption("Select Scheme Deck for " + txtPlayerName.getText());
            Forge.openScreen(lstSchemeDecks);
          }
        });
    add(btnPlanarDeck);
    btnPlanarDeck.setCommand(
        new FEventHandler() {
          @Override
          public void handleEvent(FEvent e) {
            lstPlanarDecks.setHeaderCaption("Select Planar Deck for " + txtPlayerName.getText());
            Forge.openScreen(lstPlanarDecks);
          }
        });
    add(btnVanguardAvatar);
    btnVanguardAvatar.setCommand(
        new FEventHandler() {
          @Override
          public void handleEvent(FEvent e) {
            lstVanguardAvatars.setHeaderCaption("Select Vanguard for " + txtPlayerName.getText());
            Forge.openScreen(lstVanguardAvatars);
          }
        });

    if (mayEdit == mayEdit0) {
      updateVariantControlsVisibility();
    } else {
      setMayEdit(false);
    }
    setMayControl(mayControl0);

    // disable team combo boxes for now
    cbTeam.setEnabled(false);
  }
 private void initializePlayerNameButton() {
   final FLabel btn = view.getBtnPlayerName();
   setPlayerNameButtonText();
   btn.setCommand(getPlayerNameButtonCommand());
 }