Search in sources :

Example 1 with SwitchView

use of com.ldtteam.blockout.views.SwitchView 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 2 with SwitchView

use of com.ldtteam.blockout.views.SwitchView 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

Button (com.ldtteam.blockout.controls.Button)2 DropDownList (com.ldtteam.blockout.views.DropDownList)2 SwitchView (com.ldtteam.blockout.views.SwitchView)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2