mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-09 10:29:02 +07:00
Notifications now contain location, and are clickable when appropriate
This commit is contained in:
parent
6c035c79b6
commit
5b28840940
@ -22,7 +22,7 @@ android {
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 25
|
||||
versionCode 18
|
||||
versionName "0.9"
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
@ -65,7 +65,7 @@ public class CityConstructions
|
||||
currentConstruction = null;
|
||||
if(!construction.isBuildable(this)){
|
||||
// We can't build this building anymore! (Wonder has been built / resource is gone / etc.)
|
||||
CivilizationInfo.current().notifications.add("Cannot continue work on "+saveCurrentConstruction);
|
||||
CivilizationInfo.current().addNotification("Cannot continue work on "+saveCurrentConstruction,cityLocation);
|
||||
chooseNextConstruction();
|
||||
construction = getConstruction(currentConstruction);
|
||||
}
|
||||
@ -76,7 +76,7 @@ public class CityConstructions
|
||||
{
|
||||
construction.postBuildEvent(this);
|
||||
inProgressConstructions.remove(currentConstruction);
|
||||
CivilizationInfo.current().notifications.add(currentConstruction +" has been built in "+getCity().name);
|
||||
CivilizationInfo.current().addNotification(currentConstruction +" has been built in "+getCity().name,cityLocation);
|
||||
|
||||
chooseNextConstruction();
|
||||
}
|
||||
@ -93,7 +93,7 @@ public class CityConstructions
|
||||
});
|
||||
if (currentConstruction == null) currentConstruction = Worker;
|
||||
|
||||
CivilizationInfo.current().notifications.add("Work has started on "+ currentConstruction);
|
||||
CivilizationInfo.current().addNotification("Work has started on "+ currentConstruction,cityLocation);
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,6 +60,7 @@ public class CityInfo {
|
||||
name = CityNames[civInfo.cities.size()];
|
||||
this.cityLocation = cityLocation;
|
||||
civInfo.cities.add(this);
|
||||
CivilizationInfo.current().addNotification(name+" has been founded!",cityLocation);
|
||||
cityConstructions = new CityConstructions(this);
|
||||
if(civInfo.policies.contains("Legalism") && civInfo.cities.size() <= 4) cityConstructions.addCultureBuilding();
|
||||
if(civInfo.cities.size()==1) {
|
||||
@ -275,7 +276,7 @@ public class CityInfo {
|
||||
{
|
||||
population--;
|
||||
foodStored = 0;
|
||||
CivilizationInfo.current().notifications.add(name+" is starving!");
|
||||
CivilizationInfo.current().addNotification(name+" is starving!",cityLocation);
|
||||
}
|
||||
if (foodStored >= foodToNextPopulation()) // growth!
|
||||
{
|
||||
@ -283,7 +284,7 @@ public class CityInfo {
|
||||
if(getBuildingUniques().contains("FoodCarriesOver")) foodStored+=0.4f*foodToNextPopulation(); // Aqueduct special
|
||||
population++;
|
||||
autoAssignWorker();
|
||||
CivilizationInfo.current().notifications.add(name+" has grown!");
|
||||
CivilizationInfo.current().addNotification(name+" has grown!",cityLocation);
|
||||
}
|
||||
|
||||
cityConstructions.nextTurn(stats);
|
||||
@ -291,7 +292,7 @@ public class CityInfo {
|
||||
cultureStored+=stats.culture;
|
||||
if(cultureStored>=getCultureToNextTile()){
|
||||
addNewTile();
|
||||
CivilizationInfo.current().notifications.add(name+" has expanded its borders!");
|
||||
CivilizationInfo.current().addNotification(name+" has expanded its borders!",cityLocation);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,14 @@ import com.unciv.models.stats.CivStats;
|
||||
import com.unciv.models.stats.FullStats;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Created by LENOVO on 10/18/2017.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public class CivilizationInfo {
|
||||
public static CivilizationInfo current(){ return UnCivGame.Current.civInfo; }
|
||||
|
||||
@ -34,7 +38,20 @@ public class CivilizationInfo {
|
||||
public LinqCollection<String> policies = new LinqCollection<String>();
|
||||
public int freePolicies=0;
|
||||
public int turns = 1;
|
||||
public LinqCollection<String> notifications = new LinqCollection<String>();
|
||||
|
||||
public class Notification{
|
||||
public final String text;
|
||||
public final Vector2 location;
|
||||
|
||||
Notification(String text, Vector2 location) {
|
||||
this.text = text;
|
||||
this.location = location;
|
||||
}
|
||||
}
|
||||
public LinqCollection<Notification> notifications = new LinqCollection<Notification>();
|
||||
public void addNotification(String text, Vector2 location){
|
||||
notifications.add(new Notification(text,location));
|
||||
}
|
||||
public LinqCollection<String> tutorial = new LinqCollection<String>();
|
||||
|
||||
public LinqCollection<CityInfo> cities = new LinqCollection<CityInfo>();
|
||||
@ -116,7 +133,7 @@ public class CivilizationInfo {
|
||||
|
||||
public void addGreatPerson(String unitName){ // This is also done by some wonders and social policies, remember
|
||||
tileMap.placeUnitNearTile(cities.get(0).cityLocation,unitName);
|
||||
notifications.add("A "+unitName+" has been born!");
|
||||
addNotification("A "+unitName+" has been born!",cities.get(0).cityLocation);
|
||||
}
|
||||
|
||||
public void greatPersonPointsForTurn(){
|
||||
@ -150,7 +167,7 @@ public class CivilizationInfo {
|
||||
if(getBuildingUniques().contains("GoldenAgeLengthIncrease")) turnsToGoldenAge*=1.5;
|
||||
if(policies.contains("Freedom Complete")) turnsToGoldenAge*=1.5;
|
||||
turnsLeftForCurrentGoldenAge += turnsToGoldenAge;
|
||||
notifications.add("You have entered a golden age!");
|
||||
addNotification("You have entered a golden age!",null);
|
||||
}
|
||||
|
||||
public CivStats getStatsForNextTurn() {
|
||||
|
@ -47,7 +47,7 @@ public class CivilizationTech{
|
||||
techsInProgress.remove(CurrentTechnology);
|
||||
techsToResearch.remove(CurrentTechnology);
|
||||
techsResearched.add(CurrentTechnology);
|
||||
CivilizationInfo.current().notifications.add("Research of "+CurrentTechnology+ " has completed!");
|
||||
CivilizationInfo.current().addNotification("Research of "+CurrentTechnology+ " has completed!",null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Cell;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
@ -146,8 +147,8 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
|
||||
private void updateNotificationsList() {
|
||||
notificationsTable.clearChildren();
|
||||
for (String notification : game.civInfo.notifications) {
|
||||
Label label = new Label(notification, skin);
|
||||
for (final CivilizationInfo.Notification notification : game.civInfo.notifications) {
|
||||
Label label = new Label(notification.text, skin);
|
||||
label.setColor(Color.WHITE);
|
||||
label.setFontScale(1.2f);
|
||||
Table minitable = new Table();
|
||||
@ -156,6 +157,15 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
.tint(new Color(0x004085bf)));
|
||||
minitable.add(label).pad(5);
|
||||
|
||||
if(notification.location!=null){
|
||||
minitable.addListener(new ClickListener(){
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
setCenterPosition(notification.location);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
notificationsTable.add(minitable).pad(5);
|
||||
notificationsTable.row();
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class TechPickerScreen extends PickerScreen {
|
||||
if (isFreeTechPick) {
|
||||
civTech.techsResearched.add(selectedTech.name);
|
||||
civTech.freeTechs-=1;
|
||||
game.civInfo.notifications.add("We have stumbled upon the discovery of "+selectedTech.name+"!");
|
||||
game.civInfo.addNotification("We have stumbled upon the discovery of "+selectedTech.name+"!",null);
|
||||
if(selectedTech.name.equals(civTech.currentTechnology()))
|
||||
civTech.techsToResearch.remove(selectedTech.name);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user