mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -04:00
Load game does not crash when there are notifications
Automated workers no longer complete improvements in a single turn City screen does not display building catagories which are irrelevant
This commit is contained in:
parent
d8a7c379e7
commit
80e3d16895
@ -68,7 +68,7 @@ public class CityInfo {
|
|||||||
TileInfo tile = getTile();
|
TileInfo tile = getTile();
|
||||||
tile.workingCity = this.name;
|
tile.workingCity = this.name;
|
||||||
tile.roadStatus = RoadStatus.Railroad;
|
tile.roadStatus = RoadStatus.Railroad;
|
||||||
if("Forest".equals(tile.terrainFeature) || "Jungle".equals(tile.terrainFeature) || "Marsh".equals(tile.terrainFeature))
|
if(new Linq<String>("Forest","Jungle","Marsh").contains(tile.terrainFeature))
|
||||||
tile.terrainFeature=null;
|
tile.terrainFeature=null;
|
||||||
|
|
||||||
population.autoAssignWorker();
|
population.autoAssignWorker();
|
||||||
|
@ -2,6 +2,7 @@ package com.unciv.logic.civilization;
|
|||||||
|
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.utils.Predicate;
|
import com.badlogic.gdx.utils.Predicate;
|
||||||
|
import com.sun.jmx.remote.security.NotificationAccessController;
|
||||||
import com.unciv.logic.city.CityInfo;
|
import com.unciv.logic.city.CityInfo;
|
||||||
import com.unciv.logic.map.RoadStatus;
|
import com.unciv.logic.map.RoadStatus;
|
||||||
import com.unciv.logic.map.TileInfo;
|
import com.unciv.logic.map.TileInfo;
|
||||||
@ -36,15 +37,7 @@ public class CivilizationInfo {
|
|||||||
public GreatPersonManager greatPeople = new GreatPersonManager();
|
public GreatPersonManager greatPeople = new GreatPersonManager();
|
||||||
public int turns = 1;
|
public int turns = 1;
|
||||||
|
|
||||||
public class Notification{
|
|
||||||
public final String text;
|
|
||||||
public final Vector2 location;
|
|
||||||
|
|
||||||
Notification(String text, Vector2 location) {
|
|
||||||
this.text = text;
|
|
||||||
this.location = location;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public Linq<Notification> notifications = new Linq<Notification>();
|
public Linq<Notification> notifications = new Linq<Notification>();
|
||||||
public void addNotification(String text, Vector2 location){
|
public void addNotification(String text, Vector2 location){
|
||||||
notifications.add(new Notification(text,location));
|
notifications.add(new Notification(text,location));
|
||||||
|
15
core/src/com/unciv/logic/civilization/Notification.java
Normal file
15
core/src/com/unciv/logic/civilization/Notification.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package com.unciv.logic.civilization;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
|
public class Notification{
|
||||||
|
public String text;
|
||||||
|
public Vector2 location;
|
||||||
|
|
||||||
|
Notification(){}
|
||||||
|
|
||||||
|
Notification(String text, Vector2 location) {
|
||||||
|
this.text = text;
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
}
|
@ -24,8 +24,9 @@ public class MapUnit{
|
|||||||
if(currentMovement!=0) doAction(gotTo);
|
if(currentMovement!=0) doAction(gotTo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ("automation".equals(action)) {doAutomatedAction(tile);return;}
|
||||||
if(name.equals("Worker") && tile.improvementInProgress!=null) workOnImprovement(tile);
|
if(name.equals("Worker") && tile.improvementInProgress!=null) workOnImprovement(tile);
|
||||||
if ("automation".equals(action)) doAutomatedAction(tile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -88,9 +89,13 @@ public class MapUnit{
|
|||||||
public void doAutomatedAction(TileInfo tile){
|
public void doAutomatedAction(TileInfo tile){
|
||||||
TileInfo toWork = findTileToWork(tile);
|
TileInfo toWork = findTileToWork(tile);
|
||||||
if(toWork==null) return; // Don't know what to do. Sorry.
|
if(toWork==null) return; // Don't know what to do. Sorry.
|
||||||
if(toWork!=tile) tile = headTowards(tile.position,toWork.position);
|
if(toWork!=tile) {
|
||||||
if(toWork == tile && tile.improvementInProgress==null) tile.startWorkingOnImprovement(chooseImprovement(tile));
|
tile = headTowards(tile.position, toWork.position);
|
||||||
doAction(tile);
|
doAction(tile);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(tile.improvementInProgress == null) tile.startWorkingOnImprovement(chooseImprovement(tile));
|
||||||
|
workOnImprovement(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String chooseImprovement(final TileInfo tile){
|
private String chooseImprovement(final TileInfo tile){
|
||||||
|
@ -148,13 +148,17 @@ public class CityScreen extends CameraStageBaseScreen {
|
|||||||
else Others.add(building);
|
else Others.add(building);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!Wonders.isEmpty()) {
|
||||||
Label label = new Label("Wonders", skin);
|
Label label = new Label("Wonders", skin);
|
||||||
label.setFontScale(1.5f);
|
label.setFontScale(1.5f);
|
||||||
label.setColor(Color.GREEN);
|
label.setColor(Color.GREEN);
|
||||||
BuildingsTable.add(label).pad(5).row();
|
BuildingsTable.add(label).pad(5).row();
|
||||||
for(Building building:Wonders) BuildingsTable.add(new Label(building.name,skin)).pad(5).row();
|
for (Building building : Wonders)
|
||||||
|
BuildingsTable.add(new Label(building.name, skin)).pad(5).row();
|
||||||
|
}
|
||||||
|
|
||||||
label = new Label("Specialist Buildings",skin);
|
if(!SpecialistBuildings.isEmpty()) {
|
||||||
|
Label label = new Label("Specialist Buildings", skin);
|
||||||
label.setFontScale(1.5f);
|
label.setFontScale(1.5f);
|
||||||
label.setColor(Color.GREEN);
|
label.setColor(Color.GREEN);
|
||||||
BuildingsTable.add(label).pad(5).row();
|
BuildingsTable.add(label).pad(5).row();
|
||||||
@ -191,14 +195,17 @@ public class CityScreen extends CameraStageBaseScreen {
|
|||||||
}
|
}
|
||||||
BuildingsTable.add(specialists).row();
|
BuildingsTable.add(specialists).row();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
label = new Label("Buildings",skin);
|
if(!Others.isEmpty()) {
|
||||||
|
Label label = new Label("Buildings", skin);
|
||||||
|
|
||||||
label.setFontScale(1.5f);
|
label.setFontScale(1.5f);
|
||||||
label.setColor(Color.GREEN);
|
label.setColor(Color.GREEN);
|
||||||
BuildingsTable.add(label).pad(5).row();
|
BuildingsTable.add(label).pad(5).row();
|
||||||
for(Building building:Others) BuildingsTable.add(new Label(building.name,skin)).pad(5).row();
|
for (Building building : Others)
|
||||||
|
BuildingsTable.add(new Label(building.name, skin)).pad(5).row();
|
||||||
|
}
|
||||||
BuildingsTable.pack();
|
BuildingsTable.pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
|||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
import com.badlogic.gdx.utils.Predicate;
|
import com.badlogic.gdx.utils.Predicate;
|
||||||
import com.unciv.logic.civilization.CivilizationInfo;
|
import com.unciv.logic.civilization.CivilizationInfo;
|
||||||
|
import com.unciv.logic.civilization.Notification;
|
||||||
import com.unciv.logic.map.TileInfo;
|
import com.unciv.logic.map.TileInfo;
|
||||||
import com.unciv.ui.pickerscreens.PolicyPickerScreen;
|
import com.unciv.ui.pickerscreens.PolicyPickerScreen;
|
||||||
import com.unciv.ui.pickerscreens.TechPickerScreen;
|
import com.unciv.ui.pickerscreens.TechPickerScreen;
|
||||||
@ -49,6 +50,7 @@ public class WorldScreen extends CameraStageBaseScreen {
|
|||||||
|
|
||||||
Table optionsTable = new Table();
|
Table optionsTable = new Table();
|
||||||
Table notificationsTable = new Table();
|
Table notificationsTable = new Table();
|
||||||
|
ScrollPane notificationsScroll = new ScrollPane(notificationsTable);
|
||||||
TextButton selectIdleUnitButton;
|
TextButton selectIdleUnitButton;
|
||||||
|
|
||||||
public WorldScreen() {
|
public WorldScreen() {
|
||||||
@ -57,7 +59,7 @@ public class WorldScreen extends CameraStageBaseScreen {
|
|||||||
addTiles();
|
addTiles();
|
||||||
stage.addActor(tileTable);
|
stage.addActor(tileTable);
|
||||||
|
|
||||||
Drawable tileTableBackground = com.unciv.ui.utils.ImageGetter.getDrawable("skin/tileTableBackground.png")
|
Drawable tileTableBackground = ImageGetter.getDrawable("skin/tileTableBackground.png")
|
||||||
.tint(new Color(0x004085bf));
|
.tint(new Color(0x004085bf));
|
||||||
tileTableBackground.setMinHeight(0);
|
tileTableBackground.setMinHeight(0);
|
||||||
tileTableBackground.setMinWidth(0);
|
tileTableBackground.setMinWidth(0);
|
||||||
@ -66,14 +68,12 @@ public class WorldScreen extends CameraStageBaseScreen {
|
|||||||
|
|
||||||
//notificationsTable.background(ImageGetter.getSingleColorDrawable(new Color(0x004085bf)));
|
//notificationsTable.background(ImageGetter.getSingleColorDrawable(new Color(0x004085bf)));
|
||||||
|
|
||||||
TextureRegionDrawable civBackground = com.unciv.ui.utils.ImageGetter.getDrawable("skin/civTableBackground.png");
|
TextureRegionDrawable civBackground = ImageGetter.getDrawable("skin/civTableBackground.png");
|
||||||
civTable.setBackground(civBackground.tint(new Color(0x004085bf)));
|
civTable.setBackground(civBackground.tint(new Color(0x004085bf)));
|
||||||
|
|
||||||
stage.addActor(civTable);
|
stage.addActor(civTable);
|
||||||
stage.addActor(techButton);
|
stage.addActor(techButton);
|
||||||
|
|
||||||
ScrollPane notificationsScroll = new ScrollPane(notificationsTable);
|
|
||||||
notificationsScroll.setSize(stage.getWidth() / 3, stage.getHeight() / 3);
|
|
||||||
stage.addActor(notificationsScroll);
|
stage.addActor(notificationsScroll);
|
||||||
addSelectIdleUnitButton();
|
addSelectIdleUnitButton();
|
||||||
update();
|
update();
|
||||||
@ -145,13 +145,13 @@ public class WorldScreen extends CameraStageBaseScreen {
|
|||||||
|
|
||||||
private void updateNotificationsList() {
|
private void updateNotificationsList() {
|
||||||
notificationsTable.clearChildren();
|
notificationsTable.clearChildren();
|
||||||
for (final CivilizationInfo.Notification notification : game.civInfo.notifications) {
|
for (final Notification notification : game.civInfo.notifications) {
|
||||||
Label label = new Label(notification.text, skin);
|
Label label = new Label(notification.text, skin);
|
||||||
label.setColor(Color.WHITE);
|
label.setColor(Color.WHITE);
|
||||||
label.setFontScale(1.2f);
|
label.setFontScale(1.2f);
|
||||||
Table minitable = new Table();
|
Table minitable = new Table();
|
||||||
|
|
||||||
minitable.background(com.unciv.ui.utils.ImageGetter.getDrawable("skin/civTableBackground.png")
|
minitable.background(ImageGetter.getDrawable("skin/civTableBackground.png")
|
||||||
.tint(new Color(0x004085bf)));
|
.tint(new Color(0x004085bf)));
|
||||||
minitable.add(label).pad(5);
|
minitable.add(label).pad(5);
|
||||||
|
|
||||||
@ -168,6 +168,9 @@ public class WorldScreen extends CameraStageBaseScreen {
|
|||||||
notificationsTable.row();
|
notificationsTable.row();
|
||||||
}
|
}
|
||||||
notificationsTable.pack();
|
notificationsTable.pack();
|
||||||
|
|
||||||
|
notificationsScroll.setSize(stage.getWidth() / 3,
|
||||||
|
Math.min(notificationsTable.getHeight(),stage.getHeight() / 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user