use of com.ldtteam.blockout.controls.AbstractTextBuilder.TextBuilder in project minecolonies by ldtteam.
the class WindowHireWorker method onOpened.
/**
* Called when the GUI has been opened. Will fill the fields and lists.
*/
@Override
public void onOpened() {
updateCitizens();
findPaneOfTypeByID(AUTO_HIRE_WARN, Text.class).off();
citizenList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
return citizens.size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
@NotNull final ICitizenDataView citizen = citizens.get(index);
final Button isPaused = rowPane.findPaneOfTypeByID(BUTTON_PAUSE, Button.class);
if (selectedModule.canAssign(citizen) && !selectedModule.isFull() && !selectedModule.getAssignedCitizens().contains(citizen.getId())) {
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).off();
rowPane.findPaneOfTypeByID(BUTTON_DONE, Button.class).on();
isPaused.off();
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).off();
} else if ((selectedModule.isFull()) && !selectedModule.getAssignedCitizens().contains(citizen.getId())) {
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).off();
rowPane.findPaneOfTypeByID(BUTTON_DONE, Button.class).off();
isPaused.off();
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).off();
} else {
rowPane.findPaneOfTypeByID(BUTTON_DONE, Button.class).off();
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).on();
if ((!selectedModule.getColony().isManualHiring() && selectedModule.getHiringMode() == HiringMode.DEFAULT) || (selectedModule.getHiringMode() == HiringMode.AUTO)) {
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).disable();
findPaneOfTypeByID(AUTO_HIRE_WARN, Text.class).on();
}
isPaused.on();
isPaused.setText(LanguageHandler.format(citizen.isPaused() ? COM_MINECOLONIES_COREMOD_GUI_HIRE_UNPAUSE : COM_MINECOLONIES_COREMOD_GUI_HIRE_PAUSE));
}
if (citizen.isPaused()) {
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).on();
} else {
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).off();
}
final StringTextComponent intermString = new StringTextComponent(" ");
final TextBuilder textBuilder = PaneBuilders.textBuilder();
textBuilder.append(new StringTextComponent(""));
int skillCount = citizen.getCitizenSkillHandler().getSkills().entrySet().size();
final Skill primary = selectedModule instanceof WorkerBuildingModuleView ? ((WorkerBuildingModuleView) selectedModule).getPrimarySkill() : null;
final Skill secondary = selectedModule instanceof WorkerBuildingModuleView ? ((WorkerBuildingModuleView) selectedModule).getSecondarySkill() : null;
for (final Map.Entry<Skill, Tuple<Integer, Double>> entry : citizen.getCitizenSkillHandler().getSkills().entrySet()) {
final String skillName = entry.getKey().name().toLowerCase(Locale.US);
final int skillLevel = entry.getValue().getA();
final Style skillStyle = createColor(primary, secondary, entry.getKey());
textBuilder.append(new TranslationTextComponent("com.minecolonies.coremod.gui.citizen.skills." + skillName).setStyle(skillStyle));
textBuilder.append(new StringTextComponent(": " + skillLevel).setStyle(skillStyle));
if (--skillCount > 0) {
textBuilder.append(intermString);
}
}
// finish the current line
textBuilder.newLine();
rowPane.findPaneOfTypeByID(CITIZEN_LABEL, Text.class).setText((citizen.getJob().isEmpty() ? "" : LanguageHandler.format(citizen.getJob()) + ": ") + citizen.getName());
rowPane.findPaneOfTypeByID(ATTRIBUTES_LABEL, Text.class).setText(textBuilder.getText());
final JobEntry entry = selectedModule.getJobEntry();
PaneBuilders.tooltipBuilder().hoverPane(rowPane.findPaneOfTypeByID(ATTRIBUTES_LABEL, Text.class)).build().setText(new TranslationTextComponent(entry.getKey().toString() + ".skills.desc"));
}
});
jobList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
return moduleViews.size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
final JobEntry entry = moduleViews.get(index).getJobEntry();
final Button button = rowPane.findPaneOfTypeByID(BUTTON_JOB, Button.class);
button.setText(new TranslationTextComponent(entry.getTranslationKey()));
if (entry.equals(selectedModule.getJobEntry())) {
button.disable();
} else {
button.enable();
}
PaneBuilders.tooltipBuilder().hoverPane(button).build().setText(new TranslationTextComponent(entry.getKey().toString() + ".job.desc"));
}
});
}
use of com.ldtteam.blockout.controls.AbstractTextBuilder.TextBuilder in project minecolonies by Minecolonies.
the class WindowHireWorker method onOpened.
/**
* Called when the GUI has been opened. Will fill the fields and lists.
*/
@Override
public void onOpened() {
updateCitizens();
findPaneOfTypeByID(AUTO_HIRE_WARN, Text.class).off();
citizenList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
return citizens.size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
@NotNull final ICitizenDataView citizen = citizens.get(index);
final Button isPaused = rowPane.findPaneOfTypeByID(BUTTON_PAUSE, Button.class);
if (selectedModule.canAssign(citizen) && !selectedModule.isFull() && !selectedModule.getAssignedCitizens().contains(citizen.getId())) {
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).off();
rowPane.findPaneOfTypeByID(BUTTON_DONE, Button.class).on();
isPaused.off();
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).off();
} else if ((selectedModule.isFull()) && !selectedModule.getAssignedCitizens().contains(citizen.getId())) {
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).off();
rowPane.findPaneOfTypeByID(BUTTON_DONE, Button.class).off();
isPaused.off();
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).off();
} else {
rowPane.findPaneOfTypeByID(BUTTON_DONE, Button.class).off();
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).on();
if ((!selectedModule.getColony().isManualHiring() && selectedModule.getHiringMode() == HiringMode.DEFAULT) || (selectedModule.getHiringMode() == HiringMode.AUTO)) {
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).disable();
findPaneOfTypeByID(AUTO_HIRE_WARN, Text.class).on();
}
isPaused.on();
isPaused.setText(LanguageHandler.format(citizen.isPaused() ? COM_MINECOLONIES_COREMOD_GUI_HIRE_UNPAUSE : COM_MINECOLONIES_COREMOD_GUI_HIRE_PAUSE));
}
if (citizen.isPaused()) {
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).on();
} else {
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).off();
}
final StringTextComponent intermString = new StringTextComponent(" ");
final TextBuilder textBuilder = PaneBuilders.textBuilder();
textBuilder.append(new StringTextComponent(""));
int skillCount = citizen.getCitizenSkillHandler().getSkills().entrySet().size();
final Skill primary = selectedModule instanceof WorkerBuildingModuleView ? ((WorkerBuildingModuleView) selectedModule).getPrimarySkill() : null;
final Skill secondary = selectedModule instanceof WorkerBuildingModuleView ? ((WorkerBuildingModuleView) selectedModule).getSecondarySkill() : null;
for (final Map.Entry<Skill, Tuple<Integer, Double>> entry : citizen.getCitizenSkillHandler().getSkills().entrySet()) {
final String skillName = entry.getKey().name().toLowerCase(Locale.US);
final int skillLevel = entry.getValue().getA();
final Style skillStyle = createColor(primary, secondary, entry.getKey());
textBuilder.append(new TranslationTextComponent("com.minecolonies.coremod.gui.citizen.skills." + skillName).setStyle(skillStyle));
textBuilder.append(new StringTextComponent(": " + skillLevel).setStyle(skillStyle));
if (--skillCount > 0) {
textBuilder.append(intermString);
}
}
// finish the current line
textBuilder.newLine();
rowPane.findPaneOfTypeByID(CITIZEN_LABEL, Text.class).setText((citizen.getJob().isEmpty() ? "" : LanguageHandler.format(citizen.getJob()) + ": ") + citizen.getName());
rowPane.findPaneOfTypeByID(ATTRIBUTES_LABEL, Text.class).setText(textBuilder.getText());
}
});
jobList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
return moduleViews.size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
final JobEntry entry = moduleViews.get(index).getJobEntry();
final Button button = rowPane.findPaneOfTypeByID(BUTTON_JOB, Button.class);
button.setText(new TranslationTextComponent(entry.getTranslationKey()));
if (entry.equals(selectedModule.getJobEntry())) {
button.disable();
} else {
button.enable();
}
}
});
}
Aggregations