All buildings which improve resources get that in their text, railroads now black, notifications now have background
This commit is contained in:
parent
c274367ab1
commit
ad94866aba
7 changed files with 73 additions and 33 deletions
|
@ -23,11 +23,12 @@ public class CityConstructions
|
|||
public CityConstructions(CityInfo cityInfo)
|
||||
{
|
||||
cityLocation = cityInfo.cityLocation;
|
||||
chooseNextConstruction();
|
||||
}
|
||||
|
||||
public LinqCollection<String> builtBuildings = new LinqCollection<String>();
|
||||
public HashMap<String, Integer> inProgressConstructions = new HashMap<String, Integer>();
|
||||
public String currentConstruction = Worker; // default starting building!
|
||||
public String currentConstruction; // default starting building!
|
||||
public IConstruction getCurrentConstruction(){return getConstruction(currentConstruction);}
|
||||
|
||||
public CityInfo getCity(){return UnCivGame.Current.civInfo.tileMap.get(cityLocation).getCity(); }
|
||||
|
@ -75,7 +76,6 @@ public class CityConstructions
|
|||
if (inProgressConstructions.get(currentConstruction) >= construction.getProductionCost())
|
||||
{
|
||||
construction.postBuildEvent(this);
|
||||
|
||||
inProgressConstructions.remove(currentConstruction);
|
||||
CivilizationInfo.current().notifications.add(currentConstruction +" has been built in "+getCity().name);
|
||||
|
||||
|
@ -163,7 +163,7 @@ public class CityConstructions
|
|||
|
||||
public void purchaseBuilding(String buildingName) {
|
||||
CivilizationInfo.current().civStats.gold -= getConstruction(buildingName).getGoldCost();
|
||||
builtBuildings.add(buildingName);
|
||||
getConstruction(buildingName).postBuildEvent(this);
|
||||
if(currentConstruction.equals(buildingName)) chooseNextConstruction();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,10 @@ public class CityInfo {
|
|||
name = CityNames[civInfo.cities.size()];
|
||||
this.cityLocation = cityLocation;
|
||||
cityConstructions = new CityConstructions(this);
|
||||
if(civInfo.cities.size()==0) cityConstructions.builtBuildings.add("Palace");
|
||||
if(civInfo.cities.size()==0) {
|
||||
cityConstructions.builtBuildings.add("Palace");
|
||||
cityConstructions.currentConstruction = "Worker"; // Default for first city only!
|
||||
}
|
||||
civInfo.cities.add(this);
|
||||
|
||||
for(TileInfo tileInfo : civInfo.tileMap.getTilesInDistance(cityLocation,1)) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
|||
import com.unciv.civinfo.CivilizationInfo;
|
||||
import com.unciv.civinfo.RoadStatus;
|
||||
import com.unciv.civinfo.TileInfo;
|
||||
import com.unciv.game.utils.HexMath;
|
||||
import com.unciv.game.utils.ImageGetter;
|
||||
import com.unciv.models.LinqHashMap;
|
||||
|
||||
|
@ -32,7 +33,7 @@ public class TileGroup extends Group {
|
|||
|
||||
terrainType = tileInfo.getLastTerrain().name;
|
||||
String terrainFileName = "TerrainIcons/" + terrainType.replace(' ','_') + "_(Civ5).png";
|
||||
terrainImage = ImageGetter.getImageByFilename(terrainFileName);
|
||||
terrainImage = ImageGetter.getImage(terrainFileName);
|
||||
terrainImage.setSize(50,50);
|
||||
addActor(terrainImage);
|
||||
}
|
||||
|
@ -54,12 +55,12 @@ public class TileGroup extends Group {
|
|||
if(!terrainType.equals(tileInfo.getLastTerrain().name)) {
|
||||
terrainType = tileInfo.getLastTerrain().name;
|
||||
String terrainFileName = "TerrainIcons/" + terrainType.replace(' ', '_') + "_(Civ5).png";
|
||||
terrainImage.setDrawable(new TextureRegionDrawable(ImageGetter.textureRegionByFileName.get(terrainFileName))); // In case we e.g. removed a jungle
|
||||
terrainImage.setDrawable(ImageGetter.getDrawable(terrainFileName)); // In case we e.g. removed a jungle
|
||||
}
|
||||
|
||||
if (tileInfo.hasViewableResource() && resourceImage == null) { // Need to add the resource image!
|
||||
String fileName = "ResourceIcons/" + tileInfo.resource + "_(Civ5).png";
|
||||
Image image = ImageGetter.getImageByFilename(fileName);
|
||||
Image image = ImageGetter.getImage(fileName);
|
||||
image.setSize(20,20);
|
||||
image.moveBy(terrainImage.getWidth()-image.getWidth(), 0); // bottom right
|
||||
resourceImage = image;
|
||||
|
@ -67,7 +68,7 @@ public class TileGroup extends Group {
|
|||
}
|
||||
|
||||
if (tileInfo.unit != null && unitImage == null) {
|
||||
unitImage = ImageGetter.getImageByFilename("StatIcons/" + tileInfo.unit.name + "_(Civ5).png");
|
||||
unitImage = ImageGetter.getImage("StatIcons/" + tileInfo.unit.name + "_(Civ5).png");
|
||||
addActor(unitImage);
|
||||
unitImage.setSize(20, 20); // not moved - is at bottom left
|
||||
}
|
||||
|
@ -86,7 +87,7 @@ public class TileGroup extends Group {
|
|||
|
||||
|
||||
if (tileInfo.improvement != null &&!tileInfo.improvement.equals(improvementType)) {
|
||||
improvementImage = ImageGetter.getImageByFilename("ImprovementIcons/" + tileInfo.improvement.replace(' ','_') + "_(Civ5).png");
|
||||
improvementImage = ImageGetter.getImage("ImprovementIcons/" + tileInfo.improvement.replace(' ','_') + "_(Civ5).png");
|
||||
addActor(improvementImage);
|
||||
improvementImage.setSize(20, 20);
|
||||
improvementImage.moveBy(terrainImage.getWidth()-improvementImage.getWidth(),
|
||||
|
@ -104,11 +105,14 @@ public class TileGroup extends Group {
|
|||
if (neighbor == tileInfo || neighbor.roadStatus == RoadStatus.None) continue;
|
||||
if (roadImages.containsKey(neighbor.position.toString())) continue;
|
||||
|
||||
Image image = ImageGetter.getImageByFilename("TerrainIcons/road.png");
|
||||
Image image = ImageGetter.getImage(ImageGetter.WhiteDot);
|
||||
if(tileInfo.roadStatus == RoadStatus.Railroad && neighbor.roadStatus == RoadStatus.Railroad)
|
||||
image.setColor(Color.BLACK); // railroad
|
||||
else image.setColor(Color.BROWN); // road
|
||||
roadImages.put(neighbor.position.toString(), image);
|
||||
|
||||
Vector2 relativeHexPosition = tileInfo.position.cpy().sub(neighbor.position);
|
||||
Vector2 relativeWorldPosition = com.unciv.game.utils.HexMath.Hex2WorldCoords(relativeHexPosition);
|
||||
Vector2 relativeWorldPosition = HexMath.Hex2WorldCoords(relativeHexPosition);
|
||||
|
||||
// This is some crazy voodoo magic so I'll explain.
|
||||
image.moveBy(25, 25); // Move road to center of tile
|
||||
|
|
|
@ -34,7 +34,7 @@ import com.unciv.models.stats.FullStats;
|
|||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
||||
public class WorldScreen extends CameraStageBaseScreen {
|
||||
|
||||
TileInfo selectedTile = null;
|
||||
|
||||
|
@ -58,14 +58,16 @@ public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
|||
addTiles();
|
||||
stage.addActor(tileTable);
|
||||
|
||||
Drawable tileTableBackground = new TextureRegionDrawable(new TextureRegion(new Texture("skin/tileTableBackground.png")))
|
||||
Drawable tileTableBackground = ImageGetter.getDrawable("skin/tileTableBackground.png")
|
||||
.tint(new Color(0x004085bf));
|
||||
tileTableBackground.setMinHeight(0);
|
||||
tileTableBackground.setMinWidth(0);
|
||||
tileTable.setBackground(tileTableBackground);
|
||||
OptionsTable.setBackground(tileTableBackground);
|
||||
|
||||
TextureRegionDrawable civBackground = new TextureRegionDrawable(new TextureRegion(new Texture("skin/civTableBackground.png")));
|
||||
NotificationsTable.background(ImageGetter.getDrawable(ImageGetter.WhiteDot).tint(new Color(0x004085bf)));
|
||||
|
||||
TextureRegionDrawable civBackground = ImageGetter.getDrawable("skin/civTableBackground.png");
|
||||
CivTable.setBackground(civBackground.tint(new Color(0x004085bf)));
|
||||
|
||||
stage.addActor(CivTable);
|
||||
|
@ -84,11 +86,14 @@ public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
|||
private void addNotificationsList() {
|
||||
stage.addActor(NotificationsTable);
|
||||
}
|
||||
|
||||
private void updateNotificationsList() {
|
||||
NotificationsTable.clearChildren();
|
||||
for(String notification : game.civInfo.notifications)
|
||||
{
|
||||
NotificationsTable.add(new Label(notification,skin)).pad(5);
|
||||
Label label = new Label(notification,skin);
|
||||
label.setColor(Color.WHITE);
|
||||
NotificationsTable.add(label).pad(10).fill();
|
||||
NotificationsTable.row();
|
||||
}
|
||||
NotificationsTable.pack();
|
||||
|
|
|
@ -28,7 +28,7 @@ public class WorldTileGroup extends TileGroup {
|
|||
|
||||
|
||||
if (tileInfo.owner != null && hexagon == null) {
|
||||
hexagon = com.unciv.game.utils.ImageGetter.getImageByFilename("TerrainIcons/Hexagon.png");
|
||||
hexagon = com.unciv.game.utils.ImageGetter.getImage("TerrainIcons/Hexagon.png");
|
||||
float imageScale = terrainImage.getWidth() * 1.3f / hexagon.getWidth();
|
||||
hexagon.setScale(imageScale);
|
||||
hexagon.setPosition((getWidth() - hexagon.getWidth() * imageScale) / 2,
|
||||
|
|
|
@ -4,19 +4,31 @@ import com.badlogic.gdx.Gdx;
|
|||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ImageGetter {
|
||||
public static HashMap<String, TextureRegion> textureRegionByFileName = new HashMap<String, TextureRegion>();
|
||||
public static HashMap<String, TextureRegion> textureRegionByFileName = new HashMap<String, TextureRegion>();
|
||||
public static final String WhiteDot="skin/whiteDot.png";
|
||||
|
||||
public static Image getImageByFilename(String fileName) {
|
||||
if (!textureRegionByFileName.containsKey(fileName))
|
||||
textureRegionByFileName.put(fileName, new TextureRegion(new Texture(Gdx.files.internal(fileName))));
|
||||
return new Image(textureRegionByFileName.get(fileName));
|
||||
}
|
||||
public static Image getImage(String fileName) {
|
||||
return new Image(getTextureRegion(fileName));
|
||||
}
|
||||
|
||||
public static TextureRegionDrawable getDrawable(String fileName) {
|
||||
return new TextureRegionDrawable(getTextureRegion(fileName));
|
||||
}
|
||||
|
||||
private static TextureRegion getTextureRegion(String fileName) {
|
||||
if (!textureRegionByFileName.containsKey(fileName))
|
||||
textureRegionByFileName.put(fileName, new TextureRegion(new Texture(Gdx.files.internal(fileName))));
|
||||
return textureRegionByFileName.get(fileName);
|
||||
}
|
||||
|
||||
public static Image getStatIcon(String name) {
|
||||
return getImage("StatIcons/20x" + name + "5.png");
|
||||
}
|
||||
|
||||
public static Image getStatIcon(String name) {
|
||||
return getImageByFilename("StatIcons/20x" + name + "5.png");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,16 +61,32 @@ public class Building extends NamedStats implements IConstruction, ICivilopedia
|
|||
stringBuilder.append("Requires a " + requiredBuildingInAllCities + " to be built in all cities\r\n");
|
||||
if (providesFreeBuilding != null)
|
||||
stringBuilder.append("Provides a free " + providesFreeBuilding + " in this city\r\n");
|
||||
if(description!=null) stringBuilder.append(description + "\r\n");
|
||||
if(!stats.toString().equals(""))
|
||||
stringBuilder.append(stats+"\r\n");
|
||||
if(this.percentStatBonus!=null){
|
||||
if(this.percentStatBonus.production!=0) stringBuilder.append("+"+(int)this.percentStatBonus.production+"% production\r\n");
|
||||
if(this.percentStatBonus.gold!=0) stringBuilder.append("+"+(int)this.percentStatBonus.gold+"% gold\r\n");
|
||||
if(this.percentStatBonus.science!=0) stringBuilder.append("+"+(int)this.percentStatBonus.science+"% science\r\n");
|
||||
if(this.percentStatBonus.food!=0) stringBuilder.append("+"+(int)this.percentStatBonus.food+"% food\r\n");
|
||||
if(this.percentStatBonus.culture!=0) stringBuilder.append("+"+(int)this.percentStatBonus.culture+"% culture\r\n");
|
||||
}
|
||||
if(resourceBonusStats!=null){
|
||||
String resources = String.join(",",GameBasics.TileResources.linqValues().where(new Predicate<TileResource>() {
|
||||
@Override
|
||||
public boolean evaluate(TileResource arg0) {
|
||||
return name.equals(arg0.building);
|
||||
}
|
||||
}).select(new LinqCollection.Func<TileResource, CharSequence>() {
|
||||
@Override
|
||||
public CharSequence GetBy(TileResource arg0) {
|
||||
return arg0.name;
|
||||
}
|
||||
})) ;
|
||||
stringBuilder.append(resources+" provide "+resourceBonusStats+" \r\n");
|
||||
}
|
||||
if (maintainance != 0)
|
||||
stringBuilder.append("Maintainance cost: " + maintainance + " gold\r\n");
|
||||
stringBuilder.append(description + "\r\n" + stats);
|
||||
if(this.percentStatBonus!=null){
|
||||
if(this.percentStatBonus.production!=0) stringBuilder.append("\r\n+"+this.percentStatBonus.production+" production");
|
||||
if(this.percentStatBonus.gold!=0) stringBuilder.append("\r\n+"+this.percentStatBonus.gold+" gold");
|
||||
if(this.percentStatBonus.science!=0) stringBuilder.append("\r\n+"+this.percentStatBonus.science+" science");
|
||||
if(this.percentStatBonus.food!=0) stringBuilder.append("\r\n+"+this.percentStatBonus.food+" food");
|
||||
if(this.percentStatBonus.culture!=0) stringBuilder.append("\r\n+"+this.percentStatBonus.culture+" culture");
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue