ImprovementPickerScreen is now a regular PickerScreen

Researched techs now don't display 'turns to research'
This commit is contained in:
Yair Morgenstern 2017-11-26 19:39:50 +02:00
parent c8dd598438
commit 2b8fefe675
3 changed files with 18 additions and 42 deletions

View file

@ -14,30 +14,15 @@ import com.unciv.game.UnCivGame;
import com.unciv.models.gamebasics.GameBasics;
import com.unciv.models.gamebasics.TileImprovement;
public class ImprovementPickerScreen extends CameraStageBaseScreen {
public class ImprovementPickerScreen extends PickerScreen {
TileImprovement SelectedImprovement;
public ImprovementPickerScreen(final UnCivGame game, final com.unciv.civinfo.TileInfo tileInfo) {
super(game);
Table buttonTable = new Table();
TextButton closeButton =new TextButton("Close", skin);
closeButton.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new com.unciv.game.CityScreen(game));
dispose();
}
});
// closeButton.getLabel().setFontScale(0.7f);
buttonTable.add(closeButton).width(stage.getWidth()/4);
rightSideButton.setText("Pick improvement");
final Label improvementDescription = new Label("",skin);
buttonTable.add(improvementDescription).width(stage.getWidth()/2).pad(5);
improvementDescription.setFontScale(game.settings.labelScale);
final TextButton pickImprovementButton = new TextButton("Pick improvement",skin);
pickImprovementButton.addListener(new ClickListener(){
rightSideButton.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
tileInfo.StartWorkingOnImprovement(SelectedImprovement);
@ -45,12 +30,10 @@ public class ImprovementPickerScreen extends CameraStageBaseScreen {
dispose();
}
});
// pickImprovementButton.getLabel().setFontScale(0.7f);
pickImprovementButton.setTouchable(Touchable.disabled);
pickImprovementButton.setColor(Color.GRAY);
buttonTable.add(pickImprovementButton).width(stage.getWidth()/4);
Table buildingsTable = new Table();
rightSideButton.setTouchable(Touchable.disabled);
rightSideButton.setColor(Color.GRAY);
for(final TileImprovement improvement : GameBasics.TileImprovements.values()) {
if(!tileInfo.CanBuildImprovement(improvement)) continue;
TextButton TB = new TextButton(improvement.Name+"\r\n"+improvement.TurnsToBuild+" turns", skin);
@ -58,22 +41,14 @@ public class ImprovementPickerScreen extends CameraStageBaseScreen {
@Override
public void clicked(InputEvent event, float x, float y) {
SelectedImprovement = improvement;
pickImprovementButton.setTouchable(Touchable.enabled);
pickImprovementButton.setText("Construct "+improvement.Name);
pickImprovementButton.setColor(Color.WHITE);
improvementDescription.setText(improvement.GetDescription());
rightSideButton.setTouchable(Touchable.enabled);
rightSideButton.setText("Construct "+improvement.Name);
rightSideButton.setColor(Color.WHITE);
descriptionLabel.setText(improvement.GetDescription());
}
});
buildingsTable.add(TB).pad(10);
buildingsTable.row();
topTable.add(TB).pad(10);
topTable.row();
}
ScrollPane scrollPane = new ScrollPane(buildingsTable);
scrollPane.setSize(stage.getWidth(),stage.getHeight()*0.9f);
SplitPane splitPane = new SplitPane(scrollPane, buttonTable, true, skin);
splitPane.setSplitAmount(0.9f);
splitPane.setFillParent(true);
stage.addActor(splitPane);
}
}

View file

@ -47,7 +47,8 @@ public class TechPickerScreen extends PickerScreen {
if (TechsToResearch.contains(techName)) {
TB.setText(TB.getText() + " (" + TechsToResearch.indexOf(techName) + ")");
}
TB.setText(TB.getText() + "\r\n" + game.civInfo.TurnsToTech(techName) + " turns");
if(!civTech.IsResearched(techName)) TB.setText(TB.getText() + "\r\n" + game.civInfo.TurnsToTech(techName) + " turns");
}
}

View file

@ -19,11 +19,11 @@ public class TileImprovement extends NamedStats implements ICivilopedia {
@Override
public String GetDescription() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(new FullStats(this)+"\r\n");
if(!TerrainsCanBeBuiltOn.isEmpty()) stringBuilder.append("Can be built on " + com.unciv.models.gamebasics.StringUtils.join(", ", TerrainsCanBeBuiltOn));
if(!new FullStats(this).toString().isEmpty()) stringBuilder.append(new FullStats(this)+"\r\n");
if(!TerrainsCanBeBuiltOn.isEmpty()) stringBuilder.append("Can be built on " + StringUtils.join(", ", TerrainsCanBeBuiltOn));
HashMap<String,ArrayList<String>> statsToResourceNames = new HashMap<String, ArrayList<String>>();
for(com.unciv.models.gamebasics.TileResource tr : GameBasics.TileResources.values()){
for(TileResource tr : GameBasics.TileResources.values()){
if(!tr.Improvement.equals(Name)) continue;
String statsString = tr.ImprovementStats.toString();
if(!statsToResourceNames.containsKey(statsString))
@ -31,7 +31,7 @@ public class TileImprovement extends NamedStats implements ICivilopedia {
statsToResourceNames.get(statsString).add(tr.Name);
}
for(String statsString : statsToResourceNames.keySet()){
stringBuilder.append("\r\n"+statsString+" for "+ com.unciv.models.gamebasics.StringUtils.join(", ",statsToResourceNames.get(statsString)));
stringBuilder.append("\r\n"+statsString+" for "+ StringUtils.join(", ",statsToResourceNames.get(statsString)));
}
if(TechRequired!=null) stringBuilder.append("\r\nTech required: "+TechRequired);