first commit
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="src/libraries/jfoenix-1.2.0.jar"/>
|
||||
<classpathentry kind="lib" path="src/libraries/sqlite-jdbc-3.16.1.jar"/>
|
||||
<classpathentry kind="lib" path="src/libraries/commons-io-2.5.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>cemu_UI</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,11 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import com.jfoenix.controls.JFXButton?>
|
||||
<?import com.jfoenix.controls.JFXColorPicker?>
|
||||
<?import com.jfoenix.controls.JFXHamburger?>
|
||||
<?import com.jfoenix.controls.JFXTextField?>
|
||||
<?import com.jfoenix.controls.JFXToggleButton?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<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>
|
||||
<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">
|
||||
<content>
|
||||
<AnchorPane fx:id="gamesAnchorPane">
|
||||
<padding>
|
||||
<Insets bottom="17.0" />
|
||||
</padding></AnchorPane>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<HBox fx:id="topHBox" prefHeight="38.0" prefWidth="900.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<JFXHamburger fx:id="menuHam" prefHeight="38.0" prefWidth="38.0" />
|
||||
</children>
|
||||
</HBox>
|
||||
<VBox fx:id="sideMenuVBox" layoutY="32.0" prefHeight="568.0" prefWidth="150.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="38.0">
|
||||
<children>
|
||||
<JFXButton fx:id="aboutBtn" onAction="#aboutBtnAction" prefHeight="38.0" prefWidth="150.0" text="About" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font name="System Bold" size="14.0" />
|
||||
</font>
|
||||
</JFXButton>
|
||||
<JFXButton fx:id="settingsBtn" onAction="#settingsBtnAction" prefHeight="38.0" prefWidth="150.0" text="Settings" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font name="System Bold" size="14.0" />
|
||||
</font></JFXButton>
|
||||
<JFXButton fx:id="addBtn" onAction="#addBtnAction" prefHeight="38.0" prefWidth="150.0" text="Add new Game" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font name="System Bold" size="14.0" />
|
||||
</font>
|
||||
</JFXButton>
|
||||
</children>
|
||||
</VBox>
|
||||
<AnchorPane fx:id="settingsAnchorPane" layoutX="38.0" layoutY="27.0" prefHeight="573.0" prefWidth="862.0" style="-fx-background-color: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
|
||||
<children>
|
||||
<JFXTextField fx:id="cemuTextField" layoutX="14.0" layoutY="14.0" maxWidth="305.0" minWidth="305.0" onAction="#cemuTextFieldAction" prefHeight="31.0" prefWidth="305.0" promptText="cemu directory" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="14.0" />
|
||||
<JFXTextField fx:id="romTextField" layoutX="14.0" layoutY="50.0" maxWidth="305.0" minWidth="305.0" onAction="#romTextFieldAction" prefHeight="31.0" prefWidth="305.0" promptText="rom directory" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="50.0" />
|
||||
<JFXButton fx:id="romTFBtn" layoutX="333.0" layoutY="50.0" onAction="#romTFBtnAction" prefHeight="31.0" prefWidth="108.0" text="choose directory" AnchorPane.leftAnchor="333.0" AnchorPane.topAnchor="50.0" />
|
||||
<JFXButton fx:id="cemuTFBtn" layoutX="333.0" layoutY="14.0" onAction="#cemuTFBtnAction" prefHeight="31.0" prefWidth="108.0" text="choose directory" AnchorPane.leftAnchor="333.0" AnchorPane.topAnchor="14.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" />
|
||||
</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">
|
||||
<font>
|
||||
<Font name="System Bold" size="14.0" />
|
||||
</font>
|
||||
</JFXButton>
|
||||
</children>
|
||||
</AnchorPane>
|
|
@ -0,0 +1 @@
|
|||
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
|
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 15 KiB |
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="ASCII"?>
|
||||
<anttasks:AntTask xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:anttasks="http://org.eclipse.fx.ide.jdt/1.0" buildDirectory="${project}/build">
|
||||
<deploy>
|
||||
<application name="cemu_UI"/>
|
||||
<info/>
|
||||
</deploy>
|
||||
<signjar/>
|
||||
</anttasks:AntTask>
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
|
||||
<properties>
|
||||
<comment>cemu_UI_games</comment>
|
||||
<entry key="yPos">10</entry>
|
||||
<entry key="coverAction0">aD:\Sonstiges\ROM's\wii u\Mario Kart 8\code\Turbo.rpx</entry>
|
||||
<entry key="color">ee3523</entry>
|
||||
<entry key="xPos">-200</entry>
|
||||
<entry key="cemuPath">C:\Users\Jannik\Documents\cemu_1.7.2\Cemu.exe</entry>
|
||||
<entry key="romPath">D:\Sonstiges\ROM's\wii u</entry>
|
||||
<entry key="xPosHelper">0</entry>
|
||||
<entry key="coverPath0">C:\Users\Jannik\Desktop\AMKE01.png</entry>
|
||||
<entry key="size">1</entry>
|
||||
</properties>
|
|
@ -0,0 +1,136 @@
|
|||
package application;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
|
||||
|
||||
public class Main extends Application {
|
||||
|
||||
Stage primaryStage;
|
||||
private MainWindowController mainWindowController;
|
||||
private File dirWin = new File(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 File fileWin = new File(dirWin + "/config.xml"); //Windows: C:/Users/"User"/Documents/HomeFlix/config.xml
|
||||
private File fileLinux = new File(dirLinux + "/config.xml"); //Linux: /home/"User"/HomeFlix/config.xml
|
||||
private File pictureCacheWin = new File(dirWin+"/picture_cache");
|
||||
private File pictureCacheLinux = new File(dirLinux+"/picture_cache");
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
this.primaryStage = primaryStage;
|
||||
mainWindow();
|
||||
}
|
||||
|
||||
private void mainWindow(){
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(Main.class.getResource("MainWindow.fxml"));
|
||||
AnchorPane pane = loader.load();
|
||||
primaryStage.setMinHeight(600.00);
|
||||
primaryStage.setMinWidth(900.00);
|
||||
primaryStage.setResizable(false);
|
||||
primaryStage.setTitle("cemu_UI");
|
||||
// primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("/recources/Homeflix_Icon_64x64.png"))); //adds application icon
|
||||
|
||||
mainWindowController = loader.getController(); //Link of FXMLController and controller class
|
||||
mainWindowController.setMain(this); //call setMain
|
||||
|
||||
//Linux if directory exists -> check config.xml
|
||||
if(System.getProperty("os.name").equals("Linux")){
|
||||
if(dirLinux.exists() != true){
|
||||
dirLinux.mkdir();
|
||||
pictureCacheLinux.mkdir();
|
||||
}else if(fileLinux.exists() != true){
|
||||
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(pictureCacheLinux.exists() != true){
|
||||
pictureCacheLinux.mkdir();
|
||||
}
|
||||
//windows
|
||||
}else{
|
||||
if(dirWin.exists() != true){
|
||||
dirWin.mkdir();
|
||||
pictureCacheWin.mkdir();
|
||||
}else if(fileWin.exists() != true){
|
||||
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(pictureCacheWin.exists() != true){
|
||||
pictureCacheWin.mkdir();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO download games.db
|
||||
mainWindowController.loadSettings();
|
||||
|
||||
mainWindowController.dbController.main();
|
||||
mainWindowController.dbController.loadRoms();
|
||||
|
||||
mainWindowController.initActions();
|
||||
mainWindowController.initUI();
|
||||
|
||||
Scene scene = new Scene(pane); //create new scene, append pane to scene
|
||||
|
||||
primaryStage.setScene(scene); //append scene to stage
|
||||
primaryStage.show(); //show stage
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void firstStart(){
|
||||
Alert alert = new Alert(AlertType.CONFIRMATION); //new alert with file-chooser
|
||||
alert.setTitle("cemu_UI");
|
||||
alert.setHeaderText("cemu installation");
|
||||
alert.setContentText("pleas select your cemu installation");
|
||||
|
||||
Optional<ButtonType> result = alert.showAndWait();
|
||||
if (result.get() == ButtonType.OK){
|
||||
DirectoryChooser directoryChooser = new DirectoryChooser();
|
||||
File selectedDirectory = directoryChooser.showDialog(primaryStage);
|
||||
mainWindowController.setCemuPath(selectedDirectory.getAbsolutePath());
|
||||
|
||||
} else {
|
||||
mainWindowController.setCemuPath(null);
|
||||
}
|
||||
|
||||
Alert alert2 = new Alert(AlertType.CONFIRMATION); //new alert with file-chooser
|
||||
alert2.setTitle("cemu_UI");
|
||||
alert2.setHeaderText("rom directory");
|
||||
alert2.setContentText("pleas select your rom directory");
|
||||
|
||||
Optional<ButtonType> result2 = alert2.showAndWait();
|
||||
if (result2.get() == ButtonType.OK){
|
||||
DirectoryChooser directoryChooser = new DirectoryChooser();
|
||||
File selectedDirectory = directoryChooser.showDialog(primaryStage);
|
||||
mainWindowController.setRomPath(selectedDirectory.getAbsolutePath());
|
||||
|
||||
} else {
|
||||
mainWindowController.setRomPath(null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import com.jfoenix.controls.JFXButton?>
|
||||
<?import com.jfoenix.controls.JFXColorPicker?>
|
||||
<?import com.jfoenix.controls.JFXHamburger?>
|
||||
<?import com.jfoenix.controls.JFXTextField?>
|
||||
<?import com.jfoenix.controls.JFXToggleButton?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<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>
|
||||
<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">
|
||||
<content>
|
||||
<AnchorPane fx:id="gamesAnchorPane">
|
||||
<padding>
|
||||
<Insets bottom="17.0" />
|
||||
</padding></AnchorPane>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<HBox fx:id="topHBox" prefHeight="38.0" prefWidth="900.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<JFXHamburger fx:id="menuHam" prefHeight="38.0" prefWidth="38.0" />
|
||||
</children>
|
||||
</HBox>
|
||||
<VBox fx:id="sideMenuVBox" layoutY="32.0" prefHeight="568.0" prefWidth="150.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="38.0">
|
||||
<children>
|
||||
<JFXButton fx:id="aboutBtn" onAction="#aboutBtnAction" prefHeight="38.0" prefWidth="150.0" text="About" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font name="System Bold" size="14.0" />
|
||||
</font>
|
||||
</JFXButton>
|
||||
<JFXButton fx:id="settingsBtn" onAction="#settingsBtnAction" prefHeight="38.0" prefWidth="150.0" text="Settings" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font name="System Bold" size="14.0" />
|
||||
</font></JFXButton>
|
||||
<JFXButton fx:id="addBtn" onAction="#addBtnAction" prefHeight="38.0" prefWidth="150.0" text="Add new Game" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font name="System Bold" size="14.0" />
|
||||
</font>
|
||||
</JFXButton>
|
||||
</children>
|
||||
</VBox>
|
||||
<AnchorPane fx:id="settingsAnchorPane" layoutX="38.0" layoutY="27.0" prefHeight="573.0" prefWidth="862.0" style="-fx-background-color: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
|
||||
<children>
|
||||
<JFXTextField fx:id="cemuTextField" layoutX="14.0" layoutY="14.0" maxWidth="305.0" minWidth="305.0" onAction="#cemuTextFieldAction" prefHeight="31.0" prefWidth="305.0" promptText="cemu directory" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="14.0" />
|
||||
<JFXTextField fx:id="romTextField" layoutX="14.0" layoutY="50.0" maxWidth="305.0" minWidth="305.0" onAction="#romTextFieldAction" prefHeight="31.0" prefWidth="305.0" promptText="rom directory" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="50.0" />
|
||||
<JFXButton fx:id="romTFBtn" layoutX="333.0" layoutY="50.0" onAction="#romTFBtnAction" prefHeight="31.0" prefWidth="108.0" text="choose directory" AnchorPane.leftAnchor="333.0" AnchorPane.topAnchor="50.0" />
|
||||
<JFXButton fx:id="cemuTFBtn" layoutX="333.0" layoutY="14.0" onAction="#cemuTFBtnAction" prefHeight="31.0" prefWidth="108.0" text="choose directory" AnchorPane.leftAnchor="333.0" AnchorPane.topAnchor="14.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" />
|
||||
</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">
|
||||
<font>
|
||||
<Font name="System Bold" size="14.0" />
|
||||
</font>
|
||||
</JFXButton>
|
||||
</children>
|
||||
</AnchorPane>
|
|
@ -0,0 +1,784 @@
|
|||
package application;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXColorPicker;
|
||||
import com.jfoenix.controls.JFXHamburger;
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
import com.jfoenix.controls.JFXToggleButton;
|
||||
import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.ContextMenu;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.TextInputDialog;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.scene.text.FontWeight;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class MainWindowController {
|
||||
|
||||
@FXML
|
||||
private JFXButton aboutBtn;
|
||||
|
||||
@FXML
|
||||
private JFXButton settingsBtn;
|
||||
|
||||
@FXML
|
||||
private JFXButton addBtn;
|
||||
|
||||
@FXML
|
||||
private JFXButton cemuTFBtn;
|
||||
|
||||
@FXML
|
||||
private JFXButton romTFBtn;
|
||||
|
||||
@FXML
|
||||
private JFXButton playBtn;
|
||||
|
||||
@FXML
|
||||
private JFXHamburger menuHam;
|
||||
|
||||
@FXML
|
||||
private JFXTextField cemuTextField;
|
||||
|
||||
@FXML
|
||||
private JFXTextField romTextField;
|
||||
|
||||
@FXML
|
||||
private JFXColorPicker colorPicker;
|
||||
|
||||
@FXML
|
||||
private JFXToggleButton fullscreenToggleBtn;
|
||||
|
||||
@FXML
|
||||
private AnchorPane settingsAnchorPane;
|
||||
|
||||
@FXML
|
||||
private AnchorPane gamesAnchorPane;
|
||||
|
||||
@FXML
|
||||
private ScrollPane scrollPaneMain;
|
||||
|
||||
@FXML
|
||||
private VBox sideMenuVBox;
|
||||
|
||||
@FXML
|
||||
private HBox topHBox;
|
||||
|
||||
private Main main;
|
||||
private boolean menuTrue = false;
|
||||
private boolean settingsTrue = false;
|
||||
private boolean playTrue = false;
|
||||
private boolean fullscreen;
|
||||
private String cemuPath;
|
||||
private String romPath;
|
||||
private String gameExecutePath;
|
||||
private String selectedGameTitleID;
|
||||
private String color;
|
||||
private int xPos = -200;
|
||||
private int yPos = 17;
|
||||
private int xPosHelper;
|
||||
private FileChooser fileChooser = new FileChooser();
|
||||
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");
|
||||
private File fileWin = new File(dirWin + "/config.xml");
|
||||
private File fileLinux = new File(dirLinux + "/config.xml");
|
||||
File pictureCacheWin = new File(dirWin+"/picture_cache");
|
||||
File pictureCacheLinux = new File(dirLinux+"/picture_cache");
|
||||
private ArrayList<JFXButton> gameCover = new ArrayList<JFXButton>();
|
||||
private ArrayList<Label> gameLabel = new ArrayList<Label>();
|
||||
private ArrayList<VBox> gameVBox = new ArrayList<VBox>();
|
||||
Properties props = new Properties();
|
||||
Properties gameProps = new Properties();
|
||||
private MenuItem edit = new MenuItem("edit");
|
||||
private MenuItem remove = new MenuItem("remove");
|
||||
private MenuItem update = new MenuItem("update");
|
||||
private MenuItem addDLC = new MenuItem("add DLC");
|
||||
private ContextMenu gameContextMenu = new ContextMenu(edit, remove, update, addDLC);
|
||||
private MouseEvent selectedEvent;
|
||||
|
||||
private Label lastGameLabel = new Label();
|
||||
|
||||
dbController dbController;
|
||||
|
||||
public void setMain(Main main) {
|
||||
this.main = main;
|
||||
dbController = new dbController(this);
|
||||
}
|
||||
|
||||
void initUI(){
|
||||
cemuTextField.setText(cemuPath);
|
||||
romTextField.setText(romPath);
|
||||
colorPicker.setValue(Color.valueOf(getColor()));
|
||||
fullscreenToggleBtn.setSelected(isFullscreen());
|
||||
addDLC.setDisable(true);
|
||||
applyColor();
|
||||
}
|
||||
|
||||
void initActions() {
|
||||
System.out.println("initializing Actions ...");
|
||||
|
||||
HamburgerBackArrowBasicTransition burgerTask = new HamburgerBackArrowBasicTransition(menuHam);
|
||||
menuHam.addEventHandler(MouseEvent.MOUSE_PRESSED, (e)->{
|
||||
if(playTrue){
|
||||
playBtnSlideOut();
|
||||
}
|
||||
if(menuTrue == false){
|
||||
sideMenuSlideIn();
|
||||
burgerTask.setRate(1.0);
|
||||
burgerTask.play();
|
||||
menuTrue = true;
|
||||
}else{
|
||||
sideMenuSlideOut();
|
||||
burgerTask.setRate(-1.0);
|
||||
burgerTask.play();
|
||||
menuTrue = false;
|
||||
}
|
||||
if(settingsTrue == true){
|
||||
settingsAnchorPane.setVisible(false);
|
||||
// setPath(tfPath.getText());
|
||||
saveSettings();
|
||||
settingsTrue = false;
|
||||
}
|
||||
});
|
||||
|
||||
edit.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
System.out.println("edit "+selectedGameTitleID);
|
||||
if(selectedGameTitleID == null){
|
||||
System.out.println("trying to edit null! null is not valid!");
|
||||
Alert alert = new Alert(AlertType.WARNING);
|
||||
alert.setTitle("edit");
|
||||
alert.setHeaderText("cemu_UI");
|
||||
alert.setContentText("please select a game, \""+selectedGameTitleID+"\" is not a valid type");
|
||||
alert.initOwner(main.primaryStage);
|
||||
alert.showAndWait();
|
||||
}else{
|
||||
System.out.println("show edit window TODO!");
|
||||
double i = 13;
|
||||
double j = 4;
|
||||
i = i/j;
|
||||
System.out.println(Math.ceil(i)); //aufrunden
|
||||
System.out.println(Math.floor(i)); //abrunden
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
remove.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
System.out.println("remove "+selectedGameTitleID);
|
||||
if(selectedGameTitleID == null){
|
||||
System.out.println("trying to remove null! null is not valid!");
|
||||
Alert alert = new Alert(AlertType.WARNING);
|
||||
alert.setTitle("remove");
|
||||
alert.setHeaderText("cemu_UI");
|
||||
alert.setContentText("please select a game, \""+selectedGameTitleID+"\" is not a valid type");
|
||||
alert.initOwner(main.primaryStage);
|
||||
alert.showAndWait();
|
||||
}
|
||||
else{
|
||||
System.out.println("remove TODO!");
|
||||
int i = gameCover.indexOf((selectedEvent).getSource());
|
||||
gameVBox.remove(i);
|
||||
gameCover.remove(i);
|
||||
gameLabel.remove(i);
|
||||
// dbController.removeRom(selectedGameTitleID);
|
||||
//TODO nachrück animation
|
||||
// platz(i)/4 -> aufrunden = Reihe; plath(i)-(platz(i)/4 -> abrunden*4)
|
||||
// jetzt haben wir den platz des gelöschten elements und lönnen alle nachfolgenden nachrücken
|
||||
gamesAnchorPane.getChildren().remove(i);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
update.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
String titleID = selectedGameTitleID;
|
||||
String updatePath;
|
||||
System.out.println("update: "+selectedGameTitleID);
|
||||
if(selectedGameTitleID == null){
|
||||
System.out.println("trying to update null! null is not valid!");
|
||||
Alert alert = new Alert(AlertType.WARNING);
|
||||
alert.setTitle("edit");
|
||||
alert.setHeaderText("cemu_UI");
|
||||
alert.setContentText("please select a game, \""+selectedGameTitleID+"\" is not a valid type");
|
||||
alert.initOwner(main.primaryStage);
|
||||
alert.showAndWait();
|
||||
}else{
|
||||
Alert updateAlert = new Alert(AlertType.CONFIRMATION); //new alert with file-chooser
|
||||
updateAlert.setTitle("cemu_UI");
|
||||
updateAlert.setHeaderText("add new Game");
|
||||
updateAlert.setContentText("pleas select the update directory");
|
||||
updateAlert.initOwner(main.primaryStage);
|
||||
|
||||
Optional<ButtonType> result = updateAlert.showAndWait();
|
||||
if (result.get() == ButtonType.OK){
|
||||
DirectoryChooser directoryChooser = new DirectoryChooser();
|
||||
File selectedDirecroty = directoryChooser.showDialog(main.primaryStage);
|
||||
updatePath = selectedDirecroty.getAbsolutePath();
|
||||
String[] parts = titleID.split("-"); //split string into 2 parts at "-"
|
||||
|
||||
File srcDir = new File(updatePath);
|
||||
File destDir = new File(cemuPath+"\\mlc01\\usr\\title\\"+parts[0]+"\\"+parts[1]);
|
||||
|
||||
System.out.println(updatePath);
|
||||
System.out.println(destDir.toString());
|
||||
|
||||
if(destDir.exists() != true){
|
||||
destDir.mkdir();
|
||||
}
|
||||
|
||||
try {
|
||||
System.out.println("copying files...");
|
||||
FileUtils.copyDirectory(srcDir, destDir);
|
||||
System.out.println("done!");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
updatePath = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
addDLC.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
System.out.println("add DLC");
|
||||
}
|
||||
});
|
||||
|
||||
gamesAnchorPane.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
|
||||
@Override
|
||||
public void handle(MouseEvent event) {
|
||||
if (playTrue) {
|
||||
playBtnSlideOut();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
topHBox.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
|
||||
@Override
|
||||
public void handle(MouseEvent event) {
|
||||
if (playTrue) {
|
||||
playBtnSlideOut();
|
||||
}
|
||||
}
|
||||
});
|
||||
System.out.println("done!");
|
||||
}
|
||||
|
||||
@FXML
|
||||
void detailsSlideoutBtnAction(ActionEvent event){
|
||||
playBtnSlideOut();
|
||||
}
|
||||
|
||||
@FXML
|
||||
void playBtnAction(ActionEvent event){
|
||||
dbController.setLastPlayed(selectedGameTitleID);
|
||||
try{
|
||||
if(fullscreen){
|
||||
Runtime.getRuntime().exec(getCemuPath()+"\\Cemu.exe -f -g \""+gameExecutePath+"\"");
|
||||
}else{
|
||||
Runtime.getRuntime().exec(getCemuPath()+"\\Cemu.exe -g \""+gameExecutePath+"\"");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
//Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
void settingsBtnAction(ActionEvent event) {
|
||||
if(settingsTrue == false){
|
||||
settingsAnchorPane.setVisible(true);
|
||||
settingsTrue = true;
|
||||
}else{
|
||||
settingsAnchorPane.setVisible(false);
|
||||
saveSettings();
|
||||
settingsTrue = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
void aboutBtnAction(){
|
||||
Alert alert = new Alert(AlertType.INFORMATION);
|
||||
alert.setTitle("about");
|
||||
alert.setHeaderText("cemu_UI");
|
||||
alert.setContentText("cemu_UI by @Seil0 \npre release 0.0.1 \nwww.kellerkinder.xyz");
|
||||
alert.initOwner(main.primaryStage);
|
||||
alert.showAndWait();
|
||||
}
|
||||
|
||||
@FXML
|
||||
void cemuTFBtnAction(ActionEvent event) {
|
||||
File cemuDirectory = fileChooser.showOpenDialog(main.primaryStage);
|
||||
if(cemuDirectory == null){
|
||||
System.out.println("No Directory selected");
|
||||
}else{
|
||||
setCemuPath(cemuDirectory.getAbsolutePath());
|
||||
saveSettings();
|
||||
cemuTextField.setText(getCemuPath());
|
||||
try {
|
||||
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again
|
||||
System.exit(0); //finishes itself
|
||||
} catch (IOException e) {
|
||||
System.out.println("es ist ein Fehler aufgetreten");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
void romTFBtnAction(ActionEvent event) {
|
||||
File romDirectory = directoryChooser.showDialog(main.primaryStage);
|
||||
if(romDirectory == null){
|
||||
System.out.println("No Directory selected");
|
||||
}else{
|
||||
setRomPath(romDirectory.getAbsolutePath());
|
||||
saveSettings();
|
||||
cemuTextField.setText(getCemuPath());
|
||||
try {
|
||||
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again
|
||||
System.exit(0); //finishes itself
|
||||
} catch (IOException e) {
|
||||
System.out.println("es ist ein Fehler aufgetreten");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
void cemuTextFieldAction(ActionEvent event){
|
||||
setCemuPath(cemuTextField.getText());
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
@FXML
|
||||
void romTextFieldAction(ActionEvent event){
|
||||
setRomPath(romTextField.getText());
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
@FXML
|
||||
void fullscreenToggleBtnAction(ActionEvent event){
|
||||
if(fullscreen){
|
||||
fullscreen = false;
|
||||
}else{
|
||||
fullscreen = true;
|
||||
}
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
@FXML
|
||||
void colorPickerAction(ActionEvent event){
|
||||
editColor(colorPicker.getValue().toString());
|
||||
applyColor();
|
||||
}
|
||||
|
||||
@FXML
|
||||
void addBtnAction(ActionEvent event){
|
||||
String romPath = null;
|
||||
String coverPath = null;
|
||||
String coverName = null;
|
||||
String title = null;
|
||||
String titleID = null;
|
||||
File pictureCache;
|
||||
boolean exit = false;
|
||||
|
||||
TextInputDialog titleDialog = new TextInputDialog();
|
||||
titleDialog.setTitle("cemu_UI");
|
||||
titleDialog.setHeaderText("add new Game");
|
||||
titleDialog.setContentText("Please enter the name of the game you want to add:");
|
||||
titleDialog.initOwner(main.primaryStage);
|
||||
|
||||
Optional<String> titleResult = titleDialog.showAndWait();
|
||||
if (titleResult.isPresent()){
|
||||
title = titleResult.get();
|
||||
}else{
|
||||
exit = true;
|
||||
}
|
||||
|
||||
TextInputDialog titleIDDialog = new TextInputDialog();
|
||||
titleIDDialog.setTitle("cemu_UI");
|
||||
titleIDDialog.setHeaderText("add new Game");
|
||||
titleIDDialog.setContentText("Please enter the title-ID (12345678-12345678) \nof the game you want to add:");
|
||||
titleIDDialog.initOwner(main.primaryStage);
|
||||
|
||||
Optional<String> titleIDResult = titleIDDialog.showAndWait();
|
||||
if (titleIDResult.isPresent()){
|
||||
titleID = titleIDResult.get();
|
||||
}else{
|
||||
exit = true;
|
||||
}
|
||||
|
||||
|
||||
if(exit == false){
|
||||
Alert romAlert = new Alert(AlertType.CONFIRMATION); //new alert with file-chooser
|
||||
romAlert.setTitle("cemu_UI");
|
||||
romAlert.setHeaderText("add new Game");
|
||||
romAlert.setContentText("pleas select the .rpx file from the Game you whish to add");
|
||||
romAlert.initOwner(main.primaryStage);
|
||||
|
||||
Optional<ButtonType> result = romAlert.showAndWait();
|
||||
if (result.get() == ButtonType.OK){
|
||||
FileChooser directoryChooser = new FileChooser();
|
||||
File selectedDirectory = directoryChooser.showOpenDialog(main.primaryStage);
|
||||
romPath = selectedDirectory.getAbsolutePath();
|
||||
} else {
|
||||
exit = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(exit == false){
|
||||
Alert coverAlert = new Alert(AlertType.CONFIRMATION); //new alert with file-chooser
|
||||
coverAlert.setTitle("cemu_UI");
|
||||
coverAlert.setHeaderText("add new Game");
|
||||
coverAlert.setContentText("pleas select the cover for the Game you whish to add");
|
||||
coverAlert.initOwner(main.primaryStage);
|
||||
|
||||
Optional<ButtonType> coverResult = coverAlert.showAndWait();
|
||||
if (coverResult.get() == ButtonType.OK){
|
||||
FileChooser directoryChooser = new FileChooser();
|
||||
File selectedDirectory = directoryChooser.showOpenDialog(main.primaryStage);
|
||||
coverPath = selectedDirectory.getAbsolutePath();
|
||||
} else {
|
||||
exit = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if exit == true then don't add a rom
|
||||
* else convert the cover to .png add copy it into the picture cache
|
||||
* then add the rom to the local_roms database
|
||||
*/
|
||||
if(exit){
|
||||
System.out.println("No parameter set!");
|
||||
}else{
|
||||
coverName = new File(coverPath).getName();
|
||||
try {
|
||||
if(System.getProperty("os.name").equals("Linux")){
|
||||
pictureCache = pictureCacheLinux;
|
||||
}else{
|
||||
pictureCache = pictureCacheWin;
|
||||
}
|
||||
|
||||
BufferedImage originalImage = ImageIO.read(new File(coverPath));//change path to where file is located
|
||||
int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType();
|
||||
BufferedImage resizeImagePNG = resizeImage(originalImage, type, 400, 600);
|
||||
ImageIO.write(resizeImagePNG, "png", new File(pictureCache+"\\"+coverName)); //change path where you want it saved
|
||||
coverPath = pictureCache+"\\"+coverName;
|
||||
} catch (IOException e) {
|
||||
System.out.println("Ops something went wrong!");
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
dbController.addRom(title, coverPath, romPath, titleID, "", "", "", "");
|
||||
dbController.loadSingleRom(titleID);
|
||||
} catch (SQLException e) {
|
||||
// Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void addGame(String title, String coverPath, String romPath, String titleID){
|
||||
ImageView imageView = new ImageView(); //TODO abgerundete Kanten,
|
||||
Label gameTitle = new Label(title);
|
||||
File file = new File(coverPath);
|
||||
VBox VBox = new VBox();
|
||||
JFXButton gameBtn = new JFXButton();
|
||||
Image image = new Image(file.toURI().toString());
|
||||
|
||||
generatePosition();
|
||||
// System.out.println("Title: "+title+"; cover: "+coverPath+"; rom: "+romPath);
|
||||
// System.out.println("X: "+getxPos()+"; Y: "+getyPos());
|
||||
gameVBox.add(VBox);
|
||||
gameCover.add(gameBtn);
|
||||
gameLabel.add(gameTitle);
|
||||
gameTitle.setMaxWidth(200);
|
||||
imageView.setImage(image);
|
||||
imageView.setFitHeight(300);
|
||||
imageView.setFitWidth(200);
|
||||
gameBtn.setGraphic(imageView);
|
||||
gameBtn.setContextMenu(gameContextMenu);
|
||||
// gameBtn.setOnAction(new EventHandler<ActionEvent>() {
|
||||
// @Override
|
||||
// public void handle(ActionEvent event) {
|
||||
|
||||
gameBtn.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
|
||||
@Override
|
||||
public void handle(MouseEvent event) {
|
||||
|
||||
System.out.println("selected: "+title+"; ID: "+titleID);
|
||||
gameExecutePath = romPath;
|
||||
selectedGameTitleID = titleID;
|
||||
selectedEvent = event;
|
||||
|
||||
lastGameLabel.setStyle("-fx-underline: false;");
|
||||
gameLabel.get(gameCover.indexOf(event.getSource())).setStyle("-fx-underline: true;");
|
||||
lastGameLabel = gameLabel.get(gameCover.indexOf(event.getSource()));
|
||||
System.out.println(dbController.getLastPlayed(titleID));
|
||||
|
||||
if(playTrue == false){
|
||||
playBtnSlideIn(); //TODO anderes design(mehr details spielzeit, zuletzt gespielt, etc.)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
gameTitle.setFont(Font.font("System", FontWeight.BOLD, 14));
|
||||
VBox.getChildren().addAll(gameTitle,gameBtn);
|
||||
VBox.setLayoutX(getxPos());
|
||||
VBox.setLayoutY(getyPos());
|
||||
// gameVBox.setMouseTransparent(false);
|
||||
|
||||
gamesAnchorPane.getChildren().add(VBox);
|
||||
|
||||
// gamesAnchorPane.getChildren().add(gameBtn);
|
||||
}
|
||||
|
||||
|
||||
private void generatePosition(){
|
||||
|
||||
if(xPosHelper == 4){
|
||||
xPos = 17;
|
||||
yPos = yPos + 345;
|
||||
xPosHelper = 1;
|
||||
}else{
|
||||
xPos = xPos + 217;
|
||||
xPosHelper++;
|
||||
}
|
||||
}
|
||||
|
||||
private void applyColor(){
|
||||
String style = "-fx-background-color: #"+getColor()+";";
|
||||
String btnStyleBlack = "-fx-button-type: RAISED; -fx-background-color: #"+getColor()+"; -fx-text-fill: BLACK;";
|
||||
getColor();
|
||||
|
||||
sideMenuVBox.setStyle(style);
|
||||
topHBox.setStyle(style);
|
||||
cemuTextField.setFocusColor(Color.valueOf(getColor()));
|
||||
romTextField.setFocusColor(Color.valueOf(getColor()));
|
||||
|
||||
settingsBtn.setStyle("-fx-text-fill: BLACK;");
|
||||
addBtn.setStyle("-fx-text-fill: BLACK;");
|
||||
playBtn.setStyle("-fx-text-fill: BLACK;");
|
||||
cemuTFBtn.setStyle(btnStyleBlack);
|
||||
romTFBtn.setStyle(btnStyleBlack);
|
||||
aboutBtn.setStyle(btnStyleBlack);
|
||||
playBtn.setStyle(btnStyleBlack);
|
||||
}
|
||||
|
||||
void saveSettings(){
|
||||
System.out.println("saving Settings ...");
|
||||
OutputStream outputStream; //new output-stream
|
||||
try {
|
||||
props.setProperty("cemuPath", getCemuPath());
|
||||
props.setProperty("romPath", getRomPath());
|
||||
props.setProperty("color", getColor());
|
||||
props.setProperty("fullscreen", String.valueOf(isFullscreen()));
|
||||
if(System.getProperty("os.name").equals("Linux")){
|
||||
outputStream = new FileOutputStream(fileLinux);
|
||||
}else{
|
||||
outputStream = new FileOutputStream(fileWin);
|
||||
}
|
||||
props.storeToXML(outputStream, "cemu_UI settings"); //writes new .xml
|
||||
outputStream.close();
|
||||
System.out.println("done!");
|
||||
} catch (IOException e) {
|
||||
// if(firststart == false){
|
||||
// showErrorMsg(errorLoad, e);
|
||||
e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
void loadSettings(){
|
||||
System.out.print("loading settings ...");
|
||||
InputStream inputStream;
|
||||
try {
|
||||
if(System.getProperty("os.name").equals("Linux")){
|
||||
inputStream = new FileInputStream(fileLinux);
|
||||
}else{
|
||||
inputStream = new FileInputStream(fileWin);
|
||||
}
|
||||
props.loadFromXML(inputStream); //new input-stream from .xml
|
||||
setCemuPath(props.getProperty("cemuPath"));
|
||||
setRomPath(props.getProperty("romPath"));
|
||||
setColor(props.getProperty("color"));
|
||||
setFullscreen(Boolean.parseBoolean(props.getProperty("fullscreen")));
|
||||
inputStream.close();
|
||||
System.out.println("done!");
|
||||
} catch (IOException e) {
|
||||
// if(firststart == false){
|
||||
// showErrorMsg(errorSave, e);
|
||||
e.printStackTrace();
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void sideMenuSlideIn(){
|
||||
sideMenuVBox.setVisible(true);
|
||||
//fade in from 40% to 100% opacity in 400ms
|
||||
FadeTransition fadeTransition = new FadeTransition(Duration.millis(400), sideMenuVBox);
|
||||
fadeTransition.setFromValue(0.4);
|
||||
fadeTransition.setToValue(1.0);
|
||||
//slide in in 400ms
|
||||
TranslateTransition translateTransition = new TranslateTransition(Duration.millis(400), sideMenuVBox);
|
||||
translateTransition.setFromX(-150);
|
||||
translateTransition.setToX(0);
|
||||
//in case both animations are used (add (fadeTransition, translateTransition) in the second line under this command)
|
||||
ParallelTransition parallelTransition = new ParallelTransition();
|
||||
parallelTransition.getChildren().addAll(translateTransition);//(fadeTransition, translateTransition);
|
||||
parallelTransition.play();
|
||||
}
|
||||
|
||||
private void sideMenuSlideOut(){
|
||||
// sideMenuVBox.setVisible(false);
|
||||
//fade out from 100% to 40% opacity in 400ms
|
||||
FadeTransition fadeTransition = new FadeTransition(Duration.millis(400), sideMenuVBox);
|
||||
fadeTransition.setFromValue(1.0);
|
||||
fadeTransition.setToValue(0.4);
|
||||
//slide out in 400ms
|
||||
TranslateTransition translateTransition = new TranslateTransition(Duration.millis(400), sideMenuVBox);
|
||||
translateTransition.setFromX(0);
|
||||
translateTransition.setToX(-150);
|
||||
//in case both animations are used (add (fadeTransition, translateTransition) in the second line under this command)
|
||||
ParallelTransition parallelTransition = new ParallelTransition();
|
||||
parallelTransition.getChildren().addAll(translateTransition);//(fadeTransition, translateTransition);
|
||||
parallelTransition.play();
|
||||
}
|
||||
|
||||
private void playBtnSlideIn(){
|
||||
playBtn.setVisible(true);
|
||||
playTrue = true;
|
||||
TranslateTransition translateTransition = new TranslateTransition(Duration.millis(300), playBtn);
|
||||
translateTransition.setFromY(55);
|
||||
translateTransition.setToY(0);
|
||||
translateTransition.play();
|
||||
}
|
||||
|
||||
private void playBtnSlideOut(){
|
||||
playTrue = false;
|
||||
TranslateTransition translateTransition = new TranslateTransition(Duration.millis(300), playBtn);
|
||||
translateTransition.setFromY(0);
|
||||
translateTransition.setToY(56);
|
||||
translateTransition.play();
|
||||
}
|
||||
|
||||
private void editColor(String input){
|
||||
StringBuilder sb = new StringBuilder(input);
|
||||
sb.delete(0, 2);
|
||||
this.color = sb.toString();
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
private static BufferedImage resizeImage(BufferedImage originalImage, int type, int IMG_WIDTH, int IMG_HEIGHT) {
|
||||
BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type);
|
||||
Graphics2D g = resizedImage.createGraphics();
|
||||
g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null);
|
||||
g.dispose();
|
||||
|
||||
return resizedImage;
|
||||
}
|
||||
|
||||
public String getCemuPath() {
|
||||
return cemuPath;
|
||||
}
|
||||
|
||||
public void setCemuPath(String cemuPath) {
|
||||
this.cemuPath = cemuPath;
|
||||
}
|
||||
|
||||
public String getRomPath() {
|
||||
return romPath;
|
||||
}
|
||||
|
||||
public void setRomPath(String romPath) {
|
||||
this.romPath = romPath;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public int getxPos() {
|
||||
return xPos;
|
||||
}
|
||||
|
||||
public void setxPos(int xPos) {
|
||||
this.xPos = xPos;
|
||||
}
|
||||
|
||||
public int getyPos() {
|
||||
return yPos;
|
||||
}
|
||||
|
||||
public void setyPos(int yPos) {
|
||||
this.yPos = yPos;
|
||||
}
|
||||
|
||||
public int getxPosHelper() {
|
||||
return xPosHelper;
|
||||
}
|
||||
|
||||
public void setxPosHelper(int xPosHelper) {
|
||||
this.xPosHelper = xPosHelper;
|
||||
}
|
||||
|
||||
public boolean isFullscreen() {
|
||||
return fullscreen;
|
||||
}
|
||||
|
||||
public void setFullscreen(boolean fullscreen) {
|
||||
this.fullscreen = fullscreen;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
|
|
@ -0,0 +1,268 @@
|
|||
package application;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class dbController {
|
||||
|
||||
public dbController(MainWindowController m) {
|
||||
mainWindowController = m;
|
||||
}
|
||||
|
||||
private MainWindowController mainWindowController;
|
||||
private String DB_PATH;
|
||||
private String DB_PATH_games;
|
||||
private Connection connection = null;
|
||||
private Connection connectionGames = null;
|
||||
|
||||
public void main(){
|
||||
System.out.println("<==========starting loading sql==========>");
|
||||
loadRomDatabase();
|
||||
loadGamesDatabase();
|
||||
createRomDatabase();
|
||||
loadRomDirectory(mainWindowController.getRomPath());
|
||||
checkRemoveEntry();
|
||||
System.out.println("<==========finished loading sql==========>");
|
||||
}
|
||||
|
||||
private void loadRomDatabase(){
|
||||
if (System.getProperty("os.name").equals("Linux")) {
|
||||
DB_PATH = System.getProperty("user.home") + "/localRoms.db";
|
||||
}else{
|
||||
DB_PATH = System.getProperty("user.home") + "\\Documents\\cemu_UI" + "\\" + "localRoms.db";
|
||||
}
|
||||
try {
|
||||
// create a database connection
|
||||
connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH);
|
||||
connection.setAutoCommit(false); //AutoCommit to false -> manual commit is active
|
||||
} catch (SQLException e) {
|
||||
// if the error message is "out of memory", it probably means no database file is found
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
System.out.println("rom database loaded to driver manager");
|
||||
}
|
||||
|
||||
/**
|
||||
* this method is used to load the games database with additional informations about a game
|
||||
* it is used if a new game is added (automatic or manual)
|
||||
*/
|
||||
private void loadGamesDatabase(){
|
||||
if (System.getProperty("os.name").equals("Linux")) {
|
||||
DB_PATH_games = System.getProperty("user.home") + "/games.db";
|
||||
}else{
|
||||
DB_PATH_games = System.getProperty("user.home") + "\\Documents\\cemu_UI" + "\\" + "games.db";
|
||||
}
|
||||
try {
|
||||
// create a database connection
|
||||
connectionGames = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH_games);
|
||||
connectionGames.setAutoCommit(false); //AutoCommit to false -> manual commit is active
|
||||
} catch (SQLException e) {
|
||||
// if the error message is "out of memory", it probably means no database file is found
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
System.out.println("games database loaded successfull");
|
||||
}
|
||||
|
||||
void createRomDatabase() {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("create table if not exists local_roms (title, coverPath, romPath, titleID, productCode, region, lastPlayed, timePlayed)");
|
||||
stmt.close();
|
||||
connection.commit();
|
||||
} catch (SQLException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
void addRom(String title, String coverPath, String romPath, String titleID, String productCode, String region, String lastPlayed, String timePlayed) throws SQLException{
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("insert into local_roms values ('"+title+"','"+coverPath+"','"+romPath+"','"+titleID+"','"+productCode+"','"+region+"','"+lastPlayed+"','"+timePlayed+"')");
|
||||
connection.commit();
|
||||
stmt.close();
|
||||
System.out.println("added \""+title+"\" to databsae");
|
||||
}
|
||||
|
||||
void removeRom(String titleID) throws SQLException{
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("delete from local_roms where titleID = '"+titleID+"'");
|
||||
connection.commit();
|
||||
stmt.close();
|
||||
System.out.println("removed \""+titleID+"\" from databsae");
|
||||
}
|
||||
|
||||
//load all rom's on startup to the UI
|
||||
void loadRoms(){
|
||||
System.out.println("loading all rom's on startup to mwc ...");
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms");
|
||||
while (rs.next()) {
|
||||
mainWindowController.addGame(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4));
|
||||
}
|
||||
stmt.close();
|
||||
rs.close();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//load one single rom after manual adding one
|
||||
void loadSingleRom(String titleID){
|
||||
System.out.println("loading a single rom (ID: "+titleID+") to mwc ...");
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms where titleID = '"+titleID+"'");
|
||||
while (rs.next()) {
|
||||
mainWindowController.addGame(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4));
|
||||
}
|
||||
stmt.close();
|
||||
rs.close();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//get all files with .rpx TODO add other formats
|
||||
void loadRomDirectory(String directory){
|
||||
File dir = new File(directory);
|
||||
String[] extensions = new String[] { "rpx", "jsp" };
|
||||
File pictureCache;
|
||||
String coverPath;
|
||||
|
||||
if(System.getProperty("os.name").equals("Linux")){
|
||||
pictureCache = mainWindowController.pictureCacheLinux;
|
||||
}else{
|
||||
pictureCache = mainWindowController.pictureCacheWin;
|
||||
}
|
||||
|
||||
try {
|
||||
Statement stmt = connectionGames.createStatement();
|
||||
System.out.println("Getting all .rpx files in " + dir.getCanonicalPath()+" including those in subdirectories \n");
|
||||
List<File> files = (List<File>) FileUtils.listFiles(dir, extensions, true);
|
||||
for (File file : files) {
|
||||
File appFile = new File(file.getParent()+"\\app.xml");
|
||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||
Document document = documentBuilder.parse(appFile);
|
||||
String title_ID = document.getElementsByTagName("title_id").item(0).getTextContent();
|
||||
title_ID = title_ID.substring(0, 8) + "-" + title_ID.substring(8, title_ID.length());
|
||||
System.out.println("Name: "+file.getName()+"; Title ID: "+title_ID);
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM games WHERE TitleID = '"+title_ID+"';");
|
||||
while (rs.next()) {
|
||||
System.out.print(rs.getString(2));
|
||||
if (checkEntry(rs.getString(2))) {
|
||||
System.out.println(": game already in database");
|
||||
}else{
|
||||
System.out.println(": add game");
|
||||
System.out.println("adding cover to cache ...");
|
||||
|
||||
BufferedImage originalImage = ImageIO.read(new URL(rs.getString(6)));//change path to where file is located
|
||||
int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType();
|
||||
BufferedImage resizeImagePNG = resizeImage(originalImage, type, 400, 600);
|
||||
ImageIO.write(resizeImagePNG, "png", new File(pictureCache+"\\"+rs.getString(3)+".png")); //change path where you want it saved
|
||||
coverPath = pictureCache+"\\"+rs.getString(3)+".png";
|
||||
|
||||
addRom(rs.getString(2), coverPath, file.getCanonicalPath(), rs.getString(1), rs.getString(3), rs.getString(5),"","");
|
||||
}
|
||||
}
|
||||
System.out.println("");
|
||||
}
|
||||
} catch (IOException | SQLException | ParserConfigurationException | SAXException e) {
|
||||
System.out.println("Ups something went wrong!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkEntry(String title) throws SQLException{
|
||||
Statement stmt = connection.createStatement();
|
||||
boolean check = false;
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms WHERE title = '"+title+"';");
|
||||
while (rs.next()) {
|
||||
check = true;
|
||||
}
|
||||
return check;
|
||||
}
|
||||
|
||||
private void checkRemoveEntry() {
|
||||
// TODO needs to be implemented!
|
||||
System.out.println("check if entry removed not done yet!");
|
||||
}
|
||||
|
||||
private static BufferedImage resizeImage(BufferedImage originalImage, int type, int IMG_WIDTH, int IMG_HEIGHT) {
|
||||
BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type);
|
||||
Graphics2D g = resizedImage.createGraphics();
|
||||
g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null);
|
||||
g.dispose();
|
||||
|
||||
return resizedImage;
|
||||
}
|
||||
|
||||
void setLastPlayed(String titleID){
|
||||
try{
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE local_roms SET lastPlayed=date('now') WHERE titleID = '"+titleID+"';");
|
||||
connection.commit();
|
||||
stmt.close();
|
||||
}catch(SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
String getLastPlayed(String titleID){
|
||||
String lastPlayed = null;
|
||||
try{
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT lastPlayed FROM local_roms WHERE titleID = '"+titleID+"';" );
|
||||
lastPlayed = rs.getString(1);
|
||||
stmt.close();
|
||||
rs.close();
|
||||
}catch(SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return lastPlayed;
|
||||
}
|
||||
|
||||
void setTimePlayed(String timePlayed, String titleID){
|
||||
try{
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE local_roms SET timePlayed='' WHERE titleID = '"+titleID+"';");
|
||||
connection.commit();
|
||||
stmt.close();
|
||||
}catch(SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
String getTimePlayed(String titleID){
|
||||
String timePlayed = null;
|
||||
try{
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT timePlayed FROM local_roms WHERE titleID = '"+titleID+"';" );
|
||||
timePlayed = rs.getString(4);
|
||||
stmt.close();
|
||||
rs.close();
|
||||
}catch(SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return timePlayed;
|
||||
}
|
||||
|
||||
}
|
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 15 KiB |