automate select near land marks on edit system
This commit is contained in:
@@ -164,7 +164,7 @@ public class ProfileController {
|
||||
profile.shipTankProperty().addListener(tankListener);
|
||||
profile.shipCargoProperty().addListener(cargoListener);
|
||||
profile.shipEngineProperty().addListener(engineListener);
|
||||
jumpRange.textProperty().bind(Bindings.createStringBinding(()-> String.format("%.1f - %.1f", profile.getShipJumpRange(), profile.getMaxShipJumpRange()),
|
||||
jumpRange.textProperty().bind(Bindings.createStringBinding(()-> String.format("%.1f - %.1f - %.1f", profile.getShipJumpRange(), profile.getMaxShipJumpRange(), profile.getEmptyMaxShipJumpRange()),
|
||||
profile.shipMassProperty(), profile.shipCargoProperty(), profile.shipTankProperty(), profile.shipEngineProperty()
|
||||
));
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@ import javafx.util.converter.DefaultStringConverter;
|
||||
import javafx.util.converter.DoubleStringConverter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.trader.Main;
|
||||
import ru.trader.model.MarketModel;
|
||||
import ru.trader.model.ModelFabric;
|
||||
import ru.trader.model.ProfileModel;
|
||||
import ru.trader.model.SystemModel;
|
||||
import ru.trader.model.support.PositionComputer;
|
||||
import ru.trader.view.support.Localization;
|
||||
@@ -168,12 +170,27 @@ public class SystemsEditorController {
|
||||
private void fill(SystemModel system){
|
||||
if (system != null){
|
||||
tblSystems.getItems().add(new SystemData(system));
|
||||
ProfileModel profile = MainController.getProfile();
|
||||
SystemModel s = profile.getPrevSystem();
|
||||
if (!ModelFabric.isFake(s)){
|
||||
searchLandMark(s, profile.getEmptyMaxShipJumpRange()*1.5);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 10; i++) {
|
||||
add();
|
||||
}
|
||||
}
|
||||
|
||||
private void searchLandMark(SystemModel system, double maxDistance){
|
||||
double x = system.getX(), y = system.getY(), z = system.getZ(), e = 6;
|
||||
system1.setValue(market.getNear(x + maxDistance, y, z, Double.POSITIVE_INFINITY, e, e));
|
||||
system2.setValue(market.getNear(x - maxDistance, y, z, Double.NEGATIVE_INFINITY, e, e));
|
||||
system3.setValue(market.getNear(x, y + maxDistance, z, e, Double.POSITIVE_INFINITY, e));
|
||||
system4.setValue(market.getNear(x, y - maxDistance, z, e, Double.NEGATIVE_INFINITY, e));
|
||||
system5.setValue(market.getNear(x, y, z + maxDistance, e, e, Double.POSITIVE_INFINITY));
|
||||
system6.setValue(market.getNear(x, y, z - maxDistance, e, e, Double.NEGATIVE_INFINITY));
|
||||
}
|
||||
|
||||
public void add(){
|
||||
tblSystems.getItems().add(new SystemData());
|
||||
}
|
||||
@@ -202,6 +219,36 @@ public class SystemsEditorController {
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void copySys1(){
|
||||
Main.copyToClipboard(system1Text.getText());
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void copySys2(){
|
||||
Main.copyToClipboard(system2Text.getText());
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void copySys3(){
|
||||
Main.copyToClipboard(system3Text.getText());
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void copySys4(){
|
||||
Main.copyToClipboard(system4Text.getText());
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void copySys5(){
|
||||
Main.copyToClipboard(system5Text.getText());
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void copySys6(){
|
||||
Main.copyToClipboard(system6Text.getText());
|
||||
}
|
||||
|
||||
private void commit(){
|
||||
for (SystemData systemData : tblSystems.getItems()) {
|
||||
systemData.commit();
|
||||
|
||||
@@ -92,6 +92,14 @@ public class MarketModel {
|
||||
return modeler.get(s);
|
||||
}
|
||||
|
||||
public SystemModel getNear(double x, double y, double z, double xlimit, double ylimit, double zlimit){
|
||||
Place s = market.getNear(x, y, z, xlimit, ylimit, zlimit);
|
||||
if (s == null){
|
||||
return ModelFabric.NONE_SYSTEM;
|
||||
}
|
||||
return modeler.get(s);
|
||||
}
|
||||
|
||||
public SystemModel add(String name, double x, double y, double z) {
|
||||
SystemModel system = modeler.get(market.addPlace(name, x, y, z));
|
||||
LOG.info("Add system {} to market {}", system, this);
|
||||
|
||||
@@ -14,6 +14,7 @@ public class ProfileModel {
|
||||
private final MarketModel market;
|
||||
private final StringProperty name;
|
||||
private final DoubleProperty balance;
|
||||
private final ObjectProperty<SystemModel> prevSystem;
|
||||
private final ObjectProperty<SystemModel> system;
|
||||
private final ObjectProperty<StationModel> station;
|
||||
private final BooleanProperty docked;
|
||||
@@ -29,6 +30,7 @@ public class ProfileModel {
|
||||
name = new SimpleStringProperty();
|
||||
balance = new SimpleDoubleProperty();
|
||||
system = new SimpleObjectProperty<>();
|
||||
prevSystem = new SimpleObjectProperty<>();
|
||||
station = new SimpleObjectProperty<>();
|
||||
docked = new SimpleBooleanProperty();
|
||||
shipMass = new SimpleDoubleProperty();
|
||||
@@ -45,7 +47,10 @@ public class ProfileModel {
|
||||
balance.addListener((ov, o, n) -> LOG.debug("Change balance, old: {}, new: {}", o, n));
|
||||
system.addListener((ov, o, n) -> {
|
||||
LOG.debug("Change system, old: {}, new: {}", o, n);
|
||||
if (route.getValue() != null) {getRoute().updateCurrentEntry(n);}
|
||||
if (!ModelFabric.isFake(o)) prevSystem.setValue(o);
|
||||
if (!ModelFabric.isFake(n)){
|
||||
if (route.getValue() != null) {getRoute().updateCurrentEntry(n);}
|
||||
}
|
||||
});
|
||||
station.addListener((ov, o, n) -> {
|
||||
LOG.debug("Change station, old: {}, new: {}", o, n);
|
||||
@@ -96,6 +101,14 @@ public class ProfileModel {
|
||||
this.balance.set(balance);
|
||||
}
|
||||
|
||||
public SystemModel getPrevSystem() {
|
||||
return prevSystem.get();
|
||||
}
|
||||
|
||||
public ReadOnlyObjectProperty<SystemModel> prevSystemProperty() {
|
||||
return prevSystem;
|
||||
}
|
||||
|
||||
public SystemModel getSystem() {
|
||||
return system.get();
|
||||
}
|
||||
@@ -207,6 +220,10 @@ public class ProfileModel {
|
||||
return profile.getShip().getMaxJumpRange();
|
||||
}
|
||||
|
||||
public double getEmptyMaxShipJumpRange(){
|
||||
return profile.getShip().getEmptyMaxJumpRange();
|
||||
}
|
||||
|
||||
private void refresh(){
|
||||
name.setValue(profile.getName());
|
||||
balance.setValue(profile.getBalance());
|
||||
|
||||
@@ -23,12 +23,30 @@
|
||||
</columnConstraints>
|
||||
|
||||
<Label text="%sEditor.text.orientates" prefWidth="170" GridPane.rowSpan="2"/>
|
||||
<TextField fx:id="system1Text" prefWidth="160" GridPane.columnIndex="1" />
|
||||
<TextField fx:id="system2Text" prefWidth="160" GridPane.columnIndex="2" />
|
||||
<TextField fx:id="system3Text" prefWidth="160" GridPane.columnIndex="3" />
|
||||
<TextField fx:id="system4Text" prefWidth="160" GridPane.rowIndex="1" GridPane.columnIndex="1" />
|
||||
<TextField fx:id="system5Text" prefWidth="160" GridPane.rowIndex="1" GridPane.columnIndex="2" />
|
||||
<TextField fx:id="system6Text" prefWidth="160" GridPane.rowIndex="1" GridPane.columnIndex="3" />
|
||||
<HBox GridPane.columnIndex="1">
|
||||
<TextField fx:id="system1Text" prefWidth="160"/>
|
||||
<Button minWidth="30" onAction="#copySys1"><graphic><Glyph text="FontAwesome|COPY"/></graphic></Button>
|
||||
</HBox>
|
||||
<HBox GridPane.columnIndex="2">
|
||||
<TextField fx:id="system2Text" prefWidth="160"/>
|
||||
<Button minWidth="30" onAction="#copySys2"><graphic><Glyph text="FontAwesome|COPY"/></graphic></Button>
|
||||
</HBox>
|
||||
<HBox GridPane.columnIndex="3">
|
||||
<TextField fx:id="system3Text" prefWidth="160"/>
|
||||
<Button minWidth="30" onAction="#copySys3"><graphic><Glyph text="FontAwesome|COPY"/></graphic></Button>
|
||||
</HBox>
|
||||
<HBox GridPane.rowIndex="1" GridPane.columnIndex="1">
|
||||
<TextField fx:id="system4Text" prefWidth="160"/>
|
||||
<Button minWidth="30" onAction="#copySys4"><graphic><Glyph text="FontAwesome|COPY"/></graphic></Button>
|
||||
</HBox>
|
||||
<HBox GridPane.rowIndex="1" GridPane.columnIndex="2">
|
||||
<TextField fx:id="system5Text" prefWidth="160"/>
|
||||
<Button minWidth="30" onAction="#copySys5"><graphic><Glyph text="FontAwesome|COPY"/></graphic></Button>
|
||||
</HBox>
|
||||
<HBox GridPane.rowIndex="1" GridPane.columnIndex="3">
|
||||
<TextField fx:id="system6Text" prefWidth="160"/>
|
||||
<Button minWidth="30" onAction="#copySys6"><graphic><Glyph text="FontAwesome|COPY"/></graphic></Button>
|
||||
</HBox>
|
||||
|
||||
<HBox GridPane.rowIndex="2" spacing="4">
|
||||
<Button prefWidth="30" onAction="#add">
|
||||
|
||||
Reference in New Issue
Block a user