select next entry on undocked and jump to transit entry
This commit is contained in:
@@ -11,10 +11,7 @@ import org.controlsfx.control.SegmentedButton;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import ru.trader.core.SERVICE_TYPE;
|
import ru.trader.core.SERVICE_TYPE;
|
||||||
import ru.trader.model.MarketModel;
|
import ru.trader.model.*;
|
||||||
import ru.trader.model.OfferModel;
|
|
||||||
import ru.trader.model.StationModel;
|
|
||||||
import ru.trader.model.SystemModel;
|
|
||||||
import ru.trader.model.support.BindingsHelper;
|
import ru.trader.model.support.BindingsHelper;
|
||||||
import ru.trader.model.support.ChangeMarketListener;
|
import ru.trader.model.support.ChangeMarketListener;
|
||||||
import ru.trader.view.support.FactionStringConverter;
|
import ru.trader.view.support.FactionStringConverter;
|
||||||
@@ -83,7 +80,7 @@ public class OffersController {
|
|||||||
if (n != null){
|
if (n != null){
|
||||||
fillTables((StationModel) n.getUserData());
|
fillTables((StationModel) n.getUserData());
|
||||||
} else {
|
} else {
|
||||||
fillTables(null);
|
fillTables(ModelFabric.NONE_STATION);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
stationsBar.setToggleGroup(stationsGrp);
|
stationsBar.setToggleGroup(stationsGrp);
|
||||||
@@ -126,9 +123,9 @@ public class OffersController {
|
|||||||
stations.forEach(s -> stationsBar.getButtons().add(buildStationNode(s)));
|
stations.forEach(s -> stationsBar.getButtons().add(buildStationNode(s)));
|
||||||
if (!stations.isEmpty()){
|
if (!stations.isEmpty()){
|
||||||
stationsBar.getButtons().get(0).setSelected(true);
|
stationsBar.getButtons().get(0).setSelected(true);
|
||||||
|
} else {
|
||||||
|
fillTables(ModelFabric.NONE_STATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
fillTables(stations.isEmpty() ? null : stations.get(0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ToggleButton buildStationNode(StationModel station){
|
private ToggleButton buildStationNode(StationModel station){
|
||||||
@@ -153,7 +150,7 @@ public class OffersController {
|
|||||||
cbShipyard.setSelected(false);
|
cbShipyard.setSelected(false);
|
||||||
cbMediumLandpad.setSelected(false);
|
cbMediumLandpad.setSelected(false);
|
||||||
cbLargeLandpad.setSelected(false);
|
cbLargeLandpad.setSelected(false);
|
||||||
if (station != null){
|
if (station != ModelFabric.NONE_STATION){
|
||||||
faction.setText(FactionStringConverter.toLocalizationString(station.getFaction()));
|
faction.setText(FactionStringConverter.toLocalizationString(station.getFaction()));
|
||||||
government.setText(GovernmentStringConverter.toLocalizationString(station.getGovernment()));
|
government.setText(GovernmentStringConverter.toLocalizationString(station.getGovernment()));
|
||||||
distance.setText(String.valueOf(station.getDistance()));
|
distance.setText(String.valueOf(station.getDistance()));
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import javafx.beans.value.ChangeListener;
|
|||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.CheckBox;
|
||||||
import javafx.scene.control.ComboBox;
|
import javafx.scene.control.ComboBox;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.util.StringConverter;
|
import javafx.util.StringConverter;
|
||||||
@@ -28,6 +29,8 @@ public class ProfileController {
|
|||||||
@FXML
|
@FXML
|
||||||
private ComboBox<StationModel> station;
|
private ComboBox<StationModel> station;
|
||||||
@FXML
|
@FXML
|
||||||
|
private CheckBox docked;
|
||||||
|
@FXML
|
||||||
private NumberField mass;
|
private NumberField mass;
|
||||||
@FXML
|
@FXML
|
||||||
private NumberField tank;
|
private NumberField tank;
|
||||||
@@ -79,6 +82,7 @@ public class ProfileController {
|
|||||||
consumeChanges(() -> {profile.setSystem(n); profile.setStation(ModelFabric.NONE_STATION);});
|
consumeChanges(() -> {profile.setSystem(n); profile.setStation(ModelFabric.NONE_STATION);});
|
||||||
});
|
});
|
||||||
station.valueProperty().addListener((ov, o, n) -> consumeChanges(() -> profile.setStation(n)));
|
station.valueProperty().addListener((ov, o, n) -> consumeChanges(() -> profile.setStation(n)));
|
||||||
|
docked.selectedProperty().addListener((ov, o, n) -> consumeChanges(() -> profile.setDocked(n)));
|
||||||
mass.numberProperty().addListener((ov, o, n) -> consumeChanges(() -> profile.setShipMass(n.doubleValue())));
|
mass.numberProperty().addListener((ov, o, n) -> consumeChanges(() -> profile.setShipMass(n.doubleValue())));
|
||||||
tank.numberProperty().addListener((ov, o, n) -> consumeChanges(() -> profile.setShipTank(n.doubleValue())));
|
tank.numberProperty().addListener((ov, o, n) -> consumeChanges(() -> profile.setShipTank(n.doubleValue())));
|
||||||
cargo.numberProperty().addListener((ov, o, n) -> consumeChanges(() -> profile.setShipCargo(n.intValue())));
|
cargo.numberProperty().addListener((ov, o, n) -> consumeChanges(() -> profile.setShipCargo(n.intValue())));
|
||||||
@@ -90,14 +94,17 @@ public class ProfileController {
|
|||||||
unbind();
|
unbind();
|
||||||
}
|
}
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
|
ignoreChanges = true;
|
||||||
name.setText(profile.getName());
|
name.setText(profile.getName());
|
||||||
balance.setValue(profile.getBalance());
|
balance.setValue(profile.getBalance());
|
||||||
system.setValue(profile.getSystem());
|
system.setValue(profile.getSystem());
|
||||||
station.setValue(profile.getStation());
|
station.setValue(profile.getStation());
|
||||||
|
docked.setSelected(profile.isDocked());
|
||||||
mass.setValue(profile.getShipMass());
|
mass.setValue(profile.getShipMass());
|
||||||
tank.setValue(profile.getShipTank());
|
tank.setValue(profile.getShipTank());
|
||||||
cargo.setValue(profile.getShipCargo());
|
cargo.setValue(profile.getShipCargo());
|
||||||
engine.setValue(profile.getShipEngine());
|
engine.setValue(profile.getShipEngine());
|
||||||
|
ignoreChanges = false;
|
||||||
bind();
|
bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,6 +113,7 @@ public class ProfileController {
|
|||||||
profile.balanceProperty().addListener(balanceListener);
|
profile.balanceProperty().addListener(balanceListener);
|
||||||
profile.systemProperty().addListener(systemListener);
|
profile.systemProperty().addListener(systemListener);
|
||||||
profile.stationProperty().addListener(stationListener);
|
profile.stationProperty().addListener(stationListener);
|
||||||
|
profile.dockedProperty().addListener(dockedListener);
|
||||||
profile.shipMassProperty().addListener(massListener);
|
profile.shipMassProperty().addListener(massListener);
|
||||||
profile.shipTankProperty().addListener(tankListener);
|
profile.shipTankProperty().addListener(tankListener);
|
||||||
profile.shipCargoProperty().addListener(cargoListener);
|
profile.shipCargoProperty().addListener(cargoListener);
|
||||||
@@ -117,6 +125,7 @@ public class ProfileController {
|
|||||||
profile.balanceProperty().removeListener(balanceListener);
|
profile.balanceProperty().removeListener(balanceListener);
|
||||||
profile.systemProperty().removeListener(systemListener);
|
profile.systemProperty().removeListener(systemListener);
|
||||||
profile.stationProperty().removeListener(stationListener);
|
profile.stationProperty().removeListener(stationListener);
|
||||||
|
profile.dockedProperty().removeListener(dockedListener);
|
||||||
profile.shipMassProperty().removeListener(massListener);
|
profile.shipMassProperty().removeListener(massListener);
|
||||||
profile.shipTankProperty().removeListener(tankListener);
|
profile.shipTankProperty().removeListener(tankListener);
|
||||||
profile.shipCargoProperty().removeListener(cargoListener);
|
profile.shipCargoProperty().removeListener(cargoListener);
|
||||||
@@ -128,6 +137,7 @@ public class ProfileController {
|
|||||||
private final ChangeListener<Number> balanceListener = (ov, o, n) -> consumeChanges(() -> balance.setValue(n));
|
private final ChangeListener<Number> balanceListener = (ov, o, n) -> consumeChanges(() -> balance.setValue(n));
|
||||||
private final ChangeListener<SystemModel> systemListener = (ov, o, n) -> consumeChanges(() -> system.setValue(n));
|
private final ChangeListener<SystemModel> systemListener = (ov, o, n) -> consumeChanges(() -> system.setValue(n));
|
||||||
private final ChangeListener<StationModel> stationListener = (ov, o, n) -> consumeChanges(() -> station.setValue(n));
|
private final ChangeListener<StationModel> stationListener = (ov, o, n) -> consumeChanges(() -> station.setValue(n));
|
||||||
|
private final ChangeListener<Boolean> dockedListener = (ov, o, n) -> consumeChanges(() -> docked.setSelected(n));
|
||||||
private final ChangeListener<Number> massListener = (ov, o, n) -> consumeChanges(() -> mass.setValue(n));
|
private final ChangeListener<Number> massListener = (ov, o, n) -> consumeChanges(() -> mass.setValue(n));
|
||||||
private final ChangeListener<Number> tankListener = (ov, o, n) -> consumeChanges(() -> tank.setValue(n));
|
private final ChangeListener<Number> tankListener = (ov, o, n) -> consumeChanges(() -> tank.setValue(n));
|
||||||
private final ChangeListener<Number> cargoListener = (ov, o, n) -> consumeChanges(() -> cargo.setValue(n));
|
private final ChangeListener<Number> cargoListener = (ov, o, n) -> consumeChanges(() -> cargo.setValue(n));
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class ProfileModel {
|
|||||||
system.addListener((ov, o, n) -> {
|
system.addListener((ov, o, n) -> {
|
||||||
LOG.debug("Change system, old: {}, new: {}", o, n);
|
LOG.debug("Change system, old: {}, new: {}", o, n);
|
||||||
profile.setSystem(n != null && n != ModelFabric.NONE_SYSTEM ? n.getSystem() : null);
|
profile.setSystem(n != null && n != ModelFabric.NONE_SYSTEM ? n.getSystem() : null);
|
||||||
if (route.getValue() != null) {getRoute().updateCurrentEntry(n, null);}
|
if (route.getValue() != null) {getRoute().updateCurrentEntry(n);}
|
||||||
});
|
});
|
||||||
station.addListener((ov, o, n) -> {
|
station.addListener((ov, o, n) -> {
|
||||||
LOG.debug("Change station, old: {}, new: {}", o, n);
|
LOG.debug("Change station, old: {}, new: {}", o, n);
|
||||||
@@ -62,6 +62,7 @@ public class ProfileModel {
|
|||||||
docked.addListener((ov, o, n) -> {
|
docked.addListener((ov, o, n) -> {
|
||||||
LOG.debug("Change docked, old: {}, new: {}", o, n);
|
LOG.debug("Change docked, old: {}, new: {}", o, n);
|
||||||
profile.setDocked(n);
|
profile.setDocked(n);
|
||||||
|
if (!n && route.getValue() != null) {getRoute().updateCurrentEntry(getSystem(), getStation(), true);}
|
||||||
});
|
});
|
||||||
shipMass.addListener((ov, o, n) -> {
|
shipMass.addListener((ov, o, n) -> {
|
||||||
LOG.debug("Change ship mass, old: {}, new: {}", o, n);
|
LOG.debug("Change ship mass, old: {}, new: {}", o, n);
|
||||||
|
|||||||
@@ -226,9 +226,31 @@ public class RouteModel {
|
|||||||
this.currentEntry.set(currentEntry);
|
this.currentEntry.set(currentEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void updateCurrentEntry(SystemModel system) {
|
||||||
|
updateCurrentEntry(system, null, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void updateCurrentEntry(SystemModel system, StationModel station) {
|
public void updateCurrentEntry(SystemModel system, StationModel station) {
|
||||||
for (int i = getCurrentEntry()+1; i < entries.size(); i++) {
|
updateCurrentEntry(system, station, false);
|
||||||
RouteEntryModel entry = entries.get(i);
|
}
|
||||||
|
|
||||||
|
public void updateCurrentEntry(SystemModel system, StationModel station, boolean undock) {
|
||||||
|
if (undock){
|
||||||
|
int index = getCurrentEntry();
|
||||||
|
RouteEntryModel entry = entries.get(index);
|
||||||
|
if (index < entries.size()-1 && system.equals(entry.getStation().getSystem()) && entry.getStation().equals(station)){
|
||||||
|
setCurrentEntry(index+1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int index = getCurrentEntry();
|
||||||
|
RouteEntryModel entry = entries.get(index);
|
||||||
|
if (entry.isTransit() && index < entries.size()-1 && system.equals(entry.getStation().getSystem())){
|
||||||
|
setCurrentEntry(index+1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = index+1; i < entries.size(); i++) {
|
||||||
|
entry = entries.get(i);
|
||||||
if (system.equals(entry.getStation().getSystem())
|
if (system.equals(entry.getStation().getSystem())
|
||||||
&& (station == null || station == ModelFabric.NONE_STATION ||
|
&& (station == null || station == ModelFabric.NONE_STATION ||
|
||||||
station.equals(entry.getStation()))
|
station.equals(entry.getStation()))
|
||||||
@@ -240,8 +262,8 @@ public class RouteModel {
|
|||||||
if (!entry.isTransit()) return;
|
if (!entry.isTransit()) return;
|
||||||
}
|
}
|
||||||
if (isLoop()){
|
if (isLoop()){
|
||||||
for (int i = 0; i < getCurrentEntry()-1; i++) {
|
for (int i = 0; i < index-1; i++) {
|
||||||
RouteEntryModel entry = entries.get(i);
|
entry = entries.get(i);
|
||||||
if (system.equals(entry.getStation().getSystem())
|
if (system.equals(entry.getStation().getSystem())
|
||||||
&& (station == null || station == ModelFabric.NONE_STATION ||
|
&& (station == null || station == ModelFabric.NONE_STATION ||
|
||||||
station.equals(entry.getStation()))
|
station.equals(entry.getStation()))
|
||||||
@@ -254,4 +276,5 @@ public class RouteModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
<Label text="Станция:" />
|
<Label text="Станция:" />
|
||||||
<ComboBox fx:id="station" />
|
<ComboBox fx:id="station" />
|
||||||
<Button fx:id="btnAddStation"/>
|
<Button fx:id="btnAddStation"/>
|
||||||
|
<Label text="В доке:" />
|
||||||
|
<CheckBox fx:id="docked" />
|
||||||
<VBox>
|
<VBox>
|
||||||
<HBox>
|
<HBox>
|
||||||
<Label text="Трюм:" />
|
<Label text="Трюм:" />
|
||||||
|
|||||||
Reference in New Issue
Block a user