rlease 0.3.3 #7
|
@ -953,85 +953,6 @@ public class MainWindowController {
|
|||
LOGGER.info("successfully edited " + titleID + ", new name is \"" + title + "\"");
|
||||
}
|
||||
|
||||
/**
|
||||
* add game to games (ArrayList) 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 : game ID
|
||||
*/
|
||||
public void addGame(String title, String coverPath, String romPath, String titleID){
|
||||
UIROMDataType uiROMElement = new UIROMDataType(romPath, titleID, title, coverPath, gameContextMenu);
|
||||
|
||||
uiROMElement.getButton().addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
|
||||
@Override
|
||||
public void handle(MouseEvent event) {
|
||||
LOGGER.info("selected: " + title + "; ID: " + titleID);
|
||||
// getting the selected game index by comparing event.getSource() with games.get(i).getButton()
|
||||
for (int i = 0; i < games.size(); i++) {
|
||||
if (games.get(i).getButton() == event.getSource()) {
|
||||
selectedUIDataIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
gameExecutePath = romPath;
|
||||
selectedGameTitleID = titleID;
|
||||
selectedGameTitle = title;
|
||||
|
||||
// underlining selected Label
|
||||
lastGameLabel.setStyle("-fx-underline: false;");
|
||||
games.get(selectedUIDataIndex).getLabel().setStyle("-fx-underline: true;");
|
||||
lastGameLabel = games.get(selectedUIDataIndex).getLabel();
|
||||
|
||||
// setting last played, if lastPlayed is empty game was never played before, else set correct date
|
||||
if (dbController.getLastPlayed(titleID).equals("") || dbController.getLastPlayed(titleID).equals(null)) {
|
||||
lastTimePlayedBtn.setText(lastPlayed + never);
|
||||
totalPlaytimeBtn.setText(dbController.getTotalPlaytime(titleID) + " min");
|
||||
} else {
|
||||
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
int tToday = Integer.parseInt(dtf.format(LocalDate.now()).replaceAll("-", ""));
|
||||
int tYesterday = Integer.parseInt(dtf.format(LocalDate.now().minusDays(1)).replaceAll("-", ""));
|
||||
int tLastPlayedDay = Integer.parseInt(dbController.getLastPlayed(titleID).replaceAll("-", ""));
|
||||
|
||||
if (tLastPlayedDay == tToday) {
|
||||
lastTimePlayedBtn.setText(lastPlayed + today);
|
||||
} else if (tLastPlayedDay == tYesterday) {
|
||||
lastTimePlayedBtn.setText(lastPlayed + yesterday);
|
||||
} else {
|
||||
lastTimePlayedBtn.setText(lastPlayed + dbController.getLastPlayed(titleID));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* setting total playtime, if total playtime > 60 minutes, format is "x hours x
|
||||
* minutes" (x h x min), else only minutes are showed
|
||||
*/
|
||||
if (Integer.parseInt(dbController.getTotalPlaytime(titleID)) > 60) {
|
||||
int hoursPlayed = (int) Math.floor(Integer.parseInt(dbController.getTotalPlaytime(titleID)) / 60);
|
||||
int minutesPlayed = Integer.parseInt(dbController.getTotalPlaytime(titleID)) - 60 * hoursPlayed;
|
||||
totalPlaytimeBtn.setText(hoursPlayed + " h " + minutesPlayed + " min");
|
||||
} else {
|
||||
totalPlaytimeBtn.setText(dbController.getTotalPlaytime(titleID) + " min");
|
||||
}
|
||||
|
||||
if (!playTrue) {
|
||||
playBtnSlideIn();
|
||||
}
|
||||
if (menuTrue) {
|
||||
sideMenuSlideOut();
|
||||
burgerTask.setRate(-1.0);
|
||||
burgerTask.play();
|
||||
menuTrue = false;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// add uiROMElement to games list
|
||||
games.add(uiROMElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* add the context menu and button action for all games
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue