save window size

This commit is contained in:
Jannik 2017-09-12 20:13:26 +02:00
parent 78791bb7e1
commit 3f98dfa059
16 changed files with 43 additions and 1 deletions

Binary file not shown.

View File

@ -195,6 +195,8 @@ public class Main extends Application {
public void changed(ObservableValue<? extends Number> observable, Number oldValue, final Number newValue) {
mainWindowController.refreshUIData();
mainWindowController.refreshplayBtnPosition();
//TODO saveSettings only on left mouseBtn release
mainWindowController.saveSettings();
}
};

View File

@ -228,6 +228,8 @@ public class MainWindowController {
private int xPosHelper;
private int selectedUIDataIndex;
private int selected;
private double windowWidth;
private double windowHeight;
private DirectoryChooser directoryChooser = new DirectoryChooser();
private File dirWin = new File(System.getProperty("user.home") + "/Documents/cemu_UI");
private File dirLinux = new File(System.getProperty("user.home") + "/cemu_UI");
@ -268,7 +270,13 @@ public class MainWindowController {
smmdbApiQuery = new SmmdbApiQuery();
}
void initUI(){
void initUI() {
System.out.println(getWindowWidth());
if (getWindowWidth() > 100 && getWindowHeight() > 100) {
mainAnchorPane.setPrefSize(getWindowWidth(), getWindowHeight());
}
refreshplayBtnPosition();
cemuTextField.setText(cemuPath);
romTextField.setText(romPath);
colorPicker.setValue(Color.valueOf(getColor()));
@ -1288,6 +1296,8 @@ public class MainWindowController {
props.setProperty("cloudService", getCloudService());
}
props.setProperty("folderID", main.cloudController.getFolderID(getCloudService()));
props.setProperty("windowWidth", String.valueOf(mainAnchorPane.getWidth()));
props.setProperty("windowHeight", String.valueOf(mainAnchorPane.getHeight()));
if(System.getProperty("os.name").equals("Linux")){
outputStream = new FileOutputStream(configFileLinux);
}else{
@ -1365,6 +1375,20 @@ public class MainWindowController {
setCloudSync(false);
}
try {
setWindowWidth(Double.parseDouble(props.getProperty("windowWidth")));
} catch (Exception e) {
LOGGER.error("could not load windowWidth, setting default instead", e);
setWindowWidth(904);
}
try {
setWindowHeight(Double.parseDouble(props.getProperty("windowHeight")));
} catch (Exception e) {
LOGGER.error("could not load windowHeight, setting default instead", e);
setWindowHeight(600);
}
inputStream.close();
LOGGER.info("loading settings done!");
} catch (IOException e) {
@ -1579,4 +1603,20 @@ public class MainWindowController {
this.playBtn = playBtn;
}
public double getWindowWidth() {
return windowWidth;
}
public void setWindowWidth(double windowWidth) {
this.windowWidth = windowWidth;
}
public double getWindowHeight() {
return windowHeight;
}
public void setWindowHeight(double windowHeight) {
this.windowHeight = windowHeight;
}
}