2017-04-19 02:15:44 +02:00
/ * *
* cemu_UI
*
* Copyright 2017 < @Seil0 >
*
* " 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-03-28 17:40:01 +02:00
package application ;
import java.io.IOException ;
import javafx.application.Platform ;
public class playGame extends Thread {
MainWindowController mainWindowController ;
dbController dbController ;
public playGame ( MainWindowController m , dbController db ) {
mainWindowController = m ;
dbController = db ;
}
public void run ( ) {
String selectedGameTitleID = mainWindowController . getSelectedGameTitleID ( ) ;
2017-04-08 10:52:01 +02:00
String executeComand ;
2017-03-28 17:40:01 +02:00
long startTime ;
long endTime ;
int timePlayedNow ;
int timePlayed ;
Process p ;
Platform . runLater ( ( ) - > {
mainWindowController . main . primaryStage . setIconified ( true ) ;
} ) ;
startTime = System . currentTimeMillis ( ) ;
try {
if ( mainWindowController . isFullscreen ( ) ) {
2017-04-08 10:52:01 +02:00
if ( System . getProperty ( " os.name " ) . equals ( " Linux " ) ) {
executeComand = " wine " + mainWindowController . getCemuPath ( ) + " /Cemu.exe -f -g \" " + mainWindowController . getGameExecutePath ( ) + " \" " ;
} else {
executeComand = mainWindowController . getCemuPath ( ) + " \\ Cemu.exe -f -g \" " + mainWindowController . getGameExecutePath ( ) + " \" " ;
}
2017-03-28 17:40:01 +02:00
} else {
2017-04-08 10:52:01 +02:00
if ( System . getProperty ( " os.name " ) . equals ( " Linux " ) ) {
executeComand = " wine " + mainWindowController . getCemuPath ( ) + " /Cemu.exe -g \" " + mainWindowController . getGameExecutePath ( ) + " \" " ;
} else {
executeComand = mainWindowController . getCemuPath ( ) + " \\ Cemu.exe -g \" " + mainWindowController . getGameExecutePath ( ) + " \" " ;
}
2017-03-28 17:40:01 +02:00
}
2017-04-08 10:52:01 +02:00
System . out . println ( executeComand ) ;
2017-03-28 17:40:01 +02:00
2017-04-08 10:52:01 +02:00
p = Runtime . getRuntime ( ) . exec ( executeComand ) ;
2017-03-28 17:40:01 +02:00
p . waitFor ( ) ;
endTime = System . currentTimeMillis ( ) ;
timePlayedNow = ( int ) Math . floor ( ( ( endTime - startTime ) / 1000 / 60 ) ) ;
timePlayed = Integer . parseInt ( dbController . getTimePlayed ( selectedGameTitleID ) ) + timePlayedNow ;
dbController . setTimePlayed ( Integer . toString ( timePlayed ) , selectedGameTitleID ) ;
Platform . runLater ( ( ) - > {
2017-04-06 12:00:36 +02:00
if ( Integer . parseInt ( dbController . getTimePlayed ( selectedGameTitleID ) ) > 60 ) {
int hoursPlayed = ( int ) Math . floor ( Integer . parseInt ( dbController . getTimePlayed ( selectedGameTitleID ) ) / 60 ) ;
int minutesPlayed = Integer . parseInt ( dbController . getTimePlayed ( selectedGameTitleID ) ) - 60 * hoursPlayed ;
mainWindowController . timePlayedBtn . setText ( hoursPlayed + " h " + minutesPlayed + " min " ) ;
} else {
mainWindowController . timePlayedBtn . setText ( dbController . getTimePlayed ( selectedGameTitleID ) + " min " ) ;
}
2017-03-28 17:40:01 +02:00
mainWindowController . main . primaryStage . setIconified ( false ) ;
} ) ;
2017-04-17 00:58:49 +02:00
// System.out.println(mainWindowController.getCemuPath()+"/mlc01/emulatorSave/"+);
//sync savegame with cloud service
if ( mainWindowController . isCloudSync ( ) ) {
mainWindowController . main . cloudController . sync ( mainWindowController . getCloudService ( ) , mainWindowController . getCemuPath ( ) ) ;
}
2017-03-28 17:40:01 +02:00
} catch ( IOException | InterruptedException e ) {
e . printStackTrace ( ) ;
}
}
}