Ejemplo n.º 1
0
  /**
   * Will display a dialog prompting the user to select an action from a list. The label of each
   * action will be the result of calling toString() on each Action object.
   */
  public static void showActionListDialog(
      GUIScreen owner, String title, String description, Action... actions) {
    int maxLength = 0;
    for (Action action : actions)
      if (action.toString().length() > maxLength) maxLength = action.toString().length();

    showActionListDialog(owner, title, description, maxLength, actions);
  }
Ejemplo n.º 2
0
  /**
   * Will display a dialog prompting the user to select an action from a list. The label of each
   * action will be the result of calling toString() on each Action object.
   *
   * @param owner Screen to display the dialog on
   * @param title Title of the dialog
   * @param description Description label inside the dialog
   * @param itemWidth Width of the labels in the list, this will effectively set how wide the dialog
   *     is
   * @param closeBeforeAction When an action in chosen, should the dialog be closed before the
   *     action is executed?
   * @param actions List of actions inside the dialog
   */
  public static void showActionListDialog(
      GUIScreen owner,
      String title,
      String description,
      int itemWidth,
      boolean closeBeforeAction,
      Action... actions) {
    // Autodetect width?
    if (itemWidth == 0) {
      showActionListDialog(owner, title, description, actions);
      return;
    }

    ActionListDialog actionListDialog =
        new ActionListDialog(title, description, itemWidth, closeBeforeAction);
    for (Action action : actions) actionListDialog.addAction(action.toString(), action);
    owner.showWindow(actionListDialog, GUIScreen.Position.CENTER);
  }
Ejemplo n.º 3
0
 /**
  * Adds an action to the list, using toString() of the action as a label
  *
  * @param action Action to be performed when the user presses enter key
  */
 public void addAction(final Action action) {
   addAction(action.toString(), action);
 }