Search in sources :

Example 1 with ActionButtonEnum

use of eidolons.swing.components.buttons.ActionButtonEnum in project Eidolons by IDemiurge.

the class TaskComponent method addButtons.

private void addButtons() {
    int i = 0;
    int wrap = getPanelHeight() / getButtonMaxHeight();
    String pos = "";
    int x = 0;
    int y = 0;
    int width = getButtonMaxWidth();
    int height = getButtonMaxHeight();
    for (TASK_COMMAND cmd : TASK_COMMAND.values()) {
        if (!task.checkCommandShown(cmd)) {
            continue;
        }
        Image image = cmd.getImage();
        if (image == null) {
            image = ImageManager.getEmptyItemIcon(true).getImage();
        }
        CustomButton btn = new ActionButtonEnum<>(null, image, cmd, this);
        i++;
        y += height;
        if (i >= wrap) {
            y = 0;
            x += width;
            pos = "pos " + x + " " + y;
        }
        mouseMap.put(new Rectangle(x, y, image.getWidth(null), image.getHeight(null)), cmd);
        buttonPanel.add(btn, pos);
    }
}
Also used : CustomButton(eidolons.swing.components.buttons.CustomButton) TASK_COMMAND(main.gui.sub.TaskComponent.TASK_COMMAND) ActionButtonEnum(eidolons.swing.components.buttons.ActionButtonEnum)

Aggregations

ActionButtonEnum (eidolons.swing.components.buttons.ActionButtonEnum)1 CustomButton (eidolons.swing.components.buttons.CustomButton)1 TASK_COMMAND (main.gui.sub.TaskComponent.TASK_COMMAND)1