add show orders and show orders by route buttons to station screen
This commit is contained in:
@@ -8,6 +8,7 @@ import javafx.scene.control.*;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.trader.core.Profile;
|
||||
import ru.trader.core.SERVICE_TYPE;
|
||||
import ru.trader.model.*;
|
||||
import ru.trader.model.support.BindingsHelper;
|
||||
@@ -17,6 +18,7 @@ import ru.trader.view.support.autocomplete.AutoCompletion;
|
||||
import ru.trader.view.support.autocomplete.CachedSuggestionProvider;
|
||||
import ru.trader.view.support.autocomplete.SystemsProvider;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -274,6 +276,33 @@ public class OffersController {
|
||||
tblBuy.getItems().forEach(OfferModel::refresh);
|
||||
}
|
||||
|
||||
private void showOffers(Collection<StationModel> buyers){
|
||||
StationModel seller = getStation();
|
||||
MarketModel market = MainController.getMarket();
|
||||
Profile profile = ModelFabric.get(MainController.getProfile());
|
||||
if (ModelFabric.isFake(seller)) return;
|
||||
if (buyers == null){
|
||||
market.getOrders(seller, profile, Screeners::showOrders);
|
||||
} else {
|
||||
market.getOrders(seller, buyers, profile, Screeners::showOrders);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void showOffersByRoute(){
|
||||
ProfileModel profile = MainController.getProfile();
|
||||
RouteModel route = profile.getRoute();
|
||||
if (route == null) return;
|
||||
Collection<StationModel> buyers = route.getStations();
|
||||
showOffers(buyers);
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void showOffers(){
|
||||
showOffers(null);
|
||||
}
|
||||
|
||||
private final ChangeMarketListener offersChangeListener = new ChangeMarketListener() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -320,9 +320,17 @@ public class RouteModel {
|
||||
refresh();
|
||||
}
|
||||
|
||||
public Collection<StationModel> getStations(){
|
||||
return getStations(currentEntry.get()-1, false);
|
||||
}
|
||||
|
||||
public Collection<StationModel> getStations(int offset){
|
||||
return getStations(offset, false);
|
||||
}
|
||||
|
||||
public Collection<StationModel> getStations(int offset, boolean incudeLoop){
|
||||
Collection<StationModel> res = new HashSet<>();
|
||||
int startIndex = _route.isLoop() ? 1 : offset+1;
|
||||
int startIndex = incudeLoop && _route.isLoop() ? 1 : offset+1;
|
||||
if (startIndex >= entries.size()) return res;
|
||||
entries.subList(startIndex, entries.size()).stream()
|
||||
.filter(e -> !e.isTransit())
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
minHeight="120" maxHeight="120" collapsible="false">
|
||||
<GridPane hgap="4" vgap="4">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints minWidth="80"/>
|
||||
<ColumnConstraints minWidth="80"/>
|
||||
<ColumnConstraints minWidth="140" />
|
||||
<ColumnConstraints minWidth="100" />
|
||||
@@ -52,27 +53,34 @@
|
||||
<ColumnConstraints minWidth="140" />
|
||||
<ColumnConstraints hgrow="ALWAYS" />
|
||||
</columnConstraints>
|
||||
<Label text="%label.station.type" />
|
||||
<Label fx:id="type" GridPane.columnIndex="1"/>
|
||||
<Label text="%label.government" GridPane.columnIndex="2" />
|
||||
<Label fx:id="government" GridPane.columnIndex="3" />
|
||||
<Label text="%label.allegiance" GridPane.columnIndex="4"/>
|
||||
<Label fx:id="faction" GridPane.columnIndex="5" />
|
||||
<HBox GridPane.columnIndex="6" GridPane.rowSpan="2" alignment="TOP_RIGHT">
|
||||
<HBox GridPane.columnIndex="7" GridPane.rowSpan="2" alignment="TOP_RIGHT">
|
||||
<Label fx:id="warningIcon" styleClass="icon-warning" prefWidth="30" prefHeight="30" visible="false">
|
||||
<graphic><Glyph text="FontAwesome|WARNING" /></graphic>
|
||||
</Label>
|
||||
</HBox>
|
||||
<HBox GridPane.rowIndex="2" spacing="4" alignment="BOTTOM_CENTER">
|
||||
<Button minWidth="30" minHeight="25" onAction="#showOffers"><graphic><Glyph text="FontAwesome|EXCHANGE"/></graphic></Button>
|
||||
<Button minWidth="30" minHeight="25" onAction="#showOffersByRoute"><graphic><Glyph text="FontAwesome|SHARE"/></graphic></Button>
|
||||
</HBox>
|
||||
|
||||
<Label text="%label.station.distance" GridPane.rowIndex="1" />
|
||||
<Label fx:id="distance" GridPane.rowIndex="1" GridPane.columnIndex="1" />
|
||||
<Label text="%label.economic" GridPane.rowIndex="1" GridPane.columnIndex="2" />
|
||||
<Label fx:id="economic" GridPane.rowIndex="1" GridPane.columnIndex="3" />
|
||||
<Label fx:id="subeconomic" GridPane.rowIndex="1" GridPane.columnIndex="4" GridPane.columnSpan="2"/>
|
||||
<Label text="%label.station.type" GridPane.columnIndex="1"/>
|
||||
<Label fx:id="type" GridPane.columnIndex="2"/>
|
||||
<Label text="%label.government" GridPane.columnIndex="3" />
|
||||
<Label fx:id="government" GridPane.columnIndex="4" />
|
||||
<Label text="%label.allegiance" GridPane.columnIndex="5"/>
|
||||
<Label fx:id="faction" GridPane.columnIndex="6" />
|
||||
|
||||
<Label text="%label.station.services" GridPane.rowIndex="2"/>
|
||||
<TilePane GridPane.rowIndex="2" GridPane.columnIndex="1" GridPane.columnSpan="6" GridPane.hgrow="ALWAYS"
|
||||
hgap="5" vgap="5" prefColumns="5" tileAlignment="BASELINE_LEFT">
|
||||
|
||||
<Label text="%label.station.distance" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
<Label fx:id="distance" GridPane.rowIndex="1" GridPane.columnIndex="2" />
|
||||
<Label text="%label.economic" GridPane.rowIndex="1" GridPane.columnIndex="3" />
|
||||
<Label fx:id="economic" GridPane.rowIndex="1" GridPane.columnIndex="4" />
|
||||
<Label fx:id="subeconomic" GridPane.rowIndex="1" GridPane.columnIndex="5" GridPane.columnSpan="2"/>
|
||||
|
||||
|
||||
<Label text="%label.station.services" GridPane.rowIndex="2" GridPane.columnIndex="1"/>
|
||||
<TilePane GridPane.rowIndex="2" GridPane.columnIndex="2" GridPane.columnSpan="6" GridPane.hgrow="ALWAYS"
|
||||
hgap="5" vgap="5" prefColumns="4" tileAlignment="BASELINE_LEFT">
|
||||
<CheckBox fx:id="cbMarket" text="%services.MARKET"/>
|
||||
<CheckBox fx:id="cbBlackMarket" text="%services.BLACK_MARKET"/>
|
||||
<CheckBox fx:id="cbRefuel" text="%services.REFUEL"/>
|
||||
|
||||
Reference in New Issue
Block a user