diff --git a/client/src/main/java/ru/trader/controllers/PowerPlayController.java b/client/src/main/java/ru/trader/controllers/PowerPlayController.java index c7586a2..bf069e6 100644 --- a/client/src/main/java/ru/trader/controllers/PowerPlayController.java +++ b/client/src/main/java/ru/trader/controllers/PowerPlayController.java @@ -312,13 +312,15 @@ public class PowerPlayController { public class ResultEntry { private final SystemModel starSystem; - private final StationModel nearStation; + private final ReadOnlyStringProperty nearStations; private final ReadOnlyDoubleProperty distance; private final ReadOnlyDoubleProperty distanceHQ; - private final ReadOnlyStringProperty maxSizePad; private final ReadOnlyIntegerProperty intersectCount; private final ReadOnlyStringProperty intersecting; private final ReadOnlyStringProperty controlling; + private final ReadOnlyLongProperty population; + private final ReadOnlyLongProperty upkeep; + private final ReadOnlyLongProperty income; public ResultEntry(PowerPlayAnalyzator.IntersectData data) { this(data, null); @@ -326,14 +328,17 @@ public class PowerPlayController { public ResultEntry(PowerPlayAnalyzator.IntersectData data, Place from) { starSystem = world.getModeler().get(data.getStarSystem()); - maxSizePad = new SimpleStringProperty(starSystem.getMaxSizePad()); intersectCount = new SimpleIntegerProperty(data.getCount()); - nearStation = starSystem.getNear(); + nearStations = new SimpleStringProperty(getStationsString(starSystem.getNearByType())); intersecting = new SimpleStringProperty(getControllingString(data.getControllingSystems())); controlling = new SimpleStringProperty(getControllingString(data.getStarSystem())); distance = new SimpleDoubleProperty(from != null ? from.getDistance(data.getStarSystem()) : Double.NaN); Place hq = ModelFabric.get(hqSystem.orElse(null)); distanceHQ = new SimpleDoubleProperty(hq != null ? hq.getDistance(data.getStarSystem()) : Double.NaN); + population = new SimpleLongProperty(data.getStarSystem().getPopulation()); + upkeep = new SimpleLongProperty(data.getStarSystem().getUpkeep()); + income = new SimpleLongProperty(data.getStarSystem().getIncome()); + } private String getControllingString(Collection controllings) { @@ -356,10 +361,29 @@ public class PowerPlayController { return res.toString(); } - public ReadOnlyStringProperty stationProperty(){ - return new SimpleStringProperty(String.format("%s (%.0f Ls)", nearStation.getName(), nearStation.getDistance())); + private String getStationsString(Collection stations) { + StringBuilder res = new StringBuilder(); + for (StationModel station : stations) { + if (res.length() != 0) res.append("\n"); + if (station.getType() != null){ + if (station.getType().isPlanetary()) { + res.append("LP"); + } else + if (station.getType().hasLargeLandpad()){ + res.append("L"); + } else { + res.append("M"); + } + } else { + res.append("?"); + } + res.append(" - ").append(station.getName()); + res.append(" (").append(ViewUtils.stationDistanceToString(station.getDistance())).append(")"); + } + return res.toString(); } + public ReadOnlyStringProperty nameProperty(){ return starSystem.nameProperty(); } @@ -388,10 +412,6 @@ public class PowerPlayController { return distanceHQ; } - public ReadOnlyStringProperty maxSizePadProperty() { - return maxSizePad; - } - public ReadOnlyIntegerProperty intersectCountProperty() { return intersectCount; } @@ -403,5 +423,21 @@ public class PowerPlayController { public ReadOnlyStringProperty intersectingProperty() { return intersecting; } + + public ReadOnlyLongProperty populationProperty() { + return population; + } + + public ReadOnlyLongProperty upkeepProperty() { + return upkeep; + } + + public ReadOnlyLongProperty incomeProperty() { + return income; + } + + public ReadOnlyStringProperty nearStationsProperty() { + return nearStations; + } } } \ No newline at end of file diff --git a/client/src/main/java/ru/trader/model/SystemModel.java b/client/src/main/java/ru/trader/model/SystemModel.java index 0c95ba7..5c29b90 100644 --- a/client/src/main/java/ru/trader/model/SystemModel.java +++ b/client/src/main/java/ru/trader/model/SystemModel.java @@ -1,12 +1,15 @@ package ru.trader.model; -import javafx.beans.property.*; +import javafx.beans.property.ReadOnlyStringProperty; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import ru.trader.core.*; +import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Optional; @@ -187,6 +190,33 @@ public class SystemModel { return asModel(near.orElse(null)); } + public Collection getNearByType(){ + Collection stations = system.get().stream().sorted((v1, v2) -> Double.compare(v1.getDistance(), v2.getDistance())).collect(Collectors.toList()); + Collection result = new ArrayList<>(4); + boolean findLarge = false, findMedium = false, findPlanetary = false; + for (Vendor station : stations) { + if (station.getType() != null){ + if (station.getType().isPlanetary()){ + if (!findPlanetary) { + result.add(asModel(station)); + findPlanetary = true; + } + } else + if (station.getType().hasLargeLandpad()){ + if (!findLarge) { + result.add(asModel(station)); + findLarge = true; + } + } else + if (!findMedium){ + result.add(asModel(station)); + findMedium = true; + } + } + } + return result; + } + @Override public String toString() { if (LOG.isTraceEnabled()){ diff --git a/client/src/main/java/ru/trader/view/support/CustomNumberStringConverter.java b/client/src/main/java/ru/trader/view/support/CustomNumberStringConverter.java new file mode 100644 index 0000000..5788195 --- /dev/null +++ b/client/src/main/java/ru/trader/view/support/CustomNumberStringConverter.java @@ -0,0 +1,14 @@ +package ru.trader.view.support; + + + +import javafx.beans.NamedArg; +import javafx.util.converter.NumberStringConverter; + + +public class CustomNumberStringConverter extends NumberStringConverter { + + public CustomNumberStringConverter(@NamedArg("pattern")String pattern) { + super(pattern); + } +} diff --git a/client/src/main/resources/view/powerplay.fxml b/client/src/main/resources/view/powerplay.fxml index e656256..3bc55dc 100644 --- a/client/src/main/resources/view/powerplay.fxml +++ b/client/src/main/resources/view/powerplay.fxml @@ -89,11 +89,11 @@ - + - - + + @@ -118,8 +118,20 @@ + + + + + + + + + - + + + + @@ -162,6 +174,19 @@ + + + + + + + + + + + + +