Search in sources :

Example 6 with MenuItemPage

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

the class TeamPlayerCountCondition method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu prev) {
    Menu m = new Menu(3, "Player Count", player);
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, prev), m.getSize() - 9);
    m.addItem(min.getMenuItem("Min Player Count", Material.STEP, 1, null));
    m.addItem(max.getMenuItem("Max Player Count", Material.STONE, 1, null));
    addInvertMenuItem(m);
    m.displayMenu(player);
    return true;
}
Also used : MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) Menu(au.com.mineauz.minigames.menu.Menu)

Example 7 with MenuItemPage

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

the class TeamScoreRangeCondition method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu prev) {
    Menu m = new Menu(3, "Team Score Range", player);
    m.addItem(min.getMenuItem("Minimum Score", Material.STEP, 0, null));
    m.addItem(max.getMenuItem("Maximum Score", Material.STONE, 0, null));
    List<String> teams = new ArrayList<String>();
    for (TeamColor t : TeamColor.values()) teams.add(MinigameUtils.capitalize(t.toString().replace("_", " ")));
    m.addItem(new MenuItemList("Team Color", Material.WOOL, new Callback<String>() {

        @Override
        public void setValue(String value) {
            team.setFlag(value.toUpperCase().replace(" ", "_"));
        }

        @Override
        public String getValue() {
            return MinigameUtils.capitalize(team.getFlag().replace("_", " "));
        }
    }, teams));
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, prev), m.getSize() - 9);
    addInvertMenuItem(m);
    m.displayMenu(player);
    return true;
}
Also used : Callback(au.com.mineauz.minigames.menu.Callback) MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) ArrayList(java.util.ArrayList) TeamColor(au.com.mineauz.minigames.minigame.TeamColor) Menu(au.com.mineauz.minigames.menu.Menu)

Example 8 with MenuItemPage

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

the class MenuItemActionAdd method onClick.

@Override
public ItemStack onClick() {
    Menu m = new Menu(6, "Actions", getContainer().getViewer());
    m.setPreviousPage(getContainer());
    Map<String, Menu> cats = new HashMap<>();
    List<String> acts = new ArrayList<>(Actions.getAllActionNames());
    Collections.sort(acts);
    for (String act : acts) {
        if ((Actions.getActionByName(act).useInNodes() && exec != null) || (Actions.getActionByName(act).useInRegions() && exec != null)) {
            String catname = Actions.getActionByName(act).getCategory();
            if (catname == null)
                catname = "misc actions";
            catname = catname.toLowerCase();
            Menu cat;
            if (!cats.containsKey(catname)) {
                cat = new Menu(6, MinigameUtils.capitalize(catname), getContainer().getViewer());
                cats.put(catname, cat);
                m.addItem(new MenuItemPage(MinigameUtils.capitalize(catname), Material.CHEST, cat));
                cat.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, m), cat.getSize() - 9);
            } else
                cat = cats.get(catname);
            MenuItemCustom c = new MenuItemCustom(MinigameUtils.capitalize(act), Material.PAPER);
            final String fact = act;
            c.setClick(new InteractionInterface() {

                @Override
                public Object interact(Object object) {
                    ActionInterface action = Actions.getActionByName(fact);
                    if (exec == null) {
                        exec.addAction(action);
                        getContainer().addItem(new MenuItemAction(MinigameUtils.capitalize(fact), Material.PAPER, exec, action));
                        getContainer().displayMenu(getContainer().getViewer());
                    } else {
                        exec.addAction(action);
                        getContainer().addItem(new MenuItemAction(MinigameUtils.capitalize(fact), Material.PAPER, exec, action));
                        getContainer().displayMenu(getContainer().getViewer());
                    }
                    return null;
                }
            });
            cat.addItem(c);
        }
    }
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, getContainer()), m.getSize() - 9);
    m.displayMenu(getContainer().getViewer());
    return null;
}
Also used : HashMap(java.util.HashMap) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) ArrayList(java.util.ArrayList) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) ActionInterface(au.com.mineauz.minigamesregions.actions.ActionInterface) Menu(au.com.mineauz.minigames.menu.Menu)

Example 9 with MenuItemPage

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

the class MenuItemNode method createMenu.

public static Menu createMenu(MinigamePlayer viewer, Menu previousPage, Node node) {
    Menu m = new Menu(3, "Node: " + node.getName(), viewer);
    m.setPreviousPage(previousPage);
    List<MenuItem> items = new ArrayList<>();
    for (NodeExecutor ex : node.getExecutors()) {
        items.add(new MenuItemNodeExecutor(node, ex));
    }
    if (previousPage != null) {
        m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, previousPage), m.getSize() - 9);
    }
    m.addItem(new MenuItemNodeExecutorAdd("Add Executor", Material.ITEM_FRAME, node), m.getSize() - 1);
    m.addItems(items);
    return m;
}
Also used : MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) ArrayList(java.util.ArrayList) MenuItem(au.com.mineauz.minigames.menu.MenuItem) Menu(au.com.mineauz.minigames.menu.Menu) NodeExecutor(au.com.mineauz.minigamesregions.executors.NodeExecutor)

Example 10 with MenuItemPage

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

the class MenuItemRegion method createMenu.

public static Menu createMenu(MinigamePlayer viewer, Menu previousPage, Region region) {
    Menu m = new Menu(3, "Region: " + region.getName(), viewer);
    m.setPreviousPage(previousPage);
    List<MenuItem> items = new ArrayList<>();
    for (RegionExecutor ex : region.getExecutors()) {
        items.add(new MenuItemRegionExecutor(region, ex));
    }
    if (previousPage != null) {
        m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, previousPage), m.getSize() - 9);
    }
    m.addItem(new MenuItemRegionExecutorAdd("Add Executor", Material.ITEM_FRAME, region), m.getSize() - 1);
    m.addItems(items);
    return m;
}
Also used : RegionExecutor(au.com.mineauz.minigamesregions.executors.RegionExecutor) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) ArrayList(java.util.ArrayList) MenuItem(au.com.mineauz.minigames.menu.MenuItem) Menu(au.com.mineauz.minigames.menu.Menu)

Aggregations

Menu (au.com.mineauz.minigames.menu.Menu)55 MenuItemPage (au.com.mineauz.minigames.menu.MenuItemPage)55 ArrayList (java.util.ArrayList)18 Callback (au.com.mineauz.minigames.menu.Callback)17 MenuItemList (au.com.mineauz.minigames.menu.MenuItemList)11 MenuItemString (au.com.mineauz.minigames.menu.MenuItemString)11 InteractionInterface (au.com.mineauz.minigames.menu.InteractionInterface)9 MenuItem (au.com.mineauz.minigames.menu.MenuItem)9 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)9 MenuItemNewLine (au.com.mineauz.minigames.menu.MenuItemNewLine)9 MenuItemInteger (au.com.mineauz.minigames.menu.MenuItemInteger)8 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)7 MenuItemBoolean (au.com.mineauz.minigames.menu.MenuItemBoolean)5 TeamColor (au.com.mineauz.minigames.minigame.TeamColor)5 MenuItemTime (au.com.mineauz.minigames.menu.MenuItemTime)4 MenuItemDecimal (au.com.mineauz.minigames.menu.MenuItemDecimal)2 MinigameTool (au.com.mineauz.minigames.tool.MinigameTool)2 MenuItemCondition (au.com.mineauz.minigamesregions.menuitems.MenuItemCondition)2 MenuItemConditionAdd (au.com.mineauz.minigamesregions.menuitems.MenuItemConditionAdd)2 HashMap (java.util.HashMap)2