2017-04-06 12:00:36 +02:00
/ * *
* cemu_UI
*
* Copyright 2017 < @Seil0 >
*
2017-04-19 02:15:44 +02:00
* " THE CHOCOLATE-WARE LICENSE " ( Revision 1 ) :
* As long as you retain this notice this software is licensed under the GNU GENERAL PUBLIC LICENSE Version 3 ,
* with the following additions :
* If we meet some day , and you think this stuff is worth it ,
* you can buy me a chocolate in return . - @Seil0
* ( license based in Beer - ware , see https : //fedoraproject.org/wiki/Licensing/Beerware )
2017-04-06 12:00:36 +02:00
*
* /
2017-03-23 13:44:21 +01:00
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 ;
2017-03-28 17:40:01 +02:00
import java.math.BigInteger ;
2017-03-23 13:44:21 +01:00
import java.sql.SQLException ;
2017-03-23 16:17:38 +01:00
import java.time.LocalDate ;
import java.time.format.DateTimeFormatter ;
2017-03-23 13:44:21 +01:00
import java.util.Optional ;
import java.util.Properties ;
2017-05-25 19:07:16 +02:00
2017-03-23 13:44:21 +01:00
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 ;
2017-05-25 19:07:16 +02:00
2017-03-23 13:44:21 +01:00
import javafx.animation.FadeTransition ;
import javafx.animation.ParallelTransition ;
import javafx.animation.TranslateTransition ;
2017-04-06 12:00:36 +02:00
import javafx.collections.FXCollections ;
import javafx.collections.ObservableList ;
2017-03-23 13:44:21 +01:00
import javafx.event.ActionEvent ;
import javafx.event.EventHandler ;
import javafx.fxml.FXML ;
2017-03-26 14:21:19 +02:00
import javafx.geometry.Insets ;
2017-03-23 13:44:21 +01:00
import javafx.scene.control.Alert ;
2017-03-26 14:21:19 +02:00
import javafx.scene.control.Alert.AlertType ;
2017-03-23 13:44:21 +01:00
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.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 ;
2017-03-26 14:21:19 +02:00
import javafx.scene.paint.Paint ;
2017-03-23 13:44:21 +01:00
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 ;
2017-03-25 15:18:45 +01:00
@FXML
private JFXButton reloadRomsBtn ;
2017-05-25 19:07:16 +02:00
@FXML
private JFXButton smmdbBtn ;
2017-03-23 13:44:21 +01:00
@FXML
private JFXButton cemuTFBtn ;
@FXML
private JFXButton romTFBtn ;
@FXML
private JFXButton playBtn ;
2017-03-23 16:17:38 +01:00
@FXML
2017-03-28 17:40:01 +02:00
JFXButton timePlayedBtn ;
2017-03-23 16:17:38 +01:00
@FXML
private JFXButton lastTimePlayedBtn ;
2017-03-23 13:44:21 +01:00
@FXML
private JFXHamburger menuHam ;
@FXML
private JFXTextField cemuTextField ;
@FXML
private JFXTextField romTextField ;
@FXML
private JFXColorPicker colorPicker ;
@FXML
private JFXToggleButton fullscreenToggleBtn ;
2017-04-17 00:58:49 +02:00
@FXML
private JFXToggleButton cloudSyncToggleBtn ;
2017-03-23 13:44:21 +01:00
@FXML
private AnchorPane settingsAnchorPane ;
2017-05-25 19:07:16 +02:00
@FXML
private AnchorPane smmdbAnchorPane ;
2017-03-23 13:44:21 +01:00
@FXML
private AnchorPane gamesAnchorPane ;
@FXML
private ScrollPane scrollPaneMain ;
@FXML
private VBox sideMenuVBox ;
@FXML
private HBox topHBox ;
2017-03-28 17:40:01 +02:00
Main main ;
dbController dbController ;
playGame playGame ;
2017-03-23 13:44:21 +01:00
private boolean menuTrue = false ;
private boolean settingsTrue = false ;
private boolean playTrue = false ;
private boolean fullscreen ;
2017-04-17 00:58:49 +02:00
private boolean cloudSync ;
2017-06-01 16:21:24 +02:00
private String cloudService = " " ; //set cloud provider (at the moment only GoogleDrive, Dropbox is planed)
2017-03-23 13:44:21 +01:00
private String cemuPath ;
private String romPath ;
private String gameExecutePath ;
private String selectedGameTitleID ;
2017-03-23 16:17:38 +01:00
private String selectedGameTitle ;
2017-03-23 13:44:21 +01:00
private String color ;
2017-05-01 16:46:00 +02:00
private String version = " 0.1.5 " ;
2017-06-01 17:44:05 +02:00
private String buildNumber = " 021 " ;
2017-05-01 16:46:00 +02:00
private String versionName = " Gusty Garden " ;
2017-03-23 13:44:21 +01:00
private int xPos = - 200 ;
private int yPos = 17 ;
private int xPosHelper ;
2017-04-06 12:00:36 +02:00
private int selectedUIDataIndex ;
2017-03-23 13:44:21 +01:00
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 " ) ;
2017-04-06 12:00:36 +02:00
private ObservableList < uiDataType > games = FXCollections . observableArrayList ( ) ;
2017-03-23 13:44:21 +01:00
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 Label lastGameLabel = new Label ( ) ;
2017-06-01 16:21:24 +02:00
private ImageView add_circle_black = new ImageView ( new Image ( " resources/icons/ic_add_circle_black_24dp_1x.png " ) ) ;
private ImageView info_black = new ImageView ( new Image ( " resources/icons/ic_info_black_24dp_1x.png " ) ) ;
private ImageView settings_black = new ImageView ( new Image ( " resources/icons/ic_settings_black_24dp_1x.png " ) ) ;
private ImageView cached_black = new ImageView ( new Image ( " resources/icons/ic_cached_black_24dp_1x.png " ) ) ;
private ImageView smmdb_black = new ImageView ( new Image ( " resources/icons/ic_get_app_black_24dp_1x.png " ) ) ;
private ImageView add_circle_white = new ImageView ( new Image ( " resources/icons/ic_add_circle_white_24dp_1x.png " ) ) ;
private ImageView info_white = new ImageView ( new Image ( " resources/icons/ic_info_white_24dp_1x.png " ) ) ;
private ImageView settings_white = new ImageView ( new Image ( " resources/icons/ic_settings_white_24dp_1x.png " ) ) ;
private ImageView cached_white = new ImageView ( new Image ( " resources/icons/ic_cached_white_24dp_1x.png " ) ) ;
private ImageView smmdb_white = new ImageView ( new Image ( " resources/icons/ic_get_app_white_24dp_1x.png " ) ) ;
2017-03-23 13:44:21 +01:00
public void setMain ( Main main ) {
this . main = main ;
2017-03-25 15:18:45 +01:00
dbController = new dbController ( this ) ;
2017-03-23 13:44:21 +01:00
}
2017-03-28 17:40:01 +02:00
void initUI ( ) {
2017-03-23 13:44:21 +01:00
cemuTextField . setText ( cemuPath ) ;
romTextField . setText ( romPath ) ;
colorPicker . setValue ( Color . valueOf ( getColor ( ) ) ) ;
fullscreenToggleBtn . setSelected ( isFullscreen ( ) ) ;
2017-04-25 22:16:30 +02:00
cloudSyncToggleBtn . setSelected ( isCloudSync ( ) ) ;
2017-04-08 10:52:01 +02:00
edit . setDisable ( true ) ;
2017-05-25 19:07:16 +02:00
smmdbBtn . setDisable ( true ) ;
2017-03-23 13:44:21 +01:00
applyColor ( ) ;
}
void initActions ( ) {
2017-05-07 19:57:55 +02:00
System . out . println ( " initializing Actions... " ) ;
2017-03-23 13:44:21 +01:00
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 {
2017-03-25 15:18:45 +01:00
System . out . println ( " show edit window TODO! " ) ; //TODO
2017-03-23 13:44:21 +01:00
}
}
} ) ;
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 " ) ;
2017-03-28 17:40:01 +02:00
2017-03-23 13:44:21 +01:00
alert . initOwner ( main . primaryStage ) ;
alert . showAndWait ( ) ;
}
else {
2017-03-25 15:18:45 +01:00
Alert alert = new Alert ( AlertType . CONFIRMATION ) ;
alert . setTitle ( " remove " ) ;
alert . setHeaderText ( " cemu_UI " ) ;
alert . setContentText ( " Are you sure you want to delete " + selectedGameTitle + " ? " ) ;
alert . initOwner ( main . primaryStage ) ;
Optional < ButtonType > result = alert . showAndWait ( ) ;
if ( result . get ( ) = = ButtonType . OK ) {
try {
2017-04-06 12:00:36 +02:00
//remove all elements from gamesAnchorPane
for ( int i = 0 ; i < games . size ( ) ; i + + ) {
gamesAnchorPane . getChildren ( ) . remove ( games . get ( i ) . getVBox ( ) ) ;
}
//remove game from database
games . remove ( selectedUIDataIndex ) ;
2017-03-25 15:18:45 +01:00
dbController . removeRom ( selectedGameTitleID ) ;
2017-04-06 12:00:36 +02:00
gamesAnchorPane . getChildren ( ) . removeAll ( games ) ;
//reset position
xPos = - 200 ;
yPos = 17 ;
xPosHelper = 0 ;
//add all games to gamesAnchorPane
for ( int i = 0 ; i < games . size ( ) ; i + + ) {
generatePosition ( ) ;
games . get ( i ) . getVBox ( ) . setLayoutX ( getxPos ( ) ) ;
games . get ( i ) . getVBox ( ) . setLayoutY ( getyPos ( ) ) ;
gamesAnchorPane . getChildren ( ) . add ( games . get ( i ) . getVBox ( ) ) ;
}
} catch ( Exception e ) {
2017-03-25 15:18:45 +01:00
e . printStackTrace ( ) ;
}
}
2017-03-23 13:44:21 +01:00
}
}
} ) ;
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 " ) ;
2017-03-23 16:17:38 +01:00
updateAlert . setHeaderText ( " update " + selectedGameTitle ) ;
2017-03-25 15:18:45 +01:00
updateAlert . setContentText ( " pleas select the update root directory " ) ;
2017-03-23 13:44:21 +01:00
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... " ) ;
2017-03-23 16:17:38 +01:00
playBtn . setText ( " updating... " ) ;
playBtn . setDisable ( true ) ;
FileUtils . copyDirectory ( srcDir , destDir ) ; //TODO progress indicator
playBtn . setText ( " play " ) ;
playBtn . setDisable ( false ) ;
2017-03-23 13:44:21 +01:00
System . out . println ( " done! " ) ;
} catch ( IOException e ) {
e . printStackTrace ( ) ;
}
} else {
updatePath = null ;
}
}
}
} ) ;
addDLC . setOnAction ( new EventHandler < ActionEvent > ( ) {
@Override
public void handle ( ActionEvent event ) {
2017-03-26 14:21:19 +02:00
String titleID = selectedGameTitleID ;
String dlcPath ;
System . out . println ( " add DLC: " + selectedGameTitleID ) ;
if ( selectedGameTitleID = = null ) {
System . out . println ( " trying to add a dlc to null! null is not valid! " ) ;
Alert alert = new Alert ( AlertType . WARNING ) ;
alert . setTitle ( " add DLC " ) ;
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 a DLC to " + selectedGameTitle ) ;
updateAlert . setContentText ( " pleas select the DLC root 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 ) ;
dlcPath = selectedDirecroty . getAbsolutePath ( ) ;
String [ ] parts = titleID . split ( " - " ) ; //split string into 2 parts at "-"
File srcDir = new File ( dlcPath ) ;
File destDir = new File ( cemuPath + " \\ mlc01 \\ usr \\ title \\ " + parts [ 0 ] + " \\ " + parts [ 1 ] + " \\ aoc " ) ;
System . out . println ( dlcPath ) ;
System . out . println ( destDir . toString ( ) ) ;
if ( destDir . exists ( ) ! = true ) {
destDir . mkdir ( ) ;
}
try {
System . out . println ( " copying files... " ) ;
playBtn . setText ( " copying files... " ) ;
playBtn . setDisable ( true ) ;
FileUtils . copyDirectory ( srcDir , destDir ) ; //TODO progress indicator
playBtn . setText ( " play " ) ;
playBtn . setDisable ( false ) ;
System . out . println ( " done! " ) ;
} catch ( IOException e ) {
e . printStackTrace ( ) ;
}
} else {
dlcPath = null ;
}
}
2017-03-23 13:44:21 +01:00
}
} ) ;
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 ( ) ;
}
}
} ) ;
2017-05-07 19:57:55 +02:00
System . out . println ( " initializing Actions done! " ) ;
2017-03-23 13:44:21 +01:00
}
@FXML
void detailsSlideoutBtnAction ( ActionEvent event ) {
playBtnSlideOut ( ) ;
}
@FXML
2017-03-25 15:18:45 +01:00
void aboutBtnAction ( ) {
Alert alert = new Alert ( AlertType . INFORMATION ) ;
alert . setTitle ( " about " ) ;
alert . setHeaderText ( " cemu_UI " ) ;
2017-05-01 16:46:00 +02:00
alert . setContentText ( " cemu_UI by @Seil0 \ nVersion: " + version + " ( " + buildNumber + " ) \" " + versionName + " \" \ nwww.kellerkinder.xyz " ) ;
2017-03-25 15:18:45 +01:00
alert . initOwner ( main . primaryStage ) ;
alert . showAndWait ( ) ;
2017-03-23 16:17:38 +01:00
}
2017-03-23 13:44:21 +01:00
@FXML
void settingsBtnAction ( ActionEvent event ) {
if ( settingsTrue = = false ) {
settingsAnchorPane . setVisible ( true ) ;
settingsTrue = true ;
} else {
settingsAnchorPane . setVisible ( false ) ;
saveSettings ( ) ;
settingsTrue = false ;
}
}
@FXML
2017-03-25 15:18:45 +01:00
void reloadRomsBtnAction ( ) throws IOException {
2017-03-26 14:21:19 +02:00
reloadRomsBtn . setText ( " reloading... " ) ;
dbController . loadRomDirectory ( getRomPath ( ) ) ; //TODO own thread
2017-03-25 15:18:45 +01:00
Runtime . getRuntime ( ) . exec ( " java -jar cemu_UI.jar " ) ; //start again (preventing Bugs)
System . exit ( 0 ) ; //finishes itself
}
2017-05-25 19:07:16 +02:00
@FXML
void smmdbBtnAction ( ) {
System . out . println ( " yeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeehaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa " ) ;
}
2017-03-25 15:18:45 +01:00
@FXML
void playBtnAction ( ActionEvent event ) throws InterruptedException , IOException {
dbController . setLastPlayed ( selectedGameTitleID ) ;
2017-03-28 17:40:01 +02:00
playGame = new playGame ( this , dbController ) ;
2017-03-25 15:18:45 +01:00
2017-03-28 17:40:01 +02:00
playGame . start ( ) ;
2017-03-25 15:18:45 +01:00
}
@FXML
void timePlayedBtnAction ( ActionEvent event ) {
}
@FXML
void lastTimePlayedBtnAction ( ActionEvent event ) {
2017-03-23 13:44:21 +01:00
}
@FXML
void cemuTFBtnAction ( ActionEvent event ) {
2017-04-09 10:43:06 +02:00
File cemuDirectory = directoryChooser . showDialog ( main . primaryStage ) ;
2017-03-23 13:44:21 +01:00
if ( cemuDirectory = = null ) {
System . out . println ( " No Directory selected " ) ;
} else {
setCemuPath ( cemuDirectory . getAbsolutePath ( ) ) ;
saveSettings ( ) ;
cemuTextField . setText ( getCemuPath ( ) ) ;
try {
2017-04-06 23:20:43 +02:00
Runtime . getRuntime ( ) . exec ( " java -jar cemu_UI.jar " ) ; //start again
2017-03-23 13:44:21 +01:00
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 {
2017-04-06 23:20:43 +02:00
Runtime . getRuntime ( ) . exec ( " java -jar cemu_UI.jar " ) ; //start again
2017-03-23 13:44:21 +01:00
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 ( ) ) ;
2017-05-25 19:07:16 +02:00
saveSettings ( ) ;
2017-03-23 13:44:21 +01:00
}
@FXML
void romTextFieldAction ( ActionEvent event ) {
setRomPath ( romTextField . getText ( ) ) ;
2017-05-25 19:07:16 +02:00
saveSettings ( ) ;
2017-03-23 13:44:21 +01:00
}
@FXML
void fullscreenToggleBtnAction ( ActionEvent event ) {
if ( fullscreen ) {
fullscreen = false ;
} else {
fullscreen = true ;
}
2017-05-25 19:07:16 +02:00
saveSettings ( ) ;
2017-04-17 00:58:49 +02:00
}
@FXML
void cloudSyncToggleBtnAction ( ActionEvent event ) {
if ( cloudSync ) {
cloudSync = false ;
} else {
2017-05-07 19:57:55 +02:00
Alert cloudWarningAlert = new Alert ( AlertType . CONFIRMATION ) ; //new alert with file-chooser
cloudWarningAlert . setTitle ( " cemu_UI " ) ;
cloudWarningAlert . setHeaderText ( " activate cloud savegame sync (beta) " ) ;
cloudWarningAlert . setContentText ( " You just activate the cloud savegame sync function of cemu_UI which is currently in beta. Are you sure you want to do this? " ) ;
cloudWarningAlert . initOwner ( main . primaryStage ) ;
Optional < ButtonType > coverResult = cloudWarningAlert . showAndWait ( ) ;
if ( coverResult . get ( ) = = ButtonType . OK ) {
cloudSync = true ;
2017-05-25 19:07:16 +02:00
//TODO rework for other cloud services
cloudService = " GoogleDrive " ;
2017-05-07 19:57:55 +02:00
main . cloudController . initializeConnection ( getCloudService ( ) , getCemuPath ( ) ) ;
main . cloudController . sync ( getCloudService ( ) , getCemuPath ( ) ) ;
} else {
cloudSyncToggleBtn . setSelected ( false ) ;
}
2017-04-17 00:58:49 +02:00
}
2017-05-25 19:07:16 +02:00
saveSettings ( ) ;
2017-03-23 13:44:21 +01:00
}
@FXML
void colorPickerAction ( ActionEvent event ) {
editColor ( colorPicker . getValue ( ) . toString ( ) ) ;
applyColor ( ) ;
}
@FXML
void addBtnAction ( ActionEvent event ) {
2017-03-26 14:21:19 +02:00
boolean exit = false ;
2017-03-23 13:44:21 +01:00
String romPath = null ;
String coverPath = null ;
String coverName = null ;
String title = null ;
String titleID = null ;
File pictureCache ;
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 ;
}
2017-03-26 14:21:19 +02:00
if ( exit = = false ) {
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 ;
}
2017-03-23 13:44:21 +01:00
}
if ( exit = = false ) {
Alert romAlert = new Alert ( AlertType . CONFIRMATION ) ; //new alert with file-chooser
romAlert . setTitle ( " cemu_UI " ) ;
romAlert . setHeaderText ( " add new Game " ) ;
2017-03-25 15:18:45 +01:00
romAlert . setContentText ( " Please select the .rpx file from the game you want to add. " ) ;
2017-03-23 13:44:21 +01:00
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 " ) ;
2017-03-25 15:18:45 +01:00
coverAlert . setContentText ( " Please select the cover for the game you want to add. " ) ;
2017-03-23 13:44:21 +01:00
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 ;
2017-03-26 14:21:19 +02:00
}
BufferedImage originalImage = ImageIO . read ( new File ( coverPath ) ) ; //load cover
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 ) ) ; //save image to pictureCache
coverPath = pictureCache + " \\ " + coverName ;
2017-03-23 13:44:21 +01:00
} catch ( IOException e ) {
System . out . println ( " Ops something went wrong! " ) ;
}
2017-03-26 14:21:19 +02:00
try {
dbController . addRom ( title , coverPath , romPath , titleID , " " , " " , " " , " 0 " ) ;
2017-03-23 13:44:21 +01:00
dbController . loadSingleRom ( titleID ) ;
} catch ( SQLException e ) {
// Auto-generated catch block
2017-05-25 19:07:16 +02:00
System . out . println ( " Oops, something went wrong! Error during adding a game. " ) ;
2017-03-23 13:44:21 +01:00
e . printStackTrace ( ) ;
}
}
}
2017-05-25 19:07:16 +02:00
/ * *
* add game to the program and initialize all needed actions ( start , time stamps , titleID )
* @param title : game title
* @param coverPath : path to cover ( cache )
* @param romPath : path to rom file ( . rpx )
* @param titleID : rom ID
* /
2017-03-23 13:44:21 +01:00
void addGame ( String title , String coverPath , String romPath , String titleID ) {
2017-03-26 14:21:19 +02:00
ImageView imageView = new ImageView ( ) ;
2017-03-23 16:17:38 +01:00
Label gameTitleLabel = new Label ( title ) ;
File coverFile = new File ( coverPath ) ;
2017-03-23 13:44:21 +01:00
VBox VBox = new VBox ( ) ;
JFXButton gameBtn = new JFXButton ( ) ;
2017-03-23 16:17:38 +01:00
Image coverImage = new Image ( coverFile . toURI ( ) . toString ( ) ) ;
2017-03-23 13:44:21 +01:00
generatePosition ( ) ;
2017-04-06 12:00:36 +02:00
VBox . setLayoutX ( getxPos ( ) ) ;
VBox . setLayoutY ( getyPos ( ) ) ;
VBox . getChildren ( ) . addAll ( gameTitleLabel , gameBtn ) ;
2017-03-23 16:17:38 +01:00
gameTitleLabel . setMaxWidth ( 200 ) ;
2017-03-26 14:21:19 +02:00
gameTitleLabel . setPadding ( new Insets ( 0 , 0 , 0 , 8 ) ) ;
2017-04-06 12:00:36 +02:00
gameTitleLabel . setFont ( Font . font ( " System " , FontWeight . BOLD , 14 ) ) ;
2017-03-23 16:17:38 +01:00
imageView . setImage ( coverImage ) ;
2017-03-23 13:44:21 +01:00
imageView . setFitHeight ( 300 ) ;
imageView . setFitWidth ( 200 ) ;
gameBtn . setGraphic ( imageView ) ;
2017-03-26 14:21:19 +02:00
gameBtn . setContextMenu ( gameContextMenu ) ;
gameBtn . setStyle ( " -fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 3); " ) ;
2017-03-23 13:44:21 +01:00
gameBtn . addEventHandler ( MouseEvent . MOUSE_CLICKED , new EventHandler < MouseEvent > ( ) {
@Override
public void handle ( MouseEvent event ) {
System . out . println ( " selected: " + title + " ; ID: " + titleID ) ;
2017-03-23 16:17:38 +01:00
2017-05-25 19:07:16 +02:00
//getting the selected game index by comparing event.getSource() with games.get(i).getButton()
2017-04-06 12:00:36 +02:00
for ( int i = 0 ; i < games . size ( ) ; i + + ) {
if ( games . get ( i ) . getButton ( ) = = event . getSource ( ) ) {
selectedUIDataIndex = i ;
}
}
2017-03-23 13:44:21 +01:00
gameExecutePath = romPath ;
selectedGameTitleID = titleID ;
2017-03-23 16:17:38 +01:00
selectedGameTitle = title ;
2017-03-23 13:44:21 +01:00
lastGameLabel . setStyle ( " -fx-underline: false; " ) ;
2017-04-06 12:00:36 +02:00
games . get ( selectedUIDataIndex ) . getLabel ( ) . setStyle ( " -fx-underline: true; " ) ;
lastGameLabel = games . get ( selectedUIDataIndex ) . getLabel ( ) ;
2017-05-25 19:07:16 +02:00
//setting last played
2017-03-23 16:17:38 +01:00
if ( dbController . getLastPlayed ( titleID ) . equals ( " " ) | | dbController . getLastPlayed ( titleID ) . equals ( null ) ) {
lastTimePlayedBtn . setText ( " Last played, never " ) ;
2017-03-25 15:18:45 +01:00
timePlayedBtn . setText ( dbController . getTimePlayed ( titleID ) + " min " ) ;
2017-03-23 16:17:38 +01:00
} else {
DateTimeFormatter dtf = DateTimeFormatter . ofPattern ( " yyyy-MM-dd " ) ;
2017-04-06 12:00:36 +02:00
int today = Integer . parseInt ( dtf . format ( LocalDate . now ( ) ) . replaceAll ( " - " , " " ) ) ;
int yesterday = Integer . parseInt ( dtf . format ( LocalDate . now ( ) . minusDays ( 1 ) ) . replaceAll ( " - " , " " ) ) ;
int lastday = Integer . parseInt ( dbController . getLastPlayed ( titleID ) . replaceAll ( " - " , " " ) ) ;
2017-03-23 16:17:38 +01:00
2017-04-06 12:00:36 +02:00
if ( today = = lastday ) {
2017-03-23 16:17:38 +01:00
lastTimePlayedBtn . setText ( " Last played, today " ) ;
2017-04-06 12:00:36 +02:00
} else if ( yesterday = = lastday ) {
2017-03-23 16:17:38 +01:00
lastTimePlayedBtn . setText ( " Last played, yesterday " ) ;
} else {
lastTimePlayedBtn . setText ( " Last played, " + dbController . getLastPlayed ( titleID ) ) ;
}
2017-03-28 17:40:01 +02:00
if ( Integer . parseInt ( dbController . getTimePlayed ( titleID ) ) > 60 ) {
int hoursPlayed = ( int ) Math . floor ( Integer . parseInt ( dbController . getTimePlayed ( titleID ) ) / 60 ) ;
int minutesPlayed = Integer . parseInt ( dbController . getTimePlayed ( titleID ) ) - 60 * hoursPlayed ;
timePlayedBtn . setText ( hoursPlayed + " h " + minutesPlayed + " min " ) ;
} else {
2017-03-25 15:18:45 +01:00
timePlayedBtn . setText ( dbController . getTimePlayed ( titleID ) + " min " ) ;
2017-03-28 17:40:01 +02:00
}
2017-03-23 16:17:38 +01:00
}
2017-05-25 19:07:16 +02:00
if ( ! playTrue ) {
2017-03-25 15:18:45 +01:00
playBtnSlideIn ( ) ;
2017-03-23 13:44:21 +01:00
}
2017-05-25 19:07:16 +02:00
if ( menuTrue ) {
sideMenuSlideOut ( ) ;
}
2017-03-23 13:44:21 +01:00
}
} ) ;
2017-04-06 12:00:36 +02:00
games . add ( new uiDataType ( VBox , gameTitleLabel , gameBtn , titleID , romPath ) ) ;
}
2017-05-25 19:07:16 +02:00
//add all games to the UI (only called on startup)
2017-04-06 12:00:36 +02:00
void addUIData ( ) {
for ( int i = 0 ; i < games . size ( ) ; i + + ) {
gamesAnchorPane . getChildren ( ) . add ( games . get ( i ) . getVBox ( ) ) ;
}
2017-03-23 13:44:21 +01:00
}
2017-04-17 00:58:49 +02:00
//TODO xPosHelper based on window with
2017-03-23 13:44:21 +01:00
private void generatePosition ( ) {
2017-04-17 00:58:49 +02:00
// System.out.println(main.primaryStage.getWidth());
2017-03-23 13:44:21 +01:00
if ( xPosHelper = = 4 ) {
xPos = 17 ;
yPos = yPos + 345 ;
xPosHelper = 1 ;
} else {
xPos = xPos + 217 ;
xPosHelper + + ;
}
}
private void applyColor ( ) {
2017-03-28 17:40:01 +02:00
String boxStyle = " -fx-background-color: # " + getColor ( ) + " ; " ;
2017-03-23 13:44:21 +01:00
String btnStyleBlack = " -fx-button-type: RAISED; -fx-background-color: # " + getColor ( ) + " ; -fx-text-fill: BLACK; " ;
2017-03-28 17:40:01 +02:00
String btnStyleWhite = " -fx-button-type: RAISED; -fx-background-color: # " + getColor ( ) + " ; -fx-text-fill: WHITE; " ;
BigInteger icolor = new BigInteger ( getColor ( ) , 16 ) ;
BigInteger ccolor = new BigInteger ( " 78909cff " , 16 ) ;
2017-03-23 13:44:21 +01:00
getColor ( ) ;
2017-03-28 17:40:01 +02:00
sideMenuVBox . setStyle ( boxStyle ) ;
topHBox . setStyle ( boxStyle ) ;
2017-03-23 13:44:21 +01:00
cemuTextField . setFocusColor ( Color . valueOf ( getColor ( ) ) ) ;
romTextField . setFocusColor ( Color . valueOf ( getColor ( ) ) ) ;
2017-03-28 17:40:01 +02:00
if ( icolor . compareTo ( ccolor ) = = - 1 ) {
aboutBtn . setStyle ( " -fx-text-fill: WHITE; " ) ;
settingsBtn . setStyle ( " -fx-text-fill: WHITE; " ) ;
addBtn . setStyle ( " -fx-text-fill: WHITE; " ) ;
reloadRomsBtn . setStyle ( " -fx-text-fill: WHITE; " ) ;
2017-05-25 19:07:16 +02:00
smmdbBtn . setStyle ( " -fx-text-fill: WHITE; " ) ;
2017-03-28 17:40:01 +02:00
playBtn . setStyle ( " -fx-text-fill: WHITE; -fx-font-family: Roboto Medium; " ) ;
cemuTFBtn . setStyle ( btnStyleWhite ) ;
romTFBtn . setStyle ( btnStyleWhite ) ;
playBtn . setStyle ( btnStyleWhite ) ;
aboutBtn . setGraphic ( info_white ) ;
settingsBtn . setGraphic ( settings_white ) ;
addBtn . setGraphic ( add_circle_white ) ;
reloadRomsBtn . setGraphic ( cached_white ) ;
2017-05-25 19:07:16 +02:00
smmdbBtn . setGraphic ( smmdb_white ) ;
2017-03-31 19:19:34 +02:00
menuHam . getStyleClass ( ) . add ( " jfx-hamburgerW " ) ;
2017-03-28 17:40:01 +02:00
} else {
aboutBtn . setStyle ( " -fx-text-fill: BLACK; " ) ;
settingsBtn . setStyle ( " -fx-text-fill: BLACK; " ) ;
addBtn . setStyle ( " -fx-text-fill: BLACK; " ) ;
reloadRomsBtn . setStyle ( " -fx-text-fill: BLACK; " ) ;
2017-05-25 19:07:16 +02:00
smmdbBtn . setStyle ( " -fx-text-fill: BLACK; " ) ;
2017-03-28 17:40:01 +02:00
playBtn . setStyle ( " -fx-text-fill: BLACK; -fx-font-family: Roboto Medium; " ) ;
cemuTFBtn . setStyle ( btnStyleBlack ) ;
romTFBtn . setStyle ( btnStyleBlack ) ;
playBtn . setStyle ( btnStyleBlack ) ;
aboutBtn . setGraphic ( info_black ) ;
settingsBtn . setGraphic ( settings_black ) ;
addBtn . setGraphic ( add_circle_black ) ;
reloadRomsBtn . setGraphic ( cached_black ) ;
2017-05-25 19:07:16 +02:00
smmdbBtn . setGraphic ( smmdb_black ) ;
2017-03-31 19:19:34 +02:00
menuHam . getStyleClass ( ) . add ( " jfx-hamburgerB " ) ;
2017-03-28 17:40:01 +02:00
}
2017-04-06 12:00:36 +02:00
for ( int i = 0 ; i < games . size ( ) ; i + + ) {
games . get ( i ) . getButton ( ) . setRipplerFill ( Paint . valueOf ( getColor ( ) ) ) ;
2017-03-26 14:21:19 +02:00
}
2017-03-23 13:44:21 +01:00
}
void saveSettings ( ) {
2017-03-23 16:17:38 +01:00
System . out . print ( " saving Settings... " ) ;
2017-03-23 13:44:21 +01:00
OutputStream outputStream ; //new output-stream
try {
props . setProperty ( " cemuPath " , getCemuPath ( ) ) ;
props . setProperty ( " romPath " , getRomPath ( ) ) ;
props . setProperty ( " color " , getColor ( ) ) ;
props . setProperty ( " fullscreen " , String . valueOf ( isFullscreen ( ) ) ) ;
2017-04-17 00:58:49 +02:00
props . setProperty ( " cloudSync " , String . valueOf ( cloudSync ) ) ;
2017-05-25 19:07:16 +02:00
props . setProperty ( " cloudService " , getCloudService ( ) ) ;
2017-04-17 00:58:49 +02:00
props . setProperty ( " folderID " , main . cloudController . getFolderID ( getCloudService ( ) ) ) ;
2017-03-23 13:44:21 +01:00
if ( System . getProperty ( " os.name " ) . equals ( " Linux " ) ) {
outputStream = new FileOutputStream ( fileLinux ) ;
} else {
outputStream = new FileOutputStream ( fileWin ) ;
}
2017-03-26 14:21:19 +02:00
props . storeToXML ( outputStream , " cemu_UI settings " ) ; //write new .xml
2017-03-23 13:44:21 +01:00
outputStream . close ( ) ;
System . out . println ( " done! " ) ;
} catch ( IOException e ) {
2017-03-26 14:21:19 +02:00
e . printStackTrace ( ) ;
2017-03-23 13:44:21 +01:00
}
}
void loadSettings ( ) {
2017-03-23 16:17:38 +01:00
System . out . print ( " loading settings... " ) ;
2017-03-23 13:44:21 +01:00
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 " ) ) ) ;
2017-04-17 00:58:49 +02:00
setCloudSync ( Boolean . parseBoolean ( props . getProperty ( " cloudSync " ) ) ) ;
2017-05-25 19:07:16 +02:00
setCloudService ( props . getProperty ( " cloudService " ) ) ;
2017-04-17 00:58:49 +02:00
main . cloudController . setFolderID ( props . getProperty ( " folderID " ) , getCloudService ( ) ) ;
2017-03-23 13:44:21 +01:00
inputStream . close ( ) ;
System . out . println ( " done! " ) ;
} catch ( IOException e ) {
2017-03-26 14:21:19 +02:00
e . printStackTrace ( ) ;
2017-03-23 13:44:21 +01:00
}
}
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 ) ;
2017-03-31 19:19:34 +02:00
translateTransition . setFromX ( - 175 ) ;
2017-03-23 13:44:21 +01:00
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 ) ;
2017-03-31 19:19:34 +02:00
translateTransition . setToX ( - 175 ) ;
2017-03-23 13:44:21 +01:00
//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 ) ;
2017-03-25 15:18:45 +01:00
lastTimePlayedBtn . setVisible ( true ) ;
timePlayedBtn . setVisible ( true ) ;
2017-03-23 13:44:21 +01:00
playTrue = true ;
2017-03-25 15:18:45 +01:00
TranslateTransition playBtnTransition = new TranslateTransition ( Duration . millis ( 300 ) , playBtn ) ;
playBtnTransition . setFromY ( 55 ) ;
playBtnTransition . setToY ( 0 ) ;
playBtnTransition . play ( ) ;
TranslateTransition lastTimePlayedBtnTransition = new TranslateTransition ( Duration . millis ( 300 ) , lastTimePlayedBtn ) ;
lastTimePlayedBtnTransition . setFromY ( 55 ) ;
lastTimePlayedBtnTransition . setToY ( 0 ) ;
lastTimePlayedBtnTransition . play ( ) ;
TranslateTransition timePlayedBtnTransition = new TranslateTransition ( Duration . millis ( 300 ) , timePlayedBtn ) ;
timePlayedBtnTransition . setFromY ( 55 ) ;
timePlayedBtnTransition . setToY ( 0 ) ;
timePlayedBtnTransition . play ( ) ;
2017-03-23 13:44:21 +01:00
}
2017-03-26 14:21:19 +02:00
void playBtnSlideOut ( ) {
2017-03-23 13:44:21 +01:00
playTrue = false ;
2017-03-25 15:18:45 +01:00
TranslateTransition playBtnTransition = new TranslateTransition ( Duration . millis ( 300 ) , playBtn ) ;
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 ) , timePlayedBtn ) ;
timePlayedBtnTransition . setFromY ( 0 ) ;
timePlayedBtnTransition . setToY ( 56 ) ;
timePlayedBtnTransition . play ( ) ;
2017-03-23 16:17:38 +01:00
}
2017-03-23 13:44:21 +01:00
private void editColor ( String input ) {
StringBuilder sb = new StringBuilder ( input ) ;
sb . delete ( 0 , 2 ) ;
this . color = sb . toString ( ) ;
saveSettings ( ) ;
}
2017-03-26 14:21:19 +02:00
private static BufferedImage resizeImage ( BufferedImage originalImage , int type , int imgWidth , int imgHeigth ) {
BufferedImage resizedImage = new BufferedImage ( imgWidth , imgHeigth , type ) ;
2017-03-23 13:44:21 +01:00
Graphics2D g = resizedImage . createGraphics ( ) ;
2017-03-26 14:21:19 +02:00
g . drawImage ( originalImage , 0 , 0 , imgWidth , imgHeigth , null ) ;
2017-03-23 13:44:21 +01:00
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 ;
}
2017-04-17 00:58:49 +02:00
public boolean isCloudSync ( ) {
return cloudSync ;
}
public void setCloudSync ( boolean cloudSync ) {
this . cloudSync = cloudSync ;
}
2017-03-28 17:40:01 +02:00
public String getGameExecutePath ( ) {
return gameExecutePath ;
}
public void setGameExecutePath ( String gameExecutePath ) {
this . gameExecutePath = gameExecutePath ;
}
public String getSelectedGameTitleID ( ) {
return selectedGameTitleID ;
}
public void setSelectedGameTitleID ( String selectedGameTitleID ) {
this . selectedGameTitleID = selectedGameTitleID ;
}
2017-04-17 00:58:49 +02:00
public String getCloudService ( ) {
return cloudService ;
}
public void setCloudService ( String cloudService ) {
this . cloudService = cloudService ;
}
2017-05-07 19:57:55 +02:00
public JFXButton getPlayBtn ( ) {
return playBtn ;
}
public void setPlayBtn ( JFXButton playBtn ) {
this . playBtn = playBtn ;
}
2017-03-23 13:44:21 +01:00
}