code clean up

* cleaned up the playBtn code
* added language section in settings
This commit is contained in:
Jannik 2017-12-18 09:58:32 +01:00
parent 595bfbe07d
commit fc0be39455
3 changed files with 39 additions and 57 deletions

View File

@ -51,13 +51,11 @@ import javafx.scene.layout.AnchorPane;
public class Main extends Application {
private Stage primaryStage; // TODO same as #Test01
private MainWindowController mainWindowController; // TODO Needs more testing: if cemu_UI will work as
//normally expected this waring can be removed #Test01
// if not working correctly remove private!
private CloudController cloudController; // TODO same as #Test01
private AnchorPane pane; // TODO same as #Test01
private Scene scene; // TODO same as #Test01
private Stage primaryStage;
private MainWindowController mainWindowController;
private CloudController cloudController;
private AnchorPane pane;
private Scene scene;
private static String userHome = System.getProperty("user.home");
private static String userName = System.getProperty("user.name");
private static String osName = System.getProperty("os.name");
@ -234,8 +232,6 @@ public class Main extends Application {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, final Number newValue) {
int xPosHelperMax = (int) Math.floor((mainWindowController.getMainAnchorPane().getWidth() - 36) / 217);
mainWindowController.refreshplayBtnPosition();
// call only if there is enough space for a new row
if (mainWindowController.getOldXPosHelper() != xPosHelperMax) {

View File

@ -170,6 +170,9 @@ public class MainWindowController {
@FXML
private JFXToggleButton fullscreenToggleBtn;
@FXML
private ChoiceBox<String> languageChoisBox;
@FXML
private ChoiceBox<String> branchChoisBox;
@ -203,6 +206,9 @@ public class MainWindowController {
@FXML
private HBox topHBox;
@FXML
private HBox bottomHBox;
@FXML
private ImageView smmdbImageView;
@ -221,6 +227,9 @@ public class MainWindowController {
@FXML
private Label mainColorLbl;
@FXML
private Label languageLbl;
@FXML
private Label updateLbl;
@ -276,7 +285,7 @@ public class MainWindowController {
private String selectedGameTitle;
private String id;
private String version = "0.2.2";
private String buildNumber = "065";
private String buildNumber = "067";
private String versionName = "Puzzle Plank Galaxy";
private int xPos = -200;
private int yPos = 17;
@ -295,6 +304,7 @@ public class MainWindowController {
private File pictureCacheWin = new File(dirWin + "/picture_cache");
private File pictureCacheLinux = new File(dirLinux + "/picture_cache");
private ObservableList<String> branches = FXCollections.observableArrayList("stable", "beta");
private ObservableList<String> languages = FXCollections.observableArrayList("english", "deutsch");
private ObservableList<String> smmIDs = FXCollections.observableArrayList("fe31b7f2", "44fc5929"); // TODO add more IDs
private ObservableList<UIROMDataType> games = FXCollections.observableArrayList();
ObservableList<SmmdbApiDataType> courses = FXCollections.observableArrayList();
@ -350,7 +360,6 @@ public class MainWindowController {
if (getWindowWidth() > 100 && getWindowHeight() > 100) {
mainAnchorPane.setPrefSize(getWindowWidth(), getWindowHeight());
}
refreshplayBtnPosition();
cemuTextField.setText(cemuPath);
romTextField.setText(romPath);
@ -359,6 +368,8 @@ public class MainWindowController {
cloudSyncToggleBtn.setSelected(isCloudSync());
autoUpdateToggleBtn.setSelected(isAutoUpdate());
branchChoisBox.setItems(branches);
languageChoisBox.setItems(languages);
bottomHBox.setPickOnBounds(false);
if (isUseBeta()) {
branchChoisBox.getSelectionModel().select(1);
@ -1293,19 +1304,6 @@ public class MainWindowController {
gamesAnchorPane.getChildren().add(games.get(i).getVBox());
}
}
void refreshplayBtnPosition() {
double width;
if (mainAnchorPane.getWidth() < 10) {
width = mainAnchorPane.getPrefWidth();
} else {
width = mainAnchorPane.getWidth();
}
playBtn.setLayoutX((width / 2) - 50);
totalPlaytimeBtn.setLayoutX((width / 2) - 50 - 20.5 - 100);
lastTimePlayedBtn.setLayoutX((width / 2) + 50 + 20.5);
}
private void checkAutoUpdate() {
@ -1696,43 +1694,21 @@ public class MainWindowController {
}
private void playBtnSlideIn(){
playBtn.setVisible(true);
lastTimePlayedBtn.setVisible(true);
totalPlaytimeBtn.setVisible(true);
bottomHBox.setVisible(true);
playTrue = true;
TranslateTransition playBtnTransition = new TranslateTransition(Duration.millis(300), playBtn);
TranslateTransition playBtnTransition = new TranslateTransition(Duration.millis(300), bottomHBox);
playBtnTransition.setFromY(56);
playBtnTransition.setToY(0);
playBtnTransition.play();
TranslateTransition lastTimePlayedBtnTransition = new TranslateTransition(Duration.millis(300), lastTimePlayedBtn);
lastTimePlayedBtnTransition.setFromY(56);
lastTimePlayedBtnTransition.setToY(0);
lastTimePlayedBtnTransition.play();
TranslateTransition timePlayedBtnTransition = new TranslateTransition(Duration.millis(300), totalPlaytimeBtn);
timePlayedBtnTransition.setFromY(56);
timePlayedBtnTransition.setToY(0);
timePlayedBtnTransition.play();
}
private void playBtnSlideOut(){
playTrue = false;
TranslateTransition playBtnTransition = new TranslateTransition(Duration.millis(300), playBtn);
TranslateTransition playBtnTransition = new TranslateTransition(Duration.millis(300), bottomHBox);
playBtnTransition.setFromY(0);
playBtnTransition.setToY(56);
playBtnTransition.play();
TranslateTransition lastTimePlayedBtnTransition = new TranslateTransition(Duration.millis(300), lastTimePlayedBtn);
lastTimePlayedBtnTransition.setFromY(0);
lastTimePlayedBtnTransition.setToY(56);
lastTimePlayedBtnTransition.play();
TranslateTransition timePlayedBtnTransition = new TranslateTransition(Duration.millis(300), totalPlaytimeBtn);
timePlayedBtnTransition.setFromY(0);
timePlayedBtnTransition.setToY(56);
timePlayedBtnTransition.play();
}
private void editColor(String input){

View File

@ -118,10 +118,16 @@
</VBox>
<HBox spacing="10.0">
<children>
<Label fx:id="mainColorLbl" prefHeight="25.0" text="main Color" />
<Label fx:id="mainColorLbl" minHeight="25.0" text="main Color" />
<JFXColorPicker fx:id="colorPicker" onAction="#colorPickerAction" />
</children>
</HBox>
<HBox prefHeight="100.0" prefWidth="200.0" spacing="10.0">
<children>
<Label fx:id="languageLbl" prefHeight="25.0" text="language" />
<ChoiceBox fx:id="languageChoisBox" prefWidth="150.0" />
</children>
</HBox>
<JFXToggleButton fx:id="cloudSyncToggleBtn" onAction="#cloudSyncToggleBtnAction" text="cloud savegames (Google Drive)" />
<VBox spacing="10.0">
<children>
@ -205,13 +211,17 @@
</ScrollPane>
</children>
</AnchorPane>
<JFXButton fx:id="playBtn" buttonType="RAISED" layoutX="396.0" maxHeight="28.0" minWidth="100.0" onAction="#playBtnAction" ripplerFill="#00aacc" text="play" textAlignment="CENTER" visible="false" AnchorPane.bottomAnchor="12.0">
<font>
<Font name="System Bold" size="14.0" />
</font>
<HBox fx:id="bottomHBox" alignment="CENTER" layoutX="326.0" layoutY="602.0" prefHeight="48.0" prefWidth="200.0" spacing="10.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<children>
<JFXButton fx:id="totalPlaytimeBtn" buttonType="RAISED" maxHeight="32.0" maxWidth="125.0" minWidth="125.0" onAction="#totalPlaytimeBtnAction" prefHeight="32.0" prefWidth="125.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" text="0 h 0 min">
</JFXButton>
<JFXButton fx:id="totalPlaytimeBtn" buttonType="RAISED" layoutX="275.5" maxHeight="32.0" minWidth="100.0" onAction="#totalPlaytimeBtnAction" prefHeight="32.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" text="0 h 0 min" visible="false" AnchorPane.bottomAnchor="10.0">
</JFXButton>
<JFXButton fx:id="lastTimePlayedBtn" buttonType="RAISED" layoutX="516.5" maxHeight="32.0" minWidth="100.0" onAction="#lastTimePlayedBtnAction" prefHeight="32.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" text="Last played, never" visible="false" AnchorPane.bottomAnchor="10.0" />
<JFXButton fx:id="playBtn" buttonType="RAISED" maxHeight="28.0" minWidth="100.0" onAction="#playBtnAction" ripplerFill="#00aacc" text="play" textAlignment="CENTER">
<font>
<Font name="System Bold" size="14.0" />
</font>
</JFXButton>
<JFXButton fx:id="lastTimePlayedBtn" buttonType="RAISED" maxHeight="32.0" maxWidth="125.0" minWidth="125.0" onAction="#lastTimePlayedBtnAction" prefHeight="32.0" prefWidth="125.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" text="Last played, never" />
</children>
</HBox>
</children>
</AnchorPane>