reworked time played in total

reworked time played in total, now better way wich helps with future
features and improvements, cleaned up
This commit is contained in:
Seil0
2017-03-28 17:40:01 +02:00
parent 6e270415b5
commit d2043bee0b
29 changed files with 148 additions and 69 deletions
+10 -9
View File
@@ -30,21 +30,22 @@
</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">
<JFXButton fx:id="aboutBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#aboutBtnAction" prefHeight="38.0" prefWidth="150.0" text="About" textAlignment="LEFT">
<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">
<JFXButton fx:id="settingsBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#settingsBtnAction" prefHeight="38.0" prefWidth="150.0" text="Settings" textAlignment="LEFT">
<font>
<Font name="System Bold" size="14.0" />
</font>
</JFXButton>
<JFXButton fx:id="reloadRomsBtn" onAction="#reloadRomsBtnAction" prefHeight="38.0" prefWidth="150.0" text="reload roms">
<JFXButton fx:id="addBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#addBtnAction" prefHeight="38.0" prefWidth="150.0" text="Add new Game" textAlignment="LEFT">
<font>
<Font name="System Bold" size="14.0" />
</font>
</JFXButton>
<JFXButton fx:id="reloadRomsBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#reloadRomsBtnAction" prefHeight="38.0" prefWidth="150.0" text="reload roms" textAlignment="LEFT">
<font>
<Font name="System Bold" size="14.0" />
</font>
@@ -79,8 +80,8 @@
<Font name="System Bold" size="14.0" />
</font>
</JFXButton>
<JFXButton fx:id="timePlayedBtn" buttonType="RAISED" layoutX="341.0" layoutY="588.0" onAction="#timePlayedBtnAction" prefHeight="32.0" prefWidth="100.0" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="516.5" AnchorPane.topAnchor="558.0">
<JFXButton fx:id="timePlayedBtn" buttonType="RAISED" maxHeight="32.0" minWidth="100.0" onAction="#timePlayedBtnAction" prefHeight="32.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="516.5" AnchorPane.topAnchor="558.0">
</JFXButton>
<JFXButton fx:id="lastTimePlayedBtn" buttonType="RAISED" maxHeight="32.0" onAction="#lastTimePlayedBtnAction" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="516.5" AnchorPane.topAnchor="558.0" />
<JFXButton fx:id="lastTimePlayedBtn" buttonType="RAISED" maxHeight="32.0" minWidth="100.0" onAction="#lastTimePlayedBtnAction" prefHeight="32.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="516.5" AnchorPane.topAnchor="558.0" />
</children>
</AnchorPane>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

+10 -9
View File
@@ -30,21 +30,22 @@
</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">
<JFXButton fx:id="aboutBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#aboutBtnAction" prefHeight="38.0" prefWidth="150.0" text="About" textAlignment="LEFT">
<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">
<JFXButton fx:id="settingsBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#settingsBtnAction" prefHeight="38.0" prefWidth="150.0" text="Settings" textAlignment="LEFT">
<font>
<Font name="System Bold" size="14.0" />
</font>
</JFXButton>
<JFXButton fx:id="reloadRomsBtn" onAction="#reloadRomsBtnAction" prefHeight="38.0" prefWidth="150.0" text="reload roms">
<JFXButton fx:id="addBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#addBtnAction" prefHeight="38.0" prefWidth="150.0" text="Add new Game" textAlignment="LEFT">
<font>
<Font name="System Bold" size="14.0" />
</font>
</JFXButton>
<JFXButton fx:id="reloadRomsBtn" alignment="TOP_LEFT" maxHeight="38.0" maxWidth="150.0" onAction="#reloadRomsBtnAction" prefHeight="38.0" prefWidth="150.0" text="reload roms" textAlignment="LEFT">
<font>
<Font name="System Bold" size="14.0" />
</font>
@@ -79,8 +80,8 @@
<Font name="System Bold" size="14.0" />
</font>
</JFXButton>
<JFXButton fx:id="timePlayedBtn" buttonType="RAISED" layoutX="341.0" layoutY="588.0" onAction="#timePlayedBtnAction" prefHeight="32.0" prefWidth="100.0" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="516.5" AnchorPane.topAnchor="558.0">
<JFXButton fx:id="timePlayedBtn" buttonType="RAISED" maxHeight="32.0" minWidth="100.0" onAction="#timePlayedBtnAction" prefHeight="32.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="516.5" AnchorPane.topAnchor="558.0">
</JFXButton>
<JFXButton fx:id="lastTimePlayedBtn" buttonType="RAISED" maxHeight="32.0" onAction="#lastTimePlayedBtnAction" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="516.5" AnchorPane.topAnchor="558.0" />
<JFXButton fx:id="lastTimePlayedBtn" buttonType="RAISED" maxHeight="32.0" minWidth="100.0" onAction="#lastTimePlayedBtnAction" prefHeight="32.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="516.5" AnchorPane.topAnchor="558.0" />
</children>
</AnchorPane>
+73 -47
View File
@@ -8,6 +8,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.sql.SQLException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
@@ -24,7 +25,6 @@ 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;
@@ -78,7 +78,7 @@ public class MainWindowController {
private JFXButton playBtn;
@FXML
private JFXButton timePlayedBtn;
JFXButton timePlayedBtn;
@FXML
private JFXButton lastTimePlayedBtn;
@@ -113,7 +113,9 @@ public class MainWindowController {
@FXML
private HBox topHBox;
private Main main;
Main main;
dbController dbController;
playGame playGame;
private boolean menuTrue = false;
private boolean settingsTrue = false;
private boolean playTrue = false;
@@ -146,10 +148,17 @@ public class MainWindowController {
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;
private ImageView add_circle_black = new ImageView(new Image("recources/icons/ic_add_circle_black_24dp_1x.png"));
private ImageView info_black = new ImageView(new Image("recources/icons/ic_info_black_24dp_1x.png"));
private ImageView settings_black = new ImageView(new Image("recources/icons/ic_settings_black_24dp_1x.png"));
private ImageView cached_black = new ImageView(new Image("recources/icons/ic_cached_black_24dp_1x.png"));
private ImageView add_circle_white = new ImageView(new Image("recources/icons/ic_add_circle_white_24dp_1x.png"));
private ImageView info_white = new ImageView(new Image("recources/icons/ic_info_white_24dp_1x.png"));
private ImageView settings_white = new ImageView(new Image("recources/icons/ic_settings_white_24dp_1x.png"));
private ImageView cached_white = new ImageView(new Image("recources/icons/ic_cached_white_24dp_1x.png"));
public void setMain(Main main) {
this.main = main;
@@ -220,6 +229,7 @@ public class MainWindowController {
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();
}
@@ -433,34 +443,9 @@ public class MainWindowController {
@FXML
void playBtnAction(ActionEvent event) throws InterruptedException, IOException{
dbController.setLastPlayed(selectedGameTitleID);
long startTime;
long endTime;
int timePlayedNow;
int timePlayed;
Process p;
playGame = new playGame(this,dbController);
main.primaryStage.setIconified(true);
startTime = System.currentTimeMillis();
try{
if(fullscreen){
p = Runtime.getRuntime().exec(getCemuPath()+"\\Cemu.exe -f -g \""+gameExecutePath+"\"");
}else{
p = Runtime.getRuntime().exec(getCemuPath()+"\\Cemu.exe -g \""+gameExecutePath+"\"");
}
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);
timePlayedBtn.setText(dbController.getTimePlayed(selectedGameTitleID)+ " min");
main.primaryStage.setIconified(false);
} catch (IOException e) {
e.printStackTrace();
}
playGame.start();
}
@FXML
@@ -696,7 +681,13 @@ public class MainWindowController {
}else{
lastTimePlayedBtn.setText("Last played, "+dbController.getLastPlayed(titleID));
}
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{
timePlayedBtn.setText(dbController.getTimePlayed(titleID)+ " min");
}
}
if(playTrue == false){
@@ -725,32 +716,51 @@ public class MainWindowController {
}
private void applyColor(){
String style = "-fx-background-color: #"+getColor()+";";
String boxStyle = "-fx-background-color: #"+getColor()+";";
String btnStyleBlack = "-fx-button-type: RAISED; -fx-background-color: #"+getColor()+"; -fx-text-fill: BLACK;";
String timeBtnStyle = "-fx-button-type: RAISED; -fx-background-color: #ffffff; -fx-text-fill: BLACK;";
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);
getColor();
sideMenuVBox.setStyle(style);
topHBox.setStyle(style);
sideMenuVBox.setStyle(boxStyle);
topHBox.setStyle(boxStyle);
cemuTextField.setFocusColor(Color.valueOf(getColor()));
romTextField.setFocusColor(Color.valueOf(getColor()));
aboutBtn.setStyle("-fx-text-fill: BLACK;");
settingsBtn.setStyle("-fx-text-fill: BLACK;");
addBtn.setStyle("-fx-text-fill: BLACK;");
reloadRomsBtn.setStyle("-fx-text-fill: BLACK;");
playBtn.setStyle("-fx-text-fill: BLACK;");
cemuTFBtn.setStyle(btnStyleBlack);
romTFBtn.setStyle(btnStyleBlack);
playBtn.setStyle(btnStyleBlack);
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;");
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);
}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;");
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);
}
for(int i=0; i<gameCover.size(); i++){
gameCover.get(i).setRipplerFill(Paint.valueOf(getColor()));
}
lastTimePlayedBtn.setStyle(timeBtnStyle);
timePlayedBtn.setStyle(timeBtnStyle);
}
void saveSettings(){
@@ -939,4 +949,20 @@ public class MainWindowController {
this.fullscreen = fullscreen;
}
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;
}
}
+51
View File
@@ -0,0 +1,51 @@
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();
long startTime;
long endTime;
int timePlayedNow;
int timePlayed;
Process p;
Platform.runLater(() -> {
mainWindowController.main.primaryStage.setIconified(true);
});
startTime = System.currentTimeMillis();
try{
if(mainWindowController.isFullscreen()){
p = Runtime.getRuntime().exec(mainWindowController.getCemuPath()+"\\Cemu.exe -f -g \""+mainWindowController.getGameExecutePath()+"\"");
}else{
p = Runtime.getRuntime().exec(mainWindowController.getCemuPath()+"\\Cemu.exe -g \""+mainWindowController.getGameExecutePath()+"\"");
}
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(() -> {
mainWindowController.timePlayedBtn.setText(dbController.getTimePlayed(selectedGameTitleID)+ " min");
mainWindowController.main.primaryStage.setIconified(false);
});
}catch (IOException | InterruptedException e){
e.printStackTrace();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B