int y = initialY;
// Robots actions
// Terrabot (terrain preparation)
Button terrabotButton = new ImageButton("TERRABOT", x, y);
terrabotButton.disable();
// TODO why the terrabutton size is fucked?
terrabotButton.setSize(ImageButton.IB_DEFAULT_SIZE,
ImageButton.IB_DEFAULT_SIZE);
terrabotButton.setActionHandler(new ActionHandler() {
@Override
public void run() {
PreparationAction pa = BuildingHelper.create(GameData.getSelectedColony());
BuildWindowOld.this.parent.setSelectedAction(pa);
hide();
}
});
terrabotButton.setHoverHandler(new ActionHandler() {
@Override
public void run() {
initMaps();
BuildWindowOld.this.name = "terrabot";
BuildWindowOld.this.cost.put(Resource.ENERGY,
BigDecimal.valueOf(25));
}
});
this.buttons.add(terrabotButton);
// Landscape buildings, following the robots with a little margin
x += pitch * 2; // The margin
List<BuildingType> types = BuildingType
.values(BuildingCategory.LANDSCAPE);
for (BuildingType type : types) {
Button button = createBuildingButton(type.toString()
.substring(0, 1), type);
button.setPosition(x, y);
this.buttons.add(button);
x += pitch;
}
// Industrial buildings
x = initialX;
y += pitch;
types = BuildingType.values(BuildingCategory.INDUSTRIAL);
for (BuildingType type : types) {
Button button = createBuildingButton(type.toString()
.substring(0, 1), type);
button.setPosition(x, y);
this.buttons.add(button);
x += pitch;
}
// Civil buildings
x = initialX;
y += pitch;
types = BuildingType.values(BuildingCategory.CIVIL);
for (BuildingType type : types) {
Button button = createBuildingButton(type.toString()
.substring(0, 1), type);
button.setPosition(x, y);
if (BuildingType.COMMAND_CENTER.equals(type)) {
this.cmButton = button;
this.cmButton.enable();
if (GameData.getSelectedColony().isCommandCenterBuilt()) {
// Only 1 command center
button.disable();
}
} else if (BuildingType.RESEARCH_CENTER.equals(type)
&& GameData.getSelectedColony().isResearchCenterBuilt()) {
// Only 1 research center
button.disable();
}
this.buttons.add(button);
x += pitch;
}