Center sectors map on most recently saved (played and not abandoned) sector (#375)

This commit is contained in:
Clarence "Sparr" Risher
2018-12-13 14:35:24 -08:00
committed by Anuken
parent 18ddc040d1
commit 54dd67a435
4 changed files with 34 additions and 7 deletions

View File

@@ -159,6 +159,26 @@ public class SectorsDialog extends FloatingDialog{
});
clicked(() -> clicked = true);
this.focus();
}
private void focus(){
Sector focusSector = null;
long newestTimestamp = 0;
for(Sector sector : world.sectors.getSectors()){
if(sector.hasSave()){
long timestamp = sector.getSave().getTimestamp();
if(timestamp > newestTimestamp){
focusSector = sector;
newestTimestamp = timestamp;
}
}
}
if(focusSector != null) {
panX = (focusSector.x + 0.5f) * sectorSize;
panY = (focusSector.y + 0.5f) * sectorSize;
}
}
@Override