Ejemplo n.º 1
0
  private void startGame(final GameType gameType) {
    final DeckProxy humanDeck = VSubmenuWinston.SINGLETON_INSTANCE.getLstDecks().getSelectedItem();
    final int aiIndex = 0;

    if (humanDeck == null) {
      FOptionPane.showErrorDialog(
          "No deck selected for human.\n(You may need to build a new deck)", "No Deck");
      return;
    }

    if (FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)) {
      final String errorMessage =
          gameType.getDeckFormat().getDeckConformanceProblem(humanDeck.getDeck());
      if (null != errorMessage) {
        FOptionPane.showErrorDialog(
            "Your deck " + errorMessage + " Please edit or choose a different deck.",
            "Invalid Deck");
        return;
      }
    }

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            SOverlayUtils.startGameOverlay();
            SOverlayUtils.showOverlay();
          }
        });

    final DeckGroup opponentDecks = FModel.getDecks().getWinston().get(humanDeck.getName());
    final Deck aiDeck = opponentDecks.getAiDecks().get(aiIndex);
    if (aiDeck == null) {
      throw new IllegalStateException("Draft: Computer deck is null!");
    }

    final List<RegisteredPlayer> starter = new ArrayList<RegisteredPlayer>();
    final RegisteredPlayer human =
        new RegisteredPlayer(humanDeck.getDeck()).setPlayer(GamePlayerUtil.getGuiPlayer());
    starter.add(human);
    starter.add(new RegisteredPlayer(aiDeck).setPlayer(GamePlayerUtil.createAiPlayer()));

    final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();
    hostedMatch.startMatch(
        GameType.Winston, null, starter, human, GuiBase.getInterface().getNewGuiGame());

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            SOverlayUtils.hideOverlay();
          }
        });
  }
 private void resetWorkshopLayout() {
   final String userPrompt =
       "This will reset the Workshop screen layout.\n"
           + "All tabbed views will be restored to their default positions.\n\n"
           + "Reset layout?";
   if (FOptionPane.showConfirmDialog(userPrompt, "Reset Workshop Layout")) {
     if (FScreen.WORKSHOP_SCREEN.deleteLayoutFile()) {
       FOptionPane.showMessageDialog("Workshop layout has been reset.");
     }
   }
 }
 private void resetDeckEditorLayout() {
   final String userPrompt =
       "This will reset the Deck Editor screen layout.\n"
           + "All tabbed views will be restored to their default positions.\n\n"
           + "Reset layout?";
   if (FOptionPane.showConfirmDialog(userPrompt, "Reset Deck Editor Layout")) {
     if (FScreen.DECK_EDITOR_CONSTRUCTED.deleteLayoutFile()) {
       FOptionPane.showMessageDialog("Deck Editor layout has been reset.");
     }
   }
 }
 private void resetMatchScreenLayout() {
   final String userPrompt =
       "This will reset the layout of the Match screen.\n"
           + "If you want to save the current layout first, please use "
           + "the Dock tab -> Save Layout option in the Match screen.\n\n"
           + "Reset layout?";
   if (FOptionPane.showConfirmDialog(userPrompt, "Reset Match Screen Layout")) {
     if (FScreen.deleteMatchLayoutFile()) {
       FOptionPane.showMessageDialog("Match Screen layout has been reset.");
     }
   }
 }
Ejemplo n.º 5
0
 private void generateRandomName(
     final String gender,
     final String type,
     final List<String> usedNames,
     final String title,
     final Callback<String> callback) {
   final String newName = NameGenerator.getRandomName(gender, type, usedNames);
   String confirmMsg = "Would you like to use the name \"" + newName + "\", or try again?";
   FOptionPane.showConfirmDialog(
       confirmMsg,
       title,
       "Use this name",
       "Try again",
       true,
       new Callback<Boolean>() {
         @Override
         public void run(Boolean result) {
           if (result) {
             callback.run(newName);
           } else {
             generateRandomName(gender, type, usedNames, title, callback);
           }
         }
       });
 }
 private void resetForgeSettingsToDefault() {
   final String userPrompt =
       "This will reset all preferences to their defaults and restart Forge.\n\n"
           + "Reset and restart Forge?";
   if (FOptionPane.showConfirmDialog(userPrompt, "Reset Settings")) {
     final ForgePreferences prefs = FModel.getPreferences();
     prefs.reset();
     prefs.save();
     update();
     Singletons.getControl().restartForge();
   }
 }
Ejemplo n.º 7
0
  private final void getNewName(final Callback<String> callback) {
    final String title = "Get new random name";
    final String message = "What type of name do you want to generate?";
    final FSkinImage icon = FOptionPane.QUESTION_ICON;

    FOptionPane.showOptionDialog(
        message,
        title,
        icon,
        genderOptions,
        2,
        new Callback<Integer>() {
          @Override
          public void run(final Integer genderIndex) {
            if (genderIndex == null || genderIndex < 0) {
              callback.run(null);
              return;
            }

            FOptionPane.showOptionDialog(
                message,
                title,
                icon,
                typeOptions,
                2,
                new Callback<Integer>() {
                  @Override
                  public void run(final Integer typeIndex) {
                    if (typeIndex == null || typeIndex < 0) {
                      callback.run(null);
                      return;
                    }

                    generateRandomName(
                        genderOptions.get(genderIndex),
                        typeOptions.get(typeIndex),
                        screen.getPlayerNames(),
                        title,
                        callback);
                  }
                });
          }
        });
  }
Ejemplo n.º 8
0
 public boolean canExitForge(final boolean forRestart) {
   final String action = (forRestart ? "Restart" : "Exit");
   String userPrompt = "Are you sure you wish to " + (forRestart ? "restart" : "exit") + " Forge?";
   final boolean hasCurrentMatches = hasCurrentMatches();
   if (hasCurrentMatches) {
     userPrompt = "One or more games are currently active. " + userPrompt;
   }
   if (!FOptionPane.showConfirmDialog(
       userPrompt,
       action + " Forge",
       action,
       "Cancel",
       !hasCurrentMatches)) { // default Yes if no game active
     return false;
   }
   if (!CDeckEditorUI.SINGLETON_INSTANCE.canSwitchAway(true)) {
     return false;
   }
   return true;
 }