code clean up
This commit is contained in:
parent
ba2f4123db
commit
fab1d2d062
Binary file not shown.
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<AnchorPane prefHeight="600.0" prefWidth="892.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController">
|
<AnchorPane prefHeight="600.0" prefWidth="892.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController">
|
||||||
<children>
|
<children>
|
||||||
<ScrollPane fx:id="scrollPaneMain" fitToWidth="true" layoutY="38.0" prefHeight="562.0" prefWidth="893.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
|
<ScrollPane fx:id="scrollPaneMain" fitToWidth="true" layoutY="38.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
|
||||||
<content>
|
<content>
|
||||||
<AnchorPane fx:id="gamesAnchorPane">
|
<AnchorPane fx:id="gamesAnchorPane">
|
||||||
<padding>
|
<padding>
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
</padding></AnchorPane>
|
</padding></AnchorPane>
|
||||||
</content>
|
</content>
|
||||||
</ScrollPane>
|
</ScrollPane>
|
||||||
<HBox fx:id="topHBox" prefHeight="38.0" prefWidth="900.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<HBox fx:id="topHBox" prefHeight="38.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<children>
|
<children>
|
||||||
<JFXHamburger fx:id="menuHam" prefHeight="38.0" prefWidth="38.0" />
|
<JFXHamburger fx:id="menuHam" prefHeight="38.0" prefWidth="38.0" />
|
||||||
</children>
|
</children>
|
||||||
|
@ -54,10 +54,16 @@
|
||||||
<JFXColorPicker fx:id="colorPicker" layoutX="14.0" layoutY="89.0" onAction="#colorPickerAction" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="89.0" />
|
<JFXColorPicker fx:id="colorPicker" layoutX="14.0" layoutY="89.0" onAction="#colorPickerAction" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="89.0" />
|
||||||
<JFXToggleButton fx:id="fullscreenToggleBtn" layoutX="14.0" layoutY="125.0" onAction="#fullscreenToggleBtnAction" text="start game in fullscreen" />
|
<JFXToggleButton fx:id="fullscreenToggleBtn" layoutX="14.0" layoutY="125.0" onAction="#fullscreenToggleBtnAction" text="start game in fullscreen" />
|
||||||
</children></AnchorPane>
|
</children></AnchorPane>
|
||||||
<JFXButton fx:id="playBtn" buttonType="RAISED" layoutX="392.5" layoutY="555.0" onAction="#playBtnAction" prefHeight="38.0" prefWidth="100.0" ripplerFill="#c92a2a" text="play" visible="false" AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="392.5" AnchorPane.rightAnchor="392.5" AnchorPane.topAnchor="555.0">
|
<JFXButton fx:id="playBtn" buttonType="RAISED" maxHeight="38.0" maxWidth="100.0" onAction="#playBtnAction" ripplerFill="#c92a2a" text="play" visible="false" AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="396.0" AnchorPane.rightAnchor="396.0" AnchorPane.topAnchor="555.0">
|
||||||
<font>
|
<font>
|
||||||
<Font name="System Bold" size="14.0" />
|
<Font name="System Bold" size="14.0" />
|
||||||
</font>
|
</font>
|
||||||
</JFXButton>
|
</JFXButton>
|
||||||
|
<JFXButton fx:id="timePlayedBtn" buttonType="RAISED" layoutX="341.0" layoutY="588.0" onAction="#timePlayedBtnAction" prefHeight="32.0" prefWidth="100.0" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="516.5" AnchorPane.topAnchor="558.0">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="14.0" />
|
||||||
|
</font>
|
||||||
|
</JFXButton>
|
||||||
|
<JFXButton fx:id="lastTimePlayedBtn" buttonType="RAISED" maxHeight="32.0" onAction="#lastTimePlayedBtnAction" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="516.5" AnchorPane.topAnchor="558.0" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,13 +1,16 @@
|
||||||
package application;
|
package application;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.channels.Channels;
|
||||||
|
import java.nio.channels.ReadableByteChannel;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.stage.DirectoryChooser;
|
import javafx.stage.DirectoryChooser;
|
||||||
import javafx.stage.FileChooser;
|
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
|
@ -20,12 +23,16 @@ public class Main extends Application {
|
||||||
|
|
||||||
Stage primaryStage;
|
Stage primaryStage;
|
||||||
private MainWindowController mainWindowController;
|
private MainWindowController mainWindowController;
|
||||||
private File dirWin = new File(System.getProperty("user.home") + "/Documents/cemu_UI"); //Windows: C:/Users/"User"/Documents/HomeFlix
|
private String dirWin = System.getProperty("user.home") + "/Documents/cemu_UI"; //Windows: C:/Users/"User"/Documents/HomeFlix
|
||||||
private File dirLinux = new File(System.getProperty("user.home") + "/cemu_UI"); //Linux: /home/"User"/HomeFlix
|
private String dirLinux = System.getProperty("user.home") + "/cemu_UI"; //Linux: /home/"User"/HomeFlix
|
||||||
private File fileWin = new File(dirWin + "/config.xml"); //Windows: C:/Users/"User"/Documents/HomeFlix/config.xml
|
private String gamesDBdownloadURL = "https://github.com/Seil0/cemu_UI/raw/master/downloadContent/games.db";
|
||||||
private File fileLinux = new File(dirLinux + "/config.xml"); //Linux: /home/"User"/HomeFlix/config.xml
|
private File directory;
|
||||||
private File pictureCacheWin = new File(dirWin+"/picture_cache");
|
private File configFile;
|
||||||
private File pictureCacheLinux = new File(dirLinux+"/picture_cache");
|
private File gamesDBFile;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private File localDB;
|
||||||
|
private File pictureCache;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
|
@ -37,8 +44,6 @@ public class Main extends Application {
|
||||||
try {
|
try {
|
||||||
FXMLLoader loader = new FXMLLoader(Main.class.getResource("MainWindow.fxml"));
|
FXMLLoader loader = new FXMLLoader(Main.class.getResource("MainWindow.fxml"));
|
||||||
AnchorPane pane = loader.load();
|
AnchorPane pane = loader.load();
|
||||||
primaryStage.setMinHeight(600.00);
|
|
||||||
primaryStage.setMinWidth(900.00);
|
|
||||||
primaryStage.setResizable(false);
|
primaryStage.setResizable(false);
|
||||||
primaryStage.setTitle("cemu_UI");
|
primaryStage.setTitle("cemu_UI");
|
||||||
// primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("/recources/Homeflix_Icon_64x64.png"))); //adds application icon
|
// primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("/recources/Homeflix_Icon_64x64.png"))); //adds application icon
|
||||||
|
@ -46,46 +51,61 @@ public class Main extends Application {
|
||||||
mainWindowController = loader.getController(); //Link of FXMLController and controller class
|
mainWindowController = loader.getController(); //Link of FXMLController and controller class
|
||||||
mainWindowController.setMain(this); //call setMain
|
mainWindowController.setMain(this); //call setMain
|
||||||
|
|
||||||
//Linux if directory exists -> check config.xml
|
//get os and the right paths
|
||||||
if(System.getProperty("os.name").equals("Linux")){
|
if(System.getProperty("os.name").equals("Linux")){
|
||||||
if(dirLinux.exists() != true){
|
directory = new File(dirLinux);
|
||||||
dirLinux.mkdir();
|
configFile = new File(dirLinux + "/config.xml");
|
||||||
pictureCacheLinux.mkdir();
|
gamesDBFile = new File(dirLinux + "/games.db");
|
||||||
}else if(fileLinux.exists() != true){
|
localDB = new File(dirLinux+"/localRoms.db");
|
||||||
firstStart();
|
pictureCache= new File(dirLinux+"/picture_cache");
|
||||||
mainWindowController.setColor("00a8cc");
|
|
||||||
mainWindowController.setxPosHelper(0);
|
|
||||||
mainWindowController.saveSettings();
|
|
||||||
Runtime.getRuntime().exec("java -jar cemu_UI.jar"); //start again (preventing Bugs)
|
|
||||||
System.exit(0); //finishes itself
|
|
||||||
}
|
|
||||||
if(pictureCacheLinux.exists() != true){
|
|
||||||
pictureCacheLinux.mkdir();
|
|
||||||
}
|
|
||||||
//windows
|
|
||||||
}else{
|
}else{
|
||||||
if(dirWin.exists() != true){
|
directory = new File(dirWin);
|
||||||
dirWin.mkdir();
|
configFile = new File(dirWin + "/config.xml");
|
||||||
pictureCacheWin.mkdir();
|
gamesDBFile = new File(dirWin + "/games.db");
|
||||||
}else if(fileWin.exists() != true){
|
localDB = new File(dirWin+"/localRoms.db");
|
||||||
firstStart();
|
pictureCache= new File(dirWin+"/picture_cache");
|
||||||
mainWindowController.setColor("00a8cc");
|
}
|
||||||
mainWindowController.setxPosHelper(0);
|
|
||||||
mainWindowController.saveSettings();
|
//startup checks
|
||||||
Runtime.getRuntime().exec("java -jar cemu_UI.jar"); //start again (preventing Bugs)
|
System.out.println(directory.exists());
|
||||||
System.exit(0); //finishes itself
|
System.out.println(configFile.exists());
|
||||||
}
|
if(directory.exists() != true){
|
||||||
if(pictureCacheWin.exists() != true){
|
System.out.println("mkdir all");
|
||||||
pictureCacheWin.mkdir();
|
directory.mkdir();
|
||||||
|
pictureCache.mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(configFile.exists() != true){
|
||||||
|
System.out.println("firststart");
|
||||||
|
firstStart();
|
||||||
|
mainWindowController.setColor("00a8cc");
|
||||||
|
mainWindowController.setxPosHelper(0);
|
||||||
|
mainWindowController.saveSettings();
|
||||||
|
Runtime.getRuntime().exec("java -jar cemu_UI.jar"); //start again (preventing Bugs)
|
||||||
|
System.exit(0); //finishes itself
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pictureCache.exists() != true){
|
||||||
|
pictureCache.mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(gamesDBFile.exists() != true){
|
||||||
|
try {
|
||||||
|
System.out.print("downloading games.db... ");
|
||||||
|
URL website = new URL(gamesDBdownloadURL);
|
||||||
|
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
|
||||||
|
FileOutputStream fos = new FileOutputStream(gamesDBFile);
|
||||||
|
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||||
|
fos.close();
|
||||||
|
System.out.println("done!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO download games.db
|
//loading settings and initialize UI
|
||||||
mainWindowController.loadSettings();
|
mainWindowController.loadSettings();
|
||||||
|
|
||||||
mainWindowController.dbController.main();
|
mainWindowController.dbController.main();
|
||||||
mainWindowController.dbController.loadRoms();
|
|
||||||
|
|
||||||
mainWindowController.initActions();
|
mainWindowController.initActions();
|
||||||
mainWindowController.initUI();
|
mainWindowController.initUI();
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<AnchorPane prefHeight="600.0" prefWidth="892.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController">
|
<AnchorPane prefHeight="600.0" prefWidth="892.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController">
|
||||||
<children>
|
<children>
|
||||||
<ScrollPane fx:id="scrollPaneMain" fitToWidth="true" layoutY="38.0" prefHeight="562.0" prefWidth="893.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
|
<ScrollPane fx:id="scrollPaneMain" fitToWidth="true" layoutY="38.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
|
||||||
<content>
|
<content>
|
||||||
<AnchorPane fx:id="gamesAnchorPane">
|
<AnchorPane fx:id="gamesAnchorPane">
|
||||||
<padding>
|
<padding>
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
</padding></AnchorPane>
|
</padding></AnchorPane>
|
||||||
</content>
|
</content>
|
||||||
</ScrollPane>
|
</ScrollPane>
|
||||||
<HBox fx:id="topHBox" prefHeight="38.0" prefWidth="900.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<HBox fx:id="topHBox" prefHeight="38.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<children>
|
<children>
|
||||||
<JFXHamburger fx:id="menuHam" prefHeight="38.0" prefWidth="38.0" />
|
<JFXHamburger fx:id="menuHam" prefHeight="38.0" prefWidth="38.0" />
|
||||||
</children>
|
</children>
|
||||||
|
@ -54,10 +54,16 @@
|
||||||
<JFXColorPicker fx:id="colorPicker" layoutX="14.0" layoutY="89.0" onAction="#colorPickerAction" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="89.0" />
|
<JFXColorPicker fx:id="colorPicker" layoutX="14.0" layoutY="89.0" onAction="#colorPickerAction" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="89.0" />
|
||||||
<JFXToggleButton fx:id="fullscreenToggleBtn" layoutX="14.0" layoutY="125.0" onAction="#fullscreenToggleBtnAction" text="start game in fullscreen" />
|
<JFXToggleButton fx:id="fullscreenToggleBtn" layoutX="14.0" layoutY="125.0" onAction="#fullscreenToggleBtnAction" text="start game in fullscreen" />
|
||||||
</children></AnchorPane>
|
</children></AnchorPane>
|
||||||
<JFXButton fx:id="playBtn" buttonType="RAISED" layoutX="392.5" layoutY="555.0" onAction="#playBtnAction" prefHeight="38.0" prefWidth="100.0" ripplerFill="#c92a2a" text="play" visible="false" AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="392.5" AnchorPane.rightAnchor="392.5" AnchorPane.topAnchor="555.0">
|
<JFXButton fx:id="playBtn" buttonType="RAISED" maxHeight="38.0" maxWidth="100.0" onAction="#playBtnAction" ripplerFill="#c92a2a" text="play" visible="false" AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="396.0" AnchorPane.rightAnchor="396.0" AnchorPane.topAnchor="555.0">
|
||||||
<font>
|
<font>
|
||||||
<Font name="System Bold" size="14.0" />
|
<Font name="System Bold" size="14.0" />
|
||||||
</font>
|
</font>
|
||||||
</JFXButton>
|
</JFXButton>
|
||||||
|
<JFXButton fx:id="timePlayedBtn" buttonType="RAISED" layoutX="341.0" layoutY="588.0" onAction="#timePlayedBtnAction" prefHeight="32.0" prefWidth="100.0" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="516.5" AnchorPane.topAnchor="558.0">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="14.0" />
|
||||||
|
</font>
|
||||||
|
</JFXButton>
|
||||||
|
<JFXButton fx:id="lastTimePlayedBtn" buttonType="RAISED" maxHeight="32.0" onAction="#lastTimePlayedBtnAction" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="516.5" AnchorPane.topAnchor="558.0" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|
|
@ -9,6 +9,8 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -70,6 +72,12 @@ public class MainWindowController {
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton playBtn;
|
private JFXButton playBtn;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private JFXButton timePlayedBtn;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private JFXButton lastTimePlayedBtn;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXHamburger menuHam;
|
private JFXHamburger menuHam;
|
||||||
|
|
||||||
|
@ -109,6 +117,7 @@ public class MainWindowController {
|
||||||
private String romPath;
|
private String romPath;
|
||||||
private String gameExecutePath;
|
private String gameExecutePath;
|
||||||
private String selectedGameTitleID;
|
private String selectedGameTitleID;
|
||||||
|
private String selectedGameTitle;
|
||||||
private String color;
|
private String color;
|
||||||
private int xPos = -200;
|
private int xPos = -200;
|
||||||
private int yPos = 17;
|
private int yPos = 17;
|
||||||
|
@ -152,12 +161,13 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initActions() {
|
void initActions() {
|
||||||
System.out.println("initializing Actions ...");
|
System.out.print("initializing Actions... ");
|
||||||
|
|
||||||
HamburgerBackArrowBasicTransition burgerTask = new HamburgerBackArrowBasicTransition(menuHam);
|
HamburgerBackArrowBasicTransition burgerTask = new HamburgerBackArrowBasicTransition(menuHam);
|
||||||
menuHam.addEventHandler(MouseEvent.MOUSE_PRESSED, (e)->{
|
menuHam.addEventHandler(MouseEvent.MOUSE_PRESSED, (e)->{
|
||||||
if(playTrue){
|
if(playTrue){
|
||||||
playBtnSlideOut();
|
playBtnSlideOut();
|
||||||
|
lastTimePlayedBtnSlideOut();
|
||||||
}
|
}
|
||||||
if(menuTrue == false){
|
if(menuTrue == false){
|
||||||
sideMenuSlideIn();
|
sideMenuSlideIn();
|
||||||
|
@ -215,7 +225,6 @@ public class MainWindowController {
|
||||||
alert.showAndWait();
|
alert.showAndWait();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
System.out.println("remove TODO!");
|
|
||||||
int i = gameCover.indexOf((selectedEvent).getSource());
|
int i = gameCover.indexOf((selectedEvent).getSource());
|
||||||
gameVBox.remove(i);
|
gameVBox.remove(i);
|
||||||
gameCover.remove(i);
|
gameCover.remove(i);
|
||||||
|
@ -246,7 +255,7 @@ public class MainWindowController {
|
||||||
}else{
|
}else{
|
||||||
Alert updateAlert = new Alert(AlertType.CONFIRMATION); //new alert with file-chooser
|
Alert updateAlert = new Alert(AlertType.CONFIRMATION); //new alert with file-chooser
|
||||||
updateAlert.setTitle("cemu_UI");
|
updateAlert.setTitle("cemu_UI");
|
||||||
updateAlert.setHeaderText("add new Game");
|
updateAlert.setHeaderText("update "+selectedGameTitle);
|
||||||
updateAlert.setContentText("pleas select the update directory");
|
updateAlert.setContentText("pleas select the update directory");
|
||||||
updateAlert.initOwner(main.primaryStage);
|
updateAlert.initOwner(main.primaryStage);
|
||||||
|
|
||||||
|
@ -269,7 +278,11 @@ public class MainWindowController {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
System.out.println("copying files...");
|
System.out.println("copying files...");
|
||||||
FileUtils.copyDirectory(srcDir, destDir);
|
playBtn.setText("updating...");
|
||||||
|
playBtn.setDisable(true);
|
||||||
|
FileUtils.copyDirectory(srcDir, destDir); //TODO progress indicator
|
||||||
|
playBtn.setText("play");
|
||||||
|
playBtn.setDisable(false);
|
||||||
System.out.println("done!");
|
System.out.println("done!");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -293,6 +306,7 @@ public class MainWindowController {
|
||||||
public void handle(MouseEvent event) {
|
public void handle(MouseEvent event) {
|
||||||
if (playTrue) {
|
if (playTrue) {
|
||||||
playBtnSlideOut();
|
playBtnSlideOut();
|
||||||
|
lastTimePlayedBtnSlideOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -302,6 +316,7 @@ public class MainWindowController {
|
||||||
public void handle(MouseEvent event) {
|
public void handle(MouseEvent event) {
|
||||||
if (playTrue) {
|
if (playTrue) {
|
||||||
playBtnSlideOut();
|
playBtnSlideOut();
|
||||||
|
lastTimePlayedBtnSlideOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -327,6 +342,16 @@ public class MainWindowController {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void timePlayedBtnAction(ActionEvent event){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void lastTimePlayedBtnAction(ActionEvent event){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void settingsBtnAction(ActionEvent event) {
|
void settingsBtnAction(ActionEvent event) {
|
||||||
|
@ -346,7 +371,7 @@ public class MainWindowController {
|
||||||
Alert alert = new Alert(AlertType.INFORMATION);
|
Alert alert = new Alert(AlertType.INFORMATION);
|
||||||
alert.setTitle("about");
|
alert.setTitle("about");
|
||||||
alert.setHeaderText("cemu_UI");
|
alert.setHeaderText("cemu_UI");
|
||||||
alert.setContentText("cemu_UI by @Seil0 \npre release 0.0.1 \nwww.kellerkinder.xyz");
|
alert.setContentText("cemu_UI by @Seil0 \npre release 0.1.0 \nwww.kellerkinder.xyz");
|
||||||
alert.initOwner(main.primaryStage);
|
alert.initOwner(main.primaryStage);
|
||||||
alert.showAndWait();
|
alert.showAndWait();
|
||||||
}
|
}
|
||||||
|
@ -526,57 +551,68 @@ public class MainWindowController {
|
||||||
|
|
||||||
void addGame(String title, String coverPath, String romPath, String titleID){
|
void addGame(String title, String coverPath, String romPath, String titleID){
|
||||||
ImageView imageView = new ImageView(); //TODO abgerundete Kanten,
|
ImageView imageView = new ImageView(); //TODO abgerundete Kanten,
|
||||||
Label gameTitle = new Label(title);
|
Label gameTitleLabel = new Label(title);
|
||||||
File file = new File(coverPath);
|
File coverFile = new File(coverPath);
|
||||||
VBox VBox = new VBox();
|
VBox VBox = new VBox();
|
||||||
JFXButton gameBtn = new JFXButton();
|
JFXButton gameBtn = new JFXButton();
|
||||||
Image image = new Image(file.toURI().toString());
|
Image coverImage = new Image(coverFile.toURI().toString());
|
||||||
|
|
||||||
generatePosition();
|
generatePosition();
|
||||||
// System.out.println("Title: "+title+"; cover: "+coverPath+"; rom: "+romPath);
|
// System.out.println("Title: "+title+"; cover: "+coverPath+"; rom: "+romPath);
|
||||||
// System.out.println("X: "+getxPos()+"; Y: "+getyPos());
|
// System.out.println("X: "+getxPos()+"; Y: "+getyPos());
|
||||||
gameVBox.add(VBox);
|
gameVBox.add(VBox);
|
||||||
gameCover.add(gameBtn);
|
gameCover.add(gameBtn);
|
||||||
gameLabel.add(gameTitle);
|
gameLabel.add(gameTitleLabel);
|
||||||
gameTitle.setMaxWidth(200);
|
gameTitleLabel.setMaxWidth(200);
|
||||||
imageView.setImage(image);
|
imageView.setImage(coverImage);
|
||||||
imageView.setFitHeight(300);
|
imageView.setFitHeight(300);
|
||||||
imageView.setFitWidth(200);
|
imageView.setFitWidth(200);
|
||||||
gameBtn.setGraphic(imageView);
|
gameBtn.setGraphic(imageView);
|
||||||
gameBtn.setContextMenu(gameContextMenu);
|
gameBtn.setContextMenu(gameContextMenu);
|
||||||
// gameBtn.setOnAction(new EventHandler<ActionEvent>() {
|
|
||||||
// @Override
|
|
||||||
// public void handle(ActionEvent event) {
|
|
||||||
|
|
||||||
gameBtn.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
|
gameBtn.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(MouseEvent event) {
|
public void handle(MouseEvent event) {
|
||||||
|
|
||||||
System.out.println("selected: "+title+"; ID: "+titleID);
|
System.out.println("selected: "+title+"; ID: "+titleID);
|
||||||
|
|
||||||
gameExecutePath = romPath;
|
gameExecutePath = romPath;
|
||||||
selectedGameTitleID = titleID;
|
selectedGameTitleID = titleID;
|
||||||
|
selectedGameTitle = title;
|
||||||
selectedEvent = event;
|
selectedEvent = event;
|
||||||
|
|
||||||
lastGameLabel.setStyle("-fx-underline: false;");
|
lastGameLabel.setStyle("-fx-underline: false;");
|
||||||
gameLabel.get(gameCover.indexOf(event.getSource())).setStyle("-fx-underline: true;");
|
gameLabel.get(gameCover.indexOf(event.getSource())).setStyle("-fx-underline: true;");
|
||||||
lastGameLabel = gameLabel.get(gameCover.indexOf(event.getSource()));
|
lastGameLabel = gameLabel.get(gameCover.indexOf(event.getSource()));
|
||||||
System.out.println(dbController.getLastPlayed(titleID));
|
|
||||||
|
if(dbController.getLastPlayed(titleID).equals("") || dbController.getLastPlayed(titleID).equals(null)){
|
||||||
|
lastTimePlayedBtn.setText("Last played, never");
|
||||||
|
}else{
|
||||||
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
|
||||||
|
int localInt = Integer.parseInt(dtf.format(LocalDate.now()).replaceAll("-", ""));
|
||||||
|
int lastInt = Integer.parseInt(dbController.getLastPlayed(titleID).replaceAll("-", ""));
|
||||||
|
|
||||||
|
if(localInt == lastInt){
|
||||||
|
lastTimePlayedBtn.setText("Last played, today");
|
||||||
|
}else if(localInt-1 == lastInt){
|
||||||
|
lastTimePlayedBtn.setText("Last played, yesterday");
|
||||||
|
}else{
|
||||||
|
lastTimePlayedBtn.setText("Last played, "+dbController.getLastPlayed(titleID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(playTrue == false){
|
if(playTrue == false){
|
||||||
playBtnSlideIn(); //TODO anderes design(mehr details spielzeit, zuletzt gespielt, etc.)
|
playBtnSlideIn(); //TODO anderes design(mehr details spielzeit, etc.)
|
||||||
|
lastTimePlayedBtnSlideIn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
gameTitle.setFont(Font.font("System", FontWeight.BOLD, 14));
|
gameTitleLabel.setFont(Font.font("System", FontWeight.BOLD, 14));
|
||||||
VBox.getChildren().addAll(gameTitle,gameBtn);
|
VBox.getChildren().addAll(gameTitleLabel,gameBtn);
|
||||||
VBox.setLayoutX(getxPos());
|
VBox.setLayoutX(getxPos());
|
||||||
VBox.setLayoutY(getyPos());
|
VBox.setLayoutY(getyPos());
|
||||||
// gameVBox.setMouseTransparent(false);
|
|
||||||
|
|
||||||
gamesAnchorPane.getChildren().add(VBox);
|
gamesAnchorPane.getChildren().add(VBox);
|
||||||
|
|
||||||
// gamesAnchorPane.getChildren().add(gameBtn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -595,6 +631,7 @@ public class MainWindowController {
|
||||||
private void applyColor(){
|
private void applyColor(){
|
||||||
String style = "-fx-background-color: #"+getColor()+";";
|
String style = "-fx-background-color: #"+getColor()+";";
|
||||||
String btnStyleBlack = "-fx-button-type: RAISED; -fx-background-color: #"+getColor()+"; -fx-text-fill: BLACK;";
|
String btnStyleBlack = "-fx-button-type: RAISED; -fx-background-color: #"+getColor()+"; -fx-text-fill: BLACK;";
|
||||||
|
String timeBtnStyle = "-fx-button-type: RAISED; -fx-background-color: #ffffff; -fx-text-fill: BLACK;";
|
||||||
getColor();
|
getColor();
|
||||||
|
|
||||||
sideMenuVBox.setStyle(style);
|
sideMenuVBox.setStyle(style);
|
||||||
|
@ -609,10 +646,13 @@ public class MainWindowController {
|
||||||
romTFBtn.setStyle(btnStyleBlack);
|
romTFBtn.setStyle(btnStyleBlack);
|
||||||
aboutBtn.setStyle(btnStyleBlack);
|
aboutBtn.setStyle(btnStyleBlack);
|
||||||
playBtn.setStyle(btnStyleBlack);
|
playBtn.setStyle(btnStyleBlack);
|
||||||
|
|
||||||
|
lastTimePlayedBtn.setStyle(timeBtnStyle);
|
||||||
|
timePlayedBtn.setStyle(timeBtnStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveSettings(){
|
void saveSettings(){
|
||||||
System.out.println("saving Settings ...");
|
System.out.print("saving Settings... ");
|
||||||
OutputStream outputStream; //new output-stream
|
OutputStream outputStream; //new output-stream
|
||||||
try {
|
try {
|
||||||
props.setProperty("cemuPath", getCemuPath());
|
props.setProperty("cemuPath", getCemuPath());
|
||||||
|
@ -636,7 +676,7 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadSettings(){
|
void loadSettings(){
|
||||||
System.out.print("loading settings ...");
|
System.out.print("loading settings... ");
|
||||||
InputStream inputStream;
|
InputStream inputStream;
|
||||||
try {
|
try {
|
||||||
if(System.getProperty("os.name").equals("Linux")){
|
if(System.getProperty("os.name").equals("Linux")){
|
||||||
|
@ -709,6 +749,38 @@ public class MainWindowController {
|
||||||
translateTransition.play();
|
translateTransition.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private void timePlayedBtnSlideIn(){
|
||||||
|
timePlayedBtn.setVisible(true);
|
||||||
|
TranslateTransition translateTransition = new TranslateTransition(Duration.millis(300), timePlayedBtn);
|
||||||
|
translateTransition.setFromY(55);
|
||||||
|
translateTransition.setToY(0);
|
||||||
|
translateTransition.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private void timePlayedBtnSlideOut(){
|
||||||
|
TranslateTransition translateTransition = new TranslateTransition(Duration.millis(300), timePlayedBtn);
|
||||||
|
translateTransition.setFromY(0);
|
||||||
|
translateTransition.setToY(56);
|
||||||
|
translateTransition.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lastTimePlayedBtnSlideIn(){
|
||||||
|
lastTimePlayedBtn.setVisible(true);
|
||||||
|
TranslateTransition translateTransition = new TranslateTransition(Duration.millis(300), lastTimePlayedBtn);
|
||||||
|
translateTransition.setFromY(55);
|
||||||
|
translateTransition.setToY(0);
|
||||||
|
translateTransition.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lastTimePlayedBtnSlideOut(){
|
||||||
|
TranslateTransition translateTransition = new TranslateTransition(Duration.millis(300), lastTimePlayedBtn);
|
||||||
|
translateTransition.setFromY(0);
|
||||||
|
translateTransition.setToY(56);
|
||||||
|
translateTransition.play();
|
||||||
|
}
|
||||||
|
|
||||||
private void editColor(String input){
|
private void editColor(String input){
|
||||||
StringBuilder sb = new StringBuilder(input);
|
StringBuilder sb = new StringBuilder(input);
|
||||||
sb.delete(0, 2);
|
sb.delete(0, 2);
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class dbController {
|
||||||
loadGamesDatabase();
|
loadGamesDatabase();
|
||||||
createRomDatabase();
|
createRomDatabase();
|
||||||
loadRomDirectory(mainWindowController.getRomPath());
|
loadRomDirectory(mainWindowController.getRomPath());
|
||||||
|
loadRoms();
|
||||||
checkRemoveEntry();
|
checkRemoveEntry();
|
||||||
System.out.println("<==========finished loading sql==========>");
|
System.out.println("<==========finished loading sql==========>");
|
||||||
}
|
}
|
||||||
|
@ -57,7 +58,7 @@ public class dbController {
|
||||||
// if the error message is "out of memory", it probably means no database file is found
|
// if the error message is "out of memory", it probably means no database file is found
|
||||||
System.err.println(e.getMessage());
|
System.err.println(e.getMessage());
|
||||||
}
|
}
|
||||||
System.out.println("rom database loaded to driver manager");
|
System.out.println("rom database loaded successfull");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue