modify profile screen
This commit is contained in:
@@ -95,6 +95,7 @@ public class HelperController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setDocked(boolean docked){
|
private void setDocked(boolean docked){
|
||||||
|
if (route == null) return;
|
||||||
if (docked && MainController.getProfile().getStation().equals(entry.getStation())){
|
if (docked && MainController.getProfile().getStation().equals(entry.getStation())){
|
||||||
showStationInfo();
|
showStationInfo();
|
||||||
} else {
|
} else {
|
||||||
@@ -127,7 +128,7 @@ public class HelperController {
|
|||||||
resize();
|
resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(Parent content) {
|
public void show(Parent content, boolean toggle) {
|
||||||
if (stage == null){
|
if (stage == null){
|
||||||
stage = new Stage();
|
stage = new Stage();
|
||||||
stage.setScene(new Scene(content));
|
stage.setScene(new Scene(content));
|
||||||
@@ -136,7 +137,11 @@ public class HelperController {
|
|||||||
addDragListeners(content);
|
addDragListeners(content);
|
||||||
stage.show();
|
stage.show();
|
||||||
} else {
|
} else {
|
||||||
stage.show();
|
if (toggle && stage.isShowing()){
|
||||||
|
stage.hide();
|
||||||
|
} else {
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package ru.trader.controllers;
|
package ru.trader.controllers;
|
||||||
|
|
||||||
|
|
||||||
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.beans.value.ChangeListener;
|
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.*;
|
||||||
import javafx.scene.control.CheckBox;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.control.ComboBox;
|
|
||||||
import javafx.scene.control.TextField;
|
|
||||||
import javafx.util.StringConverter;
|
import javafx.util.StringConverter;
|
||||||
import ru.trader.core.Engine;
|
import ru.trader.core.Engine;
|
||||||
import ru.trader.model.*;
|
import ru.trader.model.*;
|
||||||
@@ -39,6 +38,12 @@ public class ProfileController {
|
|||||||
@FXML
|
@FXML
|
||||||
private ComboBox<Engine> engine;
|
private ComboBox<Engine> engine;
|
||||||
@FXML
|
@FXML
|
||||||
|
private Label jumpRange;
|
||||||
|
@FXML
|
||||||
|
private Pane profileInfo;
|
||||||
|
@FXML
|
||||||
|
private Pane shipInfo;
|
||||||
|
@FXML
|
||||||
private Button btnAddSystem;
|
private Button btnAddSystem;
|
||||||
@FXML
|
@FXML
|
||||||
private Button btnAddStation;
|
private Button btnAddStation;
|
||||||
@@ -55,14 +60,32 @@ public class ProfileController {
|
|||||||
system = new AutoCompletion<>(systemText, provider, ModelFabric.NONE_SYSTEM, provider.getConverter());
|
system = new AutoCompletion<>(systemText, provider, ModelFabric.NONE_SYSTEM, provider.getConverter());
|
||||||
engine.setItems(FXCollections.observableList(Engine.getEngines()));
|
engine.setItems(FXCollections.observableList(Engine.getEngines()));
|
||||||
engine.setConverter(new EngineStringConverter());
|
engine.setConverter(new EngineStringConverter());
|
||||||
btnAddSystem.setOnAction(e -> Screeners.showSystemsEditor(null));
|
btnAddSystem.setOnAction(e -> {
|
||||||
btnAddStation.setOnAction(e -> Screeners.showAddStation(profile.getSystem()));
|
if (ModelFabric.isFake(profile.getSystem())) Screeners.showSystemsEditor(null);
|
||||||
|
else Screeners.showSystemsEditor(profile.getSystem());
|
||||||
|
});
|
||||||
|
btnAddStation.setOnAction(e -> {
|
||||||
|
if (ModelFabric.isFake(profile.getStation())) Screeners.showAddStation(profile.getSystem());
|
||||||
|
else Screeners.showEditStation(profile.getStation());
|
||||||
|
});
|
||||||
|
shipInfo.setVisible(false);
|
||||||
initListeners();
|
initListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void showHelper(){
|
private void toggleShipInfo(){
|
||||||
Screeners.showHelper();
|
if (shipInfo.isVisible()){
|
||||||
|
profileInfo.setVisible(true);
|
||||||
|
shipInfo.setVisible(false);
|
||||||
|
} else {
|
||||||
|
profileInfo.setVisible(false);
|
||||||
|
shipInfo.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private void toggleHelper(){
|
||||||
|
Screeners.toggleHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void consumeChanges(Runnable runnable){
|
private void consumeChanges(Runnable runnable){
|
||||||
@@ -123,6 +146,11 @@ public class ProfileController {
|
|||||||
profile.shipTankProperty().addListener(tankListener);
|
profile.shipTankProperty().addListener(tankListener);
|
||||||
profile.shipCargoProperty().addListener(cargoListener);
|
profile.shipCargoProperty().addListener(cargoListener);
|
||||||
profile.shipEngineProperty().addListener(engineListener);
|
profile.shipEngineProperty().addListener(engineListener);
|
||||||
|
jumpRange.textProperty().bind(Bindings.createStringBinding(()-> {
|
||||||
|
return String.format("%.1f - %.1f", profile.getShipJumpRange(), profile.getMaxShipJumpRange());
|
||||||
|
},
|
||||||
|
profile.shipMassProperty(), profile.shipCargoProperty(), profile.shipTankProperty(), profile.shipEngineProperty()
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unbind(){
|
private void unbind(){
|
||||||
@@ -135,6 +163,7 @@ public class ProfileController {
|
|||||||
profile.shipTankProperty().removeListener(tankListener);
|
profile.shipTankProperty().removeListener(tankListener);
|
||||||
profile.shipCargoProperty().removeListener(cargoListener);
|
profile.shipCargoProperty().removeListener(cargoListener);
|
||||||
profile.shipEngineProperty().removeListener(engineListener);
|
profile.shipEngineProperty().removeListener(engineListener);
|
||||||
|
jumpRange.textProperty().unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class RouteSearchController {
|
|||||||
RouteModel route = path.get();
|
RouteModel route = path.get();
|
||||||
route.addAll(0, missionsList.getItems());
|
route.addAll(0, missionsList.getItems());
|
||||||
profile.setRoute(route);
|
profile.setRoute(route);
|
||||||
Screeners.showHelper();
|
Screeners.toggleHelper();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ public class RouterController {
|
|||||||
if (path.isPresent()){
|
if (path.isPresent()){
|
||||||
orders.addAll(path.get().getOrders());
|
orders.addAll(path.get().getOrders());
|
||||||
addRouteToPath(path.get());
|
addRouteToPath(path.get());
|
||||||
Screeners.showHelper();
|
Screeners.toggleHelper();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,8 +247,8 @@ public class Screeners {
|
|||||||
return dialog.showAndWait();
|
return dialog.showAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showHelper(){
|
public static void toggleHelper(){
|
||||||
helperController.show(helperScreen);
|
helperController.show(helperScreen, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reinitAll() {
|
public static void reinitAll() {
|
||||||
|
|||||||
@@ -41,46 +41,24 @@ public class ProfileModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initListeners() {
|
private void initListeners() {
|
||||||
name.addListener((ov, o, n) -> {
|
name.addListener((ov, o, n) -> LOG.debug("Change name, old: {}, new: {}", o, n));
|
||||||
LOG.debug("Change name, old: {}, new: {}", o, n);
|
balance.addListener((ov, o, n) -> LOG.debug("Change balance, old: {}, new: {}", o, n));
|
||||||
profile.setName(n);
|
|
||||||
});
|
|
||||||
balance.addListener((ov, o, n) -> {
|
|
||||||
LOG.debug("Change balance, old: {}, new: {}", o, n);
|
|
||||||
profile.setBalance(n.doubleValue());
|
|
||||||
});
|
|
||||||
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);
|
|
||||||
if (route.getValue() != null) {getRoute().updateCurrentEntry(n);}
|
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);
|
||||||
profile.setStation(n != null && n != ModelFabric.NONE_STATION ? n.getStation() : null);
|
|
||||||
if (route.getValue() != null) {getRoute().updateCurrentEntry(getSystem(), n);}
|
if (route.getValue() != null) {getRoute().updateCurrentEntry(getSystem(), n);}
|
||||||
});
|
});
|
||||||
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);
|
|
||||||
if (!n && route.getValue() != null) {getRoute().updateCurrentEntry(getSystem(), getStation(), true);}
|
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);
|
shipTank.addListener((ov, o, n) -> LOG.debug("Change ship tank, old: {}, new: {}", o, n));
|
||||||
profile.getShip().setMass(n.doubleValue());
|
shipCargo.addListener((ov, o, n) -> LOG.debug("Change ship cargo, old: {}, new: {}", o, n));
|
||||||
});
|
shipEngine.addListener((ov, o, n) -> LOG.debug("Change ship engine, old: {}, new: {}", o, n));
|
||||||
shipTank.addListener((ov, o, n) -> {
|
|
||||||
LOG.debug("Change ship tank, old: {}, new: {}", o, n);
|
|
||||||
profile.getShip().setTank(n.doubleValue());
|
|
||||||
});
|
|
||||||
shipCargo.addListener((ov, o, n) -> {
|
|
||||||
LOG.debug("Change ship cargo, old: {}, new: {}", o, n);
|
|
||||||
profile.getShip().setCargo(n.intValue());
|
|
||||||
});
|
|
||||||
shipEngine.addListener((ov, o, n) -> {
|
|
||||||
LOG.debug("Change ship engine, old: {}, new: {}", o, n);
|
|
||||||
profile.getShip().setEngine(n);
|
|
||||||
});
|
|
||||||
|
|
||||||
route.addListener((ov, o, n) -> LOG.debug("Change route, old: {}, new: {}", o, n));
|
route.addListener((ov, o, n) -> LOG.debug("Change route, old: {}, new: {}", o, n));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +79,7 @@ public class ProfileModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
|
profile.setName(name);
|
||||||
this.name.set(name);
|
this.name.set(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +92,7 @@ public class ProfileModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBalance(double balance) {
|
public void setBalance(double balance) {
|
||||||
|
profile.setBalance(balance);
|
||||||
this.balance.set(balance);
|
this.balance.set(balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,6 +105,7 @@ public class ProfileModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSystem(SystemModel system) {
|
public void setSystem(SystemModel system) {
|
||||||
|
profile.setSystem(ModelFabric.isFake(system) ? null : system.getSystem());
|
||||||
this.system.set(system);
|
this.system.set(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +118,7 @@ public class ProfileModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setStation(StationModel station) {
|
public void setStation(StationModel station) {
|
||||||
|
profile.setStation(ModelFabric.isFake(station) ? null : station.getStation());
|
||||||
this.station.set(station);
|
this.station.set(station);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,6 +131,7 @@ public class ProfileModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setDocked(boolean docked) {
|
public void setDocked(boolean docked) {
|
||||||
|
profile.setDocked(docked);
|
||||||
this.docked.set(docked);
|
this.docked.set(docked);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,6 +144,7 @@ public class ProfileModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setShipMass(double shipMass) {
|
public void setShipMass(double shipMass) {
|
||||||
|
profile.getShip().setMass(shipMass);
|
||||||
this.shipMass.set(shipMass);
|
this.shipMass.set(shipMass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +157,7 @@ public class ProfileModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setShipTank(double shipTank) {
|
public void setShipTank(double shipTank) {
|
||||||
|
profile.getShip().setTank(shipTank);
|
||||||
this.shipTank.set(shipTank);
|
this.shipTank.set(shipTank);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,6 +170,7 @@ public class ProfileModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setShipCargo(int shipCargo) {
|
public void setShipCargo(int shipCargo) {
|
||||||
|
profile.getShip().setCargo(shipCargo);
|
||||||
this.shipCargo.set(shipCargo);
|
this.shipCargo.set(shipCargo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,6 +183,7 @@ public class ProfileModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setShipEngine(Engine engine) {
|
public void setShipEngine(Engine engine) {
|
||||||
|
profile.getShip().setEngine(engine);
|
||||||
this.shipEngine.set(engine);
|
this.shipEngine.set(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,6 +199,14 @@ public class ProfileModel {
|
|||||||
this.route.set(route);
|
this.route.set(route);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getShipJumpRange(){
|
||||||
|
return profile.getShip().getJumpRange();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMaxShipJumpRange(){
|
||||||
|
return profile.getShip().getMaxJumpRange();
|
||||||
|
}
|
||||||
|
|
||||||
private void refresh(){
|
private void refresh(){
|
||||||
name.setValue(profile.getName());
|
name.setValue(profile.getName());
|
||||||
balance.setValue(profile.getBalance());
|
balance.setValue(profile.getBalance());
|
||||||
|
|||||||
@@ -12,35 +12,36 @@
|
|||||||
spacing="4" >
|
spacing="4" >
|
||||||
<Label text="Имя:" />
|
<Label text="Имя:" />
|
||||||
<TextField fx:id="name" />
|
<TextField fx:id="name" />
|
||||||
<Label text="Баланс:" />
|
<StackPane>
|
||||||
<NumberField fx:id="balance" />
|
<HBox fx:id="profileInfo">
|
||||||
<Label text="Система:" />
|
<Label text="Баланс:" />
|
||||||
<TextField fx:id="systemText" />
|
<NumberField fx:id="balance" />
|
||||||
<Button fx:id="btnAddSystem"/>
|
<Label text="Система:" />
|
||||||
<Label text="Станция:" />
|
<TextField fx:id="systemText" />
|
||||||
<ComboBox fx:id="station" />
|
<Button fx:id="btnAddSystem"/>
|
||||||
<Button fx:id="btnAddStation"/>
|
<Label text="Станция:" />
|
||||||
<Label text="В доке:" />
|
<ComboBox fx:id="station" />
|
||||||
<CheckBox fx:id="docked" />
|
<Button fx:id="btnAddStation"/>
|
||||||
<Button prefWidth="30" onAction="#showHelper">
|
<Label text="В доке:" />
|
||||||
<graphic><Glyph text="FontAwesome|ROCKET"/></graphic>
|
<CheckBox fx:id="docked" />
|
||||||
</Button>
|
</HBox>
|
||||||
<VBox>
|
<HBox fx:id="shipInfo">
|
||||||
<HBox>
|
|
||||||
<Label text="Трюм:" />
|
<Label text="Трюм:" />
|
||||||
<NumberField fx:id="cargo" />
|
<NumberField fx:id="cargo" maxWidth="60"/>
|
||||||
</HBox>
|
|
||||||
<HBox>
|
|
||||||
<Label text="Топливный бак:" />
|
<Label text="Топливный бак:" />
|
||||||
<NumberField fx:id="tank" />
|
<NumberField fx:id="tank" maxWidth="60"/>
|
||||||
</HBox>
|
|
||||||
<HBox>
|
|
||||||
<Label text="Масса:" />
|
<Label text="Масса:" />
|
||||||
<NumberField fx:id="mass" />
|
<NumberField fx:id="mass" maxWidth="60"/>
|
||||||
</HBox>
|
|
||||||
<HBox>
|
|
||||||
<Label text="Двигатель:" />
|
<Label text="Двигатель:" />
|
||||||
<ComboBox fx:id="engine" />
|
<ComboBox fx:id="engine" maxWidth="60"/>
|
||||||
|
<Label text="Дальность прыжка, LY:" />
|
||||||
|
<Label fx:id="jumpRange"/>
|
||||||
</HBox>
|
</HBox>
|
||||||
</VBox>
|
</StackPane>
|
||||||
|
<ToggleButton prefWidth="30" onAction="#toggleShipInfo">
|
||||||
|
<graphic><Glyph text="FontAwesome|SPACE_SHUTTLE"/></graphic>
|
||||||
|
</ToggleButton>
|
||||||
|
<ToggleButton prefWidth="30" onAction="#toggleHelper">
|
||||||
|
<graphic><Glyph text="FontAwesome|ROCKET"/></graphic>
|
||||||
|
</ToggleButton>
|
||||||
</HBox>
|
</HBox>
|
||||||
|
|||||||
Reference in New Issue
Block a user