示例#1
0
 Dialog(
     HUD hud,
     GUIContext container,
     String title,
     Point upperLeft,
     DialogChoice replacement,
     boolean notifiesListener,
     DialogChoice... old) {
   this.hud = hud;
   this.title = title;
   int x = upperLeft.x;
   int y = upperLeft.y;
   int width = ICON_GAP + (ICON_GAP + ICON_WIDTH) * old.length;
   int height;
   int choicesY;
   if (replacement != null) {
     height = ICON_WIDTH * 2 + ICON_GAP * 4 + 30 + TITLE_HEIGHT;
     choicesY = y + 3 * ICON_GAP + ICON_WIDTH + 30 + TITLE_HEIGHT;
     replacementButton =
         new Button.BasicButton(
             container,
             new Rectangle(x + 50, y + ICON_GAP * 2 + TITLE_HEIGHT, ICON_WIDTH, ICON_WIDTH),
             true,
             replacement.getScaledIcon(ICON_WIDTH, ICON_WIDTH),
             replacement.getTooltip(),
             replacement.getText());
   } else {
     height = ICON_WIDTH + ICON_GAP * 2 + 30 + TITLE_HEIGHT;
     choicesY = y + ICON_GAP + 30 + TITLE_HEIGHT;
   }
   this.rectangle = new Rectangle(x, y, width, height);
   choiceButtons =
       new ButtonRow(
           container,
           new Rectangle(x + ICON_GAP, choicesY, ICON_WIDTH, ICON_WIDTH),
           ICON_GAP,
           old.length);
   for (DialogChoice choice : old) {
     choiceButtons.addBasicButton(
         choice.getTooltip(),
         notifiesListener,
         choice.getScaledIcon(ICON_WIDTH, ICON_WIDTH),
         choice.getText());
   }
   choiceButtons.addListener(this);
 }