mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-03 13:30:51 +07:00
Fixed inverted Y position when exiting city
Improvements near cities now notify "has been completed near X"
This commit is contained in:
parent
761b62038f
commit
d55297d7df
@ -3,6 +3,7 @@ package com.unciv.civinfo;
|
||||
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.gamebasics.GameBasics;
|
||||
import com.unciv.models.gamebasics.Terrain;
|
||||
import com.unciv.models.gamebasics.TileImprovement;
|
||||
@ -131,6 +132,19 @@ public class TileInfo
|
||||
|
||||
String notification = improvementInProgress+" has been completed";
|
||||
if(workingCity!=null) notification+=" for "+getCity().name;
|
||||
else {
|
||||
for (int i = 1; i < 3; i++) {
|
||||
LinqCollection<TileInfo> tilesWithCity = CivilizationInfo.current().tileMap.getTilesInDistance(position, i).where(new Predicate<TileInfo>() {
|
||||
@Override
|
||||
public boolean evaluate(TileInfo arg0) {
|
||||
return arg0.isCityCenter();
|
||||
}
|
||||
});
|
||||
if(tilesWithCity.isEmpty()) continue;
|
||||
notification+=" near "+tilesWithCity.get(0).workingCity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
notification+="!";
|
||||
CivilizationInfo.current().notifications.add(notification);
|
||||
improvementInProgress = null;
|
||||
|
@ -258,7 +258,7 @@ public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
||||
});
|
||||
|
||||
|
||||
Vector2 positionalVector = com.unciv.game.utils.HexMath.Hex2WorldCoords(tileInfo.position);
|
||||
Vector2 positionalVector = HexMath.Hex2WorldCoords(tileInfo.position);
|
||||
int groupSize = 50;
|
||||
group.setPosition(stage.getWidth() / 2 + positionalVector.x * 0.8f * groupSize,
|
||||
stage.getHeight() / 2 + positionalVector.y * 0.8f * groupSize);
|
||||
@ -442,7 +442,7 @@ public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
||||
// tiles adjacent to city tiles
|
||||
for(TileInfo tileInfo : game.civInfo.tileMap.values())
|
||||
if(game.civInfo.civName.equals(tileInfo.owner))
|
||||
for(Vector2 adjacentLocation : com.unciv.game.utils.HexMath.GetAdjacentVectors(tileInfo.position))
|
||||
for(Vector2 adjacentLocation : HexMath.GetAdjacentVectors(tileInfo.position))
|
||||
ViewableVectorStrings.add(adjacentLocation.toString());
|
||||
|
||||
// Tiles within 2 tiles of units
|
||||
@ -453,7 +453,7 @@ public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
||||
return arg0.unit !=null;
|
||||
}
|
||||
}))
|
||||
for(Vector2 vector : com.unciv.game.utils.HexMath.GetVectorsInDistance(tile.position,2))
|
||||
for(Vector2 vector : HexMath.GetVectorsInDistance(tile.position,2))
|
||||
ViewableVectorStrings.add(vector.toString());
|
||||
|
||||
for(String string : ViewableVectorStrings)
|
||||
@ -469,11 +469,12 @@ public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
||||
return arg0.tileInfo.position.equals(vector) ;
|
||||
}
|
||||
});
|
||||
float x = TG.getX()-stage.getWidth()/2;
|
||||
float y = TG.getY()-stage.getHeight()/2;
|
||||
scrollPane.layout();
|
||||
scrollPane.setScrollX(x);
|
||||
scrollPane.setScrollY(y);
|
||||
scrollPane.layout(); // Fit the scroll pane to the contents - otherwise, setScroll won't work!
|
||||
// We want to center on the middle of TG (TG.getX()+TG.getWidth()/2)
|
||||
// and so the scroll position (== where the screen starts) needs to be half a screen away
|
||||
scrollPane.setScrollX(TG.getX()+TG.getWidth()/2-stage.getWidth()/2);
|
||||
// Here it's the same, only the Y axis is inverted - when at 0 we're at the top, not bottom - so we invert it back.
|
||||
scrollPane.setScrollY(scrollPane.getMaxY() - (TG.getY() + TG.getWidth()/2 - stage.getHeight()/2));
|
||||
scrollPane.updateVisualScroll();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user