From 546472b528aa48a8c6da944f014f19f7c9e900a4 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 11 Jan 2018 22:22:51 +0200 Subject: [PATCH] Organized classes into folders --- .../src/com/unciv/game/AndroidLauncher.java | 2 +- .../city}/CityConstructions.java | 21 +++--- .../{civinfo => logic/city}/CityInfo.java | 34 +++++----- .../city}/IConstruction.java | 2 +- .../civilization}/CivilizationInfo.java | 35 +++++----- .../civilization/CivilizationPolicies.java | 8 +++ .../civilization}/CivilizationTech.java | 3 +- .../civilization}/ScienceVictory.java | 4 +- .../unciv/{civinfo => logic/map}/MapUnit.java | 8 +-- .../{civinfo => logic/map}/RoadStatus.java | 2 +- .../{civinfo => logic/map}/TileInfo.java | 12 ++-- .../unciv/{civinfo => logic/map}/TileMap.java | 45 ++++++------- core/src/com/unciv/models/LinqHashMap.java | 10 --- .../com/unciv/models/gamebasics/Building.java | 36 +++++------ .../unciv/models/gamebasics/GameBasics.java | 5 +- .../com/unciv/models/gamebasics/Policy.java | 4 +- .../unciv/models/gamebasics/PolicyBranch.java | 5 +- .../models/gamebasics/TileImprovement.java | 2 +- .../{civinfo => models/gamebasics}/Unit.java | 9 ++- .../{LinqCollection.java => linq/Linq.java} | 35 +++++----- .../unciv/models/{ => linq}/LinqCounter.java | 2 +- .../com/unciv/models/linq/LinqHashMap.java | 10 +++ .../com/unciv/{game => ui}/CityScreen.java | 42 +++++------- .../unciv/{game => ui}/CivilopediaScreen.java | 5 +- .../com/unciv/{game => ui}/GameSettings.java | 2 +- .../{game => ui}/ScienceVictoryScreen.java | 15 ++--- .../src/com/unciv/{game => ui}/TileGroup.java | 28 ++++---- .../src/com/unciv/{game => ui}/UnCivGame.java | 22 +++---- .../com/unciv/{game => ui}/VictoryScreen.java | 4 +- .../com/unciv/{game => ui}/WorldScreen.java | 64 +++++++++---------- .../unciv/{game => ui}/WorldTileGroup.java | 9 ++- .../ConstructionPickerScreen.java | 17 ++--- .../GreatPersonPickerScreen.java | 34 ++++++++++ .../ImprovementPickerScreen.java | 15 +---- .../pickerscreens/PickerScreen.java | 15 ++++- .../pickerscreens/PolicyPickerScreen.java | 18 +++--- .../pickerscreens/TechPickerScreen.java | 23 +++---- .../utils/CameraStageBaseScreen.java | 18 ++---- .../unciv/{game => ui}/utils/GameSaver.java | 6 +- .../com/unciv/{game => ui}/utils/HexMath.java | 9 ++- .../unciv/{game => ui}/utils/ImageGetter.java | 2 +- .../unciv/game/desktop/DesktopLauncher.java | 2 +- .../com/unciv/game/client/HtmlLauncher.java | 2 +- ios/src/com/unciv/game/IOSLauncher.java | 2 +- 44 files changed, 328 insertions(+), 320 deletions(-) rename core/src/com/unciv/{civinfo => logic/city}/CityConstructions.java (91%) rename core/src/com/unciv/{civinfo => logic/city}/CityInfo.java (95%) rename core/src/com/unciv/{civinfo => logic/city}/IConstruction.java (91%) rename core/src/com/unciv/{civinfo => logic/civilization}/CivilizationInfo.java (90%) create mode 100644 core/src/com/unciv/logic/civilization/CivilizationPolicies.java rename core/src/com/unciv/{civinfo => logic/civilization}/CivilizationTech.java (98%) rename core/src/com/unciv/{civinfo => logic/civilization}/ScienceVictory.java (86%) rename core/src/com/unciv/{civinfo => logic/map}/MapUnit.java (96%) rename core/src/com/unciv/{civinfo => logic/map}/RoadStatus.java (67%) rename core/src/com/unciv/{civinfo => logic/map}/TileInfo.java (95%) rename core/src/com/unciv/{civinfo => logic/map}/TileMap.java (81%) delete mode 100644 core/src/com/unciv/models/LinqHashMap.java rename core/src/com/unciv/{civinfo => models/gamebasics}/Unit.java (83%) rename core/src/com/unciv/models/{LinqCollection.java => linq/Linq.java} (54%) rename core/src/com/unciv/models/{ => linq}/LinqCounter.java (96%) create mode 100644 core/src/com/unciv/models/linq/LinqHashMap.java rename core/src/com/unciv/{game => ui}/CityScreen.java (93%) rename core/src/com/unciv/{game => ui}/CivilopediaScreen.java (97%) rename core/src/com/unciv/{game => ui}/GameSettings.java (90%) rename core/src/com/unciv/{game => ui}/ScienceVictoryScreen.java (85%) rename core/src/com/unciv/{game => ui}/TileGroup.java (82%) rename core/src/com/unciv/{game => ui}/UnCivGame.java (89%) rename core/src/com/unciv/{game => ui}/VictoryScreen.java (92%) rename core/src/com/unciv/{game => ui}/WorldScreen.java (93%) rename core/src/com/unciv/{game => ui}/WorldTileGroup.java (93%) rename core/src/com/unciv/{game => ui}/pickerscreens/ConstructionPickerScreen.java (86%) create mode 100644 core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.java rename core/src/com/unciv/{game => ui}/pickerscreens/ImprovementPickerScreen.java (77%) rename core/src/com/unciv/{game => ui}/pickerscreens/PickerScreen.java (80%) rename core/src/com/unciv/{game => ui}/pickerscreens/PolicyPickerScreen.java (93%) rename core/src/com/unciv/{game => ui}/pickerscreens/TechPickerScreen.java (90%) rename core/src/com/unciv/{game => ui}/utils/CameraStageBaseScreen.java (87%) rename core/src/com/unciv/{game => ui}/utils/GameSaver.java (85%) rename core/src/com/unciv/{game => ui}/utils/HexMath.java (92%) rename core/src/com/unciv/{game => ui}/utils/ImageGetter.java (98%) diff --git a/android/src/com/unciv/game/AndroidLauncher.java b/android/src/com/unciv/game/AndroidLauncher.java index bd2ecc48cd..86edfc276b 100644 --- a/android/src/com/unciv/game/AndroidLauncher.java +++ b/android/src/com/unciv/game/AndroidLauncher.java @@ -10,6 +10,6 @@ public class AndroidLauncher extends AndroidApplication { protected void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); - initialize(new UnCivGame(), config); + initialize(new com.unciv.ui.UnCivGame(), config); } } diff --git a/core/src/com/unciv/civinfo/CityConstructions.java b/core/src/com/unciv/logic/city/CityConstructions.java similarity index 91% rename from core/src/com/unciv/civinfo/CityConstructions.java rename to core/src/com/unciv/logic/city/CityConstructions.java index 1b726dc9ad..f2e2a3c2a4 100644 --- a/core/src/com/unciv/civinfo/CityConstructions.java +++ b/core/src/com/unciv/logic/city/CityConstructions.java @@ -1,9 +1,10 @@ -package com.unciv.civinfo; +package com.unciv.logic.city; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Predicate; -import com.unciv.game.UnCivGame; -import com.unciv.models.LinqCollection; +import com.unciv.logic.civilization.CivilizationInfo; +import com.unciv.ui.UnCivGame; +import com.unciv.models.linq.Linq; import com.unciv.models.gamebasics.Building; import com.unciv.models.gamebasics.GameBasics; import com.unciv.models.stats.FullStats; @@ -25,7 +26,7 @@ public class CityConstructions cityLocation = cityInfo.cityLocation; } - public LinqCollection builtBuildings = new LinqCollection(); + public Linq builtBuildings = new Linq(); public HashMap inProgressConstructions = new HashMap(); public String currentConstruction; // default starting building! public IConstruction getCurrentConstruction(){return getConstruction(currentConstruction);} @@ -42,7 +43,7 @@ public class CityConstructions return null; } - public LinqCollection getBuiltBuildings(){ return builtBuildings.select(new LinqCollection.Func() { + public Linq getBuiltBuildings(){ return builtBuildings.select(new Linq.Func() { @Override public Building GetBy(String arg0) { return GameBasics.Buildings.get(arg0); @@ -83,7 +84,7 @@ public class CityConstructions } - void chooseNextConstruction() { + public void chooseNextConstruction() { currentConstruction = getBuildableBuildings().first(new Predicate() { @Override public boolean evaluate(String arg0) { @@ -97,14 +98,14 @@ public class CityConstructions } - public LinqCollection getBuildableBuildings() + public Linq getBuildableBuildings() { final CityConstructions self=this; - return new LinqCollection(GameBasics.Buildings.values()) + return new Linq(GameBasics.Buildings.values()) .where(new Predicate() { @Override public boolean evaluate(Building arg0) { return (arg0.isBuildable(self)); } - }).select(new LinqCollection.Func() { + }).select(new Linq.Func() { @Override public String GetBy(Building arg0) { return arg0.name; @@ -186,7 +187,7 @@ public class CityConstructions } public void addCultureBuilding() { - for (String string : new LinqCollection("Monument","Temple","Opera House","Museum")){ + for (String string : new Linq("Monument","Temple","Opera House","Museum")){ if(!builtBuildings.contains(string)){ builtBuildings.add(string); if(currentConstruction.equals(string)) diff --git a/core/src/com/unciv/civinfo/CityInfo.java b/core/src/com/unciv/logic/city/CityInfo.java similarity index 95% rename from core/src/com/unciv/civinfo/CityInfo.java rename to core/src/com/unciv/logic/city/CityInfo.java index 11ef57d550..4b6956909b 100644 --- a/core/src/com/unciv/civinfo/CityInfo.java +++ b/core/src/com/unciv/logic/city/CityInfo.java @@ -1,11 +1,15 @@ -package com.unciv.civinfo; +package com.unciv.logic.city; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Predicate; -import com.unciv.game.UnCivGame; -import com.unciv.models.LinqCollection; -import com.unciv.models.LinqCounter; -import com.unciv.models.LinqHashMap; +import com.unciv.logic.civilization.CivilizationInfo; +import com.unciv.logic.map.RoadStatus; +import com.unciv.logic.map.TileInfo; +import com.unciv.logic.map.TileMap; +import com.unciv.ui.UnCivGame; +import com.unciv.models.linq.Linq; +import com.unciv.models.linq.LinqCounter; +import com.unciv.models.linq.LinqHashMap; import com.unciv.models.gamebasics.Building; import com.unciv.models.gamebasics.GameBasics; import com.unciv.models.gamebasics.TileResource; @@ -27,7 +31,7 @@ public class CityInfo { private TileMap getTileMap(){return UnCivGame.Current.civInfo.tileMap; } public TileInfo getTile(){return getTileMap().get(cityLocation);} - public LinqCollection getTilesInRange(){ + public Linq getTilesInRange(){ return getTileMap().getTilesInDistance(cityLocation,3).where(new Predicate() { @Override public boolean evaluate(TileInfo arg0) { @@ -56,7 +60,7 @@ public class CityInfo { return (int)Math.round(a); } - CityInfo(CivilizationInfo civInfo, Vector2 cityLocation) { + public CityInfo(CivilizationInfo civInfo, Vector2 cityLocation) { name = CityNames[civInfo.cities.size()]; this.cityLocation = cityLocation; civInfo.cities.add(this); @@ -264,7 +268,7 @@ public class CityInfo { return happiness; } - void nextTurn() { + public void nextTurn() { FullStats stats = cityStats; if (cityConstructions.currentConstruction.equals(CityConstructions.Settler) && stats.food > 0) { stats.production += stats.food; @@ -299,10 +303,10 @@ public class CityInfo { private void addNewTile(){ cultureStored -= getCultureToNextTile(); tilesClaimed++; - LinqCollection possibleNewTileVectors = new LinqCollection(); + Linq possibleNewTileVectors = new Linq(); for (int i = 2; i <4 ; i++) { - LinqCollection tiles = getTileMap().getTilesInDistance(cityLocation,i); + Linq tiles = getTileMap().getTilesInDistance(cityLocation,i); tiles = tiles.where(new Predicate() { @Override public boolean evaluate(TileInfo arg0) { @@ -359,11 +363,11 @@ public class CityInfo { private boolean isConnectedToCapital(RoadStatus roadType){ if(CivilizationInfo.current().getCapital()==null) return false;// first city! TileInfo capitalTile = CivilizationInfo.current().getCapital().getTile(); - LinqCollection tilesReached = new LinqCollection(); - LinqCollection tilesToCheck = new LinqCollection(); + Linq tilesReached = new Linq(); + Linq tilesToCheck = new Linq(); tilesToCheck.add(getTile()); while(!tilesToCheck.isEmpty()){ - LinqCollection newTiles = new LinqCollection(); + Linq newTiles = new Linq(); for(TileInfo tile : tilesToCheck) for (TileInfo maybeNewTile : getTileMap().getTilesInDistance(tile.position,1)) if(!tilesReached.contains(maybeNewTile) && !tilesToCheck.contains(maybeNewTile) && !newTiles.contains(maybeNewTile) @@ -384,8 +388,8 @@ public class CityInfo { return 15 + 6 * (population - 1) + (int)Math.floor(Math.pow(population - 1, 1.8f)); } - public LinqCollection getBuildingUniques(){ - return cityConstructions.getBuiltBuildings().select(new LinqCollection.Func() { + public Linq getBuildingUniques(){ + return cityConstructions.getBuiltBuildings().select(new Linq.Func() { @Override public String GetBy(Building arg0) { return arg0.unique; diff --git a/core/src/com/unciv/civinfo/IConstruction.java b/core/src/com/unciv/logic/city/IConstruction.java similarity index 91% rename from core/src/com/unciv/civinfo/IConstruction.java rename to core/src/com/unciv/logic/city/IConstruction.java index 7177f462df..38b14f91a9 100644 --- a/core/src/com/unciv/civinfo/IConstruction.java +++ b/core/src/com/unciv/logic/city/IConstruction.java @@ -1,4 +1,4 @@ -package com.unciv.civinfo; +package com.unciv.logic.city; import com.unciv.models.stats.INamed; diff --git a/core/src/com/unciv/civinfo/CivilizationInfo.java b/core/src/com/unciv/logic/civilization/CivilizationInfo.java similarity index 90% rename from core/src/com/unciv/civinfo/CivilizationInfo.java rename to core/src/com/unciv/logic/civilization/CivilizationInfo.java index d53f1b8d53..0b5f673ea8 100644 --- a/core/src/com/unciv/civinfo/CivilizationInfo.java +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.java @@ -1,11 +1,15 @@ -package com.unciv.civinfo; +package com.unciv.logic.civilization; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Predicate; -import com.unciv.game.UnCivGame; -import com.unciv.game.pickerscreens.PolicyPickerScreen; -import com.unciv.models.LinqCollection; -import com.unciv.models.LinqCounter; +import com.unciv.logic.city.CityInfo; +import com.unciv.logic.map.RoadStatus; +import com.unciv.logic.map.TileInfo; +import com.unciv.logic.map.TileMap; +import com.unciv.ui.UnCivGame; +import com.unciv.ui.pickerscreens.PolicyPickerScreen; +import com.unciv.models.linq.Linq; +import com.unciv.models.linq.LinqCounter; import com.unciv.models.gamebasics.Building; import com.unciv.models.gamebasics.GameBasics; import com.unciv.models.gamebasics.ResourceType; @@ -14,11 +18,6 @@ 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. - */ @@ -35,7 +34,7 @@ public class CivilizationInfo { public FullStats greatPersonPoints = new FullStats(); public CivilizationTech tech = new CivilizationTech(); - public LinqCollection policies = new LinqCollection(); + public Linq policies = new Linq(); public int freePolicies=0; public int turns = 1; @@ -48,13 +47,13 @@ public class CivilizationInfo { this.location = location; } } - public LinqCollection notifications = new LinqCollection(); + public Linq notifications = new Linq(); public void addNotification(String text, Vector2 location){ notifications.add(new Notification(text,location)); } - public LinqCollection tutorial = new LinqCollection(); + public Linq tutorial = new Linq(); - public LinqCollection cities = new LinqCollection(); + public Linq cities = new Linq(); public TileMap tileMap = new TileMap(20); public ScienceVictory scienceVictory = new ScienceVictory(); @@ -195,7 +194,7 @@ public class CivilizationInfo { int happiness = baseHappiness; int happinessPerUniqueLuxury = 5; if(policies.contains("Protectionism")) happinessPerUniqueLuxury+=1; - happiness += new LinqCollection(getCivResources().keySet()).count(new Predicate() { + happiness += new Linq(getCivResources().keySet()).count(new Predicate() { @Override public boolean evaluate(TileResource arg0) { return arg0.resourceType == ResourceType.Luxury; @@ -221,11 +220,11 @@ public class CivilizationInfo { return civResources; } - public LinqCollection getBuildingUniques(){ - return cities.selectMany(new LinqCollection.Func>() { + public Linq getBuildingUniques(){ + return cities.selectMany(new Linq.Func>() { @Override public Collection GetBy(CityInfo arg0) { - return arg0.cityConstructions.getBuiltBuildings().select(new LinqCollection.Func() { + return arg0.cityConstructions.getBuiltBuildings().select(new Linq.Func() { @Override public String GetBy(Building arg0) { return arg0.unique; diff --git a/core/src/com/unciv/logic/civilization/CivilizationPolicies.java b/core/src/com/unciv/logic/civilization/CivilizationPolicies.java new file mode 100644 index 0000000000..92eba85223 --- /dev/null +++ b/core/src/com/unciv/logic/civilization/CivilizationPolicies.java @@ -0,0 +1,8 @@ +package com.unciv.logic.civilization; + +/** + * Created by LENOVO on 1/11/2018. + */ + +class CivilizationPolicies { +} diff --git a/core/src/com/unciv/civinfo/CivilizationTech.java b/core/src/com/unciv/logic/civilization/CivilizationTech.java similarity index 98% rename from core/src/com/unciv/civinfo/CivilizationTech.java rename to core/src/com/unciv/logic/civilization/CivilizationTech.java index 43f61c8921..544d0570b8 100644 --- a/core/src/com/unciv/civinfo/CivilizationTech.java +++ b/core/src/com/unciv/logic/civilization/CivilizationTech.java @@ -1,6 +1,7 @@ -package com.unciv.civinfo; +package com.unciv.logic.civilization; import com.badlogic.gdx.utils.Predicate; +import com.unciv.logic.map.TileInfo; import com.unciv.models.gamebasics.GameBasics; import com.unciv.models.gamebasics.Technology; import com.unciv.models.gamebasics.TileResource; diff --git a/core/src/com/unciv/civinfo/ScienceVictory.java b/core/src/com/unciv/logic/civilization/ScienceVictory.java similarity index 86% rename from core/src/com/unciv/civinfo/ScienceVictory.java rename to core/src/com/unciv/logic/civilization/ScienceVictory.java index 3c2495e07c..9fb8ab4d52 100644 --- a/core/src/com/unciv/civinfo/ScienceVictory.java +++ b/core/src/com/unciv/logic/civilization/ScienceVictory.java @@ -1,6 +1,6 @@ -package com.unciv.civinfo; +package com.unciv.logic.civilization; -import com.unciv.models.LinqCounter; +import com.unciv.models.linq.LinqCounter; public class ScienceVictory{ public LinqCounter requiredParts = new LinqCounter(){ diff --git a/core/src/com/unciv/civinfo/MapUnit.java b/core/src/com/unciv/logic/map/MapUnit.java similarity index 96% rename from core/src/com/unciv/civinfo/MapUnit.java rename to core/src/com/unciv/logic/map/MapUnit.java index 0338e90043..520092140e 100644 --- a/core/src/com/unciv/civinfo/MapUnit.java +++ b/core/src/com/unciv/logic/map/MapUnit.java @@ -1,9 +1,9 @@ -package com.unciv.civinfo; +package com.unciv.logic.map; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Predicate; -import com.unciv.models.LinqCollection; -import com.unciv.models.LinqHashMap; +import com.unciv.logic.civilization.CivilizationInfo; +import com.unciv.models.linq.Linq; import com.unciv.models.gamebasics.GameBasics; public class MapUnit{ @@ -115,7 +115,7 @@ public class MapUnit{ */ public TileInfo headTowards(Vector2 origin, Vector2 destination){ TileMap tileMap = CivilizationInfo.current().tileMap; - LinqCollection path = tileMap.getShortestPath(origin,destination,currentMovement,maxMovement); + Linq path = tileMap.getShortestPath(origin,destination,currentMovement,maxMovement); TileInfo destinationThisTurn = path.get(0); if(destinationThisTurn.unit!=null) return null; diff --git a/core/src/com/unciv/civinfo/RoadStatus.java b/core/src/com/unciv/logic/map/RoadStatus.java similarity index 67% rename from core/src/com/unciv/civinfo/RoadStatus.java rename to core/src/com/unciv/logic/map/RoadStatus.java index 76402d35f2..65dc91f8df 100644 --- a/core/src/com/unciv/civinfo/RoadStatus.java +++ b/core/src/com/unciv/logic/map/RoadStatus.java @@ -1,4 +1,4 @@ -package com.unciv.civinfo; +package com.unciv.logic.map; public enum RoadStatus{ None, diff --git a/core/src/com/unciv/civinfo/TileInfo.java b/core/src/com/unciv/logic/map/TileInfo.java similarity index 95% rename from core/src/com/unciv/civinfo/TileInfo.java rename to core/src/com/unciv/logic/map/TileInfo.java index f1c93fd8af..d56f6d2d73 100644 --- a/core/src/com/unciv/civinfo/TileInfo.java +++ b/core/src/com/unciv/logic/map/TileInfo.java @@ -1,9 +1,11 @@ -package com.unciv.civinfo; +package com.unciv.logic.map; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Predicate; -import com.unciv.game.UnCivGame; -import com.unciv.models.LinqCollection; +import com.unciv.logic.city.CityInfo; +import com.unciv.logic.civilization.CivilizationInfo; +import com.unciv.ui.UnCivGame; +import com.unciv.models.linq.Linq; import com.unciv.models.gamebasics.GameBasics; import com.unciv.models.gamebasics.Terrain; import com.unciv.models.gamebasics.TileImprovement; @@ -84,7 +86,7 @@ public class TileInfo if (isResearched(improvement.improvingTech)) stats.add(improvement.improvingTechStats); // eg Chemistry for mines if(improvement.name.equals("Trading post") && CivilizationInfo.current().policies.contains("Free Thought")) stats.science+=1; - if(new LinqCollection("Academy","Landmark","Manufactory","Customs House").contains(improvement.name) + if(new Linq("Academy","Landmark","Manufactory","Customs House").contains(improvement.name) && CivilizationInfo.current().policies.contains("Freedom Complete")) stats.add(improvement); // again, for the double effect } @@ -168,7 +170,7 @@ public class TileInfo unit = null; } - public LinqCollection getNeighbors(){ + public Linq getNeighbors(){ return CivilizationInfo.current().tileMap.getTilesAtDistance(position,1); } } \ No newline at end of file diff --git a/core/src/com/unciv/civinfo/TileMap.java b/core/src/com/unciv/logic/map/TileMap.java similarity index 81% rename from core/src/com/unciv/civinfo/TileMap.java rename to core/src/com/unciv/logic/map/TileMap.java index 53d0eca4dc..f91b5a571b 100644 --- a/core/src/com/unciv/civinfo/TileMap.java +++ b/core/src/com/unciv/logic/map/TileMap.java @@ -1,10 +1,11 @@ -package com.unciv.civinfo; +package com.unciv.logic.map; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Predicate; -import com.unciv.game.utils.HexMath; -import com.unciv.models.LinqCollection; -import com.unciv.models.LinqHashMap; +import com.unciv.logic.civilization.CivilizationInfo; +import com.unciv.ui.utils.HexMath; +import com.unciv.models.linq.Linq; +import com.unciv.models.linq.LinqHashMap; import com.unciv.models.gamebasics.GameBasics; import com.unciv.models.gamebasics.ResourceType; import com.unciv.models.gamebasics.Terrain; @@ -25,7 +26,7 @@ public class TileMap{ private void addRandomTile(Vector2 position) { final TileInfo tileInfo = new TileInfo(); tileInfo.position = position; - LinqCollection Terrains = GameBasics.Terrains.linqValues(); + Linq Terrains = GameBasics.Terrains.linqValues(); final Terrain baseTerrain = Terrains.where(new Predicate() { @Override @@ -47,7 +48,7 @@ public class TileMap{ } } - LinqCollection TileResources = GameBasics.TileResources.linqValues(); + Linq TileResources = GameBasics.TileResources.linqValues(); // Resources are placed according to TerrainFeature, if exists, otherwise according to BaseLayer. TileResources = TileResources.where(new Predicate() { @@ -74,8 +75,8 @@ public class TileMap{ public TileInfo get(Vector2 vector){return tiles.get(vector.toString());} - public LinqCollection getTilesInDistance(Vector2 origin, int distance){ - LinqCollection tiles = new LinqCollection(); + public Linq getTilesInDistance(Vector2 origin, int distance){ + Linq tiles = new Linq(); for(Vector2 vector : HexMath.GetVectorsInDistance(origin, distance)) if(contains(vector)) @@ -84,8 +85,8 @@ public class TileMap{ return tiles; } - public LinqCollection getTilesAtDistance(Vector2 origin, int distance){ - LinqCollection tiles = new LinqCollection(); + public Linq getTilesAtDistance(Vector2 origin, int distance){ + Linq tiles = new Linq(); for(Vector2 vector : HexMath.GetVectorsAtDistance(origin, distance)) if(contains(vector)) @@ -97,10 +98,10 @@ public class TileMap{ public LinqHashMap getDistanceToTilesWithinTurn(Vector2 origin, float currentUnitMovement){ LinqHashMap distanceToTiles = new LinqHashMap(); distanceToTiles.put(get(origin), 0f); - LinqCollection tilesToCheck = new LinqCollection(); + Linq tilesToCheck = new Linq(); tilesToCheck.add(get(origin)); while(!tilesToCheck.isEmpty()){ - LinqCollection updatedTiles = new LinqCollection(); + Linq updatedTiles = new Linq(); for(TileInfo tileToCheck : tilesToCheck) for (TileInfo maybeUpdatedTile : getTilesInDistance(tileToCheck.position,1)) { float distanceBetweenTiles = maybeUpdatedTile.getLastTerrain().movementCost; @@ -124,20 +125,20 @@ public class TileMap{ return distanceToTiles; } - public LinqCollection getShortestPath(Vector2 origin, Vector2 destination, float currentMovement, int maxMovement){ - LinqCollection toCheck = new LinqCollection(get(origin)); + public Linq getShortestPath(Vector2 origin, Vector2 destination, float currentMovement, int maxMovement){ + Linq toCheck = new Linq(get(origin)); LinqHashMap parents = new LinqHashMap(); parents.put(get(origin),null); for (int distance = 1; ; distance++) { - LinqCollection newToCheck = new LinqCollection(); + Linq newToCheck = new Linq(); for (TileInfo ti : toCheck){ for (TileInfo otherTile : getDistanceToTilesWithinTurn(ti.position, distance == 1 ? currentMovement : maxMovement).keySet()){ if(parents.containsKey(otherTile)) continue; // We cannot be faster than anything existing... if(!otherTile.position.equals(destination) && otherTile.unit!=null) continue; // go to parents.put(otherTile,ti); if(otherTile.position.equals(destination)){ - LinqCollection path = new LinqCollection(); + Linq path = new Linq(); TileInfo current = otherTile; while(parents.get(current)!=null){ path.add(current); @@ -152,9 +153,9 @@ public class TileMap{ } } - public LinqCollection values(){return tiles.linqValues();} + public Linq values(){return tiles.linqValues();} - TileResource GetRandomResource(LinqCollection resources, final ResourceType resourceType) { + TileResource GetRandomResource(Linq resources, final ResourceType resourceType) { return resources.where(new Predicate() { @Override public boolean evaluate(TileResource arg0) { @@ -174,16 +175,16 @@ public class TileMap{ public int getTileHeight(TileInfo tileInfo){ int height=0; - if(new LinqCollection("Forest","Jungle").contains(tileInfo.terrainFeature)) height+=1; + if(new Linq("Forest","Jungle").contains(tileInfo.terrainFeature)) height+=1; if("Hill".equals(tileInfo.baseTerrain)) height+=2; return height; } - public LinqCollection getViewableTiles(Vector2 position, int sightDistance){ - final LinqCollection tiles = getTilesInDistance(position,1); + public Linq getViewableTiles(Vector2 position, int sightDistance){ + final Linq tiles = getTilesInDistance(position,1); if(get(position).baseTerrain.equals("Hill")) sightDistance+=1; for (int i = 0; i <= sightDistance; i++) { - LinqCollection tilesForLayer = new LinqCollection(); + Linq tilesForLayer = new Linq(); for (final TileInfo tile : getTilesAtDistance(position, i)) if (tile.getNeighbors().any(new Predicate() { @Override diff --git a/core/src/com/unciv/models/LinqHashMap.java b/core/src/com/unciv/models/LinqHashMap.java deleted file mode 100644 index ba58b71dc4..0000000000 --- a/core/src/com/unciv/models/LinqHashMap.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.unciv.models; - -import java.util.LinkedHashMap; - -public class LinqHashMap extends LinkedHashMap { - public LinqCollection linqValues() { - return new LinqCollection(super.values()); - } -} - diff --git a/core/src/com/unciv/models/gamebasics/Building.java b/core/src/com/unciv/models/gamebasics/Building.java index 6e5b253cfb..94ef3665c9 100644 --- a/core/src/com/unciv/models/gamebasics/Building.java +++ b/core/src/com/unciv/models/gamebasics/Building.java @@ -1,21 +1,19 @@ package com.unciv.models.gamebasics; import com.badlogic.gdx.utils.Predicate; -import com.unciv.civinfo.CityInfo; -import com.unciv.civinfo.CivilizationInfo; -import com.unciv.civinfo.CityConstructions; -import com.unciv.civinfo.IConstruction; -import com.unciv.civinfo.TileInfo; -import com.unciv.game.ScienceVictoryScreen; -import com.unciv.game.UnCivGame; -import com.unciv.game.VictoryScreen; -import com.unciv.game.pickerscreens.PolicyPickerScreen; -import com.unciv.models.LinqCollection; +import com.unciv.logic.city.CityInfo; +import com.unciv.logic.civilization.CivilizationInfo; +import com.unciv.logic.city.CityConstructions; +import com.unciv.logic.city.IConstruction; +import com.unciv.logic.map.TileInfo; +import com.unciv.ui.ScienceVictoryScreen; +import com.unciv.ui.UnCivGame; +import com.unciv.ui.VictoryScreen; +import com.unciv.ui.pickerscreens.PolicyPickerScreen; +import com.unciv.models.linq.Linq; import com.unciv.models.stats.FullStats; import com.unciv.models.stats.NamedStats; -import java.util.ArrayList; - public class Building extends NamedStats implements IConstruction, ICivilopedia { public String description; public String requiredTech; @@ -34,7 +32,7 @@ public class Building extends NamedStats implements IConstruction, ICivilopedia public String requiredBuilding; public String requiredBuildingInAllCities; public String requiredResource; // A strategic resource that will be consumed by this building - public LinqCollection requiredNearbyImprovedResources; // City can only be built if one of these resources is nearby - it must be improved! + public Linq requiredNearbyImprovedResources; // City can only be built if one of these resources is nearby - it must be improved! public String cannotBeBuiltWith; // Uniques @@ -50,21 +48,21 @@ public class Building extends NamedStats implements IConstruction, ICivilopedia public FullStats getStats(){ FullStats stats = new FullStats(this); - LinqCollection policies = CivilizationInfo.current().policies; + Linq policies = CivilizationInfo.current().policies; if (policies.contains("Organized Religion") && - new LinqCollection("Monument","Temple","Monastery").contains(name)) + new Linq("Monument","Temple","Monastery").contains(name)) stats.happiness+=1; if (policies.contains("Free Religion") && - new LinqCollection("Monument","Temple","Monastery").contains(name)) + new Linq("Monument","Temple","Monastery").contains(name)) stats.culture+=1; if (policies.contains("Entrepreneurship") && - new LinqCollection("Mint","Market","Bank","Stock Market").contains(name)) + new Linq("Mint","Market","Bank","Stock Market").contains(name)) stats.science+=1; if (policies.contains("Humanism") && - new LinqCollection("University","Observatory","Public School").contains(name)) + new Linq("University","Observatory","Public School").contains(name)) stats.science+=1; if (policies.contains("Theocracy") && name.equals("Temple")) @@ -121,7 +119,7 @@ public class Building extends NamedStats implements IConstruction, ICivilopedia public boolean evaluate(TileResource arg0) { return name.equals(arg0.building); } - }).select(new LinqCollection.Func() { + }).select(new Linq.Func() { @Override public String GetBy(TileResource arg0) { return arg0.name; diff --git a/core/src/com/unciv/models/gamebasics/GameBasics.java b/core/src/com/unciv/models/gamebasics/GameBasics.java index 36e40921c2..978ae5c45b 100644 --- a/core/src/com/unciv/models/gamebasics/GameBasics.java +++ b/core/src/com/unciv/models/gamebasics/GameBasics.java @@ -1,7 +1,6 @@ package com.unciv.models.gamebasics; -import com.unciv.civinfo.Unit; -import com.unciv.models.LinqHashMap; +import com.unciv.models.linq.LinqHashMap; import java.util.LinkedHashMap; @@ -12,6 +11,6 @@ public class GameBasics{ public static LinqHashMap TileImprovements; public static LinqHashMap Technologies; public static LinqHashMap Helps; - public static LinkedHashMap Units; + public static LinqHashMap Units; public static LinkedHashMap PolicyBranches; } \ No newline at end of file diff --git a/core/src/com/unciv/models/gamebasics/Policy.java b/core/src/com/unciv/models/gamebasics/Policy.java index 33cc620502..94d760d333 100644 --- a/core/src/com/unciv/models/gamebasics/Policy.java +++ b/core/src/com/unciv/models/gamebasics/Policy.java @@ -1,6 +1,6 @@ package com.unciv.models.gamebasics; -import com.unciv.models.LinqCollection; +import com.unciv.models.linq.Linq; import com.unciv.models.stats.INamed; /** @@ -13,7 +13,7 @@ public class Policy implements INamed{ public String branch; public int row; public int column; - public LinqCollection requires; + public Linq requires; @Override public String getName() { diff --git a/core/src/com/unciv/models/gamebasics/PolicyBranch.java b/core/src/com/unciv/models/gamebasics/PolicyBranch.java index 3e82f994ec..7bf2508d9f 100644 --- a/core/src/com/unciv/models/gamebasics/PolicyBranch.java +++ b/core/src/com/unciv/models/gamebasics/PolicyBranch.java @@ -1,8 +1,7 @@ package com.unciv.models.gamebasics; -import com.unciv.models.LinqCollection; -import com.unciv.models.stats.INamed; +import com.unciv.models.linq.Linq; public class PolicyBranch extends Policy{ - public LinqCollection policies; + public Linq policies; } diff --git a/core/src/com/unciv/models/gamebasics/TileImprovement.java b/core/src/com/unciv/models/gamebasics/TileImprovement.java index e934a77b73..3784d6f74b 100644 --- a/core/src/com/unciv/models/gamebasics/TileImprovement.java +++ b/core/src/com/unciv/models/gamebasics/TileImprovement.java @@ -1,6 +1,6 @@ package com.unciv.models.gamebasics; -import com.unciv.civinfo.CivilizationInfo; +import com.unciv.logic.civilization.CivilizationInfo; import com.unciv.models.stats.FullStats; import com.unciv.models.stats.NamedStats; diff --git a/core/src/com/unciv/civinfo/Unit.java b/core/src/com/unciv/models/gamebasics/Unit.java similarity index 83% rename from core/src/com/unciv/civinfo/Unit.java rename to core/src/com/unciv/models/gamebasics/Unit.java index 840bb5e0c9..e0b3b31b3a 100644 --- a/core/src/com/unciv/civinfo/Unit.java +++ b/core/src/com/unciv/models/gamebasics/Unit.java @@ -1,9 +1,12 @@ -package com.unciv.civinfo; +package com.unciv.models.gamebasics; -import com.unciv.game.UnCivGame; +import com.unciv.logic.city.IConstruction; +import com.unciv.logic.city.CityConstructions; +import com.unciv.logic.map.MapUnit; +import com.unciv.ui.UnCivGame; import com.unciv.models.stats.INamed; -public class Unit implements INamed, IConstruction{ +public class Unit implements INamed, IConstruction { public String name; public String description; public int cost; diff --git a/core/src/com/unciv/models/LinqCollection.java b/core/src/com/unciv/models/linq/Linq.java similarity index 54% rename from core/src/com/unciv/models/LinqCollection.java rename to core/src/com/unciv/models/linq/Linq.java index e9fca6395c..50478c6509 100644 --- a/core/src/com/unciv/models/LinqCollection.java +++ b/core/src/com/unciv/models/linq/Linq.java @@ -1,4 +1,4 @@ -package com.unciv.models; +package com.unciv.models.linq; import com.badlogic.gdx.utils.Predicate; @@ -7,29 +7,28 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.Stack; /** * Created by LENOVO on 10/20/2017. */ -public class LinqCollection extends ArrayList { - public LinqCollection() { +public class Linq extends ArrayList { + public Linq() { } - public LinqCollection(Collection objects) { + public Linq(Collection objects) { addAll(objects); } - public LinqCollection(T ... objects) { + public Linq(T ... objects) { addAll(Arrays.asList(objects)); } - public LinqCollection where(Predicate p) { - LinqCollection newCollection = new LinqCollection(); + public Linq where(Predicate p) { + Linq newCollection = new Linq(); for (T t : this) if (p.evaluate(t)) newCollection.add(t); return newCollection; } @@ -45,14 +44,14 @@ public class LinqCollection extends ArrayList { return where(p).size(); } - public LinqCollection select(Func selector) { - LinqCollection newCollection = new LinqCollection(); + public Linq select(Func selector) { + Linq newCollection = new Linq(); for (T t : this) newCollection.add(selector.GetBy(t)); return newCollection; } - public LinqCollection selectMany(Func> multiSelector){ - LinqCollection newCollection = new LinqCollection(); + public Linq selectMany(Func> multiSelector){ + Linq newCollection = new Linq(); for(T t:this) newCollection.addAll(multiSelector.GetBy(t)); return newCollection; } @@ -62,22 +61,22 @@ public class LinqCollection extends ArrayList { return get((int) (Math.random() * (size()))); } - public LinqCollection unique() { - return new LinqCollection(new HashSet(this)); // Shove it all into a hashset and build a new one around the results. + public Linq unique() { + return new Linq(new HashSet(this)); // Shove it all into a hashset and build a new one around the results. } public interface Func { public T2 GetBy(T1 arg0); } - public LinqCollection as(Class t2Class){ - LinqCollection newCollection = new LinqCollection(); + public Linq as(Class t2Class){ + Linq newCollection = new Linq(); for (T t:this) newCollection.add((T2)t); return newCollection; } - public LinqCollection reverse(){ - LinqCollection newCol = new LinqCollection(this); + public Linq reverse(){ + Linq newCol = new Linq(this); Collections.reverse(newCol); return newCol; } diff --git a/core/src/com/unciv/models/LinqCounter.java b/core/src/com/unciv/models/linq/LinqCounter.java similarity index 96% rename from core/src/com/unciv/models/LinqCounter.java rename to core/src/com/unciv/models/linq/LinqCounter.java index fb5a172f94..830c4948cb 100644 --- a/core/src/com/unciv/models/LinqCounter.java +++ b/core/src/com/unciv/models/linq/LinqCounter.java @@ -1,4 +1,4 @@ -package com.unciv.models; +package com.unciv.models.linq; import java.util.LinkedHashMap; diff --git a/core/src/com/unciv/models/linq/LinqHashMap.java b/core/src/com/unciv/models/linq/LinqHashMap.java new file mode 100644 index 0000000000..8c41911b07 --- /dev/null +++ b/core/src/com/unciv/models/linq/LinqHashMap.java @@ -0,0 +1,10 @@ +package com.unciv.models.linq; + +import java.util.LinkedHashMap; + +public class LinqHashMap extends LinkedHashMap { + public Linq linqValues() { + return new Linq(super.values()); + } +} + diff --git a/core/src/com/unciv/game/CityScreen.java b/core/src/com/unciv/ui/CityScreen.java similarity index 93% rename from core/src/com/unciv/game/CityScreen.java rename to core/src/com/unciv/ui/CityScreen.java index 0594bb1131..396f7113ba 100644 --- a/core/src/com/unciv/game/CityScreen.java +++ b/core/src/com/unciv/ui/CityScreen.java @@ -1,4 +1,4 @@ -package com.unciv.game; +package com.unciv.ui; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Vector2; @@ -14,28 +14,20 @@ import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.Drawable; import com.badlogic.gdx.utils.Align; -import com.badlogic.gdx.utils.Predicate; -import com.unciv.civinfo.CityInfo; -import com.unciv.civinfo.CivilizationInfo; -import com.unciv.civinfo.IConstruction; -import com.unciv.civinfo.TileInfo; -import com.unciv.game.pickerscreens.ConstructionPickerScreen; -import com.unciv.game.pickerscreens.ImprovementPickerScreen; -import com.unciv.game.utils.CameraStageBaseScreen; -import com.unciv.game.utils.HexMath; -import com.unciv.game.utils.ImageGetter; -import com.unciv.models.LinqCollection; +import com.unciv.logic.city.CityInfo; +import com.unciv.logic.civilization.CivilizationInfo; +import com.unciv.logic.city.IConstruction; +import com.unciv.logic.map.TileInfo; +import com.unciv.ui.utils.CameraStageBaseScreen; +import com.unciv.ui.utils.HexMath; +import com.unciv.models.linq.Linq; import com.unciv.models.gamebasics.Building; -import com.unciv.models.gamebasics.GameBasics; -import com.unciv.models.gamebasics.TileImprovement; import com.unciv.models.stats.FullStats; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; -import javax.print.attribute.standard.MediaSize; - public class CityScreen extends CameraStageBaseScreen { TileInfo selectedTile = null; @@ -55,7 +47,7 @@ public class CityScreen extends CameraStageBaseScreen { addTiles(); stage.addActor(TileTable); - Drawable tileTableBackground = ImageGetter.getDrawable("skin/tileTableBackground.png") + Drawable tileTableBackground = com.unciv.ui.utils.ImageGetter.getDrawable("skin/tileTableBackground.png") .tint(new Color(0x0040804f)); tileTableBackground.setMinHeight(0); tileTableBackground.setMinWidth(0); @@ -80,7 +72,7 @@ public class CityScreen extends CameraStageBaseScreen { stage.addActor(BuildingsTableContainer); update(); - LinqCollection tutorial = new LinqCollection(); + Linq tutorial = new Linq(); tutorial.add("Welcome to your first city!" + "\r\nAs on now, you only have 1 population," + "\r\n but this will grow when you amass enough surplus food"); @@ -121,7 +113,7 @@ public class CityScreen extends CameraStageBaseScreen { } private Image getSpecialistIcon(String imageName, final String building, final boolean isFilled, final FullStats specialistType) { - Image specialist = ImageGetter.getImage(imageName); + Image specialist = com.unciv.ui.utils.ImageGetter.getImage(imageName); specialist.setSize(50,50); if(!isFilled) specialist.setColor(Color.GRAY); specialist.addListener(new ClickListener(){ @@ -146,9 +138,9 @@ public class CityScreen extends CameraStageBaseScreen { BuildingsTable.clear(); - LinqCollection Wonders = new LinqCollection(); - LinqCollection SpecialistBuildings = new LinqCollection(); - LinqCollection Others = new LinqCollection(); + Linq Wonders = new Linq(); + Linq SpecialistBuildings = new Linq(); + Linq Others = new Linq(); for(Building building : getCity().cityConstructions.getBuiltBuildings()) { if (building.isWonder) Wonders.add(building); @@ -360,7 +352,7 @@ public class CityScreen extends CameraStageBaseScreen { CityStatsValues.put("Population",cityInfo.getFreePopulation()+"/"+cityInfo.population); for(String key : CityStatsValues.keySet()){ - CityStatsTable.add(ImageGetter.getStatIcon(key)).align(Align.right); + CityStatsTable.add(com.unciv.ui.utils.ImageGetter.getStatIcon(key)).align(Align.right); CityStatsTable.add(new Label(CityStatsValues.get(key),skin)).align(Align.left); CityStatsTable.row(); } @@ -373,7 +365,7 @@ public class CityScreen extends CameraStageBaseScreen { buildingPickButton.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y) { - game.setScreen(new ConstructionPickerScreen()); + game.setScreen(new com.unciv.ui.pickerscreens.ConstructionPickerScreen()); dispose(); } }); @@ -434,7 +426,7 @@ public class CityScreen extends CameraStageBaseScreen { for(String key : TileStatsValues.keySet()){ if(TileStatsValues.get(key) == 0) continue; // this tile gives nothing of this stat, so why even display it? - TileTable.add(ImageGetter.getStatIcon(key)).align(Align.right); + TileTable.add(com.unciv.ui.utils.ImageGetter.getStatIcon(key)).align(Align.right); TileTable.add(new Label(Math.round(TileStatsValues.get(key))+"",skin)).align(Align.left); TileTable.row(); } diff --git a/core/src/com/unciv/game/CivilopediaScreen.java b/core/src/com/unciv/ui/CivilopediaScreen.java similarity index 97% rename from core/src/com/unciv/game/CivilopediaScreen.java rename to core/src/com/unciv/ui/CivilopediaScreen.java index 8d81d987f9..5c3b41517c 100644 --- a/core/src/com/unciv/game/CivilopediaScreen.java +++ b/core/src/com/unciv/ui/CivilopediaScreen.java @@ -1,4 +1,4 @@ -package com.unciv.game; +package com.unciv.ui; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; @@ -15,12 +15,13 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Array; import com.unciv.models.gamebasics.GameBasics; import com.unciv.models.gamebasics.ICivilopedia; +import com.unciv.ui.utils.CameraStageBaseScreen; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashMap; -public class CivilopediaScreen extends com.unciv.game.utils.CameraStageBaseScreen { +public class CivilopediaScreen extends CameraStageBaseScreen { public CivilopediaScreen() { Gdx.input.setInputProcessor(stage); Table buttonTable = new Table(); diff --git a/core/src/com/unciv/game/GameSettings.java b/core/src/com/unciv/ui/GameSettings.java similarity index 90% rename from core/src/com/unciv/game/GameSettings.java rename to core/src/com/unciv/ui/GameSettings.java index 11f8c4e995..150d3a6e17 100644 --- a/core/src/com/unciv/game/GameSettings.java +++ b/core/src/com/unciv/ui/GameSettings.java @@ -1,4 +1,4 @@ -package com.unciv.game; +package com.unciv.ui; public class GameSettings{ public float labelScale = 1.5f; diff --git a/core/src/com/unciv/game/ScienceVictoryScreen.java b/core/src/com/unciv/ui/ScienceVictoryScreen.java similarity index 85% rename from core/src/com/unciv/game/ScienceVictoryScreen.java rename to core/src/com/unciv/ui/ScienceVictoryScreen.java index 5a0db44a9d..ffb357213a 100644 --- a/core/src/com/unciv/game/ScienceVictoryScreen.java +++ b/core/src/com/unciv/ui/ScienceVictoryScreen.java @@ -1,16 +1,13 @@ -package com.unciv.game; +package com.unciv.ui; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.scenes.scene2d.Touchable; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; -import com.unciv.civinfo.CivilizationInfo; -import com.unciv.game.pickerscreens.PickerScreen; -import com.unciv.models.LinqCollection; -import com.unciv.models.LinqCounter; +import com.unciv.logic.civilization.CivilizationInfo; +import com.unciv.models.linq.Linq; +import com.unciv.models.linq.LinqCounter; -import java.util.ArrayList; - -public class ScienceVictoryScreen extends PickerScreen { +public class ScienceVictoryScreen extends com.unciv.ui.pickerscreens.PickerScreen { public ScienceVictoryScreen() { LinqCounter builtSpaceshipParts = game.civInfo.scienceVictory.currentParts.clone(); @@ -25,7 +22,7 @@ public class ScienceVictoryScreen extends PickerScreen { descriptionLabel.setText("You must build the Apollo Program before you can build spaceship parts!"); else descriptionLabel.setText("Apollo program is built - you may construct spaceship parts in your cities!"); - LinqCollection tutorial = new LinqCollection(); + Linq tutorial = new Linq(); tutorial.add("This is the science victory screen, where you" + "\r\n can see your progress towards constructing a " + "\r\n spaceship to propel you towards the stars."); diff --git a/core/src/com/unciv/game/TileGroup.java b/core/src/com/unciv/ui/TileGroup.java similarity index 82% rename from core/src/com/unciv/game/TileGroup.java rename to core/src/com/unciv/ui/TileGroup.java index 5660964027..a5ec49d213 100644 --- a/core/src/com/unciv/game/TileGroup.java +++ b/core/src/com/unciv/ui/TileGroup.java @@ -1,4 +1,4 @@ -package com.unciv.game; +package com.unciv.ui; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Vector2; @@ -6,13 +6,9 @@ import com.badlogic.gdx.scenes.scene2d.Group; import com.badlogic.gdx.scenes.scene2d.ui.Container; import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; -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; +import com.unciv.logic.map.RoadStatus; +import com.unciv.logic.map.TileInfo; +import com.unciv.models.linq.LinqHashMap; public class TileGroup extends Group { Image terrainImage; @@ -33,14 +29,14 @@ public class TileGroup extends Group { terrainType = tileInfo.getLastTerrain().name; String terrainFileName = "TerrainIcons/" + terrainType.replace(' ','_') + "_(Civ5).png"; - terrainImage = ImageGetter.getImage(terrainFileName); + terrainImage = com.unciv.ui.utils.ImageGetter.getImage(terrainFileName); terrainImage.setSize(50,50); addActor(terrainImage); } void addPopulationIcon(){ - populationImage = ImageGetter.getImage("StatIcons/populationGreen.png"); + populationImage = com.unciv.ui.utils.ImageGetter.getImage("StatIcons/populationGreen.png"); populationImage.setSize(20,20); populationImage.moveBy(0, terrainImage.getHeight()-populationImage.getHeight()); // top left addActor(populationImage); @@ -63,12 +59,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(ImageGetter.getDrawable(terrainFileName)); // In case we e.g. removed a jungle + terrainImage.setDrawable(com.unciv.ui.utils.ImageGetter.getDrawable(terrainFileName)); // In case we e.g. removed a jungle } if (tileInfo.explored && tileInfo.hasViewableResource() && resourceImage == null) { // Need to add the resource image! String fileName = "ResourceIcons/" + tileInfo.resource + "_(Civ5).png"; - Image image = ImageGetter.getImage(fileName); + Image image = com.unciv.ui.utils.ImageGetter.getImage(fileName); image.setSize(20,20); image.moveBy(terrainImage.getWidth()-image.getWidth(), 0); // bottom right resourceImage = image; @@ -76,7 +72,7 @@ public class TileGroup extends Group { } if (tileInfo.explored && tileInfo.unit != null && unitImage == null) { - unitImage = ImageGetter.getImage("UnitIcons/" + tileInfo.unit.name.replace(" ","_") + "_(Civ5).png"); + unitImage = com.unciv.ui.utils.ImageGetter.getImage("UnitIcons/" + tileInfo.unit.name.replace(" ","_") + "_(Civ5).png"); addActor(unitImage); unitImage.setSize(20, 20); // not moved - is at bottom left } @@ -93,7 +89,7 @@ public class TileGroup extends Group { if (tileInfo.explored && tileInfo.improvement != null &&!tileInfo.improvement.equals(improvementType)) { - improvementImage = ImageGetter.getImage("ImprovementIcons/" + tileInfo.improvement.replace(' ','_') + "_(Civ5).png"); + improvementImage = com.unciv.ui.utils.ImageGetter.getImage("ImprovementIcons/" + tileInfo.improvement.replace(' ','_') + "_(Civ5).png"); addActor(improvementImage); improvementImage.setSize(20, 20); improvementImage.moveBy(terrainImage.getWidth()-improvementImage.getWidth(), @@ -110,11 +106,11 @@ public class TileGroup extends Group { for (TileInfo neighbor : tileInfo.getNeighbors()) { if (neighbor.roadStatus == RoadStatus.None) continue; if (!roadImages.containsKey(neighbor.position.toString())) { - Image image = ImageGetter.getImage(ImageGetter.WhiteDot); + Image image = com.unciv.ui.utils.ImageGetter.getImage(com.unciv.ui.utils.ImageGetter.WhiteDot); roadImages.put(neighbor.position.toString(), image); Vector2 relativeHexPosition = tileInfo.position.cpy().sub(neighbor.position); - Vector2 relativeWorldPosition = HexMath.Hex2WorldCoords(relativeHexPosition); + Vector2 relativeWorldPosition = com.unciv.ui.utils.HexMath.Hex2WorldCoords(relativeHexPosition); // This is some crazy voodoo magic so I'll explain. image.moveBy(25, 25); // Move road to center of tile diff --git a/core/src/com/unciv/game/UnCivGame.java b/core/src/com/unciv/ui/UnCivGame.java similarity index 89% rename from core/src/com/unciv/game/UnCivGame.java rename to core/src/com/unciv/ui/UnCivGame.java index 0ec4101a79..2f5d01372d 100644 --- a/core/src/com/unciv/game/UnCivGame.java +++ b/core/src/com/unciv/ui/UnCivGame.java @@ -1,27 +1,25 @@ -package com.unciv.game; +package com.unciv.ui; import com.badlogic.gdx.Game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Json; -import com.unciv.civinfo.CityInfo; -import com.unciv.civinfo.CivilizationInfo; -import com.unciv.civinfo.Unit; -import com.unciv.game.utils.GameSaver; -import com.unciv.models.LinqCollection; +import com.unciv.logic.city.CityInfo; +import com.unciv.logic.civilization.CivilizationInfo; +import com.unciv.models.gamebasics.Unit; +import com.unciv.models.linq.Linq; import com.unciv.models.gamebasics.BasicHelp; import com.unciv.models.gamebasics.Building; import com.unciv.models.gamebasics.GameBasics; import com.unciv.models.gamebasics.Policy; import com.unciv.models.gamebasics.PolicyBranch; import com.unciv.models.gamebasics.Technology; -import com.unciv.models.LinqHashMap; +import com.unciv.models.linq.LinqHashMap; import com.unciv.models.gamebasics.TechColumn; import com.unciv.models.gamebasics.Terrain; import com.unciv.models.gamebasics.TileImprovement; import com.unciv.models.gamebasics.TileResource; import com.unciv.models.stats.INamed; -import com.unciv.models.stats.NamedStats; public class UnCivGame extends Game { @@ -33,9 +31,9 @@ public class UnCivGame extends Game { public void create() { SetupGameBasics(); Current = this; - if(GameSaver.GetSave("Autosave").exists()) { + if(com.unciv.ui.utils.GameSaver.GetSave("Autosave").exists()) { try { - GameSaver.LoadGame(this, "Autosave"); + com.unciv.ui.utils.GameSaver.LoadGame(this, "Autosave"); for (CityInfo city : this.civInfo.cities) { if(city.cityStats == null) city.updateCityStats(); } @@ -101,12 +99,12 @@ public class UnCivGame extends Game { } for(PolicyBranch branch : GameBasics.PolicyBranches.values()){ - branch.requires=new LinqCollection(); + branch.requires=new Linq(); branch.branch=branch.name; for(Policy policy:branch.policies) { policy.branch=branch.name; if (policy.requires == null) { - policy.requires = new LinqCollection(); + policy.requires = new Linq(); policy.requires.add(branch.name); } } diff --git a/core/src/com/unciv/game/VictoryScreen.java b/core/src/com/unciv/ui/VictoryScreen.java similarity index 92% rename from core/src/com/unciv/game/VictoryScreen.java rename to core/src/com/unciv/ui/VictoryScreen.java index 07cd41eee4..7dfabd8edd 100644 --- a/core/src/com/unciv/game/VictoryScreen.java +++ b/core/src/com/unciv/ui/VictoryScreen.java @@ -1,10 +1,10 @@ -package com.unciv.game; +package com.unciv.ui; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; -import com.unciv.game.utils.CameraStageBaseScreen; +import com.unciv.ui.utils.CameraStageBaseScreen; public class VictoryScreen extends CameraStageBaseScreen{ diff --git a/core/src/com/unciv/game/WorldScreen.java b/core/src/com/unciv/ui/WorldScreen.java similarity index 93% rename from core/src/com/unciv/game/WorldScreen.java rename to core/src/com/unciv/ui/WorldScreen.java index 2e65d5ef3a..dee9c65144 100644 --- a/core/src/com/unciv/game/WorldScreen.java +++ b/core/src/com/unciv/ui/WorldScreen.java @@ -1,11 +1,10 @@ -package com.unciv.game; +package com.unciv.ui; import com.badlogic.gdx.graphics.Color; 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; @@ -16,17 +15,16 @@ import com.badlogic.gdx.scenes.scene2d.utils.Drawable; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Predicate; -import com.unciv.civinfo.CivilizationInfo; -import com.unciv.civinfo.TileInfo; -import com.unciv.game.pickerscreens.ImprovementPickerScreen; -import com.unciv.game.pickerscreens.PolicyPickerScreen; -import com.unciv.game.pickerscreens.TechPickerScreen; -import com.unciv.game.utils.CameraStageBaseScreen; -import com.unciv.game.utils.GameSaver; -import com.unciv.game.utils.HexMath; -import com.unciv.game.utils.ImageGetter; -import com.unciv.models.LinqCollection; -import com.unciv.models.LinqHashMap; +import com.unciv.logic.civilization.CivilizationInfo; +import com.unciv.logic.map.TileInfo; +import com.unciv.ui.pickerscreens.PolicyPickerScreen; +import com.unciv.ui.pickerscreens.TechPickerScreen; +import com.unciv.ui.utils.CameraStageBaseScreen; +import com.unciv.ui.utils.GameSaver; +import com.unciv.ui.utils.HexMath; +import com.unciv.ui.utils.ImageGetter; +import com.unciv.models.linq.Linq; +import com.unciv.models.linq.LinqHashMap; import com.unciv.models.gamebasics.Building; import com.unciv.models.gamebasics.GameBasics; import com.unciv.models.gamebasics.TileImprovement; @@ -47,7 +45,7 @@ public class WorldScreen extends CameraStageBaseScreen { Table tileTable = new Table(); Table civTable = new Table(); TextButton techButton = new TextButton("", skin); - public LinqHashMap tileGroups = new LinqHashMap(); + public LinqHashMap tileGroups = new LinqHashMap(); Table optionsTable = new Table(); Table notificationsTable = new Table(); @@ -59,7 +57,7 @@ public class WorldScreen extends CameraStageBaseScreen { addTiles(); stage.addActor(tileTable); - Drawable tileTableBackground = ImageGetter.getDrawable("skin/tileTableBackground.png") + Drawable tileTableBackground = com.unciv.ui.utils.ImageGetter.getDrawable("skin/tileTableBackground.png") .tint(new Color(0x004085bf)); tileTableBackground.setMinHeight(0); tileTableBackground.setMinWidth(0); @@ -68,7 +66,7 @@ public class WorldScreen extends CameraStageBaseScreen { //notificationsTable.background(ImageGetter.getSingleColorDrawable(new Color(0x004085bf))); - TextureRegionDrawable civBackground = ImageGetter.getDrawable("skin/civTableBackground.png"); + TextureRegionDrawable civBackground = com.unciv.ui.utils.ImageGetter.getDrawable("skin/civTableBackground.png"); civTable.setBackground(civBackground.tint(new Color(0x004085bf))); stage.addActor(civTable); @@ -85,7 +83,7 @@ public class WorldScreen extends CameraStageBaseScreen { addOptionsTable(); - LinqCollection beginningTutorial = new LinqCollection(); + Linq beginningTutorial = new Linq(); beginningTutorial.add("Hello, and welcome to Unciv!" + "\r\nCivilization games can be complex, so we'll" + "\r\n be guiding you along your first journey." + @@ -108,7 +106,7 @@ public class WorldScreen extends CameraStageBaseScreen { selectIdleUnitButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { - LinqCollection tilesWithIdleUnits = game.civInfo.tileMap.values().where(new Predicate() { + Linq tilesWithIdleUnits = game.civInfo.tileMap.values().where(new Predicate() { @Override public boolean evaluate(TileInfo arg0) { return arg0.hasIdleUnit(); @@ -153,7 +151,7 @@ public class WorldScreen extends CameraStageBaseScreen { label.setFontScale(1.2f); Table minitable = new Table(); - minitable.background(ImageGetter.getDrawable("skin/civTableBackground.png") + minitable.background(com.unciv.ui.utils.ImageGetter.getDrawable("skin/civTableBackground.png") .tint(new Color(0x004085bf))); minitable.add(label).pad(5); @@ -174,7 +172,7 @@ public class WorldScreen extends CameraStageBaseScreen { public void update() { if(game.civInfo.tutorial.contains("CityEntered")){ - LinqCollection tutorial = new LinqCollection(); + Linq tutorial = new Linq(); tutorial.add("Once you've done everything you can, " + "\r\nclick the next turn button on the top right to continue."); tutorial.add("Each turn, science, culture and gold are added" + @@ -223,7 +221,7 @@ public class WorldScreen extends CameraStageBaseScreen { OpenScienceVictoryScreen.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { - game.setScreen(new ScienceVictoryScreen()); + game.setScreen(new com.unciv.ui.ScienceVictoryScreen()); } }); optionsTable.add(OpenScienceVictoryScreen).pad(10); @@ -336,7 +334,7 @@ public class WorldScreen extends CameraStageBaseScreen { GameSaver.SaveGame(game, "Autosave"); update(); - LinqCollection tutorial = new LinqCollection(); + Linq tutorial = new Linq(); tutorial.add("In your first couple of turns," + "\r\n you will have very little options," + "\r\n but as your civilization grows, so do the " + @@ -360,13 +358,13 @@ public class WorldScreen extends CameraStageBaseScreen { float bottomY = 0; for (final TileInfo tileInfo : game.civInfo.tileMap.values()) { - final WorldTileGroup group = new WorldTileGroup(tileInfo); + final com.unciv.ui.WorldTileGroup group = new com.unciv.ui.WorldTileGroup(tileInfo); group.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { - LinqCollection tutorial = new LinqCollection(); + Linq tutorial = new Linq(); tutorial.add("Clicking on a tile selects that tile," + "\r\n and displays information on that tile on the bottom-right," + "\r\n as well as unit actions, if the tile contains a unit"); @@ -404,7 +402,7 @@ public class WorldScreen extends CameraStageBaseScreen { bottomY = Math.min(bottomY, group.getY()); } - for (TileGroup group : tileGroups.linqValues()) { + for (com.unciv.ui.TileGroup group : tileGroups.linqValues()) { group.moveBy(-bottomX+50, -bottomY+50); } @@ -465,7 +463,7 @@ public class WorldScreen extends CameraStageBaseScreen { for (String key : TileStatsValues.keySet()) { if (TileStatsValues.get(key) == 0) continue; // this tile gives nothing of this stat, so why even display it? - tileTable.add(com.unciv.game.utils.ImageGetter.getStatIcon(key)).align(Align.right); + tileTable.add(ImageGetter.getStatIcon(key)).align(Align.right); tileTable.add(new Label(Math.round(TileStatsValues.get(key)) + "", skin)).align(Align.left); tileTable.row(); } @@ -491,7 +489,7 @@ public class WorldScreen extends CameraStageBaseScreen { unitTile = selectedTile; // Set all tiles transparent except those in unit range - for (TileGroup TG : tileGroups.linqValues()) TG.setColor(0, 0, 0, 0.3f); + for (com.unciv.ui.TileGroup TG : tileGroups.linqValues()) TG.setColor(0, 0, 0, 0.3f); for (TileInfo tile : game.civInfo.tileMap.getDistanceToTilesWithinTurn(unitTile.position, unitTile.unit.currentMovement).keySet()) { tileGroups.get(tile.position.toString()).setColor(Color.WHITE); } @@ -513,7 +511,7 @@ public class WorldScreen extends CameraStageBaseScreen { new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { - LinqCollection tutorial = new LinqCollection(); + Linq tutorial = new Linq(); tutorial.add("You have founded a city!" + "\r\nCities are the lifeblood of your empire," + "\r\n providing gold and science empire-wide," + @@ -550,7 +548,7 @@ public class WorldScreen extends CameraStageBaseScreen { @Override public void clicked(InputEvent event, float x, float y) { - game.setScreen(new ImprovementPickerScreen(selectedTile)); + game.setScreen(new com.unciv.ui.pickerscreens.ImprovementPickerScreen(selectedTile)); } }); addUnitAction(tileTable, "automation".equals(selectedTile.unit.action) ? "Stop automation" : "Automate", true, @@ -676,7 +674,7 @@ public class WorldScreen extends CameraStageBaseScreen { } private void updateTiles() { - for (WorldTileGroup WG : tileGroups.linqValues()) WG.update(this); + for (com.unciv.ui.WorldTileGroup WG : tileGroups.linqValues()) WG.update(this); if (unitTile != null) return; // While we're in "unit move" mode, no tiles but the tiles the unit can move to will be "visible" @@ -684,7 +682,7 @@ public class WorldScreen extends CameraStageBaseScreen { // YES A TRIPLE FOR, GOT PROBLEMS WITH THAT? // Seriously though, there is probably a more efficient way of doing this, probably? // The original implementation caused serious lag on android, so efficiency is key, here - for (WorldTileGroup WG : tileGroups.linqValues()) WG.setIsViewable(false); + for (com.unciv.ui.WorldTileGroup WG : tileGroups.linqValues()) WG.setIsViewable(false); HashSet ViewableVectorStrings = new HashSet(); // tiles adjacent to city tiles @@ -711,9 +709,9 @@ public class WorldScreen extends CameraStageBaseScreen { void setCenterPosition(final Vector2 vector) { - TileGroup TG = tileGroups.linqValues().first(new Predicate() { + com.unciv.ui.TileGroup TG = tileGroups.linqValues().first(new Predicate() { @Override - public boolean evaluate(WorldTileGroup arg0) { + public boolean evaluate(com.unciv.ui.WorldTileGroup arg0) { return arg0.tileInfo.position.equals(vector); } }); diff --git a/core/src/com/unciv/game/WorldTileGroup.java b/core/src/com/unciv/ui/WorldTileGroup.java similarity index 93% rename from core/src/com/unciv/game/WorldTileGroup.java rename to core/src/com/unciv/ui/WorldTileGroup.java index 1da137cbdd..62895aafef 100644 --- a/core/src/com/unciv/game/WorldTileGroup.java +++ b/core/src/com/unciv/ui/WorldTileGroup.java @@ -1,12 +1,11 @@ -package com.unciv.game; +package com.unciv.ui; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.ui.Container; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; -import com.unciv.civinfo.CityInfo; -import com.unciv.civinfo.TileInfo; -import com.unciv.game.utils.ImageGetter; +import com.unciv.logic.city.CityInfo; +import com.unciv.logic.map.TileInfo; public class WorldTileGroup extends TileGroup { @@ -33,7 +32,7 @@ public class WorldTileGroup extends TileGroup { if (tileInfo.owner != null && hexagon == null) { - hexagon = ImageGetter.getImage("TerrainIcons/Hexagon.png"); + hexagon = com.unciv.ui.utils.ImageGetter.getImage("TerrainIcons/Hexagon.png"); float imageScale = terrainImage.getWidth() * 1.3f / hexagon.getWidth(); hexagon.setScale(imageScale); hexagon.setPosition((getWidth() - hexagon.getWidth() * imageScale) / 2, diff --git a/core/src/com/unciv/game/pickerscreens/ConstructionPickerScreen.java b/core/src/com/unciv/ui/pickerscreens/ConstructionPickerScreen.java similarity index 86% rename from core/src/com/unciv/game/pickerscreens/ConstructionPickerScreen.java rename to core/src/com/unciv/ui/pickerscreens/ConstructionPickerScreen.java index c7288c1b89..12f7cc89e7 100644 --- a/core/src/com/unciv/game/pickerscreens/ConstructionPickerScreen.java +++ b/core/src/com/unciv/ui/pickerscreens/ConstructionPickerScreen.java @@ -1,15 +1,12 @@ -package com.unciv.game.pickerscreens; +package com.unciv.ui.pickerscreens; -import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.scenes.scene2d.InputEvent; -import com.badlogic.gdx.scenes.scene2d.Touchable; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; -import com.unciv.civinfo.CityConstructions; -import com.unciv.civinfo.Unit; -import com.unciv.game.CityScreen; -import com.unciv.game.UnCivGame; +import com.unciv.logic.city.CityConstructions; +import com.unciv.models.gamebasics.Unit; +import com.unciv.ui.CityScreen; import com.unciv.models.gamebasics.Building; import com.unciv.models.gamebasics.GameBasics; @@ -23,9 +20,7 @@ public class ConstructionPickerScreen extends PickerScreen { @Override public void clicked(InputEvent event, float x, float y) { selectedProduction = production; - rightSideButton.setTouchable(Touchable.enabled); - rightSideButton.setText(rightSideButtonText); - rightSideButton.setColor(Color.WHITE); + pick(rightSideButtonText); descriptionLabel.setText(description); } }); @@ -52,8 +47,6 @@ public class ConstructionPickerScreen extends PickerScreen { dispose(); } }); - rightSideButton.setTouchable(Touchable.disabled); - rightSideButton.setColor(Color.GRAY); CityConstructions cityConstructions = game.civInfo.getCurrentCity().cityConstructions; VerticalGroup regularBuildings = new VerticalGroup().space(10), diff --git a/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.java b/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.java new file mode 100644 index 0000000000..eca62b2b5e --- /dev/null +++ b/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.java @@ -0,0 +1,34 @@ +package com.unciv.ui.pickerscreens; + +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.ui.TextButton; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.unciv.logic.civilization.CivilizationInfo; +import com.unciv.models.gamebasics.Unit; +import com.unciv.models.gamebasics.GameBasics; + +public class GreatPersonPickerScreen extends PickerScreen{ + Unit theChosenOne; + public GreatPersonPickerScreen(){ + rightSideButton.setText("Choose a free great person"); + for(final Unit unit : GameBasics.Units.linqValues()){ + if(!unit.name.startsWith("Great")) continue; + TextButton button = new TextButton(unit.name,skin); + button.addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + theChosenOne=unit; + pick(unit.name); + } + }); + topTable.add(button).pad(10); + } + rightSideButton.addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + CivilizationInfo.current().tileMap.placeUnitNearTile( + CivilizationInfo.current().cities.get(0).cityLocation, theChosenOne.name); + } + }); + } +} diff --git a/core/src/com/unciv/game/pickerscreens/ImprovementPickerScreen.java b/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.java similarity index 77% rename from core/src/com/unciv/game/pickerscreens/ImprovementPickerScreen.java rename to core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.java index 60699f5de4..d19c722798 100644 --- a/core/src/com/unciv/game/pickerscreens/ImprovementPickerScreen.java +++ b/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.java @@ -1,13 +1,10 @@ -package com.unciv.game.pickerscreens; +package com.unciv.ui.pickerscreens; -import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.scenes.scene2d.InputEvent; -import com.badlogic.gdx.scenes.scene2d.Touchable; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; -import com.unciv.civinfo.TileInfo; -import com.unciv.game.UnCivGame; +import com.unciv.logic.map.TileInfo; import com.unciv.models.gamebasics.GameBasics; import com.unciv.models.gamebasics.TileImprovement; @@ -16,7 +13,6 @@ public class ImprovementPickerScreen extends PickerScreen { public ImprovementPickerScreen(final TileInfo tileInfo) { rightSideButton.setText("Pick improvement"); - rightSideButton.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y) { @@ -26,9 +22,6 @@ public class ImprovementPickerScreen extends PickerScreen { } }); - rightSideButton.setTouchable(Touchable.disabled); - rightSideButton.setColor(Color.GRAY); - VerticalGroup regularImprovements = new VerticalGroup(); regularImprovements.space(10); for(final TileImprovement improvement : GameBasics.TileImprovements.values()) { @@ -39,9 +32,7 @@ public class ImprovementPickerScreen extends PickerScreen { @Override public void clicked(InputEvent event, float x, float y) { SelectedImprovement = improvement.name; - rightSideButton.setTouchable(Touchable.enabled); - rightSideButton.setText(improvement.name); - rightSideButton.setColor(Color.WHITE); + pick(improvement.name); descriptionLabel.setText(improvement.getDescription()); } }); diff --git a/core/src/com/unciv/game/pickerscreens/PickerScreen.java b/core/src/com/unciv/ui/pickerscreens/PickerScreen.java similarity index 80% rename from core/src/com/unciv/game/pickerscreens/PickerScreen.java rename to core/src/com/unciv/ui/pickerscreens/PickerScreen.java index e3b3085716..7bcbb39367 100644 --- a/core/src/com/unciv/game/pickerscreens/PickerScreen.java +++ b/core/src/com/unciv/ui/pickerscreens/PickerScreen.java @@ -1,6 +1,8 @@ -package com.unciv.game.pickerscreens; +package com.unciv.ui.pickerscreens; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.Touchable; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; import com.badlogic.gdx.scenes.scene2d.ui.SplitPane; @@ -8,8 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; -import com.unciv.game.utils.CameraStageBaseScreen; -import com.unciv.game.UnCivGame; +import com.unciv.ui.utils.CameraStageBaseScreen; public class PickerScreen extends CameraStageBaseScreen { @@ -44,6 +45,8 @@ public class PickerScreen extends CameraStageBaseScreen { buttonTable.add(rightSideButton).width(stage.getWidth() / 4); buttonTable.setHeight(stage.getHeight()*(1-screenSplit)); buttonTable.align(Align.center); + rightSideButton.setColor(Color.GRAY); + rightSideButton.setTouchable(Touchable.disabled); topTable = new Table(); ScrollPane scrollPane = new ScrollPane(topTable); @@ -55,5 +58,11 @@ public class PickerScreen extends CameraStageBaseScreen { splitPane.setFillParent(true); stage.addActor(splitPane); } + + protected void pick(String rightButtonText){ + rightSideButton.setTouchable(Touchable.enabled); + rightSideButton.setColor(Color.WHITE); + rightSideButton.setText(rightButtonText); + } } diff --git a/core/src/com/unciv/game/pickerscreens/PolicyPickerScreen.java b/core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.java similarity index 93% rename from core/src/com/unciv/game/pickerscreens/PolicyPickerScreen.java rename to core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.java index a3d004097b..cecfff02a0 100644 --- a/core/src/com/unciv/game/pickerscreens/PolicyPickerScreen.java +++ b/core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.java @@ -1,6 +1,5 @@ -package com.unciv.game.pickerscreens; +package com.unciv.ui.pickerscreens; -import com.badlogic.gdx.Game; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Touchable; @@ -10,10 +9,9 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Predicate; -import com.unciv.civinfo.CityInfo; -import com.unciv.civinfo.CivilizationInfo; -import com.unciv.game.utils.ImageGetter; -import com.unciv.models.LinqCollection; +import com.unciv.logic.city.CityInfo; +import com.unciv.logic.civilization.CivilizationInfo; +import com.unciv.models.linq.Linq; import com.unciv.models.gamebasics.GameBasics; import com.unciv.models.gamebasics.Policy; import com.unciv.models.gamebasics.PolicyBranch; @@ -25,7 +23,7 @@ public class PolicyPickerScreen extends PickerScreen { public PolicyPickerScreen() { - LinqCollection tutorial = new LinqCollection(); + Linq tutorial = new Linq(); tutorial.add("Each turn, the culture you gain from all your " + "\r\n cities is added to your Civilization's culture." + "\r\nWhen you have enough culture, you may pick a " + @@ -45,8 +43,6 @@ public class PolicyPickerScreen extends PickerScreen { closeButton.setTouchable(Touchable.disabled); } - rightSideButton.setColor(Color.GRAY); - rightSideButton.setTouchable(Touchable.disabled); rightSideButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { @@ -84,6 +80,8 @@ public class PolicyPickerScreen extends PickerScreen { if (pickedPolicy.name.equals("Free Religion")) CivilizationInfo.current().freePolicies++; + if (pickedPolicy.name.equals("")) + game.setScreen(new PolicyPickerScreen()); } @@ -143,7 +141,7 @@ public class PolicyPickerScreen extends PickerScreen { public Button getPolicyButton(final Policy policy, boolean image) { Button toReturn = new Button(skin); if (image) { - Image policyImage = ImageGetter.getImage("PolicyIcons/" + policy.name.replace(" ", "_") + "_(Civ5).png"); + Image policyImage = com.unciv.ui.utils.ImageGetter.getImage("PolicyIcons/" + policy.name.replace(" ", "_") + "_(Civ5).png"); toReturn.add(policyImage).size(30); } else toReturn = new TextButton(policy.name, skin); diff --git a/core/src/com/unciv/game/pickerscreens/TechPickerScreen.java b/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.java similarity index 90% rename from core/src/com/unciv/game/pickerscreens/TechPickerScreen.java rename to core/src/com/unciv/ui/pickerscreens/TechPickerScreen.java index f57fc27df1..65a53cb125 100644 --- a/core/src/com/unciv/game/pickerscreens/TechPickerScreen.java +++ b/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.java @@ -1,13 +1,12 @@ -package com.unciv.game.pickerscreens; +package com.unciv.ui.pickerscreens; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Touchable; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; -import com.unciv.civinfo.CivilizationTech; -import com.unciv.game.UnCivGame; -import com.unciv.models.LinqCollection; +import com.unciv.logic.civilization.CivilizationTech; +import com.unciv.models.linq.Linq; import com.unciv.models.gamebasics.GameBasics; import com.unciv.models.gamebasics.Technology; @@ -60,8 +59,6 @@ public class TechPickerScreen extends PickerScreen { setButtonsInfo(); rightSideButton.setText("Pick a tech"); - rightSideButton.setTouchable(Touchable.disabled); - rightSideButton.setColor(Color.GRAY); rightSideButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { @@ -80,7 +77,7 @@ public class TechPickerScreen extends PickerScreen { }); - LinqCollection tutorial = new LinqCollection(); + Linq tutorial = new Linq(); tutorial.add("Technology is central to your civilization," + "\r\n as technological progress brings with it" + "\r\n more construction options, improvements, and abilities"); @@ -132,9 +129,6 @@ public class TechPickerScreen extends PickerScreen { return; } - rightSideButton.setTouchable(Touchable.enabled); - rightSideButton.setColor(Color.WHITE); - if (civTech.canBeResearched(tech.name)) { techsToResearch.clear(); techsToResearch.add(tech.name); @@ -155,15 +149,13 @@ public class TechPickerScreen extends PickerScreen { while (!Prerequisites.isEmpty()) techsToResearch.add(Prerequisites.pop()); } - rightSideButton.setText("Research \r\n" + techsToResearch.get(0)); + pick("Research \r\n" + techsToResearch.get(0)); setButtonsInfo(); } private void selectTechnologyForFreeTech(Technology tech){ if (civTech.canBeResearched(tech.name)) { - rightSideButton.setText("Pick " + selectedTech.name+"\r\n as free tech!"); - rightSideButton.setTouchable(Touchable.enabled); - rightSideButton.setColor(Color.WHITE); + pick("Pick " + selectedTech.name+"\r\n as free tech!"); } else { rightSideButton.setText("Pick a free tech"); @@ -172,4 +164,5 @@ public class TechPickerScreen extends PickerScreen { } } -} \ No newline at end of file +} + diff --git a/core/src/com/unciv/game/utils/CameraStageBaseScreen.java b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.java similarity index 87% rename from core/src/com/unciv/game/utils/CameraStageBaseScreen.java rename to core/src/com/unciv/ui/utils/CameraStageBaseScreen.java index 5cc39620d5..3e1a7aefb4 100644 --- a/core/src/com/unciv/game/utils/CameraStageBaseScreen.java +++ b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.java @@ -1,4 +1,4 @@ -package com.unciv.game.utils; +package com.unciv.ui.utils; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Screen; @@ -15,22 +15,18 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.viewport.ExtendViewport; -import com.unciv.civinfo.CivilizationInfo; -import com.unciv.game.UnCivGame; -import com.unciv.models.LinqCollection; - -import java.util.Collection; -import java.util.Collections; +import com.unciv.logic.civilization.CivilizationInfo; +import com.unciv.models.linq.Linq; public class CameraStageBaseScreen implements Screen { - public UnCivGame game; + public com.unciv.ui.UnCivGame game; public Stage stage; public Skin skin = new Skin(Gdx.files.internal("skin/flat-earth-ui.json")); static Batch batch = new SpriteBatch(); public CameraStageBaseScreen() { - this.game = UnCivGame.Current; + this.game = com.unciv.ui.UnCivGame.Current; stage = new Stage(new ExtendViewport(1000,600 ),batch);// FitViewport(1000,600) Gdx.input.setInputProcessor(stage); @@ -66,9 +62,9 @@ public class CameraStageBaseScreen implements Screen { @Override public void dispose() { } - private LinqCollection tutorialTexts = new LinqCollection(); + private Linq tutorialTexts = new Linq(); - public void displayTutorials(String name, LinqCollection texts){ + public void displayTutorials(String name, Linq texts){ if(CivilizationInfo.current().tutorial.contains(name)) return; CivilizationInfo.current().tutorial.add(name); diff --git a/core/src/com/unciv/game/utils/GameSaver.java b/core/src/com/unciv/ui/utils/GameSaver.java similarity index 85% rename from core/src/com/unciv/game/utils/GameSaver.java rename to core/src/com/unciv/ui/utils/GameSaver.java index e6412f2a9b..ea1a898860 100644 --- a/core/src/com/unciv/game/utils/GameSaver.java +++ b/core/src/com/unciv/ui/utils/GameSaver.java @@ -1,10 +1,10 @@ -package com.unciv.game.utils; +package com.unciv.ui.utils; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.utils.Json; -import com.unciv.civinfo.CivilizationInfo; -import com.unciv.game.UnCivGame; +import com.unciv.logic.civilization.CivilizationInfo; +import com.unciv.ui.UnCivGame; public class GameSaver { public static final String saveFilesFolder = "SaveFiles"; diff --git a/core/src/com/unciv/game/utils/HexMath.java b/core/src/com/unciv/ui/utils/HexMath.java similarity index 92% rename from core/src/com/unciv/game/utils/HexMath.java rename to core/src/com/unciv/ui/utils/HexMath.java index 729adc85d7..48a65a6204 100644 --- a/core/src/com/unciv/game/utils/HexMath.java +++ b/core/src/com/unciv/ui/utils/HexMath.java @@ -1,10 +1,9 @@ -package com.unciv.game.utils; +package com.unciv.ui.utils; import com.badlogic.gdx.math.Vector2; -import com.unciv.models.LinqCollection; +import com.unciv.models.linq.Linq; import java.util.ArrayList; -import java.util.HashSet; public class HexMath { @@ -68,8 +67,8 @@ public class HexMath return vectors; } - public static LinqCollection GetVectorsInDistance(Vector2 origin, int distance) { - LinqCollection hexesToReturn = new LinqCollection(); + public static Linq GetVectorsInDistance(Vector2 origin, int distance) { + Linq hexesToReturn = new Linq(); for (int i = 0; i < distance + 1; i++) { hexesToReturn.addAll(GetVectorsAtDistance(origin, i)); } diff --git a/core/src/com/unciv/game/utils/ImageGetter.java b/core/src/com/unciv/ui/utils/ImageGetter.java similarity index 98% rename from core/src/com/unciv/game/utils/ImageGetter.java rename to core/src/com/unciv/ui/utils/ImageGetter.java index 9eb83676a0..bdd4100464 100644 --- a/core/src/com/unciv/game/utils/ImageGetter.java +++ b/core/src/com/unciv/ui/utils/ImageGetter.java @@ -1,4 +1,4 @@ -package com.unciv.game.utils; +package com.unciv.ui.utils; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; diff --git a/desktop/src/com/unciv/game/desktop/DesktopLauncher.java b/desktop/src/com/unciv/game/desktop/DesktopLauncher.java index c4325ee783..24c31adc2d 100644 --- a/desktop/src/com/unciv/game/desktop/DesktopLauncher.java +++ b/desktop/src/com/unciv/game/desktop/DesktopLauncher.java @@ -2,7 +2,7 @@ package com.unciv.game.desktop; import com.badlogic.gdx.backends.lwjgl.LwjglApplication; import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; -import com.unciv.game.UnCivGame; +import com.unciv.ui.UnCivGame; public class DesktopLauncher { public static void main (String[] arg) { diff --git a/html/src/com/unciv/game/client/HtmlLauncher.java b/html/src/com/unciv/game/client/HtmlLauncher.java index f0ad8369c2..438430bc6d 100644 --- a/html/src/com/unciv/game/client/HtmlLauncher.java +++ b/html/src/com/unciv/game/client/HtmlLauncher.java @@ -3,7 +3,7 @@ package com.unciv.game.client; import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.backends.gwt.GwtApplication; import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration; -import com.unciv.game.UnCivGame; +import com.unciv.ui.UnCivGame; public class HtmlLauncher extends GwtApplication { diff --git a/ios/src/com/unciv/game/IOSLauncher.java b/ios/src/com/unciv/game/IOSLauncher.java index bdcf89017e..5c05690d95 100644 --- a/ios/src/com/unciv/game/IOSLauncher.java +++ b/ios/src/com/unciv/game/IOSLauncher.java @@ -10,7 +10,7 @@ public class IOSLauncher extends IOSApplication.Delegate { @Override protected IOSApplication createApplication() { IOSApplicationConfiguration config = new IOSApplicationConfiguration(); - return new IOSApplication(new UnCivGame(), config); + return new IOSApplication(new com.unciv.ui.UnCivGame(), config); } public static void main(String[] argv) {