Search in sources :

Example 1 with DropDownList

use of com.ldtteam.blockout.views.DropDownList in project minecolonies by Minecolonies.

the class WindowPermissionsPage method fillUserList.

/**
 * Fills the userList in the GUI.
 */
private void fillUserList() {
    userList = findPaneOfTypeByID(LIST_USERS, ScrollingList.class);
    userList.setDataProvider(new ScrollingList.DataProvider() {

        @Override
        public int getElementCount() {
            return users.size();
        }

        @Override
        public void updateElement(final int index, @NotNull final Pane rowPane) {
            final Player player = users.get(index);
            Rank rank = player.getRank();
            rowPane.findPaneOfTypeByID(NAME_LABEL, Text.class).setText(player.getName());
            DropDownList dropdown = rowPane.findPaneOfTypeByID(TOWNHALL_RANK_PICKER, DropDownList.class);
            if (rank.getId() == building.getColony().getPermissions().OWNER_RANK_ID) {
                rowPane.findPaneOfTypeByID(BUTTON_REMOVE_PLAYER, Button.class).setEnabled(false);
                rowPane.findPaneOfTypeByID("rank", Text.class).setText(rank.getName());
                dropdown.setEnabled(false);
            } else {
                dropdown.setDataProvider(new DropDownList.DataProvider() {

                    @Override
                    public int getElementCount() {
                        return rankList.size();
                    }

                    @Override
                    public String getLabel(final int i) {
                        Rank rank = rankList.get(i);
                        return rank.getName();
                    }
                });
                dropdown.setSelectedIndex(rankList.indexOf(rank));
                dropdown.setHandler(WindowPermissionsPage.this::onRankSelected);
            }
        }
    });
}
Also used : Player(com.minecolonies.api.colony.permissions.Player) DropDownList(com.ldtteam.blockout.views.DropDownList) Rank(com.minecolonies.api.colony.permissions.Rank) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane)

Example 2 with DropDownList

use of com.ldtteam.blockout.views.DropDownList in project minecolonies by ldtteam.

the class WindowPermissionsPage method fillUserList.

/**
 * Fills the userList in the GUI.
 */
private void fillUserList() {
    userList = findPaneOfTypeByID(LIST_USERS, ScrollingList.class);
    userList.setDataProvider(new ScrollingList.DataProvider() {

        @Override
        public int getElementCount() {
            return users.size();
        }

        @Override
        public void updateElement(final int index, @NotNull final Pane rowPane) {
            final Player player = users.get(index);
            Rank rank = player.getRank();
            rowPane.findPaneOfTypeByID(NAME_LABEL, Text.class).setText(player.getName());
            DropDownList dropdown = rowPane.findPaneOfTypeByID(TOWNHALL_RANK_PICKER, DropDownList.class);
            if (rank.getId() == building.getColony().getPermissions().OWNER_RANK_ID) {
                rowPane.findPaneOfTypeByID(BUTTON_REMOVE_PLAYER, Button.class).setEnabled(false);
                rowPane.findPaneOfTypeByID("rank", Text.class).setText(rank.getName());
                dropdown.setEnabled(false);
            } else {
                dropdown.setDataProvider(new DropDownList.DataProvider() {

                    @Override
                    public int getElementCount() {
                        return rankList.size();
                    }

                    @Override
                    public String getLabel(final int i) {
                        Rank rank = rankList.get(i);
                        return rank.getName();
                    }
                });
                dropdown.setSelectedIndex(rankList.indexOf(rank));
                dropdown.setHandler(WindowPermissionsPage.this::onRankSelected);
            }
        }
    });
}
Also used : Player(com.minecolonies.api.colony.permissions.Player) DropDownList(com.ldtteam.blockout.views.DropDownList) Rank(com.minecolonies.api.colony.permissions.Rank) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane)

Example 3 with DropDownList

use of com.ldtteam.blockout.views.DropDownList in project minecolonies by ldtteam.

the class WindowPermissionsPage method togglePermMode.

/**
 * Switch the view on the rank view (between permissions and settings)
 *
 * @param button the button clicked
 */
