Search in sources :

Example 6 with MenuItemCustom

use of au.com.mineauz.minigames.menu.MenuItemCustom in project Minigames by AddstarMC.

the class ScoreboardDisplay method displayMenu.

public void displayMenu(MinigamePlayer player) {
    final Menu setupMenu = new Menu(3, "Setup Scoreboard", player);
    StatSettings settings = minigame.getSettings(stat);
    final MenuItemCustom statisticChoice = new MenuItemCustom("Statistic", Material.BOOK_AND_QUILL);
    statisticChoice.setDescription(Arrays.asList(ChatColor.GREEN + settings.getDisplayName()));
    final MenuItemCustom fieldChoice = new MenuItemCustom("Statistic Field", Material.PAPER);
    fieldChoice.setDescription(Arrays.asList(ChatColor.GREEN + field.getTitle()));
    statisticChoice.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            Menu childMenu = MinigameStats.createStatSelectMenu(setupMenu, new Callback<MinigameStat>() {

                @Override
                public MinigameStat getValue() {
                    throw new UnsupportedOperationException();
                }

                @Override
                public void setValue(MinigameStat value) {
                    stat = value;
                    StatSettings settings = minigame.getSettings(stat);
                    statisticChoice.setDescription(Arrays.asList(ChatColor.GREEN + settings.getDisplayName()));
                    // Check that the field is valid
                    StatValueField first = null;
                    boolean valid = false;
                    for (StatValueField sfield : settings.getFormat().getFields()) {
                        if (first == null) {
                            first = sfield;
                        }
                        if (sfield == field) {
                            valid = true;
                            break;
                        }
                    }
                    // Update the field
                    if (!valid) {
                        field = first;
                        fieldChoice.setDescription(Arrays.asList(ChatColor.GREEN + value.toString()));
                    }
                }
            });
            childMenu.displayMenu(setupMenu.getViewer());
            return null;
        }
    });
    fieldChoice.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            StatSettings settings = minigame.getSettings(stat);
            Menu childMenu = MinigameStats.createStatFieldSelectMenu(setupMenu, settings.getFormat(), new Callback<StatValueField>() {

                @Override
                public StatValueField getValue() {
                    throw new UnsupportedOperationException();
                }

                @Override
                public void setValue(StatValueField value) {
                    field = value;
                    fieldChoice.setDescription(Arrays.asList(ChatColor.GREEN + value.getTitle()));
                }
            });
            childMenu.displayMenu(setupMenu.getViewer());
            return null;
        }
    });
    setupMenu.addItem(statisticChoice);
    setupMenu.addItem(fieldChoice);
    List<String> sbotypes = new ArrayList<String>();
    for (ScoreboardOrder o : ScoreboardOrder.values()) {
        sbotypes.add(o.toString().toLowerCase());
    }
    setupMenu.addItem(new MenuItemList("Scoreboard Order", Material.ENDER_PEARL, new Callback<String>() {

        @Override
        public void setValue(String value) {
            order = ScoreboardOrder.valueOf(value.toUpperCase());
        }

        @Override
        public String getValue() {
            return order.toString().toLowerCase();
        }
    }, sbotypes));
    setupMenu.addItem(new MenuItemScoreboardSave("Create Scoreboard", Material.REDSTONE_TORCH_ON, this), setupMenu.getSize() - 1);
    setupMenu.displayMenu(player);
}
Also used : ArrayList(java.util.ArrayList) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom) MenuItemScoreboardSave(au.com.mineauz.minigames.menu.MenuItemScoreboardSave) StatValueField(au.com.mineauz.minigames.stats.StatValueField) FutureCallback(com.google.common.util.concurrent.FutureCallback) Callback(au.com.mineauz.minigames.menu.Callback) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) MinigameStat(au.com.mineauz.minigames.stats.MinigameStat) Menu(au.com.mineauz.minigames.menu.Menu) StatSettings(au.com.mineauz.minigames.stats.StatSettings)

Example 7 with MenuItemCustom

use of au.com.mineauz.minigames.menu.MenuItemCustom in project Minigames by AddstarMC.

the class RewardsModule method addEditMenuOptions.

@Override
public void addEditMenuOptions(final Menu menu) {
    MenuItemCustom launcher = new MenuItemCustom("Reward Settings", Material.DIAMOND);
    launcher.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            Menu submenu = createSubMenu(menu);
            submenu.displayMenu(menu.getViewer());
            return null;
        }
    });
    menu.addItem(launcher);
}
Also used : InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) Menu(au.com.mineauz.minigames.menu.Menu) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom)

Example 8 with MenuItemCustom

use of au.com.mineauz.minigames.menu.MenuItemCustom in project Minigames by AddstarMC.

the class RegionModule method addEditMenuOptions.

