save helper window position
This commit is contained in:
@@ -49,7 +49,7 @@ public class EDCE {
|
||||
this.world = world;
|
||||
this.session = new EDSession();
|
||||
this.updater = new StationUpdater(world);
|
||||
this.settings = Main.SETTINGS.getEdce();
|
||||
this.settings = Main.SETTINGS.edce();
|
||||
active = new SimpleBooleanProperty(settings.isActive());
|
||||
settings.activeProperty().addListener((ov, o, n) -> {
|
||||
if (n) run();
|
||||
|
||||
@@ -40,6 +40,9 @@ public class Main extends Application {
|
||||
loadMainScene();
|
||||
loadResources();
|
||||
primaryStage.show();
|
||||
if (Main.SETTINGS.helper().isVisible()){
|
||||
Screeners.showHelper();
|
||||
}
|
||||
ServicesManager.runAll();
|
||||
}
|
||||
|
||||
@@ -67,10 +70,14 @@ public class Main extends Application {
|
||||
public static void changeLocale(Locale locale) throws IOException {
|
||||
Localization.setLocale(locale);
|
||||
primaryStage.hide();
|
||||
Screeners.closeAll();
|
||||
MainController.getWorld().refresh();
|
||||
loadMainScene();
|
||||
loadResources();
|
||||
primaryStage.show();
|
||||
if (Main.SETTINGS.helper().isVisible()){
|
||||
Screeners.showHelper();
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadMainScene() throws IOException {
|
||||
|
||||
@@ -19,18 +19,21 @@ public class Settings {
|
||||
private final File file;
|
||||
private Profile profile;
|
||||
private final EDCESettings edce;
|
||||
private final HelperSettings helper;
|
||||
|
||||
|
||||
public Settings() {
|
||||
this.file = null;
|
||||
profile = new Profile(new Ship());
|
||||
edce = new EDCESettings();
|
||||
helper = new HelperSettings();
|
||||
}
|
||||
|
||||
public Settings(File file) {
|
||||
this.file = file;
|
||||
profile = new Profile(new Ship());
|
||||
edce = new EDCESettings();
|
||||
helper = new HelperSettings();
|
||||
}
|
||||
|
||||
public void load(Market market) {
|
||||
@@ -43,12 +46,14 @@ public class Settings {
|
||||
}
|
||||
profile = Profile.readFrom(values, market);
|
||||
edce.readFrom(values);
|
||||
helper.readFrom(values);
|
||||
}
|
||||
|
||||
public void save(){
|
||||
try (OutputStream os = new FileOutputStream(file)) {
|
||||
profile.writeTo(values);
|
||||
edce.writeTo(values);
|
||||
helper.writeTo(values);
|
||||
values.store(os, "settings");
|
||||
} catch (IOException e) {
|
||||
LOG.error("Error on load settings", e);
|
||||
@@ -148,10 +153,14 @@ public class Settings {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public EDCESettings getEdce(){
|
||||
public EDCESettings edce(){
|
||||
return edce;
|
||||
}
|
||||
|
||||
public HelperSettings helper(){
|
||||
return helper;
|
||||
}
|
||||
|
||||
public final class EDCESettings {
|
||||
private final BooleanProperty active;
|
||||
private final StringProperty email;
|
||||
@@ -213,4 +222,65 @@ public class Settings {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public final class HelperSettings {
|
||||
private final IntegerProperty x;
|
||||
private final IntegerProperty y;
|
||||
private final BooleanProperty visible;
|
||||
|
||||
public HelperSettings() {
|
||||
x = new SimpleIntegerProperty();
|
||||
y = new SimpleIntegerProperty();
|
||||
visible = new SimpleBooleanProperty();
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x.get();
|
||||
}
|
||||
|
||||
public IntegerProperty xProperty() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
this.x.set(x);
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y.get();
|
||||
}
|
||||
|
||||
public IntegerProperty yProperty() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
this.y.set(y);
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible.get();
|
||||
}
|
||||
|
||||
public BooleanProperty visibleProperty() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
this.visible.set(visible);
|
||||
}
|
||||
|
||||
public void readFrom(Properties values){
|
||||
setVisible(!"0".equals(values.getProperty("helper.visible", "0")));
|
||||
setX(Integer.valueOf(values.getProperty("helper.x", "100")));
|
||||
setY(Integer.valueOf(values.getProperty("helper.y", "100")));
|
||||
}
|
||||
|
||||
public void writeTo(Properties values){
|
||||
values.setProperty("helper.visible", isVisible() ? "1":"0");
|
||||
values.setProperty("helper.x", String.valueOf(getX()));
|
||||
values.setProperty("helper.y", String.valueOf(getY()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,9 +66,6 @@ public class HelperController {
|
||||
|
||||
@FXML
|
||||
private void initialize(){
|
||||
ProfileModel profile = MainController.getProfile();
|
||||
profile.routeProperty().addListener(routeListener);
|
||||
profile.dockedProperty().addListener(dockedListener);
|
||||
buyOrders.setCellFactory(new OrderListCell(false));
|
||||
sellOrders.setCellFactory(new OrderListCell(true));
|
||||
sellOffers.setCellFactory(new OfferListCell(true));
|
||||
@@ -83,7 +80,6 @@ public class HelperController {
|
||||
infoGroup.managedProperty().bind(infoGroup.visibleProperty());
|
||||
hideInfo();
|
||||
hideStationInfo();
|
||||
bindKeys();
|
||||
}
|
||||
|
||||
private void resize(){
|
||||
@@ -138,11 +134,18 @@ public class HelperController {
|
||||
scene.setFill(Color.TRANSPARENT);
|
||||
stage.setAlwaysOnTop(true);
|
||||
addDragListeners(content);
|
||||
stage.setX(Main.SETTINGS.helper().getX());
|
||||
stage.setY(Main.SETTINGS.helper().getY());
|
||||
bind();
|
||||
Main.SETTINGS.helper().setVisible(true);
|
||||
stage.show();
|
||||
setRoute(MainController.getProfile().getRoute());
|
||||
} else {
|
||||
if (toggle && stage.isShowing()){
|
||||
Main.SETTINGS.helper().setVisible(false);
|
||||
stage.hide();
|
||||
} else {
|
||||
Main.SETTINGS.helper().setVisible(true);
|
||||
stage.show();
|
||||
}
|
||||
}
|
||||
@@ -151,9 +154,28 @@ public class HelperController {
|
||||
public void close(){
|
||||
if (stage != null){
|
||||
stage.close();
|
||||
unbind();
|
||||
stage = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void bind(){
|
||||
ProfileModel profile = MainController.getProfile();
|
||||
profile.routeProperty().addListener(routeListener);
|
||||
profile.dockedProperty().addListener(dockedListener);
|
||||
Main.SETTINGS.helper().xProperty().bind(stage.xProperty());
|
||||
Main.SETTINGS.helper().yProperty().bind(stage.yProperty());
|
||||
bindKeys();
|
||||
}
|
||||
|
||||
private void unbind(){
|
||||
ProfileModel profile = MainController.getProfile();
|
||||
profile.routeProperty().removeListener(routeListener);
|
||||
profile.dockedProperty().removeListener(dockedListener);
|
||||
Main.SETTINGS.helper().xProperty().unbind();
|
||||
Main.SETTINGS.helper().yProperty().unbind();
|
||||
}
|
||||
|
||||
private void setRoute(RouteModel route){
|
||||
if (this.route != null){
|
||||
this.route.currentEntryProperty().removeListener(currentEntryListener);
|
||||
@@ -246,8 +268,7 @@ public class HelperController {
|
||||
}
|
||||
|
||||
private void bindKeys(){
|
||||
KeyBinding.bind(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD4, KeyEvent.CTRL_MASK | KeyEvent.ALT_MASK), k -> ViewUtils.doFX(this::previous));
|
||||
KeyBinding.bind(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD6, KeyEvent.CTRL_MASK | KeyEvent.ALT_MASK), k -> ViewUtils.doFX(this::next));
|
||||
KeyBinding.bind(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_MASK), k -> ViewUtils.doFX(this::complete));
|
||||
}
|
||||
|
||||
private final ChangeListener<? super Number> currentEntryListener = (ov, o, n) -> ViewUtils.doFX(() -> setRouteEntry(n.intValue()));
|
||||
|
||||
@@ -36,7 +36,7 @@ public class LoginController {
|
||||
loginButton.setDisable(true);
|
||||
email.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||
loginButton.setDisable(newValue.trim().isEmpty());
|
||||
Main.SETTINGS.getEdce().setEmail(newValue);
|
||||
Main.SETTINGS.edce().setEmail(newValue);
|
||||
});
|
||||
dialog.setResultConverter(dialogButton -> {
|
||||
if (dialogButton == loginButtonType) {
|
||||
|
||||
@@ -110,6 +110,7 @@ public class MainController {
|
||||
itemsController.init();
|
||||
offersController.init();
|
||||
routerController.init();
|
||||
//TODO: add init all controllers
|
||||
}
|
||||
|
||||
public void initEDCE(){
|
||||
|
||||
@@ -51,6 +51,8 @@ public class ProfileController {
|
||||
@FXML
|
||||
private Button btnAddStation;
|
||||
@FXML
|
||||
private ToggleButton btnHelper;
|
||||
@FXML
|
||||
private ToggleButton btnEDCE;
|
||||
|
||||
private AutoCompletion<SystemModel> system;
|
||||
@@ -81,6 +83,8 @@ public class ProfileController {
|
||||
if (ModelFabric.isFake(profile.getStation())) Screeners.showAddStation(profile.getSystem());
|
||||
else Screeners.showEditStation(profile.getStation());
|
||||
});
|
||||
btnHelper.setOnAction(e -> toggleHelper());
|
||||
btnHelper.setSelected(Main.SETTINGS.helper().isVisible());
|
||||
shipInfo.setVisible(false);
|
||||
initListeners();
|
||||
}
|
||||
@@ -138,7 +142,7 @@ public class ProfileController {
|
||||
}
|
||||
|
||||
public void initEDCEBtn(){
|
||||
btnEDCE.selectedProperty().bindBidirectional(Main.SETTINGS.getEdce().activeProperty());
|
||||
btnEDCE.selectedProperty().bindBidirectional(Main.SETTINGS.edce().activeProperty());
|
||||
setEDCEBtnStyles(btnEDCE.isSelected());
|
||||
ServicesManager.getEdce().activeProperty().addListener((ov, o, n) -> {
|
||||
setEDCEBtnStyles(n);
|
||||
|
||||
@@ -249,6 +249,10 @@ public class Screeners {
|
||||
return dialog.showAndWait();
|
||||
}
|
||||
|
||||
public static void showHelper(){
|
||||
helperController.show(helperScreen, false);
|
||||
}
|
||||
|
||||
public static void toggleHelper(){
|
||||
helperController.show(helperScreen, true);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<ToggleButton minWidth="30" onAction="#toggleShipInfo">
|
||||
<graphic><Glyph text="FontAwesome|SPACE_SHUTTLE"/></graphic>
|
||||
</ToggleButton>
|
||||
<ToggleButton minWidth="30" onAction="#toggleHelper">
|
||||
<ToggleButton fx:id="btnHelper" minWidth="30">
|
||||
<graphic><Glyph text="FontAwesome|ROCKET"/></graphic>
|
||||
</ToggleButton>
|
||||
<ToggleButton fx:id="btnEDCE" text="EDCE"/>
|
||||
|
||||
Reference in New Issue
Block a user