private void togglePermMode(Button button) {
    SwitchView permSwitch = findPaneOfTypeByID(TOWNHALL_PERM_MANAGEMENT, SwitchView.class);
    permSwitch.setView(permSwitch.getCurrentView() != null && permSwitch.getCurrentView().getID().equals(TOWNHALL_PERM_LIST) ? TOWNHALL_PERM_SETTINGS : TOWNHALL_PERM_LIST);
    if (permSwitch.getCurrentView().getID().equals(TOWNHALL_PERM_SETTINGS)) {
        DropDownList dropdown = findPaneOfTypeByID(TOWNHALL_RANK_TYPE_PICKER, DropDownList.class);
        dropdown.setDataProvider(new DropDownList.DataProvider() {

            @Override
            public int getElementCount() {
                return rankTypes.size();
            }

            @Override
            public String getLabel(final int i) {
                return LanguageHandler.format(rankTypes.get(i));
            }
        });
        dropdown.setHandler(this::changeRankMode);
        dropdown.setSelectedIndex(actionsRank.isColonyManager() ? 0 : (actionsRank.isHostile() ? 1 : 2));
        findPaneOfTypeByID(TOWNHALL_BUTTON_SUBSCRIBER, Button.class).setText(new TranslationTextComponent(actionsRank.isSubscriber() ? COM_MINECOLONIES_COREMOD_GUI_WORKERHUTS_RETRIEVE_ON : COM_MINECOLONIES_COREMOD_GUI_WORKERHUTS_RETRIEVE_OFF));
    }
}
Also used : Button(com.ldtteam.blockout.controls.Button) SwitchView(com.ldtteam.blockout.views.SwitchView) DropDownList(com.ldtteam.blockout.views.DropDownList) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Example 4 with DropDownList

use of com.ldtteam.blockout.views.DropDownList in project minecolonies by Minecolonies.

the class WindowPermissionsPage method togglePermMode.

/**
 * Switch the view on the rank view (between permissions and settings)
 *
 * @param button the button clicked
 */
private void togglePermMode(Button button) {
    SwitchView permSwitch = findPaneOfTypeByID(TOWNHALL_PERM_MANAGEMENT, SwitchView.class);
    permSwitch.setView(permSwitch.getCurrentView() != null && permSwitch.getCurrentView().getID().equals(TOWNHALL_PERM_LIST) ? TOWNHALL_PERM_SETTINGS : TOWNHALL_PERM_LIST);
    if (permSwitch.getCurrentView().getID().equals(TOWNHALL_PERM_SETTINGS)) {
        DropDownList dropdown = findPaneOfTypeByID(TOWNHALL_RANK_TYPE_PICKER, DropDownList.class);
        dropdown.setDataProvider(new DropDownList.DataProvider() {

            @Override
            public int getElementCount() {
                return rankTypes.size();
            }

            @Override
            public String getLabel(final int i) {
                return LanguageHandler.format(rankTypes.get(i));
            }
        });
        dropdown.setHandler(this::changeRankMode);
        dropdown.setSelectedIndex(actionsRank.isColonyManager() ? 0 : (actionsRank.isHostile() ? 1 : 2));
        findPaneOfTypeByID(TOWNHALL_BUTTON_SUBSCRIBER, Button.class).setText(new TranslationTextComponent(actionsRank.isSubscriber() ? COM_MINECOLONIES_COREMOD_GUI_WORKERHUTS_RETRIEVE_ON : COM_MINECOLONIES_COREMOD_GUI_WORKERHUTS_RETRIEVE_OFF));
    }
}
Also used : Button(com.ldtteam.blockout.controls.Button) SwitchView(com.ldtteam.blockout.views.SwitchView) DropDownList(com.ldtteam.blockout.views.DropDownList) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Aggregations

DropDownList (com.ldtteam.blockout.views.DropDownList)4 Pane (com.ldtteam.blockout.Pane)2 Button (com.ldtteam.blockout.controls.Button)2 ScrollingList (com.ldtteam.blockout.views.ScrollingList)2 SwitchView (com.ldtteam.blockout.views.SwitchView)2 Player (com.minecolonies.api.colony.permissions.Player)2 Rank (com.minecolonies.api.colony.permissions.Rank)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2