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); }
void render(GUIContext container, Graphics g) { g.setColor(Color.gray); g.fill(rectangle); renderTitle(g); if (replacementButton != null) { renderReplacement(container, g); } choiceButtons.render(container, g); choiceButtons.highlight(container, g, highlightedIndex, Color.green); g.setColor(Color.white); g.drawRoundRect( rectangle.getX(), rectangle.getY(), rectangle.getWidth(), rectangle.getHeight(), 5); g.setFont(HUD.NORMAL_FONT); if (tooltip != null) { tooltip.render(container, g); } }
void update(Input input, int delta) { choiceButtons.update(input, delta); }
@Override public void buttonMouseOver(ButtonRow sourceRow, Button sourceButton, int buttonIndex) { tooltip = hud.createButtonTooltip( sourceButton.getUpperLeft(), sourceRow.getTooltipOfButtonWithIndex(buttonIndex)); }