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);
}
}
});
}
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);
}
}
});
}
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));
}
}
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));
}
}
Aggregations