@Override
public void addEditMenuOptions(Menu menu) {
    final MenuItemCustom c = new MenuItemCustom("Regions and Nodes", Material.DIAMOND_BLOCK);
    final Menu fmenu = menu;
    c.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            displayMenu(c.getContainer().getViewer(), fmenu);
            return null;
        }
    });
    menu.addItem(c);
}
Also used : InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) Menu(au.com.mineauz.minigames.menu.Menu) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom)

Example 9 with MenuItemCustom

use of au.com.mineauz.minigames.menu.MenuItemCustom in project Minigames by AddstarMC.

the class MinigameStats method createStatSelectMenu.

/**
 * Creates a menu that allows you to select a statistic
 *
 * @param parent       The parent menu
 * @param statCallback The callback to be invoked when the statistic is chosen. Note: only the setValue() method will be called.
 * @return The menu to display
 */
public static Menu createStatSelectMenu(final Menu parent, final Callback<MinigameStat> statCallback) {
    final Menu submenu = new Menu(6, "Select Statistic", parent.getViewer());
    for (final MinigameStat stat : getAllStats().values()) {
        MenuItemCustom item = new MenuItemCustom(WordUtils.capitalizeFully(stat.getDisplayName()), Material.WRITABLE_BOOK);
        item.setClick(object -> {
            statCallback.setValue(stat);
            parent.displayMenu(submenu.getViewer());
            return null;
        });
        submenu.addItem(item);
    }
    submenu.addItem(new MenuItemBack(parent), submenu.getSize() - 9);
    return submenu;
}
Also used : MenuItemBack(au.com.mineauz.minigames.menu.MenuItemBack) Menu(au.com.mineauz.minigames.menu.Menu) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom)

Example 10 with MenuItemCustom

use of au.com.mineauz.minigames.menu.MenuItemCustom in project Minigames by AddstarMC.

the class MenuItemNodeExecutor method onClick.

@Override
public ItemStack onClick() {
    final MinigamePlayer fviewer = getContainer().getViewer();
    Menu m = new Menu(3, "Executor", fviewer);
    final Menu ffm = m;
    MenuItemCustom ca = new MenuItemCustom("Actions", Material.CHEST);
    ca.setClick(object -> {
        Actions.displayMenu(fviewer, ex, ffm);
        return null;
    });
    m.addItem(ca);
    MenuItemCustom c2 = new MenuItemCustom("Conditions", Material.CHEST);
    c2.setClick(object -> {
        Conditions.displayMenu(fviewer, ex, ffm);
        return null;
    });
    m.addItem(c2);
    m.addItem(new MenuItemNewLine());
    m.addItem(new MenuItemInteger("Trigger Count", MinigameUtils.stringToList("Number of times this;node can be;triggered"), Material.STONE, ex.getTriggerCountCallback(), 0, null));
    m.addItem(new MenuItemBoolean("Trigger Per Player", MinigameUtils.stringToList("Whether this node;is triggered per player;or just on count"), Material.ENDER_PEARL, ex.getIsTriggerPerPlayerCallback()));
    m.addItem(new MenuItemPage("Back", MenuUtility.getBackMaterial(), getContainer()), m.getSize() - 9);
    m.displayMenu(fviewer);
    return null;
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) MenuItemInteger(au.com.mineauz.minigames.menu.MenuItemInteger) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) MenuItemNewLine(au.com.mineauz.minigames.menu.MenuItemNewLine) MenuItemBoolean(au.com.mineauz.minigames.menu.MenuItemBoolean) Menu(au.com.mineauz.minigames.menu.Menu) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom)

Aggregations

MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)11 Menu (au.com.mineauz.minigames.menu.Menu)10 InteractionInterface (au.com.mineauz.minigames.menu.InteractionInterface)4 MenuItemNewLine (au.com.mineauz.minigames.menu.MenuItemNewLine)4 MenuItemPage (au.com.mineauz.minigames.menu.MenuItemPage)4 MenuItemBoolean (au.com.mineauz.minigames.menu.MenuItemBoolean)3 MenuItemInteger (au.com.mineauz.minigames.menu.MenuItemInteger)3 MenuItemList (au.com.mineauz.minigames.menu.MenuItemList)3 MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)3 ArrayList (java.util.ArrayList)3 Callback (au.com.mineauz.minigames.menu.Callback)2 MenuItemBack (au.com.mineauz.minigames.menu.MenuItemBack)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 PlayerLoadout (au.com.mineauz.minigames.PlayerLoadout)1 MinigameType (au.com.mineauz.minigames.gametypes.MinigameType)1 GameMechanicBase (au.com.mineauz.minigames.mechanics.GameMechanicBase)1 MenuItem (au.com.mineauz.minigames.menu.MenuItem)1 MenuItemAddFlag (au.com.mineauz.minigames.menu.MenuItemAddFlag)1 MenuItemDisplayLoadout (au.com.mineauz.minigames.menu.MenuItemDisplayLoadout)1 MenuItemDisplayWhitelist (au.com.mineauz.minigames.menu.MenuItemDisplayWhitelist)1